@imtbl/sdk 0.44.0 → 0.44.2

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.
package/dist/index.js CHANGED
@@ -10619,7 +10619,7 @@ class MultiRollupApiClients {
10619
10619
  }
10620
10620
 
10621
10621
  // eslint-disable-next-line @typescript-eslint/naming-convention
10622
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.0' };
10622
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.2' };
10623
10623
  const createConfig = ({ basePath, headers, }) => {
10624
10624
  if (!basePath.trim()) {
10625
10625
  throw Error('basePath can not be empty');
@@ -10691,7 +10691,7 @@ class APIError extends Error {
10691
10691
 
10692
10692
  /* eslint-disable implicit-arrow-linebreak */
10693
10693
  const defaultHeaders = {
10694
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.0',
10694
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.2',
10695
10695
  };
10696
10696
  /**
10697
10697
  * createAPIConfiguration to create a custom Configuration
@@ -11130,7 +11130,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11130
11130
  chainID,
11131
11131
  coreContractAddress,
11132
11132
  registrationContractAddress,
11133
- sdkVersion: 'ts-immutable-sdk-0.44.0',
11133
+ sdkVersion: 'ts-immutable-sdk-0.44.2',
11134
11134
  });
11135
11135
  /**
11136
11136
  * Sets `sdkVersion` at the time of build
@@ -17281,27 +17281,43 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
17281
17281
  const types = { ...typedData.types };
17282
17282
  // @ts-ignore
17283
17283
  delete types.EIP712Domain;
17284
- // eslint-disable-next-line no-underscore-dangle
17285
- const digest = ethers.utils._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
17286
- const completePayload = encodeMessageSubDigest(chainId, walletAddress, digest);
17287
- const hash = ethers.utils.keccak256(completePayload);
17288
- // Sign the digest
17284
+ // Hash the EIP712 payload and generate the complete payload
17285
+ const { _TypedDataEncoder: typedDataEncoder } = ethers.utils;
17286
+ const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
17287
+ const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
17288
+ const hash = ethers.utils.keccak256(messageSubDigest);
17289
+ // Sign the sub digest
17290
+ // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
17289
17291
  const hashArray = ethers.utils.arrayify(hash);
17290
17292
  const ethsigNoType = await signer.signMessage(hashArray);
17291
17293
  const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
17292
- const { signers } = decodeRelayerTypedDataSignature(relayerSignature);
17294
+ // Combine the relayer and user signatures; sort by address to match the imageHash order
17295
+ const { signers: relayerSigners } = decodeRelayerTypedDataSignature(relayerSignature);
17296
+ const combinedSigners = [
17297
+ ...relayerSigners,
17298
+ {
17299
+ isDynamic: false,
17300
+ unrecovered: true,
17301
+ weight: SIGNATURE_WEIGHT,
17302
+ signature: signedDigest,
17303
+ address: await signer.getAddress(),
17304
+ },
17305
+ ];
17306
+ const sortedSigners = combinedSigners.sort((a, b) => {
17307
+ const bigA = BigNumber$1.from(a.address);
17308
+ const bigB = BigNumber$1.from(b.address);
17309
+ if (bigA.lte(bigB)) {
17310
+ return -1;
17311
+ }
17312
+ if (bigA.eq(bigB)) {
17313
+ return 0;
17314
+ }
17315
+ return 1;
17316
+ });
17293
17317
  return v1.signature.encodeSignature({
17294
17318
  version: 1,
17295
17319
  threshold: EIP712_SIGNATURE_THRESHOLD,
17296
- signers: [
17297
- ...signers,
17298
- {
17299
- isDynamic: false,
17300
- unrecovered: true,
17301
- weight: SIGNATURE_WEIGHT,
17302
- signature: signedDigest,
17303
- },
17304
- ],
17320
+ signers: sortedSigners,
17305
17321
  });
17306
17322
  };
17307
17323
  const getEip155ChainId = (chainId) => `eip155:${chainId}`;
@@ -17886,9 +17902,6 @@ class Passport {
17886
17902
  return this.passportImxProviderFactory.getProvider();
17887
17903
  }
17888
17904
  connectEvm() {
17889
- if (this.config.baseConfig.environment === 'production') {
17890
- throw new Error('EVM is not supported on production network');
17891
- }
17892
17905
  return new ZkEvmProvider({
17893
17906
  passportEventEmitter: this.passportEventEmitter,
17894
17907
  authManager: this.authManager,
@@ -37003,38 +37016,84 @@ class TokenBridge {
37003
37016
  * @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
37004
37017
  */
37005
37018
  async getTransactionStatus(req) {
37006
- const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
37007
37019
  const txStatusResponse = {
37008
37020
  transactions: [],
37009
37021
  };
37010
- const abiCoder = new AbiCoder();
37011
- const statusPromises = [];
37012
- for (const transaction of req.transactions) {
37013
- statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
37022
+ const txStatusItems = await this.getAxelarStatus(req.transactions, req.sourceChainId);
37023
+ const uniqueReceivers = await this.getUniqueReceivers(txStatusItems, req.sourceChainId);
37024
+ const pendingWithdrawalPromises = [];
37025
+ for (const address of uniqueReceivers) {
37026
+ pendingWithdrawalPromises.push(this.getPendingWithdrawals({ recipient: address }));
37014
37027
  }
37015
- let statusResponses;
37028
+ let pendingWithdrawalResponses = [];
37016
37029
  try {
37017
- statusResponses = await Promise.all(statusPromises);
37030
+ pendingWithdrawalResponses = await Promise.all(pendingWithdrawalPromises);
37018
37031
  }
37019
37032
  catch (err) {
37020
- throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
37033
+ console.log('err', err);
37034
+ throw new BridgeError(`Failed to fetch the pending withdrawals with: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
37021
37035
  }
37022
- const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
37036
+ txStatusResponse.transactions = txStatusItems;
37037
+ // try match a completed transaction to a pending flowRate transaction
37038
+ for (const txStatusRes of txStatusResponse.transactions) {
37039
+ if (txStatusRes.status === StatusResponse.COMPLETE) {
37040
+ (() => {
37041
+ for (const pendingWithdrawals of pendingWithdrawalResponses) {
37042
+ const flowRatedTxIndex = pendingWithdrawals.pending.findIndex((el) => (el.amount.toString() === txStatusRes.amount.toString()
37043
+ && el.token === txStatusRes.token
37044
+ && el.withdrawer === txStatusRes.sender
37045
+ && el.recipient === txStatusRes.recipient));
37046
+ if (flowRatedTxIndex !== -1) {
37047
+ txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
37048
+ txStatusRes.data = {
37049
+ canWithdraw: pendingWithdrawals.pending[flowRatedTxIndex].canWithdraw,
37050
+ timeoutStart: pendingWithdrawals.pending[flowRatedTxIndex].timeoutStart,
37051
+ timeoutEnd: pendingWithdrawals.pending[flowRatedTxIndex].timeoutEnd,
37052
+ };
37053
+ pendingWithdrawals.pending.splice(flowRatedTxIndex, 1);
37054
+ return;
37055
+ }
37056
+ }
37057
+ })();
37058
+ }
37059
+ }
37060
+ // Return the tx status response
37061
+ return txStatusResponse;
37062
+ }
37063
+ async getUniqueReceivers(txStatusItems, sourceChainId) {
37064
+ const uniqueReceivers = [];
37023
37065
  const isWithdraw = [
37024
37066
  ZKEVM_DEVNET_CHAIN_ID,
37025
37067
  ZKEVM_TESTNET_CHAIN_ID,
37026
37068
  ZKEVM_MAINNET_CHAIN_ID
37027
- ].includes(req.sourceChainId);
37028
- let rootBridge;
37029
- if (isWithdraw) {
37030
- rootBridge = await withBridgeError(async () => {
37031
- const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
37032
- return contract;
37033
- }, BridgeErrorType.INTERNAL_ERROR);
37069
+ ].includes(sourceChainId);
37070
+ for (let i = 0, l = txStatusItems.length; i < l; i++) {
37071
+ if (txStatusItems[i].status === StatusResponse.COMPLETE
37072
+ && isWithdraw && txStatusItems[i].recipient) {
37073
+ const receiverIndex = uniqueReceivers.findIndex((el) => el === txStatusItems[i].recipient);
37074
+ if (receiverIndex === -1) {
37075
+ uniqueReceivers.push(txStatusItems[i].recipient);
37076
+ }
37077
+ }
37078
+ } // for
37079
+ return uniqueReceivers;
37080
+ }
37081
+ async getAxelarStatus(transactions, sourceChainId) {
37082
+ const txStatusItems = [];
37083
+ const statusPromises = [];
37084
+ const axelarAPIEndpoint = this.getAxelarEndpoint(sourceChainId);
37085
+ const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
37086
+ const abiCoder = new AbiCoder();
37087
+ for (const transaction of transactions) {
37088
+ statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
37089
+ }
37090
+ let statusResponses;
37091
+ try {
37092
+ statusResponses = await Promise.all(statusPromises);
37093
+ }
37094
+ catch (err) {
37095
+ throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
37034
37096
  }
37035
- const flowRatePromises = [];
37036
- const flowRateLengthPromises = [];
37037
- const flowRatePromisesReceivers = [];
37038
37097
  for (let i = 0, l = statusResponses.length; i < l; i++) {
37039
37098
  let metaStatus;
37040
37099
  // consolidate axelar statuses to our own simplified metaStatus
@@ -37068,7 +37127,7 @@ class TokenBridge {
37068
37127
  }
37069
37128
  }
37070
37129
  let txItem = {
37071
- txHash: req.transactions[i].txHash,
37130
+ txHash: transactions[i].txHash,
37072
37131
  status: metaStatus,
37073
37132
  data: {
37074
37133
  gmpResponse: statusResponses[i].status,
@@ -37085,61 +37144,9 @@ class TokenBridge {
37085
37144
  amount: decodedData[4],
37086
37145
  };
37087
37146
  }
37088
- let flowRatePromiseIndex = flowRatePromisesReceivers.findIndex((el) => el === txItem.recipient);
37089
- if (metaStatus === StatusResponse.COMPLETE
37090
- && isWithdraw && txItem.recipient) {
37091
- // consolidate the calls we have to make to the flow rate by receiver
37092
- if (flowRatePromiseIndex === -1) {
37093
- flowRatePromisesReceivers.push(txItem.recipient);
37094
- flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
37095
- }
37096
- txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
37097
- }
37098
- txStatusResponse.transactions.push(txItem);
37147
+ txStatusItems.push(txItem);
37099
37148
  } // for
37100
- for (const flowRateReceiver of flowRatePromisesReceivers) {
37101
- flowRateLengthPromises.push(rootBridge.getPendingWithdrawalsLength(flowRateReceiver));
37102
- }
37103
- let flowRateLengthResponses = [];
37104
- try {
37105
- flowRateLengthResponses = await Promise.all(flowRateLengthPromises);
37106
- }
37107
- catch (err) {
37108
- throw new BridgeError(`Failed to fetch the Flow Rate pending lengths with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
37109
- }
37110
- for (let i = 0, l = flowRatePromisesReceivers.length; i < l; i++) {
37111
- const indices = [];
37112
- const indicesLength = flowRateLengthResponses[i].toNumber();
37113
- for (let j = 0; j < indicesLength; j++) {
37114
- indices.push(j);
37115
- }
37116
- flowRatePromises.push(rootBridge.getPendingWithdrawals(flowRatePromisesReceivers[i], indices));
37117
- }
37118
- let flowRateResponses = [];
37119
- if (flowRatePromises.length > 0) {
37120
- try {
37121
- flowRateResponses = await Promise.all(flowRatePromises);
37122
- }
37123
- catch (err) {
37124
- throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
37125
- }
37126
- }
37127
- for (const txStatusRes of txStatusResponse.transactions) {
37128
- if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
37129
- const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
37130
- && el.token === txStatusRes.token
37131
- && el.withdrawer === txStatusRes.sender));
37132
- if (flowRatedTx) {
37133
- txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
37134
- txStatusRes.data = {
37135
- timestamp: flowRatedTx.timestamp.toString(),
37136
- };
37137
- }
37138
- }
37139
- delete txStatusRes.data.flowRatePromiseIndex;
37140
- }
37141
- // Return the tx status response
37142
- return txStatusResponse;
37149
+ return txStatusItems;
37143
37150
  }
37144
37151
  /**
37145
37152
  * Queries for the information about which tokens are flowrated and how long the delay is.
@@ -37165,6 +37172,7 @@ class TokenBridge {
37165
37172
  token = ETHEREUM_NATIVE_TOKEN_ADDRESS;
37166
37173
  }
37167
37174
  contractPromises.push(rootBridge.flowRateBuckets(token));
37175
+ contractPromises.push(rootBridge.largeTransferThresholds(token));
37168
37176
  }
37169
37177
  let contractPromisesRes;
37170
37178
  try {
@@ -37174,19 +37182,25 @@ class TokenBridge {
37174
37182
  throw new BridgeError('unable to query contract for flowrate info', BridgeErrorType.INTERNAL_ERROR);
37175
37183
  }
37176
37184
  const tokensRes = {};
37177
- // @note it's i + 2 because the first 2 promises are not token buckets
37185
+ const withdrawalQueueActivated = contractPromisesRes[0];
37186
+ const withdrawalDelay = contractPromisesRes[1].toNumber();
37187
+ // remove first 2 items from promise all response
37188
+ contractPromisesRes.splice(0, 2);
37189
+ // the remaining items should be sets of 2 per token
37178
37190
  for (let i = 0, l = req.tokens.length; i < l; i++) {
37191
+ const shifter = i * 2;
37179
37192
  tokensRes[req.tokens[i]] = {
37180
- capacity: contractPromisesRes[i + 2].capacity,
37181
- depth: contractPromisesRes[i + 2].depth,
37182
- refillTime: contractPromisesRes[i + 2].refillTime.toNumber(),
37183
- refillRate: contractPromisesRes[i + 2].refillRate,
37193
+ capacity: contractPromisesRes[shifter].capacity,
37194
+ depth: contractPromisesRes[shifter].depth,
37195
+ refillTime: contractPromisesRes[shifter].refillTime.toNumber(),
37196
+ refillRate: contractPromisesRes[shifter].refillRate,
37197
+ largeTransferThreshold: contractPromisesRes[shifter + 1],
37184
37198
  };
37185
37199
  }
37186
37200
  // Return the token mappings
37187
37201
  return {
37188
- withdrawalQueueActivated: contractPromisesRes[0],
37189
- withdrawalDelay: contractPromisesRes[1].toNumber(),
37202
+ withdrawalQueueActivated,
37203
+ withdrawalDelay,
37190
37204
  tokens: tokensRes,
37191
37205
  };
37192
37206
  }
@@ -37233,6 +37247,7 @@ class TokenBridge {
37233
37247
  canWithdraw: true,
37234
37248
  };
37235
37249
  }
37250
+ pendingWithdrawals.pending[i].recipient = req.recipient;
37236
37251
  pendingWithdrawals.pending[i].withdrawer = pending[i].withdrawer;
37237
37252
  pendingWithdrawals.pending[i].token = pending[i].token;
37238
37253
  pendingWithdrawals.pending[i].amount = pending[i].amount;
@@ -37276,6 +37291,7 @@ class TokenBridge {
37276
37291
  pendingWithdrawal: {
37277
37292
  canWithdraw: false,
37278
37293
  withdrawer: pending[0].withdrawer,
37294
+ recipient: req.recipient,
37279
37295
  token: pending[0].token,
37280
37296
  amount: pending[0].amount,
37281
37297
  timeoutStart: pending[0].timestamp.toNumber(),
@@ -37289,6 +37305,7 @@ class TokenBridge {
37289
37305
  pendingWithdrawal: {
37290
37306
  canWithdraw: true,
37291
37307
  withdrawer: pending[0].withdrawer,
37308
+ recipient: req.recipient,
37292
37309
  token: pending[0].token,
37293
37310
  amount: pending[0].amount,
37294
37311
  timeoutStart: pending[0].timestamp.toNumber(),
@@ -37314,10 +37331,38 @@ class TokenBridge {
37314
37331
  */
37315
37332
  async getTokenMapping(req) {
37316
37333
  // eslint-disable-next-line no-console
37317
- console.log('stubbed response with req', req);
37334
+ if (req.rootToken.toUpperCase() === 'NATIVE'
37335
+ || req.rootToken === this.config.bridgeContracts.rootChainWrappedETH) {
37336
+ const childBridge = await withBridgeError(async () => {
37337
+ const contract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE, this.config.childProvider);
37338
+ return contract;
37339
+ }, BridgeErrorType.INTERNAL_ERROR);
37340
+ const childETHToken = await childBridge.childETHToken();
37341
+ return {
37342
+ rootToken: req.rootToken,
37343
+ childToken: childETHToken,
37344
+ };
37345
+ }
37346
+ const rootBridge = await withBridgeError(async () => {
37347
+ const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
37348
+ return contract;
37349
+ }, BridgeErrorType.INTERNAL_ERROR);
37350
+ const rootTokenChildAddress = await rootBridge.rootTokenToChildToken(req.rootToken);
37351
+ if (rootTokenChildAddress === AddressZero) {
37352
+ return {
37353
+ rootToken: req.rootToken,
37354
+ childToken: null,
37355
+ };
37356
+ }
37357
+ if (rootTokenChildAddress === req.rootToken) {
37358
+ return {
37359
+ rootToken: req.rootToken,
37360
+ childToken: 'NATIVE',
37361
+ };
37362
+ }
37318
37363
  return {
37319
- rootToken: '0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF',
37320
- childToken: 'NATIVE',
37364
+ rootToken: req.rootToken,
37365
+ childToken: rootTokenChildAddress,
37321
37366
  };
37322
37367
  }
37323
37368
  }
