|
1 |
| -import { Program } 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,13 +47,18 @@ import {
|
47 | 47 | getProposalInstructions,
|
48 | 48 | idlSetBuffer,
|
49 | 49 | isPriceStorePublisherInitialized,
|
| 50 | + lazerIdl, |
50 | 51 | } from "@pythnetwork/xc-admin-common";
|
51 | 52 |
|
52 | 53 | import {
|
53 | 54 | pythSolanaReceiverIdl,
|
54 | 55 | getConfigPda,
|
55 | 56 | DEFAULT_RECEIVER_PROGRAM_ID,
|
56 | 57 | } from "@pythnetwork/pyth-solana-receiver";
|
| 58 | +import { |
| 59 | + SOLANA_LAZER_PROGRAM_ID, |
| 60 | + SOLANA_STORAGE_ID, |
| 61 | +} from "@pythnetwork/pyth-lazer-sdk"; |
57 | 62 |
|
58 | 63 | import { LedgerNodeWallet } from "./ledger";
|
59 | 64 | import {
|
@@ -924,4 +929,46 @@ multisigCommand("execute-add-and-delete", "Execute a roster change proposal")
|
924 | 929 | await vault.squad.executeTransaction(proposal);
|
925 | 930 | });
|
926 | 931 |
|
| 932 | +multisigCommand( |
| 933 | + "set-trusted-signer", |
| 934 | + "Set a trusted signer for the Lazer program" |
| 935 | +) |
| 936 | + .requiredOption( |
| 937 | + "-s, --signer <pubkey>", |
| 938 | + "public key of the trusted signer to add/update" |
| 939 | + ) |
| 940 | + .requiredOption( |
| 941 | + "-e, --expiry-time <seconds>", |
| 942 | + "expiry time in seconds since Unix epoch. Set to 0 to remove the signer." |
| 943 | + ) |
| 944 | + .action(async (options: any) => { |
| 945 | + const vault = await loadVaultFromOptions(options); |
| 946 | + const targetCluster: PythCluster = options.cluster; |
| 947 | + |
| 948 | + const trustedSigner = new PublicKey(options.signer); |
| 949 | + const expiryTime = new BN(options.expiryTime); |
| 950 | + |
| 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(); |
| 966 | + |
| 967 | + await vault.proposeInstructions( |
| 968 | + [updateInstruction], |
| 969 | + targetCluster, |
| 970 | + DEFAULT_PRIORITY_FEE_CONFIG |
| 971 | + ); |
| 972 | + }); |
| 973 | + |
927 | 974 | program.parse();
|
0 commit comments