@exodus/ethereum-lib 5.17.2 → 5.18.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,26 @@
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
+ ## [5.18.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.17.3...@exodus/ethereum-lib@5.18.0) (2025-09-26)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat(ethereum): use methodId in new staking txs shape (#6335)
13
+
14
+
15
+
16
+ ## [5.17.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.17.2...@exodus/ethereum-lib@5.17.3) (2025-09-25)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+
22
+ * fix: removed contractAddress, keepTxInput and and resolve token amount when sending to a different contract (#6508)
23
+
24
+
25
+
6
26
  ## [5.17.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.17.1...@exodus/ethereum-lib@5.17.2) (2025-08-29)
7
27
 
8
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "5.17.2",
3
+ "version": "5.18.0",
4
4
  "description": "Ethereum utils, such as for cryptography, address encoding/decoding, transaction building, etc.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -50,5 +50,5 @@
50
50
  "type": "git",
51
51
  "url": "git+https://github.com/ExodusMovement/assets.git"
52
52
  },
53
- "gitHead": "6f48374a175ff7ccea7549806d9f6d574d2f8693"
53
+ "gitHead": "cf881908a1cff88e98d2f9a7a3f29357474e3d0c"
54
54
  }
@@ -1,3 +1,4 @@
1
+ import { isNumberUnit } from '@exodus/currency'
1
2
  import { FeeMarketEIP1559Transaction, Transaction } from '@exodus/ethereumjs/tx'
2
3
  import { bufferToInt } from '@exodus/ethereumjs/util'
3
4
  import lodash from 'lodash'
@@ -19,6 +20,7 @@ const getCommonTransactionProps = ({ transaction, baseAsset }) => {
19
20
 
20
21
  const parseBuffer = (asset, unsignedTx) => {
21
22
  const { transactionBuffer, chainId, ...legacyTxData } = unsignedTx.txData
23
+ const feeAsset = asset.feeAsset
22
24
  const baseAsset = asset.baseAsset
23
25
  assert(
24
26
  isEmpty(legacyTxData),
@@ -29,8 +31,8 @@ const parseBuffer = (asset, unsignedTx) => {
29
31
  const transaction = FeeMarketEIP1559Transaction.fromSerializedTx(transactionBuffer)
30
32
  return {
31
33
  ...getCommonTransactionProps({ transaction, baseAsset }),
32
- tipGasPrice: baseAsset.currency.baseUnit(transaction.maxPriorityFeePerGas),
33
- gasPrice: baseAsset.currency.baseUnit(transaction.maxFeePerGas),
34
+ tipGasPrice: feeAsset.currency.baseUnit(transaction.maxPriorityFeePerGas),
35
+ gasPrice: feeAsset.currency.baseUnit(transaction.maxFeePerGas),
34
36
  eip1559Enabled: true,
35
37
  }
36
38
  }
@@ -38,7 +40,7 @@ const parseBuffer = (asset, unsignedTx) => {
38
40
  const transaction = Transaction.fromSerializedTx(transactionBuffer)
39
41
  return {
40
42
  ...getCommonTransactionProps({ transaction, baseAsset }),
41
- gasPrice: baseAsset.currency.baseUnit(transaction.gasPrice),
43
+ gasPrice: feeAsset.currency.baseUnit(transaction.gasPrice),
42
44
  eip1559Enabled: false,
43
45
  }
44
46
  }
@@ -47,15 +49,20 @@ function resolveToAmount({ asset, data, value, to: rawTo }) {
47
49
  const _isToken = isToken(asset)
48
50
 
49
51
  if (_isToken) {
50
- const { method, values } = asset.contract.decodeInput(data)
51
- if (method === 'transfer' || method === 'approve') {
52
- return {
53
- to: values[0],
54
- amount: asset.currency.baseUnit(values[1]),
52
+ if (asset.assetId.toLowerCase() === rawTo.toLowerCase()) {
53
+ const { method, values } = asset.contract.decodeInput(data)
54
+ if (method === 'transfer' || method === 'approve') {
55
+ return {
56
+ to: values[0],
57
+ amount: asset.currency.baseUnit(values[1]),
58
+ }
55
59
  }
60
+
61
+ // it's not possible to resolve the amount when transfering a token to a special contract, e.g lifi
62
+ return { to: values[0], amount: asset.currency.ZERO }
56
63
  }
57
64
 
58
- return { to: values[0], amount: asset.currency.ZERO }
65
+ return { to: rawTo, amount: asset.currency.ZERO }
59
66
  }
60
67
 
61
68
  return {
@@ -64,9 +71,22 @@ function resolveToAmount({ asset, data, value, to: rawTo }) {
64
71
  }
65
72
  }
66
73
 
74
+ function toNumberUnit(asset, amount) {
75
+ if (isNumberUnit(amount)) {
76
+ return amount
77
+ }
78
+
79
+ if (typeof amount === 'string') {
80
+ return asset.currency.parse(amount)
81
+ }
82
+
83
+ throw new Error('Cannot parse type ' + typeof amount)
84
+ }
85
+
67
86
  export default function parseUnsignedTx({ asset, unsignedTx }) {
68
87
  assert(asset, 'asset is required')
69
88
  assert(unsignedTx, 'unsignedTx is required')
89
+ const feeAsset = asset.feeAsset
70
90
  const baseAsset = asset.baseAsset
71
91
  const txData = unsignedTx.txData
72
92
  const {
@@ -84,17 +104,26 @@ export default function parseUnsignedTx({ asset, unsignedTx }) {
84
104
  data: txData.data,
85
105
  to: txData.to,
86
106
  value: buffer2currency({ asset: baseAsset, value: txData.value }),
87
- gasPrice: buffer2currency({ asset: baseAsset, value: txData.gasPrice }),
107
+ gasPrice: buffer2currency({ asset: feeAsset, value: txData.gasPrice }),
88
108
  tipGasPrice: txData.tipGasPrice
89
- ? buffer2currency({ asset: baseAsset, value: txData.tipGasPrice })
109
+ ? buffer2currency({ asset: feeAsset, value: txData.tipGasPrice })
90
110
  : undefined,
91
111
  eip1559Enabled: Boolean(txData.tipGasPrice),
92
112
  gasLimit: bufferToInt(txData.gasLimit),
93
113
  nonce: bufferToInt(txData.nonce),
94
114
  }
95
115
 
96
- const fee = gasPrice.mul(gasLimit)
97
- const { to, amount } = resolveToAmount({ asset, data, value, to: rawTo })
116
+ const { to, amount: resolvedAmount } = resolveToAmount({ asset, data, value, to: rawTo })
117
+
118
+ // the txMeta.fee may include implicit l1 fees
119
+ const fee = unsignedTx.txMeta?.fee
120
+ ? toNumberUnit(feeAsset, unsignedTx.txMeta?.fee)
121
+ : gasPrice.mul(gasLimit)
122
+
123
+ // unsignedTx.txMeta.amount would be more accurate when using non erc20 contracts
124
+ const amount = unsignedTx.txMeta?.amount
125
+ ? toNumberUnit(asset, unsignedTx.txMeta.amount)
126
+ : resolvedAmount ?? asset.currency.ZERO
98
127
 
99
128
  return {
100
129
  to,
@@ -106,5 +135,6 @@ export default function parseUnsignedTx({ asset, unsignedTx }) {
106
135
  eip1559Enabled,
107
136
  nonce,
108
137
  from: null, // TODO: how?
138
+ data,
109
139
  }
110
140
  }