@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignitionfi/spl-stake-pool",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "description": "Ignition Stake Pool SDK for FOGO",
5
5
  "contributors": [
6
6
  "Anza Maintainers <maintainers@anza.xyz>",
package/src/index.ts CHANGED
@@ -900,10 +900,10 @@ export async function withdrawStakeWithSession(
900
900
  signerOrSession: PublicKey,
901
901
  userPubkey: PublicKey,
902
902
  amount: number,
903
+ payer: PublicKey,
903
904
  useReserve = false,
904
905
  voteAccountAddress?: PublicKey,
905
906
  minimumLamportsOut: number = 0,
906
- payer?: PublicKey,
907
907
  validatorComparator?: (_a: ValidatorAccount, _b: ValidatorAccount) => number,
908
908
  ) {
909
909
  const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress)
@@ -991,7 +991,6 @@ export async function withdrawStakeWithSession(
991
991
  }
992
992
 
993
993
  const instructions: TransactionInstruction[] = []
994
- const signers: Signer[] = []
995
994
  const stakeAccountPubkeys: PublicKey[] = []
996
995
 
997
996
  // Max 5 accounts to prevent an error: "Transaction too large"
@@ -1003,16 +1002,27 @@ export async function withdrawStakeWithSession(
1003
1002
  break
1004
1003
  }
1005
1004
 
1006
- // Create a new stake account to receive the withdrawal
1007
- const stakeReceiver = Keypair.generate()
1008
- signers.push(stakeReceiver)
1009
- stakeAccountPubkeys.push(stakeReceiver.publicKey)
1005
+ // Create a deterministic stake account address using a seed
1006
+ // This avoids needing the new account to sign (required for sessions)
1007
+ // We use payer as base so only payer needs to sign (payer = basePubkey)
1008
+ // The seed includes timestamp + random component to ensure uniqueness
1009
+ const uniqueId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
1010
+ const seed = `ws:${uniqueId}:${i}`.slice(0, 32) // Seed max 32 chars
1011
+ const stakeReceiverPubkey = await PublicKey.createWithSeed(
1012
+ payer,
1013
+ seed,
1014
+ StakeProgram.programId,
1015
+ )
1016
+ stakeAccountPubkeys.push(stakeReceiverPubkey)
1010
1017
 
1011
- // Create the stake account that will receive the split stake
1018
+ // Create the stake account using createAccountWithSeed
1019
+ // Since basePubkey === fromPubkey (both are payer), only payer needs to sign
1012
1020
  instructions.push(
1013
- SystemProgram.createAccount({
1014
- fromPubkey: payer ?? userPubkey,
1015
- newAccountPubkey: stakeReceiver.publicKey,
1021
+ SystemProgram.createAccountWithSeed({
1022
+ fromPubkey: payer,
1023
+ newAccountPubkey: stakeReceiverPubkey,
1024
+ basePubkey: payer,
1025
+ seed,
1016
1026
  lamports: stakeAccountRentExemption,
1017
1027
  space: StakeProgram.space,
1018
1028
  programId: StakeProgram.programId,
@@ -1027,7 +1037,7 @@ export async function withdrawStakeWithSession(
1027
1037
  validatorList: stakePool.validatorList,
1028
1038
  withdrawAuthority,
1029
1039
  stakeToSplit: withdrawAccount.stakeAddress,
1030
- stakeToReceive: stakeReceiver.publicKey,
1040
+ stakeToReceive: stakeReceiverPubkey,
1031
1041
  sessionSigner: signerOrSession,
1032
1042
  burnFromPool: poolTokenAccount,
1033
1043
  managerFeeAccount: stakePool.managerFeeAccount,
@@ -1035,7 +1045,7 @@ export async function withdrawStakeWithSession(
1035
1045
  tokenProgramId: stakePool.tokenProgramId,
1036
1046
  programSigner,
1037
1047
  poolTokensIn: withdrawAccount.poolAmount.toNumber(),
1038
- minimumLamportsOut: solToLamports(minimumLamportsOut),
1048
+ minimumLamportsOut,
1039
1049
  }),
1040
1050
  )
1041
1051
  i++
@@ -1043,7 +1053,6 @@ export async function withdrawStakeWithSession(
1043
1053
 
1044
1054
  return {
1045
1055
  instructions,
1046
- signers,
1047
1056
  stakeAccountPubkeys,
1048
1057
  }
1049
1058
  }