@imtbl/sdk 1.76.11 → 1.77.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.
@@ -1,4 +1,4 @@
1
- import { E as Environment$1, t as track, I as ImmutableConfiguration } from './index-BiqzYCn2.js';
1
+ import { E as Environment$1, t as track, I as ImmutableConfiguration } from './index-CyoqdYm8.js';
2
2
  import globalAxios, { HttpStatusCode as HttpStatusCode$1 } from 'axios';
3
3
  import { ethers, BigNumber as BigNumber$1, ContractFactory, utils as utils$2, Contract as Contract$1 } from 'ethers';
4
4
  import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
@@ -8,8 +8,8 @@ import assert from 'assert';
8
8
  import { FeeAmount, Route, SwapQuoter, Pool, Trade, toHex as toHex$1, encodeRouteToPath } from '@uniswap/v3-sdk';
9
9
  import { keccak256 as keccak256$1 } from '@ethersproject/solidity';
10
10
  import { SwapRouter, PaymentsExtended } from '@uniswap/router-sdk';
11
- import { c as constants, O as OrderStatusName, a as Orderbook, A as ActionType, T as TransactionPurpose, S as SignablePurpose } from './index-C2zTAG6B.js';
12
- import { B as BlockchainData } from './index-DCEAbPKZ.js';
11
+ import { c as constants, O as OrderStatusName, a as Orderbook, A as ActionType, T as TransactionPurpose, S as SignablePurpose } from './index-6YZli_LO.js';
12
+ import { B as BlockchainData } from './index-Czu_FzNR.js';
13
13
  import detectEthereumProvider from '@metamask/detect-provider';
14
14
  import semver from 'semver';
15
15
 
@@ -19207,7 +19207,7 @@ const flattenProperties = (properties) => {
19207
19207
  };
19208
19208
 
