@streamflow/distributor 6.0.0 → 6.0.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.
@@ -89,25 +89,25 @@ var SolanaDistributorClient = /** @class */ (function () {
89
89
  SolanaDistributorClient.prototype.create = function (data, _a) {
90
90
  var invoker = _a.invoker, _b = _a.isNative, isNative = _b === void 0 ? false : _b, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
91
91
  return __awaiter(this, void 0, void 0, function () {
92
- var ixs, mint, mintAccount, distributorPublicKey, tokenVault, senderTokens, args, accounts, _c, _d, _e, _f, nowTs, endVestingTs, startVestingTs, _g, tx, hash, signature;
93
- return __generator(this, function (_h) {
94
- switch (_h.label) {
92
+ var ixs, mint, _c, mintAccount, programId, distributorPublicKey, tokenVault, senderTokens, args, accounts, _d, _e, _f, _g, nowTs, endVestingTs, startVestingTs, _h, tx, hash, signature;
93
+ return __generator(this, function (_j) {
94
+ switch (_j.label) {
95
95
  case 0:
96
96
  if (!invoker.publicKey) {
97
97
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
98
98
  }
99
99
  ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
100
100
  mint = isNative ? spl_token_1.NATIVE_MINT : new web3_js_1.PublicKey(data.mint);
101
- return [4 /*yield*/, (0, spl_token_1.getMint)(this.connection, mint)];
101
+ return [4 /*yield*/, (0, solana_1.getMintAndProgram)(this.connection, mint)];
102
102
  case 1:
103
- mintAccount = _h.sent();
103
+ _c = _j.sent(), mintAccount = _c.mint, programId = _c.programId;
104
104
  distributorPublicKey = (0, utils_1.getDistributorPda)(this.programId, mint, data.version);
105
- return [4 /*yield*/, (0, solana_1.ata)(mint, distributorPublicKey)];
105
+ return [4 /*yield*/, (0, solana_1.ata)(mint, distributorPublicKey, programId)];
106
106
  case 2:
107
- tokenVault = _h.sent();
108
- return [4 /*yield*/, (0, solana_1.ata)(mint, invoker.publicKey)];
107
+ tokenVault = _j.sent();
108
+ return [4 /*yield*/, (0, solana_1.ata)(mint, invoker.publicKey, programId)];
109
109
  case 3:
110
- senderTokens = _h.sent();
110
+ senderTokens = _j.sent();
111
111
  args = {
112
112
  version: new bn_js_1.default(data.version, 10),
113
113
  root: data.root,
@@ -127,16 +127,16 @@ var SolanaDistributorClient = /** @class */ (function () {
127
127
  admin: invoker.publicKey,
128
128
  systemProgram: web3_js_1.SystemProgram.programId,
129
129
  associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
130
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
130
+ tokenProgram: programId,
131
131
  };
132
132
  if (!isNative) return [3 /*break*/, 5];
133
- _d = (_c = ixs.push).apply;
134
- _e = [ixs];
135
- _f = [[]];
133
+ _e = (_d = ixs.push).apply;
134
+ _f = [ixs];
135
+ _g = [[]];
136
136
  return [4 /*yield*/, (0, solana_1.prepareWrappedAccount)(this.connection, invoker.publicKey, data.maxTotalClaim)];
137
137
  case 4:
138
- _d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
139
- _h.label = 5;
138
+ _e.apply(_d, _f.concat([__spreadArray.apply(void 0, _g.concat([__read.apply(void 0, [(_j.sent())]), false]))]));
139
+ _j.label = 5;
140
140
  case 5:
141
141
  nowTs = new bn_js_1.default(Math.floor(Date.now() / 1000));
142
142
  endVestingTs = args.endVestingTs.eqn(0) ? nowTs : args.endVestingTs;
@@ -145,13 +145,13 @@ var SolanaDistributorClient = /** @class */ (function () {
145
145
  throw new Error("The unlock period cannot be longer than the total vesting duration!");
146
146
  }
147
147
  ixs.push((0, instructions_1.newDistributor)(args, accounts, this.programId));
148
- ixs.push((0, spl_token_1.createTransferCheckedInstruction)(senderTokens, mint, tokenVault, invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals));
148
+ ixs.push((0, spl_token_1.createTransferCheckedInstruction)(senderTokens, mint, tokenVault, invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals, undefined, programId));
149
149
  return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey)];
150
150
  case 6:
151
- _g = _h.sent(), tx = _g.tx, hash = _g.hash;
151
+ _h = _j.sent(), tx = _h.tx, hash = _h.hash;
152
152
  return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
153
153
  case 7:
154
- signature = _h.sent();
154
+ signature = _j.sent();
155
155
  return [2 /*return*/, {
156
156
  ixs: ixs,
157
157
  txId: signature,
@@ -164,7 +164,7 @@ var SolanaDistributorClient = /** @class */ (function () {
164
164
  SolanaDistributorClient.prototype.claim = function (data, _a) {
165
165
  var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
166
166
  return __awaiter(this, void 0, void 0, function () {
167
- var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, nowTs, _f, tx, hash, signature;
167
+ var distributorPublicKey, distributor, programId, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, nowTs, _f, tx, hash, signature;
168
168
  return __generator(this, function (_g) {
169
169
  switch (_g.label) {
170
170
  case 0:
@@ -178,19 +178,22 @@ var SolanaDistributorClient = /** @class */ (function () {
178
178
  if (!distributor) {
179
179
  throw new Error("Couldn't get account info");
180
180
  }
181
+ return [4 /*yield*/, (0, solana_1.getMintAndProgram)(this.connection, distributor.mint)];
182
+ case 2:
183
+ programId = (_g.sent()).programId;
181
184
  ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
182
185
  _c = (_b = ixs.push).apply;
183
186
  _d = [ixs];
184
187
  _e = [[]];
185
- return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker)];
186
- case 2:
187
- _c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_g.sent())]), false]))]));
188
- return [4 /*yield*/, (0, solana_1.ata)(distributor.mint, invoker.publicKey)];
188
+ return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker, programId)];
189
189
  case 3:
190
+ _c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_g.sent())]), false]))]));
191
+ return [4 /*yield*/, (0, solana_1.ata)(distributor.mint, invoker.publicKey, programId)];
192
+ case 4:
190
193
  invokerTokens = _g.sent();
191
194
  claimStatusPublicKey = (0, utils_1.getClaimantStatusPda)(this.programId, distributorPublicKey, invoker.publicKey);
192
195
  return [4 /*yield*/, accounts_1.ClaimStatus.fetch(this.connection, claimStatusPublicKey)];
193
- case 4:
196
+ case 5:
194
197
  claimStatus = _g.sent();
195
198
  accounts = {
196
199
  distributor: distributorPublicKey,
@@ -199,7 +202,7 @@ var SolanaDistributorClient = /** @class */ (function () {
199
202
  to: invokerTokens,
200
203
  claimant: invoker.publicKey,
201
204
  mint: distributor.mint,
202
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
205
+ tokenProgram: programId,
203
206
  systemProgram: web3_js_1.SystemProgram.programId,
204
207
  };
205
208
  if (!claimStatus) {
@@ -215,10 +218,10 @@ var SolanaDistributorClient = /** @class */ (function () {
215
218
  ixs.push((0, instructions_1.claimLocked)(accounts, this.programId));
216
219
  }
217
220
  return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey)];
218
- case 5:
221
+ case 6:
219
222
  _f = _g.sent(), tx = _f.tx, hash = _f.hash;
220
223
  return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
221
- case 6:
224
+ case 7:
222
225
  signature = _g.sent();
223
226
  return [2 /*return*/, { ixs: ixs, txId: signature }];
224
227
  }
@@ -228,7 +231,7 @@ var SolanaDistributorClient = /** @class */ (function () {
228
231
  SolanaDistributorClient.prototype.clawback = function (data, _a) {
229
232
  var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
230
233
  return __awaiter(this, void 0, void 0, function () {
231
- var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, accounts, _f, tx, hash, signature;
234
+ var distributorPublicKey, distributor, programId, ixs, _b, _c, _d, _e, accounts, _f, tx, hash, signature;
232
235
  return __generator(this, function (_g) {
233
236
  switch (_g.label) {
234
237
  case 0:
@@ -242,12 +245,15 @@ var SolanaDistributorClient = /** @class */ (function () {
242
245
  if (!distributor) {
243
246
  throw new Error("Couldn't get account info");
244
247
  }
248
+ return [4 /*yield*/, (0, solana_1.getMintAndProgram)(this.connection, distributor.mint)];
249
+ case 2:
250
+ programId = (_g.sent()).programId;
245
251
  ixs = (0, solana_1.prepareBaseInstructions)(this.connection, { computePrice: computePrice, computeLimit: computeLimit });
246
252
  _c = (_b = ixs.push).apply;
247
253
  _d = [ixs];
248
254
  _e = [[]];
249
- return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker)];
250
- case 2:
255
+ return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, [invoker.publicKey], distributor.mint, invoker, programId)];
256
+ case 3:
251
257
  _c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_g.sent())]), false]))]));
