@streamflow/distributor 10.0.0-alpha.p311.10f340e → 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.
- package/dist/cjs/index.cjs +27 -28
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +0 -1
- package/dist/cjs/solana/index.cjs +27 -28
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +18 -19
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +18 -19
- package/dist/esm/solana/index.js +1 -2
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -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');
|
|
@@ -3566,7 +3565,7 @@ var isCompressedClaimStatus = (status) => {
|
|
|
3566
3565
|
};
|
|
3567
3566
|
async function wrappedSignAndExecuteTransaction(...args) {
|
|
3568
3567
|
try {
|
|
3569
|
-
return await
|
|
3568
|
+
return await common.signAndExecuteTransaction(...args);
|
|
3570
3569
|
} catch (err) {
|
|
3571
3570
|
if (err instanceof Error) {
|
|
3572
3571
|
const parsed = fromTxError(err);
|
|
@@ -3607,7 +3606,7 @@ var BaseDistributorClient = class {
|
|
|
3607
3606
|
this.cluster = cluster;
|
|
3608
3607
|
this.connection = new web3_js.Connection(clusterUrl, this.commitment);
|
|
3609
3608
|
this.programId = programId !== "" ? new web3_js.PublicKey(programId) : new web3_js.PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
|
|
3610
|
-
this.sendThrottler = sendThrottler ??
|
|
3609
|
+
this.sendThrottler = sendThrottler ?? common.buildSendThrottler(sendRate);
|
|
3611
3610
|
const merkleDistributorProgram = {
|
|
3612
3611
|
...merkle_distributor_default
|
|
3613
3612
|
};
|
|
@@ -3627,13 +3626,13 @@ var BaseDistributorClient = class {
|
|
|
3627
3626
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3628
3627
|
}
|
|
3629
3628
|
const { version, mint } = data;
|
|
3630
|
-
const ixs =
|
|
3629
|
+
const ixs = common.prepareBaseInstructions(this.connection, extParams);
|
|
3631
3630
|
const mintPublicKey = extParams.isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
|
|
3632
|
-
const { mint: mintAccount, tokenProgramId } = await
|
|
3631
|
+
const { mint: mintAccount, tokenProgramId } = await common.getMintAndProgram(this.connection, mintPublicKey);
|
|
3633
3632
|
const transferFeeConfig = splToken.getTransferFeeConfig(mintAccount);
|
|
3634
3633
|
const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
|
|
3635
|
-
const tokenVault = await
|
|
3636
|
-
const senderTokens = await
|
|
3634
|
+
const tokenVault = await common.ata(mintPublicKey, distributorPublicKey, tokenProgramId);
|
|
3635
|
+
const senderTokens = await common.ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
|
|
3637
3636
|
const accounts = {
|
|
3638
3637
|
distributor: distributorPublicKey,
|
|
3639
3638
|
clawbackReceiver: senderTokens,
|
|
@@ -3646,7 +3645,7 @@ var BaseDistributorClient = class {
|
|
|
3646
3645
|
};
|
|
3647
3646
|
if (extParams.isNative) {
|
|
3648
3647
|
ixs.push(
|
|
3649
|
-
...await
|
|
3648
|
+
...await common.prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN5__default.default(data.maxTotalClaim))
|
|
3650
3649
|
);
|
|
3651
3650
|
}
|
|
3652
3651
|
const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
|
|
@@ -3690,12 +3689,12 @@ var BaseDistributorClient = class {
|
|
|
3690
3689
|
const invoker = extParams.invoker.publicKey;
|
|
3691
3690
|
common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3692
3691
|
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3693
|
-
const { ixs, distributorPublicKey } = await
|
|
3692
|
+
const { ixs, distributorPublicKey } = await common.createAndEstimateTransaction(
|
|
3694
3693
|
(params) => this.prepareCreateInstructions(data, params),
|
|
3695
3694
|
executionParams,
|
|
3696
3695
|
(q) => q.ixs
|
|
3697
3696
|
);
|
|
3698
|
-
const { tx, hash, context } = await
|
|
3697
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3699
3698
|
const signature = await wrappedSignAndExecuteTransaction(
|
|
3700
3699
|
this.connection,
|
|
3701
3700
|
extParams.invoker,
|
|
@@ -3717,11 +3716,11 @@ var BaseDistributorClient = class {
|
|
|
3717
3716
|
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3718
3717
|
const invoker = executionParams.invoker.publicKey;
|
|
3719
3718
|
common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3720
|
-
const ixs = await
|
|
3719
|
+
const ixs = await common.createAndEstimateTransaction(
|
|
3721
3720
|
(params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
|
|
3722
3721
|
executionParams
|
|
3723
3722
|
);
|
|
3724
|
-
const { tx, hash, context } = await
|
|
3723
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
|
|
3725
3724
|
const signature = await wrappedSignAndExecuteTransaction(
|
|
3726
3725
|
this.connection,
|
|
3727
3726
|
executionParams.invoker,
|
|
@@ -3744,10 +3743,10 @@ var BaseDistributorClient = class {
|
|
|
3744
3743
|
if (!distributor) {
|
|
3745
3744
|
throw new Error("Couldn't get account info");
|
|
3746
3745
|
}
|
|
3747
|
-
const { tokenProgramId } = await
|
|
3748
|
-
const ixs =
|
|
3746
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, distributor.mint);
|
|
3747
|
+
const ixs = common.prepareBaseInstructions(this.connection, extParams);
|
|
3749
3748
|
ixs.push(
|
|
3750
|
-
...await
|
|
3749
|
+
...await common.checkOrCreateAtaBatch(
|
|
3751
3750
|
this.connection,
|
|
3752
3751
|
[extParams.invoker.publicKey],
|
|
3753
3752
|
distributor.mint,
|
|
@@ -3756,7 +3755,7 @@ var BaseDistributorClient = class {
|
|
|
3756
3755
|
extParams.feePayer
|
|
3757
3756
|
)
|
|
3758
3757
|
);
|
|
3759
|
-
const invokerTokens = await
|
|
3758
|
+
const invokerTokens = await common.ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
|
|
3760
3759
|
const claimStatusPublicKey = getClaimantStatusPda(
|
|
3761
3760
|
this.programId,
|
|
3762
3761
|
distributorPublicKey,
|
|
@@ -3791,7 +3790,7 @@ var BaseDistributorClient = class {
|
|
|
3791
3790
|
let feeLamports = typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0;
|
|
3792
3791
|
if (!feeLamports) {
|
|
3793
3792
|
try {
|
|
3794
|
-
const { mint: mintAccount } = await
|
|
3793
|
+
const { mint: mintAccount } = await common.getMintAndProgram(this.connection, distributor.mint);
|
|
3795
3794
|
const claimableAmountRaw = data?.claimableAmount;
|
|
3796
3795
|
const unlockedRaw = data?.amountUnlocked;
|
|
3797
3796
|
const lockedRaw = data?.amountLocked;
|
|
@@ -3816,11 +3815,11 @@ var BaseDistributorClient = class {
|
|
|
3816
3815
|
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3817
3816
|
const invoker = executionParams.invoker.publicKey;
|
|
3818
3817
|
common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3819
|
-
const ixs = await
|
|
3818
|
+
const ixs = await common.createAndEstimateTransaction(
|
|
3820
3819
|
(params) => this.prepareCloseClaimInstructions(data, params),
|
|
3821
3820
|
executionParams
|
|
3822
3821
|
);
|
|
3823
|
-
const { tx, hash, context } = await
|
|
3822
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
|
|
3824
3823
|
const signature = await wrappedSignAndExecuteTransaction(
|
|
3825
3824
|
this.connection,
|
|
3826
3825
|
executionParams.invoker,
|
|
@@ -3840,11 +3839,11 @@ var BaseDistributorClient = class {
|
|
|
3840
3839
|
}
|
|
3841
3840
|
const distributorPublicKey = new web3_js.PublicKey(data.id);
|
|
3842
3841
|
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
3843
|
-
const claimantPublicKey =
|
|
3842
|
+
const claimantPublicKey = common.pk(data.claimant);
|
|
3844
3843
|
if (!distributor) {
|
|
3845
3844
|
throw new Error("Couldn't get distributor account info");
|
|
3846
3845
|
}
|
|
3847
|
-
const ixs =
|
|
3846
|
+
const ixs = common.prepareBaseInstructions(this.connection, extParams);
|
|
3848
3847
|
const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, claimantPublicKey);
|
|
3849
3848
|
const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
|
|
3850
3849
|
const closeClaimAccounts = {
|
|
@@ -3874,10 +3873,10 @@ var BaseDistributorClient = class {
|
|
|
3874
3873
|
if (!distributor) {
|
|
3875
3874
|
throw new Error("Couldn't get account info");
|
|
3876
3875
|
}
|
|
3877
|
-
const { tokenProgramId } = await
|
|
3878
|
-
const ixs =
|
|
3876
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, distributor.mint);
|
|
3877
|
+
const ixs = common.prepareBaseInstructions(this.connection, extParams);
|
|
3879
3878
|
ixs.push(
|
|
3880
|
-
...await
|
|
3879
|
+
...await common.checkOrCreateAtaBatch(
|
|
3881
3880
|
this.connection,
|
|
3882
3881
|
[extParams.invoker.publicKey],
|
|
3883
3882
|
distributor.mint,
|
|
@@ -3903,11 +3902,11 @@ var BaseDistributorClient = class {
|
|
|
3903
3902
|
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3904
3903
|
const invoker = executionParams.invoker.publicKey;
|
|
3905
3904
|
common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3906
|
-
const ixs = await
|
|
3905
|
+
const ixs = await common.createAndEstimateTransaction(
|
|
3907
3906
|
(params) => this.prepareClawbackInstructions(data, params),
|
|
3908
3907
|
executionParams
|
|
3909
3908
|
);
|
|
3910
|
-
const { tx, hash, context } = await
|
|
3909
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
|
|
3911
3910
|
const signature = await wrappedSignAndExecuteTransaction(
|
|
3912
3911
|
this.connection,
|
|
3913
3912
|
executionParams.invoker,
|
|
@@ -3922,7 +3921,7 @@ var BaseDistributorClient = class {
|
|
|
3922
3921
|
return { ixs, txId: signature };
|
|
3923
3922
|
}
|
|
3924
3923
|
async getClaim(claimStatus) {
|
|
3925
|
-
return this.connection.getAccountInfo(
|
|
3924
|
+
return this.connection.getAccountInfo(common.pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
|
|
3926
3925
|
}
|
|
3927
3926
|
async getClaims(data) {
|
|
3928
3927
|
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
@@ -3990,7 +3989,7 @@ var BaseDistributorClient = class {
|
|
|
3990
3989
|
return args;
|
|
3991
3990
|
}
|
|
3992
3991
|
unwrapExecutionParams(extParams) {
|
|
3993
|
-
return
|
|
3992
|
+
return common.unwrapExecutionParams(extParams, this.connection);
|
|
3994
3993
|
}
|
|
3995
3994
|
decodeClaimStatus(account) {
|
|
3996
3995
|
if (!account) {
|