@exodus/ethereum-api 8.4.1 → 8.5.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 +18 -0
- package/package.json +3 -3
- package/src/create-asset.js +14 -15
- package/src/get-balances.js +8 -44
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.5.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.4.2...@exodus/ethereum-api@8.5.0) (2024-06-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* balance-utils for getBalances ([#2585](https://github.com/ExodusMovement/assets/issues/2585)) ([ee1aaa6](https://github.com/ExodusMovement/assets/commit/ee1aaa6c669bfdbbc6f3053167b678b98b5ef70d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [8.4.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.4.1...@exodus/ethereum-api@8.4.2) (2024-06-14)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **ethereum:** duplicate 'confirmationsNumber' argument in createAsset() ([#2569](https://github.com/ExodusMovement/assets/issues/2569)) ([7472fe5](https://github.com/ExodusMovement/assets/commit/7472fe5476839f879bad4fc82a9085d84d6868e9))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [8.4.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.4.0...@exodus/ethereum-api@8.4.1) (2024-06-13)
|
|
7
25
|
|
|
8
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.0",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:fix": "yarn lint --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@exodus/asset-lib": "^4.
|
|
23
|
+
"@exodus/asset-lib": "^4.2.0",
|
|
24
24
|
"@exodus/assets": "^9.1.1",
|
|
25
25
|
"@exodus/basic-utils": "^2.1.0",
|
|
26
26
|
"@exodus/bip44-constants": "^195.0.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"type": "git",
|
|
67
67
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "7f584775d566248fa9633086baee1064edbe8ef0"
|
|
70
70
|
}
|
package/src/create-asset.js
CHANGED
|
@@ -40,27 +40,26 @@ import { createWeb3API } from './web3'
|
|
|
40
40
|
import getFeeAsyncFactory from './get-fee-async'
|
|
41
41
|
|
|
42
42
|
export const createAssetFactory = ({
|
|
43
|
-
assetsList,
|
|
44
|
-
feeData,
|
|
45
43
|
AccountState: CustomAccountState,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
useEip1191ChainIdChecksum = false,
|
|
49
|
-
customTokens = true,
|
|
50
|
-
isTestnet = false,
|
|
51
|
-
isMaxFeeAsset = false,
|
|
52
|
-
erc20FuelBuffer,
|
|
53
|
-
fuelThreshold,
|
|
44
|
+
assetsList,
|
|
45
|
+
confirmationsNumber,
|
|
54
46
|
customBip44,
|
|
55
47
|
customCreateGetKeyIdentifier,
|
|
48
|
+
customTokens = true,
|
|
49
|
+
erc20FuelBuffer,
|
|
50
|
+
feeData,
|
|
56
51
|
feeMonitorInterval,
|
|
52
|
+
fuelThreshold,
|
|
53
|
+
isMaxFeeAsset = false,
|
|
54
|
+
isTestnet = false,
|
|
57
55
|
l1GasOracleAddress, // l1 extra fee for base and optostakingConfiguration = {},
|
|
58
|
-
|
|
59
|
-
confirmationsNumber,
|
|
56
|
+
monitorInterval,
|
|
60
57
|
monitorType = 'magnifier',
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
nfts = false,
|
|
59
|
+
serverUrl,
|
|
63
60
|
stakingConfiguration = {},
|
|
61
|
+
tokenType,
|
|
62
|
+
useEip1191ChainIdChecksum = false,
|
|
64
63
|
}) => {
|
|
65
64
|
assert(assetsList, 'assetsList is required')
|
|
66
65
|
assert(feeData, 'feeData is required')
|
|
@@ -216,7 +215,7 @@ export const createAssetFactory = ({
|
|
|
216
215
|
features,
|
|
217
216
|
getBalances,
|
|
218
217
|
getBalanceForAddress: createGetBalanceForAddress({ asset, server }),
|
|
219
|
-
getConfirmationsNumber: () =>
|
|
218
|
+
getConfirmationsNumber: () => confirmationsNumber,
|
|
220
219
|
getDefaultAddressPath: () => defaultAddressPath,
|
|
221
220
|
getFeeAsync: getFeeAsyncFactory({ assetClientInterface, gasLimit, createUnsignedTx }),
|
|
222
221
|
getFee,
|
package/src/get-balances.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { isRpcBalanceAsset } from '@exodus/ethereum-lib'
|
|
2
2
|
|
|
3
3
|
import { get } from 'lodash'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
asset.currency.ZERO
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const getBalanceFromTxLog = ({ txLog, asset }) => {
|
|
15
|
-
return txLog.size > 0 ? txLog.getMutations().slice(-1)[0].balance : asset.currency.ZERO
|
|
16
|
-
}
|
|
4
|
+
import {
|
|
5
|
+
getBalanceFromAccountState,
|
|
6
|
+
getBalanceFromTxLog,
|
|
7
|
+
getUnconfirmedReceivedBalance,
|
|
8
|
+
getUnconfirmedSentBalance,
|
|
9
|
+
} from '@exodus/asset-lib'
|
|
17
10
|
|
|
18
11
|
const getStaked = ({ accountState, asset }) => {
|
|
19
12
|
return get(accountState, ['staking', asset.name, 'delegatedBalance']) || asset.currency.ZERO
|
|
@@ -29,35 +22,6 @@ const getUnstaked = ({ accountState, asset }) => {
|
|
|
29
22
|
)
|
|
30
23
|
}
|
|
31
24
|
|
|
32
|
-
const getUnconfirmedSentBalanceFromTxLog = ({ asset, txLog }) => {
|
|
33
|
-
let result = asset.currency.ZERO
|
|
34
|
-
|
|
35
|
-
for (const tx of txLog) {
|
|
36
|
-
const isUnconfirmed = !tx.failed && tx.pending
|
|
37
|
-
|
|
38
|
-
if (isUnconfirmed && tx.sent) {
|
|
39
|
-
result = result.add(tx.coinAmount.abs())
|
|
40
|
-
if (tx.feeAmount && tx.coinAmount.unitType.equals(tx.feeAmount.unitType)) {
|
|
41
|
-
result = result.add(tx.feeAmount.abs())
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return result
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const getUnconfirmedReceivedBalanceFromTxLog = ({ asset, txLog }) => {
|
|
50
|
-
let result = asset.currency.ZERO
|
|
51
|
-
for (const tx of txLog) {
|
|
52
|
-
const isUnconfirmed = !tx.failed && tx.pending
|
|
53
|
-
if (isUnconfirmed && !tx.sent) {
|
|
54
|
-
result = result.add(tx.coinAmount.abs())
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return result
|
|
59
|
-
}
|
|
60
|
-
|
|
61
25
|
/**
|
|
62
26
|
* Api method to return the balance based on either account state balances or tx history.
|
|
63
27
|
*
|
|
@@ -67,8 +31,8 @@ const getUnconfirmedReceivedBalanceFromTxLog = ({ asset, txLog }) => {
|
|
|
67
31
|
* @returns {{balance}|null} an object with the balance or null if the balance is unknown
|
|
68
32
|
*/
|
|
69
33
|
export const getBalances = ({ asset, txLog, accountState }) => {
|
|
70
|
-
const unconfirmedReceived =
|
|
71
|
-
const unconfirmedSent =
|
|
34
|
+
const unconfirmedReceived = getUnconfirmedReceivedBalance({ asset, txLog })
|
|
35
|
+
const unconfirmedSent = getUnconfirmedSentBalance({ asset, txLog })
|
|
72
36
|
|
|
73
37
|
// balance from txLog / rpc is considered to be total
|
|
74
38
|
const balanceWithoutUnconfirmedSent = isRpcBalanceAsset(asset)
|