@exodus/ethereum-api 7.5.0 → 7.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "7.5.0",
3
+ "version": "7.5.2",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -25,7 +25,7 @@
25
25
  "@exodus/bip44-constants": "^195.0.0",
26
26
  "@exodus/crypto": "^1.0.0-rc.0",
27
27
  "@exodus/currency": "^2.1.3",
28
- "@exodus/ethereum-lib": "^4.2.7",
28
+ "@exodus/ethereum-lib": "^4.8.1",
29
29
  "@exodus/ethereum-meta": "^1.2.0",
30
30
  "@exodus/ethereumholesky-meta": "^1.0.1",
31
31
  "@exodus/ethereumjs-util": "^7.1.0-exodus.7",
@@ -57,5 +57,5 @@
57
57
  "cross-fetch": "^3.1.5",
58
58
  "delay": "4.0.1"
59
59
  },
60
- "gitHead": "8066c2fd98a9065156d93108e42aa01f40aecf57"
60
+ "gitHead": "8f0211c5cbdc7117872f2f910c9b31d7e4e106f0"
61
61
  }
@@ -158,10 +158,10 @@ export const createAssetFactory = ({
158
158
  throw new Error(`Monitor type ${monitorType} of evm asset ${asset.name} is unknown`)
159
159
  }
160
160
 
161
- if (supportsStaking) {
162
- const afterTickHook = createEthereumHooks({ assetClientInterface })['after-tick']
163
- monitor.addHook('after-tick', afterTickHook)
164
- }
161
+ // always run hooks that modify staking txs to have consistent balances
162
+ // revisit later to only run this hook ONLY if supportsStaking = true
163
+ const afterTickHook = createEthereumHooks({ assetClientInterface })['after-tick']
164
+ monitor.addHook('after-tick', afterTickHook)
165
165
 
166
166
  return monitor
167
167
  }
