@imtbl/sdk 0.4.0-alpha.2 → 0.4.0-alpha.3

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.
@@ -565,6 +565,16 @@ interface ModuleConfiguration<T> {
565
565
  overrides?: T;
566
566
  }
567
567
 
568
+ /**
569
+ * Interface representing the secondary fees for a swap
570
+ * @property {string} feeRecipient - The fee recipient address
571
+ * @property {number} feeBasisPoints - The fee percentage in basis points
572
+ * @example 100 basis points = 1%
573
+ */
574
+ type SecondaryFee = {
575
+ feeRecipient: string;
576
+ feeBasisPoints: number;
577
+ };
568
578
  /**
569
579
  * Interface representing a token
570
580
  * @property {number} chainId - The chain ID
@@ -585,6 +595,7 @@ interface ExchangeOverrides {
585
595
  exchangeContracts: ExchangeContracts;
586
596
  commonRoutingTokens: TokenInfo$1[];
587
597
  nativeToken: TokenInfo$1;
598
+ secondaryFees?: SecondaryFee[];
588
599
  }
589
600
 
590
601
  /**
@@ -607,8 +618,8 @@ type FungibleToken = Address | 'NATIVE';
607
618
  */
608
619
  declare enum ChainId {
609
620
  IMTBL_ZKEVM_MAINNET = 13371,
610
- IMTBL_ZKEVM_TESTNET = 13392,
611
- IMTBL_ZKEVM_DEVNET = 13403,
621
+ IMTBL_ZKEVM_TESTNET = 13372,
622
+ IMTBL_ZKEVM_DEVNET = 13423,
612
623
  ETHEREUM = 1,
613
624
  SEPOLIA = 11155111
614
625
  }
@@ -978,9 +989,11 @@ interface CreateProviderParams {
978
989
  /**
979
990
  * Represents the result of creating a Web3 provider {@link Checkout.createProvider}.
980
991
  * @property {Web3Provider} provider - The created Web3 provider.
992
+ * @property {WalletProviderName} providerName - The name of the wallet provider.
981
993
  */
982
994
  type CreateProviderResult = {
983
995
  provider: Web3Provider;
996
+ walletProviderName: WalletProviderName;
984
997
  };
985
998
  /**
986
999
  * Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
@@ -1088,6 +1101,7 @@ declare class RemoteConfigFetcher {
1088
1101
  }
1089
1102
  declare class CheckoutConfiguration {
1090
1103
  readonly isDevelopment: boolean;
1104
+ readonly isLocal: boolean;
1091
1105
  readonly isProduction: boolean;
1092
1106
  readonly remote: RemoteConfigFetcher;
1093
1107
  readonly environment: Environment;
@@ -10216,7 +10216,7 @@ const ETH_MAINNET_CHAIN_ID = 'eip155:1';
10216
10216
  /**
10217
10217
  * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
10218
10218
  */
10219
- const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13403';
10219
+ const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13423';
10220
10220
  /**
10221
10221
  /**
10222
10222
  * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
@@ -10274,14 +10274,14 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
10274
10274
  */
10275
10275
  const CONTRACTS_FOR_BRIDGE = new Map()
10276
10276
  .set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
10277
- rootChainERC20Predicate: '0x15Dd735de418B6d290727aed82cC25F8966dE4A5',
10278
- rootChainStateSender: '0xb3Bac13799dAca9D9eC9307303a65fA1218b4724',
10277
+ rootChainERC20Predicate: '0xf0b3435411A74F1aeCBD0fd6D53a90D5227fEeba',
10278
+ rootChainStateSender: '0x868097dbAcfD431F441d09D0e4D3B5eD3182E597',
10279
10279
  childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
10280
10280
  childChainStateReceiver: '0x0000000000000000000000000000000000001001',
10281
10281
  })
10282
10282
  .set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
10283
- rootChainERC20Predicate: '0x9A7E4C4337a70C6754a9672F5ba69084463794B8',
10284
- rootChainStateSender: '0xfBfF6FD165adFA113bE39eE85ef030A996153253',
10283
+ rootChainERC20Predicate: '0x0C15a8359865867CdCC44f98b2F3fd5DF098C7E0',
10284
+ rootChainStateSender: '0x4C80001188db53dbc2eaAb32d5ef825feEedECA5',
10285
10285
  childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
10286
10286
  childChainStateReceiver: '0x0000000000000000000000000000000000001001',
