@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.js CHANGED
@@ -3533,7 +3533,7 @@ class MultiRollupApiClients {
3533
3533
  }
3534
3534
 
3535
3535
  // eslint-disable-next-line @typescript-eslint/naming-convention
3536
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.25.0' };
3536
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.0' };
3537
3537
  const createConfig = ({ basePath, headers, }) => {
3538
3538
  if (!basePath.trim()) {
3539
3539
  throw Error('basePath can not be empty');
@@ -3593,7 +3593,7 @@ class APIError extends Error {
3593
3593
 
3594
3594
  /* eslint-disable implicit-arrow-linebreak */
3595
3595
  const defaultHeaders = {
3596
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.25.0',
3596
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.0',
3597
3597
  };
3598
3598
  /**
3599
3599
  * createAPIConfiguration to create a custom Configuration
@@ -3910,6 +3910,20 @@ class BlockchainData {
3910
3910
  throw formatError(err);
3911
3911
  });
3912
3912
  }
3913
+ /**
3914
+ * Get metadata by ID
3915
+ * @param request - the request object containing the parameters to be provided in the API request
3916
+ * @returns a promise that resolves with a single Metadata
3917
+ * @throws {@link index.APIError}
3918
+ */
3919
+ async getMetadata(request) {
3920
+ return await this.metadata
3921
+ .getMetadata(request)
3922
+ .then((res) => res.data)
3923
+ .catch((err) => {
3924
+ throw formatError(err);
3925
+ });
3926
+ }
3913
3927
  /**
3914
3928
  * List NFT Metadata by contract address
3915
3929
  * @param request - the request object containing the parameters to be provided in the API request
@@ -3983,7 +3997,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
3983
3997
  chainID,
3984
3998
  coreContractAddress,
3985
3999
  registrationContractAddress,
3986
- sdkVersion: 'ts-immutable-sdk-0.25.0',
4000
+ sdkVersion: 'ts-immutable-sdk-0.27.0',
3987
4001
  });
3988
4002
  /**
3989
4003
  * Sets `sdkVersion` at the time of build
@@ -28904,6 +28918,11 @@ const $d85ad1457a3f1a83$var$ZKEVM_NATIVE_TOKEN = {
28904
28918
  decimals: $d85ad1457a3f1a83$export$903389470ba9433c,
28905
28919
  address: $d85ad1457a3f1a83$export$b80040cb173ba6e9
28906
28920
  };
28921
+ ({
28922
+ [$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://api.dev.immutable.com",
28923
+ [(Environment$1).SANDBOX]: "https://api.sandbox.immutable.com",
28924
+ [(Environment$1).PRODUCTION]: "https://api.immutable.com"
28925
+ });
28907
28926
  const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
28908
28927
  [$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://checkout-api.dev.immutable.com",
28909
28928
  [(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
@@ -29296,6 +29315,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
29296
29315
  CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
29297
29316
  CheckoutErrorType["ORDER_FEE_ERROR"] = "ORDER_FEE_ERROR";
29298
29317
  CheckoutErrorType["ITEM_REQUIREMENTS_ERROR"] = "ITEM_REQUIREMENTS_ERROR";
29318
+ CheckoutErrorType["API_ERROR"] = "API_ERROR";
29299
29319
  })($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
29300
29320
  class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
29301
29321
  message;
@@ -29476,6 +29496,7 @@ async function $de192de6ef100f9f$export$b827d9418aeb5dbd(config, web3Provider, c
29476
29496
 
29477
29497
 
29478
29498
 
29499
+
29479
29500
  class $a492ee374ae7b613$export$d902b56530cd5f87 {
29480
29501
  isDevelopment;
29481
29502
  isProduction;
@@ -29490,9 +29511,9 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
29490
29511
  try {
29491
29512
  response = await (0, globalAxios$1).get(url);
29492
29513
  } catch (error) {
29493
- throw new Error(`Error fetching from api: ${error.message}`);
29514
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Error fetching from api: ${error.message}`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).API_ERROR);
29494
29515
  }
29495
- if (response.status !== 200) throw new Error(`Error fetching from api: ${response.status} ${response.statusText}`);
29516
+ if (response.status !== 200) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Error fetching from api: ${response.status} ${response.statusText}`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).API_ERROR);
29496
29517
  return response;
29497
29518
  }
29498
29519
  getEndpoint = ()=>{
@@ -31028,17 +31049,23 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
31028
31049
  try {
31029
31050
  const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, config);
31030
31051
  const dexTransactionResponsePromises = [];
31052
+ const fromToken = [];
31031
31053
  // Create a quote for each swappable token
31032
- for (const swappableToken of swappableTokens)dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount, slippagePercent));
31054
+ for (const swappableToken of swappableTokens){
31055
+ if (swappableToken === requiredToken.address) continue;
31056
+ dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount, slippagePercent));
31057
+ fromToken.push(swappableToken);
31058
+ }
31033
31059
  // Resolve all the quotes and link them back to the swappable token
31034
31060
  // The swappable token array is in the same position in the array as the quote in the promise array
31035
- const dexTransactionResponse = await Promise.all(dexTransactionResponsePromises);
31061
+ const dexTransactionResponse = await Promise.allSettled(dexTransactionResponsePromises);
31036
31062
  dexTransactionResponse.forEach((response, index)=>{
31037
- const swappableToken = swappableTokens[index];
31063
+ if (response.status === "rejected") return; // Ignore any requests to dex that failed to resolve
31064
+ const swappableToken = fromToken[index];
31038
31065
  dexQuotes.set(swappableToken, {
31039
- quote: response.quote,
31040
- approval: response.approval?.gasFeeEstimate,
31041
- swap: response.swap.gasFeeEstimate
31066
+ quote: response.value.quote,
31067
+ approval: response.value.approval?.gasFeeEstimate,
31068
+ swap: response.value.swap.gasFeeEstimate
31042
31069
  });
31043
31070
  });
31044
31071
  return dexQuotes;
@@ -31991,15 +32018,6 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
31991
32018
  fundingRoutes: []
31992
32019
  };
31993
32020
  let priority = 0;
31994
- if (bridgeFundingStep) {
31995
- priority++;
31996
- response.fundingRoutes.push({
31997
- priority: priority,
31998
- steps: [
31999
- bridgeFundingStep
32000
- ]
32001
- });
32002
- }
32003
32021
  if (swapFundingSteps.length > 0) {
32004
32022
  priority++;
32005
32023
  swapFundingSteps.forEach((swapFundingStep)=>{
@@ -32011,6 +32029,15 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32011
32029
  });
32012
32030
  });
32013
32031
  }
32032
+ if (bridgeFundingStep) {
32033
+ priority++;
32034
+ response.fundingRoutes.push({
32035
+ priority: priority,
32036
+ steps: [
32037
+ bridgeFundingStep
32038
+ ]
32039
+ });
32040
+ }
32014
32041
  if (onRampFundingStep) {
32015
32042
  priority++;
32016
32043
  response.fundingRoutes.push({
@@ -32058,12 +32085,10 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemR
32058
32085
  };
32059
32086
  const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
32060
32087
  const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
32061
- const isPassport = provider.provider?.isPassport || false;
32062
32088
  return {
32063
32089
  sufficient: sufficient,
32064
32090
  transactionRequirements: transactionRequirements,
32065
32091
  router: {
32066
- isPassport: isPassport,
32067
32092
  availableRoutingOptions: availableRoutingOptions,
32068
32093
  routingOutcome: routingOutcome
32069
32094
  }
@@ -32277,7 +32302,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32277
32302
  let order;
32278
32303
  let spenderAddress = "";
32279
32304
  const gasLimit = (constants).estimatedFulfillmentGasGwei;
32280
- 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);
32305
+ 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);
32281
32306
  const { id: id, takerFees: takerFees } = orders[0];
32282
32307
  try {
32283
32308
  orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
@@ -32353,9 +32378,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32353
32378
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
32354
32379
  transactionHash: approvalResult.transactionHash,
32355
32380
  reason: approvalResult.reason,
32356
- smartCheckoutResult: [
32357
- smartCheckoutResult
32358
- ]
32381
+ smartCheckoutResult: smartCheckoutResult
32359
32382
  };
32360
32383
  try {
32361
32384
  if (unsignedFulfillmentTransactions.length === 0) unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
@@ -32369,22 +32392,16 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32369
32392
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
32370
32393
  transactionHash: fulfillmentResult.transactionHash,
32371
32394
  reason: fulfillmentResult.reason,
32372
- smartCheckoutResult: [
32373
- smartCheckoutResult
32374
- ]
32395
+ smartCheckoutResult: smartCheckoutResult
32375
32396
  };
32376
32397
  return {
32377
32398
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
32378
- smartCheckoutResult: [
32379
- smartCheckoutResult
32380
- ]
32399
+ smartCheckoutResult: smartCheckoutResult
32381
32400
  };
32382
32401
  }
32383
32402
  return {
32384
32403
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
32385
- smartCheckoutResult: [
32386
- smartCheckoutResult
32387
- ]
32404
+ smartCheckoutResult: smartCheckoutResult
32388
32405
  };
32389
32406
  };
32390
32407
 
@@ -32398,7 +32415,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32398
32415
 
32399
32416
  const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
32400
32417
  let unsignedCancelOrderTransaction;
32401
- 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);
32418
+ 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);
32402
32419
  // Update this when bulk cancel is supported
32403
32420
  const orderId = orderIds[0];
32404
32421
  try {
@@ -32459,7 +32476,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32459
32476
  let orderbook;
32460
32477
  let listing;
32461
32478
  let spenderAddress = "";
32462
- 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);
32479
+ 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);
32463
32480
  const { buyToken: buyToken, sellToken: sellToken, makerFees: makerFees } = orders[0];
32464
32481
  let decimals = 18;
32465
32482
  if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
@@ -32506,9 +32523,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32506
32523
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
32507
32524
  transactionHash: approvalResult.transactionHash,
32508
32525
  reason: approvalResult.reason,
32509
- smartCheckoutResult: [
32510
- smartCheckoutResult
32511
- ]
32526
+ smartCheckoutResult: smartCheckoutResult
32512
32527
  };
32513
32528
  const unsignedMessage = ($a7367d01c6e76b1c$export$d62081fac18000c2)(listing.orderHash, listing.orderComponents, listing.actions);
32514
32529
  if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
@@ -32545,16 +32560,12 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32545
32560
  orderIds: [
32546
32561
  orderId
32547
32562
  ],
32548
- smartCheckoutResult: [
32549
- smartCheckoutResult
32550
- ]
32563
+ smartCheckoutResult: smartCheckoutResult
32551
32564
  };
32552
32565
  }
32553
32566
  return {
32554
32567
  status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
32555
- smartCheckoutResult: [
32556
- smartCheckoutResult
32557
- ]
32568
+ smartCheckoutResult: smartCheckoutResult
32558
32569
  };
32559
32570
  };
32560
32571
 
@@ -32911,7 +32922,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
32911
32922
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
32912
32923
 
32913
32924
 
32914
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.25.0";
32925
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.0";
32915
32926
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
32916
32927
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
32917
32928
 
@@ -33045,7 +33056,7 @@ var $207ed853f11d19d5$export$5a0ace85cae72d45;
33045
33056
  IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
33046
33057
  IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
33047
33058
  IMTBLWidgetEvents["IMTBL_ONRAMP_WIDGET_EVENT"] = "imtbl-onramp-widget";
33048
- IMTBLWidgetEvents["IMTBL_PRIMARY_REVENUE_WIDGET_EVENT"] = "imtbl-primary-revenue-widget";
33059
+ IMTBLWidgetEvents["IMTBL_PRIMARY_REVENUE_WIDGET_EVENT"] = "imtbl-sale-widget";
33049
33060
  })($207ed853f11d19d5$export$5a0ace85cae72d45 || ($207ed853f11d19d5$export$5a0ace85cae72d45 = {}));
33050
33061
 
33051
33062
 
@@ -33085,18 +33096,18 @@ $parcel$export($53d219e7f6bf0cd6$exports, "SwapEventType", () => $53d219e7f6bf0c
33085
33096
  })($53d219e7f6bf0cd6$export$140a49745ab55563 || ($53d219e7f6bf0cd6$export$140a49745ab55563 = {}));
33086
33097
 
33087
33098
 
33088
- var $8c83f59522c4ca40$exports = {};
33099
+ var $9b3189b6b155842e$exports = {};
33089
33100
 
33090
- $parcel$export($8c83f59522c4ca40$exports, "PrimaryRevenueEventType", () => $8c83f59522c4ca40$export$b33478ffb988bd5e);
33101
+ $parcel$export($9b3189b6b155842e$exports, "SaleEventType", () => $9b3189b6b155842e$export$881881ffb3bd733e);
33091
33102
  /**
33092
- * Enum representing possible Primary Revenue Widget event types.
33093
- */ var $8c83f59522c4ca40$export$b33478ffb988bd5e;
33094
- (function(PrimaryRevenueEventType) {
33095
- PrimaryRevenueEventType["CLOSE_WIDGET"] = "close-widget";
33096
- PrimaryRevenueEventType["SUCCESS"] = "success";
33097
- PrimaryRevenueEventType["FAILURE"] = "failure";
33098
- PrimaryRevenueEventType["REJECTED"] = "rejected";
33099
- })($8c83f59522c4ca40$export$b33478ffb988bd5e || ($8c83f59522c4ca40$export$b33478ffb988bd5e = {}));
33103
+ * Enum representing possible Sale Widget event types.
33104
+ */ var $9b3189b6b155842e$export$881881ffb3bd733e;
33105
+ (function(SaleEventType) {
33106
+ SaleEventType["CLOSE_WIDGET"] = "close-widget";
33107
+ SaleEventType["SUCCESS"] = "success";
33108
+ SaleEventType["FAILURE"] = "failure";
33109
+ SaleEventType["REJECTED"] = "rejected";
33110
+ })($9b3189b6b155842e$export$881881ffb3bd733e || ($9b3189b6b155842e$export$881881ffb3bd733e = {}));
33100
33111
 
33101
33112
 
33102
33113
  var $15cc9e120aa6f3bf$exports = {};
@@ -33344,7 +33355,7 @@ var checkout_widgets = /*#__PURE__*/Object.freeze({
33344
33355
  get OnRampEventType () { return $d882ddc5600b1284$export$66ec39c0924078d8; },
33345
33356
  OnRampReact: $f94f63f2c041a04c$export$9e363c61ea99bbb4,
33346
33357
  get OrchestrationEventType () { return $ad06b030b1a3ba34$export$b80d2daf830437b9; },
33347
- get PrimaryRevenueEventType () { return $8c83f59522c4ca40$export$b33478ffb988bd5e; },
33358
+ get SaleEventType () { return $9b3189b6b155842e$export$881881ffb3bd733e; },
33348
33359
  get SwapEventType () { return $53d219e7f6bf0cd6$export$140a49745ab55563; },
33349
33360
  SwapReact: $a4fbb8e3a6aeff58$export$971e031379577f4,
33350
33361
  UpdateConfig: $430e3eda76fa4d5f$export$bf1548ba7e61c17f,
package/dist/passport.js CHANGED
@@ -2067,7 +2067,7 @@ class MultiRollupApiClients {
2067
2067
  }
2068
2068
 
2069
2069
  // eslint-disable-next-line @typescript-eslint/naming-convention
2070
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.25.0' };
2070
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.0' };
2071
2071
  const createConfig = ({ basePath, headers, }) => {
2072
2072
  if (!basePath.trim()) {
2073
2073
  throw Error('basePath can not be empty');
@@ -2123,7 +2123,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2123
2123
  chainID,
2124
2124
  coreContractAddress,
2125
2125
  registrationContractAddress,
2126
- sdkVersion: 'ts-immutable-sdk-0.25.0',
2126
+ sdkVersion: 'ts-immutable-sdk-0.27.0',
2127
2127
  });
2128
2128
  /**
2129
2129
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.25.0",
4
+ "version": "0.27.0",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",