@@ -196,7 +196,11 @@ export const createAssetFactory = ({
196
196
  getDefaultAddressPath: () => defaultAddressPath,
197
197
  getFee,
198
198
  getFeeData: () => feeData,
199
- getKeyIdentifier: createGetKeyIdentifier({ bip44, allowMetaMaskCompat }),
199
+ getKeyIdentifier: createGetKeyIdentifier({
200
+ bip44,
201
+ allowMetaMaskCompat,
202
+ assetName: asset.name,
203
+ }),
200
204
  getSupportedPurposes: () => [44],
201
205
  getTokens,
202
206
  hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
@@ -70,15 +70,20 @@ export const getBalances = ({ asset, txLog, accountState }) => {
70
70
  const unconfirmedReceived = getUnconfirmedReceivedBalanceFromTxLog({ asset, txLog })
71
71
  const unconfirmedSent = getUnconfirmedSentBalanceFromTxLog({ asset, txLog })
72
72
 
73
+ // balance from txLog / rpc is considered to be total
73
74
  const balanceWithoutUnconfirmedSent = isRpcBalanceAsset(asset)
74
75
  ? getBalanceFromAccountState({ asset, accountState }).sub(unconfirmedSent)
75
76
  : getBalanceFromTxLog({ txLog, asset })
76
77
 
77
- const spendable = balanceWithoutUnconfirmedSent.sub(unconfirmedReceived)
78
78
  const staked = getStaked({ asset, accountState })
79
79
  const unstaking = getUnstaking({ asset, accountState })
80
80
  const unstaked = getUnstaked({ asset, accountState })
81
- const total = balanceWithoutUnconfirmedSent.add(staked).add(unstaking).add(unstaked)
81
+ const total = balanceWithoutUnconfirmedSent
82
+ const spendable = balanceWithoutUnconfirmedSent
83
+ .sub(unconfirmedReceived)
84
+ .sub(staked)
85
+ .sub(unstaking)
86
+ .sub(unstaked)
82
87
 
83
88
  return {
84
89
  // new
@@ -10,6 +10,10 @@ export const createEthereumHooks = ({ assetClientInterface }) => {
10
10
  baseAssetName: 'ethereum',
11
11
  })
12
12
 
13
+ // polygon on ETH is not supported in ME
14
+ // TODO: remove this once this hook only runs for wallets that support staking
15
+ const isPolygonSupported = !!polygon
16
+
13
17
  const assetName = ethereum.name
14
18
 
15
19
  const userAddress = await assetClientInterface.getReceiveAddress({
@@ -23,10 +27,12 @@ export const createEthereumHooks = ({ assetClientInterface }) => {
23
27
  asset: ethereum,
24
28
  })
25
29
 
26
- const polygonStakingInfo = await getPolygonStakingInfo({
27
- address: userAddress.toString(),
28
- asset: polygon,
29
- })
30
+ const polygonStakingInfo = isPolygonSupported
31
+ ? await getPolygonStakingInfo({
32
+ address: userAddress.toString(),
33
+ asset: polygon,
34
+ })
35
+ : {}
30
36
 
31
37
  const stakingInfo = {
32
38
  staking: {
@@ -75,7 +81,9 @@ export const createEthereumHooks = ({ assetClientInterface }) => {
75
81
  }
76
82
 
77
83
  processTxLogsPromises.push(
78
- processTxLog({ asset: polygon, assetClientInterface, walletAccount, batch }),
84
+ ...(isPolygonSupported
85
+ ? [processTxLog({ asset: polygon, assetClientInterface, walletAccount, batch })]
86
+ : []),
79
87
  processTxLog({ asset: ethereum, assetClientInterface, walletAccount, batch })
80
88
  )
81
89
  await Promise.all(processTxLogsPromises)
@@ -32,7 +32,6 @@ const txSendFactory = ({ assetClientInterface }) => {
32
32
  const baseAsset = asset.baseAsset
33
33
  const feeOpts = { ...feeOpts_ }
34
34
  const assets = await assetClientInterface.getAssetsForNetwork({ baseAssetName: baseAsset.name })
35
- let eip1559Enabled = baseAsset.name === 'ethereum' // TODO: temp override, clean up use of eip1559Enabled flag and default to always true
36
35
 
37
36
  // Using a default zero value to not break code relying on the `tx.feeAmount` property.
38
37
  // For example, some exchange providers don't supply this.
@@ -47,6 +46,12 @@ const txSendFactory = ({ assetClientInterface }) => {
47
46
 
48
47
  let nonceParam = _nonce
49
48
 
49
+ const feeData = await assetClientInterface.getFeeData({
50
+ assetName: baseAsset.name,
51
+ })
52
+
53
+ let eip1559Enabled = feeData.eip1559Enabled
54
+
50
55
  // `replacedTx` is always an ETH/ETC transaction (not a token)
51
56
  let replacedTx, replacedTokenTx
52
57
  if (bumpTxId) {
@@ -74,19 +79,17 @@ const txSendFactory = ({ assetClientInterface }) => {
74
79
  address = (replacedTokenTx || replacedTx).to
75
80
  amount = (replacedTokenTx || replacedTx).coinAmount.negate()
76
81
  feeOpts.gasLimit = replacedTx.data.gasLimit
77
- const { gasPrice: currentGasPrice, eip1559Enabled: _eip1559Enabled } =
78
- await assetClientInterface.getFeeData({
79
- assetName,
80
- })
82
+
83
+ const { gasPrice: currentGasPrice } = feeData
81
84
  const { bumpedGasPrice, bumpedTipGasPrice } = calculateBumpedGasPrice({
82
85
  baseAsset,
83
86
  tx: replacedTx,
84
87
  currentGasPrice,
85
- eip1559Enabled: _eip1559Enabled,
88
+ eip1559Enabled,
86
89
  })
87
90
  feeOpts.gasPrice = bumpedGasPrice
88
91
  feeOpts.tipGasPrice = bumpedTipGasPrice
89
- eip1559Enabled = _eip1559Enabled && feeOpts.tipGasPrice
92
+ eip1559Enabled = feeData.eip1559Enabled && feeOpts.tipGasPrice
90
93
  nonceParam = replacedTx.data.nonce
91
94
  txInput = replacedTokenTx ? null : replacedTx.data.data || '0x'
92
95
  feeAmount = feeOpts.gasPrice.mul(feeOpts.gasLimit)