@exodus/ethereum-api 7.5.1 → 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 +2 -2
- package/src/create-asset.js +9 -5
- package/src/get-balances.js +7 -2
- package/src/hooks/monitor.js +13 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.2",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"cross-fetch": "^3.1.5",
|
|
58
58
|
"delay": "4.0.1"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "8f0211c5cbdc7117872f2f910c9b31d7e4e106f0"
|
|
61
61
|
}
|
package/src/create-asset.js
CHANGED
|
@@ -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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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({
|
|
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
|
package/src/get-balances.js
CHANGED
|
@@ -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
|
|
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
|
package/src/hooks/monitor.js
CHANGED
|
@@ -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 =
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
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)
|