@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/checkout.js CHANGED
@@ -139,7 +139,7 @@ const flattenProperties$1 = (properties) => {
139
139
  };
140
140
 
141
141
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
142
- const SDK_VERSION$1 = '1.13.4';
142
+ const SDK_VERSION$1 = '1.13.5';
143
143
  const getReferrer$1 = () => {
144
144
  if (isNode$1()) {
145
145
  return '';
@@ -16273,6 +16273,9 @@ class TokenBridge {
16273
16273
  if (req.action !== BridgeFeeActions.FINALISE_WITHDRAWAL) {
16274
16274
  await this.validateChainIds(req.sourceChainId, req.destinationChainId);
16275
16275
  }
16276
+ return await this.getFeePrivate(req);
16277
+ }
16278
+ async getFeePrivate(req) {
16276
16279
  if (req.action === BridgeFeeActions.DEPOSIT && req.sourceChainId !== this.config.bridgeInstance.rootChainID) {
16277
16280
  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);
16278
16281
  }
@@ -16309,6 +16312,21 @@ class TokenBridge {
16309
16312
  totalFees,
16310
16313
  };
16311
16314
  }
16315
+ async getSimulatedTx(provider, dummyAddress, amount, token, sourceChainId, bridgeFee) {
16316
+ const getContractRes = await this.getBridgeContract(sourceChainId);
16317
+ const data = await this.getTxData(dummyAddress, dummyAddress, amount, token, sourceChainId);
16318
+ const feeData = await provider.getFeeData();
16319
+ const gasPriceInWei = getGasPriceInWei$1(feeData) ?? BigNumber.from(0);
16320
+ const txValue = (token.toUpperCase() !== 'NATIVE') ? bridgeFee.toString() : amount.add(bridgeFee).toString();
16321
+ return {
16322
+ data,
16323
+ from: dummyAddress,
16324
+ to: getContractRes.contractAddress,
16325
+ value: txValue,
16326
+ chainId: parseInt(sourceChainId, 10),
16327
+ gasPrice: gasPriceInWei,
16328
+ };
16329
+ }
16312
16330
  // eslint-disable-next-line class-methods-use-this
16313
16331
  async getGasEstimates(provider, txnGasLimitInWei) {
16314
16332
  const feeData = await provider.getFeeData();
@@ -16365,6 +16383,9 @@ class TokenBridge {
16365
16383
  */
16366
16384
  async getUnsignedApproveBridgeTx(req) {
16367
16385
  await this.validateChainConfiguration();
16386
+ return await this.getUnsignedApproveBridgeTxPrivate(req);
16387
+ }
16388
+ async getUnsignedApproveBridgeTxPrivate(req) {
16368
16389
  await this.validateDepositArgs(req.token, req.senderAddress, req.amount, req.sourceChainId, req.destinationChainId);
16369
16390
  // If the token is NATIVE, no approval is required
16370
16391
  if (req.token.toUpperCase() === 'NATIVE') {
@@ -16415,6 +16436,66 @@ class TokenBridge {
16415
16436
  unsignedTx,
16416
16437
  };
16417
16438
  }
16439
+ async getBridgeContract(sourceChainId) {
16440
+ let contract;
16441
+ let contractMethods;
16442
+ let contractAddress;
16443
+ let contractAction;
16444
+ if (sourceChainId === this.config.bridgeInstance.rootChainID) {
16445
+ contractAction = BridgeFeeActions.DEPOSIT;
16446
+ contractMethods = bridgeMethods.deposit;
16447
+ contractAddress = this.config.bridgeContracts.rootERC20BridgeFlowRate;
16448
+ contract = await withBridgeError(async () => {
16449
+ const rootContract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
16450
+ return rootContract;
16451
+ }, BridgeErrorType.INTERNAL_ERROR);
16452
+ }
16453
+ else {
16454
+ contractAction = BridgeFeeActions.WITHDRAW;
16455
+ contractMethods = bridgeMethods.withdraw;
16456
+ contractAddress = this.config.bridgeContracts.childERC20Bridge;
16457
+ contract = await withBridgeError(async () => {
16458
+ const childContract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE, this.config.childProvider);
16459
+ return childContract;
16460
+ }, BridgeErrorType.INTERNAL_ERROR);
16461
+ }
16462
+ return {
16463
+ contract,
16464
+ contractAction,
16465
+ contractMethods,
16466
+ contractAddress,
16467
+ };
16468
+ }
16469
+ async getTxData(sender, recipient, amount, token, sourceChainId) {
16470
+ const getContractRes = await this.getBridgeContract(sourceChainId);
16471
+ // Handle return if it is a native token
16472
+ if (token.toUpperCase() === 'NATIVE') {
16473
+ // Encode the function data into a payload
16474
+ let data;
16475
+ if (sender === recipient) {
16476
+ console.log('native deposit');
16477
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.native, [amount]), BridgeErrorType.INTERNAL_ERROR);
16478
+ }
16479
+ else {
16480
+ console.log('native depositTo');
16481
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.nativeTo, [recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
16482
+ }
16483
+ return data;
16484
+ }
16485
+ // Handle return for ERC20
16486
+ const erc20Token = getAddress(token);
16487
+ // Encode the function data into a payload
16488
+ let data;
16489
+ if (sender === recipient) {
16490
+ console.log('token deposit');
16491
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.token, [erc20Token, amount]), BridgeErrorType.INTERNAL_ERROR);
16492
+ }
16493
+ else {
16494
+ console.log('token depositTo');
16495
+ data = await withBridgeError(async () => getContractRes.contract.interface.encodeFunctionData(getContractRes.contractMethods.tokenTo, [erc20Token, recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
16496
+ }
16497
+ return data;
16498
+ }
16418
16499
  /**
16419
16500
  * Generates an unsigned deposit or withdrawal transaction for a user to sign and submit to the bridge.
16420
16501
  * Must be called after bridgeSdk.getUnsignedApproveBridgeTx to ensure user has approved sufficient tokens for deposit.
@@ -16490,18 +16571,7 @@ class TokenBridge {
16490
16571
  // Convert the addresses to correct format addresses (e.g. prepend 0x if not already)
16491
16572
  const receipient = getAddress(req.recipientAddress);
16492
16573
  const sender = getAddress(req.senderAddress);
16493
- if (req.sourceChainId === this.config.bridgeInstance.rootChainID) {
16494
- const rootBridge = await withBridgeError(async () => {
16495
- const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE);
16496
- return contract;
16497
- }, BridgeErrorType.INTERNAL_ERROR);
16498
- 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);
16499
- }
16500
- const childBridge = await withBridgeError(async () => {
16501
- const contract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE);
16502
- return contract;
16503
- }, BridgeErrorType.INTERNAL_ERROR);
16504
- 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);
16574
+ return this.getBridgeTx(sender, receipient, req.amount, req.token, req.sourceChainId, req.destinationChainId, this.config.rootProvider, req.gasMultiplier);
16505
16575
  }
16506
16576
  async checkReceiver(provider, address) {
16507
16577
  const ABI = ['function receive()'];
@@ -16527,55 +16597,29 @@ class TokenBridge {
16527
16597
  }
16528
16598
  }
16529
16599
  }
16530
- async getBridgeTx(sender, recipient, amount, token, contract, contractMethods, contractAddress, sourceChainId, destinationChainId, action, provider, gasMultiplier = 1.1) {
16531
- const fees = await this.getFee({
16532
- action,
16600
+ async getBridgeTx(sender, recipient, amount, token, sourceChainId, destinationChainId, provider, gasMultiplier = 1.1) {
16601
+ const canReceive = await this.checkReceiver(provider, recipient);
16602
+ if (!canReceive) {
16603
+ throw new BridgeError(`address ${recipient} is not a valid receipient`, BridgeErrorType.INVALID_RECIPIENT);
16604
+ }
16605
+ const getContractRes = await this.getBridgeContract(sourceChainId);
16606
+ const fees = await this.getFeePrivate({
16607
+ action: getContractRes.contractAction,
16533
16608
  gasMultiplier,
16534
16609
  sourceChainId,
16535
16610
  destinationChainId,
16536
16611
  token,
16537
16612
  amount,
16538
16613
  });
16539
- const canReceive = await this.checkReceiver(provider, recipient);
16540
- if (!canReceive) {
16541
- throw new BridgeError(`address ${recipient} is not a valid receipient`, BridgeErrorType.INVALID_RECIPIENT);
16542
- }
16543
- // Handle return if it is a native token
16544
- if (token.toUpperCase() === 'NATIVE') {
16545
- // Encode the function data into a payload
16546
- let data;
16547
- if (sender === recipient) {
16548
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.native, [amount]), BridgeErrorType.INTERNAL_ERROR);
16549
- }
16550
- else {
16551
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.nativeTo, [recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
16552
- }
16553
- return {
16554
- feeData: fees,
16555
- unsignedTx: {
16556
- data,
16557
- to: contractAddress,
16558
- value: amount.add(fees.bridgeFee).toString(),
16559
- chainId: parseInt(sourceChainId, 10),
16560
- },
16561
- };
16562
- }
16563
- // Handle return for ERC20
16564
- const erc20Token = getAddress(token);
16565
- // Encode the function data into a payload
16566
- let data;
16567
- if (sender === recipient) {
16568
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.token, [erc20Token, amount]), BridgeErrorType.INTERNAL_ERROR);
16569
- }
16570
- else {
16571
- data = await withBridgeError(async () => contract.interface.encodeFunctionData(contractMethods.tokenTo, [erc20Token, recipient, amount]), BridgeErrorType.INTERNAL_ERROR);
16572
- }
16614
+ const data = await this.getTxData(sender, recipient, amount, token, sourceChainId);
16615
+ const txValue = (token.toUpperCase() !== 'NATIVE')
16616
+ ? fees.bridgeFee.toString() : amount.add(fees.bridgeFee).toString();
16573
16617
  return {
16574
16618
  feeData: fees,
16575
16619
  unsignedTx: {
16576
16620
  data,
16577
- to: contractAddress,
16578
- value: fees.bridgeFee.toString(),
16621
+ to: getContractRes.contractAddress,
16622
+ value: txValue,
16579
16623
  chainId: parseInt(sourceChainId, 10),
16580
16624
  },
16581
16625
  };
@@ -17502,7 +17546,7 @@ const flattenProperties = (properties) => {
17502
17546
  };
17503
17547
 
17504
17548
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
17505
- const SDK_VERSION = '1.13.4';
17549
+ const SDK_VERSION = '1.13.5';
17506
17550
  const getReferrer = () => {
17507
17551
  if (isNode()) {
17508
17552
  return '';
@@ -27984,7 +28028,7 @@ class APIError extends Error {
27984
28028
 
27985
28029
  /* eslint-disable implicit-arrow-linebreak */
27986
28030
  const defaultHeaders = {
27987
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.4',
28031
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.5',
27988
28032
  };
27989
28033
  /**
27990
28034
  * createAPIConfiguration to create a custom Configuration
@@ -29403,7 +29447,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
29403
29447
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
29404
29448
  };
29405
29449
 
29406
- const SDK_VERSION_MARKER = '1.13.4';
29450
+ const SDK_VERSION_MARKER = '1.13.5';
29407
29451
  // This SDK version is replaced by the `yarn build` command ran on the root level
29408
29452
  const globalPackageVersion = () => SDK_VERSION_MARKER;
29409
29453
 
package/dist/config.js CHANGED
@@ -128,7 +128,7 @@ const flattenProperties = (properties) => {
128
128
  };
129
129
 
130
130
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
131
- const SDK_VERSION = '1.13.4';
131
+ const SDK_VERSION = '1.13.5';
132
132
  const getReferrer = () => {
133
133
  if (isNode()) {
134
134
  return '';