@streamflow/distributor 6.0.0-alpha.2 → 6.0.0-alpha.3

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.
@@ -16,6 +16,7 @@ export default class SolanaDistributorClient {
16
16
  * Create Stream instance
17
17
  */
18
18
  constructor({ clusterUrl, cluster, commitment, programId }: IInitOptions);
19
+ getCommitment(): Commitment | undefined;
19
20
  create(data: ICreateDistributorData, { invoker, isNative, computePrice, computeLimit }: ICreateSolanaExt): Promise<ICreateDistributorResult>;
20
21
  claim(data: IClaimData, { invoker, computePrice, computeLimit }: IInteractSolanaExt): Promise<ITransactionResult>;
21
22
  clawback(data: IClawbackData, { invoker, computePrice, computeLimit }: IInteractSolanaExt): Promise<ITransactionResult>;
@@ -83,11 +83,13 @@ var SolanaDistributorClient = /** @class */ (function () {
83
83
  this.connection = new web3_js_1.Connection(clusterUrl, this.commitment);
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
+ SolanaDistributorClient.prototype.getCommitment = function () {
87
+ return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
88
+ };
86
89
  SolanaDistributorClient.prototype.create = function (data, _a) {
87
90
  var invoker = _a.invoker, _b = _a.isNative, isNative = _b === void 0 ? false : _b, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
88
91
  return __awaiter(this, void 0, void 0, function () {
89
- var ixs, mint, mintAccount, distributorPublicKey, tokenVault, senderTokens, args, accounts, _c, _d, _e, _f, commitment, hash, tx, signature;
90
- var _g;
92
+ var ixs, mint, mintAccount, distributorPublicKey, tokenVault, senderTokens, args, accounts, _c, _d, _e, _f, _g, tx, hash, signature;
91
93
  return __generator(this, function (_h) {
92
94
  switch (_h.label) {
93
95
  case 0:
@@ -138,15 +140,9 @@ var SolanaDistributorClient = /** @class */ (function () {
138
140
  case 5:
139
141
  ixs.push((0, instructions_1.newDistributor)(args, accounts, this.programId));
140
142
  ixs.push((0, spl_token_1.createTransferCheckedInstruction)(senderTokens, mint, tokenVault, invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals));
141
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
142
- return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
143
+ return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey, this.getCommitment())];
143
144
  case 6:
144
- hash = _h.sent();
145
- tx = (_g = new web3_js_1.Transaction({
146
- feePayer: invoker.publicKey,
147
- blockhash: hash.blockhash,
148
- lastValidBlockHeight: hash.lastValidBlockHeight,
149
- })).add.apply(_g, __spreadArray([], __read(ixs), false));
145
+ _g = _h.sent(), tx = _g.tx, hash = _g.hash;
150
146
  return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
151
147
  case 7:
152
148
  signature = _h.sent();
@@ -162,8 +158,7 @@ var SolanaDistributorClient = /** @class */ (function () {
162
158
  SolanaDistributorClient.prototype.claim = function (data, _a) {
163
159
  var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
164
160
  return __awaiter(this, void 0, void 0, function () {
165
- var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, commitment, hash, tx, signature;
166
- var _f;
161
+ var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, _f, tx, hash, signature;
167
162
  return __generator(this, function (_g) {
168
163
  switch (_g.label) {
169
164
  case 0:
@@ -212,15 +207,9 @@ var SolanaDistributorClient = /** @class */ (function () {
212
207
  };
213
208
  ixs.push((0, instructions_1.newClaim)(args, accounts, this.programId));
214
209
  }
215
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
216
- return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
210
+ return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey, this.getCommitment())];
217
211
  case 5:
218
- hash = _g.sent();
219
- tx = (_f = new web3_js_1.Transaction({
220
- feePayer: invoker.publicKey,
221
- blockhash: hash.blockhash,
222
- lastValidBlockHeight: hash.lastValidBlockHeight,
223
- })).add.apply(_f, __spreadArray([], __read(ixs), false));
212
+ _f = _g.sent(), tx = _f.tx, hash = _f.hash;
224
213
  return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
225
214
  case 6:
226
215
  signature = _g.sent();
@@ -232,8 +221,7 @@ var SolanaDistributorClient = /** @class */ (function () {
232
221
  SolanaDistributorClient.prototype.clawback = function (data, _a) {
233
222
  var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
234
223
  return __awaiter(this, void 0, void 0, function () {
235
- var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, accounts, commitment, hash, tx, signature;
236
- var _f;
224
+ var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, accounts, _f, tx, hash, signature;
237
225
  return __generator(this, function (_g) {
238
226
  switch (_g.label) {
239
227
  case 0:
@@ -264,15 +252,9 @@ var SolanaDistributorClient = /** @class */ (function () {
264
252
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
265
253
  };
266
254
  ixs.push((0, instructions_1.clawback)(accounts, this.programId));
267
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
268
- return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
255
+ return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey, this.getCommitment())];
269
256
  case 3:
270
- hash = _g.sent();
271
- tx = (_f = new web3_js_1.Transaction({
272
- feePayer: invoker.publicKey,
273
- blockhash: hash.blockhash,
274
- lastValidBlockHeight: hash.lastValidBlockHeight,
275
- })).add.apply(_f, __spreadArray([], __read(ixs), false));
257
+ _f = _g.sent(), tx = _f.tx, hash = _f.hash;
276
258
  return [4 /*yield*/, (0, utils_1.wrappedSignAndExecuteTransaction)(this.connection, invoker, tx, hash)];
277
259
  case 4:
278
260
  signature = _g.sent();
@@ -61,15 +61,13 @@ function getClaimantStatusPda(programId, distributor, claimant) {
61
61
  exports.getClaimantStatusPda = getClaimantStatusPda;
62
62
  function wrappedSignAndExecuteTransaction(connection, invoker, tx, hash) {
63
63
  return __awaiter(this, void 0, void 0, function () {
64
- var signature, err_1, parsed;
64
+ var err_1, parsed;
65
65
  return __generator(this, function (_a) {
66
66
  switch (_a.label) {
67
67
  case 0:
68
68
  _a.trys.push([0, 2, , 3]);
69
69
  return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(connection, invoker, tx, hash)];
70
- case 1:
71
- signature = _a.sent();
72
- return [2 /*return*/, signature];
70
+ case 1: return [2 /*return*/, _a.sent()];
73
71
  case 2:
74
72
  err_1 = _a.sent();
75
73
  if (err_1 instanceof Error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/distributor",
3
- "version": "6.0.0-alpha.2",
3
+ "version": "6.0.0-alpha.3",
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": "0d8959b0eb4183e745173f69490f3567ee5ff880",
25
+ "gitHead": "4f5eed327dda8e1c9d5c3ad74046aff4b99a80ed",
26
26
  "devDependencies": {
27
- "@streamflow/eslint-config": "6.0.0-alpha.2",
27
+ "@streamflow/eslint-config": "6.0.0-alpha.3",
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.2",
41
+ "@streamflow/common": "6.0.0-alpha.3",
42
42
  "bn.js": "5.2.1",
43
43
  "borsh": "^2.0.0",
44
44
  "bs58": "5.0.0"