@fogo/sessions-sdk 0.0.17 → 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.
@@ -0,0 +1,47 @@
1
+ import type { Transaction, Instruction, TransactionWithLifetime } from "@solana/kit";
2
+ import type { TransactionError } from "@solana/web3.js";
3
+ import { Keypair, Connection as Web3Connection, TransactionInstruction, VersionedTransaction, PublicKey } from "@solana/web3.js";
4
+ export declare enum Network {
5
+ Testnet = 0,
6
+ Mainnet = 1
7
+ }
8
+ export declare enum TransactionResultType {
9
+ Success = 0,
10
+ Failed = 1
11
+ }
12
+ declare const TransactionResult: {
13
+ Success: (signature: string) => {
14
+ type: TransactionResultType.Success;
15
+ signature: string;
16
+ };
17
+ Failed: (signature: string, error: TransactionError) => {
18
+ type: TransactionResultType.Failed;
19
+ signature: string;
20
+ error: TransactionError;
21
+ };
22
+ };
23
+ export type TransactionResult = ReturnType<(typeof TransactionResult)[keyof typeof TransactionResult]>;
24
+ export declare const createSessionConnection: (options: {
25
+ network: Network;
26
+ rpc?: string | URL | undefined;
27
+ } & ({
28
+ paymaster?: string | URL | undefined;
29
+ sendToPaymaster?: undefined;
30
+ sponsor?: undefined;
31
+ } | {
32
+ paymaster?: undefined;
33
+ sendToPaymaster: (transaction: Transaction) => Promise<TransactionResult>;
34
+ sponsor: PublicKey;
35
+ })) => {
36
+ rpc: import("@solana/kit").Rpc<import("@solana/kit").RequestAirdropApi & import("@solana/kit").GetAccountInfoApi & import("@solana/kit").GetBalanceApi & import("@solana/kit").GetBlockApi & import("@solana/kit").GetBlockCommitmentApi & import("@solana/kit").GetBlockHeightApi & import("@solana/kit").GetBlockProductionApi & import("@solana/kit").GetBlocksApi & import("@solana/kit").GetBlocksWithLimitApi & import("@solana/kit").GetBlockTimeApi & import("@solana/kit").GetClusterNodesApi & import("@solana/kit").GetEpochInfoApi & import("@solana/kit").GetEpochScheduleApi & import("@solana/kit").GetFeeForMessageApi & import("@solana/kit").GetFirstAvailableBlockApi & import("@solana/kit").GetGenesisHashApi & import("@solana/kit").GetHealthApi & import("@solana/kit").GetHighestSnapshotSlotApi & import("@solana/kit").GetIdentityApi & import("@solana/kit").GetInflationGovernorApi & import("@solana/kit").GetInflationRateApi & import("@solana/kit").GetInflationRewardApi & import("@solana/kit").GetLargestAccountsApi & import("@solana/kit").GetLatestBlockhashApi & import("@solana/kit").GetLeaderScheduleApi & import("@solana/kit").GetMaxRetransmitSlotApi & import("@solana/kit").GetMaxShredInsertSlotApi & import("@solana/kit").GetMinimumBalanceForRentExemptionApi & import("@solana/kit").GetMultipleAccountsApi & import("@solana/kit").GetProgramAccountsApi & import("@solana/kit").GetRecentPerformanceSamplesApi & import("@solana/kit").GetRecentPrioritizationFeesApi & import("@solana/kit").GetSignaturesForAddressApi & import("@solana/kit").GetSignatureStatusesApi & import("@solana/kit").GetSlotApi & import("@solana/kit").GetSlotLeaderApi & import("@solana/kit").GetSlotLeadersApi & import("@solana/kit").GetStakeMinimumDelegationApi & import("@solana/kit").GetSupplyApi & import("@solana/kit").GetTokenAccountBalanceApi & import("@solana/kit").GetTokenAccountsByDelegateApi & import("@solana/kit").GetTokenAccountsByOwnerApi & import("@solana/kit").GetTokenLargestAccountsApi & import("@solana/kit").GetTokenSupplyApi & import("@solana/kit").GetTransactionApi & import("@solana/kit").GetTransactionCountApi & import("@solana/kit").GetVersionApi & import("@solana/kit").GetVoteAccountsApi & import("@solana/kit").IsBlockhashValidApi & import("@solana/kit").MinimumLedgerSlotApi & import("@solana/kit").SendTransactionApi & import("@solana/kit").SimulateTransactionApi>;
37
+ connection: Web3Connection;
38
+ network: Network;
39
+ getSolanaConnection: () => Promise<Web3Connection>;
40
+ sendToPaymaster: (domain: string, sponsor: PublicKey, sessionKey: CryptoKeyPair | undefined, instructions: (TransactionInstruction | Instruction)[] | VersionedTransaction | (Transaction & TransactionWithLifetime), extraConfig?: {
41
+ addressLookupTable?: string | undefined;
42
+ extraSigners?: (CryptoKeyPair | Keypair)[] | undefined;
43
+ }) => Promise<TransactionResult>;
44
+ getSponsor: (domain: string) => Promise<PublicKey>;
45
+ };
46
+ export type Connection = ReturnType<typeof createSessionConnection>;
47
+ export {};
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSessionConnection = exports.TransactionResultType = exports.Network = void 0;
4
+ const compat_1 = require("@solana/compat");
5
+ const kit_1 = require("@solana/kit");
6
+ const web3_js_1 = require("@solana/web3.js");
7
+ const zod_1 = require("zod");
8
+ var Network;
9
+ (function (Network) {
10
+ Network[Network["Testnet"] = 0] = "Testnet";
11
+ Network[Network["Mainnet"] = 1] = "Mainnet";
12
+ })(Network || (exports.Network = Network = {}));
13
+ const DEFAULT_RPC = {
14
+ [Network.Testnet]: "https://testnet.fogo.io",
15
+ [Network.Mainnet]: "https://mainnet.fogo.io",
16
+ };
17
+ const DEFAULT_PAYMASTER = {
18
+ [Network.Testnet]: "https://paymaster.fogo.io",
19
+ [Network.Mainnet]: "https://paymaster.dourolabs.app",
20
+ };
21
+ var TransactionResultType;
22
+ (function (TransactionResultType) {
23
+ TransactionResultType[TransactionResultType["Success"] = 0] = "Success";
24
+ TransactionResultType[TransactionResultType["Failed"] = 1] = "Failed";
25
+ })(TransactionResultType || (exports.TransactionResultType = TransactionResultType = {}));
26
+ const TransactionResult = {
27
+ Success: (signature) => ({
28
+ type: TransactionResultType.Success,
29
+ signature,
30
+ }),
31
+ Failed: (signature, error) => ({
32
+ type: TransactionResultType.Failed,
33
+ signature,
34
+ error,
35
+ }),
36
+ };
37
+ const createSessionConnection = (options) => {
38
+ const rpcUrl = (options.rpc ?? DEFAULT_RPC[options.network]).toString();
39
+ const rpc = (0, kit_1.createSolanaRpc)(rpcUrl);
40
+ const connection = new web3_js_1.Connection(rpcUrl, "confirmed");
41
+ const addressLookupTableCache = new Map();
42
+ return {
43
+ rpc,
44
+ connection,
45
+ network: options.network,
46
+ getSolanaConnection: createSolanaConnectionGetter(options.network),
47
+ sendToPaymaster: async (domain, sponsor, sessionKey, instructions, extraConfig) => {
48
+ const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
49
+ const transaction = await buildTransaction(connection, latestBlockhash, sessionKey, sponsor, instructions, addressLookupTableCache, extraConfig);
50
+ return sendToPaymaster(options, domain, transaction);
51
+ },
52
+ getSponsor: (domain) => getSponsor(options, domain),
53
+ };
54
+ };
55
+ exports.createSessionConnection = createSessionConnection;
56
+ const createSolanaConnectionGetter = (network) => {
57
+ let connection;
58
+ return async () => {
59
+ if (connection === undefined) {
60
+ const url = new URL("https://api.fogo.io/api/solana-rpc");
61
+ url.searchParams.set("network", NETWORK_TO_QUERY_PARAM[network]);
62
+ const rpcUrlRes = await fetch(url);
63
+ if (rpcUrlRes.status === 200) {
64
+ const rpcUrl = await rpcUrlRes.text();
65
+ connection = new web3_js_1.Connection(rpcUrl);
66
+ }
67
+ else {
68
+ throw new Error("Failed to resolve Solana RPC url");
69
+ }
70
+ }
71
+ return connection;
72
+ };
73
+ };
74
+ const NETWORK_TO_QUERY_PARAM = {
75
+ [Network.Mainnet]: "mainnet",
76
+ [Network.Testnet]: "testnet",
77
+ };
78
+ const sendToPaymaster = async (options, domain, transaction) => {
79
+ if (options.sendToPaymaster === undefined) {
80
+ const url = new URL("/api/sponsor_and_send", options.paymaster ?? DEFAULT_PAYMASTER[options.network]);
81
+ url.searchParams.set("domain", domain);
82
+ const response = await fetch(url, {
83
+ method: "POST",
84
+ headers: {
85
+ "Content-Type": "application/json",
86
+ },
87
+ body: JSON.stringify({
88
+ transaction: (0, kit_1.getBase64EncodedWireTransaction)(transaction),
89
+ }),
90
+ });
91
+ if (response.status === 200) {
92
+ return sponsorAndSendResponseSchema.parse(await response.json());
93
+ }
94
+ else {
95
+ throw new PaymasterResponseError(response.status, await response.text());
96
+ }
97
+ }
98
+ else {
99
+ return options.sendToPaymaster(transaction);
100
+ }
101
+ };
102
+ const buildTransaction = async (connection, latestBlockhash, sessionKey, sponsor, instructions, addressLookupTableCache, extraConfig) => {
103
+ const [signerKeys, addressLookupTable] = await Promise.all([
104
+ getSignerKeys(sessionKey, extraConfig?.extraSigners),
105
+ extraConfig?.addressLookupTable === undefined
106
+ ? Promise.resolve(undefined)
107
+ : getAddressLookupTable(connection, addressLookupTableCache, extraConfig.addressLookupTable),
108
+ ]);
109
+ if (Array.isArray(instructions)) {
110
+ const signers = await Promise.all(signerKeys.map((signer) => (0, kit_1.createSignerFromKeyPair)(signer)));
111
+ return (0, kit_1.partiallySignTransactionMessageWithSigners)((0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (tx) => (0, kit_1.setTransactionMessageFeePayer)((0, compat_1.fromLegacyPublicKey)(sponsor), tx), (tx) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx), (tx) => (0, kit_1.appendTransactionMessageInstructions)(instructions.map((instruction) => instruction instanceof web3_js_1.TransactionInstruction
112
+ ? (0, compat_1.fromLegacyTransactionInstruction)(instruction)
113
+ : instruction), tx), (tx) => addressLookupTable === undefined
114
+ ? tx
115
+ : (0, kit_1.compressTransactionMessageUsingAddressLookupTables)(tx, {
116
+ [(0, compat_1.fromLegacyPublicKey)(addressLookupTable.key)]: addressLookupTable.state.addresses.map((address) => (0, compat_1.fromLegacyPublicKey)(address)),
117
+ }), (tx) => (0, kit_1.addSignersToTransactionMessage)(signers, tx)));
118
+ }
119
+ else {
120
+ const tx = instructions instanceof web3_js_1.VersionedTransaction
121
+ ? (0, compat_1.fromVersionedTransaction)(instructions) // VersionedTransaction has a lifetime so it's fine to cast it so we can call partiallySignTransaction
122
+ : instructions;
123
+ return (0, kit_1.partiallySignTransaction)(signerKeys, tx);
124
+ }
125
+ };
126
+ const getSignerKeys = async (sessionKey, extraSigners) => {
127
+ const extraSignerKeys = extraSigners === undefined
128
+ ? []
129
+ : await Promise.all(extraSigners.map((signer) => signer instanceof web3_js_1.Keypair ? (0, compat_1.fromLegacyKeypair)(signer) : signer));
130
+ return [
131
+ ...extraSignerKeys,
132
+ ...(sessionKey === undefined ? [] : [sessionKey]),
133
+ ];
134
+ };
135
+ const sponsorAndSendResponseSchema = zod_1.z
136
+ .discriminatedUnion("type", [
137
+ zod_1.z.object({
138
+ type: zod_1.z.literal("success"),
139
+ signature: zod_1.z.string(),
140
+ }),
141
+ zod_1.z.object({
142
+ type: zod_1.z.literal("failed"),
143
+ signature: zod_1.z.string(),
144
+ error: zod_1.z.object({
145
+ InstructionError: zod_1.z.tuple([zod_1.z.number(), zod_1.z.unknown()]),
146
+ }),
147
+ }),
148
+ ])
149
+ .transform((data) => {
150
+ return data.type === "success"
151
+ ? TransactionResult.Success(data.signature)
152
+ : TransactionResult.Failed(data.signature, data.error);
153
+ });
154
+ const getSponsor = async (options, domain) => {
155
+ if (options.sponsor === undefined) {
156
+ const url = new URL("/api/sponsor_pubkey", options.paymaster ?? DEFAULT_PAYMASTER[options.network]);
157
+ url.searchParams.set("domain", domain);
158
+ const response = await fetch(url);
159
+ if (response.status === 200) {
160
+ return new web3_js_1.PublicKey(zod_1.z.string().parse(await response.text()));
161
+ }
162
+ else {
163
+ throw new PaymasterResponseError(response.status, await response.text());
164
+ }
165
+ }
166
+ else {
167
+ return options.sponsor;
168
+ }
169
+ };
170
+ const getAddressLookupTable = async (connection, addressLookupTableCache, addressLookupTableAddress) => {
171
+ const value = addressLookupTableCache.get(addressLookupTableAddress);
172
+ if (value === undefined) {
173
+ const result = await connection.getAddressLookupTable(new web3_js_1.PublicKey(addressLookupTableAddress));
174
+ if (result.value === null) {
175
+ return;
176
+ }
177
+ else {
178
+ addressLookupTableCache.set(addressLookupTableAddress, result.value);
179
+ return result.value;
180
+ }
181
+ }
182
+ else {
183
+ return value;
184
+ }
185
+ };
186
+ class PaymasterResponseError extends Error {
187
+ constructor(statusCode, message) {
188
+ super(`Paymaster sent a ${statusCode.toString()} response: ${message}`);
189
+ this.name = "PaymasterResponseError";
190
+ }
191
+ }
package/cjs/context.d.ts CHANGED
@@ -1,40 +1,17 @@
1
- import type { Transaction, Instruction, TransactionWithLifetime } from "@solana/kit";
2
- import type { Connection, TransactionError } from "@solana/web3.js";
3
- import { PublicKey, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
4
- export type SessionContext = {
5
- chainId: string;
6
- connection: Connection;
7
- payer: PublicKey;
8
- domain: string;
9
- sendTransaction: (sessionKey: CryptoKeyPair | undefined, instructions: (TransactionInstruction | Instruction)[] | VersionedTransaction | (Transaction & TransactionWithLifetime)) => Promise<TransactionResult>;
10
- };
11
- export declare enum TransactionResultType {
12
- Success = 0,
13
- Failed = 1
14
- }
15
- declare const TransactionResult: {
16
- Success: (signature: string) => {
17
- type: TransactionResultType.Success;
18
- signature: string;
19
- };
20
- Failed: (signature: string, error: TransactionError) => {
21
- type: TransactionResultType.Failed;
22
- signature: string;
23
- error: TransactionError;
24
- };
25
- };
26
- export type TransactionResult = ReturnType<(typeof TransactionResult)[keyof typeof TransactionResult]>;
1
+ import { Connection as Web3Connection } from "@solana/web3.js";
2
+ import type { Connection } from "./connection.js";
27
3
  export declare const createSessionContext: (options: {
28
4
  connection: Connection;
29
- addressLookupTableAddress?: string | undefined;
5
+ defaultAddressLookupTableAddress?: string | undefined;
30
6
  domain?: string | undefined;
31
- } & ({
32
- paymaster?: string | URL | undefined;
33
- sendToPaymaster?: undefined;
34
- sponsor?: undefined;
35
- } | {
36
- paymaster?: undefined;
37
- sendToPaymaster: (transaction: Transaction) => Promise<TransactionResult>;
38
- sponsor: PublicKey;
39
- })) => Promise<SessionContext>;
40
- export {};
7
+ }) => Promise<{
8
+ chainId: string;
9
+ domain: string;
10
+ payer: import("@solana/web3.js").PublicKey;
11
+ getSolanaConnection: () => Promise<Web3Connection>;
12
+ connection: Web3Connection;
13
+ rpc: import("@solana/kit").Rpc<import("@solana/kit").RequestAirdropApi & import("@solana/kit").GetAccountInfoApi & import("@solana/kit").GetBalanceApi & import("@solana/kit").GetBlockApi & import("@solana/kit").GetBlockCommitmentApi & import("@solana/kit").GetBlockHeightApi & import("@solana/kit").GetBlockProductionApi & import("@solana/kit").GetBlocksApi & import("@solana/kit").GetBlocksWithLimitApi & import("@solana/kit").GetBlockTimeApi & import("@solana/kit").GetClusterNodesApi & import("@solana/kit").GetEpochInfoApi & import("@solana/kit").GetEpochScheduleApi & import("@solana/kit").GetFeeForMessageApi & import("@solana/kit").GetFirstAvailableBlockApi & import("@solana/kit").GetGenesisHashApi & import("@solana/kit").GetHealthApi & import("@solana/kit").GetHighestSnapshotSlotApi & import("@solana/kit").GetIdentityApi & import("@solana/kit").GetInflationGovernorApi & import("@solana/kit").GetInflationRateApi & import("@solana/kit").GetInflationRewardApi & import("@solana/kit").GetLargestAccountsApi & import("@solana/kit").GetLatestBlockhashApi & import("@solana/kit").GetLeaderScheduleApi & import("@solana/kit").GetMaxRetransmitSlotApi & import("@solana/kit").GetMaxShredInsertSlotApi & import("@solana/kit").GetMinimumBalanceForRentExemptionApi & import("@solana/kit").GetMultipleAccountsApi & import("@solana/kit").GetProgramAccountsApi & import("@solana/kit").GetRecentPerformanceSamplesApi & import("@solana/kit").GetRecentPrioritizationFeesApi & import("@solana/kit").GetSignaturesForAddressApi & import("@solana/kit").GetSignatureStatusesApi & import("@solana/kit").GetSlotApi & import("@solana/kit").GetSlotLeaderApi & import("@solana/kit").GetSlotLeadersApi & import("@solana/kit").GetStakeMinimumDelegationApi & import("@solana/kit").GetSupplyApi & import("@solana/kit").GetTokenAccountBalanceApi & import("@solana/kit").GetTokenAccountsByDelegateApi & import("@solana/kit").GetTokenAccountsByOwnerApi & import("@solana/kit").GetTokenLargestAccountsApi & import("@solana/kit").GetTokenSupplyApi & import("@solana/kit").GetTransactionApi & import("@solana/kit").GetTransactionCountApi & import("@solana/kit").GetVersionApi & import("@solana/kit").GetVoteAccountsApi & import("@solana/kit").IsBlockhashValidApi & import("@solana/kit").MinimumLedgerSlotApi & import("@solana/kit").SendTransactionApi & import("@solana/kit").SimulateTransactionApi>;
14
+ network: import("./connection.js").Network;
15
+ sendTransaction: (sessionKey: CryptoKeyPair | undefined, instructions: Parameters<typeof options.connection.sendToPaymaster>[3], extraConfig?: Parameters<typeof options.connection.sendToPaymaster>[4]) => Promise<import("./connection.js").TransactionResult>;
16
+ }>;
17
+ export type SessionContext = Awaited<ReturnType<typeof createSessionContext>>;
package/cjs/context.js CHANGED
@@ -1,137 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSessionContext = exports.TransactionResultType = void 0;
3
+ exports.createSessionContext = void 0;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
5
  const sessions_idls_1 = require("@fogo/sessions-idls");
