@thesingularitynetwork/darkswap-sdk 0.1.25 → 0.1.27

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.
@@ -4650,31 +4650,59 @@ function multiGetMerklePathAndRoot(_x3, _x4) {
4650
4650
  }
4651
4651
  function _multiGetMerklePathAndRoot() {
4652
4652
  _multiGetMerklePathAndRoot = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(notes, darkSwap) {
4653
- var contract, _yield$contract$getMu, root, paths, indexes, results, i;
4653
+ var contract, results, _yield$contract$getMu, root, paths, indexes, i, _yield$contract$getMu2, _root, _paths, _indexes;
4654
4654
  return _regenerator().w(function (_context2) {
4655
4655
  while (1) switch (_context2.n) {
4656
4656
  case 0:
4657
4657
  contract = getContract$1(darkSwap.contracts.merkleTreeOperator, darkSwap);
4658
+ results = [];
4658
4659
  _context2.n = 1;
4659
- return contract.getMultiMerklePaths(notes.map(function (note) {
4660
- return hexlify32(note);
4661
- }));
4660
+ return contract.getMultiMerklePaths([hexlify32(notes[0])]);
4662
4661
  case 1:
4663
4662
  _yield$contract$getMu = _context2.v;
4664
4663
  root = _yield$contract$getMu[0];
4665
4664
  paths = _yield$contract$getMu[1];
4666
4665
  indexes = _yield$contract$getMu[2];
4667
- results = [];
4668
- for (i = 0; i < notes.length; i++) {
4669
- results.push({
4670
- noteCommitment: notes[i],
4671
- path: paths[i],
4672
- index: indexes[i].map(function (x) {
4673
- return x ? 1 : 0;
4674
- }),
4675
- root: root
4676
- });
4666
+ results.push({
4667
+ noteCommitment: notes[0],
4668
+ path: paths[0],
4669
+ index: indexes[0].map(function (x) {
4670
+ return x ? 1 : 0;
4671
+ }),
4672
+ root: root
4673
+ });
4674
+ i = 1;
4675
+ case 2:
4676
+ if (!(i < notes.length)) {
4677
+ _context2.n = 6;
4678
+ break;
4679
+ }
4680
+ _context2.n = 3;
4681
+ return contract.getMultiMerklePaths([hexlify32(notes[i])]);
4682
+ case 3:
4683
+ _yield$contract$getMu2 = _context2.v;
4684
+ _root = _yield$contract$getMu2[0];
4685
+ _paths = _yield$contract$getMu2[1];
4686
+ _indexes = _yield$contract$getMu2[2];
4687
+ if (!(_root != results[0].root)) {
4688
+ _context2.n = 4;
4689
+ break;
4677
4690
  }
4691
+ throw new DarkSwapError('Merkle root not match for multi notes, please try again');
4692
+ case 4:
4693
+ results.push({
4694
+ noteCommitment: notes[i],
4695
+ path: _paths[0],
4696
+ index: _indexes[0].map(function (x) {
4697
+ return x ? 1 : 0;
4698
+ }),
4699
+ root: _root
4700
+ });
4701
+ case 5:
4702
+ i++;
4703
+ _context2.n = 2;
4704
+ break;
4705
+ case 6:
4678
4706
  return _context2.a(2, results);
4679
4707
  }
4680
4708
  }, _callee2);
@@ -8832,7 +8860,7 @@ var ProSwapService = /*#__PURE__*/function (_BaseContractService) {
8832
8860
  }();
8833
8861
  _proto.execute = /*#__PURE__*/function () {
8834
8862
  var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
8835
- var contract, tx;
8863
+ var contract, swapArgs, estimatedGas, tx;
8836
8864
  return _regenerator().w(function (_context4) {
8837
8865
  while (1) switch (_context4.n) {
8838
8866
  case 0:
@@ -8846,13 +8874,20 @@ var ProSwapService = /*#__PURE__*/function (_BaseContractService) {
8846
8874
  throw new DarkSwapError('Invalid context');
8847
8875
  case 2:
8848
8876
  contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
8877
+ swapArgs = [context.merkleRoot, context.proof.aliceOutNullifier, hexlify32(context.orderNote.feeRatio), hexlify32(context.swapInNote.note), context.proof.aliceInNoteFooter, hexlify32(context.changeNote.note), context.proof.aliceChangeNoteFooter, context.proof.bobOutNullifier, hexlify32(context.bobSwapMessage.orderNote.feeRatio), hexlify32(context.bobSwapMessage.inNote.note), context.proof.bobInNoteFooter];
8849
8878
  _context4.n = 3;
8850
- return contract.proSwap([context.merkleRoot, context.proof.aliceOutNullifier, hexlify32(context.orderNote.feeRatio), hexlify32(context.swapInNote.note), context.proof.aliceInNoteFooter, hexlify32(context.changeNote.note), context.proof.aliceChangeNoteFooter, context.proof.bobOutNullifier, hexlify32(context.bobSwapMessage.orderNote.feeRatio), hexlify32(context.bobSwapMessage.inNote.note), context.proof.bobInNoteFooter], context.proof.proof);
8879
+ return contract.proSwap.estimateGas(swapArgs, context.proof.proof);
8851
8880
  case 3:
8852
- tx = _context4.v;
8881
+ estimatedGas = _context4.v;
8853
8882
  _context4.n = 4;
8854
- return tx.wait();
8883
+ return contract.proSwap(swapArgs, context.proof.proof, {
8884
+ gasLimit: estimatedGas
8885
+ });
8855
8886
  case 4:
8887
+ tx = _context4.v;
8888
+ _context4.n = 5;
8889
+ return tx.wait();
8890
+ case 5:
8856
8891
  return _context4.a(2, tx.hash);
8857
8892
  }
8858
8893
  }, _callee4, this);