@thesingularitynetwork/darkswap-sdk 0.1.37 → 0.1.38
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/darkswap-sdk.cjs.development.js +19 -157
- package/dist/darkswap-sdk.cjs.development.js.map +1 -1
- package/dist/darkswap-sdk.cjs.production.min.js +1 -1
- package/dist/darkswap-sdk.cjs.production.min.js.map +1 -1
- package/dist/darkswap-sdk.esm.js +19 -157
- package/dist/darkswap-sdk.esm.js.map +1 -1
- package/dist/services/retail/depositAndCreateOrder.d.ts +1 -1
- package/package.json +1 -1
- package/dist/utils/safeWait.d.ts +0 -2
|
@@ -5292,104 +5292,6 @@ function _generateWithdrawProof() {
|
|
|
5292
5292
|
return _generateWithdrawProof.apply(this, arguments);
|
|
5293
5293
|
}
|
|
5294
5294
|
|
|
5295
|
-
function safeWait(_x, _x2, _x3) {
|
|
5296
|
-
return _safeWait.apply(this, arguments);
|
|
5297
|
-
}
|
|
5298
|
-
function _safeWait() {
|
|
5299
|
-
_safeWait = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(tx, provider, conf) {
|
|
5300
|
-
var _err$message, err, msg, _t;
|
|
5301
|
-
return _regenerator().w(function (_context) {
|
|
5302
|
-
while (1) switch (_context.n) {
|
|
5303
|
-
case 0:
|
|
5304
|
-
if (conf === void 0) {
|
|
5305
|
-
conf = 1;
|
|
5306
|
-
}
|
|
5307
|
-
_context.p = 1;
|
|
5308
|
-
_context.n = 2;
|
|
5309
|
-
return tx.wait(conf);
|
|
5310
|
-
case 2:
|
|
5311
|
-
return _context.a(2, _context.v);
|
|
5312
|
-
case 3:
|
|
5313
|
-
_context.p = 3;
|
|
5314
|
-
_t = _context.v;
|
|
5315
|
-
console.log("tx.wait error", _t);
|
|
5316
|
-
err = _t;
|
|
5317
|
-
msg = (_err$message = err == null ? void 0 : err.message) != null ? _err$message : "";
|
|
5318
|
-
if (!(msg.includes("value.nonce") || msg.includes("Cannot convert undefined to a BigInt"))) {
|
|
5319
|
-
_context.n = 5;
|
|
5320
|
-
break;
|
|
5321
|
-
}
|
|
5322
|
-
console.log("try getTransactionReceipt");
|
|
5323
|
-
_context.n = 4;
|
|
5324
|
-
return waitForReceipt(provider, tx.hash, conf);
|
|
5325
|
-
case 4:
|
|
5326
|
-
return _context.a(2, _context.v);
|
|
5327
|
-
case 5:
|
|
5328
|
-
throw _t;
|
|
5329
|
-
case 6:
|
|
5330
|
-
return _context.a(2);
|
|
5331
|
-
}
|
|
5332
|
-
}, _callee, null, [[1, 3]]);
|
|
5333
|
-
}));
|
|
5334
|
-
return _safeWait.apply(this, arguments);
|
|
5335
|
-
}
|
|
5336
|
-
function waitForReceipt(_x4, _x5, _x6, _x7, _x8) {
|
|
5337
|
-
return _waitForReceipt.apply(this, arguments);
|
|
5338
|
-
}
|
|
5339
|
-
function _waitForReceipt() {
|
|
5340
|
-
_waitForReceipt = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(provider, hash, confirmations, pollMs, timeoutMs) {
|
|
5341
|
-
var start, receipt, tip;
|
|
5342
|
-
return _regenerator().w(function (_context2) {
|
|
5343
|
-
while (1) switch (_context2.n) {
|
|
5344
|
-
case 0:
|
|
5345
|
-
if (confirmations === void 0) {
|
|
5346
|
-
confirmations = 1;
|
|
5347
|
-
}
|
|
5348
|
-
if (pollMs === void 0) {
|
|
5349
|
-
pollMs = 600;
|
|
5350
|
-
}
|
|
5351
|
-
if (timeoutMs === void 0) {
|
|
5352
|
-
timeoutMs = 60000;
|
|
5353
|
-
}
|
|
5354
|
-
start = Date.now();
|
|
5355
|
-
case 1:
|
|
5356
|
-
if (!(Date.now() - start < timeoutMs)) {
|
|
5357
|
-
_context2.n = 6;
|
|
5358
|
-
break;
|
|
5359
|
-
}
|
|
5360
|
-
_context2.n = 2;
|
|
5361
|
-
return provider.getTransactionReceipt(hash);
|
|
5362
|
-
case 2:
|
|
5363
|
-
receipt = _context2.v;
|
|
5364
|
-
if (!(receipt && receipt.blockNumber)) {
|
|
5365
|
-
_context2.n = 4;
|
|
5366
|
-
break;
|
|
5367
|
-
}
|
|
5368
|
-
_context2.n = 3;
|
|
5369
|
-
return provider.getBlockNumber();
|
|
5370
|
-
case 3:
|
|
5371
|
-
tip = _context2.v;
|
|
5372
|
-
if (!(tip - receipt.blockNumber + 1 >= confirmations)) {
|
|
5373
|
-
_context2.n = 4;
|
|
5374
|
-
break;
|
|
5375
|
-
}
|
|
5376
|
-
return _context2.a(2, receipt);
|
|
5377
|
-
case 4:
|
|
5378
|
-
_context2.n = 5;
|
|
5379
|
-
return new Promise(function (r) {
|
|
5380
|
-
return setTimeout(r, pollMs);
|
|
5381
|
-
});
|
|
5382
|
-
case 5:
|
|
5383
|
-
_context2.n = 1;
|
|
5384
|
-
break;
|
|
5385
|
-
case 6:
|
|
5386
|
-
return _context2.a(2, null);
|
|
5387
|
-
}
|
|
5388
|
-
}, _callee2);
|
|
5389
|
-
}));
|
|
5390
|
-
return _waitForReceipt.apply(this, arguments);
|
|
5391
|
-
}
|
|
5392
|
-
|
|
5393
5295
|
var WithdrawContext = /*#__PURE__*/function (_BaseContext) {
|
|
5394
5296
|
function WithdrawContext(signature) {
|
|
5395
5297
|
return _BaseContext.call(this, signature) || this;
|
|
@@ -5506,7 +5408,7 @@ var WithdrawService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
5506
5408
|
}();
|
|
5507
5409
|
_proto.execute = /*#__PURE__*/function () {
|
|
5508
5410
|
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(context) {
|
|
5509
|
-
var contract, tx
|
|
5411
|
+
var contract, tx;
|
|
5510
5412
|
return _regenerator().w(function (_context3) {
|
|
5511
5413
|
while (1) switch (_context3.n) {
|
|
5512
5414
|
case 0:
|
|
@@ -5525,15 +5427,8 @@ var WithdrawService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
5525
5427
|
case 3:
|
|
5526
5428
|
tx = _context3.v;
|
|
5527
5429
|
_context3.n = 4;
|
|
5528
|
-
return
|
|
5430
|
+
return tx.wait();
|
|
5529
5431
|
case 4:
|
|
5530
|
-
reciept = _context3.v;
|
|
5531
|
-
if (!(!reciept || reciept.status !== 1)) {
|
|
5532
|
-
_context3.n = 5;
|
|
5533
|
-
break;
|
|
5534
|
-
}
|
|
5535
|
-
throw new DarkSwapError('Failed to withdraw');
|
|
5536
|
-
case 5:
|
|
5537
5432
|
return _context3.a(2, tx.hash);
|
|
5538
5433
|
}
|
|
5539
5434
|
}, _callee3, this);
|
|
@@ -9361,7 +9256,7 @@ var RetailCancelOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9361
9256
|
}();
|
|
9362
9257
|
_proto.execute = /*#__PURE__*/function () {
|
|
9363
9258
|
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(context) {
|
|
9364
|
-
var contract, tx
|
|
9259
|
+
var contract, tx;
|
|
9365
9260
|
return _regenerator().w(function (_context3) {
|
|
9366
9261
|
while (1) switch (_context3.n) {
|
|
9367
9262
|
case 0:
|
|
@@ -9380,15 +9275,8 @@ var RetailCancelOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9380
9275
|
case 3:
|
|
9381
9276
|
tx = _context3.v;
|
|
9382
9277
|
_context3.n = 4;
|
|
9383
|
-
return
|
|
9278
|
+
return tx.wait();
|
|
9384
9279
|
case 4:
|
|
9385
|
-
reciept = _context3.v;
|
|
9386
|
-
if (!(!reciept || reciept.status !== 1)) {
|
|
9387
|
-
_context3.n = 5;
|
|
9388
|
-
break;
|
|
9389
|
-
}
|
|
9390
|
-
throw new DarkSwapError('Failed to cancel order');
|
|
9391
|
-
case 5:
|
|
9392
9280
|
return _context3.a(2, tx.hash);
|
|
9393
9281
|
}
|
|
9394
9282
|
}, _callee3, this);
|
|
@@ -9567,7 +9455,7 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9567
9455
|
}();
|
|
9568
9456
|
_proto.allowance = /*#__PURE__*/function () {
|
|
9569
9457
|
var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
|
|
9570
|
-
var signer, asset, amount, allowanceContract, allowance, isLegacy, contract, tx
|
|
9458
|
+
var signer, asset, amount, allowanceContract, allowance, isLegacy, contract, tx;
|
|
9571
9459
|
return _regenerator().w(function (_context4) {
|
|
9572
9460
|
while (1) switch (_context4.n) {
|
|
9573
9461
|
case 0:
|
|
@@ -9577,13 +9465,19 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9577
9465
|
}
|
|
9578
9466
|
throw new DarkSwapError('Invalid context');
|
|
9579
9467
|
case 1:
|
|
9468
|
+
if (!isNativeAsset(context.orderNote.asset)) {
|
|
9469
|
+
_context4.n = 2;
|
|
9470
|
+
break;
|
|
9471
|
+
}
|
|
9472
|
+
return _context4.a(2);
|
|
9473
|
+
case 2:
|
|
9580
9474
|
signer = this._darkSwap.signer;
|
|
9581
9475
|
asset = context.orderNote.asset;
|
|
9582
9476
|
amount = context.orderNote.amount;
|
|
9583
9477
|
allowanceContract = new ethers.ethers.Contract(asset, ERC20Abi.abi, this._darkSwap);
|
|
9584
|
-
_context4.n =
|
|
9478
|
+
_context4.n = 3;
|
|
9585
9479
|
return allowanceContract.allowance(signer.getAddress(), this._darkSwap.contracts.darkSwapAssetManager);
|
|
9586
|
-
case
|
|
9480
|
+
case 3:
|
|
9587
9481
|
allowance = _context4.v;
|
|
9588
9482
|
if (!(BigInt(allowance) < amount)) {
|
|
9589
9483
|
_context4.n = 5;
|
|
@@ -9591,19 +9485,12 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9591
9485
|
}
|
|
9592
9486
|
isLegacy = legacyTokenConfig.hasOwnProperty(this._darkSwap.chainId) && legacyTokenConfig[this._darkSwap.chainId].includes(asset.toLowerCase());
|
|
9593
9487
|
contract = new ethers.ethers.Contract(asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
|
|
9594
|
-
_context4.n = 3;
|
|
9595
|
-
return contract.approve(this._darkSwap.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
|
|
9596
|
-
case 3:
|
|
9597
|
-
tx = _context4.v;
|
|
9598
9488
|
_context4.n = 4;
|
|
9599
|
-
return
|
|
9489
|
+
return contract.approve(this._darkSwap.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
|
|
9600
9490
|
case 4:
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
break;
|
|
9605
|
-
}
|
|
9606
|
-
throw new DarkSwapError('Failed to approve token');
|
|
9491
|
+
tx = _context4.v;
|
|
9492
|
+
_context4.n = 5;
|
|
9493
|
+
return tx.wait();
|
|
9607
9494
|
case 5:
|
|
9608
9495
|
return _context4.a(2);
|
|
9609
9496
|
}
|
|
@@ -9616,7 +9503,7 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9616
9503
|
}();
|
|
9617
9504
|
_proto.execute = /*#__PURE__*/function () {
|
|
9618
9505
|
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(context) {
|
|
9619
|
-
var contract, ethAmount, tx
|
|
9506
|
+
var contract, ethAmount, tx;
|
|
9620
9507
|
return _regenerator().w(function (_context5) {
|
|
9621
9508
|
while (1) switch (_context5.n) {
|
|
9622
9509
|
case 0:
|
|
@@ -9648,34 +9535,9 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9648
9535
|
});
|
|
9649
9536
|
case 5:
|
|
9650
9537
|
tx = _context5.v;
|
|
9651
|
-
console.log("=== before safeWait");
|
|
9652
9538
|
_context5.n = 6;
|
|
9653
|
-
return
|
|
9539
|
+
return tx.wait();
|
|
9654
9540
|
case 6:
|
|
9655
|
-
reciept = _context5.v;
|
|
9656
|
-
if (reciept) {
|
|
9657
|
-
_context5.n = 9;
|
|
9658
|
-
break;
|
|
9659
|
-
}
|
|
9660
|
-
_context5.n = 7;
|
|
9661
|
-
return isNoteCreated(this._darkSwap, context.orderNote.note);
|
|
9662
|
-
case 7:
|
|
9663
|
-
tmpIsNoteCreated = _context5.v;
|
|
9664
|
-
if (tmpIsNoteCreated) {
|
|
9665
|
-
_context5.n = 8;
|
|
9666
|
-
break;
|
|
9667
|
-
}
|
|
9668
|
-
throw new DarkSwapError('Failed to create order');
|
|
9669
|
-
case 8:
|
|
9670
|
-
_context5.n = 10;
|
|
9671
|
-
break;
|
|
9672
|
-
case 9:
|
|
9673
|
-
if (!(reciept.status !== 1)) {
|
|
9674
|
-
_context5.n = 10;
|
|
9675
|
-
break;
|
|
9676
|
-
}
|
|
9677
|
-
throw new DarkSwapError('Failed to create order');
|
|
9678
|
-
case 10:
|
|
9679
9541
|
return _context5.a(2, tx.hash);
|
|
9680
9542
|
}
|
|
9681
9543
|
}, _callee5, this);
|