10287
10287
  })
@@ -10873,7 +10873,7 @@ function getQuote(otherCurrency, tradeType, tradeInfo, slippage) {
10873
10873
  }
10874
10874
 
10875
10875
  const IMMUTABLE_TESTNET_RPC_URL = 'https://zkevm-rpc.sandbox.x.immutable.com';
10876
- const IMMUTABLE_TESTNET_CHAIN_ID = 13392;
10876
+ const IMMUTABLE_TESTNET_CHAIN_ID = 13372;
10877
10877
 
10878
10878
  const TIMX_IMMUTABLE_TESTNET = {
10879
10879
  chainId: IMMUTABLE_TESTNET_CHAIN_ID,
@@ -12512,16 +12512,28 @@ const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
12512
12512
  [Environment$1.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
12513
12513
  };
12514
12514
  function validateOverrides(overrides) {
12515
- Object.entries(overrides).forEach(([key, value]) => {
12516
- if (!value) {
12515
+ const keysToCheck = ['rpcURL', 'exchangeContracts', 'commonRoutingTokens', 'nativeToken'];
12516
+ for (const key of keysToCheck) {
12517
+ if (!overrides[key]) {
12517
12518
  throw new InvalidConfigurationError(`Missing override: ${key}`);
12518
12519
  }
12519
- });
12520
+ }
12520
12521
  Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
12521
12522
  if (!isValidNonZeroAddress(contract)) {
12522
12523
  throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
12523
12524
  }
12524
12525
  });
12526
+ if (!overrides.secondaryFees) {
12527
+ return;
12528
+ }
12529
+ for (const secondaryFee of overrides.secondaryFees) {
12530
+ if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
12531
+ throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
12532
+ }
12533
+ if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > 10000) {
12534
+ throw new InvalidConfigurationError(`Invalid secondary fee percentage: ${secondaryFee.feeBasisPoints}`);
12535
+ }
12536
+ }
12525
12537
  }
12526
12538
  /**
12527
12539
  * {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
@@ -12531,6 +12543,7 @@ function validateOverrides(overrides) {
12531
12543
  class ExchangeConfiguration {
12532
12544
  baseConfig;
12533
12545
  chain;
12546
+ secondaryFees;
12534
12547
  constructor({ chainId, baseConfig, overrides }) {
12535
12548
  this.baseConfig = baseConfig;
12536
12549
  if (overrides) {
@@ -12542,8 +12555,10 @@ class ExchangeConfiguration {
12542
12555
  commonRoutingTokens: overrides.commonRoutingTokens,
12543
12556
  nativeToken: overrides.nativeToken,
12544
12557
  };
12558
+ this.secondaryFees = overrides.secondaryFees ? overrides.secondaryFees : [];
12545
12559
  return;
12546
12560
  }
12561
+ this.secondaryFees = [];
12547
12562
  const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
12548
12563
  if (!chain) {
12549
12564
  throw new ChainNotSupportedError(chainId, baseConfig.environment);
@@ -12557,11 +12572,13 @@ class Exchange {
12557
12572
  router;
12558
12573
  chainId;
12559
12574
  nativeToken;
12575
+ secondaryFees;
12560
12576
  constructor(configuration) {
12561
12577
  const config = new ExchangeConfiguration(configuration);
12562
12578
  this.chainId = config.chain.chainId;
12563
12579
  this.nativeToken = config.chain.nativeToken;
12564
12580
  this.provider = new ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
12581
+ this.secondaryFees = config.secondaryFees;
12565
12582
  this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
12566
12583
  multicallAddress: config.chain.contracts.multicall,
12567
12584
  factoryAddress: config.chain.contracts.coreFactory,
@@ -12644,6 +12661,9 @@ class Exchange {
12644
12661
  async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
12645
12662
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, TradeType.EXACT_OUTPUT);
12646
12663
  }
12664
+ thereAreSecondaryFees() {
12665
+ return this.secondaryFees.length > 0;
12666
+ }
12647
12667
  }
12648
12668
 
12649
12669
  /* eslint-disable class-methods-use-this */
@@ -12720,8 +12740,8 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
12720
12740
  */ var $0472f23319457bfb$export$c06e1e7429de6283;
12721
12741
  (function(ChainId) {
12722
12742
  ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
12723
- ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13392] = "IMTBL_ZKEVM_TESTNET";
12724
- ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13403] = "IMTBL_ZKEVM_DEVNET";
12743
+ ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13372] = "IMTBL_ZKEVM_TESTNET";
12744
+ ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13423] = "IMTBL_ZKEVM_DEVNET";
12725
12745
  ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
