Skip to content

Commit

Permalink
refactor: init publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
keyvankhademi committed Sep 4, 2024
1 parent 5575426 commit 1655b69
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions staking/cli/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ use {
},
};

pub fn init_publisher_caps(rpc_client: &RpcClient, payer: &Keypair, publisher_caps: &Keypair) {
pub fn init_publisher_caps(rpc_client: &RpcClient, payer: &Keypair) -> Pubkey {
let publisher_caps = Keypair::new();
let create_account_ix = create_account(
&payer.pubkey(),
&publisher_caps.pubkey(),
Expand Down Expand Up @@ -95,8 +96,10 @@ pub fn init_publisher_caps(rpc_client: &RpcClient, payer: &Keypair, publisher_ca
instruction,
ComputeBudgetInstruction::set_compute_unit_limit(1_400_000),
],
&[payer, publisher_caps],
&[payer, &publisher_caps],
);

publisher_caps.pubkey()
}

pub fn write_publisher_caps(
Expand Down Expand Up @@ -413,10 +416,7 @@ pub fn fetch_publisher_caps_and_advance(
let encoded_vaa = process_write_encoded_vaa(rpc_client, vaa.as_slice(), wormhole, payer);


let publisher_caps = Keypair::new();


init_publisher_caps(rpc_client, payer, &publisher_caps);
let publisher_caps = init_publisher_caps(rpc_client, payer);


let publisher_caps_message_bytes =
Expand All @@ -427,22 +427,22 @@ pub fn fetch_publisher_caps_and_advance(
let chunk =
&publisher_caps_message_bytes[i..min(i + 1000, publisher_caps_message_bytes.len())];

write_publisher_caps(rpc_client, payer, publisher_caps.pubkey(), i, chunk);
write_publisher_caps(rpc_client, payer, publisher_caps, i, chunk);
}

verify_publisher_caps(
rpc_client,
payer,
publisher_caps.pubkey(),
publisher_caps,
encoded_vaa,
merkle_proofs,
);


println!(
"Initialized publisher caps with pubkey : {:?}",
publisher_caps.pubkey()
publisher_caps
);

advance(rpc_client, payer, publisher_caps.pubkey());
advance(rpc_client, payer, publisher_caps);
}

0 comments on commit 1655b69

Please sign in to comment.