Skip to content

Commit 6edb6b6

Browse files
committed
use anchor
1 parent 71de85d commit 6edb6b6

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

governance/xc_admin/packages/xc_admin_cli/src/index.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Program, BN } from "@coral-xyz/anchor";
1+
import { Program, BN, Idl } from "@coral-xyz/anchor";
22
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
33
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
44
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token";
@@ -47,6 +47,7 @@ import {
4747
getProposalInstructions,
4848
idlSetBuffer,
4949
isPriceStorePublisherInitialized,
50+
lazerIdl,
5051
} from "@pythnetwork/xc-admin-common";
5152

5253
import {
@@ -947,30 +948,21 @@ multisigCommand(
947948
const trustedSigner = new PublicKey(options.signer);
948949
const expiryTime = new BN(options.expiryTime);
949950

950-
// Create the update instruction
951-
const updateInstruction = new TransactionInstruction({
952-
programId: SOLANA_LAZER_PROGRAM_ID,
953-
keys: [
954-
{
955-
pubkey: await vault.getVaultAuthorityPDA(targetCluster),
956-
isSigner: false,
957-
isWritable: false,
958-
},
959-
{
960-
pubkey: SOLANA_STORAGE_ID,
961-
isSigner: false,
962-
isWritable: true,
963-
},
964-
],
965-
data: Buffer.concat([
966-
// Anchor discriminator for "update"
967-
Buffer.from([219, 200, 88, 176, 158, 63, 253, 127]),
968-
// Trusted signer pubkey
969-
trustedSigner.toBuffer(),
970-
// Expiry time (i64)
971-
Buffer.from(expiryTime.toArray("le", 8)),
972-
]),
973-
});
951+
// Create Anchor program instance
952+
const lazerProgram = new Program(
953+
lazerIdl as Idl,
954+
SOLANA_LAZER_PROGRAM_ID,
955+
vault.getAnchorProvider()
956+
);
957+
958+
// Use Anchor to create the instruction
959+
const updateInstruction = await lazerProgram.methods
960+
.update(trustedSigner, expiryTime)
961+
.accounts({
962+
authority: await vault.getVaultAuthorityPDA(targetCluster),
963+
storage: SOLANA_STORAGE_ID,
964+
})
965+
.instruction();
974966

975967
await vault.proposeInstructions(
976968
[updateInstruction],

governance/xc_admin/packages/xc_admin_common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export * from "./executor";
1313
export * from "./chains";
1414
export * from "./deterministic_stake_accounts";
1515
export * from "./price_store";
16+
export { default as lazerIdl } from "./multisig_transaction/idl/lazer.json";

0 commit comments

Comments
 (0)