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