@streamflow/distributor 7.3.3 → 7.4.1
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/solana/clients/BaseDistributorClient.js +44 -1
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +9 -1
- package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +103 -423
- package/dist/cjs/solana/generated/accounts/ClaimStatus.js +11 -1
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +16 -6
- package/dist/cjs/solana/generated/errors/custom.js +66 -1
- package/dist/cjs/solana/generated/instructions/closeClaim.js +39 -3
- package/dist/cjs/solana/generated/instructions/newDistributor.js +3 -3
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +3 -1
- package/dist/esm/solana/clients/BaseDistributorClient.js +45 -2
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +9 -1
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +13 -3
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +103 -423
- package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +12 -0
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +15 -1
- package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +15 -3
- package/dist/esm/solana/generated/accounts/MerkleDistributor.js +21 -7
- package/dist/esm/solana/generated/errors/custom.d.ts +41 -1
- package/dist/esm/solana/generated/errors/custom.js +65 -0
- package/dist/esm/solana/generated/instructions/closeClaim.d.ts +9 -2
- package/dist/esm/solana/generated/instructions/closeClaim.js +15 -3
- package/dist/esm/solana/generated/instructions/newDistributor.d.ts +3 -1
- package/dist/esm/solana/generated/instructions/newDistributor.js +3 -3
- package/dist/esm/solana/types.d.ts +8 -2
- package/package.json +4 -4
|
@@ -13,6 +13,7 @@ const constants_1 = require("../constants");
|
|
|
13
13
|
const instructions_1 = require("../generated/instructions");
|
|
14
14
|
const accounts_1 = require("../generated/accounts");
|
|
15
15
|
const utils_1 = require("../utils");
|
|
16
|
+
const closeClaim_1 = require("../generated/instructions/closeClaim");
|
|
16
17
|
class BaseDistributorClient {
|
|
17
18
|
constructor({ clusterUrl, cluster = common_1.ICluster.Mainnet, commitment = "confirmed", programId = "", sendRate = 1, sendThrottler, }) {
|
|
18
19
|
this.commitment = commitment;
|
|
@@ -129,6 +130,46 @@ class BaseDistributorClient {
|
|
|
129
130
|
}
|
|
130
131
|
return ixs;
|
|
131
132
|
}
|
|
133
|
+
async closeClaim(data, extParams) {
|
|
134
|
+
const ixs = await this.prepareCloseClaimInstructions(data, extParams);
|
|
135
|
+
const { tx, hash, context } = await (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey);
|
|
136
|
+
const signature = await (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
|
|
137
|
+
hash,
|
|
138
|
+
context,
|
|
139
|
+
commitment: this.getCommitment(),
|
|
140
|
+
}, { sendThrottler: this.sendThrottler });
|
|
141
|
+
return { ixs, txId: signature };
|
|
142
|
+
}
|
|
143
|
+
async prepareCloseClaimInstructions(data, extParams) {
|
|
144
|
+
if (!extParams.invoker.publicKey) {
|
|
145
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
146
|
+
}
|
|
147
|
+
const distributorPublicKey = new web3_js_1.PublicKey(data.id);
|
|
148
|
+
const distributor = await accounts_1.MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
149
|
+
const claimantPublicKey = (0, solana_1.pk)(data.claimant);
|
|
150
|
+
if (!distributor) {
|
|
151
|
+
throw new Error("Couldn't get distributor account info");
|
|
152
|
+
}
|
|
153
|
+
const ixs = (0, solana_1.prepareBaseInstructions)(this.connection, extParams);
|
|
154
|
+
const claimStatusPublicKey = (0, utils_1.getClaimantStatusPda)(this.programId, distributorPublicKey, claimantPublicKey);
|
|
155
|
+
const eventAuthorityPublicKey = (0, utils_1.getEventAuthorityPda)(this.programId);
|
|
156
|
+
const closeClaimAccounts = {
|
|
157
|
+
adminOrClaimant: extParams.invoker.publicKey,
|
|
158
|
+
distributor: distributorPublicKey,
|
|
159
|
+
claimStatus: claimStatusPublicKey,
|
|
160
|
+
claimant: claimantPublicKey,
|
|
161
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
162
|
+
eventAuthority: eventAuthorityPublicKey,
|
|
163
|
+
program: this.programId,
|
|
164
|
+
};
|
|
165
|
+
const closeClaimArgs = {
|
|
166
|
+
amountLocked: data.amountLocked ? new bn_js_1.default(data.amountLocked) : undefined,
|
|
167
|
+
amountUnlocked: data.amountUnlocked ? new bn_js_1.default(data.amountUnlocked) : undefined,
|
|
168
|
+
proof: data.proof,
|
|
169
|
+
};
|
|
170
|
+
ixs.push((0, closeClaim_1.closeClaim)(closeClaimArgs, closeClaimAccounts, this.programId));
|
|
171
|
+
return ixs;
|
|
172
|
+
}
|
|
132
173
|
async prepareClawbackInstructions(data, extParams) {
|
|
133
174
|
if (!extParams.invoker.publicKey) {
|
|
134
175
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -208,7 +249,9 @@ class BaseDistributorClient {
|
|
|
208
249
|
startVestingTs: new bn_js_1.default(data.startVestingTs),
|
|
209
250
|
endVestingTs: new bn_js_1.default(data.endVestingTs),
|
|
210
251
|
clawbackStartTs: new bn_js_1.default(data.clawbackStartTs),
|
|
211
|
-
|
|
252
|
+
claimsClosableByAdmin: data.claimsClosableByAdmin,
|
|
253
|
+
claimsClosableByClaimant: data.claimsClosableByClaimant,
|
|
254
|
+
claimsLimit: data.claimsLimit,
|
|
212
255
|
};
|
|
213
256
|
const nowTs = new bn_js_1.default(Math.floor(Date.now() / 1000));
|
|
214
257
|
const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
|
|
@@ -52,7 +52,15 @@ class SolanaAlignedDistributorClient extends BaseDistributorClient_js_1.default
|
|
|
52
52
|
: (0, utils_js_1.getTestOraclePda)(this.alignedProxyProgram.programId, mint, admin);
|
|
53
53
|
const newDistributorIx = await this.alignedProxyProgram.methods
|
|
54
54
|
.newDistributor({
|
|
55
|
-
|
|
55
|
+
claimsClosable: baseArgs.claimsClosableByAdmin,
|
|
56
|
+
version: baseArgs.version,
|
|
57
|
+
root: baseArgs.root,
|
|
58
|
+
maxTotalClaim: baseArgs.maxTotalClaim,
|
|
59
|
+
maxNumNodes: baseArgs.maxNumNodes,
|
|
60
|
+
unlockPeriod: baseArgs.unlockPeriod,
|
|
61
|
+
startVestingTs: baseArgs.startVestingTs,
|
|
62
|
+
endVestingTs: baseArgs.endVestingTs,
|
|
63
|
+
clawbackStartTs: baseArgs.clawbackStartTs,
|
|
56
64
|
...alignedArgs,
|
|
57
65
|
})
|
|
58
66
|
.accounts({
|