diff --git a/packages/helium-admin-cli/src/fix-mobile-genesis-accounts.ts b/packages/helium-admin-cli/src/fix-mobile-genesis-accounts.ts deleted file mode 100644 index c76b6cf11..000000000 --- a/packages/helium-admin-cli/src/fix-mobile-genesis-accounts.ts +++ /dev/null @@ -1,47 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import yargs from "yargs/yargs"; -import { PublicKey } from "@solana/web3.js"; -import fs from "fs"; -import os from "os"; -import { init, keyToAssetKey, mobileInfoKey, rewardableEntityConfigKey } from "@helium/helium-entity-manager-sdk"; -import { daoKey } from "@helium/helium-sub-daos-sdk"; -import { HNT_MINT } from "@helium/spl-utils"; -import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes"; - -export async function run(args: any = process.argv) { - const yarg = yargs(args).options({ - wallet: { - alias: "k", - describe: "Anchor wallet keypair", - default: `${os.homedir()}/.config/solana/id.json`, - }, - url: { - alias: "u", - default: "http://127.0.0.1:8899", - describe: "The solana url", - }, - }); - const argv = await yarg.argv; - process.env.ANCHOR_WALLET = argv.wallet; - process.env.ANCHOR_PROVIDER_URL = argv.url; - anchor.setProvider(anchor.AnchorProvider.local(argv.url)); - const provider = anchor.getProvider() as anchor.AnchorProvider; - - const hemProgram = await init(provider); - - const rawAccs = await provider.connection.getProgramAccounts(hemProgram.programId, { - filters: [{ - dataSize: 113, - }] - }); - - for (const acc of rawAccs) { - if (acc.account.data.toString("hex").slice(0, 8) != "79c874d129f1e4b8") { - // this account has a bad discriminator, needs to be fixed - await hemProgram.methods.fixMobileGenesisAccountsV0().accounts({ - brokenAccount: acc.pubkey, - }).rpc({ skipPreflight: true }) - } - } - -} \ No newline at end of file diff --git a/programs/helium-entity-manager/src/instructions/fix_mobile_genesis_accounts_v0.rs b/programs/helium-entity-manager/src/instructions/fix_mobile_genesis_accounts_v0.rs deleted file mode 100644 index 20641d633..000000000 --- a/programs/helium-entity-manager/src/instructions/fix_mobile_genesis_accounts_v0.rs +++ /dev/null @@ -1,31 +0,0 @@ -use anchor_lang::{prelude::*, Discriminator}; -use std::str::FromStr; - -use crate::MobileHotspotInfoV0; - -#[derive(Accounts)] -pub struct FixMobileGenesisAccountsV0<'info> { - #[account(address = Pubkey::from_str("hprdnjkbziK8NqhThmAn5Gu4XqrBbctX8du4PfJdgvW").unwrap())] - pub authority: Signer<'info>, - /// CHECK: Raw data surgery requires this - #[account(mut)] - pub broken_account: AccountInfo<'info>, -} - -pub fn handler(ctx: Context) -> Result<()> { - let mut data = ctx.accounts.broken_account.data.borrow_mut(); - assert!(data.len() == 113); - let mut clone = vec![0; 113]; - clone.clone_from_slice(&data); - - // Check only 0s after the raw data - for byte in data[54..].iter() { - assert!(*byte == 0); - } - - // Move the data and add the discriminator - data[..8].copy_from_slice(&MobileHotspotInfoV0::discriminator()); - data[8..8 + 54].copy_from_slice(&clone[0..54]); - - Ok(()) -} diff --git a/programs/helium-entity-manager/src/instructions/mod.rs b/programs/helium-entity-manager/src/instructions/mod.rs index d84c2b9e4..978687f9b 100644 --- a/programs/helium-entity-manager/src/instructions/mod.rs +++ b/programs/helium-entity-manager/src/instructions/mod.rs @@ -1,6 +1,5 @@ pub mod approve_maker_v0; pub mod approve_program_v0; -pub mod fix_mobile_genesis_accounts_v0; pub mod initialize_data_only_v0; pub mod initialize_maker_v0; pub mod initialize_rewardable_entity_config_v0; @@ -29,7 +28,6 @@ pub mod update_rewardable_entity_config_v0; pub use approve_maker_v0::*; pub use approve_program_v0::*; -pub use fix_mobile_genesis_accounts_v0::*; pub use initialize_data_only_v0::*; pub use initialize_maker_v0::*; pub use initialize_rewardable_entity_config_v0::*; diff --git a/programs/helium-entity-manager/src/lib.rs b/programs/helium-entity-manager/src/lib.rs index c04d801bd..e607e20b0 100644 --- a/programs/helium-entity-manager/src/lib.rs +++ b/programs/helium-entity-manager/src/lib.rs @@ -175,10 +175,4 @@ pub mod helium_entity_manager { ) -> Result<()> { temp_update_iot_operations_fund_metadata::handler(ctx, args) } - - pub fn fix_mobile_genesis_accounts_v0<'info>( - ctx: Context<'_, '_, '_, 'info, FixMobileGenesisAccountsV0<'info>>, - ) -> Result<()> { - fix_mobile_genesis_accounts_v0::handler(ctx) - } }