@@ -11,7 +11,8 @@ import {
1111 Keypair ,
1212 LAMPORTS_PER_SOL ,
1313 PublicKey ,
14- SystemProgram , TransactionInstruction ,
14+ SystemProgram ,
15+ TransactionInstruction ,
1516} from "@solana/web3.js" ;
1617import Squads from "@sqds/mesh" ;
1718import bs58 from "bs58" ;
@@ -47,7 +48,13 @@ program
4748 )
4849 . option ( "-p, --payload <hex-string>" , "payload to sign" , "0xdeadbeef" )
4950 . action ( async ( options ) => {
50- const squad = await getSquadsClient ( options . cluster , options . ledger , options . ledgerDerivationAccount , options . ledgerDerivationChange , options . wallet ) ;
51+ const squad = await getSquadsClient (
52+ options . cluster ,
53+ options . ledger ,
54+ options . ledgerDerivationAccount ,
55+ options . ledgerDerivationChange ,
56+ options . wallet
57+ ) ;
5158 await createWormholeMsgMultisigTx (
5259 options . cluster ,
5360 squad ,
@@ -59,7 +66,9 @@ program
5966
6067program
6168 . command ( "set-is-active" )
62- . description ( "Create a new multisig transaction to set the attester is-active flag" )
69+ . description (
70+ "Create a new multisig transaction to set the attester is-active flag"
71+ )
6372 . option ( "-c, --cluster <network>" , "solana cluster to use" , "devnet" )
6473 . requiredOption ( "-v, --vault-address <address>" , "multisig vault address" )
6574 . option ( "-l, --ledger" , "use ledger" )
@@ -77,17 +86,38 @@ program
7786 "keys/key.json"
7887 )
7988 . option ( "-a, --attester <program id>" )
80- . option ( "-i, --is-active <true/false>" , "set the isActive field to this value" , true )
89+ . option (
90+ "-i, --is-active <true/false>" ,
91+ "set the isActive field to this value" ,
92+ true
93+ )
8194 . action ( async ( options ) => {
82- const squad = await getSquadsClient ( options . cluster , options . ledger , options . ledgerDerivationAccount , options . ledgerDerivationChange , options . wallet ) ;
95+ const squad = await getSquadsClient (
96+ options . cluster ,
97+ options . ledger ,
98+ options . ledgerDerivationAccount ,
99+ options . ledgerDerivationChange ,
100+ options . wallet
101+ ) ;
83102 const msAccount = await squad . getMultisig ( options . vaultAddress ) ;
84103 const vaultAuthority = squad . getAuthorityPDA (
85104 msAccount . publicKey ,
86105 msAccount . authorityIndex
87106 ) ;
88107 const attesterProgramId = new PublicKey ( options . attester ) ;
89- const txKey = await createTx ( squad , options . ledger , new PublicKey ( options . vaultAddress ) ) ;
90- const instructions = [ await setIsActiveIx ( vaultAuthority , vaultAuthority , attesterProgramId , options . active ) ] ;
108+ const txKey = await createTx (
109+ squad ,
110+ options . ledger ,
111+ new PublicKey ( options . vaultAddress )
112+ ) ;
113+ const instructions = [
114+ await setIsActiveIx (
115+ vaultAuthority ,
116+ vaultAuthority ,
117+ attesterProgramId ,
118+ options . active
119+ ) ,
120+ ] ;
91121 await addInstructionsToTx ( squad , options . ledger , txKey , instructions ) ;
92122 } ) ;
93123
@@ -146,11 +176,12 @@ const solanaClusterMappingToWormholeNetwork: Record<Cluster, WormholeNetwork> =
146176 "mainnet-beta" : "MAINNET" ,
147177 } ;
148178
149- async function getSquadsClient ( cluster : Cluster ,
150- ledger : boolean ,
151- ledgerDerivationAccount : number | undefined ,
152- ledgerDerivationChange : number | undefined ,
153- walletPath : string ,
179+ async function getSquadsClient (
180+ cluster : Cluster ,
181+ ledger : boolean ,
182+ ledgerDerivationAccount : number | undefined ,
183+ ledgerDerivationChange : number | undefined ,
184+ walletPath : string
154185) {
155186 let wallet : LedgerNodeWallet | NodeWallet ;
156187 if ( ledger ) {
@@ -176,7 +207,7 @@ async function getSquadsClient(cluster: Cluster,
176207async function createTx (
177208 squad : Squads ,
178209 ledger : boolean ,
179- vault : PublicKey ,
210+ vault : PublicKey
180211) : Promise < PublicKey > {
181212 const msAccount = await squad . getMultisig ( vault ) ;
182213
@@ -201,7 +232,9 @@ async function addInstructionsToTx(
201232 instructions : TransactionInstruction [ ]
202233) {
203234 for ( let i = 0 ; i < instructions . length ; i ++ ) {
204- console . log ( `Adding instruction ${ i } /${ instructions . length } to transaction...` ) ;
235+ console . log (
236+ `Adding instruction ${ i } /${ instructions . length } to transaction...`
237+ ) ;
205238 if ( ledger ) {
206239 console . log ( "Please approve the transaction on your ledger device..." ) ;
207240 }
@@ -221,33 +254,36 @@ async function setIsActiveIx(
221254 attesterProgramId : PublicKey ,
222255 isActive : boolean
223256) : Promise < TransactionInstruction > {
224- const configKey = PublicKey . createProgramAddressSync ( [ Buffer . from ( "pyth2wormhole-config-v3" ) ] , attesterProgramId )
257+ const configKey = PublicKey . createProgramAddressSync (
258+ [ Buffer . from ( "pyth2wormhole-config-v3" ) ] ,
259+ attesterProgramId
260+ ) ;
225261 const config : AccountMeta = {
226262 pubkey : configKey ,
227263 isSigner : false ,
228264 isWritable : true ,
229- }
265+ } ;
230266
231267 const opsOwner : AccountMeta = {
232268 pubkey : opsOwnerKey ,
233269 isSigner : true ,
234270 isWritable : true ,
235- }
271+ } ;
236272 const payer : AccountMeta = {
237273 pubkey : payerKey ,
238274 isSigner : true ,
239275 isWritable : true ,
240- }
276+ } ;
241277
242- const isActiveInt = ( isActive === true ) ? 1 : 0 ;
278+ const isActiveInt = isActive === true ? 1 : 0 ;
243279 // first byte is the isActive instruction, second byte is true/false
244- const data = new Buffer ( [ 4 , isActiveInt ] )
280+ const data = new Buffer ( [ 4 , isActiveInt ] ) ;
245281
246282 return {
247283 keys : [ config , opsOwner , payer ] ,
248284 programId : attesterProgramId ,
249285 data : data ,
250- }
286+ } ;
251287}
252288
253289async function getWormholeMessageIx (
@@ -286,7 +322,7 @@ async function getWormholeMessageIx(
286322 emitter . toBase58 ( ) ,
287323 message . toBase58 ( ) ,
288324 0 ,
289- Uint8Array . from ( Buffer . from ( payload , ' hex' ) ) ,
325+ Uint8Array . from ( Buffer . from ( payload , " hex" ) ) ,
290326 "CONFIRMED"
291327 )
292328 ) ,
@@ -312,9 +348,12 @@ async function createWormholeMsgMultisigTx(
312348
313349 const message = Keypair . generate ( ) ;
314350
315- fs . mkdirSync ( ' keys' , { recursive : true } ) ;
351+ fs . mkdirSync ( " keys" , { recursive : true } ) ;
316352 // save message to Uint8 array keypair file called mesage.json
317- fs . writeFileSync ( `keys/message-${ txKey . toBase58 ( ) } .json` , `[${ message . secretKey . toString ( ) } ]` ) ;
353+ fs . writeFileSync (
354+ `keys/message-${ txKey . toBase58 ( ) } .json` ,
355+ `[${ message . secretKey . toString ( ) } ]`
356+ ) ;
318357 console . log ( `Message Address: ${ message . publicKey . toBase58 ( ) } ` ) ;
319358
320359 console . log ( "Creating wormhole instructions..." ) ;
@@ -431,7 +470,6 @@ async function executeMultisigTx(
431470 ) ;
432471 await new Promise ( ( resolve ) => setTimeout ( resolve , 10000 ) ) ;
433472
434-
435473 const txDetails = await squad . connection . getParsedTransaction (
436474 signature ,
437475 "confirmed"
@@ -460,10 +498,10 @@ async function executeMultisigTx(
460498 const { vaaBytes } = await response . json ( ) ;
461499 console . log ( `VAA (Base64): ${ vaaBytes } ` ) ;
462500 const parsedVaa = await parse ( vaaBytes ) ;
463- console . log ( `VAA (Hex): ${ Buffer . from ( vaaBytes ) . toString ( ' hex' ) } ` )
501+ console . log ( `VAA (Hex): ${ Buffer . from ( vaaBytes ) . toString ( " hex" ) } ` ) ;
464502 console . log ( `Emitter chain: ${ parsedVaa . emitter_chain } ` ) ;
465503 console . log ( `Nonce: ${ parsedVaa . nonce } ` ) ;
466- console . log ( `Payload: ${ Buffer . from ( parsedVaa . payload ) . toString ( ' hex' ) } ` ) ;
504+ console . log ( `Payload: ${ Buffer . from ( parsedVaa . payload ) . toString ( " hex" ) } ` ) ;
467505}
468506
469507async function parse ( data : string ) {
0 commit comments