@streamflow/staking 8.0.1 → 8.0.2-alpha.p287.a3616ff

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/esm/index.js CHANGED
@@ -2,7 +2,7 @@ import { Program, translateError, parseIdlErrors } from '@coral-xyz/anchor';
2
2
  import { TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
3
3
  import { PublicKey, Connection } from '@solana/web3.js';
4
4
  import { ICluster, invariant, ContractError, getNumberFromBN, getBN, divCeilN } from '@streamflow/common';
5
- import { buildSendThrottler, getFilters, pk, checkOrCreateAtaBatch, prepareTransaction, prepareBaseInstructions, signAndExecuteTransaction } from '@streamflow/common/solana';
5
+ import { buildSendThrottler, getFilters, unwrapExecutionParams, createAndEstimateTransaction, prepareBaseInstructions, pk, checkOrCreateAtaBatch, prepareTransaction, signAndExecuteTransaction } from '@streamflow/common/solana';
6
6
  import BN3 from 'bn.js';
7
7
  import '@solana/wallet-adapter-base';
8
8
 
@@ -2443,8 +2443,16 @@ var SolanaStakingClient = class {
2443
2443
  return feeManagerProgram.account.feeValue.fetchNullable(feeValueKey);
2444
2444
  }
2445
2445
  async createStakePool(data, extParams) {
2446
- const { ixs, publicKey } = await this.prepareCreateStakePoolInstructions(data, extParams);
2447
- const { signature } = await this.execute(ixs, extParams);
2446
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2447
+ const { ixs, publicKey } = await createAndEstimateTransaction(
2448
+ async (params) => this.prepareCreateStakePoolInstructions(data, params).then((res) => ({
2449
+ ixs: prepareBaseInstructions(this.connection, params).concat(res.ixs),
2450
+ publicKey: res.publicKey
2451
+ })),
2452
+ executionParams,
2453
+ (res) => res.ixs
2454
+ );
2455
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2448
2456
  return {
2449
2457
  ixs,
2450
2458
  txId: signature,
@@ -2474,8 +2482,14 @@ var SolanaStakingClient = class {
2474
2482
  return { ixs: [createInstruction], publicKey: stakePoolPDA };
2475
2483
  }
2476
2484
  async stake(data, extParams) {
2477
- const { ixs } = await this.prepareStakeInstructions(data, extParams);
2478
- const { signature } = await this.execute(ixs, extParams);
2485
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2486
+ const ixs = await createAndEstimateTransaction(
2487
+ (params) => this.prepareStakeInstructions(data, params).then(
2488
+ (res) => prepareBaseInstructions(this.connection, params).concat(res.ixs)
2489
+ ),
2490
+ executionParams
2491
+ );
2492
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2479
2493
  return {
2480
2494
  ixs,
2481
2495
  txId: signature
@@ -2499,8 +2513,14 @@ var SolanaStakingClient = class {
2499
2513
  return { ixs: [instruction] };
2500
2514
  }
2501
2515
  async unstake(data, extParams) {
2502
- const { ixs } = await this.prepareUnstakeInstructions(data, extParams);
2503
- const { signature } = await this.execute(ixs, extParams);
2516
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2517
+ const ixs = await createAndEstimateTransaction(
2518
+ (params) => this.prepareUnstakeInstructions(data, params).then(
2519
+ (res) => prepareBaseInstructions(this.connection, params).concat(res.ixs)
2520
+ ),
2521
+ executionParams
2522
+ );
2523
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2504
2524
  return {
2505
2525
  ixs,
2506
2526
  txId: signature
@@ -2524,8 +2544,16 @@ var SolanaStakingClient = class {
2524
2544
  return { ixs: [instruction] };
2525
2545
  }
2526
2546
  async createRewardPool(data, extParams) {
2527
- const { ixs, publicKey } = await this.prepareCreateRewardPoolInstructions(data, extParams);
2528
- const { signature } = await this.execute(ixs, extParams);
2547
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2548
+ const { ixs, publicKey } = await createAndEstimateTransaction(
2549
+ async (params) => this.prepareCreateRewardPoolInstructions(data, params).then((res) => ({
2550
+ ixs: prepareBaseInstructions(this.connection, params).concat(res.ixs),
2551
+ publicKey: res.publicKey
2552
+ })),
2553
+ executionParams,
2554
+ (res) => res.ixs
2555
+ );
2556
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2529
2557
  return {
2530
2558
  ixs,
2531
2559
  txId: signature,
@@ -2555,8 +2583,14 @@ var SolanaStakingClient = class {
2555
2583
  return { publicKey: rewardPoolKey, ixs: [instruction] };
2556
2584
  }
2557
2585
  async claimRewards(data, extParams) {
2558
- const { ixs } = await this.prepareClaimRewardsInstructions(data, extParams);
2559
- const { signature } = await this.execute(ixs, extParams);
2586
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2587
+ const ixs = await createAndEstimateTransaction(
2588
+ (params) => this.prepareClaimRewardsInstructions(data, params).then(
2589
+ (res) => prepareBaseInstructions(this.connection, params).concat(res.ixs)
2590
+ ),
2591
+ executionParams
2592
+ );
2593
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2560
2594
  return {
2561
2595
  ixs,
2562
2596
  txId: signature
@@ -2576,8 +2610,14 @@ var SolanaStakingClient = class {
2576
2610
  return { ixs: [instruction] };
2577
2611
  }
2578
2612
  async fundPool(data, extParams) {
2579
- const { ixs } = await this.prepareFundPoolInstructions(data, extParams);
2580
- const { signature } = await this.execute(ixs, extParams);
2613
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2614
+ const ixs = await createAndEstimateTransaction(
2615
+ (params) => this.prepareFundPoolInstructions(data, params).then(
2616
+ (res) => prepareBaseInstructions(this.connection, params).concat(res.ixs)
2617
+ ),
2618
+ executionParams
2619
+ );
2620
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2581
2621
  return {
2582
2622
  ixs,
2583
2623
  txId: signature
@@ -2610,8 +2650,13 @@ var SolanaStakingClient = class {
2610
2650
  return { ixs: treasuryATA ? treasuryATA.concat([instruction]) : [instruction] };
2611
2651
  }
2612
2652
  async createRewardEntry(data, extParams) {
2613
- const { ixs } = await this.prepareCreateRewardEntryInstructions(data, extParams);
2614
- const { signature } = await this.execute(ixs, extParams);
2653
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2654
+ const ixs = await createAndEstimateTransaction(async (params) => {
2655
+ return this.prepareCreateRewardEntryInstructions(data, params).then(
2656
+ (res) => prepareBaseInstructions(this.connection, params).concat(res.ixs)
2657
+ );
2658
+ }, executionParams);
2659
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2615
2660
  return {
2616
2661
  ixs,
2617
2662
  txId: signature
@@ -2630,8 +2675,13 @@ var SolanaStakingClient = class {
2630
2675
  return { ixs: [instruction] };
2631
2676
  }
2632
2677
  async updateRewardPool(data, extParams) {
2633
- const { ixs } = await this.prepareUpdateRewardPoolInstructions(data, extParams);
2634
- const { signature } = await this.execute(ixs, extParams);
2678
+ const executionParams = unwrapExecutionParams(extParams, this.connection);
2679
+ const ixs = await createAndEstimateTransaction(async (params) => {
2680
+ return this.prepareUpdateRewardPoolInstructions(data, params).then(
2681
+ (res) => prepareBaseInstructions(this.connection, params).concat(res.ixs)
2682
+ );
2683
+ }, executionParams);
2684
+ const { signature } = await this.execute(ixs, extParams.invoker, executionParams.skipSimulation);
2635
2685
  return {
2636
2686
  ixs,
2637
2687
  txId: signature
@@ -2663,23 +2713,19 @@ var SolanaStakingClient = class {
2663
2713
  );
2664
2714
  return accountEntity.discriminator;
2665
2715
  }
2666
- async execute(ixs, extParams) {
2667
- const { tx, hash, context } = await prepareTransaction(
2668
- this.connection,
2669
- prepareBaseInstructions(this.connection, extParams).concat(ixs),
2670
- extParams.invoker.publicKey
2671
- );
2716
+ async execute(ixs, invoker, skipSimulation = false) {
2717
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker.publicKey);
2672
2718
  try {
2673
2719
  const signature = await signAndExecuteTransaction(
2674
2720
  this.connection,
2675
- extParams.invoker,
2721
+ invoker,
2676
2722
  tx,
2677
2723
  {
2678
2724
  hash,
2679
2725
  context,
2680
2726
  commitment: this.getCommitment()
2681
2727
  },
2682
- { sendThrottler: this.sendThrottler }
2728
+ { sendThrottler: this.sendThrottler, skipSimulation }
2683
2729
  );
2684
2730
  return { signature };
2685
2731
  } catch (err) {