@imtbl/sdk 1.13.4 → 1.13.5

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.
Files changed (35) hide show
  1. package/dist/blockchain_data.js +2 -2
  2. package/dist/browser/checkout/{BridgeWidget-dcd71ca9.js → BridgeWidget-cefd712d.js} +1 -1
  3. package/dist/browser/checkout/{OnRampWidget-77b9252b.js → OnRampWidget-b4266e39.js} +1 -1
  4. package/dist/browser/checkout/{SaleWidget-22aeb5cf.js → SaleWidget-f9be8158.js} +1 -1
  5. package/dist/browser/checkout/{SpendingCapHero-30560501.js → SpendingCapHero-11f0e68a.js} +1 -1
  6. package/dist/browser/checkout/{SwapWidget-e566f294.js → SwapWidget-c5f9f041.js} +1 -1
  7. package/dist/browser/checkout/{TopUpView-d3059efc.js → TopUpView-6927b26e.js} +1 -1
  8. package/dist/browser/checkout/{WalletWidget-466870cf.js → WalletWidget-a17d0cc5.js} +1 -1
  9. package/dist/browser/checkout/{auto-track-ef86ef9d.js → auto-track-ed70ee8a.js} +1 -1
  10. package/dist/browser/checkout/{balance-ce9feed9.js → balance-1abfdac7.js} +1 -1
  11. package/dist/browser/checkout/{index-c96b2810.js → index-0a30f623.js} +1 -1
  12. package/dist/browser/checkout/{index-540ecd2d.js → index-0c572918.js} +1 -1
  13. package/dist/browser/checkout/{index-ba874b79.js → index-1d43d6f2.js} +1 -1
  14. package/dist/browser/checkout/{index-f315a31c.js → index-691f5ce8.js} +1 -1
  15. package/dist/browser/checkout/{index-187db549.js → index-cf3b56ee.js} +1 -1
  16. package/dist/browser/checkout/{index-96ca7ad4.js → index-d4117464.js} +15 -15
  17. package/dist/browser/checkout/index-f0366ae9.js +1 -0
  18. package/dist/browser/checkout/{index-11477845.js → index-f32be3af.js} +1 -1
  19. package/dist/browser/checkout/{index.umd-6c8a7698.js → index.umd-b2a4cb81.js} +1 -1
  20. package/dist/browser/checkout/{retry-50c84c29.js → retry-0087cf02.js} +1 -1
  21. package/dist/browser/checkout/sdk.js +7 -7
  22. package/dist/browser/checkout/{useTransakEvents-1f3a3223.js → useTransakEvents-52c867f2.js} +1 -1
  23. package/dist/browser/checkout/widgets-esm.js +1 -1
  24. package/dist/browser/checkout/widgets.js +74 -74
  25. package/dist/checkout.js +99 -55
  26. package/dist/config.js +1 -1
  27. package/dist/index.browser.js +5 -5
  28. package/dist/index.browser.js.map +1 -1
  29. package/dist/index.cjs +101 -57
  30. package/dist/index.js +101 -57
  31. package/dist/orderbook.js +1 -1
  32. package/dist/passport.js +3 -3
  33. package/dist/x.js +2 -2
  34. package/package.json +1 -1
  35. package/dist/browser/checkout/index-dfc1ffda.js +0 -1
package/dist/index.cjs CHANGED
@@ -174,7 +174,7 @@ const flattenProperties$1 = (properties) => {
174
174
  };
175
175
 
