@exodus/ethereum-api 8.22.5 → 8.23.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.23.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.5...@exodus/ethereum-api@8.23.0) (2024-12-09)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: customFees api (#4653)
13
+
14
+
15
+
6
16
  ## [8.22.5](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.4...@exodus/ethereum-api@8.22.5) (2024-12-09)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.22.5",
3
+ "version": "8.23.0",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -64,5 +64,5 @@
64
64
  "type": "git",
65
65
  "url": "git+https://github.com/ExodusMovement/assets.git"
66
66
  },
67
- "gitHead": "2a5e9f37cb3694f7fc17f8760c69cbccda13e462"
67
+ "gitHead": "4d505ee7d024c0ae961e2d95e6408b0b251a7d89"
68
68
  }
@@ -22,6 +22,7 @@ import ms from 'ms'
22
22
 
23
23
  import { addressHasHistoryFactory } from './address-has-history.js'
24
24
  import { createTokenFactory } from './create-token-factory.js'
25
+ import { createCustomFeesApi } from './custom-fees.js'
25
26
  import { createEvmServer } from './exodus-eth-server/index.js'
26
27
  import { createFeeData } from './fee-data-factory.js'
27
28
  import { createGetBalanceForAddress } from './get-balance-for-address.js'
@@ -62,6 +63,7 @@ export const createAssetFactory = ({
62
63
  stakingConfiguration = {},
63
64
  useEip1191ChainIdChecksum = false,
64
65
  forceGasLimitEstimation = false,
66
+ supportsCustomFees: defaultSupportsCustomFees = false,
65
67
  }) => {
66
68
  assert(assetsList, 'assetsList is required')
67
69
  assert(providedFeeData || feeDataConfig, 'feeData or feeDataConfig is required')
@@ -81,6 +83,7 @@ export const createAssetFactory = ({
81
83
  const defaultConfig = {
82
84
  allowMetaMaskCompat: false,
83
85
  supportsStaking: false,
86
+ supportsCustomFees: defaultSupportsCustomFees,
84
87
  nfts: defaultNfts,
85
88
  customTokens: defaultCustomTokens,
86
89
  }
@@ -93,7 +96,7 @@ export const createAssetFactory = ({
93
96
  ) => {
94
97
  const assets = connectAssetsList(assetsList)
95
98
 
96
- const { allowMetaMaskCompat, supportsStaking, nfts, customTokens } = {
99
+ const { allowMetaMaskCompat, supportsStaking, nfts, customTokens, supportsCustomFees } = {
97
100
  ...defaultConfig,
98
101
  ...config,
99
102
  }
@@ -156,6 +159,7 @@ export const createAssetFactory = ({
156
159
  noHistory: monitorType === 'no-history',
157
160
  signWithSigner: true,
158
161
  signMessageWithSigner: true,
162
+ supportsCustomFees,
159
163
  ...(supportsStaking && { staking: {} }),
160
164
  }
161
165
 
@@ -246,6 +250,7 @@ export const createAssetFactory = ({
246
250
  createHistoryMonitor,
247
251
  createToken,
248
252
  createUnsignedTx,
253
+ customFees: createCustomFeesApi({ baseAsset: asset }),
249
254
  defaultAddressPath,
250
255
  features,
251
256
  getBalances,
@@ -263,7 +268,7 @@ export const createAssetFactory = ({
263
268
  getSupportedPurposes: () => [44],
264
269
  getTokens,
265
270
  hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
266
- privateKeyEncodingDefinition: { encoding: 'hex', prefix: '0x' },
271
+ privateKeyEncodingDefinition: { encoding: 'hex' },
267
272
  sendTx,
268
273
  signTx: ({ unsignedTx, privateKey, signer }) =>
269
274
  signer
@@ -0,0 +1,26 @@
1
+ import NumberUnit from '@exodus/currency'
2
+
3
+ export const createCustomFeesApi = ({ baseAsset }) => {
4
+ const Gwei = baseAsset.currency.units.Gwei
5
+ return {
6
+ getRecommendedMinMaxFeeUnitPrices: ({ feeData }) => {
7
+ const { gasPrice, gasPriceMinimumRate, gasPriceMaximumRate } = feeData
8
+
9
+ const calculateFeeUnitPrice = (
10
+ feeUnitPrice,
11
+ multiplier = 1,
12
+ toAdd = baseAsset.currency.ZERO
13
+ ) => feeUnitPrice.to('Gwei').mul(multiplier).add(toAdd).toNumber(Gwei)
14
+
15
+ return {
16
+ recommended: calculateFeeUnitPrice(gasPrice),
17
+ min: calculateFeeUnitPrice(gasPrice, gasPriceMinimumRate),
18
+ max: calculateFeeUnitPrice(gasPrice, gasPriceMaximumRate),
19
+ }
20
+ },
21
+ unit: 'gwei/gas',
22
+ feeUnitPriceToNumber: (feeNumberUnit) => feeNumberUnit.toNumber(Gwei),
23
+ numberToFeeUnitPrice: (value) => new NumberUnit(value, Gwei),
24
+ isEnabled: ({ feeData }) => Boolean(feeData.rbfEnabled),
25
+ }
26
+ }