@fogo/sessions-sdk 0.0.18 → 0.0.19

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,13 @@ 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]: undefined,
434
+ };
413
435
  const buildStartSessionInstruction = async (options, sessionKey, tokens) => {
414
436
  const instruction = new SessionManagerProgram(new AnchorProvider(options.context.connection, {}, {})).methods
415
437
  .startSession()
@@ -491,7 +513,7 @@ export const sendTransfer = async (options) => {
491
513
  };
492
514
  const buildTransferIntentInstruction = async (program, options, symbol) => {
493
515
  const [nonce, { decimals }] = await Promise.all([
494
- getNonce(program, options.walletPublicKey),
516
+ getNonce(program, options.walletPublicKey, NonceType.Transfer),
495
517
  getMint(options.context.connection, options.mint),
496
518
  ]);
497
519
  const message = new TextEncoder().encode([
@@ -512,13 +534,206 @@ const buildTransferIntentInstruction = async (program, options, symbol) => {
512
534
  message: await addOffchainMessagePrefixToMessageIfNeeded(options.walletPublicKey, intentSignature, message),
513
535
  });
514
536
  };
515
- const getNonce = async (program, walletPublicKey) => {
537
+ const BRIDGE_OUT_MESSAGE_HEADER = `Fogo Bridge Transfer:
538
+ Signing this intent will bridge out the tokens as described below.
539
+ `;
540
+ export const bridgeOut = async (options) => {
541
+ const { wh, route, transferRequest, transferParams, decimals } = await buildWormholeTransfer(options, options.context.connection);
542
+ // @ts-expect-error the wormhole client types are incorrect and do not
543
+ // properly represent the runtime representation.
544
+ const quote = await route.fetchExecutorQuote(transferRequest, transferParams);
545
+ const program = new IntentTransferProgram(new AnchorProvider(options.context.connection, {}, {}));
546
+ const umi = createUmi(options.context.connection.rpcEndpoint);
547
+ const metaplexMint = metaplexPublicKey(options.fromToken.mint.toBase58());
548
+ const metadataAddress = findMetadataPda(umi, { mint: metaplexMint })[0];
549
+ const outboxItem = Keypair.generate();
550
+ const [metadata, nttPdas] = await Promise.all([
551
+ safeFetchMetadata(umi, metadataAddress),
552
+ getNttPdas(options, wh, program, outboxItem.publicKey, new PublicKey(quote.payeeAddress)),
553
+ ]);
554
+ const bridgeInstruction = await program.methods
555
+ .bridgeNttTokens({
556
+ execAmount: new BN(quote.estimatedCost.toString()),
557
+ relayInstructions: Buffer.from(quote.relayInstructions),
558
+ signedQuoteBytes: Buffer.from(quote.signedQuote),
559
+ })
560
+ .accounts({
561
+ sponsor: options.context.payer,
562
+ mint: options.fromToken.mint,
563
+ metadata:
564
+ // eslint-disable-next-line unicorn/no-null
565
+ metadata?.symbol === undefined ? null : new PublicKey(metadataAddress),
566
+ source: getAssociatedTokenAddressSync(options.fromToken.mint, options.walletPublicKey),
567
+ ntt: nttPdas,
568
+ })
569
+ .instruction();
570
+ return options.context.sendTransaction(options.sessionKey, [
571
+ await buildBridgeOutIntent(program, options, decimals, metadata?.symbol),
572
+ bridgeInstruction,
573
+ ], {
574
+ extraSigners: [outboxItem],
575
+ addressLookupTable: BRIDGING_ADDRESS_LOOKUP_TABLE[options.context.network]?.[options.fromToken.mint.toBase58()],
576
+ });
577
+ };
578
+ // Here we use the Wormhole SDKs to produce the wormhole pdas that are needed
579
+ // for the bridge out transaction. Currently this is using wormhole SDK apis
580
+ // that are _technically_ public but it seems likely these are not considered to
581
+ // be truly public. It might be better to extract the pdas by using the sdk to
582
+ // generate (but not send) a transaction, and taking the pdas from that. That
583
+ // may be something to revisit in the future if we find that the wormhole sdk
584
+ // upgrades in ways that break these calls.
585
+ const getNttPdas = async (options, wh, program, outboxItemPublicKey, quotePayeeAddress) => {
586
+ const pdas = NTT.pdas(options.fromToken.manager);
587
+ const solana = wh.getChain("Solana");
588
+ const coreBridgeContract = contracts.coreBridge.get(wh.network, "Fogo");
589
+ if (coreBridgeContract === undefined) {
590
+ throw new Error("Core bridge contract address not returned by wormhole!");
591
+ }
592
+ const transceiverPdas = NTT.transceiverPdas(options.fromToken.manager);
593
+ const [intentTransferSetterPda] = PublicKey.findProgramAddressSync([Buffer.from("intent_transfer")], program.programId);
594
+ const wormholePdas = utils.getWormholeDerivedAccounts(options.fromToken.manager, coreBridgeContract);
595
+ return {
596
+ emitter: transceiverPdas.emitterAccount(),
597
+ nttConfig: pdas.configAccount(),
598
+ nttCustody: await NTT.custodyAccountAddress(pdas, options.fromToken.mint),
599
+ nttInboxRateLimit: pdas.inboxRateLimitAccount(solana.chain),
600
+ nttManager: options.fromToken.manager,
601
+ nttOutboxItem: outboxItemPublicKey,
602
+ nttOutboxRateLimit: pdas.outboxRateLimitAccount(),
603
+ nttPeer: pdas.peerAccount(solana.chain),
604
+ nttSessionAuthority: pdas.sessionAuthority(intentTransferSetterPda, NTT.transferArgs(options.amount, Wormhole.chainAddress("Solana", options.walletPublicKey.toBase58()), false)),
605
+ nttTokenAuthority: pdas.tokenAuthority(),
606
+ payeeNttWithExecutor: quotePayeeAddress,
607
+ transceiver: options.fromToken.transceiver,
608
+ wormholeBridge: wormholePdas.wormholeBridge,
609
+ wormholeFeeCollector: wormholePdas.wormholeFeeCollector,
610
+ wormholeMessage: transceiverPdas.wormholeMessageAccount(outboxItemPublicKey),
611
+ wormholeSequence: wormholePdas.wormholeSequence,
612
+ };
613
+ };
614
+ const buildBridgeOutIntent = async (program, options, decimals, symbol) => {
615
+ const nonce = await getNonce(program, options.walletPublicKey, NonceType.Bridge);
616
+ const message = new TextEncoder().encode([
617
+ BRIDGE_OUT_MESSAGE_HEADER,
618
+ serializeKV({
619
+ version: `${CURRENT_BRIDGE_OUT_MAJOR}.${CURRENT_BRIDGE_OUT_MINOR}`,
620
+ from_chain_id: options.context.chainId,
621
+ to_chain_id: "solana",
622
+ token: symbol ?? options.fromToken.mint.toBase58(),
623
+ amount: amountToString(options.amount, decimals),
624
+ recipient_address: options.walletPublicKey.toBase58(),
625
+ nonce: nonce === null ? "1" : nonce.nonce.add(new BN(1)).toString(),
626
+ }),
627
+ ].join("\n"));
628
+ const intentSignature = signatureBytes(await options.solanaWallet.signMessage(message));
629
+ return Ed25519Program.createInstructionWithPublicKey({
630
+ publicKey: options.walletPublicKey.toBytes(),
631
+ signature: intentSignature,
632
+ message: await addOffchainMessagePrefixToMessageIfNeeded(options.walletPublicKey, intentSignature, message),
633
+ });
634
+ };
635
+ export const bridgeIn = async (options) => {
636
+ const solanaConnection = await options.context.getSolanaConnection();
637
+ const { route, transferRequest, transferParams } = await buildWormholeTransfer(options, solanaConnection);
638
+ // @ts-expect-error the wormhole client types are incorrect and do not
639
+ // properly represent the runtime representation.
640
+ const quote = await route.quote(transferRequest, transferParams);
641
+ if (quote.success) {
642
+ return await routes.checkAndCompleteTransfer(route, await route.initiate(transferRequest, {
643
+ address: () => options.walletPublicKey.toBase58(),
644
+ chain: () => "Solana",
645
+ signAndSend: (transactions) => Promise.all(transactions.map(({ transaction }) => options.solanaWallet.sendTransaction(
646
+ // Hooray for Wormhole's incomplete typing eh?
647
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
648
+ transaction.transaction, solanaConnection,
649
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
650
+ { signers: transaction.signers, skipPreflight: true }))),
651
+ }, quote, Wormhole.chainAddress("Fogo", options.walletPublicKey.toBase58())));
652
+ }
653
+ else {
654
+ throw quote.error;
655
+ }
656
+ };
657
+ const buildWormholeTransfer = async (options, connection) => {
658
+ const [wh, { decimals }] = await Promise.all([
659
+ wormhole(NETWORK_TO_WORMHOLE_NETWORK[options.context.network], [solanaSdk]),
660
+ getMint(connection, options.fromToken.mint),
661
+ ]);
662
+ const Route = nttExecutorRoute({
663
+ ntt: {
664
+ tokens: {
665
+ USDC: [
666
+ {
667
+ chain: options.fromToken.chain,
668
+ manager: options.fromToken.manager.toBase58(),
669
+ token: options.fromToken.mint.toBase58(),
670
+ transceiver: [
671
+ {
672
+ address: options.fromToken.transceiver.toBase58(),
673
+ type: "wormhole",
674
+ },
675
+ ],
676
+ },
677
+ {
678
+ chain: options.toToken.chain,
679
+ manager: options.toToken.manager.toBase58(),
680
+ token: options.toToken.mint.toBase58(),
681
+ transceiver: [
682
+ {
683
+ address: options.toToken.transceiver.toBase58(),
684
+ type: "wormhole",
685
+ },
686
+ ],
687
+ },
688
+ ],
689
+ },
690
+ },
691
+ });
692
+ const route = new Route(wh);
693
+ const transferRequest = await routes.RouteTransferRequest.create(wh, {
694
+ source: Wormhole.tokenId(options.fromToken.chain, options.fromToken.mint.toBase58()),
695
+ destination: Wormhole.tokenId(options.toToken.chain, options.toToken.mint.toBase58()),
696
+ });
697
+ const validated = await route.validate(transferRequest, {
698
+ amount: amountToString(options.amount, decimals),
699
+ options: route.getDefaultOptions(),
700
+ });
701
+ if (validated.valid) {
702
+ return {
703
+ wh,
704
+ route,
705
+ transferRequest,
706
+ transferParams: validated.params,
707
+ decimals,
708
+ };
709
+ }
710
+ else {
711
+ throw validated.error;
712
+ }
713
+ };
714
+ const NETWORK_TO_WORMHOLE_NETWORK = {
715
+ [Network.Mainnet]: "Mainnet",
716
+ [Network.Testnet]: "Testnet",
717
+ };
718
+ const getNonce = async (program, walletPublicKey, nonceType) => {
516
719
  const [noncePda] = await getProgramDerivedAddress({
517
720
  programAddress: fromLegacyPublicKey(program.programId),
518
- seeds: [Buffer.from("nonce"), walletPublicKey.toBuffer()],
721
+ seeds: [
722
+ Buffer.from(NONCE_TYPE_TO_SEED[nonceType]),
723
+ walletPublicKey.toBuffer(),
724
+ ],
519
725
  });
520
726
  return program.account.nonce.fetchNullable(noncePda);
521
727
  };
728
+ var NonceType;
729
+ (function (NonceType) {
730
+ NonceType[NonceType["Transfer"] = 0] = "Transfer";
731
+ NonceType[NonceType["Bridge"] = 1] = "Bridge";
732
+ })(NonceType || (NonceType = {}));
733
+ const NONCE_TYPE_TO_SEED = {
734
+ [NonceType.Transfer]: "nonce",
735
+ [NonceType.Bridge]: "bridge_ntt_nonce",
736
+ };
522
737
  const loginTokenPayloadSchema = z.object({
523
738
  iat: z.number(),
524
739
  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.19",
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
  }