@streamflow/distributor 6.0.0-alpha.1 → 6.0.0-alpha.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.d.ts +3 -3
- package/dist/solana/client.js +34 -26
- package/dist/solana/types.d.ts +2 -1
- package/package.json +4 -4
package/dist/solana/client.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ export default class SolanaDistributorClient {
|
|
|
16
16
|
* Create Stream instance
|
|
17
17
|
*/
|
|
18
18
|
constructor({ clusterUrl, cluster, commitment, programId }: IInitOptions);
|
|
19
|
-
create(data: ICreateDistributorData, { invoker, isNative }: ICreateSolanaExt): Promise<ICreateDistributorResult>;
|
|
20
|
-
claim(data: IClaimData, { invoker }: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
21
|
-
clawback(data: IClawbackData, { invoker }: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
19
|
+
create(data: ICreateDistributorData, { invoker, isNative, computePrice, computeLimit }: ICreateSolanaExt): Promise<ICreateDistributorResult>;
|
|
20
|
+
claim(data: IClaimData, { invoker, computePrice, computeLimit }: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
21
|
+
clawback(data: IClawbackData, { invoker, computePrice, computeLimit }: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
22
22
|
getClaims(data: IGetClaimsData): Promise<(ClaimStatus | null)[]>;
|
|
23
23
|
getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
|
|
24
24
|
}
|
package/dist/solana/client.js
CHANGED
|
@@ -84,7 +84,7 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
84
84
|
this.programId = programId !== "" ? new web3_js_1.PublicKey(programId) : new web3_js_1.PublicKey(constants_1.DISTRIBUTOR_PROGRAM_ID[cluster]);
|
|
85
85
|
}
|
|
86
86
|
SolanaDistributorClient.prototype.create = function (data, _a) {
|
|
87
|
-
var invoker = _a.invoker, _b = _a.isNative, isNative = _b === void 0 ? false : _b;
|
|
87
|
+
var invoker = _a.invoker, _b = _a.isNative, isNative = _b === void 0 ? false : _b, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
|
|
88
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
89
|
var ixs, mint, mintAccount, distributorPublicKey, tokenVault, senderTokens, args, accounts, _c, _d, _e, _f, commitment, hash, tx, signature;
|
|
90
90
|
var _g;
|
|
@@ -94,7 +94,7 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
94
94
|
if (!invoker.publicKey) {
|
|
95
95
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
96
96
|
}
|
|
97
|
-
ixs =
|
|
97
|
+
ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
|
|
98
98
|
mint = isNative ? spl_token_1.NATIVE_MINT : new web3_js_1.PublicKey(data.mint);
|
|
99
99
|
return [4 /*yield*/, (0, spl_token_1.getMint)(this.connection, mint)];
|
|
100
100
|
case 1:
|
|
@@ -160,12 +160,12 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
160
160
|
});
|
|
161
161
|
};
|
|
162
162
|
SolanaDistributorClient.prototype.claim = function (data, _a) {
|
|
163
|
-
var invoker = _a.invoker;
|
|
163
|
+
var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
|
|
164
164
|
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var distributorPublicKey, distributor, ixs, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, commitment, hash, tx, signature;
|
|
166
|
-
var
|
|
167
|
-
return __generator(this, function (
|
|
168
|
-
switch (
|
|
165
|
+
var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, commitment, hash, tx, signature;
|
|
166
|
+
var _f;
|
|
167
|
+
return __generator(this, function (_g) {
|
|
168
|
+
switch (_g.label) {
|
|
169
169
|
case 0:
|
|
170
170
|
if (!invoker.publicKey) {
|
|
171
171
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -173,20 +173,24 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
173
173
|
distributorPublicKey = new web3_js_1.PublicKey(data.id);
|
|
174
174
|
return [4 /*yield*/, accounts_1.MerkleDistributor.fetch(this.connection, distributorPublicKey)];
|
|
175
175
|
case 1:
|
|
176
|
-
distributor =
|
|
176
|
+
distributor = _g.sent();
|
|
177
177
|
if (!distributor) {
|
|
178
178
|
throw new Error("Couldn't get account info");
|
|
179
179
|
}
|
|
180
|
+
ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
|
|
181
|
+
_c = (_b = ixs.push).apply;
|
|
182
|
+
_d = [ixs];
|
|
183
|
+
_e = [[]];
|
|
180
184
|
return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker)];
|
|
181
185
|
case 2:
|
|
182
|
-
|
|
186
|
+
_c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_g.sent())]), false]))]));
|
|
183
187
|
return [4 /*yield*/, (0, solana_1.ata)(distributor.mint, invoker.publicKey)];
|
|
184
188
|
case 3:
|
|
185
|
-
invokerTokens =
|
|
189
|
+
invokerTokens = _g.sent();
|
|
186
190
|
claimStatusPublicKey = (0, utils_1.getClaimantStatusPda)(this.programId, distributorPublicKey, invoker.publicKey);
|
|
187
191
|
return [4 /*yield*/, accounts_1.ClaimStatus.fetch(this.connection, claimStatusPublicKey)];
|
|
188
192
|
case 4:
|
|
189
|
-
claimStatus =
|
|
193
|
+
claimStatus = _g.sent();
|
|
190
194
|
accounts = {
|
|
191
195
|
distributor: distributorPublicKey,
|
|
192
196
|
claimStatus: claimStatusPublicKey,
|
|
@@ -211,27 +215,27 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
211
215
|
commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
212
216
|
return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
|
|
213
217
|
case 5:
|
|
214
|
-
hash =
|
|
215
|
-
tx = (
|
|
218
|
+
hash = _g.sent();
|
|
219
|
+
tx = (_f = new web3_js_1.Transaction({
|
|
216
220
|
feePayer: invoker.publicKey,
|
|
217
221
|
blockhash: hash.blockhash,
|
|
218
222
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
219
|
-
})).add.apply(
|
|
223
|
+
})).add.apply(_f, __spreadArray([], __read(ixs), false));
|
|
220
224
|
return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
221
225
|
case 6:
|
|
222
|
-
signature =
|
|
226
|
+
signature = _g.sent();
|
|
223
227
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
224
228
|
}
|
|
225
229
|
});
|
|
226
230
|
});
|
|
227
231
|
};
|
|
228
232
|
SolanaDistributorClient.prototype.clawback = function (data, _a) {
|
|
229
|
-
var invoker = _a.invoker;
|
|
233
|
+
var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
|
|
230
234
|
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
-
var distributorPublicKey, distributor, ixs, accounts, commitment, hash, tx, signature;
|
|
232
|
-
var
|
|
233
|
-
return __generator(this, function (
|
|
234
|
-
switch (
|
|
235
|
+
var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, accounts, commitment, hash, tx, signature;
|
|
236
|
+
var _f;
|
|
237
|
+
return __generator(this, function (_g) {
|
|
238
|
+
switch (_g.label) {
|
|
235
239
|
case 0:
|
|
236
240
|
if (!invoker.publicKey) {
|
|
237
241
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -239,13 +243,17 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
239
243
|
distributorPublicKey = new web3_js_1.PublicKey(data.id);
|
|
240
244
|
return [4 /*yield*/, accounts_1.MerkleDistributor.fetch(this.connection, distributorPublicKey)];
|
|
241
245
|
case 1:
|
|
242
|
-
distributor =
|
|
246
|
+
distributor = _g.sent();
|
|
243
247
|
if (!distributor) {
|
|
244
248
|
throw new Error("Couldn't get account info");
|
|
245
249
|
}
|
|
250
|
+
ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
|
|
251
|
+
_c = (_b = ixs.push).apply;
|
|
252
|
+
_d = [ixs];
|
|
253
|
+
_e = [[]];
|
|
246
254
|
return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker)];
|
|
247
255
|
case 2:
|
|
248
|
-
|
|
256
|
+
_c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_g.sent())]), false]))]));
|
|
249
257
|
accounts = {
|
|
250
258
|
distributor: distributorPublicKey,
|
|
251
259
|
from: distributor.tokenVault,
|
|
@@ -259,15 +267,15 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
259
267
|
commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
260
268
|
return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
|
|
261
269
|
case 3:
|
|
262
|
-
hash =
|
|
263
|
-
tx = (
|
|
270
|
+
hash = _g.sent();
|
|
271
|
+
tx = (_f = new web3_js_1.Transaction({
|
|
264
272
|
feePayer: invoker.publicKey,
|
|
265
273
|
blockhash: hash.blockhash,
|
|
266
274
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
267
|
-
})).add.apply(
|
|
275
|
+
})).add.apply(_f, __spreadArray([], __read(ixs), false));
|
|
268
276
|
return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
269
277
|
case 4:
|
|
270
|
-
signature =
|
|
278
|
+
signature = _g.sent();
|
|
271
279
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
272
280
|
}
|
|
273
281
|
});
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import BN from "bn.js";
|
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { Keypair } from "@solana/web3.js";
|
|
4
4
|
import { ITransactionResult } from "@streamflow/common";
|
|
5
|
-
|
|
5
|
+
import { ITransactionSolanaExt } from "@streamflow/common/solana";
|
|
6
|
+
export interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
6
7
|
invoker: SignerWalletAdapter | Keypair;
|
|
7
8
|
}
|
|
8
9
|
export interface ICreateSolanaExt extends IInteractSolanaExt {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/distributor",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.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": "0d8959b0eb4183e745173f69490f3567ee5ff880",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@streamflow/eslint-config": "6.0.0-alpha.
|
|
27
|
+
"@streamflow/eslint-config": "6.0.0-alpha.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.0.0-alpha.
|
|
41
|
+
"@streamflow/common": "6.0.0-alpha.2",
|
|
42
42
|
"bn.js": "5.2.1",
|
|
43
43
|
"borsh": "^2.0.0",
|
|
44
44
|
"bs58": "5.0.0"
|