@fogo/sessions-sdk 0.0.18 → 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/esm/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import type { Connection, TransactionError } from "@solana/web3.js";
2
- import { PublicKey } from "@solana/web3.js";
1
+ import type { BaseWalletAdapter, MessageSignerWalletAdapterProps } from "@solana/wallet-adapter-base";
2
+ import type { TransactionError } from "@solana/web3.js";
3
+ import { Connection, PublicKey } from "@solana/web3.js";
4
+ import type { Chain } from "@wormhole-foundation/sdk";
3
5
  import BN from "bn.js";
4
6
  import { z } from "zod";
5
7
  import type { TransactionResult } from "./connection.js";
@@ -13,6 +15,7 @@ type EstablishSessionOptions = {
13
15
  expires: Date;
14
16
  extra?: Record<string, string> | undefined;
15
17
  createUnsafeExtractableSessionKey?: boolean | undefined;
18
+ sessionEstablishmentLookupTable?: string | undefined;
16
19
  } & ({
17
20
  limits?: Map<PublicKey, bigint>;
18
21
  unlimited?: false;
@@ -1316,6 +1319,40 @@ type SendTransferOptions = {
1316
1319
  recipient: PublicKey;
1317
1320
  };
1318
1321
  export declare const sendTransfer: (options: SendTransferOptions) => Promise<TransactionResult>;
1322
+ type SendBridgeOutOptions = {
1323
+ context: SessionContext;
1324
+ sessionKey: CryptoKeyPair;
1325
+ sessionPublicKey: PublicKey;
1326
+ walletPublicKey: PublicKey;
1327
+ solanaWallet: MessageSignerWalletAdapterProps;
1328
+ amount: bigint;
1329
+ fromToken: WormholeToken & {
1330
+ chain: "Fogo";
1331
+ };
1332
+ toToken: WormholeToken & {
1333
+ chain: "Solana";
1334
+ };
1335
+ };
1336
+ type WormholeToken = {
1337
+ chain: Chain;
1338
+ mint: PublicKey;
1339
+ manager: PublicKey;
1340
+ transceiver: PublicKey;
1341
+ };
1342
+ export declare const bridgeOut: (options: SendBridgeOutOptions) => Promise<TransactionResult>;
1343
+ type SendBridgeInOptions = {
1344
+ context: SessionContext;
1345
+ walletPublicKey: PublicKey;
1346
+ solanaWallet: BaseWalletAdapter;
1347
+ amount: bigint;
1348
+ fromToken: WormholeToken & {
1349
+ chain: "Solana";
1350
+ };
1351
+ toToken: WormholeToken & {
1352
+ chain: "Fogo";
1353
+ };
1354
+ };
1355
+ export declare const bridgeIn: (options: SendBridgeInOptions) => Promise<import("@wormhole-foundation/sdk").CreatedTransferReceipt<"Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").SourceInitiatedTransferReceipt<"Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").FailedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").SourceFinalizedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").InReviewTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").AttestedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").RefundedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").RedeemedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").DestinationQueuedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore"> | import("@wormhole-foundation/sdk").CompletedTransferReceipt<import("@wormhole-foundation/sdk").AttestationReceipt<keyof import("@wormhole-foundation/sdk-definitions").WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>, "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore", "Fogo" | "Solana" | "Ethereum" | "Bsc" | "Polygon" | "Avalanche" | "Algorand" | "Fantom" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Pythnet" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Sonic" | "Converge" | "Plume" | "XRPLEVM" | "Plasma" | "CreditCoin" | "Stacks" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "HyperCore">>;
1319
1356
  /**
1320
1357
  * Create a login token signed with the session key
1321
1358
  * @param session - The session to create a login token for
package/esm/index.js CHANGED
@@ -7,11 +7,17 @@ import { sha256 } from "@noble/hashes/sha2";
7
7
  import { fromLegacyPublicKey } from "@solana/compat";
8
8
  import { generateKeyPair, getAddressFromPublicKey, getProgramDerivedAddress, signatureBytes, verifySignature, } from "@solana/kit";
9
9
  import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, getMint, } from "@solana/spl-token";
10
- import { Ed25519Program, PublicKey } from "@solana/web3.js";
10
+ import { Connection, Ed25519Program, Keypair, PublicKey, } from "@solana/web3.js";
11
+ import { Wormhole, wormhole, routes } from "@wormhole-foundation/sdk";
12
+ import solanaSdk from "@wormhole-foundation/sdk/solana";
13
+ import { contracts } from "@wormhole-foundation/sdk-base";
14
+ import { nttExecutorRoute } from "@wormhole-foundation/sdk-route-ntt";
15
+ import { utils } from "@wormhole-foundation/sdk-solana-core";
16
+ import { NTT } from "@wormhole-foundation/sdk-solana-ntt";
11
17
  import BN from "bn.js";
12
18
  import bs58 from "bs58";
13
19
  import { z } from "zod";
14
- import { TransactionResultType } from "./connection.js";
20
+ import { Network, TransactionResultType } from "./connection.js";
15
21
  import { importKey, signMessageWithKey, verifyMessageWithKey, } from "./crypto.js";
16
22
  export { createSessionContext } from "./context.js";
17
23
  export { Network, TransactionResultType, createSessionConnection, } from "./connection.js";
@@ -24,6 +30,12 @@ const CURRENT_MAJOR = "0";
24
30
  const CURRENT_MINOR = "3";
25
31
  const CURRENT_INTENT_TRANSFER_MAJOR = "0";
26
32
  const CURRENT_INTENT_TRANSFER_MINOR = "1";
33
+ const CURRENT_BRIDGE_OUT_MAJOR = "0";
34
+ const CURRENT_BRIDGE_OUT_MINOR = "1";
35
+ const SESSION_ESTABLISHMENT_LOOKUP_TABLE_ADDRESS = {
36
+ [Network.Testnet]: "B8cUjJMqaWWTNNSTXBmeptjWswwCH1gTSCRYv4nu7kJW",
37
+ [Network.Mainnet]: undefined,
38
+ };
27
39
  export const establishSession = async (options) => {
28
40
  const sessionKey = options.createUnsafeExtractableSessionKey
29
41
  ? await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"])
@@ -32,7 +44,7 @@ export const establishSession = async (options) => {
32
44
  return sendSessionEstablishTransaction(options, sessionKey, await Promise.all([
33
45
  buildIntentInstruction(options, sessionKey),
34
46
  buildStartSessionInstruction(options, sessionKey),
35
- ]));
47
+ ]), options.sessionEstablishmentLookupTable);
36
48
  }
37
49
  else {
38
50
  const filteredLimits = new Map(options.limits?.entries().filter(([, amount]) => amount > 0n));
@@ -47,11 +59,14 @@ export const establishSession = async (options) => {
47
59
  ...buildCreateAssociatedTokenAccountInstructions(options, tokenInfo),
48
60
  intentInstruction,
49
61
  startSessionInstruction,
50
- ]);
62
+ ], options.sessionEstablishmentLookupTable);
51
63
  }
52
64
  };
53
- const sendSessionEstablishTransaction = async (options, sessionKey, instructions) => {
54
- const result = await options.context.sendTransaction(sessionKey, instructions);
65
+ const sendSessionEstablishTransaction = async (options, sessionKey, instructions, sessionEstablishmentLookupTable) => {
66
+ const result = await options.context.sendTransaction(sessionKey, instructions, {
67
+ addressLookupTable: sessionEstablishmentLookupTable ??
68
+ SESSION_ESTABLISHMENT_LOOKUP_TABLE_ADDRESS[options.context.network],
69
+ });
55
70
  switch (result.type) {
56
71
  case TransactionResultType.Success: {
57
72
  const session = await createSession(options.context, options.walletPublicKey, sessionKey);
@@ -410,6 +425,16 @@ export const getDomainRecordAddress = (domain) => {
410
425
  const hash = sha256(domain);
411
426
  return PublicKey.findProgramAddressSync([Buffer.from("domain-record"), hash], new PublicKey(DomainRegistryIdl.address))[0];
412
427
  };
428
+ const BRIDGING_ADDRESS_LOOKUP_TABLE = {
429
+ [Network.Testnet]: {
430
+ // USDC
431
+ ELNbJ1RtERV2fjtuZjbTscDekWhVzkQ1LjmiPsxp5uND: "4FCi6LptexBdZtaePsoCMeb1XpCijxnWu96g5LsSb6WP",
432
+ },
433
+ [Network.Mainnet]: {
434
+ // USDC
435
+ UsdcSt7U9H5bVy4WaWgeqoowe8RgXpLShCmxUFgZssx: "DjM31fhuQsjxLmpRFQpFUpZvyXzwQeNvyR1DUd8GMVmo",
436
+ },
437
+ };
413
438
  const buildStartSessionInstruction = async (options, sessionKey, tokens) => {
414
439
  const instruction = new SessionManagerProgram(new AnchorProvider(options.context.connection, {}, {})).methods
415
440
  .startSession()
@@ -491,7 +516,7 @@ export const sendTransfer = async (options) => {
491
516
  };
492
517
  const buildTransferIntentInstruction = async (program, options, symbol) => {
493
518
  const [nonce, { decimals }] = await Promise.all([
494
- getNonce(program, options.walletPublicKey),
519
+ getNonce(program, options.walletPublicKey, NonceType.Transfer),
495
520
  getMint(options.context.connection, options.mint),
496
521
  ]);
497
522
  const message = new TextEncoder().encode([
@@ -512,13 +537,211 @@ const buildTransferIntentInstruction = async (program, options, symbol) => {
512
537
  message: await addOffchainMessagePrefixToMessageIfNeeded(options.walletPublicKey, intentSignature, message),
513
538
  });
514
539
  };
515
- const getNonce = async (program, walletPublicKey) => {
540
+ const BRIDGE_OUT_MESSAGE_HEADER = `Fogo Bridge Transfer:
541
+ Signing this intent will bridge out the tokens as described below.
542
+ `;
543
+ export const bridgeOut = async (options) => {
544
+ const { wh, route, transferRequest, transferParams, decimals } = await buildWormholeTransfer(options, options.context.connection);
545
+ // @ts-expect-error the wormhole client types are incorrect and do not
546
+ // properly represent the runtime representation.
547
+ const quote = await route.fetchExecutorQuote(transferRequest, transferParams);
548
+ const program = new IntentTransferProgram(new AnchorProvider(options.context.connection, {}, {}));
549
+ const umi = createUmi(options.context.connection.rpcEndpoint);
550
+ const metaplexMint = metaplexPublicKey(options.fromToken.mint.toBase58());
551
+ const metadataAddress = findMetadataPda(umi, { mint: metaplexMint })[0];
552
+ const outboxItem = Keypair.generate();
553
+ const [metadata, nttPdas] = await Promise.all([
554
+ safeFetchMetadata(umi, metadataAddress),
555
+ getNttPdas(options, wh, program, outboxItem.publicKey, new PublicKey(quote.payeeAddress)),
556
+ ]);
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
+ ]), {
577
+ extraSigners: [outboxItem],
578
+ addressLookupTable: BRIDGING_ADDRESS_LOOKUP_TABLE[options.context.network]?.[options.fromToken.mint.toBase58()],
579
+ });
580
+ };
581
+ // Here we use the Wormhole SDKs to produce the wormhole pdas that are needed
582
+ // for the bridge out transaction. Currently this is using wormhole SDK apis
583
+ // that are _technically_ public but it seems likely these are not considered to
584
+ // be truly public. It might be better to extract the pdas by using the sdk to
585
+ // generate (but not send) a transaction, and taking the pdas from that. That
586
+ // may be something to revisit in the future if we find that the wormhole sdk
587
+ // upgrades in ways that break these calls.
588
+ const getNttPdas = async (options, wh, program, outboxItemPublicKey, quotePayeeAddress) => {
589
+ const pdas = NTT.pdas(options.fromToken.manager);
590
+ const solana = wh.getChain("Solana");
591
+ const coreBridgeContract = contracts.coreBridge.get(wh.network, "Fogo");
592
+ if (coreBridgeContract === undefined) {
593
+ throw new Error("Core bridge contract address not returned by wormhole!");
594
+ }
595
+ const transceiverPdas = NTT.transceiverPdas(options.fromToken.manager);
596
+ const [intentTransferSetterPda] = PublicKey.findProgramAddressSync([Buffer.from("intent_transfer")], program.programId);
597
+ const wormholePdas = utils.getWormholeDerivedAccounts(options.fromToken.manager, coreBridgeContract);
598
+ return {
599
+ emitter: transceiverPdas.emitterAccount(),
600
+ nttConfig: pdas.configAccount(),
601
+ nttCustody: await NTT.custodyAccountAddress(pdas, options.fromToken.mint),
602
+ nttInboxRateLimit: pdas.inboxRateLimitAccount(solana.chain),
603
+ nttManager: options.fromToken.manager,
604
+ nttOutboxItem: outboxItemPublicKey,
605
+ nttOutboxRateLimit: pdas.outboxRateLimitAccount(),
606
+ nttPeer: pdas.peerAccount(solana.chain),
607
+ nttSessionAuthority: pdas.sessionAuthority(intentTransferSetterPda, NTT.transferArgs(options.amount, Wormhole.chainAddress("Solana", options.walletPublicKey.toBase58()), false)),
608
+ nttTokenAuthority: pdas.tokenAuthority(),
609
+ payeeNttWithExecutor: quotePayeeAddress,
610
+ transceiver: options.fromToken.transceiver,
611
+ wormholeProgram: coreBridgeContract,
612
+ wormholeBridge: wormholePdas.wormholeBridge,
613
+ wormholeFeeCollector: wormholePdas.wormholeFeeCollector,
614
+ wormholeMessage: transceiverPdas.wormholeMessageAccount(outboxItemPublicKey),
615
+ wormholeSequence: wormholePdas.wormholeSequence,
616
+ };
617
+ };
618
+ const buildBridgeOutIntent = async (program, options, decimals, symbol) => {
619
+ const nonce = await getNonce(program, options.walletPublicKey, NonceType.Bridge);
620
+ const message = new TextEncoder().encode([
621
+ BRIDGE_OUT_MESSAGE_HEADER,
622
+ serializeKV({
623
+ version: `${CURRENT_BRIDGE_OUT_MAJOR}.${CURRENT_BRIDGE_OUT_MINOR}`,
624
+ from_chain_id: options.context.chainId,
625
+ to_chain_id: "solana",
626
+ token: symbol ?? options.fromToken.mint.toBase58(),
627
+ amount: amountToString(options.amount, decimals),
628
+ recipient_address: options.walletPublicKey.toBase58(),
629
+ nonce: nonce === null ? "1" : nonce.nonce.add(new BN(1)).toString(),
630
+ }),
631
+ ].join("\n"));
632
+ const intentSignature = signatureBytes(await options.solanaWallet.signMessage(message));
633
+ return Ed25519Program.createInstructionWithPublicKey({
634
+ publicKey: options.walletPublicKey.toBytes(),
635
+ signature: intentSignature,
636
+ message: await addOffchainMessagePrefixToMessageIfNeeded(options.walletPublicKey, intentSignature, message),
637
+ });
638
+ };
639
+ export const bridgeIn = async (options) => {
640
+ const solanaConnection = await options.context.getSolanaConnection();
641
+ const { route, transferRequest, transferParams } = await buildWormholeTransfer(options, solanaConnection);
642
+ // @ts-expect-error the wormhole client types are incorrect and do not
643
+ // properly represent the runtime representation.
644
+ const quote = await route.quote(transferRequest, transferParams);
645
+ if (quote.success) {
646
+ return await routes.checkAndCompleteTransfer(route, await route.initiate(transferRequest, {
647
+ address: () => options.walletPublicKey.toBase58(),
648
+ chain: () => "Solana",
649
+ signAndSend: (transactions) => Promise.all(transactions.map(({ transaction }) => options.solanaWallet.sendTransaction(
650
+ // Hooray for Wormhole's incomplete typing eh?
651
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
652
+ transaction.transaction, solanaConnection,
653
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
654
+ { signers: transaction.signers }))),
655
+ }, quote, Wormhole.chainAddress("Fogo", options.walletPublicKey.toBase58())));
656
+ }
657
+ else {
658
+ throw quote.error;
659
+ }
660
+ };
661
+ const buildWormholeTransfer = async (options, connection) => {
662
+ const solanaConnection = await options.context.getSolanaConnection();
663
+ const [wh, { decimals }] = await Promise.all([
664
+ wormhole(NETWORK_TO_WORMHOLE_NETWORK[options.context.network], [solanaSdk], {
665
+ chains: { Solana: { rpc: solanaConnection.rpcEndpoint } },
666
+ }),
667
+ getMint(connection, options.fromToken.mint),
668
+ ]);
669
+ const Route = nttExecutorRoute({
670
+ ntt: {
671
+ tokens: {
672
+ USDC: [
673
+ {
674
+ chain: options.fromToken.chain,
675
+ manager: options.fromToken.manager.toBase58(),
676
+ token: options.fromToken.mint.toBase58(),
677
+ transceiver: [
678
+ {
679
+ address: options.fromToken.transceiver.toBase58(),
680
+ type: "wormhole",
681
+ },
682
+ ],
683
+ },
684
+ {
685
+ chain: options.toToken.chain,
686
+ manager: options.toToken.manager.toBase58(),
687
+ token: options.toToken.mint.toBase58(),
688
+ transceiver: [
689
+ {
690
+ address: options.toToken.transceiver.toBase58(),
691
+ type: "wormhole",
692
+ },
693
+ ],
694
+ },
695
+ ],
696
+ },
697
+ },
698
+ });
699
+ const route = new Route(wh);
700
+ const transferRequest = await routes.RouteTransferRequest.create(wh, {
701
+ recipient: Wormhole.chainAddress(options.toToken.chain, options.walletPublicKey.toBase58()),
702
+ source: Wormhole.tokenId(options.fromToken.chain, options.fromToken.mint.toBase58()),
703
+ destination: Wormhole.tokenId(options.toToken.chain, options.toToken.mint.toBase58()),
704
+ });
705
+ const validated = await route.validate(transferRequest, {
706
+ amount: amountToString(options.amount, decimals),
707
+ options: route.getDefaultOptions(),
708
+ });
709
+ if (validated.valid) {
710
+ return {
711
+ wh,
712
+ route,
713
+ transferRequest,
714
+ transferParams: validated.params,
715
+ decimals,
716
+ };
717
+ }
718
+ else {
719
+ throw validated.error;
720
+ }
721
+ };
722
+ const NETWORK_TO_WORMHOLE_NETWORK = {
723
+ [Network.Mainnet]: "Mainnet",
724
+ [Network.Testnet]: "Testnet",
725
+ };
726
+ const getNonce = async (program, walletPublicKey, nonceType) => {
516
727
  const [noncePda] = await getProgramDerivedAddress({
517
728
  programAddress: fromLegacyPublicKey(program.programId),
518
- seeds: [Buffer.from("nonce"), walletPublicKey.toBuffer()],
729
+ seeds: [
730
+ Buffer.from(NONCE_TYPE_TO_SEED[nonceType]),
731
+ walletPublicKey.toBuffer(),
732
+ ],
519
733
  });
520
734
  return program.account.nonce.fetchNullable(noncePda);
521
735
  };
736
+ var NonceType;
737
+ (function (NonceType) {
738
+ NonceType[NonceType["Transfer"] = 0] = "Transfer";
739
+ NonceType[NonceType["Bridge"] = 1] = "Bridge";
740
+ })(NonceType || (NonceType = {}));
741
+ const NONCE_TYPE_TO_SEED = {
742
+ [NonceType.Transfer]: "nonce",
743
+ [NonceType.Bridge]: "bridge_ntt_nonce",
744
+ };
522
745
  const loginTokenPayloadSchema = z.object({
523
746
  iat: z.number(),
524
747
  sessionPublicKey: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fogo/sessions-sdk",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "A set of utilities for integrating with Fogo sessions",
5
5
  "keywords": [
6
6
  "fogo",
@@ -36,9 +36,14 @@
36
36
  "@solana/kit": "^4.0.0",
37
37
  "@solana/spl-token": "^0.4.13",
38
38
  "@solana/web3.js": "^1.92.3",
39
+ "@wormhole-foundation/sdk": "^3.10.0",
40
+ "@wormhole-foundation/sdk-base": "^3.11.0",
41
+ "@wormhole-foundation/sdk-route-ntt": "^4.0.1",
42
+ "@wormhole-foundation/sdk-solana-core": "^3.10.0",
43
+ "@wormhole-foundation/sdk-solana-ntt": "^4.0.1",
39
44
  "bn.js": "^5.1.2",
40
45
  "bs58": "^6.0.0",
41
46
  "zod": "^3.25.62",
42
- "@fogo/sessions-idls": "^0.0.7"
47
+ "@fogo/sessions-idls": "^0.0.8"
43
48
  }
44
49
  }