@ignitionfi/spl-stake-pool 1.1.25 → 1.1.26

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.
@@ -832,7 +832,7 @@ async function prepareWithdrawAccounts(connection, stakePool, stakePoolAddress,
832
832
  const stakePoolProgramId = getStakePoolProgramId(connection.rpcEndpoint);
833
833
  const validatorListAcc = await connection.getAccountInfo(stakePool.validatorList);
834
834
  const validatorList = ValidatorListLayout.decode(validatorListAcc === null || validatorListAcc === void 0 ? void 0 : validatorListAcc.data);
835
- if (!(validatorList === null || validatorList === void 0 ? void 0 : validatorList.validators) || (validatorList === null || validatorList === void 0 ? void 0 : validatorList.validators.length) == 0) {
835
+ if (!(validatorList === null || validatorList === void 0 ? void 0 : validatorList.validators) || (validatorList === null || validatorList === void 0 ? void 0 : validatorList.validators.length) === 0) {
836
836
  throw new Error('No accounts found');
837
837
  }
838
838
  const minBalanceForRentExemption = await connection.getMinimumBalanceForRentExemption(web3_js.StakeProgram.space);
@@ -887,9 +887,9 @@ async function prepareWithdrawAccounts(connection, stakePool, stakePoolAddress,
887
887
  denominator: fee.denominator,
888
888
  };
889
889
  for (const type of ['preferred', 'active', 'transient', 'reserve']) {
890
- const filteredAccounts = accounts.filter(a => a.type == type);
890
+ const filteredAccounts = accounts.filter(a => a.type === type);
891
891
  for (const { stakeAddress, voteAddress, lamports } of filteredAccounts) {
892
- if (lamports.lte(minBalance) && type == 'transient') {
892
+ if (lamports.lte(minBalance) && type === 'transient') {
893
893
  continue;
894
894
  }
895
895
  let availableForWithdrawal = calcPoolTokensForDeposit(stakePool, lamports);
@@ -1664,38 +1664,25 @@ class StakePoolInstruction {
1664
1664
  /**
1665
1665
  * Creates a transaction instruction to withdraw SOL from a deactivated user stake account using a Fogo session.
1666
1666
  * The stake account must be fully deactivated (inactive).
1667
- * User receives full stake balance (payer's rent contribution compensates for reduced split).
1668
1667
  */
1669
1668
  static withdrawFromStakeAccountWithSession(params) {
1670
- // For u64::MAX (full withdrawal), we need to manually encode since buffer-layout doesn't handle bigint well
1671
- const U64_MAX = BigInt('18446744073709551615');
1672
- const isFullWithdrawal = params.lamports >= U64_MAX;
1673
- // Manually create the instruction data buffer using Uint8Array for browser compatibility
1674
- // Layout: u8 instruction (1) + u64 lamports (8) + u64 userStakeSeed (8) = 17 bytes
1675
- const data = new Uint8Array(17);
1676
- data[0] = 30; // instruction discriminator (WithdrawFromStakeAccountWithSession = 30)
1677
- // Write lamports as u64 little-endian (bytes 1-8)
1678
- const lamportsBigInt = isFullWithdrawal ? U64_MAX : params.lamports;
1679
- for (let i = 0; i < 8; i++) {
1680
- data[1 + i] = Number((lamportsBigInt >> BigInt(i * 8)) & BigInt(0xff));
1681
- }
1682
- // Write userStakeSeed as u64 little-endian (bytes 9-16)
1683
- const seedBigInt = BigInt(params.userStakeSeed);
1684
- for (let i = 0; i < 8; i++) {
1685
- data[9 + i] = Number((seedBigInt >> BigInt(i * 8)) & BigInt(0xff));
1686
- }
1687
- // Account order matches Rust: stake_account, recipient, clock, stake_history, session_signer
1669
+ const type = STAKE_POOL_INSTRUCTION_LAYOUTS.WithdrawFromStakeAccountWithSession;
1670
+ const data = encodeData(type, {
1671
+ lamports: params.lamports,
1672
+ userStakeSeed: params.userStakeSeed,
1673
+ });
1688
1674
  const keys = [
1689
1675
  { pubkey: params.userStakeAccount, isSigner: false, isWritable: true },
1690
1676
  { pubkey: params.userWallet, isSigner: false, isWritable: true },
1691
1677
  { pubkey: web3_js.SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
1692
1678
  { pubkey: web3_js.SYSVAR_STAKE_HISTORY_PUBKEY, isSigner: false, isWritable: false },
1693
1679
  { pubkey: params.sessionSigner, isSigner: true, isWritable: false },
1680
+ { pubkey: web3_js.StakeProgram.programId, isSigner: false, isWritable: false },
1694
1681
  ];
1695
1682
  return new web3_js.TransactionInstruction({
1696
1683
  programId: params.programId,
1697
1684
  keys,
1698
- data: Buffer.from(data),
1685
+ data,
1699
1686
  });
1700
1687
  }
1701
1688
  /**