@thesingularitynetwork/darkswap-sdk 0.2.4 → 0.2.7-beta1

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.
@@ -2579,6 +2579,26 @@ function _getNullifierBySignature() {
2579
2579
  }));
2580
2580
  return _getNullifierBySignature.apply(this, arguments);
2581
2581
  }
2582
+ function isNoteCreated(_x19, _x20) {
2583
+ return _isNoteCreated.apply(this, arguments);
2584
+ }
2585
+ function _isNoteCreated() {
2586
+ _isNoteCreated = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(darkSwap, note) {
2587
+ var contract, isNotCreated;
2588
+ return _regenerator().w(function (_context8) {
2589
+ while (1) switch (_context8.n) {
2590
+ case 0:
2591
+ contract = getContract(darkSwap.contracts.merkleTreeOperator, darkSwap);
2592
+ _context8.n = 1;
2593
+ return contract.noteIsNotCreated(hexlify32(note));
2594
+ case 1:
2595
+ isNotCreated = _context8.v;
2596
+ return _context8.a(2, !isNotCreated);
2597
+ }
2598
+ }, _callee8);
2599
+ }));
2600
+ return _isNoteCreated.apply(this, arguments);
2601
+ }
2582
2602
 
2583
2603
  var _format$1 = "hh-sol-artifact-1";
2584
2604
  var contractName$1 = "DarkSwapAssetManager";
@@ -4204,13 +4224,19 @@ var ChainId;
4204
4224
  ChainId[ChainId["HARDHAT_BASE"] = 31339] = "HARDHAT_BASE";
4205
4225
  ChainId[ChainId["MAINNET"] = 1] = "MAINNET";
4206
4226
  ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
4227
+ ChainId[ChainId["BASE_SEPOLIA"] = 84532] = "BASE_SEPOLIA";
4207
4228
  ChainId[ChainId["HORIZEN_TESTNET"] = 845320009] = "HORIZEN_TESTNET";
4208
4229
  ChainId[ChainId["ARBITRUM_ONE"] = 42161] = "ARBITRUM_ONE";
4209
4230
  ChainId[ChainId["BASE"] = 8453] = "BASE";
4210
4231
  })(ChainId || (ChainId = {}));
4211
4232
 
4212
- var _legacyTokenConfig;
4233
+ var _legacyTokenConfig, _confirmationsConfig;
4213
4234
  var legacyTokenConfig = (_legacyTokenConfig = {}, _legacyTokenConfig[ChainId.MAINNET] = ['0xdac17f958d2ee523a2206206994597c13d831ec7'], _legacyTokenConfig[ChainId.HARDHAT] = ['0xdac17f958d2ee523a2206206994597c13d831ec7'], _legacyTokenConfig);
4235
+ var confirmationsConfig = (_confirmationsConfig = {}, _confirmationsConfig[ChainId.MAINNET] = 3, _confirmationsConfig[ChainId.ARBITRUM_ONE] = 3, _confirmationsConfig[ChainId.BASE] = 3, _confirmationsConfig[ChainId.SEPOLIA] = 3, _confirmationsConfig[ChainId.HARDHAT] = 3, _confirmationsConfig);
4236
+ var DEFAULT_CONFIRMATIONS = 3;
4237
+ var getConfirmations = function getConfirmations(chainId) {
4238
+ return confirmationsConfig[chainId] || DEFAULT_CONFIRMATIONS;
4239
+ };
4214
4240
  var DEFAULT_FEE_RATIO = 300n;
4215
4241
  var GAS_LIMIT_MULTIPLIER = 120n;
4216
4242
  var GAS_LIMIT_PRECISION = 100n;
