@fogo/sessions-sdk 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +31 -23
- package/esm/index.js +31 -23
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -446,7 +446,10 @@ const BRIDGING_ADDRESS_LOOKUP_TABLE = {
|
|
|
446
446
|
// USDC
|
|
447
447
|
ELNbJ1RtERV2fjtuZjbTscDekWhVzkQ1LjmiPsxp5uND: "4FCi6LptexBdZtaePsoCMeb1XpCijxnWu96g5LsSb6WP",
|
|
448
448
|
},
|
|
449
|
-
[connection_js_1.Network.Mainnet]:
|
|
449
|
+
[connection_js_1.Network.Mainnet]: {
|
|
450
|
+
// USDC
|
|
451
|
+
UsdcSt7U9H5bVy4WaWgeqoowe8RgXpLShCmxUFgZssx: "DjM31fhuQsjxLmpRFQpFUpZvyXzwQeNvyR1DUd8GMVmo",
|
|
452
|
+
},
|
|
450
453
|
};
|
|
451
454
|
const buildStartSessionInstruction = async (options, sessionKey, tokens) => {
|
|
452
455
|
const instruction = new sessions_idls_1.SessionManagerProgram(new anchor_1.AnchorProvider(options.context.connection, {}, {})).methods
|
|
@@ -568,26 +571,26 @@ const bridgeOut = async (options) => {
|
|
|
568
571
|
(0, mpl_token_metadata_1.safeFetchMetadata)(umi, metadataAddress),
|
|
569
572
|
getNttPdas(options, wh, program, outboxItem.publicKey, new web3_js_1.PublicKey(quote.payeeAddress)),
|
|
570
573
|
]);
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
], {
|
|
574
|
+
return options.context.sendTransaction(options.sessionKey, await Promise.all([
|
|
575
|
+
buildBridgeOutIntent(program, options, decimals, metadata?.symbol),
|
|
576
|
+
program.methods
|
|
577
|
+
.bridgeNttTokens({
|
|
578
|
+
execAmount: new bn_js_1.default(quote.estimatedCost.toString()),
|
|
579
|
+
relayInstructions: Buffer.from(quote.relayInstructions),
|
|
580
|
+
signedQuoteBytes: Buffer.from(quote.signedQuote),
|
|
581
|
+
})
|
|
582
|
+
.accounts({
|
|
583
|
+
sponsor: options.context.payer,
|
|
584
|
+
mint: options.fromToken.mint,
|
|
585
|
+
metadata: metadata?.symbol === undefined
|
|
586
|
+
? // eslint-disable-next-line unicorn/no-null
|
|
587
|
+
null
|
|
588
|
+
: new web3_js_1.PublicKey(metadataAddress),
|
|
589
|
+
source: (0, spl_token_1.getAssociatedTokenAddressSync)(options.fromToken.mint, options.walletPublicKey),
|
|
590
|
+
ntt: nttPdas,
|
|
591
|
+
})
|
|
592
|
+
.instruction(),
|
|
593
|
+
]), {
|
|
591
594
|
extraSigners: [outboxItem],
|
|
592
595
|
addressLookupTable: BRIDGING_ADDRESS_LOOKUP_TABLE[options.context.network]?.[options.fromToken.mint.toBase58()],
|
|
593
596
|
});
|
|
@@ -623,6 +626,7 @@ const getNttPdas = async (options, wh, program, outboxItemPublicKey, quotePayeeA
|
|
|
623
626
|
nttTokenAuthority: pdas.tokenAuthority(),
|
|
624
627
|
payeeNttWithExecutor: quotePayeeAddress,
|
|
625
628
|
transceiver: options.fromToken.transceiver,
|
|
629
|
+
wormholeProgram: coreBridgeContract,
|
|
626
630
|
wormholeBridge: wormholePdas.wormholeBridge,
|
|
627
631
|
wormholeFeeCollector: wormholePdas.wormholeFeeCollector,
|
|
628
632
|
wormholeMessage: transceiverPdas.wormholeMessageAccount(outboxItemPublicKey),
|
|
@@ -665,7 +669,7 @@ const bridgeIn = async (options) => {
|
|
|
665
669
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
666
670
|
transaction.transaction, solanaConnection,
|
|
667
671
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
668
|
-
{ signers: transaction.signers
|
|
672
|
+
{ signers: transaction.signers }))),
|
|
669
673
|
}, quote, sdk_1.Wormhole.chainAddress("Fogo", options.walletPublicKey.toBase58())));
|
|
670
674
|
}
|
|
671
675
|
else {
|
|
@@ -674,8 +678,11 @@ const bridgeIn = async (options) => {
|
|
|
674
678
|
};
|
|
675
679
|
exports.bridgeIn = bridgeIn;
|
|
676
680
|
const buildWormholeTransfer = async (options, connection) => {
|
|
681
|
+
const solanaConnection = await options.context.getSolanaConnection();
|
|
677
682
|
const [wh, { decimals }] = await Promise.all([
|
|
678
|
-
(0, sdk_1.wormhole)(NETWORK_TO_WORMHOLE_NETWORK[options.context.network], [solana_1.default]
|
|
683
|
+
(0, sdk_1.wormhole)(NETWORK_TO_WORMHOLE_NETWORK[options.context.network], [solana_1.default], {
|
|
684
|
+
chains: { Solana: { rpc: solanaConnection.rpcEndpoint } },
|
|
685
|
+
}),
|
|
679
686
|
(0, spl_token_1.getMint)(connection, options.fromToken.mint),
|
|
680
687
|
]);
|
|
681
688
|
const Route = (0, sdk_route_ntt_1.nttExecutorRoute)({
|
|
@@ -710,6 +717,7 @@ const buildWormholeTransfer = async (options, connection) => {
|
|
|
710
717
|
});
|
|
711
718
|
const route = new Route(wh);
|
|
712
719
|
const transferRequest = await sdk_1.routes.RouteTransferRequest.create(wh, {
|
|
720
|
+
recipient: sdk_1.Wormhole.chainAddress(options.toToken.chain, options.walletPublicKey.toBase58()),
|
|
713
721
|
source: sdk_1.Wormhole.tokenId(options.fromToken.chain, options.fromToken.mint.toBase58()),
|
|
714
722
|
destination: sdk_1.Wormhole.tokenId(options.toToken.chain, options.toToken.mint.toBase58()),
|
|
715
723
|
});
|
package/esm/index.js
CHANGED
|
@@ -430,7 +430,10 @@ const BRIDGING_ADDRESS_LOOKUP_TABLE = {
|
|
|
430
430
|
// USDC
|
|
431
431
|
ELNbJ1RtERV2fjtuZjbTscDekWhVzkQ1LjmiPsxp5uND: "4FCi6LptexBdZtaePsoCMeb1XpCijxnWu96g5LsSb6WP",
|
|
432
432
|
},
|
|
433
|
-
[Network.Mainnet]:
|
|
433
|
+
[Network.Mainnet]: {
|
|
434
|
+
// USDC
|
|
435
|
+
UsdcSt7U9H5bVy4WaWgeqoowe8RgXpLShCmxUFgZssx: "DjM31fhuQsjxLmpRFQpFUpZvyXzwQeNvyR1DUd8GMVmo",
|
|
436
|
+
},
|
|
434
437
|
};
|
|
435
438
|
const buildStartSessionInstruction = async (options, sessionKey, tokens) => {
|
|
436
439
|
const instruction = new SessionManagerProgram(new AnchorProvider(options.context.connection, {}, {})).methods
|
|
@@ -551,26 +554,26 @@ export const bridgeOut = async (options) => {
|
|
|
551
554
|
safeFetchMetadata(umi, metadataAddress),
|
|
552
555
|
getNttPdas(options, wh, program, outboxItem.publicKey, new PublicKey(quote.payeeAddress)),
|
|
553
556
|
]);
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
], {
|
|
557
|
+
return options.context.sendTransaction(options.sessionKey, await Promise.all([
|
|
558
|
+
buildBridgeOutIntent(program, options, decimals, metadata?.symbol),
|
|
559
|
+
program.methods
|
|
560
|
+
.bridgeNttTokens({
|
|
561
|
+
execAmount: new BN(quote.estimatedCost.toString()),
|
|
562
|
+
relayInstructions: Buffer.from(quote.relayInstructions),
|
|
563
|
+
signedQuoteBytes: Buffer.from(quote.signedQuote),
|
|
564
|
+
})
|
|
565
|
+
.accounts({
|
|
566
|
+
sponsor: options.context.payer,
|
|
567
|
+
mint: options.fromToken.mint,
|
|
568
|
+
metadata: metadata?.symbol === undefined
|
|
569
|
+
? // eslint-disable-next-line unicorn/no-null
|
|
570
|
+
null
|
|
571
|
+
: new PublicKey(metadataAddress),
|
|
572
|
+
source: getAssociatedTokenAddressSync(options.fromToken.mint, options.walletPublicKey),
|
|
573
|
+
ntt: nttPdas,
|
|
574
|
+
})
|
|
575
|
+
.instruction(),
|
|
576
|
+
]), {
|
|
574
577
|
extraSigners: [outboxItem],
|
|
575
578
|
addressLookupTable: BRIDGING_ADDRESS_LOOKUP_TABLE[options.context.network]?.[options.fromToken.mint.toBase58()],
|
|
576
579
|
});
|
|
@@ -605,6 +608,7 @@ const getNttPdas = async (options, wh, program, outboxItemPublicKey, quotePayeeA
|
|
|
605
608
|
nttTokenAuthority: pdas.tokenAuthority(),
|
|
606
609
|
payeeNttWithExecutor: quotePayeeAddress,
|
|
607
610
|
transceiver: options.fromToken.transceiver,
|
|
611
|
+
wormholeProgram: coreBridgeContract,
|
|
608
612
|
wormholeBridge: wormholePdas.wormholeBridge,
|
|
609
613
|
wormholeFeeCollector: wormholePdas.wormholeFeeCollector,
|
|
610
614
|
wormholeMessage: transceiverPdas.wormholeMessageAccount(outboxItemPublicKey),
|
|
@@ -647,7 +651,7 @@ export const bridgeIn = async (options) => {
|
|
|
647
651
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
648
652
|
transaction.transaction, solanaConnection,
|
|
649
653
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
650
|
-
{ signers: transaction.signers
|
|
654
|
+
{ signers: transaction.signers }))),
|
|
651
655
|
}, quote, Wormhole.chainAddress("Fogo", options.walletPublicKey.toBase58())));
|
|
652
656
|
}
|
|
653
657
|
else {
|
|
@@ -655,8 +659,11 @@ export const bridgeIn = async (options) => {
|
|
|
655
659
|
}
|
|
656
660
|
};
|
|
657
661
|
const buildWormholeTransfer = async (options, connection) => {
|
|
662
|
+
const solanaConnection = await options.context.getSolanaConnection();
|
|
658
663
|
const [wh, { decimals }] = await Promise.all([
|
|
659
|
-
wormhole(NETWORK_TO_WORMHOLE_NETWORK[options.context.network], [solanaSdk]
|
|
664
|
+
wormhole(NETWORK_TO_WORMHOLE_NETWORK[options.context.network], [solanaSdk], {
|
|
665
|
+
chains: { Solana: { rpc: solanaConnection.rpcEndpoint } },
|
|
666
|
+
}),
|
|
660
667
|
getMint(connection, options.fromToken.mint),
|
|
661
668
|
]);
|
|
662
669
|
const Route = nttExecutorRoute({
|
|
@@ -691,6 +698,7 @@ const buildWormholeTransfer = async (options, connection) => {
|
|
|
691
698
|
});
|
|
692
699
|
const route = new Route(wh);
|
|
693
700
|
const transferRequest = await routes.RouteTransferRequest.create(wh, {
|
|
701
|
+
recipient: Wormhole.chainAddress(options.toToken.chain, options.walletPublicKey.toBase58()),
|
|
694
702
|
source: Wormhole.tokenId(options.fromToken.chain, options.fromToken.mint.toBase58()),
|
|
695
703
|
destination: Wormhole.tokenId(options.toToken.chain, options.toToken.mint.toBase58()),
|
|
696
704
|
});
|