@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
package/dist/index.d.ts
CHANGED
|
@@ -94,9 +94,8 @@ export declare function withdrawWsolWithSession(connection: Connection, stakePoo
|
|
|
94
94
|
* Creates instructions required to withdraw stake from a stake pool using a Fogo session.
|
|
95
95
|
* The withdrawn stake account will be authorized to the user's wallet.
|
|
96
96
|
*/
|
|
97
|
-
export declare function withdrawStakeWithSession(connection: Connection, stakePoolAddress: PublicKey, signerOrSession: PublicKey, userPubkey: PublicKey, amount: number, useReserve?: boolean, voteAccountAddress?: PublicKey, minimumLamportsOut?: number,
|
|
97
|
+
export declare function withdrawStakeWithSession(connection: Connection, stakePoolAddress: PublicKey, signerOrSession: PublicKey, userPubkey: PublicKey, amount: number, payer: PublicKey, useReserve?: boolean, voteAccountAddress?: PublicKey, minimumLamportsOut?: number, validatorComparator?: (_a: ValidatorAccount, _b: ValidatorAccount) => number): Promise<{
|
|
98
98
|
instructions: TransactionInstruction[];
|
|
99
|
-
signers: Signer[];
|
|
100
99
|
stakeAccountPubkeys: PublicKey[];
|
|
101
100
|
}>;
|
|
102
101
|
export declare function addValidatorToPool(connection: Connection, stakePoolAddress: PublicKey, validatorVote: PublicKey, seed?: number): Promise<{
|
package/dist/index.esm.js
CHANGED
|
@@ -2223,7 +2223,7 @@ async function withdrawWsolWithSession(connection, stakePoolAddress, signerOrSes
|
|
|
2223
2223
|
* Creates instructions required to withdraw stake from a stake pool using a Fogo session.
|
|
2224
2224
|
* The withdrawn stake account will be authorized to the user's wallet.
|
|
2225
2225
|
*/
|
|
2226
|
-
async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, useReserve = false, voteAccountAddress, minimumLamportsOut = 0,
|
|
2226
|
+
async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSession, userPubkey, amount, payer, useReserve = false, voteAccountAddress, minimumLamportsOut = 0, validatorComparator) {
|
|
2227
2227
|
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
|
|
2228
2228
|
const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
|
|
2229
2229
|
const stakePool = stakePoolAccount.account.data;
|
|
@@ -2273,7 +2273,6 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2273
2273
|
withdrawAccounts.push(...(await prepareWithdrawAccounts(connection, stakePool, stakePoolAddress, poolAmount, validatorComparator, poolTokenAccount.equals(stakePool.managerFeeAccount))));
|
|
2274
2274
|
}
|
|
2275
2275
|
const instructions = [];
|
|
2276
|
-
const signers = [];
|
|
2277
2276
|
const stakeAccountPubkeys = [];
|
|
2278
2277
|
// Max 5 accounts to prevent an error: "Transaction too large"
|
|
2279
2278
|
const maxWithdrawAccounts = 5;
|
|
@@ -2282,14 +2281,21 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2282
2281
|
if (i >= maxWithdrawAccounts) {
|
|
2283
2282
|
break;
|
|
2284
2283
|
}
|
|
2285
|
-
// Create a
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2284
|
+
// Create a deterministic stake account address using a seed
|
|
2285
|
+
// This avoids needing the new account to sign (required for sessions)
|
|
2286
|
+
// We use payer as base so only payer needs to sign (payer = basePubkey)
|
|
2287
|
+
// The seed includes timestamp + random component to ensure uniqueness
|
|
2288
|
+
const uniqueId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2289
|
+
const seed = `ws:${uniqueId}:${i}`.slice(0, 32); // Seed max 32 chars
|
|
2290
|
+
const stakeReceiverPubkey = await PublicKey.createWithSeed(payer, seed, StakeProgram.programId);
|
|
2291
|
+
stakeAccountPubkeys.push(stakeReceiverPubkey);
|
|
2292
|
+
// Create the stake account using createAccountWithSeed
|
|
2293
|
+
// Since basePubkey === fromPubkey (both are payer), only payer needs to sign
|
|
2294
|
+
instructions.push(SystemProgram.createAccountWithSeed({
|
|
2295
|
+
fromPubkey: payer,
|
|
2296
|
+
newAccountPubkey: stakeReceiverPubkey,
|
|
2297
|
+
basePubkey: payer,
|
|
2298
|
+
seed,
|
|
2293
2299
|
lamports: stakeAccountRentExemption,
|
|
2294
2300
|
space: StakeProgram.space,
|
|
2295
2301
|
programId: StakeProgram.programId,
|
|
@@ -2301,7 +2307,7 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2301
2307
|
validatorList: stakePool.validatorList,
|
|
2302
2308
|
withdrawAuthority,
|
|
2303
2309
|
stakeToSplit: withdrawAccount.stakeAddress,
|
|
2304
|
-
stakeToReceive:
|
|
2310
|
+
stakeToReceive: stakeReceiverPubkey,
|
|
2305
2311
|
sessionSigner: signerOrSession,
|
|
2306
2312
|
burnFromPool: poolTokenAccount,
|
|
2307
2313
|
managerFeeAccount: stakePool.managerFeeAccount,
|
|
@@ -2309,13 +2315,12 @@ async function withdrawStakeWithSession(connection, stakePoolAddress, signerOrSe
|
|
|
2309
2315
|
tokenProgramId: stakePool.tokenProgramId,
|
|
2310
2316
|
programSigner,
|
|
2311
2317
|
poolTokensIn: withdrawAccount.poolAmount.toNumber(),
|
|
2312
|
-
minimumLamportsOut
|
|
2318
|
+
minimumLamportsOut,
|
|
2313
2319
|
}));
|
|
2314
2320
|
i++;
|
|
2315
2321
|
}
|
|
2316
2322
|
return {
|
|
2317
2323
|
instructions,
|
|
2318
|
-
signers,
|
|
2319
2324
|
stakeAccountPubkeys,
|
|
2320
2325
|
};
|
|
2321
2326
|
}
|