@streamflow/distributor 6.2.1 → 6.3.2
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/solana/client.js +24 -15
- package/dist/solana/generated/instructions/claimLocked.d.ts +2 -0
- package/dist/solana/generated/instructions/claimLocked.js +2 -0
- package/dist/solana/generated/instructions/closeClaim.d.ts +2 -0
- package/dist/solana/generated/instructions/closeClaim.js +2 -0
- package/dist/solana/generated/instructions/newClaim.d.ts +2 -0
- package/dist/solana/generated/instructions/newClaim.js +2 -0
- package/dist/solana/types.d.ts +1 -0
- package/dist/solana/utils.d.ts +1 -0
- package/dist/solana/utils.js +8 -1
- package/package.json +4 -4
package/dist/solana/client.js
CHANGED
|
@@ -168,9 +168,9 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
168
168
|
SolanaDistributorClient.prototype.claim = function (data, _a) {
|
|
169
169
|
var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
|
|
170
170
|
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
-
var distributorPublicKey, distributor, tokenProgramId, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, nowTs,
|
|
172
|
-
return __generator(this, function (
|
|
173
|
-
switch (
|
|
171
|
+
var distributorPublicKey, distributor, tokenProgramId, ixs, _b, _c, _d, _e, invokerTokens, _f, claimStatusPublicKey, eventAuthorityPublicKey, claimStatus, accounts, args, nowTs, _g, tx, hash, context, signature;
|
|
172
|
+
return __generator(this, function (_h) {
|
|
173
|
+
switch (_h.label) {
|
|
174
174
|
case 0:
|
|
175
175
|
if (!invoker.publicKey) {
|
|
176
176
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -178,27 +178,34 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
178
178
|
distributorPublicKey = new web3_js_1.PublicKey(data.id);
|
|
179
179
|
return [4 /*yield*/, accounts_1.MerkleDistributor.fetch(this.connection, distributorPublicKey)];
|
|
180
180
|
case 1:
|
|
181
|
-
distributor =
|
|
181
|
+
distributor = _h.sent();
|
|
182
182
|
if (!distributor) {
|
|
183
183
|
throw new Error("Couldn't get account info");
|
|
184
184
|
}
|
|
185
185
|
return [4 /*yield*/, (0, solana_1.getMintAndProgram)(this.connection, distributor.mint)];
|
|
186
186
|
case 2:
|
|
187
|
-
tokenProgramId = (
|
|
187
|
+
tokenProgramId = (_h.sent()).tokenProgramId;
|
|
188
188
|
ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
|
|
189
189
|
_c = (_b = ixs.push).apply;
|
|
190
190
|
_d = [ixs];
|
|
191
191
|
_e = [[]];
|
|
192
192
|
return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker, tokenProgramId)];
|
|
193
193
|
case 3:
|
|
194
|
-
_c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(
|
|
195
|
-
return [
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
_c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
|
|
195
|
+
if (!data.tokenAccount) return [3 /*break*/, 4];
|
|
196
|
+
_f = new web3_js_1.PublicKey(data.tokenAccount);
|
|
197
|
+
return [3 /*break*/, 6];
|
|
198
|
+
case 4: return [4 /*yield*/, (0, solana_1.ata)(distributor.mint, invoker.publicKey, tokenProgramId)];
|
|
199
|
+
case 5:
|
|
200
|
+
_f = _h.sent();
|
|
201
|
+
_h.label = 6;
|
|
202
|
+
case 6:
|
|
203
|
+
invokerTokens = _f;
|
|
198
204
|
claimStatusPublicKey = (0, utils_1.getClaimantStatusPda)(this.programId, distributorPublicKey, invoker.publicKey);
|
|
205
|
+
eventAuthorityPublicKey = (0, utils_1.getEventAuthorityPda)(this.programId);
|
|
199
206
|
return [4 /*yield*/, accounts_1.ClaimStatus.fetch(this.connection, claimStatusPublicKey)];
|
|
200
|
-
case
|
|
201
|
-
claimStatus =
|
|
207
|
+
case 7:
|
|
208
|
+
claimStatus = _h.sent();
|
|
202
209
|
accounts = {
|
|
203
210
|
distributor: distributorPublicKey,
|
|
204
211
|
claimStatus: claimStatusPublicKey,
|
|
@@ -208,6 +215,8 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
208
215
|
mint: distributor.mint,
|
|
209
216
|
tokenProgram: tokenProgramId,
|
|
210
217
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
218
|
+
eventAuthority: eventAuthorityPublicKey,
|
|
219
|
+
program: this.programId,
|
|
211
220
|
};
|
|
212
221
|
if (!claimStatus) {
|
|
213
222
|
args = {
|
|
@@ -222,15 +231,15 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
222
231
|
ixs.push((0, instructions_1.claimLocked)(accounts, this.programId));
|
|
223
232
|
}
|
|
224
233
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey)];
|
|
225
|
-
case
|
|
226
|
-
|
|
234
|
+
case 8:
|
|
235
|
+
_g = _h.sent(), tx = _g.tx, hash = _g.hash, context = _g.context;
|
|
227
236
|
return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, {
|
|
228
237
|
hash: hash,
|
|
229
238
|
context: context,
|
|
230
239
|
commitment: this.getCommitment(),
|
|
231
240
|
})];
|
|
232
|
-
case
|
|
233
|
-
signature =
|
|
241
|
+
case 9:
|
|
242
|
+
signature = _h.sent();
|
|
234
243
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
235
244
|
}
|
|
236
245
|
});
|
|
@@ -17,5 +17,7 @@ export interface ClaimLockedAccounts {
|
|
|
17
17
|
mint: PublicKey;
|
|
18
18
|
/** SPL [Token] program. */
|
|
19
19
|
tokenProgram: PublicKey;
|
|
20
|
+
eventAuthority: PublicKey;
|
|
21
|
+
program: PublicKey;
|
|
20
22
|
}
|
|
21
23
|
export declare function claimLocked(accounts: ClaimLockedAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -13,6 +13,8 @@ function claimLocked(accounts, programId) {
|
|
|
13
13
|
{ pubkey: accounts.claimant, isSigner: true, isWritable: true },
|
|
14
14
|
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
15
15
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
16
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
17
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
16
18
|
];
|
|
17
19
|
var identifier = Buffer.from([34, 206, 181, 23, 11, 207, 147, 90]);
|
|
18
20
|
var data = identifier;
|
|
@@ -9,5 +9,7 @@ export interface CloseClaimAccounts {
|
|
|
9
9
|
claimStatus: PublicKey;
|
|
10
10
|
/** The [System] program. */
|
|
11
11
|
systemProgram: PublicKey;
|
|
12
|
+
eventAuthority: PublicKey;
|
|
13
|
+
program: PublicKey;
|
|
12
14
|
}
|
|
13
15
|
export declare function closeClaim(accounts: CloseClaimAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -11,6 +11,8 @@ function closeClaim(accounts, programId) {
|
|
|
11
11
|
{ pubkey: accounts.claimant, isSigner: false, isWritable: false },
|
|
12
12
|
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
13
13
|
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
14
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
15
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
14
16
|
];
|
|
15
17
|
var identifier = Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
|
|
16
18
|
var data = identifier;
|
|
@@ -22,6 +22,8 @@ export interface NewClaimAccounts {
|
|
|
22
22
|
tokenProgram: PublicKey;
|
|
23
23
|
/** The [System] program. */
|
|
24
24
|
systemProgram: PublicKey;
|
|
25
|
+
eventAuthority: PublicKey;
|
|
26
|
+
program: PublicKey;
|
|
25
27
|
}
|
|
26
28
|
export declare const layout: any;
|
|
27
29
|
export declare function newClaim(args: NewClaimArgs, accounts: NewClaimAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -43,6 +43,8 @@ function newClaim(args, accounts, programId) {
|
|
|
43
43
|
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
44
44
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
45
45
|
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
46
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
47
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
46
48
|
];
|
|
47
49
|
var identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
|
|
48
50
|
var buffer = Buffer.alloc(1000);
|
package/dist/solana/types.d.ts
CHANGED
package/dist/solana/utils.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import { Connection, Keypair, PublicKey, Transaction, VersionedTransaction } fro
|
|
|
3
3
|
import { ConfirmationParams } from "@streamflow/common/solana";
|
|
4
4
|
export declare function getDistributorPda(programId: PublicKey, mint: PublicKey, version: number): PublicKey;
|
|
5
5
|
export declare function getClaimantStatusPda(programId: PublicKey, distributor: PublicKey, claimant: PublicKey): PublicKey;
|
|
6
|
+
export declare function getEventAuthorityPda(programId: PublicKey): PublicKey;
|
|
6
7
|
export declare function wrappedSignAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams): Promise<string>;
|
package/dist/solana/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.wrappedSignAndExecuteTransaction = exports.getClaimantStatusPda = exports.getDistributorPda = void 0;
|
|
39
|
+
exports.wrappedSignAndExecuteTransaction = exports.getEventAuthorityPda = exports.getClaimantStatusPda = exports.getDistributorPda = void 0;
|
|
40
40
|
var web3_js_1 = require("@solana/web3.js");
|
|
41
41
|
var common_1 = require("@streamflow/common");
|
|
42
42
|
var solana_1 = require("@streamflow/common/solana");
|
|
@@ -59,6 +59,13 @@ function getClaimantStatusPda(programId, distributor, claimant) {
|
|
|
59
59
|
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
60
60
|
}
|
|
61
61
|
exports.getClaimantStatusPda = getClaimantStatusPda;
|
|
62
|
+
function getEventAuthorityPda(programId) {
|
|
63
|
+
// Constructing the seed for the PDA
|
|
64
|
+
var seeds = [Buffer.from("__event_authority")];
|
|
65
|
+
// Finding the PDA
|
|
66
|
+
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
67
|
+
}
|
|
68
|
+
exports.getEventAuthorityPda = getEventAuthorityPda;
|
|
62
69
|
function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirmationParams) {
|
|
63
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
71
|
var err_1, parsed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/distributor",
|
|
3
|
-
"version": "6.2
|
|
3
|
+
"version": "6.3.2",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"lint": "eslint --fix .",
|
|
23
23
|
"prepublishOnly": "npm run lint && npm run build"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "8fa0da9107e1a1b9ea900d1f7159169c0d256d31",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@streamflow/eslint-config": "6.
|
|
27
|
+
"@streamflow/eslint-config": "6.3.2",
|
|
28
28
|
"@types/bn.js": "5.1.1",
|
|
29
29
|
"@types/jest": "29.2.4",
|
|
30
30
|
"date-fns": "2.28.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@solana/spl-token": "0.3.6",
|
|
39
39
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
40
40
|
"@solana/web3.js": "1.70.1",
|
|
41
|
-
"@streamflow/common": "6.2
|
|
41
|
+
"@streamflow/common": "6.3.2",
|
|
42
42
|
"bn.js": "5.2.1",
|
|
43
43
|
"borsh": "^2.0.0",
|
|
44
44
|
"bs58": "5.0.0"
|