@imtbl/sdk 0.38.0 → 0.39.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.
@@ -12438,6 +12438,7 @@ declare class RemoteConfigFetcher {
12438
12438
  private version;
12439
12439
  constructor(httpClient: HttpClient, params: RemoteConfigParams);
12440
12440
  private getEndpoint;
12441
+ private parseResponse;
12441
12442
  private loadConfig;
12442
12443
  private loadConfigTokens;
12443
12444
  getConfig(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
package/dist/checkout.js CHANGED
@@ -26051,7 +26051,7 @@ class APIError extends Error {
26051
26051
 
26052
26052
  /* eslint-disable implicit-arrow-linebreak */
26053
26053
  const defaultHeaders = {
26054
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.38.0',
26054
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.39.0',
26055
26055
  };
26056
26056
  /**
26057
26057
  * createAPIConfiguration to create a custom Configuration
@@ -26956,7 +26956,11 @@ async function addNetworkToWallet(networkMap, web3Provider, chainId) {
26956
26956
  async function getNetworkAllowList(config, { type = NetworkFilterTypes.ALL, exclude }) {
26957
26957
  const { networkMap } = config;
26958
26958
  const allowedNetworkConfig = (await config.remote.getConfig('allowedNetworks'));
26959
- const list = allowedNetworkConfig.filter((network) => {
26959
+ if (!allowedNetworkConfig) {
26960
+ // eslint-disable-next-line no-console
26961
+ console.warn('No allowed networks configured');
26962
+ }
26963
+ const list = (allowedNetworkConfig || []).filter((network) => {
26960
26964
  const allowAllTokens = type === NetworkFilterTypes.ALL;
26961
26965
  const networkNotExcluded = !(exclude || [])
26962
26966
  .map((exc) => exc.chainId)
@@ -27396,7 +27400,7 @@ const GAS_OVERRIDES = {
27396
27400
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
27397
27401
  };
27398
27402
 
27399
- const SDK_VERSION_MARKER = '0.38.0';
27403
+ const SDK_VERSION_MARKER = '0.39.0';
27400
27404
  // This SDK version is replaced by the `yarn build` command ran on the root level
27401
27405
  const globalPackageVersion = () => SDK_VERSION_MARKER;
27402
27406
 
@@ -27419,18 +27423,33 @@ class RemoteConfigFetcher {
27419
27423
  return CHECKOUT_CDN_BASE_URL[Environment$1.PRODUCTION];
27420
27424
  return CHECKOUT_CDN_BASE_URL[Environment$1.SANDBOX];
27421
27425
  };
27426
+ // eslint-disable-next-line class-methods-use-this
27427
+ parseResponse(response) {
27428
+ let responseData = response.data;
27429
+ if (response.data && typeof response.data !== 'object') {
27430
+ try {
27431
+ responseData = JSON.parse(response.data);
27432
+ }
27433
+ catch (jsonError) {
27434
+ throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
27435
+ }
27436
+ }
27437
+ return responseData;
27438
+ }
27422
27439
  async loadConfig() {
27423
27440
  if (this.configCache)
27424
27441
  return this.configCache;
27425
27442
  const response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
27426
- this.configCache = response.data;
27443
+ // Ensure that the configuration is valid
27444
+ this.configCache = this.parseResponse(response);
27427
27445
  return this.configCache;
27428
27446
  }
27429
27447
  async loadConfigTokens() {
27430
27448
  if (this.tokensCache)
27431
27449
  return this.tokensCache;
27432
27450
  const response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
27433
- this.tokensCache = response.data;
27451
+ // Ensure that the configuration is valid
27452
+ this.tokensCache = this.parseResponse(response);
27434
27453
  return this.tokensCache;
27435
27454
  }
27436
27455
  async getConfig(key) {
@@ -29584,8 +29603,8 @@ const bridgeRoute = async (config, readOnlyProviders, availableRoutingOptions, b
29584
29603
  if (tokenBalanceResult === undefined || tokenBalanceResult.success === false)
29585
29604
  return undefined;
29586
29605
  // todo: revert this back to using the allowlist
29587
- const allowedTokenList = await allowListCheckForBridge(config, tokenBalanceResults, availableRoutingOptions);
29588
- if (allowedTokenList.length === 0)
29606
+ const allowedL1TokenList = await allowListCheckForBridge(config, tokenBalanceResults, availableRoutingOptions);
29607
+ if (allowedL1TokenList.length === 0)
29589
29608
  return undefined;
29590
29609
  const l1RepresentationResult = await fetchL1Representation(config, bridgeRequirement.l2address);
29591
29610
  if (!l1RepresentationResult)
@@ -29593,10 +29612,10 @@ const bridgeRoute = async (config, readOnlyProviders, availableRoutingOptions, b
29593
29612
  // Ensure l1address is in the allowed token list
29594
29613
  const { l1address } = l1RepresentationResult;
29595
29614
  if (isNativeToken(l1address)) {
29596
- if (!allowedTokenList.find((token) => !('address' in token)))
29615
+ if (!allowedL1TokenList.find((token) => isNativeToken(token.address)))
29597
29616
  return undefined;
29598
29617
  }
29599
- else if (!allowedTokenList.find((token) => token.address === l1address)) {
29618
+ else if (!allowedL1TokenList.find((token) => token.address === l1address)) {
29600
29619
  return undefined;
29601
29620
  }
29602
29621
  const feesFromBridge = await getBridgeFeeEstimate(config, readOnlyProviders, l1ChainId, l2ChainId);
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
17
17
  chainID,
18
18
  coreContractAddress,
19
19
  registrationContractAddress,
20
- sdkVersion: 'ts-immutable-sdk-0.38.0',
20
+ sdkVersion: 'ts-immutable-sdk-0.39.0',
21
21
  });
22
22
  /**
23
23
  * Sets `sdkVersion` at the time of build