@imtbl/sdk 1.43.2-alpha.8 → 1.43.2-alpha.9

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 (36) hide show
  1. package/dist/blockchain_data.js +2 -2
  2. package/dist/browser/checkout/{BridgeWidget-658e152c.js → BridgeWidget-65a6f548.js} +1 -1
  3. package/dist/browser/checkout/{OnRampWidget-fea8789a.js → OnRampWidget-2ad8527a.js} +1 -1
  4. package/dist/browser/checkout/{SaleWidget-03dd6551.js → SaleWidget-39f46402.js} +1 -1
  5. package/dist/browser/checkout/{SpendingCapHero-220f61bf.js → SpendingCapHero-5ea5ca00.js} +1 -1
  6. package/dist/browser/checkout/{SwapWidget-d09f2ca0.js → SwapWidget-8f257923.js} +1 -1
  7. package/dist/browser/checkout/{TopUpView-4e4983da.js → TopUpView-1ee96622.js} +1 -1
  8. package/dist/browser/checkout/{WalletWidget-28ba6bfb.js → WalletWidget-d34a438a.js} +1 -1
  9. package/dist/browser/checkout/{auto-track-f8c278b4.js → auto-track-4bc18a69.js} +1 -1
  10. package/dist/browser/checkout/{balance-78f9d53c.js → balance-de2a2c73.js} +1 -1
  11. package/dist/browser/checkout/{index-d6bb330e.js → index-1672c9aa.js} +1 -1
  12. package/dist/browser/checkout/{index-a08c7054.js → index-1838fda1.js} +1 -1
  13. package/dist/browser/checkout/{index-963082eb.js → index-2244a7f0.js} +1 -1
  14. package/dist/browser/checkout/{index-1d657ceb.js → index-a5536772.js} +3 -3
  15. package/dist/browser/checkout/{index-a40f8006.js → index-b2a772fc.js} +1 -1
  16. package/dist/browser/checkout/{index-9fbf62cf.js → index-cc166624.js} +1 -1
  17. package/dist/browser/checkout/{index-e6efd23e.js → index-d8d68038.js} +1 -1
  18. package/dist/browser/checkout/index-f426b9fd.js +1 -0
  19. package/dist/browser/checkout/{index.umd-06c44429.js → index.umd-fd3873f7.js} +1 -1
  20. package/dist/browser/checkout/{retry-4841e554.js → retry-f5c958f0.js} +1 -1
  21. package/dist/browser/checkout/sdk.js +5 -5
  22. package/dist/browser/checkout/widgets-esm.js +1 -1
  23. package/dist/browser/checkout/widgets.js +1 -1
  24. package/dist/checkout.js +90 -57
  25. package/dist/config.js +1 -1
  26. package/dist/index.browser.js +5 -5
  27. package/dist/index.browser.js.map +1 -1
  28. package/dist/index.cjs +93 -60
  29. package/dist/index.js +93 -60
  30. package/dist/minting_backend.js +2 -2
  31. package/dist/orderbook.js +1 -1
  32. package/dist/passport.js +4 -4
  33. package/dist/webhook.js +1 -1
  34. package/dist/x.js +3 -3
  35. package/package.json +1 -1
  36. package/dist/browser/checkout/index-0ab42d36.js +0 -1
package/dist/index.cjs CHANGED
@@ -185,7 +185,7 @@ const flattenProperties$1 = (properties) => {
185
185
  };
186
186
 
