|
1 | | -import { Program, BN } from "@coral-xyz/anchor"; |
| 1 | +import { Program, BN, Idl } from "@coral-xyz/anchor"; |
2 | 2 | import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; |
3 | 3 | import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider"; |
4 | 4 | import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; |
@@ -47,6 +47,7 @@ import { |
47 | 47 | getProposalInstructions, |
48 | 48 | idlSetBuffer, |
49 | 49 | isPriceStorePublisherInitialized, |
| 50 | + lazerIdl, |
50 | 51 | } from "@pythnetwork/xc-admin-common"; |
51 | 52 |
|
52 | 53 | import { |
@@ -947,30 +948,21 @@ multisigCommand( |
947 | 948 | const trustedSigner = new PublicKey(options.signer); |
948 | 949 | const expiryTime = new BN(options.expiryTime); |
949 | 950 |
|
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(); |
974 | 966 |
|
975 | 967 | await vault.proposeInstructions( |
976 | 968 | [updateInstruction], |
|
0 commit comments