@exodus/ethereum-api 8.20.0 → 8.20.1
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,15 @@
|
|
|
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.20.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.20.0...@exodus/ethereum-api@8.20.1) (2024-10-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* remove unconfirmed receive from total balance on evm tokens ([#4338](https://github.com/ExodusMovement/assets/issues/4338)) ([eb5e9af](https://github.com/ExodusMovement/assets/commit/eb5e9afb0cf5b84da6d77d573c77a08a47852b94))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [8.20.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.19.1...@exodus/ethereum-api@8.20.0) (2024-10-09)
|
|
7
16
|
|
|
8
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.20.
|
|
3
|
+
"version": "8.20.1",
|
|
4
4
|
"description": "Ethereum Api",
|
|
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": "
|
|
67
|
+
"gitHead": "b170fd8817e953f92d4fe38e1686d9e7bdbd92ea"
|
|
68
68
|
}
|
package/src/gas-estimation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { currency2buffer, isEthereumLikeToken } from '@exodus/ethereum-lib'
|
|
2
|
-
import
|
|
2
|
+
import { bufferToHex, toBuffer } from '@exodus/ethereumjs-util'
|
|
3
3
|
import BN from 'bn.js'
|
|
4
4
|
|
|
5
5
|
import { estimateGas, isContractAddressCached } from './eth-like-util.js'
|
|
@@ -28,7 +28,7 @@ export async function estimateGasLimit(
|
|
|
28
28
|
from: fromAddress,
|
|
29
29
|
to: toAddress,
|
|
30
30
|
value: normalizeAmount(amount),
|
|
31
|
-
data: Buffer.isBuffer(data) ?
|
|
31
|
+
data: Buffer.isBuffer(data) ? bufferToHex(data) : data,
|
|
32
32
|
gasPrice: normalizeGasPrice(gasPrice),
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -41,9 +41,7 @@ export async function estimateGasLimit(
|
|
|
41
41
|
|
|
42
42
|
export function resolveDefaultTxInput({ asset, toAddress, amount }) {
|
|
43
43
|
return isEthereumLikeToken(asset)
|
|
44
|
-
?
|
|
45
|
-
asset.contract.transfer.build(toAddress.toLowerCase(), amount.toBaseString())
|
|
46
|
-
)
|
|
44
|
+
? bufferToHex(asset.contract.transfer.build(toAddress.toLowerCase(), amount.toBaseString()))
|
|
47
45
|
: '0x'
|
|
48
46
|
}
|
|
49
47
|
|
|
@@ -64,8 +62,7 @@ export async function fetchGasLimit({
|
|
|
64
62
|
|
|
65
63
|
const txInput = providedTxInput || resolveDefaultTxInput({ asset, toAddress, amount })
|
|
66
64
|
|
|
67
|
-
const defaultGasLimit = () =>
|
|
68
|
-
asset.gasLimit + GAS_PER_NON_ZERO_BYTE * ethUtil.toBuffer(txInput).length
|
|
65
|
+
const defaultGasLimit = () => asset.gasLimit + GAS_PER_NON_ZERO_BYTE * toBuffer(txInput).length
|
|
69
66
|
|
|
70
67
|
const isContract = await isContractAddressCached({ asset, address: toAddress })
|
|
71
68
|
|
|
@@ -90,7 +87,7 @@ export async function fetchGasLimit({
|
|
|
90
87
|
// calling forwarder contracts with a bumped gas limit causes 'Out Of Gas' error on chain
|
|
91
88
|
// Since geth v1.9.14 estimateGas will throw if user does not have enough ETH.
|
|
92
89
|
// If gasPrice is set to zero, estimateGas will make the expected estimation.
|
|
93
|
-
const gasPrice =
|
|
90
|
+
const gasPrice = bufferToHex(currency2buffer(asset.baseAsset.currency.ZERO))
|
|
94
91
|
|
|
95
92
|
try {
|
|
96
93
|
return await estimateGasLimit(
|
|
@@ -120,7 +117,7 @@ function normalizeAmount(amount) {
|
|
|
120
117
|
amount = currency2buffer(amount)
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
amount =
|
|
120
|
+
amount = bufferToHex(amount)
|
|
124
121
|
while (amount[2] === '0') amount = '0x' + amount.slice(3)
|
|
125
122
|
if (amount === '0x') amount = '0x0'
|
|
126
123
|
|
package/src/get-balances.js
CHANGED
|
@@ -77,7 +77,7 @@ export const getBalancesFactory = ({ monitorType, config = Object.create(null) }
|
|
|
77
77
|
// Balance from accountState is considered total b/c is fetched from rpc
|
|
78
78
|
if (useAccountStateBalanceOnly || isRpcBalanceAsset(asset) || monitorType === 'no-history') {
|
|
79
79
|
total = getBalanceFromAccountState({ asset, accountState }).sub(unconfirmedSent)
|
|
80
|
-
spendable = total.sub(staked).sub(unstaking).sub(unstaked)
|
|
80
|
+
spendable = total.sub(staked).sub(unstaking).sub(unstaked)
|
|
81
81
|
} else {
|
|
82
82
|
// Balance from txLog does not include staking rewards
|
|
83
83
|
// spendable and total are calculated differently based on staking txs
|
|
@@ -87,7 +87,7 @@ export const getBalancesFactory = ({ monitorType, config = Object.create(null) }
|
|
|
87
87
|
txLog,
|
|
88
88
|
unconfirmedReceived,
|
|
89
89
|
})
|
|
90
|
-
total = spendable.add(
|
|
90
|
+
total = spendable.add(staked).add(unstaking).add(unstaked)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContract, createEthereumJsTx } from '@exodus/ethereum-lib'
|
|
2
|
-
import
|
|
2
|
+
import { bufferToHex } from '@exodus/ethereumjs-util'
|
|
3
3
|
import assert from 'minimalistic-assert'
|
|
4
4
|
|
|
5
5
|
import { fromHexToBigInt } from '../number-utils.js'
|
|
@@ -13,7 +13,7 @@ export const estimateL1DataFeeFactory = ({ l1GasOracleAddress, server }) => {
|
|
|
13
13
|
const serialized = ethjsTx.serialize()
|
|
14
14
|
const callData = gasContract.getL1Fee.build(serialized)
|
|
15
15
|
const buffer = Buffer.from(callData)
|
|
16
|
-
const data =
|
|
16
|
+
const data = bufferToHex(buffer)
|
|
17
17
|
const hex = await server.ethCall({ to: l1GasOracleAddress, data }, 'latest')
|
|
18
18
|
const l1DataFee = fromHexToBigInt(hex)
|
|
19
19
|
const padFee = l1DataFee / BigInt(4)
|
|
@@ -7,8 +7,5 @@ export default function getFeeAmount(asset, serverTx) {
|
|
|
7
7
|
// genesis, coinbase, uncles
|
|
8
8
|
if (!gasPrice) return asset.currency.ZERO
|
|
9
9
|
|
|
10
|
-
return asset.currency
|
|
11
|
-
.baseUnit(gasUsed || gasLimit)
|
|
12
|
-
.mul(gasPrice)
|
|
13
|
-
.toDefault()
|
|
10
|
+
return asset.currency.baseUnit(gasUsed || gasLimit).mul(gasPrice)
|
|
14
11
|
}
|