@@ -41243,12 +41288,14 @@ const validateProviderDefaults = {
41243
41288
  * @property {string} SUCCESS - If checkout succeeded as the transactions were able to be processed
41244
41289
  * @property {string} FAILED - If checkout failed due to transactions not settling on chain
41245
41290
  * @property {string} INSUFFICIENT_FUNDS - If checkout failed due to insufficient funds
41291
+ * @property {string} FULFILLMENTS_UNSETTLED - If checkout succeeded but the fulfillment transactions are not yet settled
41246
41292
  */
41247
41293
  var CheckoutStatus;
41248
41294
  (function (CheckoutStatus) {
41249
41295
  CheckoutStatus["SUCCESS"] = "SUCCESS";
41250
41296
  CheckoutStatus["FAILED"] = "FAILED";
41251
41297
  CheckoutStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
41298
+ CheckoutStatus["FULFILLMENTS_UNSETTLED"] = "FULFILLMENTS_UNSETTLED";
41252
41299
  })(CheckoutStatus || (CheckoutStatus = {}));
41253
41300
  /**
41254
41301
  * An enum representing the item types
@@ -41923,7 +41970,7 @@ const GAS_OVERRIDES = {
41923
41970
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
41924
41971
  };
41925
41972
 
41926
- const SDK_VERSION_MARKER = '0.44.0';
41973
+ const SDK_VERSION_MARKER = '0.44.2';
41927
41974
  // This SDK version is replaced by the `yarn build` command ran on the root level
41928
41975
  const globalPackageVersion = () => SDK_VERSION_MARKER;
41929
41976
 
@@ -44984,7 +45031,9 @@ const getTransactionOrGas = (gasLimit, fulfillmentTransactions) => {
44984
45031
  },
44985
45032
  };
44986
45033
  };
44987
- const buy = async (config, provider, orders) => {
45034
+ const buy = async (config, provider, orders, overrides = {
45035
+ waitFulfillmentSettlements: true,
45036
+ }) => {
44988
45037
  if (orders.length === 0) {
44989
45038
  throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR);
44990
45039
  }
@@ -45112,18 +45161,35 @@ const buy = async (config, provider, orders) => {
45112
45161
  message: err.message,
45113
45162
  });
45114
45163
  }
45115
- const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
45116
- if (fulfillmentResult.type === SignTransactionStatusType.FAILED) {
45164
+ if (overrides.waitFulfillmentSettlements) {
45165
+ const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
45166
+ if (fulfillmentResult.type === SignTransactionStatusType.FAILED) {
45167
+ return {
45168
+ status: CheckoutStatus.FAILED,
45169
+ transactionHash: fulfillmentResult.transactionHash,
45170
+ reason: fulfillmentResult.reason,
45171
+ smartCheckoutResult,
45172
+ };
45173
+ }
45117
45174
  return {
45118
- status: CheckoutStatus.FAILED,
45119
- transactionHash: fulfillmentResult.transactionHash,
45120
- reason: fulfillmentResult.reason,
45175
+ status: CheckoutStatus.SUCCESS,
45121
45176
  smartCheckoutResult,
45122
45177
  };
45123
45178
  }
45179
+ let transactions;
45180
+ try {
45181
+ const response = await Promise.all(unsignedFulfillmentTransactions.map((transaction) => sendTransaction(provider, transaction)));
45182
+ transactions = response.map((result) => result.transactionResponse);
45183
+ }
45184
+ catch (err) {
45185
+ throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
45186
+ message: err.message,
45187
+ });
45188
+ }
45124
45189
  return {
45125
- status: CheckoutStatus.SUCCESS,
45190
+ status: CheckoutStatus.FULFILLMENTS_UNSETTLED,
45126
45191
  smartCheckoutResult,
45192
+ transactions,
45127
45193
  };
45128
45194
  }
45129
45195
  return {
@@ -45700,7 +45766,7 @@ class Checkout {
45700
45766
  console.warn('This endpoint currently only processes the first order in the array.');
45701
45767
  }
45702
45768
  const web3Provider = await validateProvider(this.config, params.provider);
45703
- return await buy(this.config, web3Provider, params.orders);
45769
+ return await buy(this.config, web3Provider, params.orders, params.overrides);
45704
45770
  }
45705
45771
  /**
45706
45772
  * Determines the requirements for performing a sell.
@@ -1653,4 +1653,4 @@ declare const constants: {
1653
1653
  estimatedFulfillmentGasGwei: number;
1654
1654
  };
1655
1655
 
1656
- export { Action, ActionType, CancelOrdersOnChainResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillBulkOrdersInsufficientBalanceResponse, FulfillBulkOrdersResponse, FulfillBulkOrdersSufficientBalanceResponse, FulfillOrderResponse, FulfillmentListing, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatusName, Orderbook, Page, PrepareCancelOrdersResponse, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, UnfulfillableOrder, constants };
1656
+ export { Action, ActionType, CancelOrdersOnChainResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillBulkOrdersInsufficientBalanceResponse, FulfillBulkOrdersResponse, FulfillBulkOrdersSufficientBalanceResponse, FulfillOrderResponse, FulfillmentListing, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatusName, Orderbook, OrderbookModuleConfiguration, OrderbookOverrides, Page, PrepareCancelOrdersResponse, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, UnfulfillableOrder, constants };
package/dist/passport.js CHANGED
@@ -8724,7 +8724,7 @@ class MultiRollupApiClients {
8724
8724
  }
8725
8725
 
8726
8726
  // eslint-disable-next-line @typescript-eslint/naming-convention
8727
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.44.0' };
8727
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.44.2' };
8728
8728
  const createConfig = ({ basePath, headers, }) => {
8729
8729
  if (!basePath.trim()) {
8730
8730
  throw Error('basePath can not be empty');
@@ -8792,7 +8792,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
8792
8792
  chainID,
8793
8793
  coreContractAddress,
8794
8794
  registrationContractAddress,
8795
- sdkVersion: 'ts-immutable-sdk-0.44.0',
8795
+ sdkVersion: 'ts-immutable-sdk-0.44.2',
8796
8796
  });
8797
8797
  /**
8798
8798
  * Sets `sdkVersion` at the time of build
@@ -14926,27 +14926,43 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
14926
14926
  const types = { ...typedData.types };
14927
14927
  // @ts-ignore
14928
14928
  delete types.EIP712Domain;
14929
- // eslint-disable-next-line no-underscore-dangle
14930
- const digest = ethers.utils._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
14931
- const completePayload = encodeMessageSubDigest(chainId, walletAddress, digest);
14932
- const hash = ethers.utils.keccak256(completePayload);
14933
- // Sign the digest
14929
+ // Hash the EIP712 payload and generate the complete payload
14930
+ const { _TypedDataEncoder: typedDataEncoder } = ethers.utils;
14931
+ const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
14932
+ const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
14933
+ const hash = ethers.utils.keccak256(messageSubDigest);
14934
+ // Sign the sub digest
14935
+ // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
14934
14936
  const hashArray = ethers.utils.arrayify(hash);
14935
14937
  const ethsigNoType = await signer.signMessage(hashArray);
14936
14938
  const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
14937
- const { signers } = decodeRelayerTypedDataSignature(relayerSignature);
14939
+ // Combine the relayer and user signatures; sort by address to match the imageHash order
14940
+ const { signers: relayerSigners } = decodeRelayerTypedDataSignature(relayerSignature);
14941
+ const combinedSigners = [
14942
+ ...relayerSigners,
14943
+ {
14944
+ isDynamic: false,
14945
+ unrecovered: true,
14946
+ weight: SIGNATURE_WEIGHT,
14947
+ signature: signedDigest,
14948
+ address: await signer.getAddress(),
14949
+ },
14950
+ ];
14951
+ const sortedSigners = combinedSigners.sort((a, b) => {
14952
+ const bigA = BigNumber.from(a.address);
14953
+ const bigB = BigNumber.from(b.address);
14954
+ if (bigA.lte(bigB)) {
14955
+ return -1;
14956
+ }
14957
+ if (bigA.eq(bigB)) {
14958
+ return 0;
14959
+ }
14960
+ return 1;
14961
+ });
14938
14962
  return v1.signature.encodeSignature({
14939
14963
  version: 1,
14940
14964
  threshold: EIP712_SIGNATURE_THRESHOLD,
14941
- signers: [
14942
- ...signers,
14943
- {
14944
- isDynamic: false,
14945
- unrecovered: true,
14946
- weight: SIGNATURE_WEIGHT,
14947
- signature: signedDigest,
14948
- },
14949
- ],
14965
+ signers: sortedSigners,
14950
14966
  });
14951
14967
  };
14952
14968
  const getEip155ChainId = (chainId) => `eip155:${chainId}`;
@@ -15531,9 +15547,6 @@ class Passport {
15531
15547
  return this.passportImxProviderFactory.getProvider();
15532
15548
  }
15533
15549
  connectEvm() {
15534
- if (this.config.baseConfig.environment === 'production') {
15535
- throw new Error('EVM is not supported on production network');
15536
- }
15537
15550
  return new ZkEvmProvider({
15538
15551
  passportEventEmitter: this.passportEventEmitter,
15539
15552
  authManager: this.authManager,
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.44.0",
4
+ "version": "0.44.2",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
8
8
  "dependencies": {
9
9
  "@0xsequence/abi": "^1.4.3",
10
10
  "@0xsequence/core": "^1.4.3",
11
- "@biom3/design-tokens": "0.2.9",
12
- "@biom3/react": "^0.19.34",
11
+ "@biom3/design-tokens": "^0.2.10",
12
+ "@biom3/react": "^0.19.40",
13
13
  "@ethersproject/abi": "^5.7.0",
14
14
  "@ethersproject/abstract-signer": "^5.7.0",
15
15
  "@ethersproject/providers": "^5.7.2",
@@ -17,7 +17,7 @@
17
17
  "@imtbl/core-sdk": "^2.4.0",
18
18
  "@imtbl/react-analytics": "0.2.1-alpha",
19
19
  "@jest/globals": "^29.5.0",
20
- "@magic-ext/oidc": "^4.2.0",
20
+ "@magic-ext/oidc": "4.2.0",
21
21
  "@metamask/detect-provider": "^2.0.0",
22
22
  "@opensea/seaport-js": "2.0.7",
23
23
  "@uniswap/router-sdk": "^1.4.0",
@@ -35,7 +35,7 @@
35
35
  "i18next-browser-languagedetector": "^7.2.0",
36
36
  "jwt-decode": "^3.1.2",
37
37
  "magic-sdk": "^21.2.0",
38
- "oidc-client-ts": "^2.2.1",
38
+ "oidc-client-ts": "2.2.1",
39
39
  "os-browserify": "^0.3.0",
40
40
  "pako": "^2.1.0",
41
41
  "react-i18next": "^13.5.0",
@@ -127,7 +127,7 @@
127
127
  },
128
128
  "repository": "immutable/ts-immutable-sdk.git",
129
129
  "resolutions": {
130
- "@biom3/design-tokens": "0.2.9",
130
+ "@biom3/design-tokens": "^0.2.10",
131
131
  "@openzeppelin/contracts": "3.4.2-solc-0.7"
132
132
  },
133
133
  "scripts": {