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