@ignitionfi/spl-stake-pool 1.1.21 → 1.1.22
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/dist/index.browser.cjs.js +18 -13
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.browser.esm.js +18 -13
- package/dist/index.browser.esm.js.map +1 -1
- package/dist/index.cjs.js +18 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.esm.js +18 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +18 -13
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +22 -13
|
@@ -2244,7 +2244,7 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
|
|
|
2244
2244
|
* Creates instructions required to withdraw stake from a stake pool using a Fogo session.
|
|
2245
2245
|
* The withdrawn stake account will be authorized to the user's wallet.
|
|
2246
2246
|
*/
|
|
2247
|
-
async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, useReserve = false, voteAccountAddress, minimumLamportsOut = 0,
|
|
2247
|
+
async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, payer, useReserve = false, voteAccountAddress, minimumLamportsOut = 0, validatorComparator) {
|
|
2248
2248
|
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
|
|
2249
2249
|
const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
|
|
2250
2250
|
const stakePool = stakePoolAccount.account.data;
|
|
@@ -2294,7 +2294,6 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2294
2294
|
withdrawAccounts.push(...(await prepareWithdrawAccounts(connection, stakePool, stakePoolAddress, poolAmount, validatorComparator, poolTokenAccount.equals(stakePool.managerFeeAccount))));
|
|
2295
2295
|
}
|
|
2296
2296
|
const instructions = [];
|
|
2297
|
-
const signers = [];
|
|
2298
2297
|
const stakeAccountPubkeys = [];
|
|
2299
2298
|
// Max 5 accounts to prevent an error: "Transaction too large"
|
|
2300
2299
|
const maxWithdrawAccounts = 5;
|
|
@@ -2303,14 +2302,21 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2303
2302
|
if (i >= maxWithdrawAccounts) {
|
|
2304
2303
|
break;
|
|
2305
2304
|
}
|
|
2306
|
-
// Create a
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2305
|
+
// Create a deterministic stake account address using a seed
|
|
2306
|
+
// This avoids needing the new account to sign (required for sessions)
|
|
2307
|
+
// We use payer as base so only payer needs to sign (payer = basePubkey)
|
|
2308
|
+
// The seed includes timestamp + random component to ensure uniqueness
|
|
2309
|
+
const uniqueId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2310
|
+
const seed = `ws:${uniqueId}:${i}`.slice(0, 32); // Seed max 32 chars
|
|
2311
|
+
const stakeReceiverPubkey = await web3_js.PublicKey.createWithSeed(payer, seed, web3_js.StakeProgram.programId);
|
|
2312
|
+
stakeAccountPubkeys.push(stakeReceiverPubkey);
|
|
2313
|
+
// Create the stake account using createAccountWithSeed
|
|
2314
|
+
// Since basePubkey === fromPubkey (both are payer), only payer needs to sign
|
|
2315
|
+
instructions.push(web3_js.SystemProgram.createAccountWithSeed({
|
|
2316
|
+
fromPubkey: payer,
|
|
2317
|
+
newAccountPubkey: stakeReceiverPubkey,
|
|
2318
|
+
basePubkey: payer,
|
|
2319
|
+
seed,
|
|
2314
2320
|
lamports: stakeAccountRentExemption,
|
|
2315
2321
|
space: web3_js.StakeProgram.space,
|
|
2316
2322
|
programId: web3_js.StakeProgram.programId,
|
|
@@ -2322,7 +2328,7 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2322
2328
|
validatorList: stakePool.validatorList,
|
|
2323
2329
|
withdrawAuthority,
|
|
2324
2330
|
stakeToSplit: withdrawAccount.stakeAddress,
|
|
2325
|
-
stakeToReceive:
|
|
2331
|
+
stakeToReceive: stakeReceiverPubkey,
|
|
2326
2332
|
sessionSigner: signerOrSession,
|
|
2327
2333
|
burnFromPool: poolTokenAccount,
|
|
2328
2334
|
managerFeeAccount: stakePool.managerFeeAccount,
|
|
@@ -2330,13 +2336,12 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2330
2336
|
tokenProgramId: stakePool.tokenProgramId,
|
|
2331
2337
|
programSigner,
|
|
2332
2338
|
poolTokensIn: withdrawAccount.poolAmount.toNumber(),
|
|
2333
|
-
minimumLamportsOut
|
|
2339
|
+
minimumLamportsOut,
|
|
2334
2340
|
}));
|
|
2335
2341
|
i++;
|
|
2336
2342
|
}
|
|
2337
2343
|
return {
|
|
2338
2344
|
instructions,
|
|
2339
|
-
signers,
|
|
2340
2345
|
stakeAccountPubkeys,
|
|
2341
2346
|
};
|
|
2342
2347
|
}
|