@streamflow/distributor 9.0.3 → 10.0.0-alpha.p313.3ce4d29

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.
@@ -2,7 +2,6 @@ export { i as StreamflowDistributorSolana } from './solana/index.cjs';
2
2
  import '@solana/web3.js';
3
3
  import '@solana/wallet-adapter-base';
4
4
  import '@streamflow/common';
5
- import '@streamflow/common/solana';
6
5
  import 'bn.js';
7
6
  import '@coral-xyz/anchor';
8
7
  import './solana/descriptor/aligned_distributor.cjs';
@@ -3,7 +3,6 @@
3
3
  var web3_js = require('@solana/web3.js');
4
4
  require('@solana/wallet-adapter-base');
5
5
  var common = require('@streamflow/common');
6
- var solana = require('@streamflow/common/solana');
7
6
  var anchor = require('@coral-xyz/anchor');
8
7
  var borsh7 = require('@coral-xyz/borsh');
9
8
  var buffer = require('buffer');
@@ -3527,7 +3526,7 @@ var isCompressedClaimStatus = (status) => {
3527
3526
  };
3528
3527
  async function wrappedSignAndExecuteTransaction(...args) {
3529
3528
  try {
3530
- return await solana.signAndExecuteTransaction(...args);
3529
+ return await common.signAndExecuteTransaction(...args);
3531
3530
  } catch (err) {
3532
3531
  if (err instanceof Error) {
3533
3532
  const parsed = fromTxError(err);
@@ -3568,7 +3567,7 @@ var BaseDistributorClient = class {
3568
3567
  this.cluster = cluster;
3569
3568
  this.connection = new web3_js.Connection(clusterUrl, this.commitment);
3570
3569
  this.programId = programId !== "" ? new web3_js.PublicKey(programId) : new web3_js.PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
3571
- this.sendThrottler = sendThrottler ?? solana.buildSendThrottler(sendRate);
3570
+ this.sendThrottler = sendThrottler ?? common.buildSendThrottler(sendRate);
3572
3571
  const merkleDistributorProgram = {
3573
3572
  ...merkle_distributor_default
3574
3573
  };
@@ -3588,13 +3587,13 @@ var BaseDistributorClient = class {
3588
3587
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3589
3588
  }
3590
3589
  const { version, mint } = data;
3591
- const ixs = solana.prepareBaseInstructions(this.connection, extParams);
3590
+ const ixs = common.prepareBaseInstructions(this.connection, extParams);
3592
3591
  const mintPublicKey = extParams.isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
3593
- const { mint: mintAccount, tokenProgramId } = await solana.getMintAndProgram(this.connection, mintPublicKey);
3592
+ const { mint: mintAccount, tokenProgramId } = await common.getMintAndProgram(this.connection, mintPublicKey);
3594
3593
  const transferFeeConfig = splToken.getTransferFeeConfig(mintAccount);
3595
3594
  const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
3596
- const tokenVault = await solana.ata(mintPublicKey, distributorPublicKey, tokenProgramId);
3597
- const senderTokens = await solana.ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
3595
+ const tokenVault = await common.ata(mintPublicKey, distributorPublicKey, tokenProgramId);
3596
+ const senderTokens = await common.ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
3598
3597
  const accounts = {
3599
3598
  distributor: distributorPublicKey,
3600
3599
  clawbackReceiver: senderTokens,
@@ -3607,7 +3606,7 @@ var BaseDistributorClient = class {
3607
3606
  };
3608
3607
  if (extParams.isNative) {
3609
3608
  ixs.push(
3610
- ...await solana.prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN5__default.default(data.maxTotalClaim))
3609
+ ...await common.prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN5__default.default(data.maxTotalClaim))
3611
3610
  );
3612
3611
  }
3613
3612
  const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
@@ -3651,12 +3650,12 @@ var BaseDistributorClient = class {
3651
3650
  const invoker = extParams.invoker.publicKey;
3652
3651
  common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3653
3652
  const executionParams = this.unwrapExecutionParams(extParams);
3654
- const { ixs, distributorPublicKey } = await solana.createAndEstimateTransaction(
3653
+ const { ixs, distributorPublicKey } = await common.createAndEstimateTransaction(
3655
3654
  (params) => this.prepareCreateInstructions(data, params),
3656
3655
  executionParams,
3657
3656
  (q) => q.ixs
3658
3657
  );
3659
- const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3658
+ const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3660
3659
  const signature = await wrappedSignAndExecuteTransaction(
3661
3660
  this.connection,
3662
3661
  extParams.invoker,
@@ -3678,11 +3677,11 @@ var BaseDistributorClient = class {
3678
3677
  const executionParams = this.unwrapExecutionParams(extParams);
3679
3678
  const invoker = executionParams.invoker.publicKey;
3680
3679
  common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3681
- const ixs = await solana.createAndEstimateTransaction(
3680
+ const ixs = await common.createAndEstimateTransaction(
3682
3681
  (params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
3683
3682
  executionParams
3684
3683
  );
3685
- const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker);
3684
+ const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
3686
3685
  const signature = await wrappedSignAndExecuteTransaction(
3687
3686
  this.connection,
3688
3687
  executionParams.invoker,
@@ -3705,10 +3704,10 @@ var BaseDistributorClient = class {
3705
3704
  if (!distributor) {
3706
3705
  throw new Error("Couldn't get account info");
3707
3706
  }
3708
- const { tokenProgramId } = await solana.getMintAndProgram(this.connection, distributor.mint);
3709
- const ixs = solana.prepareBaseInstructions(this.connection, extParams);
3707
+ const { tokenProgramId } = await common.getMintAndProgram(this.connection, distributor.mint);
3708
+ const ixs = common.prepareBaseInstructions(this.connection, extParams);
3710
3709
  ixs.push(
3711
- ...await solana.checkOrCreateAtaBatch(
3710
+ ...await common.checkOrCreateAtaBatch(
3712
3711
  this.connection,
3713
3712
  [extParams.invoker.publicKey],
3714
3713
  distributor.mint,
@@ -3717,7 +3716,7 @@ var BaseDistributorClient = class {
3717
3716
  extParams.feePayer
3718
3717
  )
3719
3718
  );
3720
- const invokerTokens = await solana.ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
3719
+ const invokerTokens = await common.ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
3721
3720
  const claimStatusPublicKey = getClaimantStatusPda(
3722
3721
  this.programId,
3723
3722
  distributorPublicKey,
@@ -3752,7 +3751,7 @@ var BaseDistributorClient = class {
3752
3751
  let feeLamports = typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0;
3753
3752
  if (!feeLamports) {
3754
3753
  try {
3755
- const { mint: mintAccount } = await solana.getMintAndProgram(this.connection, distributor.mint);
3754
+ const { mint: mintAccount } = await common.getMintAndProgram(this.connection, distributor.mint);
3756
3755
  const claimableAmountRaw = data?.claimableAmount;
3757
3756
  const unlockedRaw = data?.amountUnlocked;
3758
3757
  const lockedRaw = data?.amountLocked;
@@ -3777,11 +3776,11 @@ var BaseDistributorClient = class {
3777
3776
  const executionParams = this.unwrapExecutionParams(extParams);
3778
3777
  const invoker = executionParams.invoker.publicKey;
3779
3778
  common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3780
- const ixs = await solana.createAndEstimateTransaction(
3779
+ const ixs = await common.createAndEstimateTransaction(
3781
3780
  (params) => this.prepareCloseClaimInstructions(data, params),
3782
3781
  executionParams
3783
3782
  );
3784
- const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker);
3783
+ const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
3785
3784
  const signature = await wrappedSignAndExecuteTransaction(
3786
3785
  this.connection,
3787
3786
  executionParams.invoker,
@@ -3801,11 +3800,11 @@ var BaseDistributorClient = class {
3801
3800
  }
3802
3801
  const distributorPublicKey = new web3_js.PublicKey(data.id);
3803
3802
  const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
3804
- const claimantPublicKey = solana.pk(data.claimant);
3803
+ const claimantPublicKey = common.pk(data.claimant);
3805
3804
  if (!distributor) {
3806
3805
  throw new Error("Couldn't get distributor account info");
3807
3806
  }
3808
- const ixs = solana.prepareBaseInstructions(this.connection, extParams);
3807
+ const ixs = common.prepareBaseInstructions(this.connection, extParams);
3809
3808
  const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, claimantPublicKey);
3810
3809
  const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
3811
3810
  const closeClaimAccounts = {
@@ -3835,10 +3834,10 @@ var BaseDistributorClient = class {
3835
3834
  if (!distributor) {
3836
3835
  throw new Error("Couldn't get account info");
3837
3836
  }
3838
- const { tokenProgramId } = await solana.getMintAndProgram(this.connection, distributor.mint);
3839
- const ixs = solana.prepareBaseInstructions(this.connection, extParams);
3837
+ const { tokenProgramId } = await common.getMintAndProgram(this.connection, distributor.mint);
3838
+ const ixs = common.prepareBaseInstructions(this.connection, extParams);
3840
3839
  ixs.push(
3841
- ...await solana.checkOrCreateAtaBatch(
3840
+ ...await common.checkOrCreateAtaBatch(
3842
3841
  this.connection,
3843
3842
  [extParams.invoker.publicKey],
3844
3843
  distributor.mint,
@@ -3864,11 +3863,11 @@ var BaseDistributorClient = class {
3864
3863
  const executionParams = this.unwrapExecutionParams(extParams);
3865
3864
  const invoker = executionParams.invoker.publicKey;
3866
3865
  common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3867
- const ixs = await solana.createAndEstimateTransaction(
3866
+ const ixs = await common.createAndEstimateTransaction(
3868
3867
  (params) => this.prepareClawbackInstructions(data, params),
3869
3868
  executionParams
3870
3869
  );
3871
- const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker);
3870
+ const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
3872
3871
  const signature = await wrappedSignAndExecuteTransaction(
3873
3872
  this.connection,
3874
3873
  executionParams.invoker,
@@ -3883,7 +3882,7 @@ var BaseDistributorClient = class {
3883
3882
  return { ixs, txId: signature };
3884
3883
  }
3885
3884
  async getClaim(claimStatus) {
3886
- return this.connection.getAccountInfo(solana.pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
3885
+ return this.connection.getAccountInfo(common.pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
3887
3886
  }
3888
3887
  async getClaims(data) {
3889
3888
  const claimStatusPublicKeys = data.map(({ id, recipient }) => {
@@ -3951,7 +3950,7 @@ var BaseDistributorClient = class {
3951
3950
  return args;
3952
3951
  }
3953
3952
  unwrapExecutionParams(extParams) {
3954
- return solana.unwrapExecutionParams(extParams, this.connection);
3953
+ return common.unwrapExecutionParams(extParams, this.connection);
3955
3954
  }
3956
3955
  decodeClaimStatus(account) {
3957
3956
  if (!account) {