@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.
package/dist/index.cjs CHANGED
@@ -4256,7 +4256,7 @@ class MultiRollupApiClients {
4256
4256
  }
4257
4257
 
4258
4258
  // eslint-disable-next-line @typescript-eslint/naming-convention
4259
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.38.0' };
4259
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.39.0' };
4260
4260
  const createConfig = ({ basePath, headers, }) => {
4261
4261
  if (!basePath.trim()) {
4262
4262
  throw Error('basePath can not be empty');
@@ -4316,7 +4316,7 @@ class APIError extends Error {
4316
4316
 
4317
4317
  /* eslint-disable implicit-arrow-linebreak */
4318
4318
  const defaultHeaders = {
4319
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.38.0',
4319
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.39.0',
4320
4320
  };
4321
4321
  /**
4322
4322
  * createAPIConfiguration to create a custom Configuration
@@ -4755,7 +4755,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4755
4755
  chainID,
4756
4756
  coreContractAddress,
4757
4757
  registrationContractAddress,
4758
- sdkVersion: 'ts-immutable-sdk-0.38.0',
4758
+ sdkVersion: 'ts-immutable-sdk-0.39.0',
4759
4759
  });
4760
4760
  /**
4761
4761
  * Sets `sdkVersion` at the time of build
@@ -35261,7 +35261,11 @@ async function addNetworkToWallet(networkMap, web3Provider, chainId) {
35261
35261
  async function getNetworkAllowList(config, { type = NetworkFilterTypes.ALL, exclude }) {
35262
35262
  const { networkMap } = config;
35263
35263
  const allowedNetworkConfig = (await config.remote.getConfig('allowedNetworks'));
35264
- const list = allowedNetworkConfig.filter((network) => {
35264
+ if (!allowedNetworkConfig) {
35265
+ // eslint-disable-next-line no-console
35266
+ console.warn('No allowed networks configured');
35267
+ }
35268
+ const list = (allowedNetworkConfig || []).filter((network) => {
35265
35269
  const allowAllTokens = type === NetworkFilterTypes.ALL;
35266
35270
  const networkNotExcluded = !(exclude || [])
35267
35271
  .map((exc) => exc.chainId)
@@ -35701,7 +35705,7 @@ const GAS_OVERRIDES = {
35701
35705
  maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
35702
35706
  };
35703
35707
 
35704
- const SDK_VERSION_MARKER = '0.38.0';
35708
+ const SDK_VERSION_MARKER = '0.39.0';
35705
35709
  // This SDK version is replaced by the `yarn build` command ran on the root level
35706
35710
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35707
35711
 
@@ -35724,18 +35728,33 @@ class RemoteConfigFetcher {
35724
35728
  return CHECKOUT_CDN_BASE_URL[Environment$1.PRODUCTION];
35725
35729
  return CHECKOUT_CDN_BASE_URL[Environment$1.SANDBOX];
35726
35730
  };
35731
+ // eslint-disable-next-line class-methods-use-this
35732
+ parseResponse(response) {
35733
+ let responseData = response.data;
35734
+ if (response.data && typeof response.data !== 'object') {
35735
+ try {
35736
+ responseData = JSON.parse(response.data);
35737
+ }
35738
+ catch (jsonError) {
35739
+ throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
35740
+ }
35741
+ }
35742
+ return responseData;
35743
+ }
35727
35744
  async loadConfig() {
35728
35745
  if (this.configCache)
35729
35746
  return this.configCache;
35730
35747
  const response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
35731
- this.configCache = response.data;
35748
+ // Ensure that the configuration is valid
35749
+ this.configCache = this.parseResponse(response);
35732
35750
  return this.configCache;
35733
35751
  }
35734
35752
  async loadConfigTokens() {
35735
35753
  if (this.tokensCache)
35736
35754
  return this.tokensCache;
35737
35755
  const response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
35738
- this.tokensCache = response.data;
35756
+ // Ensure that the configuration is valid
35757
+ this.tokensCache = this.parseResponse(response);
35739
35758
  return this.tokensCache;
35740
35759
  }
35741
35760
  async getConfig(key) {
@@ -37889,8 +37908,8 @@ const bridgeRoute = async (config, readOnlyProviders, availableRoutingOptions, b
37889
37908
  if (tokenBalanceResult === undefined || tokenBalanceResult.success === false)
37890
37909
  return undefined;
37891
37910
  // todo: revert this back to using the allowlist
37892
- const allowedTokenList = await allowListCheckForBridge(config, tokenBalanceResults, availableRoutingOptions);
37893
- if (allowedTokenList.length === 0)
37911
+ const allowedL1TokenList = await allowListCheckForBridge(config, tokenBalanceResults, availableRoutingOptions);
37912
+ if (allowedL1TokenList.length === 0)
37894
37913
  return undefined;
37895
37914
  const l1RepresentationResult = await fetchL1Representation(config, bridgeRequirement.l2address);
37896
37915
  if (!l1RepresentationResult)
@@ -37898,10 +37917,10 @@ const bridgeRoute = async (config, readOnlyProviders, availableRoutingOptions, b
37898
37917
  // Ensure l1address is in the allowed token list
37899
37918
  const { l1address } = l1RepresentationResult;
37900
37919
  if (isNativeToken(l1address)) {
37901
- if (!allowedTokenList.find((token) => !('address' in token)))
37920
+ if (!allowedL1TokenList.find((token) => isNativeToken(token.address)))
37902
37921
  return undefined;
37903
37922
  }
37904
- else if (!allowedTokenList.find((token) => token.address === l1address)) {
37923
+ else if (!allowedL1TokenList.find((token) => token.address === l1address)) {
37905
37924
  return undefined;
37906
37925
  }
37907
37926
  const feesFromBridge = await getBridgeFeeEstimate(config, readOnlyProviders, l1ChainId, l2ChainId);
package/dist/index.d.ts CHANGED
@@ -18366,6 +18366,7 @@ declare class RemoteConfigFetcher {
18366
18366
  private version;
18367
18367
  constructor(httpClient: HttpClient, params: RemoteConfigParams);
18368
18368
  private getEndpoint;
18369
+ private parseResponse;
18369
18370
  private loadConfig;
18370
18371
  private loadConfigTokens;
18371
18372
  getConfig(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
package/dist/index.js CHANGED
@@ -4234,7 +4234,7 @@ class MultiRollupApiClients {
4234
4234
  }
4235
4235
 
4236
4236
  // eslint-disable-next-line @typescript-eslint/naming-convention
4237
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.38.0' };
4237
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.39.0' };
4238
4238
  const createConfig = ({ basePath, headers, }) => {
4239
4239
  if (!basePath.trim()) {
4240
4240
  throw Error('basePath can not be empty');
@@ -4294,7 +4294,7 @@ class APIError extends Error {
4294
4294
 
4295
4295
  /* eslint-disable implicit-arrow-linebreak */
4296
4296
  const defaultHeaders = {
4297
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.38.0',
4297
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.39.0',
4298
4298
  };
4299
4299
  /**
4300
4300
  * createAPIConfiguration to create a custom Configuration
@@ -4733,7 +4733,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4733
4733
  chainID,
4734
4734
  coreContractAddress,
4735
4735
  registrationContractAddress,
4736
- sdkVersion: 'ts-immutable-sdk-0.38.0',
4736
+ sdkVersion: 'ts-immutable-sdk-0.39.0',
4737
4737
  });
4738
4738
  /**
4739
4739
  * Sets `sdkVersion` at the time of build
@@ -35239,7 +35239,11 @@ async function addNetworkToWallet(networkMap, web3Provider, chainId) {
35239
35239
  async function getNetworkAllowList(config, { type = NetworkFilterTypes.ALL, exclude }) {
35240
35240
  const { networkMap } = config;
35241
35241
  const allowedNetworkConfig = (await config.remote.getConfig('allowedNetworks'));
35242
- const list = allowedNetworkConfig.filter((network) => {
35242
+ if (!allowedNetworkConfig) {
35243
+ // eslint-disable-next-line no-console
35244
+ console.warn('No allowed networks configured');
35245
+ }
35246
+ const list = (allowedNetworkConfig || []).filter((network) => {
35243
35247
  const allowAllTokens = type === NetworkFilterTypes.ALL;
35244
35248
  const networkNotExcluded = !(exclude || [])
35245
35249
  .map((exc) => exc.chainId)
@@ -35679,7 +35683,7 @@ const GAS_OVERRIDES = {
35679
35683
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
35680
35684
  };
35681
35685
 
35682
- const SDK_VERSION_MARKER = '0.38.0';
35686
+ const SDK_VERSION_MARKER = '0.39.0';
35683
35687
  // This SDK version is replaced by the `yarn build` command ran on the root level
35684
35688
  const globalPackageVersion = () => SDK_VERSION_MARKER;
35685
35689
 
@@ -35702,18 +35706,33 @@ class RemoteConfigFetcher {
35702
35706
  return CHECKOUT_CDN_BASE_URL[Environment$1.PRODUCTION];
35703
35707
  return CHECKOUT_CDN_BASE_URL[Environment$1.SANDBOX];
35704
35708
  };
35709
+ // eslint-disable-next-line class-methods-use-this
35710
+ parseResponse(response) {
35711
+ let responseData = response.data;
35712
+ if (response.data && typeof response.data !== 'object') {
35713
+ try {
35714
+ responseData = JSON.parse(response.data);
35715
+ }
35716
+ catch (jsonError) {
35717
+ throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
35718
+ }
35719
+ }
35720
+ return responseData;
35721
+ }
35705
35722
  async loadConfig() {
35706
35723
  if (this.configCache)
35707
35724
  return this.configCache;
35708
35725
  const response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
35709
- this.configCache = response.data;
35726
+ // Ensure that the configuration is valid
35727
+ this.configCache = this.parseResponse(response);
35710
35728
  return this.configCache;
35711
35729
  }
35712
35730
  async loadConfigTokens() {
35713
35731
  if (this.tokensCache)
35714
35732
  return this.tokensCache;
35715
35733
  const response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
35716
- this.tokensCache = response.data;
35734
+ // Ensure that the configuration is valid
35735
+ this.tokensCache = this.parseResponse(response);
35717
35736
  return this.tokensCache;
35718
35737
  }
35719
35738
  async getConfig(key) {
@@ -37867,8 +37886,8 @@ const bridgeRoute = async (config, readOnlyProviders, availableRoutingOptions, b
37867
37886
  if (tokenBalanceResult === undefined || tokenBalanceResult.success === false)
37868
37887
  return undefined;
37869
37888
  // todo: revert this back to using the allowlist
37870
- const allowedTokenList = await allowListCheckForBridge(config, tokenBalanceResults, availableRoutingOptions);
37871
- if (allowedTokenList.length === 0)
37889
+ const allowedL1TokenList = await allowListCheckForBridge(config, tokenBalanceResults, availableRoutingOptions);
37890
+ if (allowedL1TokenList.length === 0)
37872
37891
  return undefined;
37873
37892
  const l1RepresentationResult = await fetchL1Representation(config, bridgeRequirement.l2address);
37874
37893
  if (!l1RepresentationResult)
@@ -37876,10 +37895,10 @@ const bridgeRoute = async (config, readOnlyProviders, availableRoutingOptions, b
37876
37895
  // Ensure l1address is in the allowed token list
37877
37896
  const { l1address } = l1RepresentationResult;
37878
37897
  if (isNativeToken(l1address)) {
37879
- if (!allowedTokenList.find((token) => !('address' in token)))
37898
+ if (!allowedL1TokenList.find((token) => isNativeToken(token.address)))
37880
37899
  return undefined;
37881
37900
  }
37882
- else if (!allowedTokenList.find((token) => token.address === l1address)) {
37901
+ else if (!allowedL1TokenList.find((token) => token.address === l1address)) {
37883
37902
  return undefined;
37884
37903
  }
37885
37904
  const feesFromBridge = await getBridgeFeeEstimate(config, readOnlyProviders, l1ChainId, l2ChainId);
package/dist/passport.js CHANGED
@@ -2349,7 +2349,7 @@ class MultiRollupApiClients {
2349
2349
  }
2350
2350
 
2351
2351
  // eslint-disable-next-line @typescript-eslint/naming-convention
2352
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.38.0' };
2352
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.39.0' };
2353
2353
  const createConfig = ({ basePath, headers, }) => {
2354
2354
  if (!basePath.trim()) {
2355
2355
  throw Error('basePath can not be empty');
@@ -2405,7 +2405,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2405
2405
  chainID,
2406
2406
  coreContractAddress,
2407
2407
  registrationContractAddress,
2408
- sdkVersion: 'ts-immutable-sdk-0.38.0',
2408
+ sdkVersion: 'ts-immutable-sdk-0.39.0',
2409
2409
  });
2410
2410
  /**
2411
2411
  * 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.38.0",
4
+ "version": "0.39.0",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",