6
- const compat_1 = require("@solana/compat");
7
- const kit_1 = require("@solana/kit");
8
6
  const web3_js_1 = require("@solana/web3.js");
9
- const zod_1 = require("zod");
10
7
  // eslint-disable-next-line unicorn/no-typeof-undefined
11
8
  const IS_BROWSER = typeof globalThis.window !== "undefined";
12
- const DEFAULT_PAYMASTER = "https://paymaster.fogo.io";
13
- const DEFAULT_ADDRESS_LOOKUP_TABLE_ADDRESS = "B8cUjJMqaWWTNNSTXBmeptjWswwCH1gTSCRYv4nu7kJW";
14
- var TransactionResultType;
15
- (function (TransactionResultType) {
16
- TransactionResultType[TransactionResultType["Success"] = 0] = "Success";
17
- TransactionResultType[TransactionResultType["Failed"] = 1] = "Failed";
18
- })(TransactionResultType || (exports.TransactionResultType = TransactionResultType = {}));
19
- const TransactionResult = {
20
- Success: (signature) => ({
21
- type: TransactionResultType.Success,
22
- signature,
23
- }),
24
- Failed: (signature, error) => ({
25
- type: TransactionResultType.Failed,
26
- signature,
27
- error,
28
- }),
29
- };
30
9
  const createSessionContext = async (options) => {
31
- const addressLookupTables = await getAddressLookupTables(options.connection, options.addressLookupTableAddress);
32
10
  const domain = getDomain(options.domain);
33
- const sponsor = await getSponsor(options, domain);
11
+ const sponsor = await options.connection.getSponsor(domain);
34
12
  return {
35
- connection: options.connection,
36
- payer: sponsor,
37
- chainId: await fetchChainId(options.connection),
13
+ chainId: await fetchChainId(options.connection.connection),
38
14
  domain: getDomain(options.domain),
39
- sendTransaction: async (sessionKey, instructions) => {
40
- const rpc = (0, kit_1.createSolanaRpc)(options.connection.rpcEndpoint);
41
- const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
42
- return await sendToPaymaster(options, await buildTransaction(latestBlockhash, sessionKey, sponsor, instructions, addressLookupTables), domain);
43
- },
15
+ payer: sponsor,
16
+ getSolanaConnection: options.connection.getSolanaConnection,
17
+ connection: options.connection.connection,
18
+ rpc: options.connection.rpc,
19
+ network: options.connection.network,
20
+ sendTransaction: (sessionKey, instructions, extraConfig) => options.connection.sendToPaymaster(domain, sponsor, sessionKey, instructions, {
21
+ addressLookupTable: extraConfig?.addressLookupTable ??
22
+ options.defaultAddressLookupTableAddress,
23
+ extraSigners: extraConfig?.extraSigners,
24
+ }),
44
25
  };
45
26
  };
