@streamflow/stream 4.1.0-beta.1 → 4.1.0-beta.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.
@@ -260,7 +260,7 @@ var EvmStreamClient = /** @class */ (function (_super) {
260
260
  var result;
261
261
  return __generator(this, function (_a) {
262
262
  switch (_a.label) {
263
- case 0: return [4 /*yield*/, this.writeContract.cancel(transferData.id, transferData.newRecipient)];
263
+ case 0: return [4 /*yield*/, this.writeContract.transfer(transferData.id, transferData.newRecipient)];
264
264
  case 1:
265
265
  result = _a.sent();
266
266
  return [2 /*return*/, {
@@ -273,16 +273,27 @@ var EvmStreamClient = /** @class */ (function (_super) {
273
273
  };
274
274
  EvmStreamClient.prototype.topup = function (topupData) {
275
275
  return __awaiter(this, void 0, void 0, function () {
276
- var fees, result;
276
+ var fees, sum, stream, tokenContract, approvalTx, result;
277
277
  return __generator(this, function (_a) {
278
278
  switch (_a.label) {
279
279
  case 0: return [4 /*yield*/, this.readContract.getTopUpWithdrawalFees(topupData.id, topupData.amount.toString())];
280
280
  case 1:
281
281
  fees = _a.sent();
282
- return [4 /*yield*/, this.writeContract.create(topupData.id, topupData.amount.toString(), {
282
+ sum = topupData.amount.mul(new bn_js_1.BN(constants_2.BASE_FEE)).div(new bn_js_1.BN(1000000));
283
+ return [4 /*yield*/, this.getOne({ id: topupData.id })];
284
+ case 2:
285
+ stream = _a.sent();
286
+ tokenContract = new ethers_1.ethers.Contract(stream.mint, ercAbi_1.default, this.signer);
287
+ return [4 /*yield*/, tokenContract.approve(this.programId, sum.toString())];
288
+ case 3:
289
+ approvalTx = _a.sent();
290
+ return [4 /*yield*/, approvalTx.wait()];
291
+ case 4:
292
+ _a.sent();
293
+ return [4 /*yield*/, this.writeContract.topUp(topupData.id, topupData.amount.toString(), {
283
294
  value: fees.value,
284
295
  })];
285
- case 2:
296
+ case 5:
286
297
  result = _a.sent();
287
298
  return [2 /*return*/, {
288
299
  ixs: [],
@@ -412,7 +423,8 @@ var EvmStreamClient = /** @class */ (function (_super) {
412
423
  ];
413
424
  };
414
425
  EvmStreamClient.prototype.formatMetadataId = function (id) {
415
- return (0, ethereum_checksum_address_1.toChecksumAddress)("0x".concat(id.replace(/^0x0+/, "")));
426
+ // 40 chars is etherium address size
427
+ return (0, ethereum_checksum_address_1.toChecksumAddress)("0x".concat(id.slice(-40)));
416
428
  };
417
429
  return EvmStreamClient;
418
430
  }(BaseStreamClient_1.BaseStreamClient));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "4.1.0-beta.1",
3
+ "version": "4.1.0-beta.2",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",