@fogo/sessions-sdk 0.1.7 → 0.1.8
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 -1
- package/cjs/connection.js +7 -4
- package/esm/connection.d.ts +2 -1
- package/esm/connection.js +7 -4
- package/package.json +1 -1
package/cjs/connection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetLatestBlockhashApi, Instruction, Rpc, Transaction, TransactionWithLifetime } from "@solana/kit";
|
|
1
|
+
import type { Address, GetLatestBlockhashApi, Instruction, Rpc, Transaction, TransactionWithLifetime } from "@solana/kit";
|
|
2
2
|
import type { TransactionError } from "@solana/web3.js";
|
|
3
3
|
import { Keypair, PublicKey, TransactionInstruction, VersionedTransaction, Connection as Web3Connection } from "@solana/web3.js";
|
|
4
4
|
import { Network } from "./network.js";
|
|
@@ -42,6 +42,7 @@ export type SendTransactionOptions = {
|
|
|
42
42
|
variation?: string | undefined;
|
|
43
43
|
addressLookupTable?: string | undefined;
|
|
44
44
|
extraSigners?: (CryptoKeyPair | Keypair)[] | undefined;
|
|
45
|
+
feeMint?: PublicKey | Address;
|
|
45
46
|
};
|
|
46
47
|
export type Connection = ReturnType<typeof createSessionConnection>;
|
|
47
48
|
export {};
|
package/cjs/connection.js
CHANGED
|
@@ -11,7 +11,6 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
11
11
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
12
12
|
const zod_1 = require("zod");
|
|
13
13
|
const instructions_js_1 = require("./instructions.js");
|
|
14
|
-
const mints_js_1 = require("./mints.js");
|
|
15
14
|
const network_js_1 = require("./network.js");
|
|
16
15
|
const paymaster_js_1 = require("./paymaster.js");
|
|
17
16
|
const DEFAULT_RPC = {
|
|
@@ -108,7 +107,9 @@ const sendToPaymaster = async (connection, domain, sessionKey, instructions, wal
|
|
|
108
107
|
}
|
|
109
108
|
};
|
|
110
109
|
const buildTransaction = async (connection, domain, sessionKey, signerKeys, instructions, walletPublicKey, extraConfig) => {
|
|
111
|
-
const feeMint =
|
|
110
|
+
const feeMint = extraConfig?.feeMint === undefined
|
|
111
|
+
? undefined
|
|
112
|
+
: new web3_js_1.PublicKey(extraConfig.feeMint);
|
|
112
113
|
const [{ value: latestBlockhash }, sponsor, addressLookupTable, signers, feeAmount, sessionKeyAddress,] = await Promise.all([
|
|
113
114
|
connection.rpc.getLatestBlockhash().send(),
|
|
114
115
|
connection.sponsor === undefined
|
|
@@ -118,7 +119,7 @@ const buildTransaction = async (connection, domain, sessionKey, signerKeys, inst
|
|
|
118
119
|
? Promise.resolve(undefined)
|
|
119
120
|
: getAddressLookupTable(connection.connection, connection.addressLookupTableCache, extraConfig.addressLookupTable),
|
|
120
121
|
Promise.all(signerKeys.map((signer) => (0, kit_1.createSignerFromKeyPair)(signer))),
|
|
121
|
-
extraConfig?.variation === undefined
|
|
122
|
+
extraConfig?.variation === undefined || feeMint === undefined
|
|
122
123
|
? Promise.resolve(new bn_js_1.default(0))
|
|
123
124
|
: (0, paymaster_js_1.getPaymasterFee)(connection.paymaster ?? DEFAULT_PAYMASTER[connection.network], domain, extraConfig.variation, feeMint),
|
|
124
125
|
sessionKey === undefined
|
|
@@ -144,7 +145,9 @@ const buildTransaction = async (connection, domain, sessionKey, signerKeys, inst
|
|
|
144
145
|
}), (tx) => (0, kit_1.addSignersToTransactionMessage)(signers, tx)));
|
|
145
146
|
};
|
|
146
147
|
const buildTollboothInstructionIfNeeded = ({ sessionKeyAddress, walletPublicKey, domain, feeMint, feeAmount, }) => {
|
|
147
|
-
if (feeAmount.gt(new bn_js_1.default(0)) &&
|
|
148
|
+
if (feeAmount.gt(new bn_js_1.default(0)) &&
|
|
149
|
+
sessionKeyAddress !== undefined &&
|
|
150
|
+
feeMint !== undefined) {
|
|
148
151
|
return (0, instructions_js_1.createPaymasterFeeInstruction)({
|
|
149
152
|
sessionKey: new web3_js_1.PublicKey(sessionKeyAddress),
|
|
150
153
|
walletPublicKey,
|
package/esm/connection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetLatestBlockhashApi, Instruction, Rpc, Transaction, TransactionWithLifetime } from "@solana/kit";
|
|
1
|
+
import type { Address, GetLatestBlockhashApi, Instruction, Rpc, Transaction, TransactionWithLifetime } from "@solana/kit";
|
|
2
2
|
import type { TransactionError } from "@solana/web3.js";
|
|
3
3
|
import { Keypair, PublicKey, TransactionInstruction, VersionedTransaction, Connection as Web3Connection } from "@solana/web3.js";
|
|
4
4
|
import { Network } from "./network.js";
|
|
@@ -42,6 +42,7 @@ export type SendTransactionOptions = {
|
|
|
42
42
|
variation?: string | undefined;
|
|
43
43
|
addressLookupTable?: string | undefined;
|
|
44
44
|
extraSigners?: (CryptoKeyPair | Keypair)[] | undefined;
|
|
45
|
+
feeMint?: PublicKey | Address;
|
|
45
46
|
};
|
|
46
47
|
export type Connection = ReturnType<typeof createSessionConnection>;
|
|
47
48
|
export {};
|
package/esm/connection.js
CHANGED
|
@@ -5,7 +5,6 @@ import { Keypair, PublicKey, TransactionInstruction, VersionedTransaction, Conne
|
|
|
5
5
|
import BN from "bn.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { createPaymasterFeeInstruction } from "./instructions.js";
|
|
8
|
-
import { USDC_MINT } from "./mints.js";
|
|
9
8
|
import { Network } from "./network.js";
|
|
10
9
|
import { getPaymasterFee, PaymasterResponseError } from "./paymaster.js";
|
|
11
10
|
const DEFAULT_RPC = {
|
|
@@ -101,7 +100,9 @@ const sendToPaymaster = async (connection, domain, sessionKey, instructions, wal
|
|
|
101
100
|
}
|
|
102
101
|
};
|
|
103
102
|
const buildTransaction = async (connection, domain, sessionKey, signerKeys, instructions, walletPublicKey, extraConfig) => {
|
|
104
|
-
const feeMint =
|
|
103
|
+
const feeMint = extraConfig?.feeMint === undefined
|
|
104
|
+
? undefined
|
|
105
|
+
: new PublicKey(extraConfig.feeMint);
|
|
105
106
|
const [{ value: latestBlockhash }, sponsor, addressLookupTable, signers, feeAmount, sessionKeyAddress,] = await Promise.all([
|
|
106
107
|
connection.rpc.getLatestBlockhash().send(),
|
|
107
108
|
connection.sponsor === undefined
|
|
@@ -111,7 +112,7 @@ const buildTransaction = async (connection, domain, sessionKey, signerKeys, inst
|
|
|
111
112
|
? Promise.resolve(undefined)
|
|
112
113
|
: getAddressLookupTable(connection.connection, connection.addressLookupTableCache, extraConfig.addressLookupTable),
|
|
113
114
|
Promise.all(signerKeys.map((signer) => createSignerFromKeyPair(signer))),
|
|
114
|
-
extraConfig?.variation === undefined
|
|
115
|
+
extraConfig?.variation === undefined || feeMint === undefined
|
|
115
116
|
? Promise.resolve(new BN(0))
|
|
116
117
|
: getPaymasterFee(connection.paymaster ?? DEFAULT_PAYMASTER[connection.network], domain, extraConfig.variation, feeMint),
|
|
117
118
|
sessionKey === undefined
|
|
@@ -137,7 +138,9 @@ const buildTransaction = async (connection, domain, sessionKey, signerKeys, inst
|
|
|
137
138
|
}), (tx) => addSignersToTransactionMessage(signers, tx)));
|
|
138
139
|
};
|
|
139
140
|
const buildTollboothInstructionIfNeeded = ({ sessionKeyAddress, walletPublicKey, domain, feeMint, feeAmount, }) => {
|
|
140
|
-
if (feeAmount.gt(new BN(0)) &&
|
|
141
|
+
if (feeAmount.gt(new BN(0)) &&
|
|
142
|
+
sessionKeyAddress !== undefined &&
|
|
143
|
+
feeMint !== undefined) {
|
|
141
144
|
return createPaymasterFeeInstruction({
|
|
142
145
|
sessionKey: new PublicKey(sessionKeyAddress),
|
|
143
146
|
walletPublicKey,
|