12726
12746
  ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
12727
12747
  })($0472f23319457bfb$export$c06e1e7429de6283 || ($0472f23319457bfb$export$c06e1e7429de6283 = {}));
@@ -12806,6 +12826,10 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
12806
12826
  [(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
12807
12827
  [(Environment$1).PRODUCTION]: "https://checkout-api.immutable.com"
12808
12828
  };
12829
+ const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
12830
+ [(Environment$1).SANDBOX]: "https://zkevm-rpc.sandbox.x.immutable.com",
12831
+ [(Environment$1).PRODUCTION]: "https://zkevm-rpc.x.immutable.com"
12832
+ };
12809
12833
  const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
12810
12834
  [
12811
12835
  ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
@@ -12831,7 +12855,7 @@ const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
12831
12855
  chainIdHex: `0x${($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET.toString(16)}`,
12832
12856
  chainName: ($0472f23319457bfb$export$b874c6b1dfe85e02).IMTBL_ZKEVM_MAINNET,
12833
12857
  rpcUrls: [
12834
- "https://zkevm-rpc.x.immutable.com"
12858
+ "https://rpc.immutable.com"
12835
12859
  ],
12836
12860
  nativeCurrency: {
12837
12861
  name: "IMX",
@@ -12866,7 +12890,7 @@ const $d85ad1457a3f1a83$export$3e81fc0987227f10 = new Map([
12866
12890
  chainIdHex: `0x${($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET.toString(16)}`,
12867
12891
  chainName: ($0472f23319457bfb$export$b874c6b1dfe85e02).IMTBL_ZKEVM_TESTNET,
12868
12892
  rpcUrls: [
12869
- "https://zkevm-rpc.sandbox.x.immutable.com"
12893
+ "https://rpc.testnet.immutable.com"
12870
12894
  ],
12871
12895
  nativeCurrency: {
12872
12896
  name: "IMX",
@@ -13242,16 +13266,19 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
13242
13266
  if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
13243
13267
  return new (Web3Provider)(provider);
13244
13268
  }
13245
- async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
13246
- let web3Provider = null;
13247
- switch(defaultProvider){
13269
+ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
13270
+ let provider = null;
13271
+ switch(walletProviderName){
13248
13272
  case ($e768639828688ca3$export$2d7a51a18d87e21d).METAMASK:
13249
- web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
13273
+ provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
13250
13274
  break;
13251
13275
  default:
13252
13276
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).DEFAULT_PROVIDER_ERROR);
13253
13277
  }
13254
- return web3Provider;
13278
+ return {
13279
+ provider: provider,
13280
+ walletProviderName: walletProviderName
13281
+ };
13255
13282
  }
13256
13283
 
13257
13284
 
@@ -13260,9 +13287,8 @@ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
13260
13287
 
13261
13288
 
13262
13289
 
13263
-
13264
13290
  function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
13265
- if (web3Provider && web3Provider instanceof (Web3Provider) && web3Provider.provider?.request) return true;
13291
+ if (web3Provider && web3Provider.provider?.request && typeof web3Provider.provider.request === "function") return true;
13266
13292
  return false;
13267
13293
  }
13268
13294
  async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
@@ -13472,10 +13498,23 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
13472
13498
  this.message = message;
13473
13499
  }
13474
13500
  }
13475
- const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
13476
- if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
13477
- if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
13478
- return $d85ad1457a3f1a83$export$3e81fc0987227f10;
13501
+ const $4013c5c91bb535f6$var$networkMap = (prod, dev, local)=>{
13502
+ let networks;
13503
+ if (dev) networks = ($d85ad1457a3f1a83$export$3a9ebede6a150274);
13504
+ else if (prod) {
13505
+ networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
13506
+ if (local) {
13507
+ const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
13508
+ rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).PRODUCTION]);
13509
+ }
13510
+ } else {
13511
+ networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
13512
+ if (local) {
13513
+ const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
13514
+ rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).SANDBOX]);
13515
+ }
13516
+ }
13517
+ return networks;
13479
13518
  };
13480
13519
  const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
13481
13520
  // DevMode and Sandbox will both use Sepolia.
@@ -13493,6 +13532,11 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
13493
13532
  // This will be used to get around the lack of