46
27
  exports.createSessionContext = createSessionContext;
47
- const buildTransaction = async (latestBlockhash, sessionKey, sponsor, instructions, addressLookupTables) => {
48
- const sessionKeySigner = sessionKey
49
- ? await (0, kit_1.createSignerFromKeyPair)(sessionKey)
50
- : undefined;
51
- if (Array.isArray(instructions)) {
52
- return (0, kit_1.partiallySignTransactionMessageWithSigners)((0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (tx) => (0, kit_1.setTransactionMessageFeePayer)((0, compat_1.fromLegacyPublicKey)(sponsor), tx), (tx) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, tx), (tx) => (0, kit_1.appendTransactionMessageInstructions)(instructions.map((instruction) => instruction instanceof web3_js_1.TransactionInstruction
53
- ? (0, compat_1.fromLegacyTransactionInstruction)(instruction)
54
- : instruction), tx), (tx) => (0, kit_1.compressTransactionMessageUsingAddressLookupTables)(tx, Object.fromEntries(addressLookupTables?.map((table) => [
55
- (0, compat_1.fromLegacyPublicKey)(table.key),
56
- table.state.addresses.map((address) => (0, compat_1.fromLegacyPublicKey)(address)),
57
- ]) ?? [])), (tx) => sessionKeySigner === undefined
58
- ? tx
59
- : (0, kit_1.addSignersToTransactionMessage)([sessionKeySigner], tx)));
60
- }
61
- else {
62
- const tx = instructions instanceof web3_js_1.VersionedTransaction
63
- ? (0, compat_1.fromVersionedTransaction)(instructions) // VersionedTransaction has a lifetime so it's fine to cast it so we can call partiallySignTransaction
64
- : instructions;
65
- return sessionKey === undefined
66
- ? tx
67
- : (0, kit_1.partiallySignTransaction)([sessionKey], tx);
68
- }
69
- };
70
- const getSponsor = async (options, domain) => {
71
- if (options.sponsor === undefined) {
72
- const url = new URL("/api/sponsor_pubkey", options.paymaster ?? DEFAULT_PAYMASTER);
73
- url.searchParams.set("domain", domain);
74
- const response = await fetch(url);
75
- if (response.status === 200) {
76
- return new web3_js_1.PublicKey(zod_1.z.string().parse(await response.text()));
77
- }
78
- else {
79
- throw new PaymasterResponseError(response.status, await response.text());
80
- }
81
- }
82
- else {
83
- return options.sponsor;
84
- }
85
- };
86
- const sponsorAndSendResponseSchema = zod_1.z
87
- .discriminatedUnion("type", [
88
- zod_1.z.object({
89
- type: zod_1.z.literal("success"),
90
- signature: zod_1.z.string(),
91
- }),
92
- zod_1.z.object({
93
- type: zod_1.z.literal("failed"),
94
- signature: zod_1.z.string(),
95
- error: zod_1.z.object({
96
- InstructionError: zod_1.z.tuple([zod_1.z.number(), zod_1.z.unknown()]),
97
- }),
98
- }),
99
- ])
100
- .transform((data) => {
101
- return data.type === "success"
102
- ? TransactionResult.Success(data.signature)
103
- : TransactionResult.Failed(data.signature, data.error);
104
- });
105
- const sendToPaymaster = async (options, transaction, domain) => {
106
- if (options.sendToPaymaster === undefined) {
107
- const url = new URL("/api/sponsor_and_send", options.paymaster ?? DEFAULT_PAYMASTER);
108
- url.searchParams.set("domain", domain);
109
- const response = await fetch(url, {
110
- method: "POST",
111
- headers: {
112
- "Content-Type": "application/json",
113
- },
114
- body: JSON.stringify({
115
- transaction: (0, kit_1.getBase64EncodedWireTransaction)(transaction),
116
- }),
117
- });
118
- if (response.status === 200) {
119
- return sponsorAndSendResponseSchema.parse(await response.json());
120
- }
121
- else {
122
- throw new PaymasterResponseError(response.status, await response.text());
123
- }
124
- }
125
- else {
126
- return options.sendToPaymaster(transaction);
127
- }
128
- };
129
- const getAddressLookupTables = async (connection, addressLookupTableAddress = DEFAULT_ADDRESS_LOOKUP_TABLE_ADDRESS) => {
130
- const addressLookupTableResult = await connection.getAddressLookupTable(new web3_js_1.PublicKey(addressLookupTableAddress));
131
- return addressLookupTableResult.value
132
- ? [addressLookupTableResult.value]
133
- : undefined;
134
- };
135
28
  const fetchChainId = async (connection) => {
136
29
  const chainIdProgram = new sessions_idls_1.ChainIdProgram(new anchor_1.AnchorProvider(connection, { publicKey: new web3_js_1.Keypair().publicKey }, {})); // We mock the wallet because we don't need to sign anything
137
30
  const { chainIdAccount: chainIdAddress } = await chainIdProgram.methods
@@ -157,12 +50,6 @@ const getDomain = (requestedDomain) => {
157
50
  return requestedDomain;
158
51
  }
159
52
  };