19209
19209
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
19210
- const SDK_VERSION = '1.76.11';
19210
+ const SDK_VERSION = '1.77.0';
19211
19211
  const getFrameParentDomain = () => {
19212
19212
  if (isNode()) {
19213
19213
  return '';
@@ -24327,7 +24327,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
24327
24327
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
24328
24328
  };
24329
24329
 
24330
- const SDK_VERSION_MARKER = '1.76.11';
24330
+ const SDK_VERSION_MARKER = '1.77.0';
24331
24331
  // This SDK version is replaced by the `yarn build` command ran on the root level
24332
24332
  const globalPackageVersion = () => SDK_VERSION_MARKER;
24333
24333
 
@@ -28937,16 +28937,15 @@ function validateAndBuildVersion(version) {
28937
28937
  return validatedVersion;
28938
28938
  }
28939
28939
  /**
28940
- * Fetches the latest version of the package from the NPM registry.
28941
- * Loads a specific latest version instead of relying on the latest tag helps with caching issues.
28942
- * Falls back to 'latest' if an error occurs or if the response is invalid.
28940
+ * Fetches the latest version of the package from the JSDelivr version.json file.
28941
+ * Falls back to 'latest' if an error occurs or the response is invalid.
28943
28942
  * @returns {Promise<string>} A promise resolving to the latest version string or 'latest'.
28944
28943
  */
28945
- async function getLatestVersionFromNpm() {
28946
- const npmRegistryUrl = 'https://registry.npmjs.org/@imtbl/sdk/latest';
28944
+ async function getLatestVersion() {
28945
+ const cacheBustingUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@latest/dist/version.json?t=${Date.now()}`;
28947
28946
  const fallbackVersion = 'latest';
28948
28947
  try {
28949
- const response = await fetch(npmRegistryUrl);
28948
+ const response = await fetch(cacheBustingUrl);
28950
28949
  if (!response.ok) {
28951
28950
  return fallbackVersion;
28952
28951
  }
@@ -28973,33 +28972,6 @@ function latestCompatibleVersion(validVersion, compatibleVersionMarkers) {
28973
28972
  }
28974
28973
  return 'latest';
28975
28974
  }
28976
- /**
28977
- * Checks if the last_updated.json file exists on the CDN and validates its timestamp.
28978
- * @param {string} version - The version to check.
28979
- * @returns {Promise<boolean>} A promise resolving to `true` if last_updated.json exists and is older than 15 minutes, `false` otherwise.
28980
- */
28981
- async function checkLastUpdatedTimestamp(version) {
28982
- const WAIT_TIME_IN_MINUTES = 45;
28983
- const lastUpdatedJsonUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${version}/dist/last_updated.json`;
28984
- try {
28985
- const response = await fetch(lastUpdatedJsonUrl);
28986
- if (!response.ok) {
28987
- return false;
28988
- }
28989
- const lastUpdatedData = await response.json();
28990
- if (lastUpdatedData.timestamp) {
28991
- const timestamp = new Date(lastUpdatedData.timestamp);
28992
- const now = new Date();
28993
- const diffInMs = now.getTime() - timestamp.getTime();
28994
- const diffInMinutes = diffInMs / (1000 * 60);
28995
- return diffInMinutes > WAIT_TIME_IN_MINUTES;
28996
- }
28997
- }
28998
- catch (error) {
28999
- return false;
29000
- }
29001
- return false;
29002
- }
29003
28975
  /**
29004
28976
  * Determines the version of the widgets to use based on the provided validated build version and checkout version config.
29005
28977
  * If a version is provided in the widget init parameters, it uses that version.
@@ -29020,13 +28992,9 @@ async function determineWidgetsVersion(validatedBuildVersion, initVersionProvide
29020
28992
  return validatedBuildVersion;
29021
28993
  }
29022
28994
  const compatibleVersion = latestCompatibleVersion(validatedBuildVersion, versionConfig.compatibleVersionMarkers);
29023
- // If `latest` is returned, query NPM registry for the actual latest version and check timestamp
28995
+ // If `latest` is returned, query CDN for the actual latest version
29024
28996
  if (compatibleVersion === 'latest') {
29025
- const latestVersion = await getLatestVersionFromNpm();
29026
- if (await checkLastUpdatedTimestamp(latestVersion)) {
29027
- return latestVersion;
29028
- }
29029
- return 'latest';
28997
+ return await getLatestVersion();
29030
28998
  }
29031
28999
  return compatibleVersion;
29032
29000
  }
@@ -29159,19 +29127,43 @@ class Checkout {
29159
29127
  }
29160
29128
  async loadEsModules(config, validVersion) {
29161
29129
  const checkout = this;
29162
- try {
29163
- const cdnUrl = getWidgetsEsmUrl(validVersion);
29164
- // WebpackIgnore comment required to prevent webpack modifying the import statement and
29165
- // breaking the dynamic import in certain applications integrating checkout
29166
- const checkoutWidgetsModule = await import(
29167
- /* webpackIgnore: true */ cdnUrl);
29168
- if (checkoutWidgetsModule && checkoutWidgetsModule.WidgetsFactory) {
29169
- return new checkoutWidgetsModule.WidgetsFactory(checkout, config);
29130
+ async function tryLoadEsModule(version) {
29131
+ const cdnUrl = getWidgetsEsmUrl(version);
29132
+ try {
29133
+ // WebpackIgnore comment required to prevent webpack modifying the import statement and
29134
+ // breaking the dynamic import in certain applications integrating checkout
29135
+ const checkoutWidgetsModule = await import(
29136
+ /* webpackIgnore: true */ cdnUrl);
29137
+ if (checkoutWidgetsModule && checkoutWidgetsModule.WidgetsFactory) {
29138
+ return new checkoutWidgetsModule.WidgetsFactory(checkout, config);
29139
+ }
29140
+ throw new Error(`WidgetsFactory not found in loaded module for version: ${version}`);
29141
+ }
29142
+ catch (err) {
29143
+ // eslint-disable-next-line no-console
29144
+ console.warn(`Failed to load ESM bundle for version ${version}. Error: ${err.message}`);
29145
+ throw err;
29170
29146
  }
29171
29147
  }
29148
+ try {
29149
+ return await tryLoadEsModule(validVersion);
29150
+ }
29172
29151
  catch (err) {
29173
- // eslint-disable-next-line no-console
29174
- console.warn(`Failed to resolve Commerce Widgets module, falling back to UMD bundle. Error: ${err.message}`);
29152
+ const latestVersion = await getLatestVersion();
29153
+ if (validVersion === latestVersion && validVersion !== 'latest') {
29154
+ try {
29155
+ return await tryLoadEsModule('latest');
29156
+ }
29157
+ catch (retryErr) {
29158
+ // eslint-disable-next-line no-console
29159
+ console.warn(`Failed to resolve Commerce Widgets module, falling back to UMD bundle. Error: ${retryErr.message}`);
29160
+ }
29161
+ }
29162
+ else {
29163
+ // eslint-disable-next-line no-console
29164
+ console.warn(`Failed to resolve Commerce Widgets module for version ${validVersion}, falling back to UMD bundle.
29165
+ Error: ${err.message}`);
29166
+ }
29175
29167
  }
29176
29168
  // Fallback to UMD bundle if esm bundle fails to load
29177
29169
  return await checkout.loadUmdBundle(config, validVersion);
package/dist/checkout.js CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AddTokensEventType, B as BlockExplorerService, a as BridgeEventType, C as ChainId, b as ChainName, d as ChainSlug, e as Checkout, f as CheckoutConfiguration, g as CheckoutError, h as CheckoutErrorType, i as CheckoutStatus, j as CommerceEventType, k as CommerceFailureEventType, l as CommerceFlowType, m as CommerceSuccessEventType, n as CommerceUserActionEventType, o as ConnectEventType, p as ConnectTargetLayer, E as ExchangeType, F as FeeType, q as FundingStepType, G as GasEstimateType, r as GasTokenType, I as IMMUTABLE_API_BASE_URL, s as IMTBLWidgetEvents, t as ItemType, N as NetworkFilterTypes, O as OnRampEventType, u as OrchestrationEventType, P as ProviderEventType, v as PurchaseEventType, R as RoutingOutcomeType, S as SaleEventType, w as SalePaymentTypes, x as SwapDirection, y as SwapEventType, T as TokenFilterTypes, z as TransactionOrGasType, W as WalletEventType, D as WalletFilterTypes, H as WalletProviderName, J as WalletProviderRdns, K as WidgetTheme, L as WidgetType, M as fetchRiskAssessment, Q as getMetaMaskProviderDetail, U as getPassportProviderDetail, V as isAddressSanctioned, X as validateProvider } from './checkout-3tvm_CV9.js';
2
- import './index-BiqzYCn2.js';
1
+ export { A as AddTokensEventType, B as BlockExplorerService, a as BridgeEventType, C as ChainId, b as ChainName, d as ChainSlug, e as Checkout, f as CheckoutConfiguration, g as CheckoutError, h as CheckoutErrorType, i as CheckoutStatus, j as CommerceEventType, k as CommerceFailureEventType, l as CommerceFlowType, m as CommerceSuccessEventType, n as CommerceUserActionEventType, o as ConnectEventType, p as ConnectTargetLayer, E as ExchangeType, F as FeeType, q as FundingStepType, G as GasEstimateType, r as GasTokenType, I as IMMUTABLE_API_BASE_URL, s as IMTBLWidgetEvents, t as ItemType, N as NetworkFilterTypes, O as OnRampEventType, u as OrchestrationEventType, P as ProviderEventType, v as PurchaseEventType, R as RoutingOutcomeType, S as SaleEventType, w as SalePaymentTypes, x as SwapDirection, y as SwapEventType, T as TokenFilterTypes, z as TransactionOrGasType, W as WalletEventType, D as WalletFilterTypes, H as WalletProviderName, J as WalletProviderRdns, K as WidgetTheme, L as WidgetType, M as fetchRiskAssessment, Q as getMetaMaskProviderDetail, U as getPassportProviderDetail, V as isAddressSanctioned, X as validateProvider } from './checkout-CLISlSe4.js';
2
+ import './index-CyoqdYm8.js';
3
3
  import 'axios';
4
4
  import 'lru-memorise';
5
5
  import 'global-const';
@@ -10,13 +10,13 @@ import 'assert';
10
10
  import '@uniswap/v3-sdk';
11
11
  import '@ethersproject/solidity';
12
12
  import '@uniswap/router-sdk';
13
- import './index-C2zTAG6B.js';
13
+ import './index-6YZli_LO.js';
14
14
  import 'form-data';
15
15
  import '@opensea/seaport-js/lib/constants';
16
16
  import 'ethers-v6';
17
17
  import 'merkletreejs';
18
18
  import '@opensea/seaport-js';
19
- import './index-DCEAbPKZ.js';
20
- import './index-uLrZv2yp.js';
19
+ import './index-Czu_FzNR.js';
20
+ import './index-CQ9TbMkB.js';
21
21
  import '@metamask/detect-provider';
22
22
  import 'semver';
@@ -1,4 +1,4 @@
1
- import { E as Environment, I as ImmutableConfiguration, K as KeyHeaders, a as addKeysToHeadersOverride } from './index-BiqzYCn2.js';
1
+ import { E as Environment, I as ImmutableConfiguration, K as KeyHeaders, a as addKeysToHeadersOverride } from './index-CyoqdYm8.js';
2
2
 
3
3
  var config = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- export { E as Environment, I as ImmutableConfiguration, K as KeyHeaders, a as addKeysToHeadersOverride } from './index-BiqzYCn2.js';
1
+ export { E as Environment, I as ImmutableConfiguration, K as KeyHeaders, a as addKeysToHeadersOverride } from './index-CyoqdYm8.js';
2
2
  import 'axios';
3
3
  import 'lru-memorise';
4
4
  import 'global-const';
@@ -1,4 +1,4 @@
1
- import { t as track, E as Environment } from './index-BiqzYCn2.js';
1
+ import { t as track, E as Environment } from './index-CyoqdYm8.js';
2
2
  import globalAxios from 'axios';
3
3
  import FormData from 'form-data';
4
4
  import { OrderType as OrderType$1, ItemType as ItemType$1 } from '@opensea/seaport-js/lib/constants';
@@ -14336,7 +14336,7 @@ class MultiRollupApiClients {
14336
14336
  }
14337
14337
 
14338
14338
  // eslint-disable-next-line @typescript-eslint/naming-convention
14339
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.76.11' };
14339
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.77.0' };
14340
14340
  const createConfig = ({ basePath, headers, }) => {
14341
14341
  if (!basePath.trim()) {
14342
14342
  throw Error('basePath can not be empty');
@@ -158,7 +158,7 @@ const flattenProperties = (properties) => {
158
158
  };
159
159
 
160
160
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
161
- const SDK_VERSION = '1.76.11';
161
+ const SDK_VERSION = '1.77.0';
162
162
  const getFrameParentDomain = () => {
163
163
  if (isNode()) {
164
164
  return '';
@@ -1,5 +1,5 @@
1
- import { a as index$1 } from './index-uLrZv2yp.js';
2
- import { E as Environment, a as addKeysToHeadersOverride } from './index-BiqzYCn2.js';
1
+ import { a as index$1 } from './index-CQ9TbMkB.js';
2
+ import { E as Environment, a as addKeysToHeadersOverride } from './index-CyoqdYm8.js';
3
3
  import globalAxios from 'axios';
4
4
 
5
5
  /**
@@ -21,7 +21,7 @@ class APIError extends Error {
21
21
 
22
22
  /* eslint-disable implicit-arrow-linebreak */
23
23
  const defaultHeaders = {
24
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.76.11',
24
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.77.0',
25
25
  };
26
26
  /**
27
27
  * createAPIConfiguration to create a custom Configuration
@@ -1,5 +1,5 @@
1
1
  import MessageValidator from 'sns-validator';
2
- import { E as Environment } from './index-BiqzYCn2.js';
2
+ import { E as Environment } from './index-CyoqdYm8.js';
3
3
 
4
4
  const validator = new MessageValidator();
5
5
  const allowedTopicArnPrefix = {
@@ -1,5 +1,5 @@
1
- import { d as index$2, I as ImxApiClients } from './index-uLrZv2yp.js';
2
- import { a as addKeysToHeadersOverride, E as Environment, I as ImmutableConfiguration } from './index-BiqzYCn2.js';
1
+ import { d as index$2, I as ImxApiClients } from './index-CQ9TbMkB.js';
2
+ import { a as addKeysToHeadersOverride, E as Environment, I as ImmutableConfiguration } from './index-CyoqdYm8.js';
3
3
  import globalAxios from 'axios';
4
4
  import { keccak256 } from '@ethersproject/keccak256';
5
5
  import { toUtf8Bytes } from '@ethersproject/strings';
@@ -16,7 +16,7 @@ import '@ethersproject/abstract-signer';
16
16
  /* eslint-disable @typescript-eslint/naming-convention */
17
17
  class ApiConfiguration extends index$2.Configuration {
18
18
  }
19
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.76.11' };
19
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.77.0' };
20
20
  /**
21
21
  * @dev use createImmutableXConfiguration instead
22
22
  */
@@ -57,7 +57,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
57
57
  coreContractAddress,
58
58
  registrationContractAddress,
59
59
  registrationV4ContractAddress,
60
- sdkVersion: 'ts-immutable-sdk-1.76.11',
60
+ sdkVersion: 'ts-immutable-sdk-1.77.0',
61
61
  baseConfig,
62
62
  });
63
63
  const production = ({ baseConfig }) => createImmutableXConfiguration({