@@ -12,7 +12,6 @@ import {
1212 deriveWormholeBridgeDataKey ,
1313} from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole/index.js" ;
1414import { AnchorProvider , Wallet } from "@coral-xyz/anchor" ;
15- import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet.js" ;
1615import type { PythCluster } from "@pythnetwork/client" ;
1716import { getPythClusterApiUrl } from "@pythnetwork/client" ;
1817import type { PriorityFeeConfig } from "@pythnetwork/solana-utils" ;
@@ -35,7 +34,7 @@ import {
3534 SYSVAR_RENT_PUBKEY ,
3635 Transaction ,
3736} from "@solana/web3.js" ;
38- import SquadsMesh from "@sqds/mesh" ;
37+ import SquadsMeshModule from "@sqds/mesh" ;
3938import * as bs58 from "bs58" ;
4039
4140import type { KeyValueConfig } from "../../core/base.js" ;
@@ -231,7 +230,7 @@ export class WormholeEmitter {
231230export class WormholeMultisigProposal {
232231 constructor (
233232 public address : PublicKey ,
234- public squad : SquadsMesh ,
233+ public squad : SquadsMeshInstance ,
235234 public cluster : PythCluster ,
236235 ) { }
237236
@@ -267,7 +266,7 @@ export class WormholeMultisigProposal {
267266 this . cluster ,
268267 ) ,
269268 ) ;
270- } catch ( error ) {
269+ } catch ( error : unknown ) {
271270 if ( ! ( error instanceof InvalidTransactionError ) ) throw error ;
272271 }
273272 }
@@ -280,10 +279,19 @@ export class WormholeMultisigProposal {
280279 * A vault represents a pyth multisig governance realm which exists in solana mainnet or testnet.
281280 * It can be used for proposals to send wormhole messages to the wormhole bridge.
282281 */
282+ type SquadsMeshClass = typeof SquadsMeshModule ;
283+ type SquadsMeshInstance = InstanceType < SquadsMeshClass > ;
284+
285+ function getSquadsMesh ( ) : SquadsMeshClass {
286+ const mod = SquadsMeshModule as { default ?: SquadsMeshClass } ;
287+ if ( mod . default ) return mod . default ;
288+ return SquadsMeshModule ;
289+ }
290+
283291export class Vault extends Storable {
284292 static type = "vault" ;
285293 key : PublicKey ;
286- squad ?: SquadsMesh ;
294+ squad ?: SquadsMeshInstance ;
287295 cluster : PythCluster ;
288296
289297 constructor ( key : string , cluster : string ) {
@@ -327,10 +335,11 @@ export class Vault extends Storable {
327335 wallet : Wallet ,
328336 registry : SolanaRpcRegistry = getPythClusterApiUrl ,
329337 ) : void {
330- this . squad = SquadsMesh . endpoint ( registry ( this . cluster ) , wallet ) ;
338+ const mesh = getSquadsMesh ( ) ;
339+ this . squad = mesh . endpoint ( registry ( this . cluster ) , wallet ) ;
331340 }
332341
333- getSquadOrThrow ( ) : SquadsMesh {
342+ getSquadOrThrow ( ) : SquadsMeshInstance {
334343 if ( ! this . squad ) throw new Error ( "Please connect a wallet to the vault" ) ;
335344 return this . squad ;
336345 }
@@ -341,9 +350,10 @@ export class Vault extends Storable {
341350 */
342351 // eslint-disable-next-line @typescript-eslint/require-await
343352 public async getEmitter ( registry : SolanaRpcRegistry = getPythClusterApiUrl ) {
344- const squad = SquadsMesh . endpoint (
353+ const mesh = getSquadsMesh ( ) ;
354+ const squad = mesh . endpoint (
345355 registry ( this . cluster ) ,
346- new NodeWallet ( Keypair . generate ( ) ) , // dummy wallet
356+ new Wallet ( Keypair . generate ( ) ) , // dummy wallet
347357 ) ;
348358 return squad . getAuthorityPDA ( this . key , 1 ) ;
349359 }
@@ -401,7 +411,7 @@ export class Vault extends Storable {
401411 */
402412// eslint-disable-next-line @typescript-eslint/require-await
403413export async function loadHotWallet ( walletPath : string ) : Promise < Wallet > {
404- return new NodeWallet (
414+ return new Wallet (
405415 Keypair . fromSecretKey (
406416 Uint8Array . from ( JSON . parse ( readFileSync ( walletPath , "ascii" ) ) ) ,
407417 ) ,
0 commit comments