160
- class PaymasterResponseError extends Error {
161
- constructor(statusCode, message) {
162
- super(`Paymaster sent a ${statusCode.toString()} response: ${message}`);
163
- this.name = "PaymasterResponseError";
164
- }
165
- }
166
53
  class NoChainIdAddressError extends Error {
167
54
  constructor() {
168
55
  super("Failed to derive chain ID address");
package/cjs/index.d.ts CHANGED
@@ -1,9 +1,13 @@
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
- import type { SessionContext, TransactionResult } from "./context.js";
6
- export { createSessionContext, TransactionResultType, type SessionContext, type TransactionResult, } from "./context.js";
7
+ import type { TransactionResult } from "./connection.js";
8
+ import type { SessionContext } from "./context.js";
9
+ export { type SessionContext, createSessionContext } from "./context.js";
10
+ export { type TransactionResult, type Connection, Network, TransactionResultType, createSessionConnection, } from "./connection.js";
7
11
  type EstablishSessionOptions = {
8
12
  context: SessionContext;
9
13
  walletPublicKey: PublicKey;
@@ -11,6 +15,7 @@ type EstablishSessionOptions = {
11
15
  expires: Date;
12
16
  extra?: Record<string, string> | undefined;
13
17
  createUnsafeExtractableSessionKey?: boolean | undefined;
18
+ sessionEstablishmentLookupTable?: string | undefined;
14
19
  } & ({
15
20
  limits?: Map<PublicKey, bigint>;
16
21
  unlimited?: false;
@@ -1314,6 +1319,40 @@ type SendTransferOptions = {
1314
1319
  recipient: PublicKey;
1315
1320
  };
1316
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/dist/cjs").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/dist/cjs").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/dist/cjs").FailedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").SourceFinalizedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").InReviewTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").AttestedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").RefundedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").RedeemedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").DestinationQueuedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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/dist/cjs").CompletedTransferReceipt<import("@wormhole-foundation/sdk/dist/cjs").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">>;
1317
1356
  /**
1318
1357
  * Create a login token signed with the session key
1319
1358
  * @param session - The session to create a login token for