176
176
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
177
- const SDK_VERSION$1 = '1.13.4';
177
+ const SDK_VERSION$1 = '1.13.5';
178
178
  const getReferrer$1 = () => {
179
179
  if (isNode$1()) {
180
180
  return '';
@@ -10603,7 +10603,7 @@ class MultiRollupApiClients {
10603
10603
  }
10604
10604
 
10605
10605
  // eslint-disable-next-line @typescript-eslint/naming-convention
10606
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.13.4' };
10606
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.13.5' };
10607
10607
  const createConfig = ({ basePath, headers, }) => {
10608
10608
  if (!basePath.trim()) {
10609
10609
  throw Error('basePath can not be empty');
@@ -10675,7 +10675,7 @@ class APIError extends Error {
10675
10675
 
10676
10676
  /* eslint-disable implicit-arrow-linebreak */
10677
10677
  const defaultHeaders = {
10678
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.4',
10678
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.5',
10679
10679
  };
10680
10680
  /**
10681
10681
  * createAPIConfiguration to create a custom Configuration
@@ -11158,7 +11158,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11158
11158
  chainID,
11159
11159
  coreContractAddress,
11160
11160
  registrationContractAddress,
11161
- sdkVersion: 'ts-immutable-sdk-1.13.4',
11161
+ sdkVersion: 'ts-immutable-sdk-1.13.5',
11162
11162
  });
11163
11163
  /**
11164
11164
  * Sets `sdkVersion` at the time of build
@@ -35672,6 +35672,9 @@ class TokenBridge {
35672
35672
  if (req.action !== BridgeFeeActions.FINALISE_WITHDRAWAL) {
35673
35673
  await this.validateChainIds(req.sourceChainId, req.destinationChainId);
35674
35674
  }
35675
+ return await this.getFeePrivate(req);
35676
+ }
35677
+ async getFeePrivate(req) {
35675
35678
  if (req.action === BridgeFeeActions.DEPOSIT && req.sourceChainId !== this.config.bridgeInstance.rootChainID) {
35676
35679
  throw new BridgeError(`Deposit must be from the root chain (${this.config.bridgeInstance.rootChainID}) to the child chain (${this.config.bridgeInstance.childChainID})`, BridgeErrorType.UNSUPPORTED_ERROR);
35677
35680
  }
@@ -35708,6 +35711,21 @@ class TokenBridge {
35708
35711
  totalFees,
35709
35712
  };
35710
35713
  }
35714
+ async getSimulatedTx(provider, dummyAddress, amount, token, sourceChainId, bridgeFee) {
35715
+ const getContractRes = await this.getBridgeContract(sourceChainId);
35716
+ const data = await this.getTxData(dummyAddress, dummyAddress, amount, token, sourceChainId);
35717
+ const feeData = await provider.getFeeData();
35718
+ const gasPriceInWei = getGasPriceInWei$1(feeData) ?? BigNumber.from(0);
35719
+ const txValue = (token.toUpperCase() !== 'NATIVE') ? bridgeFee.toString() : amount.add(bridgeFee).toString();
35720
+ return {
35721
+ data,
35722
+ from: dummyAddress,
35723
+ to: getContractRes.contractAddress,
35724
+ value: txValue,
35725
+ chainId: parseInt(sourceChainId, 10),
35726
+ gasPrice: gasPriceInWei,
35727
+ };
35728
+ }
35711
35729
  // eslint-disable-next-line class-methods-use-this
35712
35730
  async getGasEstimates(provider, txnGasLimitInWei) {
35713
35731
  const feeData = await provider.getFeeData();
@@ -35764,6 +35782,9 @@ class TokenBridge {
35764
35782
  */
35765
35783
  async getUnsignedApproveBridgeTx(req) {
35766
35784
  await this.validateChainConfiguration();
35785
+ return await this.getUnsignedApproveBridgeTxPrivate(req);
35786
+ }
35787
+ async getUnsignedApproveBridgeTxPrivate(req) {
35767
35788
  await this.validateDepositArgs(req.token, req.senderAddress, req.amount, req.sourceChainId, req.destinationChainId);
35768
35789
  // If the token is NATIVE, no approval is required
35769
35790
  if (req.token.toUpperCase() === 'NATIVE') {
@@ -35814,6 +35835,66 @@ class TokenBridge {
35814
35835
  unsignedTx,
35815
35836
  };
35816
35837
  }
35838
+ async getBridgeContract(sourceChainId) {
35839
+ let contract;
35840
+ let contractMethods;
35841
+ let contractAddress;
35842
+ let contractAction;
35843
+ if (sourceChainId === this.config.bridgeInstance.rootChainID) {
35844
+ contractAction = BridgeFeeActions.DEPOSIT;
35845
+ contractMethods = bridgeMethods.deposit;
35846
+ contractAddress = this.config.bridgeContracts.rootERC20BridgeFlowRate;
35847
+ contract = await withBridgeError(async () => {
35848
+ const rootContract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
35849
+ return rootContract;
35850
+ }, BridgeErrorType.INTERNAL_ERROR);
35851
+ }
35852
+ else {
35853
+ contractAction = BridgeFeeActions.WITHDRAW;
35854
+ contractMethods = bridgeMethods.withdraw;
35855
+ contractAddress = this.config.bridgeContracts.childERC20Bridge;
35856
+ contract = await withBridgeError(async () => {
35857
+ const childContract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE, this.config.childProvider);
35858
+ return childContract;
35859
+ }, BridgeErrorType.INTERNAL_ERROR);
35860
+ }
35861
+ return {
35862
+ contract,
35863
+ contractAction,
35864
+ contractMethods,
35865
+ contractAddress,
35866
+ };
35867
+ }
35868
+ async getTxData(sender, recipient, amount, token, sourceChainId) {
35869
+ const getContractRes = await this.getBridgeContract(sourceChainId);
35870
+ // Handle return if it is a native token
35871
+ if (token.toUpperCase() === 'NATIVE') {
35872
+ // Encode the function data into a payload
35873
+ let data;
35874
+ if (sender === recipient) {
35875
+ console.log('native deposit');
35876
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.native, [amount]), BridgeErrorType.INTERNAL_ERROR);
35877
+ }
35878
+ else {
35879
+ console.log('native depositTo');
35880
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.nativeTo, [recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35881
+ }
35882
+ return data;
35883
+ }
35884
+ // Handle return for ERC20
35885
+ const erc20Token = getAddress(token);
35886
+ // Encode the function data into a payload
35887
+ let data;
35888
+ if (sender === recipient) {
35889
+ console.log('token deposit');
35890
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.token, [erc20Token, amount]), BridgeErrorType.INTERNAL_ERROR);
35891
+ }
35892
+ else {
35893
+ console.log('token depositTo');
35894
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.tokenTo, [erc20Token, recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35895
+ }
35896
+ return data;
35897
+ }
35817
35898
  /**
35818
35899
  * Generates an unsigned deposit or withdrawal transaction for a user to sign and submit to the bridge.
35819
35900
  * Must be called after bridgeSdk.getUnsignedApproveBridgeTx to ensure user has approved sufficient tokens for deposit.
@@ -35889,18 +35970,7 @@ class TokenBridge {
35889
35970
  // Convert the addresses to correct format addresses (e.g. prepend 0x if not already)
35890
35971
  const receipient = getAddress(req.recipientAddress);
35891
35972
  const sender = getAddress(req.senderAddress);
35892
- if (req.sourceChainId === this.config.bridgeInstance.rootChainID) {
35893
- const rootBridge = await withBridgeError(async () => {
35894
- const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE);
35895
- return contract;
35896
- }, BridgeErrorType.INTERNAL_ERROR);
35897
- return this.getBridgeTx(sender, receipient, req.amount, req.token, rootBridge, bridgeMethods.deposit, this.config.bridgeContracts.rootERC20BridgeFlowRate, req.sourceChainId, req.destinationChainId, BridgeFeeActions.DEPOSIT, this.config.rootProvider, req.gasMultiplier);
35898
- }
35899
- const childBridge = await withBridgeError(async () => {
35900
- const contract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE);
35901
- return contract;
35902
- }, BridgeErrorType.INTERNAL_ERROR);
35903
- return this.getBridgeTx(sender, receipient, req.amount, req.token, childBridge, bridgeMethods.withdraw, this.config.bridgeContracts.childERC20Bridge, req.sourceChainId, req.destinationChainId, BridgeFeeActions.WITHDRAW, this.config.childProvider, req.gasMultiplier);
35973
+ return this.getBridgeTx(sender, receipient, req.amount, req.token, req.sourceChainId, req.destinationChainId, this.config.rootProvider, req.gasMultiplier);
35904
35974
  }
35905
35975
  async checkReceiver(provider, address) {
35906
35976
  const ABI = ['function receive()'];
@@ -35926,55 +35996,29 @@ class TokenBridge {
35926
35996
  }
35927
35997
  }
35928
35998
  }
35929
- async getBridgeTx(sender, recipient, amount, token, contract, contractMethods, contractAddress, sourceChainId, destinationChainId, action, provider, gasMultiplier = 1.1) {
35930
- const fees = await this.getFee({
35931
- action,
35999
+ async getBridgeTx(sender, recipient, amount, token, sourceChainId, destinationChainId, provider, gasMultiplier = 1.1) {
36000
+ const canReceive = await this.checkReceiver(provider, recipient);
36001
+ if (!canReceive) {
36002
+ throw new BridgeError(`address ${recipient} is not a valid receipient`, BridgeErrorType.INVALID_RECIPIENT);
36003
+ }
36004
+ const getContractRes = await this.getBridgeContract(sourceChainId);
36005
+ const fees = await this.getFeePrivate({
36006
+ action: getContractRes.contractAction,
35932
36007
  gasMultiplier,
35933
36008
  sourceChainId,
35934
36009
  destinationChainId,
35935
36010
  token,
35936
36011
  amount,
35937
36012
  });
35938
- const canReceive = await this.checkReceiver(provider, recipient);
35939
- if (!canReceive) {
35940
- throw new BridgeError(`address ${recipient} is not a valid receipient`, BridgeErrorType.INVALID_RECIPIENT);
35941
- }
35942
- // Handle return if it is a native token
35943
- if (token.toUpperCase() === 'NATIVE') {
35944
- // Encode the function data into a payload
35945
- let data;
35946
- if (sender === recipient) {
35947
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.native, [amount]), BridgeErrorType.INTERNAL_ERROR);
35948
- }
35949
- else {
35950
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.nativeTo, [recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35951
- }
35952
- return {
35953
- feeData: fees,
35954
- unsignedTx: {
35955
- data,
35956
- to: contractAddress,
35957
- value: amount.add(fees.bridgeFee).toString(),
35958
- chainId: parseInt(sourceChainId, 10),
35959
- },
35960
- };
35961
- }
35962
- // Handle return for ERC20
35963
- const erc20Token = getAddress(token);
35964
- // Encode the function data into a payload
35965
- let data;
35966
- if (sender === recipient) {
35967
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.token, [erc20Token, amount]), BridgeErrorType.INTERNAL_ERROR);
35968
- }
35969
- else {
35970
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.tokenTo, [erc20Token, recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35971
- }
36013
+ const data = await this.getTxData(sender, recipient, amount, token, sourceChainId);
36014
+ const txValue = (token.toUpperCase() !== 'NATIVE')
36015
+ ? fees.bridgeFee.toString() : amount.add(fees.bridgeFee).toString();
35972
36016
  return {
35973
36017
  feeData: fees,
35974
36018
  unsignedTx: {
35975
36019
  data,
35976
- to: contractAddress,
35977
- value: fees.bridgeFee.toString(),
36020
+ to: getContractRes.contractAddress,
36021
+ value: txValue,
35978
36022
  chainId: parseInt(sourceChainId, 10),
35979
36023
  },
35980
36024
  };
@@ -36901,7 +36945,7 @@ const flattenProperties = (properties) => {
36901
36945
  };
36902
36946
 
36903
36947
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
36904
- const SDK_VERSION = '1.13.4';
36948
+ const SDK_VERSION = '1.13.5';
36905
36949
  const getReferrer = () => {
36906
36950
  if (isNode()) {
36907
36951
  return '';
@@ -42077,7 +42121,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
42077
42121
  maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
42078
42122
  };
42079
42123
 
42080
- const SDK_VERSION_MARKER = '1.13.4';
42124
+ const SDK_VERSION_MARKER = '1.13.5';
42081
42125
  // This SDK version is replaced by the `yarn build` command ran on the root level
42082
42126
  const globalPackageVersion = () => SDK_VERSION_MARKER;
42083
42127
 
package/dist/index.js CHANGED
@@ -152,7 +152,7 @@ const flattenProperties$1 = (properties) => {
152
152
  };
153
153
 
154
154
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
155
- const SDK_VERSION$1 = '1.13.4';
155
+ const SDK_VERSION$1 = '1.13.5';
156
156
  const getReferrer$1 = () => {
157
157
  if (isNode$1()) {
158
158
  return '';
@@ -10581,7 +10581,7 @@ class MultiRollupApiClients {
10581
10581
  }
10582
10582
 
10583
10583
  // eslint-disable-next-line @typescript-eslint/naming-convention
10584
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.13.4' };
10584
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.13.5' };
10585
10585
  const createConfig = ({ basePath, headers, }) => {
10586
10586
  if (!basePath.trim()) {
10587
10587
  throw Error('basePath can not be empty');
@@ -10653,7 +10653,7 @@ class APIError extends Error {
10653
10653
 
10654
10654
  /* eslint-disable implicit-arrow-linebreak */
10655
10655
  const defaultHeaders = {
10656
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.4',
10656
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.5',
10657
10657
  };
10658
10658
  /**
10659
10659
  * createAPIConfiguration to create a custom Configuration
@@ -11136,7 +11136,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11136
11136
  chainID,
11137
11137
  coreContractAddress,
11138
11138
  registrationContractAddress,
11139
- sdkVersion: 'ts-immutable-sdk-1.13.4',
11139
+ sdkVersion: 'ts-immutable-sdk-1.13.5',
11140
11140
  });
11141
11141
  /**
11142
11142
  * Sets `sdkVersion` at the time of build
@@ -35650,6 +35650,9 @@ class TokenBridge {
35650
35650
  if (req.action !== BridgeFeeActions.FINALISE_WITHDRAWAL) {
35651
35651
  await this.validateChainIds(req.sourceChainId, req.destinationChainId);
35652
35652
  }
35653
+ return await this.getFeePrivate(req);
35654
+ }
35655
+ async getFeePrivate(req) {
35653
35656
  if (req.action === BridgeFeeActions.DEPOSIT && req.sourceChainId !== this.config.bridgeInstance.rootChainID) {
35654
35657
  throw new BridgeError(`Deposit must be from the root chain (${this.config.bridgeInstance.rootChainID}) to the child chain (${this.config.bridgeInstance.childChainID})`, BridgeErrorType.UNSUPPORTED_ERROR);
35655
35658
  }
@@ -35686,6 +35689,21 @@ class TokenBridge {
35686
35689
  totalFees,
35687
35690
  };
35688
35691
  }
35692
+ async getSimulatedTx(provider, dummyAddress, amount, token, sourceChainId, bridgeFee) {
35693
+ const getContractRes = await this.getBridgeContract(sourceChainId);
35694
+ const data = await this.getTxData(dummyAddress, dummyAddress, amount, token, sourceChainId);
35695
+ const feeData = await provider.getFeeData();
35696
+ const gasPriceInWei = getGasPriceInWei$1(feeData) ?? BigNumber.from(0);
35697
+ const txValue = (token.toUpperCase() !== 'NATIVE') ? bridgeFee.toString() : amount.add(bridgeFee).toString();
35698
+ return {
35699
+ data,
35700
+ from: dummyAddress,
35701
+ to: getContractRes.contractAddress,
35702
+ value: txValue,
35703
+ chainId: parseInt(sourceChainId, 10),
35704
+ gasPrice: gasPriceInWei,
35705
+ };
35706
+ }
35689
35707
  // eslint-disable-next-line class-methods-use-this
35690
35708
  async getGasEstimates(provider, txnGasLimitInWei) {
35691
35709
  const feeData = await provider.getFeeData();
@@ -35742,6 +35760,9 @@ class TokenBridge {
35742
35760
  */
35743
35761
  async getUnsignedApproveBridgeTx(req) {
35744
35762
  await this.validateChainConfiguration();
35763
+ return await this.getUnsignedApproveBridgeTxPrivate(req);
35764
+ }
35765
+ async getUnsignedApproveBridgeTxPrivate(req) {
35745
35766
  await this.validateDepositArgs(req.token, req.senderAddress, req.amount, req.sourceChainId, req.destinationChainId);
35746
35767
  // If the token is NATIVE, no approval is required
35747
35768
  if (req.token.toUpperCase() === 'NATIVE') {
@@ -35792,6 +35813,66 @@ class TokenBridge {
35792
35813
  unsignedTx,
35793
35814
  };
35794
35815
  }
35816
+ async getBridgeContract(sourceChainId) {
35817
+ let contract;
35818
+ let contractMethods;
35819
+ let contractAddress;
35820
+ let contractAction;
35821
+ if (sourceChainId === this.config.bridgeInstance.rootChainID) {
35822
+ contractAction = BridgeFeeActions.DEPOSIT;
35823
+ contractMethods = bridgeMethods.deposit;
35824
+ contractAddress = this.config.bridgeContracts.rootERC20BridgeFlowRate;
35825
+ contract = await withBridgeError(async () => {
35826
+ const rootContract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
35827
+ return rootContract;
35828
+ }, BridgeErrorType.INTERNAL_ERROR);
35829
+ }
35830
+ else {
35831
+ contractAction = BridgeFeeActions.WITHDRAW;
35832
+ contractMethods = bridgeMethods.withdraw;
35833
+ contractAddress = this.config.bridgeContracts.childERC20Bridge;
35834
+ contract = await withBridgeError(async () => {
35835
+ const childContract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE, this.config.childProvider);
35836
+ return childContract;
35837
+ }, BridgeErrorType.INTERNAL_ERROR);
35838
+ }
35839
+ return {
35840
+ contract,
35841
+ contractAction,
35842
+ contractMethods,
35843
+ contractAddress,
35844
+ };
35845
+ }
35846
+ async getTxData(sender, recipient, amount, token, sourceChainId) {
35847
+ const getContractRes = await this.getBridgeContract(sourceChainId);
35848
+ // Handle return if it is a native token
35849
+ if (token.toUpperCase() === 'NATIVE') {
35850
+ // Encode the function data into a payload
35851
+ let data;
35852
+ if (sender === recipient) {
35853
+ console.log('native deposit');
35854
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.native, [amount]), BridgeErrorType.INTERNAL_ERROR);
35855
+ }
35856
+ else {
35857
+ console.log('native depositTo');
35858
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.nativeTo, [recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35859
+ }
35860
+ return data;
35861
+ }
35862
+ // Handle return for ERC20
35863
+ const erc20Token = getAddress(token);
35864
+ // Encode the function data into a payload
35865
+ let data;
35866
+ if (sender === recipient) {
35867
+ console.log('token deposit');
35868
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.token, [erc20Token, amount]), BridgeErrorType.INTERNAL_ERROR);
35869
+ }
35870
+ else {
35871
+ console.log('token depositTo');
35872
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.tokenTo, [erc20Token, recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35873
+ }
35874
+ return data;
35875
+ }
35795
35876
  /**
35796
35877
  * Generates an unsigned deposit or withdrawal transaction for a user to sign and submit to the bridge.
35797
35878
  * Must be called after bridgeSdk.getUnsignedApproveBridgeTx to ensure user has approved sufficient tokens for deposit.
@@ -35867,18 +35948,7 @@ class TokenBridge {
35867
35948
  // Convert the addresses to correct format addresses (e.g. prepend 0x if not already)
35868
35949
  const receipient = getAddress(req.recipientAddress);
35869
35950
  const sender = getAddress(req.senderAddress);
35870
- if (req.sourceChainId === this.config.bridgeInstance.rootChainID) {
35871
- const rootBridge = await withBridgeError(async () => {
35872
- const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE);
35873
- return contract;
35874
- }, BridgeErrorType.INTERNAL_ERROR);
35875
- return this.getBridgeTx(sender, receipient, req.amount, req.token, rootBridge, bridgeMethods.deposit, this.config.bridgeContracts.rootERC20BridgeFlowRate, req.sourceChainId, req.destinationChainId, BridgeFeeActions.DEPOSIT, this.config.rootProvider, req.gasMultiplier);
35876
- }
35877
- const childBridge = await withBridgeError(async () => {
35878
- const contract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE);
35879
- return contract;
35880
- }, BridgeErrorType.INTERNAL_ERROR);
35881
- return this.getBridgeTx(sender, receipient, req.amount, req.token, childBridge, bridgeMethods.withdraw, this.config.bridgeContracts.childERC20Bridge, req.sourceChainId, req.destinationChainId, BridgeFeeActions.WITHDRAW, this.config.childProvider, req.gasMultiplier);
35951
+ return this.getBridgeTx(sender, receipient, req.amount, req.token, req.sourceChainId, req.destinationChainId, this.config.rootProvider, req.gasMultiplier);
35882
35952
  }
35883
35953
  async checkReceiver(provider, address) {
35884
35954
  const ABI = ['function receive()'];
@@ -35904,55 +35974,29 @@ class TokenBridge {
35904
35974
  }
35905
35975
  }
35906
35976
  }
35907
- async getBridgeTx(sender, recipient, amount, token, contract, contractMethods, contractAddress, sourceChainId, destinationChainId, action, provider, gasMultiplier = 1.1) {
35908
- const fees = await this.getFee({
35909
- action,
35977
+ async getBridgeTx(sender, recipient, amount, token, sourceChainId, destinationChainId, provider, gasMultiplier = 1.1) {
35978
+ const canReceive = await this.checkReceiver(provider, recipient);
35979
+ if (!canReceive) {
35980
+ throw new BridgeError(`address ${recipient} is not a valid receipient`, BridgeErrorType.INVALID_RECIPIENT);
35981
+ }
35982
+ const getContractRes = await this.getBridgeContract(sourceChainId);
35983
+ const fees = await this.getFeePrivate({
35984
+ action: getContractRes.contractAction,
35910
35985
  gasMultiplier,
35911
35986
  sourceChainId,
35912
35987
  destinationChainId,
35913
35988
  token,
35914
35989
  amount,
35915
35990
  });
35916
- const canReceive = await this.checkReceiver(provider, recipient);
35917
- if (!canReceive) {
35918
- throw new BridgeError(`address ${recipient} is not a valid receipient`, BridgeErrorType.INVALID_RECIPIENT);
35919
- }
35920
- // Handle return if it is a native token
35921
- if (token.toUpperCase() === 'NATIVE') {
35922
- // Encode the function data into a payload
35923
- let data;
35924
- if (sender === recipient) {
35925
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.native, [amount]), BridgeErrorType.INTERNAL_ERROR);
35926
- }
35927
- else {
35928
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.nativeTo, [recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35929
- }
35930
- return {
35931
- feeData: fees,
35932
- unsignedTx: {
35933
- data,
35934
- to: contractAddress,
35935
- value: amount.add(fees.bridgeFee).toString(),
35936
- chainId: parseInt(sourceChainId, 10),
35937
- },
35938
- };
35939
- }
35940
- // Handle return for ERC20
35941
- const erc20Token = getAddress(token);
35942
- // Encode the function data into a payload
35943
- let data;
35944
- if (sender === recipient) {
35945
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.token, [erc20Token, amount]), BridgeErrorType.INTERNAL_ERROR);
35946
- }
35947
- else {
35948
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.tokenTo, [erc20Token, recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
35949
- }
35991
+ const data = await this.getTxData(sender, recipient, amount, token, sourceChainId);
35992
+ const txValue = (token.toUpperCase() !== 'NATIVE')
35993
+ ? fees.bridgeFee.toString() : amount.add(fees.bridgeFee).toString();
35950
35994
  return {
35951
35995
  feeData: fees,
35952
35996
  unsignedTx: {
35953
35997
  data,
35954
- to: contractAddress,
35955
- value: fees.bridgeFee.toString(),
35998
+ to: getContractRes.contractAddress,
35999
+ value: txValue,
35956
36000
  chainId: parseInt(sourceChainId, 10),
35957
36001
  },
35958
36002
  };
@@ -36879,7 +36923,7 @@ const flattenProperties = (properties) => {
36879
36923
  };
36880
36924
 
36881
36925
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
36882
- const SDK_VERSION = '1.13.4';
36926
+ const SDK_VERSION = '1.13.5';
36883
36927
  const getReferrer = () => {
36884
36928
  if (isNode()) {
36885
36929
  return '';
@@ -42055,7 +42099,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
42055
42099
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
42056
42100
  };
42057
42101
 
42058
- const SDK_VERSION_MARKER = '1.13.4';
42102
+ const SDK_VERSION_MARKER = '1.13.5';
42059
42103
  // This SDK version is replaced by the `yarn build` command ran on the root level
42060
42104
  const globalPackageVersion = () => SDK_VERSION_MARKER;
42061
42105
 
package/dist/orderbook.js CHANGED
@@ -131,7 +131,7 @@ const flattenProperties = (properties) => {
131
131
  };
132
132
 
133
133
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
134
- const SDK_VERSION = '1.13.4';
134
+ const SDK_VERSION = '1.13.5';
135
135
  const getReferrer = () => {
136
136
  if (isNode()) {
137
137
  return '';
package/dist/passport.js CHANGED
@@ -8399,7 +8399,7 @@ class MultiRollupApiClients {
8399
8399
  }
8400
8400
 
8401
8401
  // eslint-disable-next-line @typescript-eslint/naming-convention
8402
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.13.4' };
8402
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.13.5' };
8403
8403
  const createConfig = ({ basePath, headers, }) => {
8404
8404
  if (!basePath.trim()) {
8405
8405
  throw Error('basePath can not be empty');
@@ -8578,7 +8578,7 @@ const flattenProperties = (properties) => {
8578
8578
  };
8579
8579
 
8580
8580
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
8581
- const SDK_VERSION = '1.13.4';
8581
+ const SDK_VERSION = '1.13.5';
8582
8582
  const getReferrer = () => {
8583
8583
  if (isNode()) {
8584
8584
  return '';
@@ -8797,7 +8797,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
8797
8797
  chainID,
8798
8798
  coreContractAddress,
8799
8799
  registrationContractAddress,
8800
- sdkVersion: 'ts-immutable-sdk-1.13.4',
8800
+ sdkVersion: 'ts-immutable-sdk-1.13.5',
8801
8801
  });
8802
8802
  /**
8803
8803
  * Sets `sdkVersion` at the time of build
package/dist/x.js CHANGED
@@ -136,7 +136,7 @@ const flattenProperties = (properties) => {
136
136
  };
137
137
 
138
138
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
139
- const SDK_VERSION = '1.13.4';
139
+ const SDK_VERSION = '1.13.5';
140
140
  const getReferrer = () => {
141
141
  if (isNode()) {
142
142
  return '';
@@ -334,7 +334,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
334
334
  chainID,
335
335
  coreContractAddress,
336
336
  registrationContractAddress,
337
- sdkVersion: 'ts-immutable-sdk-1.13.4',
337
+ sdkVersion: 'ts-immutable-sdk-1.13.5',
338
338
  });
339
339
  /**
340
340
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "1.13.4",
4
+ "version": "1.13.5",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
@@ -1 +0,0 @@
1
- import{bT as n,bU as t}from"./index-96ca7ad4.js";function i(i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return[4,import("./index.umd-6c8a7698.js").then((function(n){return n.i}))];case 1:return n=t.sent(),i._plugins=n,[2]}}))}))}export{i as loadLegacyVideoPlugins};