13494
13533
  // Environment.DEVELOPMENT
13495
13534
  isDevelopment = false;
13535
+ // This is a hidden feature that is only available
13536
+ // when building the project from source code.
13537
+ // This will be used to get around the lack of
13538
+ // Environment.LOCAL_DEVELOPMENT
13539
+ isLocal = false;
13496
13540
  isProduction;
13497
13541
  remote;
13498
13542
  environment;
@@ -13502,7 +13546,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
13502
13546
  this.environment = config.baseConfig.environment;
13503
13547
  // Developer mode will super set any environment configuration
13504
13548
  this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
13505
- this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
13549
+ this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment, this.isLocal);
13506
13550
  this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
13507
13551
  isDevelopment: this.isDevelopment,
13508
13552
  isProduction: this.isProduction
@@ -13648,10 +13692,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
13648
13692
  * @param {CreateProviderParams} params - The parameters for creating the provider.
13649
13693
  * @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
13650
13694
  */ async createProvider(params) {
13651
- const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
13652
- return {
13653
- provider: web3Provider
13654
- };
13695
+ return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
13655
13696
  }
13656
13697
  /**
13657
13698
  * Checks if a wallet is connected to the specified provider.
@@ -14135,6 +14135,9 @@ declare namespace React {
14135
14135
  // - "string"
14136
14136
  // - union of string literals
14137
14137
  interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
14138
+ // React-specific Attributes
14139
+ suppressHydrationWarning?: boolean | undefined;
14140
+
14138
14141
  // Attributes which also defined in HTMLAttributes
14139
14142
  // See comment in SVGDOMPropertyConfig.js
14140
14143
  className?: string | undefined;
@@ -15024,7 +15027,6 @@ type SemanticVersion = {
15024
15027
  * @property {WidgetTheme | undefined} theme - The theme of the Checkout Widget (default: "DARK")
15025
15028
  * @property {Environment | undefined} environment - The environment configuration (default: "SANDBOX")
15026
15029
  * @property {SemanticVersion | undefined} version - The version of the checkout widgets js file to use (default: "0.1.0")
15027
- * @property {boolean | undefined} isOnRampEnabled - Enable on-ramp top-up method (default: "true")
15028
15030
  * @property {boolean | undefined} isSwapEnabled - Enable swap top-up method (default: "true")
15029
15031
  * @property {boolean | undefined} isBridgeEnabled - Enable bridge top-up method (default: "true")
15030
15032
  */
@@ -15032,7 +15034,6 @@ type CheckoutWidgetsConfig = {
15032
15034
  theme?: WidgetTheme;
15033
15035
  environment?: Environment;
15034
15036
  version?: SemanticVersion;
15035
- isOnRampEnabled?: boolean;
15036
15037
  isSwapEnabled?: boolean;
15037
15038
  isBridgeEnabled?: boolean;
15038
15039
  };
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha.2";
7
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha.3";
8
8
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
9
9
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
10
10
 
@@ -10194,14 +10194,14 @@ declare class ImmutableXClient {
10194
10194
  * @returns a promise that resolves with the requested Order
10195
10195
  * @throws {@link index.IMXError}
10196
10196
  */
10197
- getOrder(request: OrdersApiGetOrderRequest): Promise<Order>;
10197
+ getOrder(request: OrdersApiGetOrderRequest): Promise<OrderV3>;
10198
10198
  /**
10199
10199
  * Get a list of Orders
10200
10200
  * @param request - optional object containing the parameters to be provided in the API request
10201
10201
  * @returns a promise that resolves with the requested list of Orders
10202
10202
  * @throws {@link index.IMXError}
10203
10203
  */
10204
- listOrders(request?: OrdersApiListOrdersRequest): Promise<ListOrdersResponse>;
10204
+ listOrders(request?: OrdersApiListOrdersRequest): Promise<ListOrdersResponseV3>;
10205
10205
  /**
10206
10206
  * Get details of a Trade with the given ID
10207
10207
  * @param request - the request object containing the parameters to be provided in the API request
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
16
16
  chainID,
17
17
  coreContractAddress,
18
18
  registrationContractAddress,
19
- sdkVersion: 'ts-immutable-sdk-0.4.0-alpha.2',
19
+ sdkVersion: 'ts-immutable-sdk-0.4.0-alpha.3',
20
20
  });
21
21
  /**
22
22
  * Sets `sdkVersion` at the time of build