@streamflow/distributor 6.0.0-alpha.9 → 6.0.0

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,7 +89,7 @@ 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, _g, tx, hash, signature;
92
+ var ixs, mint, mintAccount, distributorPublicKey, tokenVault, senderTokens, args, accounts, _c, _d, _e, _f, nowTs, endVestingTs, startVestingTs, _g, tx, hash, signature;
93
93
  return __generator(this, function (_h) {
94
94
  switch (_h.label) {
95
95
  case 0:
@@ -138,6 +138,12 @@ var SolanaDistributorClient = /** @class */ (function () {
138
138
  _d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
139
139
  _h.label = 5;
140
140
  case 5:
141
+ nowTs = new bn_js_1.default(Math.floor(Date.now() / 1000));
142
+ endVestingTs = args.endVestingTs.eqn(0) ? nowTs : args.endVestingTs;
143
+ startVestingTs = args.startVestingTs.eqn(0) ? nowTs : args.startVestingTs;
144
+ if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
145
+ throw new Error("The unlock period cannot be longer than the total vesting duration!");
146
+ }
141
147
  ixs.push((0, instructions_1.newDistributor)(args, accounts, this.programId));
142
148
  ixs.push((0, spl_token_1.createTransferCheckedInstruction)(senderTokens, mint, tokenVault, invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals));
143
149
  return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey)];
@@ -158,7 +164,7 @@ var SolanaDistributorClient = /** @class */ (function () {
158
164
  SolanaDistributorClient.prototype.claim = function (data, _a) {
159
165
  var invoker = _a.invoker, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
160
166
  return __awaiter(this, void 0, void 0, function () {
161
- var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, _f, tx, hash, signature;
167
+ var distributorPublicKey, distributor, ixs, _b, _c, _d, _e, invokerTokens, claimStatusPublicKey, claimStatus, accounts, args, nowTs, _f, tx, hash, signature;
162
168
  return __generator(this, function (_g) {
163
169
  switch (_g.label) {
164
170
  case 0:
@@ -204,7 +210,8 @@ var SolanaDistributorClient = /** @class */ (function () {
204
210
  };
205
211
  ixs.push((0, instructions_1.newClaim)(args, accounts, this.programId));
206
212
  }
207
- if (data.amountLocked.gtn(0)) {
213
+ nowTs = new bn_js_1.default(Math.floor(Date.now() / 1000));
214
+ if (claimStatus || (data.amountLocked.gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod))) {
208
215
  ixs.push((0, instructions_1.claimLocked)(accounts, this.programId));
209
216
  }
210
217
  return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, invoker.publicKey)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/distributor",
3
- "version": "6.0.0-alpha.9",
3
+ "version": "6.0.0",
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": "ced180a9f3c99ae6b5dab7f2dca3309390e35e59",
25
+ "gitHead": "29f0a936ac05651c8b61d0e3db35f2f06533178c",
26
26
  "devDependencies": {
27
- "@streamflow/eslint-config": "6.0.0-alpha.9",
27
+ "@streamflow/eslint-config": "6.0.0",
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.9",
41
+ "@streamflow/common": "6.0.0",
42
42
  "bn.js": "5.2.1",
43
43
  "borsh": "^2.0.0",
44
44
  "bs58": "5.0.0"