@imtbl/sdk 1.5.0 → 1.5.1

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
@@ -151,7 +151,7 @@ const flattenProperties$1 = (properties) => {
151
151
  };
152
152
 
153
153
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
154
- const SDK_VERSION$1 = '1.5.0';
154
+ const SDK_VERSION$1 = '1.5.1';
155
155
  let initialised$1 = false;
156
156
  const isInitialised$1 = () => initialised$1;
157
157
  const getReferrer$1 = () => {
@@ -11238,7 +11238,7 @@ class MultiRollupApiClients {
11238
11238
  }
11239
11239
 
11240
11240
  // eslint-disable-next-line @typescript-eslint/naming-convention
11241
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.0' };
11241
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.1' };
11242
11242
  const createConfig = ({ basePath, headers, }) => {
11243
11243
  if (!basePath.trim()) {
11244
11244
  throw Error('basePath can not be empty');
@@ -11310,7 +11310,7 @@ class APIError extends Error {
11310
11310
 
11311
11311
  /* eslint-disable implicit-arrow-linebreak */
11312
11312
  const defaultHeaders = {
11313
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.0',
11313
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.1',
11314
11314
  };
11315
11315
  /**
11316
11316
  * createAPIConfiguration to create a custom Configuration
@@ -11743,7 +11743,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11743
11743
  chainID,
11744
11744
  coreContractAddress,
11745
11745
  registrationContractAddress,
11746
- sdkVersion: 'ts-immutable-sdk-1.5.0',
11746
+ sdkVersion: 'ts-immutable-sdk-1.5.1',
11747
11747
  });
11748
11748
  /**
11749
11749
  * Sets `sdkVersion` at the time of build
@@ -16813,12 +16813,14 @@ class GuardianClient {
16813
16813
  messageAPI;
16814
16814
  confirmationScreen;
16815
16815
  crossSdkBridgeEnabled;
16816
- constructor({ confirmationScreen, config }) {
16816
+ authManager;
16817
+ constructor({ confirmationScreen, config, authManager }) {
16817
16818
  const guardianConfiguration = new Configuration({ basePath: config.imxPublicApiDomain });
16818
16819
  this.confirmationScreen = confirmationScreen;
16819
16820
  this.crossSdkBridgeEnabled = config.crossSdkBridgeEnabled;
16820
16821
  this.messageAPI = new MessagesApi(guardianConfiguration);
16821
16822
  this.transactionAPI = new TransactionsApi(guardianConfiguration);
16823
+ this.authManager = authManager;
16822
16824
  }
16823
16825
  /**
16824
16826
  * Open confirmation screen and close it automatically if the
@@ -16842,10 +16844,11 @@ class GuardianClient {
16842
16844
  withDefaultConfirmationScreenTask(task) {
16843
16845
  return this.withConfirmationScreenTask()(task);
16844
16846
  }
16845
- async evaluateImxTransaction({ payloadHash, user }) {
16847
+ async evaluateImxTransaction({ payloadHash }) {
16846
16848
  const finallyFn = () => {
16847
16849
  this.confirmationScreen.closeWindow();
16848
16850
  };
16851
+ const user = await this.authManager.getUser();
16849
16852
  const headers = { Authorization: `Bearer ${user.accessToken}` };
16850
16853
  const transactionRes = await retryWithDelay(async () => this.transactionAPI.getTransactionByID({
16851
16854
  transactionID: payloadHash,
@@ -16874,7 +16877,8 @@ class GuardianClient {
16874
16877
  this.confirmationScreen.closeWindow();
16875
16878
  }
16876
16879
  }
16877
- async evaluateEVMTransaction({ chainId, nonce, user, metaTransactions, }) {
16880
+ async evaluateEVMTransaction({ chainId, nonce, metaTransactions, }) {
16881
+ const user = await this.authManager.getUser();
16878
16882
  const headers = { Authorization: `Bearer ${user.accessToken}` };
16879
16883
  const guardianTransactions = transformGuardianTransactions(metaTransactions);
16880
16884
  try {
@@ -16897,11 +16901,10 @@ class GuardianClient {
16897
16901
  throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
16898
16902
  }
16899
16903
  }
16900
- async validateEVMTransaction({ chainId, nonce, user, metaTransactions, }) {
16904
+ async validateEVMTransaction({ chainId, nonce, metaTransactions, }) {
16901
16905
  const transactionEvaluationResponse = await this.evaluateEVMTransaction({
16902
16906
  chainId,
16903
16907
  nonce,
16904
- user,
16905
16908
  metaTransactions,
16906
16909
  });
16907
16910
  const { confirmationRequired, transactionId } = transactionEvaluationResponse;
@@ -16909,6 +16912,7 @@ class GuardianClient {
16909
16912
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
16910
16913
  }
16911
16914
  if (confirmationRequired && !!transactionId) {
16915
+ const user = await this.authManager.getUser();
16912
16916
  const confirmationResult = await this.confirmationScreen.requestConfirmation(transactionId, user.zkEvm.ethAddress, TransactionApprovalRequestChainTypeEnum.Evm, chainId);
16913
16917
  if (!confirmationResult.confirmed) {
16914
16918
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Transaction rejected by user');
@@ -16918,8 +16922,12 @@ class GuardianClient {
16918
16922
  this.confirmationScreen.closeWindow();
16919
16923
  }
16920
16924
  }
16921
- async evaluateMessage({ chainID, payload, user }) {
16925
+ async evaluateMessage({ chainID, payload }) {
16922
16926
  try {
16927
+ const user = await this.authManager.getUser();
16928
+ if (user === null) {
16929
+ throw new PassportError('evaluateMessage requires a valid ID token or refresh token. Please log in first', PassportErrorType.NOT_LOGGED_IN_ERROR);
16930
+ }
16923
16931
  const messageEvalResponse = await this.messageAPI.evaluateMessage({ messageEvaluationRequest: { chainID, payload } }, { headers: { Authorization: `Bearer ${user.accessToken}` } });
16924
16932
  return messageEvalResponse.data;
16925
16933
  }
@@ -16928,12 +16936,13 @@ class GuardianClient {
16928
16936
  throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Message failed to validate with error: ${errorMessage}`);
16929
16937
  }
16930
16938
  }
16931
- async validateMessage({ chainID, payload, user }) {
16932
- const { messageId, confirmationRequired } = await this.evaluateMessage({ chainID, payload, user });
16939
+ async validateMessage({ chainID, payload }) {
16940
+ const { messageId, confirmationRequired } = await this.evaluateMessage({ chainID, payload });
16933
16941
  if (confirmationRequired && this.crossSdkBridgeEnabled) {
16934
16942
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
16935
16943
  }
16936
16944
  if (confirmationRequired && !!messageId) {
16945
+ const user = await this.authManager.getUser();
16937
16946
  const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId, user.zkEvm.ethAddress);
16938
16947
  if (!confirmationResult.confirmed) {
16939
16948
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Signature rejected by user');
@@ -17015,7 +17024,6 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
17015
17024
  getSignableOrderRequestV3,
17016
17025
  }, { headers });
17017
17026
  await guardianClient.evaluateImxTransaction({
17018
- user,
17019
17027
  payloadHash: getSignableOrderResponse.data.payload_hash,
17020
17028
  });
17021
17029
  const { payload_hash: payloadHash } = getSignableOrderResponse.data;
@@ -17058,7 +17066,6 @@ async function cancelOrder$1({ user, starkSigner, request, ordersApi, guardianCl
17058
17066
  getSignableCancelOrderRequest,
17059
17067
  }, { headers });
17060
17068
  await guardianClient.evaluateImxTransaction({
17061
- user,
17062
17069
  payloadHash: getSignableCancelOrderResponse.data.payload_hash,
17063
17070
  });
17064
17071
  const { payload_hash: payloadHash } = getSignableCancelOrderResponse.data;
@@ -17120,7 +17127,6 @@ async function createTrade$1({ request, tradesApi, user, starkSigner, guardianCl
17120
17127
  getSignableTradeRequest,
17121
17128
  }, { headers });
17122
17129
  await guardianClient.evaluateImxTransaction({
17123
- user,
17124
17130
  payloadHash: getSignableTradeResponse.data.payload_hash,
17125
17131
  });
17126
17132
  const { payload_hash: payloadHash } = getSignableTradeResponse.data;
@@ -17168,7 +17174,6 @@ async function transfer$1({ request, transfersApi, starkSigner, user, guardianCl
17168
17174
  getSignableTransferRequest,
17169
17175
  }, { headers });
17170
17176
  await guardianClient.evaluateImxTransaction({
17171
- user,
17172
17177
  payloadHash: signableResult.data.payload_hash,
17173
17178
  });
17174
17179
  const signableResultData = signableResult.data;
@@ -17219,7 +17224,6 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, guar
17219
17224
  },
17220
17225
  }, { headers });
17221
17226
  await guardianClient.evaluateImxTransaction({
17222
- user,
17223
17227
  payloadHash: signableResult.data.signable_responses[0]?.payload_hash,
17224
17228
  });
17225
17229
  const requests = await Promise.all(signableResult.data.signable_responses.map(async (resp) => {
@@ -17299,6 +17303,7 @@ class PassportImxProvider {
17299
17303
  this.guardianClient = new GuardianClient({
17300
17304
  confirmationScreen,
17301
17305
  config,
17306
+ authManager,
17302
17307
  });
17303
17308
  this.magicAdapter = magicAdapter;
17304
17309
  this.imxApiClients = imxApiClients;
@@ -17930,11 +17935,11 @@ const getEip155ChainId = (chainId) => `eip155:${chainId}`;
17930
17935
  class RelayerClient {
17931
17936
  config;
17932
17937
  jsonRpcProvider;
17933
- user;
17934
- constructor({ config, jsonRpcProvider, user }) {
17938
+ authManager;
17939
+ constructor({ config, jsonRpcProvider, authManager }) {
17935
17940
  this.config = config;
17936
17941
  this.jsonRpcProvider = jsonRpcProvider;
17937
- this.user = user;
17942
+ this.authManager = authManager;
17938
17943
  }
17939
17944
  async postToRelayer(request) {
17940
17945
  const body = {
@@ -17942,10 +17947,11 @@ class RelayerClient {
17942
17947
  jsonrpc: '2.0',
17943
17948
  ...request,
17944
17949
  };
17950
+ const user = await this.authManager.getUser();
17945
17951
  const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
17946
17952
  method: 'POST',
17947
17953
  headers: {
17948
- Authorization: `Bearer ${this.user.accessToken}`,
17954
+ Authorization: `Bearer ${user?.accessToken}`,
17949
17955
  'Content-Type': 'application/json',
17950
17956
  },
17951
17957
  body: JSON.stringify(body),
@@ -18104,7 +18110,7 @@ const getMetaTransactions = async (metaTransaction, nonce, chainId, walletAddres
18104
18110
  }
18105
18111
  return [metaTransaction, feeMetaTransaction];
18106
18112
  };
18107
- const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, user, }) => guardianClient
18113
+ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, zkevmAddress, }) => guardianClient
18108
18114
  .withConfirmationScreen({ width: 480, height: 720 })(async () => {
18109
18115
  const transactionRequest = params[0];
18110
18116
  if (!transactionRequest.to) {
@@ -18114,7 +18120,7 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
18114
18120
  const chainIdBigNumber = BigNumber$1.from(chainId);
18115
18121
  const magicWeb3Provider = new Web3Provider(magicProvider);
18116
18122
  const signer = magicWeb3Provider.getSigner();
18117
- const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
18123
+ const nonce = await getNonce(jsonRpcProvider, zkevmAddress);
18118
18124
  const metaTransaction = {
18119
18125
  to: transactionRequest.to,
18120
18126
  data: transactionRequest.data,
@@ -18122,17 +18128,16 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
18122
18128
  value: transactionRequest.value,
18123
18129
  revertOnError: true,
18124
18130
  };
18125
- const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber, user.zkEvm.ethAddress, signer, relayerClient);
18131
+ const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber, zkevmAddress, signer, relayerClient);
18126
18132
  await guardianClient.validateEVMTransaction({
18127
18133
  chainId: getEip155ChainId(chainId),
18128
18134
  nonce: convertBigNumberishToString(nonce),
18129
- user,
18130
18135
  metaTransactions,
18131
18136
  });
18132
18137
  // NOTE: We sign again because we now are adding the fee transaction, so the
18133
18138
  // whole payload is different and needs a new signature.
18134
- const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, user.zkEvm.ethAddress, signer);
18135
- const relayerId = await relayerClient.ethSendTransaction(user.zkEvm.ethAddress, signedTransactions);
18139
+ const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, zkevmAddress, signer);
18140
+ const relayerId = await relayerClient.ethSendTransaction(zkevmAddress, signedTransactions);
18136
18141
  const retrieveRelayerTransaction = async () => {
18137
18142
  const tx = await relayerClient.imGetTransactionByHash(relayerId);
18138
18143
  // NOTE: The transaction hash is only available from the Relayer once the
@@ -18200,7 +18205,7 @@ const transformTypedData = (typedData, chainId) => {
18200
18205
  }
18201
18206
  return transformedTypedData;
18202
18207
  };
18203
- const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider, relayerClient, guardianClient, user, }) => guardianClient
18208
+ const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider, relayerClient, guardianClient, }) => guardianClient
18204
18209
  .withConfirmationScreen({ width: 480, height: 730 })(async () => {
18205
18210
  const fromAddress = params[0];
18206
18211
  const typedDataParam = params[1];
@@ -18209,7 +18214,7 @@ const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider,
18209
18214
  }
18210
18215
  const { chainId } = await jsonRpcProvider.ready;
18211
18216
  const typedData = transformTypedData(typedDataParam, chainId);
18212
- await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData, user });
18217
+ await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData });
18213
18218
  const relayerSignature = await relayerClient.imSignTypedData(fromAddress, typedData);
18214
18219
  const magicWeb3Provider = new Web3Provider(magicProvider);
18215
18220
  const signer = magicWeb3Provider.getSigner();
@@ -18227,7 +18232,7 @@ class ZkEvmProvider {
18227
18232
  guardianClient;
18228
18233
  relayerClient;
18229
18234
  magicProvider; // Used for signing
18230
- user;
18235
+ zkevmAddress;
18231
18236
  isPassport = true;
18232
18237
  constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, passportEventEmitter, }) {
18233
18238
  this.authManager = authManager;
@@ -18252,7 +18257,6 @@ class ZkEvmProvider {
18252
18257
  handleLogout = () => {
18253
18258
  const shouldEmitAccountsChanged = this.isLoggedIn();
18254
18259
  this.magicProvider = undefined;
18255
- this.user = undefined;
18256
18260
  this.relayerClient = undefined;
18257
18261
  this.guardianClient = undefined;
18258
18262
  if (shouldEmitAccountsChanged) {
@@ -18261,7 +18265,7 @@ class ZkEvmProvider {
18261
18265
  };
18262
18266
  isLoggedIn() {
18263
18267
  return this.magicProvider !== undefined
18264
- && this.user !== undefined
18268
+ && this.zkevmAddress !== undefined
18265
18269
  && this.relayerClient !== undefined
18266
18270
  && this.guardianClient !== undefined;
18267
18271
  }
@@ -18269,7 +18273,7 @@ class ZkEvmProvider {
18269
18273
  switch (request.method) {
18270
18274
  case 'eth_requestAccounts': {
18271
18275
  if (this.isLoggedIn()) {
18272
- return [this.user.zkEvm.ethAddress];
18276
+ return [this.zkevmAddress];
18273
18277
  }
18274
18278
  const { magicProvider, user } = await loginZkEvmUser({
18275
18279
  authManager: this.authManager,
@@ -18278,19 +18282,20 @@ class ZkEvmProvider {
18278
18282
  multiRollupApiClients: this.multiRollupApiClients,
18279
18283
  jsonRpcProvider: this.jsonRpcProvider,
18280
18284
  });
18281
- this.user = user;
18282
18285
  this.magicProvider = magicProvider;
18283
18286
  this.relayerClient = new RelayerClient({
18284
18287
  config: this.config,
18285
18288
  jsonRpcProvider: this.jsonRpcProvider,
18286
- user: this.user,
18289
+ authManager: this.authManager,
18287
18290
  });
18288
18291
  this.guardianClient = new GuardianClient({
18289
18292
  confirmationScreen: this.confirmationScreen,
18290
18293
  config: this.config,
18294
+ authManager: this.authManager,
18291
18295
  });
18292
- this.eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
18293
- return [this.user.zkEvm.ethAddress];
18296
+ this.zkevmAddress = user.zkEvm.ethAddress;
18297
+ this.eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [user.zkEvm.ethAddress]);
18298
+ return [user.zkEvm.ethAddress];
18294
18299
  }
18295
18300
  case 'eth_sendTransaction': {
18296
18301
  if (!this.isLoggedIn()) {
@@ -18302,11 +18307,11 @@ class ZkEvmProvider {
18302
18307
  guardianClient: this.guardianClient,
18303
18308
  jsonRpcProvider: this.jsonRpcProvider,
18304
18309
  relayerClient: this.relayerClient,
18305
- user: this.user,
18310
+ zkevmAddress: this.zkevmAddress,
18306
18311
  });
18307
18312
  }
18308
18313
  case 'eth_accounts': {
18309
- return this.isLoggedIn() ? [this.user.zkEvm.ethAddress] : [];
18314
+ return this.zkevmAddress ? [this.zkevmAddress] : [];
18310
18315
  }
18311
18316
  case 'eth_signTypedData':
18312
18317
  case 'eth_signTypedData_v4': {
@@ -18319,7 +18324,6 @@ class ZkEvmProvider {
18319
18324
  magicProvider: this.magicProvider,
18320
18325
  jsonRpcProvider: this.jsonRpcProvider,
18321
18326
  relayerClient: this.relayerClient,
18322
- user: this.user,
18323
18327
  guardianClient: this.guardianClient,
18324
18328
  });
18325
18329
  }
@@ -37040,7 +37044,7 @@ const flattenProperties = (properties) => {
37040
37044
  };
37041
37045
 
37042
37046
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
37043
- const SDK_VERSION = '1.5.0';
37047
+ const SDK_VERSION = '1.5.1';
37044
37048
  let initialised = false;
37045
37049
  const isInitialised = () => initialised;
37046
37050
  const getReferrer = () => {
@@ -42148,7 +42152,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
42148
42152
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
42149
42153
  };
42150
42154
 
42151
- const SDK_VERSION_MARKER = '1.5.0';
42155
+ const SDK_VERSION_MARKER = '1.5.1';
42152
42156
  // This SDK version is replaced by the `yarn build` command ran on the root level
42153
42157
  const globalPackageVersion = () => SDK_VERSION_MARKER;
42154
42158
 
@@ -45410,9 +45414,7 @@ const buy = async (config, provider, orders, overrides = {
45410
45414
  };
45411
45415
  };
45412
45416
 
45413
- const cancel = async (config, provider, orderIds, overrides = {
45414
- waitFulfillmentSettlements: true,
45415
- }) => {
45417
+ const cancelOnChain = async (config, orderbook, provider, orderIds, waitFulfillmentSettlements) => {
45416
45418
  let unsignedCancelOrderTransaction;
45417
45419
  if (orderIds.length === 0) {
45418
45420
  throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
@@ -45421,7 +45423,6 @@ const cancel = async (config, provider, orderIds, overrides = {
45421
45423
  const orderId = orderIds[0];
45422
45424
  try {
45423
45425
  const offererAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
45424
- const orderbook = createOrderbookInstance(config);
45425
45426
  const cancelOrderResponse = await measureAsyncExecution(config, 'Time to get the cancel order from the orderbook', orderbook.cancelOrdersOnChain([orderId], offererAddress));
45426
45427
  unsignedCancelOrderTransaction = await cancelOrderResponse.cancellationAction.buildTransaction();
45427
45428
  }
@@ -45431,7 +45432,7 @@ const cancel = async (config, provider, orderIds, overrides = {
45431
45432
  error: err,
45432
45433
  });
45433
45434
  }
45434
- if (overrides.waitFulfillmentSettlements) {
45435
+ if (waitFulfillmentSettlements) {
45435
45436
  const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
45436
45437
  if (result.type === SignTransactionStatusType.FAILED) {
45437
45438
  return {
@@ -45459,6 +45460,56 @@ const cancel = async (config, provider, orderIds, overrides = {
45459
45460
  transactions,
45460
45461
  };
45461
45462
  };
45463
+ const gaslessCancel = async (orderbook, provider, orderIds) => {
45464
+ try {
45465
+ const signer = provider.getSigner();
45466
+ const address = await signer.getAddress();
45467
+ const { signableAction } = await orderbook.prepareOrderCancellations(orderIds);
45468
+ // eslint-disable-next-line no-underscore-dangle
45469
+ const signedMessage = await signer._signTypedData(signableAction.message.domain, signableAction.message.types, signableAction.message.value);
45470
+ const { result } = await orderbook.cancelOrders(orderIds, address, signedMessage);
45471
+ const successfulCancellations = [];
45472
+ const failedCancellations = [];
45473
+ const pendingCancellations = [];
45474
+ for (const success of result.successful_cancellations) {
45475
+ successfulCancellations.push({
45476
+ orderId: success,
45477
+ });
45478
+ }
45479
+ for (const failed of result.failed_cancellations) {
45480
+ failedCancellations.push({
45481
+ orderId: failed.order,
45482
+ reason: failed.reason_code,
45483
+ });
45484
+ }
45485
+ for (const pending of result.pending_cancellations) {
45486
+ pendingCancellations.push({
45487
+ orderId: pending,
45488
+ });
45489
+ }
45490
+ return {
45491
+ successfulCancellations,
45492
+ failedCancellations,
45493
+ pendingCancellations,
45494
+ };
45495
+ }
45496
+ catch (err) {
45497
+ throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
45498
+ orderIds,
45499
+ error: err,
45500
+ });
45501
+ }
45502
+ };
45503
+ const cancel = async (config, provider, orderIds, overrides = {
45504
+ waitFulfillmentSettlements: true,
45505
+ useGaslessCancel: false,
45506
+ }) => {
45507
+ const orderbook = createOrderbookInstance(config);
45508
+ if (overrides.useGaslessCancel) {
45509
+ return await gaslessCancel(orderbook, provider, orderIds);
45510
+ }
45511
+ return await cancelOnChain(config, orderbook, provider, orderIds, overrides.waitFulfillmentSettlements ?? true);
45512
+ };
45462
45513
 
45463
45514
  const getERC721Requirement = (id, contractAddress, spenderAddress) => ({
45464
45515
  type: ItemType.ERC721,
package/dist/orderbook.js CHANGED
@@ -126,7 +126,7 @@ const flattenProperties = (properties) => {
126
126
  };
127
127
 
128
128
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
129
- const SDK_VERSION = '1.5.0';
129
+ const SDK_VERSION = '1.5.1';
130
130
  let initialised = false;
131
131
  const isInitialised = () => initialised;
132
132
  const getReferrer = () => {