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