@imtbl/sdk 0.25.0 → 0.27.0

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.cjs CHANGED
@@ -3555,7 +3555,7 @@ class MultiRollupApiClients {
3555
3555
  }
3556
3556
 
3557
3557
  // eslint-disable-next-line @typescript-eslint/naming-convention
3558
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.25.0' };
3558
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.0' };
3559
3559
  const createConfig = ({ basePath, headers, }) => {
3560
3560
  if (!basePath.trim()) {
3561
3561
  throw Error('basePath can not be empty');
@@ -3615,7 +3615,7 @@ class APIError extends Error {
3615
3615
 
3616
3616
  /* eslint-disable implicit-arrow-linebreak */
3617
3617
  const defaultHeaders = {
3618
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.25.0',
3618
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.0',
3619
3619
  };
3620
3620
  /**
3621
3621
  * createAPIConfiguration to create a custom Configuration
@@ -3932,6 +3932,20 @@ class BlockchainData {
3932
3932
  throw formatError(err);
3933
3933
  });
3934
3934
  }
3935
+ /**
3936
+ * Get metadata by ID
3937
+ * @param request - the request object containing the parameters to be provided in the API request
3938
+ * @returns a promise that resolves with a single Metadata
3939
+ * @throws {@link index.APIError}
3940
+ */
3941
+ async getMetadata(request) {
3942
+ return await this.metadata
3943
+ .getMetadata(request)
3944
+ .then((res) => res.data)
3945
+ .catch((err) => {
3946
+ throw formatError(err);
3947
+ });
3948
+ }
3935
3949
  /**
3936
3950
  * List NFT Metadata by contract address
3937
3951
  * @param request - the request object containing the parameters to be provided in the API request
@@ -4005,7 +4019,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4005
4019
  chainID,
4006
4020
  coreContractAddress,
4007
4021
  registrationContractAddress,
4008
- sdkVersion: 'ts-immutable-sdk-0.25.0',
4022
+ sdkVersion: 'ts-immutable-sdk-0.27.0',
4009
4023
  });
4010
4024
  /**
4011
4025
  * Sets `sdkVersion` at the time of build
@@ -28926,6 +28940,11 @@ const $d85ad1457a3f1a83$var$ZKEVM_NATIVE_TOKEN = {
28926
28940
  decimals: $d85ad1457a3f1a83$export$903389470ba9433c,
28927
28941
  address: $d85ad1457a3f1a83$export$b80040cb173ba6e9
28928
28942
  };
28943
+ ({
28944
+ [$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://api.dev.immutable.com",
28945
+ [(Environment$1).SANDBOX]: "https://api.sandbox.immutable.com",
28946
+ [(Environment$1).PRODUCTION]: "https://api.immutable.com"
28947
+ });
28929
28948
  const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
28930
28949
  [$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://checkout-api.dev.immutable.com",
28931
28950
  [(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
@@ -29318,6 +29337,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
29318
29337
  CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
29319
29338
  CheckoutErrorType["ORDER_FEE_ERROR"] = "ORDER_FEE_ERROR";
29320
29339
  CheckoutErrorType["ITEM_REQUIREMENTS_ERROR"] = "ITEM_REQUIREMENTS_ERROR";
29340
+ CheckoutErrorType["API_ERROR"] = "API_ERROR";
29321
29341
  })($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
29322
29342
  class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
29323
29343
  message;
@@ -29498,6 +29518,7 @@ async function $de192de6ef100f9f$export$b827d9418aeb5dbd(config, web3Provider, c
29498
29518
 
29499
29519
 
29500
29520
 
29521
+
29501
29522
  class $a492ee374ae7b613$export$d902b56530cd5f87 {
29502
29523
  isDevelopment;
29503
29524
  isProduction;
@@ -29512,9 +29533,9 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
29512
29533
  try {
29513
29534
  response = await (0, globalAxios$1).get(url);
29514
29535
  } catch (error) {
29515
- throw new Error(`Error fetching from api: ${error.message}`);
29536
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Error fetching from api: ${error.message}`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).API_ERROR);
29516
29537
  }
29517
- if (response.status !== 200) throw new Error(`Error fetching from api: ${response.status} ${response.statusText}`);
29538
+ if (response.status !== 200) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Error fetching from api: ${response.status} ${response.statusText}`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).API_ERROR);
29518
29539
  return response;
29519
29540
  }
29520
29541
  getEndpoint = ()=>{
@@ -31050,17 +31071,23 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
31050
31071
  try {
31051
31072
  const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, config);
31052
31073
  const dexTransactionResponsePromises = [];
31074
+ const fromToken = [];
31053
31075
  // Create a quote for each swappable token
31054
- for (const swappableToken of swappableTokens)dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount, slippagePercent));
31076
+ for (const swappableToken of swappableTokens){
31077
+ if (swappableToken === requiredToken.address) continue;
31078
+ dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount, slippagePercent));
31079
+ fromToken.push(swappableToken);
31080
+ }
31055
31081
  // Resolve all the quotes and link them back to the swappable token
31056
31082
  // The swappable token array is in the same position in the array as the quote in the promise array
31057
- const dexTransactionResponse = await Promise.all(dexTransactionResponsePromises);
31083
+ const dexTransactionResponse = await Promise.allSettled(dexTransactionResponsePromises);
31058
31084
  dexTransactionResponse.forEach((response, index)=>{
31059
- const swappableToken = swappableTokens[index];
31085
+ if (response.status === "rejected") return; // Ignore any requests to dex that failed to resolve
31086
+ const swappableToken = fromToken[index];
31060
31087
  dexQuotes.set(swappableToken, {
31061
- quote: response.quote,
31062
- approval: response.approval?.gasFeeEstimate,
31063
- swap: response.swap.gasFeeEstimate
31088
+ quote: response.value.quote,
31089
+ approval: response.value.approval?.gasFeeEstimate,
31090
+ swap: response.value.swap.gasFeeEstimate
31064
31091
  });
31065
31092
  });
31066
31093
  return dexQuotes;
@@ -32013,15 +32040,6 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32013
32040
  fundingRoutes: []
32014
32041
  };
32015
32042
  let priority = 0;
32016
- if (bridgeFundingStep) {
32017
- priority++;
32018
- response.fundingRoutes.push({
32019
- priority: priority,
32020
- steps: [
32021
- bridgeFundingStep
32022
- ]
32023
- });
32024
- }
32025
32043
  if (swapFundingSteps.length > 0) {
32026
32044
  priority++;
32027
32045
  swapFundingSteps.forEach((swapFundingStep)=>{
@@ -32033,6 +32051,15 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32033
32051
  });
32034
32052
  });
32035
32053
  }
32054
+ if (bridgeFundingStep) {
32055
+ priority++;
32056
+ response.fundingRoutes.push({
32057
+ priority: priority,
32058
+ steps: [
32059
+ bridgeFundingStep
32060
+ ]
32061
+ });
32062
+ }
32036
32063
  if (onRampFundingStep) {
32037
32064
  priority++;
32038
32065
  response.fundingRoutes.push({
@@ -32080,12 +32107,10 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemR
32080
32107
  };
32081
32108
  const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
32082
32109
  const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
32083
- const isPassport = provider.provider?.isPassport || false;
32084
32110
  return {
32085
32111
  sufficient: sufficient,
32086
32112
  transactionRequirements: transactionRequirements,
32087
32113
  router: {
32088
- isPassport: isPassport,
32089
32114
  availableRoutingOptions: availableRoutingOptions,
32090
32115
  routingOutcome: routingOutcome
32091
32116
  }
@@ -32299,7 +32324,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32299
32324
  let order;
32300
32325
  let spenderAddress = "";
32301
32326
  const gasLimit = (constants).estimatedFulfillmentGasGwei;
32302
- if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were passed in, must pass at least one order", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).FULFILL_ORDER_LISTING_ERROR);
32327
+ if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were provided to the orders array. Please provide at least one order.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).FULFILL_ORDER_LISTING_ERROR);
32303
32328
  const { id: id, takerFees: takerFees } = orders[0];
32304
32329
  try {
32305
32330
  orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
@@ -32375,9 +32400,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32375
32400
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
32376
32401
  transactionHash: approvalResult.transactionHash,
32377
32402
  reason: approvalResult.reason,
32378
- smartCheckoutResult: [
32379
- smartCheckoutResult
32380
- ]
32403
+ smartCheckoutResult: smartCheckoutResult
32381
32404
  };
32382
32405
  try {
32383
32406
  if (unsignedFulfillmentTransactions.length === 0) unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
@@ -32391,22 +32414,16 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32391
32414
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
32392
32415
  transactionHash: fulfillmentResult.transactionHash,
32393
32416
  reason: fulfillmentResult.reason,
32394
- smartCheckoutResult: [
32395
- smartCheckoutResult
32396
- ]
32417
+ smartCheckoutResult: smartCheckoutResult
32397
32418
  };
32398
32419
  return {
32399
32420
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
32400
- smartCheckoutResult: [
32401
- smartCheckoutResult
32402
- ]
32421
+ smartCheckoutResult: smartCheckoutResult
32403
32422
  };
32404
32423
  }
32405
32424
  return {
32406
32425
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
32407
- smartCheckoutResult: [
32408
- smartCheckoutResult
32409
- ]
32426
+ smartCheckoutResult: smartCheckoutResult
32410
32427
  };
32411
32428
  };
32412
32429
 
@@ -32420,7 +32437,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32420
32437
 
32421
32438
  const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
32422
32439
  let unsignedCancelOrderTransaction;
32423
- if (orderIds.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orderIds were passed in, must pass at least one orderId to cancel", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR);
32440
+ if (orderIds.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orderIds were provided to the orderIds array. Please provide at least one orderId.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR);
32424
32441
  // Update this when bulk cancel is supported
32425
32442
  const orderId = orderIds[0];
32426
32443
  try {
@@ -32481,7 +32498,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32481
32498
  let orderbook;
32482
32499
  let listing;
32483
32500
  let spenderAddress = "";
32484
- if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were parsed, must parse at least one order", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR);
32501
+ if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were provided to the orders array. Please provide at least one order.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR);
32485
32502
  const { buyToken: buyToken, sellToken: sellToken, makerFees: makerFees } = orders[0];
32486
32503
  let decimals = 18;
32487
32504
  if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
@@ -32528,9 +32545,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32528
32545
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
32529
32546
  transactionHash: approvalResult.transactionHash,
32530
32547
  reason: approvalResult.reason,
32531
- smartCheckoutResult: [
32532
- smartCheckoutResult
32533
- ]
32548
+ smartCheckoutResult: smartCheckoutResult
32534
32549
  };
32535
32550
  const unsignedMessage = ($a7367d01c6e76b1c$export$d62081fac18000c2)(listing.orderHash, listing.orderComponents, listing.actions);
32536
32551
  if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
@@ -32567,16 +32582,12 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32567
32582
  orderIds: [
32568
32583
  orderId
32569
32584
  ],
32570
- smartCheckoutResult: [
32571
- smartCheckoutResult
32572
- ]
32585
+ smartCheckoutResult: smartCheckoutResult
32573
32586
  };
32574
32587
  }
32575
32588
  return {
32576
32589
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
32577
- smartCheckoutResult: [
32578
- smartCheckoutResult
32579
- ]
32590
+ smartCheckoutResult: smartCheckoutResult
32580
32591
  };
32581
32592
  };
32582
32593
 
@@ -32933,7 +32944,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
32933
32944
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
32934
32945
 
32935
32946
 
32936
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.25.0";
32947
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.0";
32937
32948
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
32938
32949
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
32939
32950
 
@@ -33067,7 +33078,7 @@ var $207ed853f11d19d5$export$5a0ace85cae72d45;
33067
33078
  IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
33068
33079
  IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
33069
33080
  IMTBLWidgetEvents["IMTBL_ONRAMP_WIDGET_EVENT"] = "imtbl-onramp-widget";
33070
- IMTBLWidgetEvents["IMTBL_PRIMARY_REVENUE_WIDGET_EVENT"] = "imtbl-primary-revenue-widget";
33081
+ IMTBLWidgetEvents["IMTBL_PRIMARY_REVENUE_WIDGET_EVENT"] = "imtbl-sale-widget";
33071
33082
  })($207ed853f11d19d5$export$5a0ace85cae72d45 || ($207ed853f11d19d5$export$5a0ace85cae72d45 = {}));
33072
33083
 
33073
33084
 
@@ -33107,18 +33118,18 @@ $parcel$export($53d219e7f6bf0cd6$exports, "SwapEventType", () => $53d219e7f6bf0c
33107
33118
  })($53d219e7f6bf0cd6$export$140a49745ab55563 || ($53d219e7f6bf0cd6$export$140a49745ab55563 = {}));
33108
33119
 
33109
33120
 
33110
- var $8c83f59522c4ca40$exports = {};
33121
+ var $9b3189b6b155842e$exports = {};
33111
33122
 
33112
- $parcel$export($8c83f59522c4ca40$exports, "PrimaryRevenueEventType", () => $8c83f59522c4ca40$export$b33478ffb988bd5e);
33123
+ $parcel$export($9b3189b6b155842e$exports, "SaleEventType", () => $9b3189b6b155842e$export$881881ffb3bd733e);
33113
33124
  /**
33114
- * Enum representing possible Primary Revenue Widget event types.
33115
- */ var $8c83f59522c4ca40$export$b33478ffb988bd5e;
33116
- (function(PrimaryRevenueEventType) {
33117
- PrimaryRevenueEventType["CLOSE_WIDGET"] = "close-widget";
33118
- PrimaryRevenueEventType["SUCCESS"] = "success";
33119
- PrimaryRevenueEventType["FAILURE"] = "failure";
33120
- PrimaryRevenueEventType["REJECTED"] = "rejected";
33121
- })($8c83f59522c4ca40$export$b33478ffb988bd5e || ($8c83f59522c4ca40$export$b33478ffb988bd5e = {}));
33125
+ * Enum representing possible Sale Widget event types.
33126
+ */ var $9b3189b6b155842e$export$881881ffb3bd733e;
33127
+ (function(SaleEventType) {
33128
+ SaleEventType["CLOSE_WIDGET"] = "close-widget";
33129
+ SaleEventType["SUCCESS"] = "success";
33130
+ SaleEventType["FAILURE"] = "failure";
33131
+ SaleEventType["REJECTED"] = "rejected";
33132
+ })($9b3189b6b155842e$export$881881ffb3bd733e || ($9b3189b6b155842e$export$881881ffb3bd733e = {}));
33122
33133
 
33123
33134
 
33124
33135
  var $15cc9e120aa6f3bf$exports = {};
@@ -33366,7 +33377,7 @@ var checkout_widgets = /*#__PURE__*/Object.freeze({
33366
33377
  get OnRampEventType () { return $d882ddc5600b1284$export$66ec39c0924078d8; },
33367
33378
  OnRampReact: $f94f63f2c041a04c$export$9e363c61ea99bbb4,
33368
33379
  get OrchestrationEventType () { return $ad06b030b1a3ba34$export$b80d2daf830437b9; },
33369
- get PrimaryRevenueEventType () { return $8c83f59522c4ca40$export$b33478ffb988bd5e; },
33380
+ get SaleEventType () { return $9b3189b6b155842e$export$881881ffb3bd733e; },
33370
33381
  get SwapEventType () { return $53d219e7f6bf0cd6$export$140a49745ab55563; },
33371
33382
  SwapReact: $a4fbb8e3a6aeff58$export$971e031379577f4,
33372
33383
  UpdateConfig: $430e3eda76fa4d5f$export$bf1548ba7e61c17f,