Skip to content

Commit

Permalink
clean up migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
HardhatChad committed Jan 9, 2025
1 parent a2ead03 commit 1d24923
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions migration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ use steel::{AccountDeserialize, Discriminator};
#[tokio::main]
pub async fn main() {
// Create client
let signer = read_keypair_file("../migration-admin-key.json").unwrap();
let url = "https://mainnet.helius-rpc.com/?api-key=TODO";
let signer = read_keypair_file("~/.config/solana/id.json").unwrap(); // TODO
let url = "https://devnet.helius-rpc.com/?api-key=TODO"; // TODO Mainnet
let rpc = RpcClient::new_with_commitment(url.to_owned(), CommitmentConfig::confirmed());

// Fetch pools
let pool_filter = RpcFilterType::Memcmp(Memcmp::new_raw_bytes(
0,
Pool::discriminator().to_le_bytes().to_vec(),
));
let Ok(pools) = rpc
let pools = match rpc
.get_program_accounts_with_config(
&ore_pool_api::ID,
RpcProgramAccountsConfig {
Expand All @@ -38,10 +38,16 @@ pub async fn main() {
},
)
.await
else {
return;
{
Ok(pools) => {
println!("Num pools {:?}\n", pools.len());
pools
}
Err(e) => {
println!("Error fetching pools: {:?}", e);
return;
}
};
println!("Pools {:?}\n", pools.len());

// TODO Phase 1: Initialize migration
for pool in pools {
Expand All @@ -59,14 +65,18 @@ pub async fn main() {

// TODO: Phase 2: Migrate member balances
// for pool in pools {
// // Fetch pool
// let pool_account = Pool::try_from_bytes(&pool.1.data).unwrap();
// println!("Pool: {}", pool.0);

// // Fetch members of the given pool
// let member_filter = RpcFilterType::Memcmp(Memcmp::new_raw_bytes(
// 0,
// Member::discriminator().to_le_bytes().to_vec(),
// ));
// let pool_member_filter =
// RpcFilterType::Memcmp(Memcmp::new_raw_bytes(16, pool.0.to_bytes().to_vec()));
// let Ok(members) = rpc
// let members = match rpc
// .get_program_accounts_with_config(
// &ore_pool_api::ID,
// RpcProgramAccountsConfig {
Expand All @@ -81,13 +91,17 @@ pub async fn main() {
// },
// )
// .await
// else {
// return;
// };
// let pool_account = Pool::try_from_bytes(&pool.1.data).unwrap();
// println!("Pool: {}", pool.0);
// println!("Expected members: {}", pool_account.total_members);
// println!("Actual members: {}\n", members.len());
// {
// Ok(members) => {
// println!("Expected members: {}", pool_account.total_members);
// println!("Actual members: {}\n", members.len());
// members
// }
// Err(e) => {
// println!("Error fetching members: {:?}", e);
// return;
// }
// };

// // Migrate each member balance
// for member in members {
Expand All @@ -98,7 +112,9 @@ pub async fn main() {
// let hash = rpc.get_latest_blockhash().await.unwrap();
// let mut tx = Transaction::new_with_payer(final_ixs.as_slice(), Some(&signer.pubkey()));
// tx.sign(&[&signer], hash);
// rpc.send_transaction(&tx).await.unwrap();
// println!("Migrate member balance: {:?}", tx);
// // rpc.send_transaction(&tx).await.unwrap();
// }
// }
}

0 comments on commit 1d24923

Please sign in to comment.