252
258
  accounts = {
253
259
  distributor: distributorPublicKey,
@@ -256,14 +262,14 @@ var SolanaDistributorClient = /** @class */ (function () {
256
262
  admin: invoker.publicKey,
257
263
  mint: distributor.mint,
258
264
  systemProgram: web3_js_1.SystemProgram.programId,
259
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
265
+ tokenProgram: programId,
260
266
  };
261
267
  ixs.push((0, instructions_1.clawback)(accounts, this.programId));
262
268
  return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey)];
263
- case 3:
269
+ case 4:
264
270
  _f = _g.sent(), tx = _f.tx, hash = _f.hash;
265
271
  return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
266
- case 4:
272
+ case 5:
267
273
  signature = _g.sent();
268
274
  return [2 /*return*/, { ixs: ixs, txId: signature }];
269
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/distributor",
3
- "version": "6.0.0",
3
+ "version": "6.0.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,7 +22,7 @@
22
22
  "lint": "eslint --fix .",
23
23
  "prepublishOnly": "npm run lint && npm run build"
24
24
  },
25
- "gitHead": "29f0a936ac05651c8b61d0e3db35f2f06533178c",
25
+ "gitHead": "53a78cbfcb7053bf2b9b267ad8f678cade3e6fe1",
26
26
  "devDependencies": {
27
27
  "@streamflow/eslint-config": "6.0.0",
28
28
  "@types/bn.js": "5.1.1",
@@ -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",
41
+ "@streamflow/common": "6.0.2",
42
42
  "bn.js": "5.2.1",
43
43
  "borsh": "^2.0.0",
44
44
  "bs58": "5.0.0"