@@ -4722,8 +4748,8 @@ var contractConfig = (_contractConfig = {}, _contractConfig[ChainId.MAINNET] = {
4722
4748
  darkSwapFeeAssetManager: '0x0',
4723
4749
  synaraDarkSwapOnBridgeAssetManager: '0x0',
4724
4750
  synaraBridge: '0x0',
4725
- zkverifyRelayerUrls: [],
4726
- darkSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-subgraph/version/v0.0.1/api'
4751
+ synaraCanonicalTokenRegistry: '0x0',
4752
+ zkverifyRelayerUrls: []
4727
4753
  }, _contractConfig[ChainId.ARBITRUM_ONE] = {
4728
4754
  priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
4729
4755
  ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
@@ -4733,30 +4759,41 @@ var contractConfig = (_contractConfig = {}, _contractConfig[ChainId.MAINNET] = {
4733
4759
  darkSwapFeeAssetManager: '0x0',
4734
4760
  synaraDarkSwapOnBridgeAssetManager: '0x0',
4735
4761
  synaraBridge: '0x0',
4736
- zkverifyRelayerUrls: [],
4737
- darkSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-arb-subgraph/api'
4762
+ synaraCanonicalTokenRegistry: '0x0',
4763
+ zkverifyRelayerUrls: []
4738
4764
  }, _contractConfig[ChainId.BASE] = {
4739
4765
  priceOracle: '0xf224a25453D76A41c4427DD1C05369BC9f498444',
4740
4766
  ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
4741
4767
  nativeWrapper: '0x4200000000000000000000000000000000000006',
4742
- merkleTreeOperator: '0x0',
4743
- darkSwapAssetManager: '0x0',
4744
- darkSwapFeeAssetManager: '0x0',
4768
+ merkleTreeOperator: '0x918B4F76CAE5F67A3818D8eD3d0e11D9888684E9',
4769
+ darkSwapAssetManager: '0x6fbA1F1aAb8449b7ba576E41F4617d918391b7cF',
4770
+ darkSwapFeeAssetManager: '0xfde341e63EB2f25A32D353d58C2DAd7f91c8Bd57',
4745
4771
  synaraDarkSwapOnBridgeAssetManager: '0x0',
4746
4772
  synaraBridge: '0x0',
4747
- zkverifyRelayerUrls: [],
4748
- darkSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-base-subgraph/api'
4773
+ synaraCanonicalTokenRegistry: '0x0',
4774
+ zkverifyRelayerUrls: []
4749
4775
  }, _contractConfig[ChainId.SEPOLIA] = {
4750
4776
  priceOracle: '0x4Fe44a9aC8Ef059Be2dB97f9e3bcA32Ab698C2f2',
4751
4777
  ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
4752
4778
  nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
4753
- merkleTreeOperator: '0x0',
4754
- darkSwapAssetManager: '0x0',
4755
- darkSwapFeeAssetManager: '0x0',
4756
- synaraDarkSwapOnBridgeAssetManager: '0x0',
4757
- synaraBridge: '0x0',
4758
- zkverifyRelayerUrls: [],
4759
- darkSwapSubgraphUrl: ''
4779
+ merkleTreeOperator: '0xbeCd9FD715d131F8E897095Ef008BB4d9325B744',
4780
+ darkSwapAssetManager: '0x6E56b48361aD94Cb67EB5aA9182b2813bC76E6C0',
4781
+ darkSwapFeeAssetManager: '0x5C550CE1F4a02865F0f59d839D86807C75A6ddE0',
4782
+ synaraDarkSwapOnBridgeAssetManager: '0xEAC8292c1ef7b112Ccd5B3CB16E587E1799358db',
4783
+ synaraBridge: '0x2a9569b5df66B7E24B4FdC2B91d19E4C1C02F2D3',
4784
+ synaraCanonicalTokenRegistry: '0xD35264a934b5b7b8b3507b1d073e29EeBa4Dc754',
4785
+ zkverifyRelayerUrls: []
4786
+ }, _contractConfig[ChainId.BASE_SEPOLIA] = {
4787
+ priceOracle: '0x4Fe44a9aC8Ef059Be2dB97f9e3bcA32Ab698C2f2',
4788
+ ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
4789
+ nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
4790
+ merkleTreeOperator: '0xC486e448e068A888AF09c386337E3C3C4812569b',
4791
+ darkSwapAssetManager: '0xEd349302ff6C2527be9555Fa386061652EAC712D',
4792
+ darkSwapFeeAssetManager: '0xa62C0693296f64eb9BA29ff2E41E96749c18de0F',
4793
+ synaraDarkSwapOnBridgeAssetManager: '0x0aAd845E874F0007e328862A3C455CB2D6625660',
4794
+ synaraBridge: '0xda348F7dEAeE972D8a5B4D4D182EF0273aDd3E2c',
4795
+ synaraCanonicalTokenRegistry: '0x016C6334d644E0B21aD5c6e91083Dd2f22739eB6',
4796
+ zkverifyRelayerUrls: []
4760
4797
  }, _contractConfig[ChainId.HORIZEN_TESTNET] = {
4761
4798
  priceOracle: '0x54c375f28ce4B0c2B986D6256E4Bc75d242A8793',
4762
4799
  ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
@@ -4766,8 +4803,8 @@ var contractConfig = (_contractConfig = {}, _contractConfig[ChainId.MAINNET] = {
4766
4803
  darkSwapFeeAssetManager: '0x8CF86856Bd7dE95b4ba33DCae4cd5Ec02542Bf5b',
4767
4804
  synaraDarkSwapOnBridgeAssetManager: '0x0',
4768
4805
  synaraBridge: '0x0',
4769
- zkverifyRelayerUrls: [],
4770
- darkSwapSubgraphUrl: ''
4806
+ synaraCanonicalTokenRegistry: '0x0',
4807
+ zkverifyRelayerUrls: []
4771
4808
  }, _contractConfig[ChainId.HARDHAT] = {
4772
4809
  priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
4773
4810
  ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
@@ -4777,8 +4814,8 @@ var contractConfig = (_contractConfig = {}, _contractConfig[ChainId.MAINNET] = {
4777
4814
  darkSwapFeeAssetManager: '0xb9b0c96e4E7181926D2A7ed331C9C346dfa59b4D',
4778
4815
  synaraDarkSwapOnBridgeAssetManager: '0x0',
4779
4816
  synaraBridge: '0x0',
4780
- zkverifyRelayerUrls: [],
4781
- darkSwapSubgraphUrl: 'https://app.dev.portalgate.me:8080/subgraphs/name/singularity/'
4817
+ synaraCanonicalTokenRegistry: '0x0',
4818
+ zkverifyRelayerUrls: []
4782
4819
  }, _contractConfig[ChainId.HARDHAT_BASE] = {
4783
4820
  priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
4784
4821
  ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
@@ -4788,8 +4825,8 @@ var contractConfig = (_contractConfig = {}, _contractConfig[ChainId.MAINNET] = {
4788
4825
  darkSwapFeeAssetManager: '0xb9b0c96e4E7181926D2A7ed331C9C346dfa59b4D',
4789
4826
  synaraDarkSwapOnBridgeAssetManager: '0x0',
4790
4827
  synaraBridge: '0x0',
4791
- zkverifyRelayerUrls: [],
4792
- darkSwapSubgraphUrl: 'https://app.dev.portalgate.me:8080/subgraphs/name/singularity/'
4828
+ synaraCanonicalTokenRegistry: '0x0',
4829
+ zkverifyRelayerUrls: []
4793
4830
  }, _contractConfig);
4794
4831
 
4795
4832
  function refineGasLimit(estimatedGas) {
@@ -5020,7 +5057,7 @@ var DepositService = /*#__PURE__*/function (_BaseContractService) {
5020
5057
  case 3:
5021
5058
  tx = _context4.v;
5022
5059
  _context4.n = 4;
5023
- return tx.wait();
5060
+ return tx.wait(getConfirmations(this._darkSwap.chainId));
5024
5061
  case 4:
5025
5062
  return _context4.a(2);
5026
5063
  }
@@ -9358,9 +9395,9 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
9358
9395
  }
9359
9396
  _inheritsLoose(RetailCreateOrderService, _BaseContractService);
9360
9397
  var _proto = RetailCreateOrderService.prototype;
9361
- _proto.prepare = /*#__PURE__*/function () {
9362
- var _prepare = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(address, depositAsset, depositAmount, swapInAsset, swapInAmount, signature) {
9363
- var _yield$generateKeyPai, pubKey, privKey, feeRatio, orderNote, feeAmount, realSwapInAmount, swapInNote, context, swapMessage, _t, _t2;
9398
+ _proto.rebuildContextFromSwapMessage = /*#__PURE__*/function () {
9399
+ var _rebuildContextFromSwapMessage = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(swapMessage, signature) {
9400
+ var _yield$generateKeyPai, pubKey, context;
9364
9401
  return _regenerator().w(function (_context) {
9365
9402
  while (1) switch (_context.n) {
9366
9403
  case 0:
@@ -9369,12 +9406,46 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
9369
9406
  case 1:
9370
9407
  _yield$generateKeyPai = _context.v;
9371
9408
  pubKey = _yield$generateKeyPai[0];
9372
- privKey = _yield$generateKeyPai[1];
9409
+ if (validateOrderNoteWithPubKey(swapMessage.orderNote, pubKey)) {
9410
+ _context.n = 2;
9411
+ break;
9412
+ }
9413
+ throw new DarkSwapError('SwapMessage does not belong to this wallet');
9414
+ case 2:
9415
+ context = new RetailCreateOrderContext(signature);
9416
+ context.orderNote = swapMessage.orderNote;
9417
+ context.swapInNote = swapMessage.inNote;
9418
+ context.feeAmount = swapMessage.feeAmount;
9419
+ context.address = swapMessage.address;
9420
+ _context.n = 3;
9421
+ return this.generateProof(context);
9422
+ case 3:
9423
+ return _context.a(2, context);
9424
+ }
9425
+ }, _callee, this);
9426
+ }));
9427
+ function rebuildContextFromSwapMessage(_x, _x2) {
9428
+ return _rebuildContextFromSwapMessage.apply(this, arguments);
9429
+ }
9430
+ return rebuildContextFromSwapMessage;
9431
+ }();
9432
+ _proto.prepare = /*#__PURE__*/function () {
9433
+ var _prepare = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(address, depositAsset, depositAmount, swapInAsset, swapInAmount, signature) {
9434
+ var _yield$generateKeyPai2, pubKey, privKey, feeRatio, orderNote, feeAmount, realSwapInAmount, swapInNote, context, swapMessage, _t, _t2;
9435
+ return _regenerator().w(function (_context2) {
9436
+ while (1) switch (_context2.n) {
9437
+ case 0:
9438
+ _context2.n = 1;
9439
+ return generateKeyPair(signature);
9440
+ case 1:
9441
+ _yield$generateKeyPai2 = _context2.v;
9442
+ pubKey = _yield$generateKeyPai2[0];
9443
+ privKey = _yield$generateKeyPai2[1];
9373
9444
  _t = BigInt;
9374
- _context.n = 2;
9445
+ _context2.n = 2;
9375
9446
  return getFeeRatio(address, this._darkSwap);
9376
9447
  case 2:
9377
- _t2 = _context.v;
9448
+ _t2 = _context2.v;
9378
9449
  feeRatio = _t(_t2);
9379
9450
  orderNote = createOrderNoteExt(address, depositAsset, depositAmount, feeRatio, pubKey);
9380
9451
  feeAmount = calcFeeAmount(swapInAmount, feeRatio);
@@ -9385,36 +9456,36 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
9385
9456
  context.swapInNote = swapInNote;
9386
9457
  context.feeAmount = feeAmount;
9387
9458
  context.address = address;
9388
- _context.n = 3;
9459
+ _context2.n = 3;
9389
9460
  return generateRetailSwapMessage(address, orderNote, swapInNote, feeAmount, pubKey, privKey);
9390
9461
  case 3:
9391
- swapMessage = _context.v;
9462
+ swapMessage = _context2.v;
9392
9463
  context.swapMessage = swapMessage;
9393
- return _context.a(2, {
9464
+ return _context2.a(2, {
9394
9465
  context: context,
9395
9466
  swapMessage: swapMessage
9396
9467
  });
9397
9468
  }
9398
- }, _callee, this);
9469
+ }, _callee2, this);
9399
9470
  }));
9400
- function prepare(_x, _x2, _x3, _x4, _x5, _x6) {
9471
+ function prepare(_x3, _x4, _x5, _x6, _x7, _x8) {
9401
9472
  return _prepare.apply(this, arguments);
9402
9473
  }
9403
9474
  return prepare;
9404
9475
  }();
9405
9476
  _proto.generateProof = /*#__PURE__*/function () {
9406
- var _generateProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context) {
9477
+ var _generateProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(context) {
9407
9478
  var proof;
9408
- return _regenerator().w(function (_context2) {
9409
- while (1) switch (_context2.n) {
9479
+ return _regenerator().w(function (_context3) {
9480
+ while (1) switch (_context3.n) {
9410
9481
  case 0:
9411
9482
  if (!(!context || !context.orderNote || !context.swapInNote || !context.address || !context.feeAmount || !context.signature)) {
9412
- _context2.n = 1;
9483
+ _context3.n = 1;
9413
9484
  break;
9414
9485
  }
9415
9486
  throw new DarkSwapError('Invalid context');
9416
9487
  case 1:
9417
- _context2.n = 2;
9488
+ _context3.n = 2;
9418
9489
  return generateRetailCreateOrderProof({
9419
9490
  depositNote: context.orderNote,
9420
9491
  swapInNote: context.swapInNote,
@@ -9423,71 +9494,77 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
9423
9494
  feeAmount: context.feeAmount
9424
9495
  });
9425
9496
  case 2:
9426
- proof = _context2.v;
9497
+ proof = _context3.v;
9427
9498
  context.proof = proof;
9428
9499
  case 3:
9429
- return _context2.a(2);
9500
+ return _context3.a(2);
9430
9501
  }
9431
- }, _callee2);
9502
+ }, _callee3);
9432
9503
  }));
9433
- function generateProof(_x7) {
9504
+ function generateProof(_x9) {
9434
9505
  return _generateProof.apply(this, arguments);
9435
9506
  }
9436
9507
  return generateProof;
9437
9508
  }();
9438
9509
  _proto.allowance = /*#__PURE__*/function () {
9439
- var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(context) {
9510
+ var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
9440
9511
  var signer, asset, amount, allowanceContract, allowance, isLegacy, contract, tx;
9441
- return _regenerator().w(function (_context3) {
9442
- while (1) switch (_context3.n) {
9512
+ return _regenerator().w(function (_context4) {
9513
+ while (1) switch (_context4.n) {
9443
9514
  case 0:
9444
9515
  if (!(!context || !context.orderNote || !context.address || !context.signature || !context.proof)) {
9445
- _context3.n = 1;
9516
+ _context4.n = 1;
9446
9517
  break;
9447
9518
  }
9448
9519
  throw new DarkSwapError('Invalid context');
9449
9520
  case 1:
9521
+ if (!isNativeAsset(context.orderNote.asset)) {
9522
+ _context4.n = 2;
9523
+ break;
9524
+ }
9525
+ return _context4.a(2);
9526
+ case 2:
9450
9527
  signer = this._darkSwap.signer;
9451
9528
  asset = context.orderNote.asset;
9452
9529
  amount = context.orderNote.amount;
9453
9530
  allowanceContract = new ethers.Contract(asset, ERC20Abi.abi, this._darkSwap);
9454
- _context3.n = 2;
9531
+ _context4.n = 3;
9455
9532
  return allowanceContract.allowance(signer.getAddress(), this._darkSwap.contracts.darkSwapAssetManager);
9456
- case 2:
9457
- allowance = _context3.v;
9533
+ case 3:
9534
+ allowance = _context4.v;
9458
9535
  if (!(BigInt(allowance) < amount)) {
9459
- _context3.n = 4;
9536
+ _context4.n = 5;
9460
9537
  break;
9461
9538
  }
9462
9539
  isLegacy = legacyTokenConfig.hasOwnProperty(this._darkSwap.chainId) && legacyTokenConfig[this._darkSwap.chainId].includes(asset.toLowerCase());
9463
9540
  contract = new ethers.Contract(asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
9464
- _context3.n = 3;
9541
+ _context4.n = 4;
9465
9542
  return contract.approve(this._darkSwap.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
9466
- case 3:
9467
- tx = _context3.v;
9468
- _context3.n = 4;
9469
- return tx.wait();
9470
9543
  case 4:
9471
- return _context3.a(2);
9544
+ tx = _context4.v;
9545
+ _context4.n = 5;
9546
+ return tx.wait(getConfirmations(this._darkSwap.chainId));
9547
+ case 5:
9548
+ return _context4.a(2);
9472
9549
  }
9473
- }, _callee3, this);
9550
+ }, _callee4, this);
9474
9551
  }));
9475
- function allowance(_x8) {
9552
+ function allowance(_x0) {
9476
9553
  return _allowance.apply(this, arguments);
9477
9554
  }
9478
9555
  return allowance;
9479
9556
  }();
9480
9557
  _proto.execute = /*#__PURE__*/function () {
9481
- var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
9558
+ var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(context) {
9482
9559
  var contract, ethAmount, tx;
9483
- return _regenerator().w(function (_context4) {
9484
- while (1) switch (_context4.n) {
9560
+ return _regenerator().w(function (_context5) {
9561
+ while (1) switch (_context5.n) {
9485
9562
  case 0:
9486
- _context4.n = 1;
9563
+ _context5.n = 1;
9487
9564
  return this.generateProof(context);
9488
9565
  case 1:
9489
9566
  if (!(!context || !context.orderNote || !context.swapInNote || !context.proof)) {
9490
- _context4.n = 2;
9567
+ _context5.n = 2;
9491
9568
  break;
9492
9569
  }
9493
9570
  throw new DarkSwapError('Invalid context');
@@ -9495,30 +9572,30 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
9495
9572
  contract = new ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
9496
9573
  ethAmount = 0n;
9497
9574
  if (!isNativeAsset(context.orderNote.asset)) {
9498
- _context4.n = 3;
9575
+ _context5.n = 3;
9499
9576
  break;
9500
9577
  }
9501
9578
  ethAmount = context.orderNote.amount;
9502
- _context4.n = 4;
9579
+ _context5.n = 4;
9503
9580
  break;
9504
9581
  case 3:
9505
- _context4.n = 4;
9582
+ _context5.n = 4;
9506
9583
  return this.allowance(context);
9507
9584
  case 4:
9508
- _context4.n = 5;
9585
+ _context5.n = 5;
9509
9586
  return contract.retailDepositCreateOrder([hexlify32(context.orderNote.note), context.proof.depositFooter, context.orderNote.asset, bn_to_0xhex(context.orderNote.amount), hexlify32(context.swapInNote.note), context.proof.swapInNoteFooter], context.proof.proof, {
9510
9587
  value: bn_to_0xhex(ethAmount)
9511
9588
  });
9512
9589
  case 5:
9513
- tx = _context4.v;
9514
- _context4.n = 6;
9590
+ tx = _context5.v;
9591
+ _context5.n = 6;
9515
9592
  return tx.wait();
9516
9593
  case 6:
9517
- return _context4.a(2, tx.hash);
9594
+ return _context5.a(2, tx.hash);
9518
9595
  }
9519
- }, _callee4, this);
9596
+ }, _callee5, this);
9520
9597
  }));
9521
- function execute(_x9) {
9598
+ function execute(_x1) {
9522
9599
  return _execute.apply(this, arguments);
9523
9600
  }
9524
9601
  return execute;
@@ -9868,7 +9945,7 @@ function generateRetailSwapProof(_x) {
9868
9945
  }
9869
9946
  function _generateRetailSwapProof() {
9870
9947
  _generateRetailSwapProof = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(param) {
9871
- var aliceFeeAmount, bobFeeAmount, aliceOrderNoteNullifier, aliceInNoteFooter, bobOrderNoteNullifier, bobInNoteFooter, aliceAddressMod, bobAddressMod, inputs, proof;
9948
+ var aliceOrderNoteNullifier, aliceInNoteFooter, bobOrderNoteNullifier, bobInNoteFooter, aliceAddressMod, bobAddressMod, inputs, proof;
9872
9949
  return _regenerator().w(function (_context) {
9873
9950
  while (1) switch (_context.n) {
9874
9951
  case 0:
@@ -9884,14 +9961,12 @@ function _generateRetailSwapProof() {
9884
9961
  }
9885
9962
  throw new DarkSwapProofError("Invalid note amount");
9886
9963
  case 2:
9887
- if (!(param.aliceMessage.orderNote.amount != param.bobMessage.inNote.amount || param.bobMessage.orderNote.amount != param.aliceMessage.inNote.amount)) {
9964
+ if (!(param.aliceMessage.orderNote.amount != param.bobMessage.inNote.amount + param.bobMessage.feeAmount || param.bobMessage.orderNote.amount != param.aliceMessage.inNote.amount + param.aliceMessage.feeAmount)) {
9888
9965
  _context.n = 3;
9889
9966
  break;
9890
9967
  }
9891
9968
  throw new DarkSwapProofError("Invalid order amount");
9892
9969
  case 3:
9893
- aliceFeeAmount = param.aliceMessage.inNote.amount * param.aliceMessage.orderNote.feeRatio / FEE_RATIO_PRECISION;
9894
- bobFeeAmount = param.bobMessage.inNote.amount * param.bobMessage.orderNote.feeRatio / FEE_RATIO_PRECISION;
9895
9970
  aliceOrderNoteNullifier = calcNullifier(param.aliceMessage.orderNote.rho, param.aliceMessage.publicKey);
9896
9971
  aliceInNoteFooter = getNoteFooter(param.aliceMessage.inNote.rho, param.aliceMessage.publicKey);
9897
9972
  bobOrderNoteNullifier = calcNullifier(param.bobMessage.orderNote.rho, param.bobMessage.publicKey);
@@ -9911,10 +9986,10 @@ function _generateRetailSwapProof() {
9911
9986
  alice_out_note: bn_to_0xhex(param.aliceMessage.orderNote.note),
9912
9987
  alice_out_nullifier: bn_to_0xhex(aliceOrderNoteNullifier),
9913
9988
  alice_fee_ratio: bn_to_0xhex(param.aliceMessage.orderNote.feeRatio),
9914
- alice_fee_amount: bn_to_0xhex(aliceFeeAmount),
9989
+ alice_fee_amount: bn_to_0xhex(param.aliceMessage.feeAmount),
9915
9990
  alice_in_rho: bn_to_0xhex(param.aliceMessage.inNote.rho),
9916
9991
  alice_in_asset: bn_to_0xhex(encodeAddress(param.aliceMessage.inNote.asset)),
9917
- alice_in_amount: bn_to_0xhex(param.aliceMessage.inNote.amount),
9992
+ alice_in_amount: bn_to_0xhex(param.aliceMessage.inNote.amount + param.aliceMessage.feeAmount),
9918
9993
  alice_in_note: bn_to_0xhex(param.aliceMessage.inNote.note),
9919
9994
  alice_in_note_footer: bn_to_0xhex(aliceInNoteFooter),
9920
9995
  alice_pub_key: [param.aliceMessage.publicKey[0].toString(), param.aliceMessage.publicKey[1].toString()],
@@ -9928,7 +10003,7 @@ function _generateRetailSwapProof() {
9928
10003
  bob_out_rho: bn_to_0xhex(param.bobMessage.orderNote.rho),
9929
10004
  bob_out_nullifier: bn_to_0xhex(bobOrderNoteNullifier),
9930
10005
  bob_fee_ratio: bn_to_0xhex(param.bobMessage.orderNote.feeRatio),
9931
- bob_fee_amount: bn_to_0xhex(bobFeeAmount),
10006
+ bob_fee_amount: bn_to_0xhex(param.bobMessage.feeAmount),
9932
10007
  bob_in_note: bn_to_0xhex(param.bobMessage.inNote.note),
9933
10008
  bob_in_rho: bn_to_0xhex(param.bobMessage.inNote.rho),
9934
10009
  bob_in_note_footer: bn_to_0xhex(bobInNoteFooter),
@@ -11109,144 +11184,1614 @@ var SynaraDarkSwapOnBridgeAssetManagerAbi = {
11109
11184
  deployedLinkReferences: deployedLinkReferences$5
11110
11185
  };
11111
11186
 
11112
- var _DOMAIN_PREFIX = "0x191253796e6172614272696467654465706f7369740a";
11113
- var BridgeCreateOrderContext = /*#__PURE__*/function (_BaseContext) {
11114
- function BridgeCreateOrderContext(signature) {
11115
- return _BaseContext.call(this, signature) || this;
11116
- }
11117
- _inheritsLoose(BridgeCreateOrderContext, _BaseContext);
11118
- return _createClass(BridgeCreateOrderContext, [{
11119
- key: "orderNote",
11120
- get: function get() {
11121
- return this._orderNote;
11122
- },
11123
- set: function set(orderNote) {
11124
- this._orderNote = orderNote;
11125
- }
11126
- }, {
11127
- key: "swapInNote",
11128
- get: function get() {
11129
- return this._swapInNote;
11130
- },
11131
- set: function set(swapInNote) {
11132
- this._swapInNote = swapInNote;
11133
- }
11134
- }, {
11135
- key: "feeAmount",
11136
- get: function get() {
11137
- return this._feeAmount;
11138
- },
11139
- set: function set(feeAmount) {
11140
- this._feeAmount = feeAmount;
11141
- }
11142
- }, {
11143
- key: "proof",
11144
- get: function get() {
11145
- return this._proof;
11146
- },
11147
- set: function set(proof) {
11148
- this._proof = proof;
11149
- }
11150
- }, {
11151
- key: "swapMessage",
11152
- get: function get() {
11153
- return this._swapMessage;
11154
- },
11155
- set: function set(swapMessage) {
11156
- this._swapMessage = swapMessage;
11157
- }
11158
- }, {
11159
- key: "sourceChainId",
11160
- get: function get() {
11161
- return this._sourceChainId;
11162
- },
11163
- set: function set(sourceChainId) {
11164
- this._sourceChainId = sourceChainId;
11165
- }
11166
- }, {
11167
- key: "destChainId",
11168
- get: function get() {
11169
- return this._destChainId;
11170
- },
11171
- set: function set(destChainId) {
11172
- this._destChainId = destChainId;
11173
- }
11174
- }, {
11175
- key: "sourceAsset",
11176
- get: function get() {
11177
- return this._sourceAsset;
11178
- },
11179
- set: function set(sourceAsset) {
11180
- this._sourceAsset = sourceAsset;
11181
- }
11182
- }, {
11183
- key: "sourceAmount",
11184
- get: function get() {
11185
- return this._sourceAmount;
11186
- },
11187
- set: function set(sourceAmount) {
11188
- this._sourceAmount = sourceAmount;
11189
- }
11190
- }, {
11191
- key: "bridgeFeeAmount",
11192
- get: function get() {
11193
- return this._bridgeFeeAmount;
11194
- },
11195
- set: function set(bridgeFeeAmount) {
11196
- this._bridgeFeeAmount = bridgeFeeAmount;
11197
- }
11198
- }, {
11199
- key: "depositId",
11200
- get: function get() {
11201
- return this._depositId;
11202
- },
11203
- set: function set(depositId) {
11204
- this._depositId = depositId;
11205
- }
11206
- }, {
11207
- key: "attestationDetails",
11208
- get: function get() {
11209
- return this._attestationDetails;
11210
- },
11211
- set: function set(attestationDetails) {
11212
- this._attestationDetails = attestationDetails;
11213
- }
11214
- }, {
11215
- key: "relayer",
11216
- get: function get() {
11217
- return this._relayer;
11218
- },
11219
- set: function set(relayer) {
11220
- this._relayer = relayer;
11221
- }
11222
- }, {
11223
- key: "jobId",
11224
- get: function get() {
11225
- return this._jobId;
11226
- },
11227
- set: function set(jobId) {
11228
- this._jobId = jobId;
11229
- }
11230
- }, {
11231
- key: "canonicalId",
11232
- get: function get() {
11233
- return this._canonicalId;
11234
- },
11235
- set: function set(canonicalId) {
11236
- this._canonicalId = canonicalId;
11237
- }
11238
- }, {
11239
- key: "callDataHash",
11240
- get: function get() {
11241
- return this._callDataHash;
11242
- },
11243
- set: function set(callDataHash) {
11244
- this._callDataHash = callDataHash;
11245
- }
11246
- }, {
11247
- key: "nonce",
11248
- get: function get() {
11249
- return this._nonce;
11187
+ var CanonicalTokenRegistryAbi = [
11188
+ {
11189
+ inputs: [
11190
+ ],
11191
+ stateMutability: "nonpayable",
11192
+ type: "constructor"
11193
+ },
11194
+ {
11195
+ inputs: [
11196
+ ],
11197
+ name: "AccessControlBadConfirmation",
11198
+ type: "error"
11199
+ },
11200
+ {
11201
+ inputs: [
11202
+ {
11203
+ internalType: "address",
11204
+ name: "account",
11205
+ type: "address"
11206
+ },
11207
+ {
11208
+ internalType: "bytes32",
11209
+ name: "neededRole",
11210
+ type: "bytes32"
11211
+ }
11212
+ ],
11213
+ name: "AccessControlUnauthorizedAccount",
11214
+ type: "error"
11215
+ },
11216
+ {
11217
+ inputs: [
11218
+ ],
11219
+ name: "AlreadyRegistered",
11220
+ type: "error"
11221
+ },
11222
+ {
11223
+ inputs: [
11224
+ ],
11225
+ name: "EnforcedPause",
11226
+ type: "error"
11227
+ },
11228
+ {
11229
+ inputs: [
11230
+ ],
11231
+ name: "ExpectedPause",
11232
+ type: "error"
11233
+ },
11234
+ {
11235
+ inputs: [
11236
+ ],
11237
+ name: "NotRegistered",
11238
+ type: "error"
11239
+ },
11240
+ {
11241
+ inputs: [
11242
+ ],
11243
+ name: "TokenAlreadyMapped",
11244
+ type: "error"
11245
+ },
11246
+ {
11247
+ inputs: [
11248
+ ],
11249
+ name: "ZeroAddress",
11250
+ type: "error"
11251
+ },
11252
+ {
11253
+ inputs: [
11254
+ ],
11255
+ name: "ZeroCanonicalId",
11256
+ type: "error"
11257
+ },
11258
+ {
11259
+ anonymous: false,
11260
+ inputs: [
11261
+ {
11262
+ indexed: false,
11263
+ internalType: "address",
11264
+ name: "account",
11265
+ type: "address"
11266
+ }
11267
+ ],
11268
+ name: "Paused",
11269
+ type: "event"
11270
+ },
11271
+ {
11272
+ anonymous: false,
11273
+ inputs: [
11274
+ {
11275
+ indexed: true,
11276
+ internalType: "bytes32",
11277
+ name: "role",
11278
+ type: "bytes32"
11279
+ },
11280
+ {
11281
+ indexed: true,
11282
+ internalType: "bytes32",
11283
+ name: "previousAdminRole",
11284
+ type: "bytes32"
11285
+ },
11286
+ {
11287
+ indexed: true,
11288
+ internalType: "bytes32",
11289
+ name: "newAdminRole",
11290
+ type: "bytes32"
11291
+ }
11292
+ ],
11293
+ name: "RoleAdminChanged",
11294
+ type: "event"
11295
+ },
11296
+ {
11297
+ anonymous: false,
11298
+ inputs: [
11299
+ {
11300
+ indexed: true,
11301
+ internalType: "bytes32",
11302
+ name: "role",
11303
+ type: "bytes32"
11304
+ },
11305
+ {
11306
+ indexed: true,
11307
+ internalType: "address",
11308
+ name: "account",
11309
+ type: "address"
11310
+ },
11311
+ {
11312
+ indexed: true,
11313
+ internalType: "address",
11314
+ name: "sender",
11315
+ type: "address"
11316
+ }
11317
+ ],
11318
+ name: "RoleGranted",
11319
+ type: "event"
11320
+ },
11321
+ {
11322
+ anonymous: false,
11323
+ inputs: [
11324
+ {
11325
+ indexed: true,
11326
+ internalType: "bytes32",
11327
+ name: "role",
11328
+ type: "bytes32"
11329
+ },
11330
+ {
11331
+ indexed: true,
11332
+ internalType: "address",
11333
+ name: "account",
11334
+ type: "address"
11335
+ },
11336
+ {
11337
+ indexed: true,
11338
+ internalType: "address",
11339
+ name: "sender",
11340
+ type: "address"
11341
+ }
11342
+ ],
11343
+ name: "RoleRevoked",
11344
+ type: "event"
11345
+ },
11346
+ {
11347
+ anonymous: false,
11348
+ inputs: [
11349
+ {
11350
+ indexed: true,
11351
+ internalType: "bytes32",
11352
+ name: "canonicalId",
11353
+ type: "bytes32"
11354
+ },
11355
+ {
11356
+ indexed: true,
11357
+ internalType: "address",
11358
+ name: "token",
11359
+ type: "address"
11360
+ }
11361
+ ],
11362
+ name: "TokenMappingRemoved",
11363
+ type: "event"
11364
+ },
11365
+ {
11366
+ anonymous: false,
11367
+ inputs: [
11368
+ {
11369
+ indexed: true,
11370
+ internalType: "bytes32",
11371
+ name: "canonicalId",
11372
+ type: "bytes32"
11373
+ },
11374
+ {
11375
+ indexed: true,
11376
+ internalType: "address",
11377
+ name: "token",
11378
+ type: "address"
11379
+ }
11380
+ ],
11381
+ name: "TokenMappingSet",
11382
+ type: "event"
11383
+ },
11384
+ {
11385
+ anonymous: false,
11386
+ inputs: [
11387
+ {
11388
+ indexed: false,
11389
+ internalType: "address",
11390
+ name: "account",
11391
+ type: "address"
11392
+ }
11393
+ ],
11394
+ name: "Unpaused",
11395
+ type: "event"
11396
+ },
11397
+ {
11398
+ inputs: [
11399
+ ],
11400
+ name: "DEFAULT_ADMIN_ROLE",
11401
+ outputs: [
11402
+ {
11403
+ internalType: "bytes32",
11404
+ name: "",
11405
+ type: "bytes32"
11406
+ }
11407
+ ],
11408
+ stateMutability: "view",
11409
+ type: "function"
11410
+ },
11411
+ {
11412
+ inputs: [
11413
+ ],
11414
+ name: "GUARDIAN_ROLE",
11415
+ outputs: [
11416
+ {
11417
+ internalType: "bytes32",
11418
+ name: "",
11419
+ type: "bytes32"
11420
+ }
11421
+ ],
11422
+ stateMutability: "view",
11423
+ type: "function"
11424
+ },
11425
+ {
11426
+ inputs: [
11427
+ ],
11428
+ name: "OPERATOR_ROLE",
11429
+ outputs: [
11430
+ {
11431
+ internalType: "bytes32",
11432
+ name: "",
11433
+ type: "bytes32"
11434
+ }
11435
+ ],
11436
+ stateMutability: "view",
11437
+ type: "function"
11438
+ },
11439
+ {
11440
+ inputs: [
11441
+ {
11442
+ internalType: "address",
11443
+ name: "token",
11444
+ type: "address"
11445
+ }
11446
+ ],
11447
+ name: "getCanonicalId",
11448
+ outputs: [
11449
+ {
11450
+ internalType: "bytes32",
11451
+ name: "",
11452
+ type: "bytes32"
11453
+ }
11454
+ ],
11455
+ stateMutability: "view",
11456
+ type: "function"
11457
+ },
11458
+ {
11459
+ inputs: [
11460
+ {
11461
+ internalType: "bytes32",
11462
+ name: "role",
11463
+ type: "bytes32"
11464
+ }
11465
+ ],
11466
+ name: "getRoleAdmin",
11467
+ outputs: [
11468
+ {
11469
+ internalType: "bytes32",
11470
+ name: "",
11471
+ type: "bytes32"
11472
+ }
11473
+ ],
11474
+ stateMutability: "view",
11475
+ type: "function"
11476
+ },
11477
+ {
11478
+ inputs: [
11479
+ {
11480
+ internalType: "bytes32",
11481
+ name: "canonicalId",
11482
+ type: "bytes32"
11483
+ }
11484
+ ],
11485
+ name: "getToken",
11486
+ outputs: [
11487
+ {
11488
+ internalType: "address",
11489
+ name: "",
11490
+ type: "address"
11491
+ }
11492
+ ],
11493
+ stateMutability: "view",
11494
+ type: "function"
11495
+ },
11496
+ {
11497
+ inputs: [
11498
+ {
11499
+ internalType: "bytes32",
11500
+ name: "role",
11501
+ type: "bytes32"
11502
+ },
11503
+ {
11504
+ internalType: "address",
11505
+ name: "account",
11506
+ type: "address"
11507
+ }
11508
+ ],
11509
+ name: "grantRole",
11510
+ outputs: [
11511
+ ],
11512
+ stateMutability: "nonpayable",
11513
+ type: "function"
11514
+ },
11515
+ {
11516
+ inputs: [
11517
+ {
11518
+ internalType: "bytes32",
11519
+ name: "role",
11520
+ type: "bytes32"
11521
+ },
11522
+ {
11523
+ internalType: "address",
11524
+ name: "account",
11525
+ type: "address"
11526
+ }
11527
+ ],
11528
+ name: "hasRole",
11529
+ outputs: [
11530
+ {
11531
+ internalType: "bool",
11532
+ name: "",
11533
+ type: "bool"
11534
+ }
11535
+ ],
11536
+ stateMutability: "view",
11537
+ type: "function"
11538
+ },
11539
+ {
11540
+ inputs: [
11541
+ {
11542
+ internalType: "bytes32",
11543
+ name: "canonicalId",
11544
+ type: "bytes32"
11545
+ }
11546
+ ],
11547
+ name: "isRegistered",
11548
+ outputs: [
11549
+ {
11550
+ internalType: "bool",
11551
+ name: "",
11552
+ type: "bool"
11553
+ }
11554
+ ],
11555
+ stateMutability: "view",
11556
+ type: "function"
11557
+ },
11558
+ {
11559
+ inputs: [
11560
+ ],
11561
+ name: "pause",
11562
+ outputs: [
11563
+ ],
11564
+ stateMutability: "nonpayable",
11565
+ type: "function"
11566
+ },
11567
+ {
11568
+ inputs: [
11569
+ ],
11570
+ name: "paused",
11571
+ outputs: [
11572
+ {
11573
+ internalType: "bool",
11574
+ name: "",
11575
+ type: "bool"
11576
+ }
11577
+ ],
11578
+ stateMutability: "view",
11579
+ type: "function"
11580
+ },
11581
+ {
11582
+ inputs: [
11583
+ {
11584
+ internalType: "bytes32",
11585
+ name: "canonicalId",
11586
+ type: "bytes32"
11587
+ }
11588
+ ],
11589
+ name: "removeTokenMapping",
11590
+ outputs: [
11591
+ ],
11592
+ stateMutability: "nonpayable",
11593
+ type: "function"
11594
+ },
11595
+ {
11596
+ inputs: [
11597
+ {
11598
+ internalType: "bytes32",
11599
+ name: "role",
11600
+ type: "bytes32"
11601
+ },
11602
+ {
11603
+ internalType: "address",
11604
+ name: "callerConfirmation",
11605
+ type: "address"
11606
+ }
11607
+ ],
11608
+ name: "renounceRole",
11609
+ outputs: [
11610
+ ],
11611
+ stateMutability: "nonpayable",
11612
+ type: "function"
11613
+ },
11614
+ {
11615
+ inputs: [
11616
+ {
11617
+ internalType: "bytes32",
11618
+ name: "role",
11619
+ type: "bytes32"
11620
+ },
11621
+ {
11622
+ internalType: "address",
11623
+ name: "account",
11624
+ type: "address"
11625
+ }
11626
+ ],
11627
+ name: "revokeRole",
11628
+ outputs: [
11629
+ ],
11630
+ stateMutability: "nonpayable",
11631
+ type: "function"
11632
+ },
11633
+ {
11634
+ inputs: [
11635
+ {
11636
+ internalType: "bytes32",
11637
+ name: "canonicalId",
11638
+ type: "bytes32"
11639
+ },
11640
+ {
11641
+ internalType: "address",
11642
+ name: "token",
11643
+ type: "address"
11644
+ }
11645
+ ],
11646
+ name: "setTokenMapping",
11647
+ outputs: [
11648
+ ],
11649
+ stateMutability: "nonpayable",
11650
+ type: "function"
11651
+ },
11652
+ {
11653
+ inputs: [
11654
+ {
11655
+ internalType: "bytes4",
11656
+ name: "interfaceId",
11657
+ type: "bytes4"
11658
+ }
11659
+ ],
11660
+ name: "supportsInterface",
11661
+ outputs: [
11662
+ {
11663
+ internalType: "bool",
11664
+ name: "",
11665
+ type: "bool"
11666
+ }
11667
+ ],
11668
+ stateMutability: "view",
11669
+ type: "function"
11670
+ },
11671
+ {
11672
+ inputs: [
11673
+ ],
11674
+ name: "unpause",
11675
+ outputs: [
11676
+ ],
11677
+ stateMutability: "nonpayable",
11678
+ type: "function"
11679
+ }
11680
+ ];
11681
+
11682
+ var _format$6 = "hh-sol-artifact-1";
11683
+ var contractName$6 = "Bridge";
11684
+ var sourceName$6 = "src/Bridge.sol";
11685
+ var abi$h = [
11686
+ {
11687
+ inputs: [
11688
+ {
11689
+ internalType: "address",
11690
+ name: "_erc20Pool",
11691
+ type: "address"
11692
+ },
11693
+ {
11694
+ internalType: "address",
11695
+ name: "_nativePool",
11696
+ type: "address"
11697
+ },
11698
+ {
11699
+ internalType: "address",
11700
+ name: "feeManager",
11701
+ type: "address"
11702
+ },
11703
+ {
11704
+ internalType: "address",
11705
+ name: "verifierHub",
11706
+ type: "address"
11707
+ },
11708
+ {
11709
+ internalType: "address",
11710
+ name: "initialOwner",
11711
+ type: "address"
11712
+ }
11713
+ ],
11714
+ stateMutability: "nonpayable",
11715
+ type: "constructor"
11716
+ },
11717
+ {
11718
+ inputs: [
11719
+ ],
11720
+ name: "AmountZero",
11721
+ type: "error"
11722
+ },
11723
+ {
11724
+ inputs: [
11725
+ ],
11726
+ name: "CallDataHashMismatch",
11727
+ type: "error"
11728
+ },
11729
+ {
11730
+ inputs: [
11731
+ ],
11732
+ name: "CallerNotRegistered",
11733
+ type: "error"
11734
+ },
11735
+ {
11736
+ inputs: [
11737
+ ],
11738
+ name: "DepositExists",
11739
+ type: "error"
11740
+ },
11741
+ {
11742
+ inputs: [
11743
+ ],
11744
+ name: "DepositUsed",
11745
+ type: "error"
11746
+ },
11747
+ {
11748
+ inputs: [
11749
+ ],
11750
+ name: "NonceTooLow",
11751
+ type: "error"
11752
+ },
11753
+ {
11754
+ inputs: [
11755
+ {
11756
+ internalType: "address",
11757
+ name: "owner",
11758
+ type: "address"
11759
+ }
11760
+ ],
11761
+ name: "OwnableInvalidOwner",
11762
+ type: "error"
11763
+ },
11764
+ {
11765
+ inputs: [
11766
+ {
11767
+ internalType: "address",
11768
+ name: "account",
11769
+ type: "address"
11770
+ }
11771
+ ],
11772
+ name: "OwnableUnauthorizedAccount",
11773
+ type: "error"
11774
+ },
11775
+ {
11776
+ inputs: [
11777
+ ],
11778
+ name: "ReentrancyGuardReentrantCall",
11779
+ type: "error"
11780
+ },
11781
+ {
11782
+ inputs: [
11783
+ {
11784
+ internalType: "address",
11785
+ name: "token",
11786
+ type: "address"
11787
+ }
11788
+ ],
11789
+ name: "SafeERC20FailedOperation",
11790
+ type: "error"
11791
+ },
11792
+ {
11793
+ inputs: [
11794
+ ],
11795
+ name: "ZeroAddress",
11796
+ type: "error"
11797
+ },
11798
+ {
11799
+ anonymous: false,
11800
+ inputs: [
11801
+ {
11802
+ indexed: true,
11803
+ internalType: "bytes32",
11804
+ name: "depositCommitment",
11805
+ type: "bytes32"
11806
+ },
11807
+ {
11808
+ indexed: true,
11809
+ internalType: "bytes32",
11810
+ name: "canonicalTokenId",
11811
+ type: "bytes32"
11812
+ },
11813
+ {
11814
+ indexed: true,
11815
+ internalType: "address",
11816
+ name: "from",
11817
+ type: "address"
11818
+ },
11819
+ {
11820
+ indexed: false,
11821
+ internalType: "address",
11822
+ name: "owner",
11823
+ type: "address"
11824
+ },
11825
+ {
11826
+ indexed: false,
11827
+ internalType: "uint256",
11828
+ name: "amount",
11829
+ type: "uint256"
11830
+ },
11831
+ {
11832
+ indexed: false,
11833
+ internalType: "uint256",
11834
+ name: "destinationChain",
11835
+ type: "uint256"
11836
+ },
11837
+ {
11838
+ indexed: false,
11839
+ internalType: "uint256",
11840
+ name: "nonce",
11841
+ type: "uint256"
11842
+ },
11843
+ {
11844
+ indexed: false,
11845
+ internalType: "uint256",
11846
+ name: "sourceChain",
11847
+ type: "uint256"
11848
+ },
11849
+ {
11850
+ indexed: false,
11851
+ internalType: "address",
11852
+ name: "destContract",
11853
+ type: "address"
11854
+ },
11855
+ {
11856
+ indexed: false,
11857
+ internalType: "bytes",
11858
+ name: "callData",
11859
+ type: "bytes"
11860
+ }
11861
+ ],
11862
+ name: "Deposited",
11863
+ type: "event"
11864
+ },
11865
+ {
11866
+ anonymous: false,
11867
+ inputs: [
11868
+ {
11869
+ indexed: true,
11870
+ internalType: "address",
11871
+ name: "previousOwner",
11872
+ type: "address"
11873
+ },
11874
+ {
11875
+ indexed: true,
11876
+ internalType: "address",
11877
+ name: "newOwner",
11878
+ type: "address"
11879
+ }
11880
+ ],
11881
+ name: "OwnershipTransferred",
11882
+ type: "event"
11883
+ },
11884
+ {
11885
+ anonymous: false,
11886
+ inputs: [
11887
+ {
11888
+ indexed: true,
11889
+ internalType: "bytes32",
11890
+ name: "depositCommitment",
11891
+ type: "bytes32"
11892
+ },
11893
+ {
11894
+ indexed: true,
11895
+ internalType: "bytes32",
11896
+ name: "canonicalTokenId",
11897
+ type: "bytes32"
11898
+ },
11899
+ {
11900
+ indexed: true,
11901
+ internalType: "address",
11902
+ name: "to",
11903
+ type: "address"
11904
+ },
11905
+ {
11906
+ indexed: false,
11907
+ internalType: "uint256",
11908
+ name: "amount",
11909
+ type: "uint256"
11910
+ },
11911
+ {
11912
+ indexed: false,
11913
+ internalType: "bytes",
11914
+ name: "callData",
11915
+ type: "bytes"
11916
+ }
11917
+ ],
11918
+ name: "Withdrawal",
11919
+ type: "event"
11920
+ },
11921
+ {
11922
+ inputs: [
11923
+ ],
11924
+ name: "SYNARA_BRIDGE",
11925
+ outputs: [
11926
+ {
11927
+ internalType: "uint256",
11928
+ name: "",
11929
+ type: "uint256"
11930
+ }
11931
+ ],
11932
+ stateMutability: "view",
11933
+ type: "function"
11934
+ },
11935
+ {
11936
+ inputs: [
11937
+ {
11938
+ internalType: "bytes32",
11939
+ name: "canonicalId",
11940
+ type: "bytes32"
11941
+ },
11942
+ {
11943
+ internalType: "uint256",
11944
+ name: "amount",
11945
+ type: "uint256"
11946
+ },
11947
+ {
11948
+ internalType: "uint256",
11949
+ name: "destinationChainId",
11950
+ type: "uint256"
11951
+ },
11952
+ {
11953
+ internalType: "uint256",
11954
+ name: "nonce",
11955
+ type: "uint256"
11956
+ }
11957
+ ],
11958
+ name: "depositERC20",
11959
+ outputs: [
11960
+ ],
11961
+ stateMutability: "nonpayable",
11962
+ type: "function"
11963
+ },
11964
+ {
11965
+ inputs: [
11966
+ {
11967
+ internalType: "bytes32",
11968
+ name: "canonicalId",
11969
+ type: "bytes32"
11970
+ },
11971
+ {
11972
+ internalType: "uint256",
11973
+ name: "amount",
11974
+ type: "uint256"
11975
+ },
11976
+ {
11977
+ internalType: "uint256",
11978
+ name: "destinationChainId",
11979
+ type: "uint256"
11980
+ },
11981
+ {
11982
+ internalType: "uint256",
11983
+ name: "nonce",
11984
+ type: "uint256"
11985
+ },
11986
+ {
11987
+ components: [
11988
+ {
11989
+ internalType: "address",
11990
+ name: "target",
11991
+ type: "address"
11992
+ },
11993
+ {
11994
+ internalType: "bytes",
11995
+ name: "data",
11996
+ type: "bytes"
11997
+ }
11998
+ ],
11999
+ internalType: "struct Bridge.CrossChainCall",
12000
+ name: "call",
12001
+ type: "tuple"
12002
+ }
12003
+ ],
12004
+ name: "depositERC20WithCallData",
12005
+ outputs: [
12006
+ ],
12007
+ stateMutability: "nonpayable",
12008
+ type: "function"
12009
+ },
12010
+ {
12011
+ inputs: [
12012
+ {
12013
+ internalType: "bytes32",
12014
+ name: "canonicalId",
12015
+ type: "bytes32"
12016
+ },
12017
+ {
12018
+ internalType: "uint256",
12019
+ name: "destinationChainId",
12020
+ type: "uint256"
12021
+ },
12022
+ {
12023
+ internalType: "uint256",
12024
+ name: "nonce",
12025
+ type: "uint256"
12026
+ }
12027
+ ],
12028
+ name: "depositNative",
12029
+ outputs: [
12030
+ ],
12031
+ stateMutability: "payable",
12032
+ type: "function"
12033
+ },
12034
+ {
12035
+ inputs: [
12036
+ {
12037
+ internalType: "bytes32",
12038
+ name: "canonicalId",
12039
+ type: "bytes32"
12040
+ },
12041
+ {
12042
+ internalType: "uint256",
12043
+ name: "destinationChainId",
12044
+ type: "uint256"
12045
+ },
12046
+ {
12047
+ internalType: "uint256",
12048
+ name: "nonce",
12049
+ type: "uint256"
12050
+ },
12051
+ {
12052
+ components: [
12053
+ {
12054
+ internalType: "address",
12055
+ name: "target",
12056
+ type: "address"
12057
+ },
12058
+ {
12059
+ internalType: "bytes",
12060
+ name: "data",
12061
+ type: "bytes"
12062
+ }
12063
+ ],
12064
+ internalType: "struct Bridge.CrossChainCall",
12065
+ name: "call",
12066
+ type: "tuple"
12067
+ }
12068
+ ],
12069
+ name: "depositNativeWithCallData",
12070
+ outputs: [
12071
+ ],
12072
+ stateMutability: "payable",
12073
+ type: "function"
12074
+ },
12075
+ {
12076
+ inputs: [
12077
+ ],
12078
+ name: "erc20Pool",
12079
+ outputs: [
12080
+ {
12081
+ internalType: "address",
12082
+ name: "",
12083
+ type: "address"
12084
+ }
12085
+ ],
12086
+ stateMutability: "view",
12087
+ type: "function"
12088
+ },
12089
+ {
12090
+ inputs: [
12091
+ {
12092
+ internalType: "bytes32",
12093
+ name: "canonicalId",
12094
+ type: "bytes32"
12095
+ },
12096
+ {
12097
+ internalType: "address",
12098
+ name: "wallet",
12099
+ type: "address"
12100
+ },
12101
+ {
12102
+ internalType: "uint256",
12103
+ name: "amount",
12104
+ type: "uint256"
12105
+ }
12106
+ ],
12107
+ name: "getBridgeFee",
12108
+ outputs: [
12109
+ {
12110
+ internalType: "uint256",
12111
+ name: "",
12112
+ type: "uint256"
12113
+ }
12114
+ ],
12115
+ stateMutability: "view",
12116
+ type: "function"
12117
+ },
12118
+ {
12119
+ inputs: [
12120
+ ],
12121
+ name: "nativePool",
12122
+ outputs: [
12123
+ {
12124
+ internalType: "address",
12125
+ name: "",
12126
+ type: "address"
12127
+ }
12128
+ ],
12129
+ stateMutability: "view",
12130
+ type: "function"
12131
+ },
12132
+ {
12133
+ inputs: [
12134
+ ],
12135
+ name: "owner",
12136
+ outputs: [
12137
+ {
12138
+ internalType: "address",
12139
+ name: "",
12140
+ type: "address"
12141
+ }
12142
+ ],
12143
+ stateMutability: "view",
12144
+ type: "function"
12145
+ },
12146
+ {
12147
+ inputs: [
12148
+ {
12149
+ internalType: "address",
12150
+ name: "caller",
12151
+ type: "address"
12152
+ },
12153
+ {
12154
+ internalType: "bool",
12155
+ name: "registered",
12156
+ type: "bool"
12157
+ }
12158
+ ],
12159
+ name: "registerCaller",
12160
+ outputs: [
12161
+ ],
12162
+ stateMutability: "nonpayable",
12163
+ type: "function"
12164
+ },
12165
+ {
12166
+ inputs: [
12167
+ {
12168
+ internalType: "address",
12169
+ name: "relayer",
12170
+ type: "address"
12171
+ },
12172
+ {
12173
+ internalType: "bool",
12174
+ name: "registered",
12175
+ type: "bool"
12176
+ }
12177
+ ],
12178
+ name: "registerRelayer",
12179
+ outputs: [
12180
+ ],
12181
+ stateMutability: "nonpayable",
12182
+ type: "function"
12183
+ },
12184
+ {
12185
+ inputs: [
12186
+ ],
12187
+ name: "renounceOwnership",
12188
+ outputs: [
12189
+ ],
12190
+ stateMutability: "nonpayable",
12191
+ type: "function"
12192
+ },
12193
+ {
12194
+ inputs: [
12195
+ {
12196
+ internalType: "address",
12197
+ name: "newOwner",
12198
+ type: "address"
12199
+ }
12200
+ ],
12201
+ name: "transferOwnership",
12202
+ outputs: [
12203
+ ],
12204
+ stateMutability: "nonpayable",
12205
+ type: "function"
12206
+ },
12207
+ {
12208
+ inputs: [
12209
+ {
12210
+ components: [
12211
+ {
12212
+ internalType: "bytes32",
12213
+ name: "canonicalId",
12214
+ type: "bytes32"
12215
+ },
12216
+ {
12217
+ internalType: "uint256",
12218
+ name: "amount",
12219
+ type: "uint256"
12220
+ },
12221
+ {
12222
+ internalType: "address",
12223
+ name: "to",
12224
+ type: "address"
12225
+ },
12226
+ {
12227
+ internalType: "bytes",
12228
+ name: "callData",
12229
+ type: "bytes"
12230
+ },
12231
+ {
12232
+ internalType: "bytes32",
12233
+ name: "stateRootHigh16",
12234
+ type: "bytes32"
12235
+ },
12236
+ {
12237
+ internalType: "bytes32",
12238
+ name: "stateRootLow16",
12239
+ type: "bytes32"
12240
+ },
12241
+ {
12242
+ internalType: "bytes32",
12243
+ name: "depositCommitmentHigh16",
12244
+ type: "bytes32"
12245
+ },
12246
+ {
12247
+ internalType: "bytes32",
12248
+ name: "depositCommitmentLow16",
12249
+ type: "bytes32"
12250
+ },
12251
+ {
12252
+ internalType: "address",
12253
+ name: "from",
12254
+ type: "address"
12255
+ },
12256
+ {
12257
+ internalType: "address",
12258
+ name: "owner",
12259
+ type: "address"
12260
+ },
12261
+ {
12262
+ internalType: "uint256",
12263
+ name: "destinationChainId",
12264
+ type: "uint256"
12265
+ },
12266
+ {
12267
+ internalType: "bytes32",
12268
+ name: "calldataHashHigh16",
12269
+ type: "bytes32"
12270
+ },
12271
+ {
12272
+ internalType: "bytes32",
12273
+ name: "calldataHashLow16",
12274
+ type: "bytes32"
12275
+ }
12276
+ ],
12277
+ internalType: "struct Bridge.WithdrawalArguments",
12278
+ name: "_args",
12279
+ type: "tuple"
12280
+ },
12281
+ {
12282
+ components: [
12283
+ {
12284
+ internalType: "uint256",
12285
+ name: "attestationId",
12286
+ type: "uint256"
12287
+ },
12288
+ {
12289
+ internalType: "bytes32[]",
12290
+ name: "merklePath",
12291
+ type: "bytes32[]"
12292
+ },
12293
+ {
12294
+ internalType: "uint256",
12295
+ name: "leafCount",
12296
+ type: "uint256"
12297
+ },
12298
+ {
12299
+ internalType: "uint256",
12300
+ name: "index",
12301
+ type: "uint256"
12302
+ }
12303
+ ],
12304
+ internalType: "struct IZkvHub.AttestationDetails",
12305
+ name: "_attDetails",
12306
+ type: "tuple"
12307
+ }
12308
+ ],
12309
+ name: "withdrawERC20",
12310
+ outputs: [
12311
+ ],
12312
+ stateMutability: "nonpayable",
12313
+ type: "function"
12314
+ },
12315
+ {
12316
+ inputs: [
12317
+ {
12318
+ components: [
12319
+ {
12320
+ internalType: "bytes32",
12321
+ name: "canonicalId",
12322
+ type: "bytes32"
12323
+ },
12324
+ {
12325
+ internalType: "uint256",
12326
+ name: "amount",
12327
+ type: "uint256"
12328
+ },
12329
+ {
12330
+ internalType: "address",
12331
+ name: "to",
12332
+ type: "address"
12333
+ },
12334
+ {
12335
+ internalType: "bytes",
12336
+ name: "callData",
12337
+ type: "bytes"
12338
+ },
12339
+ {
12340
+ internalType: "bytes32",
12341
+ name: "stateRootHigh16",
12342
+ type: "bytes32"
12343
+ },
12344
+ {
12345
+ internalType: "bytes32",
12346
+ name: "stateRootLow16",
12347
+ type: "bytes32"
12348
+ },
12349
+ {
12350
+ internalType: "bytes32",
12351
+ name: "depositCommitmentHigh16",
12352
+ type: "bytes32"
12353
+ },
12354
+ {
12355
+ internalType: "bytes32",
12356
+ name: "depositCommitmentLow16",
12357
+ type: "bytes32"
12358
+ },
12359
+ {
12360
+ internalType: "address",
12361
+ name: "from",
12362
+ type: "address"
12363
+ },
12364
+ {
12365
+ internalType: "address",
12366
+ name: "owner",
12367
+ type: "address"
12368
+ },
12369
+ {
12370
+ internalType: "uint256",
12371
+ name: "destinationChainId",
12372
+ type: "uint256"
12373
+ },
12374
+ {
12375
+ internalType: "bytes32",
12376
+ name: "calldataHashHigh16",
12377
+ type: "bytes32"
12378
+ },
12379
+ {
12380
+ internalType: "bytes32",
12381
+ name: "calldataHashLow16",
12382
+ type: "bytes32"
12383
+ }
12384
+ ],
12385
+ internalType: "struct Bridge.WithdrawalArguments",
12386
+ name: "_args",
12387
+ type: "tuple"
12388
+ },
12389
+ {
12390
+ components: [
12391
+ {
12392
+ internalType: "uint256",
12393
+ name: "attestationId",
12394
+ type: "uint256"
12395
+ },
12396
+ {
12397
+ internalType: "bytes32[]",
12398
+ name: "merklePath",
12399
+ type: "bytes32[]"
12400
+ },
12401
+ {
12402
+ internalType: "uint256",
12403
+ name: "leafCount",
12404
+ type: "uint256"
12405
+ },
12406
+ {
12407
+ internalType: "uint256",
12408
+ name: "index",
12409
+ type: "uint256"
12410
+ }
12411
+ ],
12412
+ internalType: "struct IZkvHub.AttestationDetails",
12413
+ name: "_attDetails",
12414
+ type: "tuple"
12415
+ }
12416
+ ],
12417
+ name: "withdrawERC20ToContract",
12418
+ outputs: [
12419
+ ],
12420
+ stateMutability: "nonpayable",
12421
+ type: "function"
12422
+ },
12423
+ {
12424
+ inputs: [
12425
+ {
12426
+ components: [
12427
+ {
12428
+ internalType: "bytes32",
12429
+ name: "canonicalId",
12430
+ type: "bytes32"
12431
+ },
12432
+ {
12433
+ internalType: "uint256",
12434
+ name: "amount",
12435
+ type: "uint256"
12436
+ },
12437
+ {
12438
+ internalType: "address",
12439
+ name: "to",
12440
+ type: "address"
12441
+ },
12442
+ {
12443
+ internalType: "bytes",
12444
+ name: "callData",
12445
+ type: "bytes"
12446
+ },
12447
+ {
12448
+ internalType: "bytes32",
12449
+ name: "stateRootHigh16",
12450
+ type: "bytes32"
12451
+ },
12452
+ {
12453
+ internalType: "bytes32",
12454
+ name: "stateRootLow16",
12455
+ type: "bytes32"
12456
+ },
12457
+ {
12458
+ internalType: "bytes32",
12459
+ name: "depositCommitmentHigh16",
12460
+ type: "bytes32"
12461
+ },
12462
+ {
12463
+ internalType: "bytes32",
12464
+ name: "depositCommitmentLow16",
12465
+ type: "bytes32"
12466
+ },
12467
+ {
12468
+ internalType: "address",
12469
+ name: "from",
12470
+ type: "address"
12471
+ },
12472
+ {
12473
+ internalType: "address",
12474
+ name: "owner",
12475
+ type: "address"
12476
+ },
12477
+ {
12478
+ internalType: "uint256",
12479
+ name: "destinationChainId",
12480
+ type: "uint256"
12481
+ },
12482
+ {
12483
+ internalType: "bytes32",
12484
+ name: "calldataHashHigh16",
12485
+ type: "bytes32"
12486
+ },
12487
+ {
12488
+ internalType: "bytes32",
12489
+ name: "calldataHashLow16",
12490
+ type: "bytes32"
12491
+ }
12492
+ ],
12493
+ internalType: "struct Bridge.WithdrawalArguments",
12494
+ name: "_args",
12495
+ type: "tuple"
12496
+ },
12497
+ {
12498
+ components: [
12499
+ {
12500
+ internalType: "uint256",
12501
+ name: "attestationId",
12502
+ type: "uint256"
12503
+ },
12504
+ {
12505
+ internalType: "bytes32[]",
12506
+ name: "merklePath",
12507
+ type: "bytes32[]"
12508
+ },
12509
+ {
12510
+ internalType: "uint256",
12511
+ name: "leafCount",
12512
+ type: "uint256"
12513
+ },
12514
+ {
12515
+ internalType: "uint256",
12516
+ name: "index",
12517
+ type: "uint256"
12518
+ }
12519
+ ],
12520
+ internalType: "struct IZkvHub.AttestationDetails",
12521
+ name: "_attDetails",
12522
+ type: "tuple"
12523
+ }
12524
+ ],
12525
+ name: "withdrawNative",
12526
+ outputs: [
12527
+ ],
12528
+ stateMutability: "nonpayable",
12529
+ type: "function"
12530
+ },
12531
+ {
12532
+ inputs: [
12533
+ {
12534
+ components: [
12535
+ {
12536
+ internalType: "bytes32",
12537
+ name: "canonicalId",
12538
+ type: "bytes32"
12539
+ },
12540
+ {
12541
+ internalType: "uint256",
12542
+ name: "amount",
12543
+ type: "uint256"
12544
+ },
12545
+ {
12546
+ internalType: "address",
12547
+ name: "to",
12548
+ type: "address"
12549
+ },
12550
+ {
12551
+ internalType: "bytes",
12552
+ name: "callData",
12553
+ type: "bytes"
12554
+ },
12555
+ {
12556
+ internalType: "bytes32",
12557
+ name: "stateRootHigh16",
12558
+ type: "bytes32"
12559
+ },
12560
+ {
12561
+ internalType: "bytes32",
12562
+ name: "stateRootLow16",
12563
+ type: "bytes32"
12564
+ },
12565
+ {
12566
+ internalType: "bytes32",
12567
+ name: "depositCommitmentHigh16",
12568
+ type: "bytes32"
12569
+ },
12570
+ {
12571
+ internalType: "bytes32",
12572
+ name: "depositCommitmentLow16",
12573
+ type: "bytes32"
12574
+ },
12575
+ {
12576
+ internalType: "address",
12577
+ name: "from",
12578
+ type: "address"
12579
+ },
12580
+ {
12581
+ internalType: "address",
12582
+ name: "owner",
12583
+ type: "address"
12584
+ },
12585
+ {
12586
+ internalType: "uint256",
12587
+ name: "destinationChainId",
12588
+ type: "uint256"
12589
+ },
12590
+ {
12591
+ internalType: "bytes32",
12592
+ name: "calldataHashHigh16",
12593
+ type: "bytes32"
12594
+ },
12595
+ {
12596
+ internalType: "bytes32",
12597
+ name: "calldataHashLow16",
12598
+ type: "bytes32"
12599
+ }
12600
+ ],
12601
+ internalType: "struct Bridge.WithdrawalArguments",
12602
+ name: "_args",
12603
+ type: "tuple"
12604
+ },
12605
+ {
12606
+ components: [
12607
+ {
12608
+ internalType: "uint256",
12609
+ name: "attestationId",
12610
+ type: "uint256"
12611
+ },
12612
+ {
12613
+ internalType: "bytes32[]",
12614
+ name: "merklePath",
12615
+ type: "bytes32[]"
12616
+ },
12617
+ {
12618
+ internalType: "uint256",
12619
+ name: "leafCount",
12620
+ type: "uint256"
12621
+ },
12622
+ {
12623
+ internalType: "uint256",
12624
+ name: "index",
12625
+ type: "uint256"
12626
+ }
12627
+ ],
12628
+ internalType: "struct IZkvHub.AttestationDetails",
12629
+ name: "_attDetails",
12630
+ type: "tuple"
12631
+ }
12632
+ ],
12633
+ name: "withdrawNativeToContract",
12634
+ outputs: [
12635
+ ],
12636
+ stateMutability: "nonpayable",
12637
+ type: "function"
12638
+ }
12639
+ ];
12640
+ var bytecode$h = "";
12641
+ var deployedBytecode$6 = "";
12642
+ var linkReferences$6 = {
12643
+ };
12644
+ var deployedLinkReferences$6 = {
12645
+ };
12646
+ var BridgeAbi = {
12647
+ _format: _format$6,
12648
+ contractName: contractName$6,
12649
+ sourceName: sourceName$6,
12650
+ abi: abi$h,
12651
+ bytecode: bytecode$h,
12652
+ deployedBytecode: deployedBytecode$6,
12653
+ linkReferences: linkReferences$6,
12654
+ deployedLinkReferences: deployedLinkReferences$6
12655
+ };
12656
+
12657
+ var _DOMAIN_PREFIX = "0x191253796e6172614272696467654465706f7369740a";
12658
+ var BridgeCreateOrderContext = /*#__PURE__*/function (_BaseContext) {
12659
+ function BridgeCreateOrderContext(signature) {
12660
+ return _BaseContext.call(this, signature) || this;
12661
+ }
12662
+ _inheritsLoose(BridgeCreateOrderContext, _BaseContext);
12663
+ return _createClass(BridgeCreateOrderContext, [{
12664
+ key: "orderNote",
12665
+ get: function get() {
12666
+ return this._orderNote;
12667
+ },
12668
+ set: function set(orderNote) {
12669
+ this._orderNote = orderNote;
12670
+ }
12671
+ }, {
12672
+ key: "swapInNote",
12673
+ get: function get() {
12674
+ return this._swapInNote;
12675
+ },
12676
+ set: function set(swapInNote) {
12677
+ this._swapInNote = swapInNote;
12678
+ }
12679
+ }, {
12680
+ key: "feeAmount",
12681
+ get: function get() {
12682
+ return this._feeAmount;
12683
+ },
12684
+ set: function set(feeAmount) {
12685
+ this._feeAmount = feeAmount;
12686
+ }
12687
+ }, {
12688
+ key: "proof",
12689
+ get: function get() {
12690
+ return this._proof;
12691
+ },
12692
+ set: function set(proof) {
12693
+ this._proof = proof;
12694
+ }
12695
+ }, {
12696
+ key: "swapMessage",
12697
+ get: function get() {
12698
+ return this._swapMessage;
12699
+ },
12700
+ set: function set(swapMessage) {
12701
+ this._swapMessage = swapMessage;
12702
+ }
12703
+ }, {
12704
+ key: "sourceChainId",
12705
+ get: function get() {
12706
+ return this._sourceChainId;
12707
+ },
12708
+ set: function set(sourceChainId) {
12709
+ this._sourceChainId = sourceChainId;
12710
+ }
12711
+ }, {
12712
+ key: "destChainId",
12713
+ get: function get() {
12714
+ return this._destChainId;
12715
+ },
12716
+ set: function set(destChainId) {
12717
+ this._destChainId = destChainId;
12718
+ }
12719
+ }, {
12720
+ key: "sourceAsset",
12721
+ get: function get() {
12722
+ return this._sourceAsset;
12723
+ },
12724
+ set: function set(sourceAsset) {
12725
+ this._sourceAsset = sourceAsset;
12726
+ }
12727
+ }, {
12728
+ key: "sourceAmount",
12729
+ get: function get() {
12730
+ return this._sourceAmount;
12731
+ },
12732
+ set: function set(sourceAmount) {
12733
+ this._sourceAmount = sourceAmount;
12734
+ }
12735
+ }, {
12736
+ key: "bridgeFeeAmount",
12737
+ get: function get() {
12738
+ return this._bridgeFeeAmount;
12739
+ },
12740
+ set: function set(bridgeFeeAmount) {
12741
+ this._bridgeFeeAmount = bridgeFeeAmount;
12742
+ }
12743
+ }, {
12744
+ key: "depositId",
12745
+ get: function get() {
12746
+ return this._depositId;
12747
+ },
12748
+ set: function set(depositId) {
12749
+ this._depositId = depositId;
12750
+ }
12751
+ }, {
12752
+ key: "attestationDetails",
12753
+ get: function get() {
12754
+ return this._attestationDetails;
12755
+ },
12756
+ set: function set(attestationDetails) {
12757
+ this._attestationDetails = attestationDetails;
12758
+ }
12759
+ }, {
12760
+ key: "relayer",
12761
+ get: function get() {
12762
+ return this._relayer;
12763
+ },
12764
+ set: function set(relayer) {
12765
+ this._relayer = relayer;
12766
+ }
12767
+ }, {
12768
+ key: "jobId",
12769
+ get: function get() {
12770
+ return this._jobId;
12771
+ },
12772
+ set: function set(jobId) {
12773
+ this._jobId = jobId;
12774
+ }
12775
+ }, {
12776
+ key: "canonicalId",
12777
+ get: function get() {
12778
+ return this._canonicalId;
12779
+ },
12780
+ set: function set(canonicalId) {
12781
+ this._canonicalId = canonicalId;
12782
+ }
12783
+ }, {
12784
+ key: "callDataHash",
12785
+ get: function get() {
12786
+ return this._callDataHash;
12787
+ },
12788
+ set: function set(callDataHash) {
12789
+ this._callDataHash = callDataHash;
12790
+ }
12791
+ }, {
12792
+ key: "nonce",
12793
+ get: function get() {
12794
+ return this._nonce;
11250
12795
  },
11251
12796
  set: function set(nonce) {
11252
12797
  this._nonce = nonce;
@@ -11267,24 +12812,82 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11267
12812
  this._darkSwapOfDestChain = _darkSwapOfDestChain;
11268
12813
  }
11269
12814
  var _proto = BridgeCreateOrderService.prototype;
11270
- _proto.prepare = /*#__PURE__*/function () {
11271
- var _prepare = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(address, sourceChainId, sourceAsset, sourceAmount, canonicalId, bridgeFee, destChainId, depositAsset, depositAmount, swapInAsset, swapInAmount, signature) {
11272
- var _yield$generateKeyPai, pubKey, privKey, feeRatio, orderNote, feeAmount, realSwapInAmount, swapInNote, context, swapMessage, _t, _t2;
12815
+ _proto.getCanonicalTokenAddress = /*#__PURE__*/function () {
12816
+ var _getCanonicalTokenAddress = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sourceAsset) {
12817
+ var canonicalTokenRegistry;
11273
12818
  return _regenerator().w(function (_context) {
11274
12819
  while (1) switch (_context.n) {
11275
12820
  case 0:
12821
+ canonicalTokenRegistry = new ethers.Contract(this._darkSwapOfSourceChain.contracts.synaraCanonicalTokenRegistry, CanonicalTokenRegistryAbi, this._darkSwapOfSourceChain.provider);
11276
12822
  _context.n = 1;
12823
+ return canonicalTokenRegistry.getCanonicalId(sourceAsset);
12824
+ case 1:
12825
+ return _context.a(2, _context.v);
12826
+ }
12827
+ }, _callee, this);
12828
+ }));
12829
+ function getCanonicalTokenAddress(_x) {
12830
+ return _getCanonicalTokenAddress.apply(this, arguments);
12831
+ }
12832
+ return getCanonicalTokenAddress;
12833
+ }();
12834
+ _proto.getBridgeFee = /*#__PURE__*/function () {
12835
+ var _getBridgeFee = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(canonicalId, wallet, amount) {
12836
+ var bridge;
12837
+ return _regenerator().w(function (_context2) {
12838
+ while (1) switch (_context2.n) {
12839
+ case 0:
12840
+ bridge = new ethers.Contract(this._darkSwapOfSourceChain.contracts.synaraBridge, BridgeAbi.abi, this._darkSwapOfSourceChain.provider);
12841
+ _context2.n = 1;
12842
+ return bridge.getBridgeFee(canonicalId, wallet, amount);
12843
+ case 1:
12844
+ return _context2.a(2, _context2.v);
12845
+ }
12846
+ }, _callee2, this);
12847
+ }));
12848
+ function getBridgeFee(_x2, _x3, _x4) {
12849
+ return _getBridgeFee.apply(this, arguments);
12850
+ }
12851
+ return getBridgeFee;
12852
+ }();
12853
+ _proto.prepare = /*#__PURE__*/function () {
12854
+ var _prepare = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(address, sourceChainId, sourceAsset, sourceAmount, canonicalId, bridgeFee, destChainId, depositAsset, depositAmount, swapInAsset, swapInAmount, signature) {
12855
+ var _yield$generateKeyPai, pubKey, privKey, feeRatio, canonicalIdFromContract, bridgeFeeAmountFromContract, orderNote, feeAmount, realSwapInAmount, swapInNote, context, swapMessage, _t, _t2;
12856
+ return _regenerator().w(function (_context3) {
12857
+ while (1) switch (_context3.n) {
12858
+ case 0:
12859
+ _context3.n = 1;
11277
12860
  return generateKeyPair(signature);
11278
12861
  case 1:
11279
- _yield$generateKeyPai = _context.v;
12862
+ _yield$generateKeyPai = _context3.v;
11280
12863
  pubKey = _yield$generateKeyPai[0];
11281
12864
  privKey = _yield$generateKeyPai[1];
11282
12865
  _t = BigInt;
11283
- _context.n = 2;
12866
+ _context3.n = 2;
11284
12867
  return getFeeRatio(address, this._darkSwapOfDestChain);
11285
12868
  case 2:
11286
- _t2 = _context.v;
12869
+ _t2 = _context3.v;
11287
12870
  feeRatio = _t(_t2);
12871
+ _context3.n = 3;
12872
+ return this.getCanonicalTokenAddress(sourceAsset);
12873
+ case 3:
12874
+ canonicalIdFromContract = _context3.v;
12875
+ if (!(canonicalIdFromContract !== canonicalId)) {
12876
+ _context3.n = 4;
12877
+ break;
12878
+ }
12879
+ throw new DarkSwapError('CanonicalId not match');
12880
+ case 4:
12881
+ _context3.n = 5;
12882
+ return this.getBridgeFee(canonicalId, address, sourceAmount);
12883
+ case 5:
12884
+ bridgeFeeAmountFromContract = _context3.v;
12885
+ if (!(bridgeFeeAmountFromContract !== bridgeFee)) {
12886
+ _context3.n = 6;
12887
+ break;
12888
+ }
12889
+ throw new DarkSwapError('BridgeFee not match');
12890
+ case 6:
11288
12891
  orderNote = createOrderNoteExt(address, depositAsset, depositAmount, feeRatio, pubKey);
11289
12892
  feeAmount = calcFeeAmount(swapInAmount, feeRatio);
11290
12893
  realSwapInAmount = swapInAmount - feeAmount;
@@ -11300,19 +12903,19 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11300
12903
  context.sourceAmount = sourceAmount;
11301
12904
  context.bridgeFeeAmount = bridgeFee;
11302
12905
  context.canonicalId = canonicalId;
11303
- _context.n = 3;
12906
+ _context3.n = 7;
11304
12907
  return generateRetailSwapMessage(address, orderNote, swapInNote, feeAmount, pubKey, privKey);
11305
- case 3:
11306
- swapMessage = _context.v;
12908
+ case 7:
12909
+ swapMessage = _context3.v;
11307
12910
  context.swapMessage = swapMessage;
11308
- return _context.a(2, {
12911
+ return _context3.a(2, {
11309
12912
  context: context,
11310
12913
  swapMessage: swapMessage
11311
12914
  });
11312
12915
  }
11313
- }, _callee, this);
12916
+ }, _callee3, this);
11314
12917
  }));
11315
- function prepare(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x0, _x1, _x10) {
12918
+ function prepare(_x5, _x6, _x7, _x8, _x9, _x0, _x1, _x10, _x11, _x12, _x13, _x14) {
11316
12919
  return _prepare.apply(this, arguments);
11317
12920
  }
11318
12921
  return prepare;
@@ -11321,123 +12924,123 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11321
12924
  return this._darkSwapOfSourceChain.contracts.zkverifyRelayerUrls[0];
11322
12925
  };
11323
12926
  _proto.submitProof = /*#__PURE__*/function () {
11324
- var _submitProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context) {
12927
+ var _submitProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
11325
12928
  var relayerRequest, response, _yield$this$pollJobSt, error, result;
11326
- return _regenerator().w(function (_context2) {
11327
- while (1) switch (_context2.n) {
12929
+ return _regenerator().w(function (_context4) {
12930
+ while (1) switch (_context4.n) {
11328
12931
  case 0:
11329
12932
  if (context) {
11330
- _context2.n = 1;
12933
+ _context4.n = 1;
11331
12934
  break;
11332
12935
  }
11333
12936
  throw new DarkSwapError('Invalid context');
11334
12937
  case 1:
11335
- _context2.n = 2;
12938
+ _context4.n = 2;
11336
12939
  return this.generateProof(context);
11337
12940
  case 2:
11338
- context.proof = _context2.v;
12941
+ context.proof = _context4.v;
11339
12942
  relayerRequest = {
11340
12943
  proof: context.proof.proof,
11341
12944
  publicSignals: context.proof.verifyInputs,
11342
12945
  vkHash: VK_HASH_CONFIG[PROOF_DOMAIN.RETAIL_BRIDGE_ORDER]
11343
12946
  };
11344
12947
  context.relayer = this.pickRelayer();
11345
- _context2.n = 3;
12948
+ _context4.n = 3;
11346
12949
  return axios.post(context.relayer + '/v1/zkVerifySubmitProof', relayerRequest);
11347
12950
  case 3:
11348
- response = _context2.v;
12951
+ response = _context4.v;
11349
12952
  if (!(response.status == 200)) {
11350
- _context2.n = 4;
12953
+ _context4.n = 4;
11351
12954
  break;
11352
12955
  }
11353
12956
  context.jobId = response.data.id;
11354
- _context2.n = 6;
12957
+ _context4.n = 6;
11355
12958
  break;
11356
12959
  case 4:
11357
12960
  if (!(response.status == 400)) {
11358
- _context2.n = 5;
12961
+ _context4.n = 5;
11359
12962
  break;
11360
12963
  }
11361
12964
  throw new Error('Request error' + response.data.error);
11362
12965
  case 5:
11363
12966
  throw new Error('Relayer not asscessable');
11364
12967
  case 6:
11365
- _context2.n = 7;
12968
+ _context4.n = 7;
11366
12969
  return this.pollJobStatus(context);
11367
12970
  case 7:
11368
- _yield$this$pollJobSt = _context2.v;
12971
+ _yield$this$pollJobSt = _context4.v;
11369
12972
  error = _yield$this$pollJobSt.error;
11370
12973
  result = _yield$this$pollJobSt.result;
11371
12974
  if (!error) {
11372
- _context2.n = 8;
12975
+ _context4.n = 8;
11373
12976
  break;
11374
12977
  }
11375
12978
  throw new DarkSwapError(error);
11376
12979
  case 8:
11377
12980
  context.attestationDetails = result;
11378
12981
  case 9:
11379
- return _context2.a(2);
12982
+ return _context4.a(2);
11380
12983
  }
11381
- }, _callee2, this);
12984
+ }, _callee4, this);
11382
12985
  }));
11383
- function submitProof(_x11) {
12986
+ function submitProof(_x15) {
11384
12987
  return _submitProof.apply(this, arguments);
11385
12988
  }
11386
12989
  return submitProof;
11387
12990
  }();
11388
12991
  _proto.pollJobStatus = /*#__PURE__*/function () {
11389
- var _pollJobStatus = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(context) {
12992
+ var _pollJobStatus = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(context) {
11390
12993
  var tries, response, error, _response$data, status, failedReason, result, _t3;
11391
- return _regenerator().w(function (_context3) {
11392
- while (1) switch (_context3.n) {
12994
+ return _regenerator().w(function (_context5) {
12995
+ while (1) switch (_context5.n) {
11393
12996
  case 0:
11394
12997
  tries = 1;
11395
12998
  case 1:
11396
12999
  if (!(tries <= 100)) {
11397
- _context3.n = 10;
13000
+ _context5.n = 10;
11398
13001
  break;
11399
13002
  }
11400
13003
  if (!(tries >= 100)) {
11401
- _context3.n = 2;
13004
+ _context5.n = 2;
11402
13005
  break;
11403
13006
  }
11404
- return _context3.a(3, 10);
13007
+ return _context5.a(3, 10);
11405
13008
  case 2:
11406
- _context3.p = 2;
11407
- _context3.n = 3;
13009
+ _context5.p = 2;
13010
+ _context5.n = 3;
11408
13011
  return axios.get(context.relayer + "/v1/jobs/" + context.jobId);
11409
13012
  case 3:
11410
- response = _context3.v;
13013
+ response = _context5.v;
11411
13014
  if (!(response.status === 400)) {
11412
- _context3.n = 4;
13015
+ _context5.n = 4;
11413
13016
  break;
11414
13017
  }
11415
13018
  error = response.data.error;
11416
13019
  console.log(error);
11417
- return _context3.a(2, {
13020
+ return _context5.a(2, {
11418
13021
  error: 'Failed to submit proof to relayer:' + error,
11419
13022
  result: undefined
11420
13023
  });
11421
13024
  case 4:
11422
13025
  if (!(response.status === 200)) {
11423
- _context3.n = 6;
13026
+ _context5.n = 6;
11424
13027
  break;
11425
13028
  }
11426
13029
  _response$data = response.data, status = _response$data.status, failedReason = _response$data.failedReason, result = _response$data.result;
11427
13030
  if (!(status === 'FAILED')) {
11428
- _context3.n = 5;
13031
+ _context5.n = 5;
11429
13032
  break;
11430
13033
  }
11431
- return _context3.a(2, {
13034
+ return _context5.a(2, {
11432
13035
  error: failedReason != null ? failedReason : 'Transaction failed.',
11433
13036
  result: undefined
11434
13037
  });
11435
13038
  case 5:
11436
13039
  if (!(status === 'CONFIRMED' || status === 'MINED')) {
11437
- _context3.n = 6;
13040
+ _context5.n = 6;
11438
13041
  break;
11439
13042
  }
11440
- return _context3.a(2, {
13043
+ return _context5.a(2, {
11441
13044
  error: undefined,
11442
13045
  result: {
11443
13046
  attestationId: BigInt(result.attestationId),
@@ -11447,47 +13050,47 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11447
13050
  }
11448
13051
  });
11449
13052
  case 6:
11450
- _context3.n = 7;
13053
+ _context5.n = 7;
11451
13054
  return new Promise(function (resolve) {
11452
13055
  return setTimeout(resolve, 5000);
11453
13056
  });
11454
13057
  case 7:
11455
- _context3.n = 9;
13058
+ _context5.n = 9;
11456
13059
  break;
11457
13060
  case 8:
11458
- _context3.p = 8;
11459
- _t3 = _context3.v;
13061
+ _context5.p = 8;
13062
+ _t3 = _context5.v;
11460
13063
  console.log(_t3);
11461
13064
  case 9:
11462
13065
  tries++;
11463
- _context3.n = 1;
13066
+ _context5.n = 1;
11464
13067
  break;
11465
13068
  case 10:
11466
- return _context3.a(2, {
13069
+ return _context5.a(2, {
11467
13070
  error: 'Waited too long for getting attestation details.',
11468
13071
  result: undefined
11469
13072
  });
11470
13073
  }
11471
- }, _callee3, null, [[2, 8]]);
13074
+ }, _callee5, null, [[2, 8]]);
11472
13075
  }));
11473
- function pollJobStatus(_x12) {
13076
+ function pollJobStatus(_x16) {
11474
13077
  return _pollJobStatus.apply(this, arguments);
11475
13078
  }
11476
13079
  return pollJobStatus;
11477
13080
  }();
11478
13081
  _proto.generateProof = /*#__PURE__*/function () {
11479
- var _generateProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
13082
+ var _generateProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(context) {
11480
13083
  var proof;
11481
- return _regenerator().w(function (_context4) {
11482
- while (1) switch (_context4.n) {
13084
+ return _regenerator().w(function (_context6) {
13085
+ while (1) switch (_context6.n) {
11483
13086
  case 0:
11484
13087
  if (!(!context || !context.orderNote || !context.swapInNote || !context.address || context.feeAmount === undefined || !context.signature || !context.sourceChainId || !context.destChainId || !context.sourceAsset || !context.sourceAmount || context.bridgeFeeAmount === undefined)) {
11485
- _context4.n = 1;
13088
+ _context6.n = 1;
11486
13089
  break;
11487
13090
  }
11488
13091
  throw new DarkSwapError('Invalid context');
11489
13092
  case 1:
11490
- _context4.n = 2;
13093
+ _context6.n = 2;
11491
13094
  return generateRetailBridgeOrderProof({
11492
13095
  depositSourceAsset: context.sourceAsset,
11493
13096
  depositNote: context.orderNote,
@@ -11500,77 +13103,77 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11500
13103
  signedMessage: context.signature
11501
13104
  });
11502
13105
  case 2:
11503
- proof = _context4.v;
11504
- return _context4.a(2, proof);
13106
+ proof = _context6.v;
13107
+ return _context6.a(2, proof);
11505
13108
  }
11506
- }, _callee4);
13109
+ }, _callee6);
11507
13110
  }));
11508
- function generateProof(_x13) {
13111
+ function generateProof(_x17) {
11509
13112
  return _generateProof.apply(this, arguments);
11510
13113
  }
11511
13114
  return generateProof;
11512
13115
  }();
11513
13116
  _proto.computeDepositId = /*#__PURE__*/function () {
11514
- var _computeDepositId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(context) {
13117
+ var _computeDepositId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(context) {
11515
13118
  var callDataHash, currentNonce, packedData, depositCommitment;
11516
- return _regenerator().w(function (_context5) {
11517
- while (1) switch (_context5.n) {
13119
+ return _regenerator().w(function (_context7) {
13120
+ while (1) switch (_context7.n) {
11518
13121
  case 0:
11519
13122
  if (!(!context || !context.callData || !context.orderNote || !context.swapInNote || !context.address || context.feeAmount === undefined || !context.signature || !context.sourceChainId || !context.destChainId || !context.sourceAsset || context.bridgeFeeAmount === undefined)) {
11520
- _context5.n = 1;
13123
+ _context7.n = 1;
11521
13124
  break;
11522
13125
  }
11523
13126
  throw new DarkSwapError('Invalid context');
11524
13127
  case 1:
11525
- callDataHash = ethers.solidityPackedKeccak256(['address', 'bytes'], [this._darkSwapOfSourceChain.contracts.synaraDarkSwapOnBridgeAssetManager, context.callData]);
13128
+ callDataHash = ethers.solidityPackedKeccak256(['address', 'bytes'], [this._darkSwapOfDestChain.contracts.synaraDarkSwapOnBridgeAssetManager, context.callData]);
11526
13129
  context.callDataHash = callDataHash;
11527
- _context5.n = 2;
13130
+ _context7.n = 2;
11528
13131
  return this.getCurrentNonce(context);
11529
13132
  case 2:
11530
- currentNonce = _context5.v;
13133
+ currentNonce = _context7.v;
11531
13134
  context.nonce = currentNonce;
11532
13135
  packedData = solidityPacked(["bytes", "address", "bytes32", "address", "address", "bytes32", "bytes32", "bytes32", "bytes32", "bytes32" // _computeCallDataHash(call)
11533
13136
  ], [_DOMAIN_PREFIX, this._darkSwapOfSourceChain.contracts.synaraBridge, context.canonicalId, this._darkSwapOfSourceChain.contracts.synaraDarkSwapOnBridgeAssetManager, context.address, hexlify32(context.orderNote.amount), hexlify32(context.destChainId), hexlify32(context.nonce), hexlify32(context.sourceChainId), context.callDataHash]);
11534
13137
  depositCommitment = keccak256(packedData);
11535
- return _context5.a(2, depositCommitment);
13138
+ return _context7.a(2, depositCommitment);
11536
13139
  }
11537
- }, _callee5, this);
13140
+ }, _callee7, this);
11538
13141
  }));
11539
- function computeDepositId(_x14) {
13142
+ function computeDepositId(_x18) {
11540
13143
  return _computeDepositId.apply(this, arguments);
11541
13144
  }
11542
13145
  return computeDepositId;
11543
13146
  }();
11544
13147
  _proto.getCurrentNonce = /*#__PURE__*/function () {
11545
- var _getCurrentNonce = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(context) {
13148
+ var _getCurrentNonce = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(context) {
11546
13149
  var provider, contract;
11547
- return _regenerator().w(function (_context6) {
11548
- while (1) switch (_context6.n) {
13150
+ return _regenerator().w(function (_context8) {
13151
+ while (1) switch (_context8.n) {
11549
13152
  case 0:
11550
13153
  provider = this._darkSwapOfSourceChain.provider;
11551
13154
  contract = new ethers.Contract(this._darkSwapOfSourceChain.contracts.synaraDarkSwapOnBridgeAssetManager, SynaraDarkSwapOnBridgeAssetManagerAbi.abi, provider);
11552
- _context6.n = 1;
13155
+ _context8.n = 1;
11553
13156
  return contract.currentNonce({
11554
13157
  from: context.address
11555
13158
  });
11556
13159
  case 1:
11557
- return _context6.a(2, _context6.v);
13160
+ return _context8.a(2, _context8.v);
11558
13161
  }
11559
- }, _callee6, this);
13162
+ }, _callee8, this);
11560
13163
  }));
11561
- function getCurrentNonce(_x15) {
13164
+ function getCurrentNonce(_x19) {
11562
13165
  return _getCurrentNonce.apply(this, arguments);
11563
13166
  }
11564
13167
  return getCurrentNonce;
11565
13168
  }();
11566
13169
  _proto.composeCallData = /*#__PURE__*/function () {
11567
- var _composeCallData = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(context) {
13170
+ var _composeCallData = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(context) {
11568
13171
  var functionSignature, args, iface, fullData;
11569
- return _regenerator().w(function (_context7) {
11570
- while (1) switch (_context7.n) {
13172
+ return _regenerator().w(function (_context9) {
13173
+ while (1) switch (_context9.n) {
11571
13174
  case 0:
11572
13175
  if (!(!context || !context.orderNote || !context.swapInNote || !context.address || !context.destChainId || !context.sourceAsset || context.bridgeFeeAmount === undefined || !context.proof || !context.attestationDetails)) {
11573
- _context7.n = 1;
13176
+ _context9.n = 1;
11574
13177
  break;
11575
13178
  }
11576
13179
  throw new DarkSwapError('Invalid context');
@@ -11583,7 +13186,7 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11583
13186
  depositOutNote: hexlify32(context.orderNote.note),
11584
13187
  depositOutNoteFooter: context.proof.depositFooter,
11585
13188
  outAssetSource: context.sourceAsset,
11586
- outAssetDest: context.orderNote.address,
13189
+ outAssetDest: context.orderNote.asset,
11587
13190
  outAmount: context.orderNote.amount,
11588
13191
  feeRatio: context.orderNote.feeRatio,
11589
13192
  inNote: hexlify32(context.swapInNote.note),
@@ -11592,23 +13195,23 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11592
13195
  };
11593
13196
  iface = new ethers.Interface(["function " + functionSignature]);
11594
13197
  fullData = iface.encodeFunctionData('_retailBridgeCreateOrder', [[args.destChain, args.bridgeFee, args.owner, args.depositOutNote, args.depositOutNoteFooter, args.outAssetSource, args.outAssetDest, args.outAmount, args.feeRatio, args.inNote, args.inNoteFooter, args.destContractAddress], [context.attestationDetails.attestationId, context.attestationDetails.merklePath, context.attestationDetails.leafCount, context.attestationDetails.index]]);
11595
- return _context7.a(2, fullData);
13198
+ return _context9.a(2, fullData);
11596
13199
  }
11597
- }, _callee7, this);
13200
+ }, _callee9, this);
11598
13201
  }));
11599
- function composeCallData(_x16) {
13202
+ function composeCallData(_x20) {
11600
13203
  return _composeCallData.apply(this, arguments);
11601
13204
  }
11602
13205
  return composeCallData;
11603
13206
  }();
11604
13207
  _proto.allowance = /*#__PURE__*/function () {
11605
- var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(context) {
13208
+ var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(context) {
11606
13209
  var signer, asset, amount, allowanceContract, allowance, isLegacy, contract, tx;
11607
- return _regenerator().w(function (_context8) {
11608
- while (1) switch (_context8.n) {
13210
+ return _regenerator().w(function (_context0) {
13211
+ while (1) switch (_context0.n) {
11609
13212
  case 0:
11610
13213
  if (!(!context || !context.orderNote || !context.address || !context.signature || !context.proof)) {
11611
- _context8.n = 1;
13214
+ _context0.n = 1;
11612
13215
  break;
11613
13216
  }
11614
13217
  throw new DarkSwapError('Invalid context');
@@ -11617,74 +13220,74 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11617
13220
  asset = context.orderNote.asset;
11618
13221
  amount = context.orderNote.amount;
11619
13222
  allowanceContract = new ethers.Contract(asset, ERC20Abi.abi, this._darkSwapOfSourceChain);
11620
- _context8.n = 2;
13223
+ _context0.n = 2;
11621
13224
  return allowanceContract.allowance(signer.getAddress(), this._darkSwapOfSourceChain.contracts.darkSwapAssetManager);
11622
13225
  case 2:
11623
- allowance = _context8.v;
13226
+ allowance = _context0.v;
11624
13227
  if (!(BigInt(allowance) < amount)) {
11625
- _context8.n = 4;
13228
+ _context0.n = 4;
11626
13229
  break;
11627
13230
  }
11628
13231
  isLegacy = legacyTokenConfig.hasOwnProperty(this._darkSwapOfSourceChain.chainId) && legacyTokenConfig[this._darkSwapOfSourceChain.chainId].includes(asset.toLowerCase());
11629
13232
  contract = new ethers.Contract(asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
11630
- _context8.n = 3;
13233
+ _context0.n = 3;
11631
13234
  return contract.approve(this._darkSwapOfSourceChain.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
11632
13235
  case 3:
11633
- tx = _context8.v;
11634
- _context8.n = 4;
13236
+ tx = _context0.v;
13237
+ _context0.n = 4;
11635
13238
  return tx.wait();
11636
13239
  case 4:
11637
- return _context8.a(2);
13240
+ return _context0.a(2);
11638
13241
  }
11639
- }, _callee8, this);
13242
+ }, _callee0, this);
11640
13243
  }));
11641
- function allowance(_x17) {
13244
+ function allowance(_x21) {
11642
13245
  return _allowance.apply(this, arguments);
11643
13246
  }
11644
13247
  return allowance;
11645
13248
  }();
11646
13249
  _proto.execute = /*#__PURE__*/function () {
11647
- var _execute2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(context) {
13250
+ var _execute2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(context) {
11648
13251
  var callData, txHash;
11649
- return _regenerator().w(function (_context9) {
11650
- while (1) switch (_context9.n) {
13252
+ return _regenerator().w(function (_context1) {
13253
+ while (1) switch (_context1.n) {
11651
13254
  case 0:
11652
- _context9.n = 1;
13255
+ _context1.n = 1;
11653
13256
  return this.submitProof(context);
11654
13257
  case 1:
11655
- _context9.n = 2;
13258
+ _context1.n = 2;
11656
13259
  return this.composeCallData(context);
11657
13260
  case 2:
11658
- callData = _context9.v;
13261
+ callData = _context1.v;
11659
13262
  context.callData = callData;
11660
- _context9.n = 3;
13263
+ _context1.n = 3;
11661
13264
  return this.computeDepositId(context);
11662
13265
  case 3:
11663
- context.depositId = _context9.v;
11664
- _context9.n = 4;
13266
+ context.depositId = _context1.v;
13267
+ _context1.n = 4;
11665
13268
  return this._execute(context);
11666
13269
  case 4:
11667
- txHash = _context9.v;
11668
- return _context9.a(2, {
13270
+ txHash = _context1.v;
13271
+ return _context1.a(2, {
11669
13272
  depositId: context.depositId,
11670
13273
  txHash: txHash
11671
13274
  });
11672
13275
  }
11673
- }, _callee9, this);
13276
+ }, _callee1, this);
11674
13277
  }));
11675
- function execute(_x18) {
13278
+ function execute(_x22) {
11676
13279
  return _execute2.apply(this, arguments);
11677
13280
  }
11678
13281
  return execute;
11679
13282
  }();
11680
13283
  _proto._execute = /*#__PURE__*/function () {
11681
- var _execute3 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(context) {
13284
+ var _execute3 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(context) {
11682
13285
  var contract, ethAmount, tx;
11683
- return _regenerator().w(function (_context0) {
11684
- while (1) switch (_context0.n) {
13286
+ return _regenerator().w(function (_context10) {
13287
+ while (1) switch (_context10.n) {
11685
13288
  case 0:
11686
13289
  if (!(!context || !context.destChainId || !context.attestationDetails || !context.orderNote || !context.swapInNote || !context.sourceAsset || !context.sourceAmount || context.bridgeFeeAmount === undefined || !context.depositId || !context.proof)) {
11687
- _context0.n = 1;
13290
+ _context10.n = 1;
11688
13291
  break;
11689
13292
  }
11690
13293
  throw new DarkSwapError('Invalid context');
@@ -11692,30 +13295,30 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11692
13295
  contract = new ethers.Contract(this._darkSwapOfSourceChain.contracts.synaraDarkSwapOnBridgeAssetManager, SynaraDarkSwapOnBridgeAssetManagerAbi.abi, this._darkSwapOfSourceChain.signer);
11693
13296
  ethAmount = 0n;
11694
13297
  if (!isNativeAsset(context.sourceAsset)) {
11695
- _context0.n = 2;
13298
+ _context10.n = 2;
11696
13299
  break;
11697
13300
  }
11698
13301
  ethAmount = context.sourceAmount;
11699
- _context0.n = 3;
13302
+ _context10.n = 3;
11700
13303
  break;
11701
13304
  case 2:
11702
- _context0.n = 3;
13305
+ _context10.n = 3;
11703
13306
  return this.allowance(context);
11704
13307
  case 3:
11705
- _context0.n = 4;
11706
- return contract.retailDepositBridge(context.depositId, [hexlify32(BigInt(context.destChainId)), hexlify32(context.bridgeFeeAmount), context.address, hexlify32(context.orderNote.note), context.proof.depositFooter, context.sourceAsset, context.orderNote.address, hexlify32(context.sourceAmount), hexlify32(context.orderNote.feeRatio), hexlify32(context.swapInNote.note), context.proof.swapInNoteFooter, this._darkSwapOfDestChain.contracts.synaraDarkSwapOnBridgeAssetManager], [hexlify32(context.attestationDetails.attestationId), context.attestationDetails.merklePath, hexlify32(context.attestationDetails.leafCount), hexlify32(context.attestationDetails.index)], {
13308
+ _context10.n = 4;
13309
+ return contract.retailDepositBridge(context.depositId, [hexlify32(BigInt(context.destChainId)), hexlify32(context.bridgeFeeAmount), context.address, hexlify32(context.orderNote.note), context.proof.depositFooter, context.sourceAsset, context.orderNote.asset, hexlify32(context.sourceAmount), hexlify32(context.orderNote.feeRatio), hexlify32(context.swapInNote.note), context.proof.swapInNoteFooter, this._darkSwapOfDestChain.contracts.synaraDarkSwapOnBridgeAssetManager], [hexlify32(context.attestationDetails.attestationId), context.attestationDetails.merklePath, hexlify32(context.attestationDetails.leafCount), hexlify32(context.attestationDetails.index)], {
11707
13310
  value: bn_to_0xhex(ethAmount)
11708
13311
  });
11709
13312
  case 4:
11710
- tx = _context0.v;
11711
- _context0.n = 5;
13313
+ tx = _context10.v;
13314
+ _context10.n = 5;
11712
13315
  return tx.wait();
11713
13316
  case 5:
11714
- return _context0.a(2, tx.hash);
13317
+ return _context10.a(2, tx.hash);
11715
13318
  }
11716
- }, _callee0, this);
13319
+ }, _callee10, this);
11717
13320
  }));
11718
- function _execute(_x19) {
13321
+ function _execute(_x23) {
11719
13322
  return _execute3.apply(this, arguments);
11720
13323
  }
11721
13324
  return _execute;
@@ -11723,11 +13326,11 @@ var BridgeCreateOrderService = /*#__PURE__*/function () {
11723
13326
  return BridgeCreateOrderService;
11724
13327
  }();
11725
13328
 
11726
- var DarkSwap = function DarkSwap(signer, chainId, contracts) {
13329
+ var DarkSwap = function DarkSwap(signer, chainId, provider, contracts) {
11727
13330
  // @ts-ignore
11728
13331
  this.signer = signer;
11729
13332
  // @ts-ignore
11730
- this.provider = signer.provider;
13333
+ this.provider = provider || signer.provider;
11731
13334
  this.chainId = chainId;
11732
13335
  if (contracts) {
11733
13336
  this.contracts = contracts;
@@ -11791,5 +13394,5 @@ function deserializeDarkSwapMessage(serializedMessage) {
11791
13394
  };
11792
13395
  }
11793
13396
 
11794
- export { BridgeCreateOrderService, ChainId, DEFAULT_FEE_RATIO, DOMAIN_NOTE, DOMAIN_ORDER_NOTE, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NOTE, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO_PRECISION, GAS_LIMIT_MULTIPLIER, GAS_LIMIT_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCancelOrderService, ProCreateOrderService, ProSwapService, RetailCancelOrderService, RetailCreateOrderService, RetailSwapService, TripleJoinService, WithdrawService, calcFeeAmount, calcNullifier, contractConfig, createNote, createOrderNoteExt, deserializeDarkSwapMessage, generateKeyPair, getFeeRatio, getMerklePathAndRoot, getNoteFooter, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, getNullifierBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot, serializeDarkSwapMessage, validateNoteWithPubKey, validateOrderNoteWithPubKey };
13397
+ export { BridgeCreateOrderService, ChainId, DEFAULT_FEE_RATIO, DOMAIN_NOTE, DOMAIN_ORDER_NOTE, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NOTE, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO_PRECISION, GAS_LIMIT_MULTIPLIER, GAS_LIMIT_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCancelOrderService, ProCreateOrderService, ProSwapService, RetailCancelOrderService, RetailCreateOrderService, RetailSwapService, TripleJoinService, WithdrawService, calcFeeAmount, calcNullifier, contractConfig, createNote, createOrderNoteExt, deserializeDarkSwapMessage, generateKeyPair, getConfirmations, getFeeRatio, getMerklePathAndRoot, getNoteFooter, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, getNullifierBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteCreated, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot, serializeDarkSwapMessage, validateNoteWithPubKey, validateOrderNoteWithPubKey };
11795
13398
  //# sourceMappingURL=darkswap-sdk.esm.js.map