@imtbl/sdk 1.28.1 → 1.28.2

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
@@ -182,7 +182,7 @@ const flattenProperties$1 = (properties) => {
182
182
  };
183
183
 
184
184
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
185
- const SDK_VERSION$1 = '1.28.1';
185
+ const SDK_VERSION$1 = '1.28.2';
186
186
  const getReferrer$1 = () => {
187
187
  if (isNode$1()) {
188
188
  return '';
@@ -14334,7 +14334,7 @@ class MultiRollupApiClients {
14334
14334
  }
14335
14335
 
14336
14336
  // eslint-disable-next-line @typescript-eslint/naming-convention
14337
- const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
14337
+ const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
14338
14338
  const createConfig$1 = ({ basePath, headers, }) => {
14339
14339
  if (!basePath.trim()) {
14340
14340
  throw Error('basePath can not be empty');
@@ -14406,7 +14406,7 @@ class APIError extends Error {
14406
14406
 
14407
14407
  /* eslint-disable implicit-arrow-linebreak */
14408
14408
  const defaultHeaders$1 = {
14409
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.28.1',
14409
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.28.2',
14410
14410
  };
14411
14411
  /**
14412
14412
  * createAPIConfiguration to create a custom Configuration
@@ -14880,7 +14880,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
14880
14880
  /* eslint-disable @typescript-eslint/naming-convention */
14881
14881
  class ApiConfiguration extends index$2.Configuration {
14882
14882
  }
14883
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
14883
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
14884
14884
  /**
14885
14885
  * @dev use createImmutableXConfiguration instead
14886
14886
  */
@@ -14919,7 +14919,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
14919
14919
  chainID,
14920
14920
  coreContractAddress,
14921
14921
  registrationContractAddress,
14922
- sdkVersion: 'ts-immutable-sdk-1.28.1',
14922
+ sdkVersion: 'ts-immutable-sdk-1.28.2',
14923
14923
  baseConfig,
14924
14924
  });
14925
14925
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -28443,11 +28443,13 @@ class Seaport {
28443
28443
  provider;
28444
28444
  seaportContractAddress;
28445
28445
  zoneContractAddress;
28446
- constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress) {
28446
+ rateLimitingKey;
28447
+ constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress, rateLimitingKey) {
28447
28448
  this.seaportLibFactory = seaportLibFactory;
28448
28449
  this.provider = provider;
28449
28450
  this.seaportContractAddress = seaportContractAddress;
28450
28451
  this.zoneContractAddress = zoneContractAddress;
28452
+ this.rateLimitingKey = rateLimitingKey;
28451
28453
  }
28452
28454
  async prepareSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
28453
28455
  const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry);
@@ -28613,11 +28615,7 @@ class Seaport {
28613
28615
  }
28614
28616
  getSeaportLib(order) {
28615
28617
  const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
28616
- const seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
28617
- // if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
28618
- // seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
28619
- // }
28620
- return this.seaportLibFactory.create(seaportVersion, seaportAddress);
28618
+ return this.seaportLibFactory.create(seaportAddress, this.rateLimitingKey);
28621
28619
  }
28622
28620
  static getExpirationISOTimeFromExtraData(extraData) {
28623
28621
  // Expirtaion bytes in SIP7 extra data [21:29]
@@ -28740,12 +28738,17 @@ class ImmutableApiClientFactory {
28740
28738
  chainName;
28741
28739
  seaportAddress;
28742
28740
  orderbookClient;
28743
- constructor(apiEndpoint, chainName, seaportAddress) {
28741
+ constructor(apiEndpoint, chainName, seaportAddress, rateLimitingKey) {
28744
28742
  this.chainName = chainName;
28745
28743
  this.seaportAddress = seaportAddress;
28746
28744
  this.orderbookClient = new OrderBookClient({
28747
28745
  // eslint-disable-next-line @typescript-eslint/naming-convention
28748
28746
  BASE: apiEndpoint,
28747
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28748
+ HEADERS: rateLimitingKey ? {
28749
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28750
+ 'x-api-key': rateLimitingKey,
28751
+ } : undefined,
28749
28752
  });
28750
28753
  }
28751
28754
  create() {
@@ -28755,15 +28758,24 @@ class ImmutableApiClientFactory {
28755
28758
 
28756
28759
  const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
28757
28760
  const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
28758
- function getOrderbookConfig(environment) {
28759
- switch (environment) {
28761
+ function getConfiguredProvider(url, rateLimitingKey) {
28762
+ return new ethers.providers.JsonRpcProvider({
28763
+ url,
28764
+ headers: rateLimitingKey ? {
28765
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28766
+ 'x-api-key': rateLimitingKey,
28767
+ } : undefined,
28768
+ });
28769
+ }
28770
+ function getOrderbookConfig(config) {
28771
+ switch (config.baseConfig.environment) {
28760
28772
  case Environment$1.SANDBOX:
28761
28773
  return {
28762
28774
  seaportContractAddress: '0x7d117aA8BD6D31c4fa91722f246388f38ab1942c',
28763
28775
  zoneContractAddress: '0x8831867E347AB87FA30199C5B695F0A31604Bb52',
28764
28776
  apiEndpoint: 'https://api.sandbox.immutable.com',
28765
28777
  chainName: TESTNET_CHAIN_NAME,
28766
- provider: new ethers.providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
28778
+ provider: getConfiguredProvider('https://rpc.testnet.immutable.com', config.baseConfig.rateLimitingKey),
28767
28779
  };
28768
28780
  // not yet deployed
28769
28781
  case Environment$1.PRODUCTION:
@@ -28772,7 +28784,7 @@ function getOrderbookConfig(environment) {
28772
28784
  zoneContractAddress: '0x00338b92Bec262078B3e49BF12bbEA058916BF91',
28773
28785
  apiEndpoint: 'https://api.immutable.com',
28774
28786
  chainName: MAINNET_CHAIN_NAME,
28775
- provider: new ethers.providers.JsonRpcProvider('https://rpc.immutable.com'),
28787
+ provider: getConfiguredProvider('https://rpc.immutable.com', config.baseConfig.rateLimitingKey),
28776
28788
  };
28777
28789
  default:
28778
28790
  return null;
@@ -28782,8 +28794,12 @@ function getOrderbookConfig(environment) {
28782
28794
  // The order book module only supports V5 JsonRpcProviders. These are instantiated
28783
28795
  // by the environment or by providing an RPC URL override. For this reason we can
28784
28796
  // safely instantiate a V6 provider for the V5 provider URL.
28785
- function convertToV6Provider(provider) {
28786
- const overwrittenProvider = new ethersV6.JsonRpcProvider(provider.connection.url);
28797
+ function convertToV6Provider(provider, rateLimitingKey) {
28798
+ const fetch = new ethersV6.FetchRequest(provider.connection.url);
28799
+ if (rateLimitingKey) {
28800
+ fetch.setHeader('x-api-key', rateLimitingKey);
28801
+ }
28802
+ const overwrittenProvider = new ethersV6.JsonRpcProvider(fetch);
28787
28803
  // Need to override the getSigner method to mimic V5 behaviour
28788
28804
  overwrittenProvider.getSigner = async function getSigner(address) {
28789
28805
  if (address == null) {
@@ -28813,9 +28829,9 @@ class SeaportLibFactory {
28813
28829
  this.defaultSeaportContractAddress = defaultSeaportContractAddress;
28814
28830
  this.provider = provider;
28815
28831
  }
28816
- create(orderSeaportVersion, orderSeaportAddress) {
28832
+ create(orderSeaportAddress, rateLimitingKey) {
28817
28833
  const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
28818
- return new seaportJs.Seaport(convertToV6Provider(this.provider), {
28834
+ return new seaportJs.Seaport(convertToV6Provider(this.provider, rateLimitingKey), {
28819
28835
  balanceAndApprovalChecksOnOrderCreation: true,
28820
28836
  overrides: {
28821
28837
  contractAddress: seaportContractAddress,
@@ -28834,13 +28850,13 @@ class Orderbook {
28834
28850
  seaport;
28835
28851
  orderbookConfig;
28836
28852
  constructor(config) {
28837
- const obConfig = getOrderbookConfig(config.baseConfig.environment);
28853
+ const obConfig = getOrderbookConfig(config);
28838
28854
  const finalConfig = {
28839
28855
  ...obConfig,
28840
28856
  ...config.overrides,
28841
28857
  };
28842
28858
  if (config.overrides?.jsonRpcProviderUrl) {
28843
- finalConfig.provider = new ethers.providers.JsonRpcProvider(config.overrides.jsonRpcProviderUrl);
28859
+ finalConfig.provider = getConfiguredProvider(config.overrides?.jsonRpcProviderUrl, config.baseConfig.rateLimitingKey);
28844
28860
  }
28845
28861
  if (!finalConfig) {
28846
28862
  throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
@@ -28850,9 +28866,9 @@ class Orderbook {
28850
28866
  if (!apiEndpoint) {
28851
28867
  throw new Error('API endpoint must be provided');
28852
28868
  }
28853
- this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
28869
+ this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress, config.baseConfig.rateLimitingKey).create();
28854
28870
  const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
28855
- this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
28871
+ this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress, config.baseConfig.rateLimitingKey);
28856
28872
  }
28857
28873
  /**
28858
28874
  * Return the configuration for the orderbook module.
@@ -46319,7 +46335,7 @@ const flattenProperties = (properties) => {
46319
46335
  };
46320
46336
 
46321
46337
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
46322
- const SDK_VERSION = '1.28.1';
46338
+ const SDK_VERSION = '1.28.2';
46323
46339
  const getReferrer = () => {
46324
46340
  if (isNode()) {
46325
46341
  return '';
@@ -51514,7 +51530,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
51514
51530
  maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
51515
51531
  };
51516
51532
 
51517
- const SDK_VERSION_MARKER = '1.28.1';
51533
+ const SDK_VERSION_MARKER = '1.28.2';
51518
51534
  // This SDK version is replaced by the `yarn build` command ran on the root level
51519
51535
  const globalPackageVersion = () => SDK_VERSION_MARKER;
51520
51536
 
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import { walletContracts } from '@0xsequence/abi';
23
23
  import { v1 } from '@0xsequence/core';
24
24
  import FormData$2 from 'form-data';
25
25
  import { Seaport as Seaport$1 } from '@opensea/seaport-js';
26
- import { JsonRpcProvider, JsonRpcSigner } from 'ethers-v6';
26
+ import { FetchRequest, JsonRpcProvider, JsonRpcSigner } from 'ethers-v6';
27
27
  import detectEthereumProvider from '@metamask/detect-provider';
28
28
  import * as Uniswap from '@uniswap/sdk-core';
29
29
  import { TradeType, Percent } from '@uniswap/sdk-core';
@@ -159,7 +159,7 @@ const flattenProperties$1 = (properties) => {
159
159
  };
160
160
 
161
161
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
162
- const SDK_VERSION$1 = '1.28.1';
162
+ const SDK_VERSION$1 = '1.28.2';
163
163
  const getReferrer$1 = () => {
164
164
  if (isNode$1()) {
165
165
  return '';
@@ -14311,7 +14311,7 @@ class MultiRollupApiClients {
14311
14311
  }
14312
14312
 
14313
14313
  // eslint-disable-next-line @typescript-eslint/naming-convention
14314
- const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
14314
+ const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
14315
14315
  const createConfig$1 = ({ basePath, headers, }) => {
14316
14316
  if (!basePath.trim()) {
14317
14317
  throw Error('basePath can not be empty');
@@ -14383,7 +14383,7 @@ class APIError extends Error {
14383
14383
 
14384
14384
  /* eslint-disable implicit-arrow-linebreak */
14385
14385
  const defaultHeaders$1 = {
14386
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.28.1',
14386
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.28.2',
14387
14387
  };
14388
14388
  /**
14389
14389
  * createAPIConfiguration to create a custom Configuration
@@ -14857,7 +14857,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
14857
14857
  /* eslint-disable @typescript-eslint/naming-convention */
14858
14858
  class ApiConfiguration extends index$2.Configuration {
14859
14859
  }
14860
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
14860
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
14861
14861
  /**
14862
14862
  * @dev use createImmutableXConfiguration instead
14863
14863
  */
@@ -14896,7 +14896,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
14896
14896
  chainID,
14897
14897
  coreContractAddress,
14898
14898
  registrationContractAddress,
14899
- sdkVersion: 'ts-immutable-sdk-1.28.1',
14899
+ sdkVersion: 'ts-immutable-sdk-1.28.2',
14900
14900
  baseConfig,
14901
14901
  });
14902
14902
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -28420,11 +28420,13 @@ class Seaport {
28420
28420
  provider;
28421
28421
  seaportContractAddress;
28422
28422
  zoneContractAddress;
28423
- constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress) {
28423
+ rateLimitingKey;
28424
+ constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress, rateLimitingKey) {
28424
28425
  this.seaportLibFactory = seaportLibFactory;
28425
28426
  this.provider = provider;
28426
28427
  this.seaportContractAddress = seaportContractAddress;
28427
28428
  this.zoneContractAddress = zoneContractAddress;
28429
+ this.rateLimitingKey = rateLimitingKey;
28428
28430
  }
28429
28431
  async prepareSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
28430
28432
  const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry);
@@ -28590,11 +28592,7 @@ class Seaport {
28590
28592
  }
28591
28593
  getSeaportLib(order) {
28592
28594
  const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
28593
- const seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
28594
- // if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
28595
- // seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
28596
- // }
28597
- return this.seaportLibFactory.create(seaportVersion, seaportAddress);
28595
+ return this.seaportLibFactory.create(seaportAddress, this.rateLimitingKey);
28598
28596
  }
28599
28597
  static getExpirationISOTimeFromExtraData(extraData) {
28600
28598
  // Expirtaion bytes in SIP7 extra data [21:29]
@@ -28717,12 +28715,17 @@ class ImmutableApiClientFactory {
28717
28715
  chainName;
28718
28716
  seaportAddress;
28719
28717
  orderbookClient;
28720
- constructor(apiEndpoint, chainName, seaportAddress) {
28718
+ constructor(apiEndpoint, chainName, seaportAddress, rateLimitingKey) {
28721
28719
  this.chainName = chainName;
28722
28720
  this.seaportAddress = seaportAddress;
28723
28721
  this.orderbookClient = new OrderBookClient({
28724
28722
  // eslint-disable-next-line @typescript-eslint/naming-convention
28725
28723
  BASE: apiEndpoint,
28724
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28725
+ HEADERS: rateLimitingKey ? {
28726
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28727
+ 'x-api-key': rateLimitingKey,
28728
+ } : undefined,
28726
28729
  });
28727
28730
  }
28728
28731
  create() {
@@ -28732,15 +28735,24 @@ class ImmutableApiClientFactory {
28732
28735
 
28733
28736
  const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
28734
28737
  const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
28735
- function getOrderbookConfig(environment) {
28736
- switch (environment) {
28738
+ function getConfiguredProvider(url, rateLimitingKey) {
28739
+ return new providers.JsonRpcProvider({
28740
+ url,
28741
+ headers: rateLimitingKey ? {
28742
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28743
+ 'x-api-key': rateLimitingKey,
28744
+ } : undefined,
28745
+ });
28746
+ }
28747
+ function getOrderbookConfig(config) {
28748
+ switch (config.baseConfig.environment) {
28737
28749
  case Environment$1.SANDBOX:
28738
28750
  return {
28739
28751
  seaportContractAddress: '0x7d117aA8BD6D31c4fa91722f246388f38ab1942c',
28740
28752
  zoneContractAddress: '0x8831867E347AB87FA30199C5B695F0A31604Bb52',
28741
28753
  apiEndpoint: 'https://api.sandbox.immutable.com',
28742
28754
  chainName: TESTNET_CHAIN_NAME,
28743
- provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
28755
+ provider: getConfiguredProvider('https://rpc.testnet.immutable.com', config.baseConfig.rateLimitingKey),
28744
28756
  };
28745
28757
  // not yet deployed
28746
28758
  case Environment$1.PRODUCTION:
@@ -28749,7 +28761,7 @@ function getOrderbookConfig(environment) {
28749
28761
  zoneContractAddress: '0x00338b92Bec262078B3e49BF12bbEA058916BF91',
28750
28762
  apiEndpoint: 'https://api.immutable.com',
28751
28763
  chainName: MAINNET_CHAIN_NAME,
28752
- provider: new providers.JsonRpcProvider('https://rpc.immutable.com'),
28764
+ provider: getConfiguredProvider('https://rpc.immutable.com', config.baseConfig.rateLimitingKey),
28753
28765
  };
28754
28766
  default:
28755
28767
  return null;
@@ -28759,8 +28771,12 @@ function getOrderbookConfig(environment) {
28759
28771
  // The order book module only supports V5 JsonRpcProviders. These are instantiated
28760
28772
  // by the environment or by providing an RPC URL override. For this reason we can
28761
28773
  // safely instantiate a V6 provider for the V5 provider URL.
28762
- function convertToV6Provider(provider) {
28763
- const overwrittenProvider = new JsonRpcProvider(provider.connection.url);
28774
+ function convertToV6Provider(provider, rateLimitingKey) {
28775
+ const fetch = new FetchRequest(provider.connection.url);
28776
+ if (rateLimitingKey) {
28777
+ fetch.setHeader('x-api-key', rateLimitingKey);
28778
+ }
28779
+ const overwrittenProvider = new JsonRpcProvider(fetch);
28764
28780
  // Need to override the getSigner method to mimic V5 behaviour
28765
28781
  overwrittenProvider.getSigner = async function getSigner(address) {
28766
28782
  if (address == null) {
@@ -28790,9 +28806,9 @@ class SeaportLibFactory {
28790
28806
  this.defaultSeaportContractAddress = defaultSeaportContractAddress;
28791
28807
  this.provider = provider;
28792
28808
  }
28793
- create(orderSeaportVersion, orderSeaportAddress) {
28809
+ create(orderSeaportAddress, rateLimitingKey) {
28794
28810
  const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
28795
- return new Seaport$1(convertToV6Provider(this.provider), {
28811
+ return new Seaport$1(convertToV6Provider(this.provider, rateLimitingKey), {
28796
28812
  balanceAndApprovalChecksOnOrderCreation: true,
28797
28813
  overrides: {
28798
28814
  contractAddress: seaportContractAddress,
@@ -28811,13 +28827,13 @@ class Orderbook {
28811
28827
  seaport;
28812
28828
  orderbookConfig;
28813
28829
  constructor(config) {
28814
- const obConfig = getOrderbookConfig(config.baseConfig.environment);
28830
+ const obConfig = getOrderbookConfig(config);
28815
28831
  const finalConfig = {
28816
28832
  ...obConfig,
28817
28833
  ...config.overrides,
28818
28834
  };
28819
28835
  if (config.overrides?.jsonRpcProviderUrl) {
28820
- finalConfig.provider = new providers.JsonRpcProvider(config.overrides.jsonRpcProviderUrl);
28836
+ finalConfig.provider = getConfiguredProvider(config.overrides?.jsonRpcProviderUrl, config.baseConfig.rateLimitingKey);
28821
28837
  }
28822
28838
  if (!finalConfig) {
28823
28839
  throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
@@ -28827,9 +28843,9 @@ class Orderbook {
28827
28843
  if (!apiEndpoint) {
28828
28844
  throw new Error('API endpoint must be provided');
28829
28845
  }
28830
- this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
28846
+ this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress, config.baseConfig.rateLimitingKey).create();
28831
28847
  const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
28832
- this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
28848
+ this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress, config.baseConfig.rateLimitingKey);
28833
28849
  }
28834
28850
  /**
28835
28851
  * Return the configuration for the orderbook module.
@@ -46296,7 +46312,7 @@ const flattenProperties = (properties) => {
46296
46312
  };
46297
46313
 
46298
46314
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
46299
- const SDK_VERSION = '1.28.1';
46315
+ const SDK_VERSION = '1.28.2';
46300
46316
  const getReferrer = () => {
46301
46317
  if (isNode()) {
46302
46318
  return '';
@@ -51491,7 +51507,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
51491
51507
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
51492
51508
  };
51493
51509
 
51494
- const SDK_VERSION_MARKER = '1.28.1';
51510
+ const SDK_VERSION_MARKER = '1.28.2';
51495
51511
  // This SDK version is replaced by the `yarn build` command ran on the root level
51496
51512
  const globalPackageVersion = () => SDK_VERSION_MARKER;
51497
51513
 
package/dist/orderbook.js CHANGED
@@ -1,10 +1,10 @@
1
- import { providers, BigNumber, constants as constants$1 } from 'ethers';
2
1
  import axios from 'axios';
3
2
  import FormData from 'form-data';
3
+ import { providers, BigNumber, constants as constants$1 } from 'ethers';
4
4
  import { memorise } from 'lru-memorise';
5
5
  import { getGlobalisedValue as getGlobalisedValue$1 } from 'global-const';
6
6
  import { Seaport as Seaport$1 } from '@opensea/seaport-js';
7
- import { JsonRpcProvider, JsonRpcSigner } from 'ethers-v6';
7
+ import { FetchRequest, JsonRpcProvider, JsonRpcSigner } from 'ethers-v6';
8
8
 
9
9
  const isNode = () => typeof window === 'undefined';
10
10
  const isBrowser = () => !isNode();
@@ -132,7 +132,7 @@ const flattenProperties = (properties) => {
132
132
  };
133
133
 
134
134
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
135
- const SDK_VERSION = '1.28.1';
135
+ const SDK_VERSION = '1.28.2';
136
136
  const getReferrer = () => {
137
137
  if (isNode()) {
138
138
  return '';
@@ -1294,11 +1294,13 @@ class Seaport {
1294
1294
  provider;
1295
1295
  seaportContractAddress;
1296
1296
  zoneContractAddress;
1297
- constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress) {
1297
+ rateLimitingKey;
1298
+ constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress, rateLimitingKey) {
1298
1299
  this.seaportLibFactory = seaportLibFactory;
1299
1300
  this.provider = provider;
1300
1301
  this.seaportContractAddress = seaportContractAddress;
1301
1302
  this.zoneContractAddress = zoneContractAddress;
1303
+ this.rateLimitingKey = rateLimitingKey;
1302
1304
  }
1303
1305
  async prepareSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
1304
1306
  const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry);
@@ -1464,11 +1466,7 @@ class Seaport {
1464
1466
  }
1465
1467
  getSeaportLib(order) {
1466
1468
  const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
1467
- const seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
1468
- // if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
1469
- // seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
1470
- // }
1471
- return this.seaportLibFactory.create(seaportVersion, seaportAddress);
1469
+ return this.seaportLibFactory.create(seaportAddress, this.rateLimitingKey);
1472
1470
  }
1473
1471
  static getExpirationISOTimeFromExtraData(extraData) {
1474
1472
  // Expirtaion bytes in SIP7 extra data [21:29]
@@ -1591,12 +1589,17 @@ class ImmutableApiClientFactory {
1591
1589
  chainName;
1592
1590
  seaportAddress;
1593
1591
  orderbookClient;
1594
- constructor(apiEndpoint, chainName, seaportAddress) {
1592
+ constructor(apiEndpoint, chainName, seaportAddress, rateLimitingKey) {
1595
1593
  this.chainName = chainName;
1596
1594
  this.seaportAddress = seaportAddress;
1597
1595
  this.orderbookClient = new OrderBookClient({
1598
1596
  // eslint-disable-next-line @typescript-eslint/naming-convention
1599
1597
  BASE: apiEndpoint,
1598
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1599
+ HEADERS: rateLimitingKey ? {
1600
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1601
+ 'x-api-key': rateLimitingKey,
1602
+ } : undefined,
1600
1603
  });
1601
1604
  }
1602
1605
  create() {
@@ -1606,15 +1609,24 @@ class ImmutableApiClientFactory {
1606
1609
 
1607
1610
  const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
1608
1611
  const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
1609
- function getOrderbookConfig(environment) {
1610
- switch (environment) {
1612
+ function getConfiguredProvider(url, rateLimitingKey) {
1613
+ return new providers.JsonRpcProvider({
1614
+ url,
1615
+ headers: rateLimitingKey ? {
1616
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1617
+ 'x-api-key': rateLimitingKey,
1618
+ } : undefined,
1619
+ });
1620
+ }
1621
+ function getOrderbookConfig(config) {
1622
+ switch (config.baseConfig.environment) {
1611
1623
  case Environment.SANDBOX:
1612
1624
  return {
1613
1625
  seaportContractAddress: '0x7d117aA8BD6D31c4fa91722f246388f38ab1942c',
1614
1626
  zoneContractAddress: '0x8831867E347AB87FA30199C5B695F0A31604Bb52',
1615
1627
  apiEndpoint: 'https://api.sandbox.immutable.com',
1616
1628
  chainName: TESTNET_CHAIN_NAME,
1617
- provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
1629
+ provider: getConfiguredProvider('https://rpc.testnet.immutable.com', config.baseConfig.rateLimitingKey),
1618
1630
  };
1619
1631
  // not yet deployed
1620
1632
  case Environment.PRODUCTION:
@@ -1623,7 +1635,7 @@ function getOrderbookConfig(environment) {
1623
1635
  zoneContractAddress: '0x00338b92Bec262078B3e49BF12bbEA058916BF91',
1624
1636
  apiEndpoint: 'https://api.immutable.com',
1625
1637
  chainName: MAINNET_CHAIN_NAME,
1626
- provider: new providers.JsonRpcProvider('https://rpc.immutable.com'),
1638
+ provider: getConfiguredProvider('https://rpc.immutable.com', config.baseConfig.rateLimitingKey),
1627
1639
  };
1628
1640
  default:
1629
1641
  return null;
@@ -1633,8 +1645,12 @@ function getOrderbookConfig(environment) {
1633
1645
  // The order book module only supports V5 JsonRpcProviders. These are instantiated
1634
1646
  // by the environment or by providing an RPC URL override. For this reason we can
1635
1647
  // safely instantiate a V6 provider for the V5 provider URL.
1636
- function convertToV6Provider(provider) {
1637
- const overwrittenProvider = new JsonRpcProvider(provider.connection.url);
1648
+ function convertToV6Provider(provider, rateLimitingKey) {
1649
+ const fetch = new FetchRequest(provider.connection.url);
1650
+ if (rateLimitingKey) {
1651
+ fetch.setHeader('x-api-key', rateLimitingKey);
1652
+ }
1653
+ const overwrittenProvider = new JsonRpcProvider(fetch);
1638
1654
  // Need to override the getSigner method to mimic V5 behaviour
1639
1655
  overwrittenProvider.getSigner = async function getSigner(address) {
1640
1656
  if (address == null) {
@@ -1664,9 +1680,9 @@ class SeaportLibFactory {
1664
1680
  this.defaultSeaportContractAddress = defaultSeaportContractAddress;
1665
1681
  this.provider = provider;
1666
1682
  }
1667
- create(orderSeaportVersion, orderSeaportAddress) {
1683
+ create(orderSeaportAddress, rateLimitingKey) {
1668
1684
  const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
1669
- return new Seaport$1(convertToV6Provider(this.provider), {
1685
+ return new Seaport$1(convertToV6Provider(this.provider, rateLimitingKey), {
1670
1686
  balanceAndApprovalChecksOnOrderCreation: true,
1671
1687
  overrides: {
1672
1688
  contractAddress: seaportContractAddress,
@@ -1685,13 +1701,13 @@ class Orderbook {
1685
1701
  seaport;
1686
1702
  orderbookConfig;
1687
1703
  constructor(config) {
1688
- const obConfig = getOrderbookConfig(config.baseConfig.environment);
1704
+ const obConfig = getOrderbookConfig(config);
1689
1705
  const finalConfig = {
1690
1706
  ...obConfig,
1691
1707
  ...config.overrides,
1692
1708
  };
1693
1709
  if (config.overrides?.jsonRpcProviderUrl) {
1694
- finalConfig.provider = new providers.JsonRpcProvider(config.overrides.jsonRpcProviderUrl);
1710
+ finalConfig.provider = getConfiguredProvider(config.overrides?.jsonRpcProviderUrl, config.baseConfig.rateLimitingKey);
1695
1711
  }
1696
1712
  if (!finalConfig) {
1697
1713
  throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
@@ -1701,9 +1717,9 @@ class Orderbook {
1701
1717
  if (!apiEndpoint) {
1702
1718
  throw new Error('API endpoint must be provided');
1703
1719
  }
1704
- this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
1720
+ this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress, config.baseConfig.rateLimitingKey).create();
1705
1721
  const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
1706
- this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
1722
+ this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress, config.baseConfig.rateLimitingKey);
1707
1723
  }
1708
1724
  /**
1709
1725
  * Return the configuration for the orderbook module.
package/dist/passport.js CHANGED
@@ -11563,7 +11563,7 @@ class MultiRollupApiClients {
11563
11563
  }
11564
11564
 
11565
11565
  // eslint-disable-next-line @typescript-eslint/naming-convention
11566
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
11566
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
11567
11567
  const createConfig$1 = ({ basePath, headers, }) => {
11568
11568
  if (!basePath.trim()) {
11569
11569
  throw Error('basePath can not be empty');
@@ -11742,7 +11742,7 @@ const flattenProperties = (properties) => {
11742
11742
  };
11743
11743
 
11744
11744
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
11745
- const SDK_VERSION = '1.28.1';
11745
+ const SDK_VERSION = '1.28.2';
11746
11746
  const getReferrer = () => {
11747
11747
  if (isNode()) {
11748
11748
  return '';
@@ -11992,7 +11992,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
11992
11992
  /* eslint-disable @typescript-eslint/naming-convention */
11993
11993
  class ApiConfiguration extends index$2.Configuration {
11994
11994
  }
11995
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
11995
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
11996
11996
  /**
11997
11997
  * @dev use createImmutableXConfiguration instead
11998
11998
  */
@@ -12031,7 +12031,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
12031
12031
  chainID,
12032
12032
  coreContractAddress,
12033
12033
  registrationContractAddress,
12034
- sdkVersion: 'ts-immutable-sdk-1.28.1',
12034
+ sdkVersion: 'ts-immutable-sdk-1.28.2',
12035
12035
  baseConfig,
12036
12036
  });
12037
12037
  const production = ({ baseConfig }) => createImmutableXConfiguration({
package/dist/x.js CHANGED
@@ -9003,7 +9003,7 @@ const flattenProperties = (properties) => {
9003
9003
  };
9004
9004
 
9005
9005
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
9006
- const SDK_VERSION = '1.28.1';
9006
+ const SDK_VERSION = '1.28.2';
9007
9007
  const getReferrer = () => {
9008
9008
  if (isNode()) {
9009
9009
  return '';
@@ -9246,7 +9246,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
9246
9246
  /* eslint-disable @typescript-eslint/naming-convention */
9247
9247
  class ApiConfiguration extends index$2.Configuration {
9248
9248
  }
9249
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.1' };
9249
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.28.2' };
9250
9250
  /**
9251
9251
  * @dev use createImmutableXConfiguration instead
9252
9252
  */
@@ -9285,7 +9285,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
9285
9285
  chainID,
9286
9286
  coreContractAddress,
9287
9287
  registrationContractAddress,
9288
- sdkVersion: 'ts-immutable-sdk-1.28.1',
9288
+ sdkVersion: 'ts-immutable-sdk-1.28.2',
9289
9289
  baseConfig,
9290
9290
  });
9291
9291
  const production = ({ baseConfig }) => createImmutableXConfiguration({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "1.28.1",
4
+ "version": "1.28.2",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",