187
187
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
188
- const SDK_VERSION$1 = '1.43.2-alpha.8';
188
+ const SDK_VERSION$1 = '1.43.2-alpha.9';
189
189
  const getFrameParentDomain$1 = () => {
190
190
  if (isNode$1()) {
191
191
  return '';
@@ -14212,7 +14212,7 @@ class MultiRollupApiClients {
14212
14212
  }
14213
14213
 
14214
14214
  // eslint-disable-next-line @typescript-eslint/naming-convention
14215
- const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
14215
+ const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
14216
14216
  const createConfig$1 = ({ basePath, headers, }) => {
14217
14217
  if (!basePath.trim()) {
14218
14218
  throw Error('basePath can not be empty');
@@ -14284,7 +14284,7 @@ class APIError extends Error {
14284
14284
 
14285
14285
  /* eslint-disable implicit-arrow-linebreak */
14286
14286
  const defaultHeaders$1 = {
14287
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.43.2-alpha.8',
14287
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.43.2-alpha.9',
14288
14288
  };
14289
14289
  /**
14290
14290
  * createAPIConfiguration to create a custom Configuration
@@ -14758,7 +14758,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
14758
14758
  /* eslint-disable @typescript-eslint/naming-convention */
14759
14759
  class ApiConfiguration extends index$2.Configuration {
14760
14760
  }
14761
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
14761
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
14762
14762
  /**
14763
14763
  * @dev use createImmutableXConfiguration instead
14764
14764
  */
@@ -14799,7 +14799,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
14799
14799
  coreContractAddress,
14800
14800
  registrationContractAddress,
14801
14801
  registrationV4ContractAddress,
14802
- sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.8',
14802
+ sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.9',
14803
14803
  baseConfig,
14804
14804
  });
14805
14805
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -47028,13 +47028,8 @@ async function getWithdrawRootToken(childToken, destinationChainId, childProvide
47028
47028
  }
47029
47029
 
47030
47030
  /* eslint-disable @typescript-eslint/naming-convention */
47031
- // TODO generate a type for these state objects. Readability could be improved from the double nested Record
47032
47031
  /**
47033
- * Submits tenderly simulations, returning an array of gas usage estimates
47034
- * @param chainId ID of network to estimate transactions on
47035
- * @param simulations Array of TenderlySimulation objects (transactions) to estimate gas usage for
47036
- * @param state_objects A double-nested record which can be used to change the state of smart contracts in the simulation.
47037
- * @returns Array of gas usage estimates.
47032
+ * We want to convert a StateObject type to the following format (Record<string, Record<string, Record<string, string>>>):
47038
47033
  * @example An example of a state object that changes the state at slot 0xe1b959...2585e to 1 at address 0xe43215...8E31:
47039
47034
  * {
47040
47035
  * "0xe432150cce91c13a887f7D836923d5597adD8E31": {
@@ -47045,9 +47040,32 @@ async function getWithdrawRootToken(childToken, destinationChainId, childProvide
47045
47040
  * }
47046
47041
  * }
47047
47042
  */
47048
- async function submitTenderlySimulations(chainId, simulations, state_objects) {
47043
+ function unwrapStateObjects(stateObjects) {
47044
+ const unwrappedStateObjects = {};
47045
+ stateObjects.forEach((stateObject) => {
47046
+ const { contractAddress, stateDiff } = stateObject;
47047
+ const { storageSlot, value } = stateDiff;
47048
+ if (unwrappedStateObjects[contractAddress] === undefined) {
47049
+ unwrappedStateObjects[contractAddress] = {
47050
+ stateDiff: {},
47051
+ };
47052
+ }
47053
+ unwrappedStateObjects[contractAddress].stateDiff[storageSlot] = value;
47054
+ });
47055
+ return unwrappedStateObjects;
47056
+ }
47057
+ /**
47058
+ * Submits tenderly simulations, returning an array of gas usage estimates
47059
+ * @param chainId ID of network to estimate transactions on
47060
+ * @param simulations Array of TenderlySimulation objects (transactions) to estimate gas usage for
47061
+ * @param stateObjects An array of `StateObject`s. Each `StateObject` represents one smart contract state change.
47062
+ * These `StateObject`s get unwrapped into Tenderly's required format.
47063
+ * @returns Array of gas usage estimates.
47064
+ */
47065
+ async function submitTenderlySimulations(chainId, simulations, stateObjects) {
47049
47066
  let axiosResponse;
47050
47067
  const tenderlyAPI = getTenderlyEndpoint(chainId);
47068
+ const state_objects = stateObjects ? unwrapStateObjects(stateObjects) : undefined;
47051
47069
  try {
47052
47070
  axiosResponse = await axios$1.post(tenderlyAPI, {
47053
47071
  jsonrpc: '2.0',
@@ -47087,6 +47105,54 @@ async function submitTenderlySimulations(chainId, simulations, state_objects) {
47087
47105
  return gas;
47088
47106
  }
47089
47107
 
47108
+ const trueInHex = '0x0000000000000000000000000000000000000000000000000000000000000001';
47109
+
47110
+ /**
47111
+ * @param sender Bridge depositer/withdrawer
47112
+ * @param recipient Deposit or withdrawal recipient
47113
+ * @param amount Amount to deposit or withdraw
47114
+ * @param token Token to deposit or withdraw. NATIVE if native asset on the source chain.
47115
+ * @param currentBridgeMethods A Record mapping bridge operation names to contract method names
47116
+ * @param bridgeContract: The bridge contract to be interacting with dependinig on network and if it's a deposit or withdrawal
47117
+ * @returns calldata for the requested bridge transaction (i.e. tx.data)
47118
+ */
47119
+ async function getBridgeTxCalldata(sender, recipient, amount, token, currentBridgeMethods, bridgeContract) {
47120
+ let functionName;
47121
+ let parameters;
47122
+ /**
47123
+ * Handle bridge transaction for native token
47124
+ */
47125
+ if (token.toUpperCase() === NATIVE$1) {
47126
+ if (sender === recipient) {
47127
+ // Deposit or withdraw native token
47128
+ functionName = currentBridgeMethods.native;
47129
+ parameters = [amount];
47130
+ }
47131
+ else {
47132
+ // Deposit or withdraw native token TO
47133
+ functionName = currentBridgeMethods.nativeTo;
47134
+ parameters = [recipient, amount];
47135
+ }
47136
+ }
47137
+ else {
47138
+ /**
47139
+ * Handle bridge transaction for ERC20
47140
+ */
47141
+ const erc20Token = getAddress(token);
47142
+ if (sender === recipient) {
47143
+ // Deposit or withdraw ERC20
47144
+ functionName = currentBridgeMethods.token;
47145
+ parameters = [erc20Token, amount];
47146
+ }
47147
+ else {
47148
+ // Deposit or withdraw ERC20 TO.
47149
+ functionName = currentBridgeMethods.tokenTo;
47150
+ parameters = [erc20Token, recipient, amount];
47151
+ }
47152
+ }
47153
+ return await withBridgeError(async () => bridgeContract.interface.encodeFunctionData(functionName, parameters), BridgeErrorType.INTERNAL_ERROR);
47154
+ }
47155
+
47090
47156
  const ROOT_ERC20_BRIDGE_FLOW_RATE = [
47091
47157
  {
47092
47158
  inputs: [
@@ -50927,43 +50993,10 @@ class TokenBridge {
50927
50993
  * @param sourceChainId Chain ID of the source chain
50928
50994
  * @returns calldata for the requested bridge transaction (i.e. tx.data)
50929
50995
  */
50930
- async getTxData(sender, recipient, amount, token, direction) {
50996
+ async getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction) {
50931
50997
  const currentBridgeMethods = await this.getBridgeMethods(direction);
50932
50998
  const bridgeContract = await this.getBridgeContract(direction);
50933
- let functionName;
50934
- let parameters;
50935
- /**
50936
- * Handle bridge transaction for native token
50937
- */
50938
- if (token.toUpperCase() === NATIVE$1) {
50939
- if (sender === recipient) {
50940
- // Deposit or withdraw native token
50941
- functionName = currentBridgeMethods.native;
50942
- parameters = [amount];
50943
- }
50944
- else {
50945
- // Deposit or withdraw native token TO
50946
- functionName = currentBridgeMethods.nativeTo;
50947
- parameters = [recipient, amount];
50948
- }
50949
- }
50950
- else {
50951
- /**
50952
- * Handle bridge transaction for ERC20
50953
- */
50954
- const erc20Token = getAddress(token);
50955
- if (sender === recipient) {
50956
- // Deposit or withdraw ERC20
50957
- functionName = currentBridgeMethods.token;
50958
- parameters = [erc20Token, amount];
50959
- }
50960
- else {
50961
- // Deposit or withdraw ERC20 TO.
50962
- functionName = currentBridgeMethods.tokenTo;
50963
- parameters = [erc20Token, recipient, amount];
50964
- }
50965
- }
50966
- return await withBridgeError(async () => bridgeContract.interface.encodeFunctionData(functionName, parameters), BridgeErrorType.INTERNAL_ERROR);
50999
+ return getBridgeTxCalldata(sender, recipient, amount, token, currentBridgeMethods, bridgeContract);
50967
51000
  }
50968
51001
  /**
50969
51002
  * Generates an unsigned deposit or withdrawal transaction for a user to sign and submit to the bridge.
@@ -51192,7 +51225,7 @@ class TokenBridge {
51192
51225
  unsignedApprovalTx = null;
51193
51226
  }
51194
51227
  // Deposit transaction & fees.
51195
- const txData = await this.getTxData(sender, recipient, amount, token, direction);
51228
+ const txData = await this.getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction);
51196
51229
  const txValue = (token.toUpperCase() === NATIVE$1)
51197
51230
  ? amount.add(bridgeFee).toString() : bridgeFee.toString();
51198
51231
  const unsignedBridgeTx = {
@@ -51254,7 +51287,7 @@ class TokenBridge {
51254
51287
  unsignedApprovalTx = null;
51255
51288
  }
51256
51289
  // Withdraw transaction & fees.
51257
- const txData = await this.getTxData(sender, recipient, amount, token, direction);
51290
+ const txData = await this.getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction);
51258
51291
  const txValue = (token.toUpperCase() === NATIVE$1)
51259
51292
  ? amount.add(bridgeFee).toString() : bridgeFee.toString();
51260
51293
  const unsignedBridgeTx = {
@@ -51303,7 +51336,7 @@ class TokenBridge {
51303
51336
  destinationChainId: this.config.bridgeInstance.childChainID,
51304
51337
  };
51305
51338
  // Get tx data
51306
- const txData = await this.getTxData(sender, recipient, amount, token, direction);
51339
+ const txData = await this.getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction);
51307
51340
  // tx value for simulation mocked as amount + 1 wei for a native bridge and 1 wei for token bridges
51308
51341
  // hexValue() is required to remove leading zeros, which tenderly does not support.
51309
51342
  const txValue = (token.toUpperCase() !== NATIVE$1) ? '0x1' : hexValue(amount.add('1').toHexString());
@@ -51339,7 +51372,7 @@ class TokenBridge {
51339
51372
  // Calculate slot key for given command ID.
51340
51373
  const command = defaultAbiCoder.encode(['bytes32', 'bytes32', 'string', 'string', 'address', 'bytes32'], [SLOT_PREFIX_CONTRACT_CALL_APPROVED, commandId, sourceChain, sourceAddress, destinationAddress, payloadHash]);
51341
51374
  const commandHash = keccak256(command);
51342
- const slot = keccak256(concat([
51375
+ const gatewayCallApprovedSlot = keccak256(concat([
51343
51376
  commandHash,
51344
51377
  hexlify(zeroPad(hexlify(SLOT_POS_CONTRACT_CALL_APPROVED), 32)),
51345
51378
  ]));
@@ -51354,14 +51387,14 @@ class TokenBridge {
51354
51387
  to: destinationAddress,
51355
51388
  data: executeData,
51356
51389
  }];
51357
- const gas = await submitTenderlySimulations(destinationChainId, simulations, {
51358
- [axelarGateway]: {
51359
- stateDiff: {
51360
- // Override storage to approve this command.
51361
- [slot]: '0x0000000000000000000000000000000000000000000000000000000000000001',
51362
- },
51390
+ const stateObject = {
51391
+ contractAddress: axelarGateway,
51392
+ stateDiff: {
51393
+ storageSlot: gatewayCallApprovedSlot,
51394
+ value: trueInHex,
51363
51395
  },
51364
- });
51396
+ };
51397
+ const gas = await submitTenderlySimulations(destinationChainId, simulations, [stateObject]);
51365
51398
  return gas[0];
51366
51399
  }
51367
51400
  async getAllowance(direction, token, sender) {
@@ -52235,7 +52268,7 @@ const flattenProperties = (properties) => {
52235
52268
  };
52236
52269
 
52237
52270
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
52238
- const SDK_VERSION = '1.43.2-alpha.8';
52271
+ const SDK_VERSION = '1.43.2-alpha.9';
52239
52272
  const getFrameParentDomain = () => {
52240
52273
  if (isNode()) {
52241
52274
  return '';
@@ -57554,7 +57587,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
57554
57587
  maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
57555
57588
  };
57556
57589
 
57557
- const SDK_VERSION_MARKER = '1.43.2-alpha.8';
57590
+ const SDK_VERSION_MARKER = '1.43.2-alpha.9';
57558
57591
  // This SDK version is replaced by the `yarn build` command ran on the root level
57559
57592
  const globalPackageVersion = () => SDK_VERSION_MARKER;
57560
57593
 
package/dist/index.js CHANGED
@@ -162,7 +162,7 @@ const flattenProperties$1 = (properties) => {
162
162
  };
163
163
 
164
164
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
165
- const SDK_VERSION$1 = '1.43.2-alpha.8';
165
+ const SDK_VERSION$1 = '1.43.2-alpha.9';
166
166
  const getFrameParentDomain$1 = () => {
167
167
  if (isNode$1()) {
168
168
  return '';
@@ -14189,7 +14189,7 @@ class MultiRollupApiClients {
14189
14189
  }
14190
14190
 
14191
14191
  // eslint-disable-next-line @typescript-eslint/naming-convention
14192
- const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
14192
+ const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
14193
14193
  const createConfig$1 = ({ basePath, headers, }) => {
14194
14194
  if (!basePath.trim()) {
14195
14195
  throw Error('basePath can not be empty');
@@ -14261,7 +14261,7 @@ class APIError extends Error {
14261
14261
 
14262
14262
  /* eslint-disable implicit-arrow-linebreak */
14263
14263
  const defaultHeaders$1 = {
14264
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.43.2-alpha.8',
14264
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.43.2-alpha.9',
14265
14265
  };
14266
14266
  /**
14267
14267
  * createAPIConfiguration to create a custom Configuration
@@ -14735,7 +14735,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
14735
14735
  /* eslint-disable @typescript-eslint/naming-convention */
14736
14736
  class ApiConfiguration extends index$2.Configuration {
14737
14737
  }
14738
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
14738
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
14739
14739
  /**
14740
14740
  * @dev use createImmutableXConfiguration instead
14741
14741
  */
@@ -14776,7 +14776,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
14776
14776
  coreContractAddress,
14777
14777
  registrationContractAddress,
14778
14778
  registrationV4ContractAddress,
14779
- sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.8',
14779
+ sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.9',
14780
14780
  baseConfig,
14781
14781
  });
14782
14782
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -47005,13 +47005,8 @@ async function getWithdrawRootToken(childToken, destinationChainId, childProvide
47005
47005
  }
47006
47006
 
47007
47007
  /* eslint-disable @typescript-eslint/naming-convention */
47008
- // TODO generate a type for these state objects. Readability could be improved from the double nested Record
47009
47008
  /**
47010
- * Submits tenderly simulations, returning an array of gas usage estimates
47011
- * @param chainId ID of network to estimate transactions on
47012
- * @param simulations Array of TenderlySimulation objects (transactions) to estimate gas usage for
47013
- * @param state_objects A double-nested record which can be used to change the state of smart contracts in the simulation.
47014
- * @returns Array of gas usage estimates.
47009
+ * We want to convert a StateObject type to the following format (Record<string, Record<string, Record<string, string>>>):
47015
47010
  * @example An example of a state object that changes the state at slot 0xe1b959...2585e to 1 at address 0xe43215...8E31:
47016
47011
  * {
47017
47012
  * "0xe432150cce91c13a887f7D836923d5597adD8E31": {
@@ -47022,9 +47017,32 @@ async function getWithdrawRootToken(childToken, destinationChainId, childProvide
47022
47017
  * }
47023
47018
  * }
47024
47019
  */
47025
- async function submitTenderlySimulations(chainId, simulations, state_objects) {
47020
+ function unwrapStateObjects(stateObjects) {
47021
+ const unwrappedStateObjects = {};
47022
+ stateObjects.forEach((stateObject) => {
47023
+ const { contractAddress, stateDiff } = stateObject;
47024
+ const { storageSlot, value } = stateDiff;
47025
+ if (unwrappedStateObjects[contractAddress] === undefined) {
47026
+ unwrappedStateObjects[contractAddress] = {
47027
+ stateDiff: {},
47028
+ };
47029
+ }
47030
+ unwrappedStateObjects[contractAddress].stateDiff[storageSlot] = value;
47031
+ });
47032
+ return unwrappedStateObjects;
47033
+ }
47034
+ /**
47035
+ * Submits tenderly simulations, returning an array of gas usage estimates
47036
+ * @param chainId ID of network to estimate transactions on
47037
+ * @param simulations Array of TenderlySimulation objects (transactions) to estimate gas usage for
47038
+ * @param stateObjects An array of `StateObject`s. Each `StateObject` represents one smart contract state change.
47039
+ * These `StateObject`s get unwrapped into Tenderly's required format.
47040
+ * @returns Array of gas usage estimates.
47041
+ */
47042
+ async function submitTenderlySimulations(chainId, simulations, stateObjects) {
47026
47043
  let axiosResponse;
47027
47044
  const tenderlyAPI = getTenderlyEndpoint(chainId);
47045
+ const state_objects = stateObjects ? unwrapStateObjects(stateObjects) : undefined;
47028
47046
  try {
47029
47047
  axiosResponse = await axios$1.post(tenderlyAPI, {
47030
47048
  jsonrpc: '2.0',
@@ -47064,6 +47082,54 @@ async function submitTenderlySimulations(chainId, simulations, state_objects) {
47064
47082
  return gas;
47065
47083
  }
47066
47084
 
47085
+ const trueInHex = '0x0000000000000000000000000000000000000000000000000000000000000001';
47086
+
47087
+ /**
47088
+ * @param sender Bridge depositer/withdrawer
47089
+ * @param recipient Deposit or withdrawal recipient
47090
+ * @param amount Amount to deposit or withdraw
47091
+ * @param token Token to deposit or withdraw. NATIVE if native asset on the source chain.
47092
+ * @param currentBridgeMethods A Record mapping bridge operation names to contract method names
47093
+ * @param bridgeContract: The bridge contract to be interacting with dependinig on network and if it's a deposit or withdrawal
47094
+ * @returns calldata for the requested bridge transaction (i.e. tx.data)
47095
+ */
47096
+ async function getBridgeTxCalldata(sender, recipient, amount, token, currentBridgeMethods, bridgeContract) {
47097
+ let functionName;
47098
+ let parameters;
47099
+ /**
47100
+ * Handle bridge transaction for native token
47101
+ */
47102
+ if (token.toUpperCase() === NATIVE$1) {
47103
+ if (sender === recipient) {
47104
+ // Deposit or withdraw native token
47105
+ functionName = currentBridgeMethods.native;
47106
+ parameters = [amount];
47107
+ }
47108
+ else {
47109
+ // Deposit or withdraw native token TO
47110
+ functionName = currentBridgeMethods.nativeTo;
47111
+ parameters = [recipient, amount];
47112
+ }
47113
+ }
47114
+ else {
47115
+ /**
47116
+ * Handle bridge transaction for ERC20
47117
+ */
47118
+ const erc20Token = getAddress(token);
47119
+ if (sender === recipient) {
47120
+ // Deposit or withdraw ERC20
47121
+ functionName = currentBridgeMethods.token;
47122
+ parameters = [erc20Token, amount];
47123
+ }
47124
+ else {
47125
+ // Deposit or withdraw ERC20 TO.
47126
+ functionName = currentBridgeMethods.tokenTo;
47127
+ parameters = [erc20Token, recipient, amount];
47128
+ }
47129
+ }
47130
+ return await withBridgeError(async () => bridgeContract.interface.encodeFunctionData(functionName, parameters), BridgeErrorType.INTERNAL_ERROR);
47131
+ }
47132
+
47067
47133
  const ROOT_ERC20_BRIDGE_FLOW_RATE = [
47068
47134
  {
47069
47135
  inputs: [
@@ -50904,43 +50970,10 @@ class TokenBridge {
50904
50970
  * @param sourceChainId Chain ID of the source chain
50905
50971
  * @returns calldata for the requested bridge transaction (i.e. tx.data)
50906
50972
  */
50907
- async getTxData(sender, recipient, amount, token, direction) {
50973
+ async getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction) {
50908
50974
  const currentBridgeMethods = await this.getBridgeMethods(direction);
50909
50975
  const bridgeContract = await this.getBridgeContract(direction);
50910
- let functionName;
50911
- let parameters;
50912
- /**
50913
- * Handle bridge transaction for native token
50914
- */
50915
- if (token.toUpperCase() === NATIVE$1) {
50916
- if (sender === recipient) {
50917
- // Deposit or withdraw native token
50918
- functionName = currentBridgeMethods.native;
50919
- parameters = [amount];
50920
- }
50921
- else {
50922
- // Deposit or withdraw native token TO
50923
- functionName = currentBridgeMethods.nativeTo;
50924
- parameters = [recipient, amount];
50925
- }
50926
- }
50927
- else {
50928
- /**
50929
- * Handle bridge transaction for ERC20
50930
- */
50931
- const erc20Token = getAddress(token);
50932
- if (sender === recipient) {
50933
- // Deposit or withdraw ERC20
50934
- functionName = currentBridgeMethods.token;
50935
- parameters = [erc20Token, amount];
50936
- }
50937
- else {
50938
- // Deposit or withdraw ERC20 TO.
50939
- functionName = currentBridgeMethods.tokenTo;
50940
- parameters = [erc20Token, recipient, amount];
50941
- }
50942
- }
50943
- return await withBridgeError(async () => bridgeContract.interface.encodeFunctionData(functionName, parameters), BridgeErrorType.INTERNAL_ERROR);
50976
+ return getBridgeTxCalldata(sender, recipient, amount, token, currentBridgeMethods, bridgeContract);
50944
50977
  }
50945
50978
  /**
50946
50979
  * Generates an unsigned deposit or withdrawal transaction for a user to sign and submit to the bridge.
@@ -51169,7 +51202,7 @@ class TokenBridge {
51169
51202
  unsignedApprovalTx = null;
51170
51203
  }
51171
51204
  // Deposit transaction & fees.
51172
- const txData = await this.getTxData(sender, recipient, amount, token, direction);
51205
+ const txData = await this.getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction);
51173
51206
  const txValue = (token.toUpperCase() === NATIVE$1)
51174
51207
  ? amount.add(bridgeFee).toString() : bridgeFee.toString();
51175
51208
  const unsignedBridgeTx = {
@@ -51231,7 +51264,7 @@ class TokenBridge {
51231
51264
  unsignedApprovalTx = null;
51232
51265
  }
51233
51266
  // Withdraw transaction & fees.
51234
- const txData = await this.getTxData(sender, recipient, amount, token, direction);
51267
+ const txData = await this.getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction);
51235
51268
  const txValue = (token.toUpperCase() === NATIVE$1)
51236
51269
  ? amount.add(bridgeFee).toString() : bridgeFee.toString();
51237
51270
  const unsignedBridgeTx = {
@@ -51280,7 +51313,7 @@ class TokenBridge {
51280
51313
  destinationChainId: this.config.bridgeInstance.childChainID,
51281
51314
  };
51282
51315
  // Get tx data
51283
- const txData = await this.getTxData(sender, recipient, amount, token, direction);
51316
+ const txData = await this.getConfigAndBridgeTxCalldata(sender, recipient, amount, token, direction);
51284
51317
  // tx value for simulation mocked as amount + 1 wei for a native bridge and 1 wei for token bridges
51285
51318
  // hexValue() is required to remove leading zeros, which tenderly does not support.
51286
51319
  const txValue = (token.toUpperCase() !== NATIVE$1) ? '0x1' : hexValue(amount.add('1').toHexString());
@@ -51316,7 +51349,7 @@ class TokenBridge {
51316
51349
  // Calculate slot key for given command ID.
51317
51350
  const command = defaultAbiCoder.encode(['bytes32', 'bytes32', 'string', 'string', 'address', 'bytes32'], [SLOT_PREFIX_CONTRACT_CALL_APPROVED, commandId, sourceChain, sourceAddress, destinationAddress, payloadHash]);
51318
51351
  const commandHash = keccak256(command);
51319
- const slot = keccak256(concat([
51352
+ const gatewayCallApprovedSlot = keccak256(concat([
51320
51353
  commandHash,
51321
51354
  hexlify(zeroPad(hexlify(SLOT_POS_CONTRACT_CALL_APPROVED), 32)),
51322
51355
  ]));
@@ -51331,14 +51364,14 @@ class TokenBridge {
51331
51364
  to: destinationAddress,
51332
51365
  data: executeData,
51333
51366
  }];
51334
- const gas = await submitTenderlySimulations(destinationChainId, simulations, {
51335
- [axelarGateway]: {
51336
- stateDiff: {
51337
- // Override storage to approve this command.
51338
- [slot]: '0x0000000000000000000000000000000000000000000000000000000000000001',
51339
- },
51367
+ const stateObject = {
51368
+ contractAddress: axelarGateway,
51369
+ stateDiff: {
51370
+ storageSlot: gatewayCallApprovedSlot,
51371
+ value: trueInHex,
51340
51372
  },
51341
- });
51373
+ };
51374
+ const gas = await submitTenderlySimulations(destinationChainId, simulations, [stateObject]);
51342
51375
  return gas[0];
51343
51376
  }
51344
51377
  async getAllowance(direction, token, sender) {
@@ -52212,7 +52245,7 @@ const flattenProperties = (properties) => {
52212
52245
  };
52213
52246
 
52214
52247
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
52215
- const SDK_VERSION = '1.43.2-alpha.8';
52248
+ const SDK_VERSION = '1.43.2-alpha.9';
52216
52249
  const getFrameParentDomain = () => {
52217
52250
  if (isNode()) {
52218
52251
  return '';
@@ -57531,7 +57564,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
57531
57564
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
57532
57565
  };
57533
57566
 
57534
- const SDK_VERSION_MARKER = '1.43.2-alpha.8';
57567
+ const SDK_VERSION_MARKER = '1.43.2-alpha.9';
57535
57568
  // This SDK version is replaced by the `yarn build` command ran on the root level
57536
57569
  const globalPackageVersion = () => SDK_VERSION_MARKER;
57537
57570
 
@@ -5286,7 +5286,7 @@ const flattenProperties = (properties) => {
5286
5286
  };
5287
5287
 
5288
5288
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
5289
- const SDK_VERSION = '1.43.2-alpha.8';
5289
+ const SDK_VERSION = '1.43.2-alpha.9';
5290
5290
  const getFrameParentDomain = () => {
5291
5291
  if (isNode()) {
5292
5292
  return '';
@@ -5554,7 +5554,7 @@ class APIError extends Error {
5554
5554
 
5555
5555
  /* eslint-disable implicit-arrow-linebreak */
5556
5556
  const defaultHeaders = {
5557
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.43.2-alpha.8',
5557
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.43.2-alpha.9',
5558
5558
  };
5559
5559
  /**
5560
5560
  * createAPIConfiguration to create a custom Configuration
package/dist/orderbook.js CHANGED
@@ -133,7 +133,7 @@ const flattenProperties = (properties) => {
133
133
  };
134
134
 
135
135
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
136
- const SDK_VERSION = '1.43.2-alpha.8';
136
+ const SDK_VERSION = '1.43.2-alpha.9';
137
137
  const getFrameParentDomain = () => {
138
138
  if (isNode()) {
139
139
  return '';
package/dist/passport.js CHANGED
@@ -11459,7 +11459,7 @@ class MultiRollupApiClients {
11459
11459
  }
11460
11460
 
11461
11461
  // eslint-disable-next-line @typescript-eslint/naming-convention
11462
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
11462
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
11463
11463
  const createConfig$1 = ({ basePath, headers, }) => {
11464
11464
  if (!basePath.trim()) {
11465
11465
  throw Error('basePath can not be empty');
@@ -11638,7 +11638,7 @@ const flattenProperties = (properties) => {
11638
11638
  };
11639
11639
 
11640
11640
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
11641
- const SDK_VERSION = '1.43.2-alpha.8';
11641
+ const SDK_VERSION = '1.43.2-alpha.9';
11642
11642
  const getFrameParentDomain = () => {
11643
11643
  if (isNode()) {
11644
11644
  return '';
@@ -12028,7 +12028,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
12028
12028
  /* eslint-disable @typescript-eslint/naming-convention */
12029
12029
  class ApiConfiguration extends index$2.Configuration {
12030
12030
  }
12031
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
12031
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
12032
12032
  /**
12033
12033
  * @dev use createImmutableXConfiguration instead
12034
12034
  */
@@ -12069,7 +12069,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
12069
12069
  coreContractAddress,
12070
12070
  registrationContractAddress,
12071
12071
  registrationV4ContractAddress,
12072
- sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.8',
12072
+ sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.9',
12073
12073
  baseConfig,
12074
12074
  });
12075
12075
  const production = ({ baseConfig }) => createImmutableXConfiguration({
package/dist/webhook.js CHANGED
@@ -129,7 +129,7 @@ const flattenProperties = (properties) => {
129
129
  };
130
130
 
131
131
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
132
- const SDK_VERSION = '1.43.2-alpha.8';
132
+ const SDK_VERSION = '1.43.2-alpha.9';
133
133
  const getFrameParentDomain = () => {
134
134
  if (isNode()) {
135
135
  return '';
package/dist/x.js CHANGED
@@ -9003,7 +9003,7 @@ const flattenProperties = (properties) => {
9003
9003
  };
9004
9004
 
9005
9005
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
9006
- const SDK_VERSION = '1.43.2-alpha.8';
9006
+ const SDK_VERSION = '1.43.2-alpha.9';
9007
9007
  const getFrameParentDomain = () => {
9008
9008
  if (isNode()) {
9009
9009
  return '';
@@ -9269,7 +9269,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
9269
9269
  /* eslint-disable @typescript-eslint/naming-convention */
9270
9270
  class ApiConfiguration extends index$2.Configuration {
9271
9271
  }
9272
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.8' };
9272
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.43.2-alpha.9' };
9273
9273
  /**
9274
9274
  * @dev use createImmutableXConfiguration instead
9275
9275
  */
@@ -9310,7 +9310,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
9310
9310
  coreContractAddress,
9311
9311
  registrationContractAddress,
9312
9312
  registrationV4ContractAddress,
9313
- sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.8',
9313
+ sdkVersion: 'ts-immutable-sdk-1.43.2-alpha.9',
9314
9314
  baseConfig,
9315
9315
  });
9316
9316
  const production = ({ baseConfig }) => createImmutableXConfiguration({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Typescript SDK",
4
- "version": "1.43.2-alpha.8",
4
+ "version": "1.43.2-alpha.9",
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{cB as n,cC as t}from"./index-1d657ceb.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-06c44429.js").then((function(n){return n.i}))];case 1:return n=t.sent(),i._plugins=n,[2]}}))}))}export{i as loadLegacyVideoPlugins};