@toruslabs/ethereum-controllers 4.9.0 → 4.10.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.
@@ -1551,6 +1551,8 @@ class GasFeeController extends BaseController {
1551
1551
  state
1552
1552
  });
1553
1553
  _defineProperty(this, "name", "GasFeeController");
1554
+ // https://0x.org/docs/introduction/0x-cheat-sheet#swap-api-endpoints
1555
+ _defineProperty(this, "API_SUPPORTED_CHAINIDS", new Set(["0x1", "0x5", "0x13881", "0xa4b1", "0xa86a", "0x2105", "0x38", "0xfa", "0xa", "0x89"]));
1554
1556
  _defineProperty(this, "intervalId", void 0);
1555
1557
  _defineProperty(this, "provider", void 0);
1556
1558
  _defineProperty(this, "currentChainId", void 0);
@@ -1654,7 +1656,11 @@ class GasFeeController extends BaseController {
1654
1656
  if (isEIP1559Compatible) {
1655
1657
  let estimates;
1656
1658
  try {
1657
- estimates = await this.fetchGasEstimates(this.config.EIP1559APIEndpoint.replace("<chain_id>", `${chainIdInt}`));
1659
+ if (this.API_SUPPORTED_CHAINIDS.has(chainId)) {
1660
+ estimates = await this.fetchGasEstimates(this.config.EIP1559APIEndpoint.replace("<chain_id>", `${chainIdInt}`));
1661
+ } else {
1662
+ throw new Error("ChainId not supported by api");
1663
+ }
1658
1664
  } catch (error) {
1659
1665
  estimates = await this.fetchGasEstimatesViaEthFeeHistory(this.provider);
1660
1666
  }
@@ -2948,7 +2954,7 @@ function createProviderConfigMiddleware(providerConfig) {
2948
2954
  return next();
2949
2955
  };
2950
2956
  }
2951
- function createJsonRpcClient(providerConfig) {
2957
+ function createJsonRpcClient(providerConfig, networkConfig) {
2952
2958
  const {
2953
2959
  chainId,
2954
2960
  rpcTarget
@@ -2958,9 +2964,9 @@ function createJsonRpcClient(providerConfig) {
2958
2964
  });
2959
2965
  const blockProvider = providerFromMiddleware(fetchMiddleware);
2960
2966
  const blockTracker = new PollingBlockTracker({
2961
- config: {
2967
+ config: _objectSpread(_objectSpread({}, networkConfig), {}, {
2962
2968
  provider: blockProvider
2963
- },
2969
+ }),
2964
2970
  state: {}
2965
2971
  });
2966
2972
  const networkMiddleware = mergeMiddleware([createChainIdMiddleware(chainId), createProviderConfigMiddleware(providerConfig),
@@ -3152,7 +3158,7 @@ class NetworkController extends BaseController {
3152
3158
  this.blockTracker = blockTracker;
3153
3159
  }
3154
3160
  configureStandardProvider(providerConfig) {
3155
- const networkClient = createJsonRpcClient(providerConfig);
3161
+ const networkClient = createJsonRpcClient(providerConfig, this.config);
3156
3162
  log.info("networkClient", networkClient);
3157
3163
  this.setNetworkClient(networkClient);
3158
3164
  }
@@ -5073,7 +5079,6 @@ function getFinalStates() {
5073
5079
  TransactionStatus.dropped // the tx nonce was already used
5074
5080
  ];
5075
5081
  }
5076
-
5077
5082
  function parseStandardTokenTransactionData(data) {
5078
5083
  try {
5079
5084
  const txDesc = erc20Interface.parseTransaction({
@@ -5513,7 +5518,6 @@ class TransactionController extends TransactionStateManager {
5513
5518
  getConfirmedTransactions: this.getConfirmedTransactions.bind(this),
5514
5519
  getPendingTransactions: this.getSubmittedTransactions.bind(this) // nonce tracker should only care about submitted transactions
5515
5520
  });
5516
-
5517
5521
  this.pendingTxTracker = new PendingTransactionTracker({
5518
5522
  provider,
5519
5523
  nonceTracker: this.nonceTracker,