@fogo/sessions-sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/connection.d.ts +2 -5
- package/cjs/connection.js +74 -18
- package/cjs/context.d.ts +5 -5
- package/cjs/context.js +1 -1
- package/cjs/index.d.ts +148 -146
- package/cjs/index.js +23 -21
- package/cjs/mints.d.ts +5 -0
- package/cjs/mints.js +9 -0
- package/cjs/network.d.ts +4 -0
- package/cjs/network.js +8 -0
- package/esm/connection.d.ts +2 -5
- package/esm/connection.js +68 -12
- package/esm/context.d.ts +5 -5
- package/esm/context.js +2 -2
- package/esm/index.d.ts +148 -146
- package/esm/index.js +12 -13
- package/esm/mints.d.ts +5 -0
- package/esm/mints.js +6 -0
- package/esm/network.d.ts +4 -0
- package/esm/network.js +5 -0
- package/package.json +1 -1
package/esm/index.js
CHANGED
|
@@ -17,12 +17,16 @@ import { NTT } from "@wormhole-foundation/sdk-solana-ntt";
|
|
|
17
17
|
import BN from "bn.js";
|
|
18
18
|
import bs58 from "bs58";
|
|
19
19
|
import { z } from "zod";
|
|
20
|
-
import {
|
|
20
|
+
import { TransactionResultType } from "./connection.js";
|
|
21
21
|
import { SESSIONS_INTERNAL_PAYMASTER_DOMAIN } from "./context.js";
|
|
22
22
|
import { importKey, signMessageWithKey, verifyMessageWithKey, } from "./crypto.js";
|
|
23
23
|
import { createSessionUnwrapInstruction, createSessionWrapInstructions, createSystemProgramSessionWrapInstruction, } from "./instructions.js";
|
|
24
|
-
|
|
24
|
+
import { USDC_DECIMALS, USDC_MINT } from "./mints.js";
|
|
25
|
+
import { Network } from "./network.js";
|
|
26
|
+
export { createSessionConnection, TransactionResultType, } from "./connection.js";
|
|
25
27
|
export { createSessionContext, } from "./context.js";
|
|
28
|
+
export { createSessionUnwrapInstruction, createSessionWrapInstructions, createSystemProgramSessionWrapInstruction, } from "./instructions.js";
|
|
29
|
+
export { Network } from "./network.js";
|
|
26
30
|
const MESSAGE_HEADER = `Fogo Sessions:
|
|
27
31
|
Signing this intent will allow this app to interact with your on-chain balances. Please make sure you trust this app and the domain in the message matches the domain of the current web application.
|
|
28
32
|
`;
|
|
@@ -61,7 +65,7 @@ export const establishSession = async (options) => {
|
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
const sendSessionEstablishTransaction = async (options, sessionKey, instructions, sessionEstablishmentLookupTable) => {
|
|
64
|
-
const result = await options.context.sendTransaction(sessionKey, instructions, {
|
|
68
|
+
const result = await options.context.sendTransaction(sessionKey, instructions, options.walletPublicKey, {
|
|
65
69
|
variation: "Session Establishment",
|
|
66
70
|
addressLookupTable: sessionEstablishmentLookupTable ??
|
|
67
71
|
SESSION_ESTABLISHMENT_LOOKUP_TABLE_ADDRESS[options.context.network],
|
|
@@ -91,7 +95,7 @@ export const revokeSession = async (options) => {
|
|
|
91
95
|
session: options.session.sessionPublicKey,
|
|
92
96
|
})
|
|
93
97
|
.instruction();
|
|
94
|
-
return options.context.sendTransaction(options.session.sessionKey, [instruction], {
|
|
98
|
+
return options.context.sendTransaction(options.session.sessionKey, [instruction], options.session.walletPublicKey, {
|
|
95
99
|
variation: "Session Revocation",
|
|
96
100
|
});
|
|
97
101
|
}
|
|
@@ -121,7 +125,7 @@ const createSession = async (context, walletPublicKey, sessionKey) => {
|
|
|
121
125
|
getSessionUnwrapInstructions: () => [
|
|
122
126
|
createSessionUnwrapInstruction(sessionPublicKey, walletPublicKey),
|
|
123
127
|
],
|
|
124
|
-
sendTransaction: (instructions, extraConfig) => context.sendTransaction(sessionKey, instructions, extraConfig),
|
|
128
|
+
sendTransaction: (instructions, extraConfig) => context.sendTransaction(sessionKey, instructions, walletPublicKey, extraConfig),
|
|
125
129
|
sessionInfo,
|
|
126
130
|
};
|
|
127
131
|
};
|
|
@@ -487,11 +491,6 @@ const EstablishSessionResult = {
|
|
|
487
491
|
error,
|
|
488
492
|
}),
|
|
489
493
|
};
|
|
490
|
-
const USDC_MINT = {
|
|
491
|
-
[Network.Mainnet]: "uSd2czE61Evaf76RNbq4KPpXnkiL3irdzgLFUMe3NoG",
|
|
492
|
-
[Network.Testnet]: "ELNbJ1RtERV2fjtuZjbTscDekWhVzkQ1LjmiPsxp5uND",
|
|
493
|
-
};
|
|
494
|
-
const USDC_DECIMALS = 6;
|
|
495
494
|
export const getTransferFee = async (context) => {
|
|
496
495
|
const { fee, ...config } = await getFee(context);
|
|
497
496
|
return {
|
|
@@ -554,7 +553,7 @@ export const sendTransfer = async (options) => {
|
|
|
554
553
|
symbol === undefined ? null : new PublicKey(metadataAddress),
|
|
555
554
|
})
|
|
556
555
|
.instruction(),
|
|
557
|
-
], {
|
|
556
|
+
], options.walletPublicKey, {
|
|
558
557
|
variation: "Intent Transfer",
|
|
559
558
|
paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
|
|
560
559
|
});
|
|
@@ -590,7 +589,7 @@ export const sendNativeTransfer = async (options) => {
|
|
|
590
589
|
sponsor: options.context.internalPayer,
|
|
591
590
|
})
|
|
592
591
|
.instruction(),
|
|
593
|
-
], {
|
|
592
|
+
], options.walletPublicKey, {
|
|
594
593
|
variation: "Intent Transfer",
|
|
595
594
|
paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
|
|
596
595
|
});
|
|
@@ -653,7 +652,7 @@ export const bridgeOut = async (options) => {
|
|
|
653
652
|
return options.context.sendTransaction(options.sessionKey, [
|
|
654
653
|
ComputeBudgetProgram.setComputeUnitLimit({ units: BRIDGE_OUT_CUS }),
|
|
655
654
|
...instructions,
|
|
656
|
-
], {
|
|
655
|
+
], options.walletPublicKey, {
|
|
657
656
|
variation: "Intent NTT Bridge",
|
|
658
657
|
paymasterDomain: SESSIONS_INTERNAL_PAYMASTER_DOMAIN,
|
|
659
658
|
extraSigners: [outboxItem],
|
package/esm/mints.d.ts
ADDED
package/esm/mints.js
ADDED
package/esm/network.d.ts
ADDED
package/esm/network.js
ADDED