@exodus/ethereum-api 8.42.0 → 8.42.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/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.42.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.42.1...@exodus/ethereum-api@8.42.2) (2025-07-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: use explicit events dep import in ethereum-api (#6052)
13
+
14
+
15
+
16
+ ## [8.42.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.42.0...@exodus/ethereum-api@8.42.1) (2025-07-11)
17
+
18
+ **Note:** Version bump only for package @exodus/ethereum-api
19
+
20
+
21
+
22
+
23
+
6
24
  ## [8.42.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.41.0...@exodus/ethereum-api@8.42.0) (2025-07-10)
7
25
 
8
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.42.0",
3
+ "version": "8.42.2",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -63,5 +63,5 @@
63
63
  "type": "git",
64
64
  "url": "git+https://github.com/ExodusMovement/assets.git"
65
65
  },
66
- "gitHead": "6bd56e57bee720ffef602f57421eae67e42e190c"
66
+ "gitHead": "b719d7ad24ba1be671d286e2859afc22ab3b7255"
67
67
  }
@@ -1,4 +1,6 @@
1
1
  import { isNumberUnit } from '@exodus/currency'
2
+ import { buffer2currency, createUnsignedTxFactory } from '@exodus/ethereum-lib'
3
+ import { bufferToInt } from '@exodus/ethereumjs/util'
2
4
  import assert from 'minimalistic-assert'
3
5
 
4
6
  import { getServer } from '../exodus-eth-server/index.js'
@@ -38,17 +40,29 @@ export const buildApproveTx = async ({
38
40
  approveAmount = asset.currency.ZERO,
39
41
  gasLimit,
40
42
  txInput,
43
+ nonce,
44
+ walletAccount,
41
45
  }) => {
42
46
  assert(asset, 'expected asset')
43
47
  assert(feeData, 'expected feeData')
44
48
  assert(isNumberUnit(approveAmount), 'expected approveAmount')
45
49
  assert(typeof spenderAddress === 'string', 'expected spenderAddress')
50
+ assert(walletAccount, 'expected walletAccount')
51
+
52
+ const { baseAsset } = asset
53
+ const chainId = baseAsset.chainId
54
+ assert(typeof chainId === 'number', 'expected chainId')
55
+
56
+ const createUnsignedTx = createUnsignedTxFactory({ chainId })
46
57
 
47
- const baseAsset = asset.baseAsset
48
58
  const toAddress = asset.contract.address
59
+ assert(typeof toAddress === 'string', 'expected contract address')
49
60
 
50
61
  if (!txInput) txInput = asset.contract.approve.build(spenderAddress, approveAmount.toBaseString())
51
62
 
63
+ if (typeof nonce !== 'number')
64
+ nonce = await baseAsset.getNonce({ asset, fromAddress, walletAccount })
65
+
52
66
  if (!gasLimit)
53
67
  gasLimit = await fetchGasLimit({
54
68
  asset: baseAsset,
@@ -60,24 +74,67 @@ export const buildApproveTx = async ({
60
74
  fromAddress,
61
75
  })
62
76
 
63
- return {
64
- asset: baseAsset.name,
65
- receiver: {
66
- address: toAddress,
67
- amount: baseAsset.currency.ZERO,
68
- },
77
+ return createUnsignedTx({
78
+ asset,
79
+ address: toAddress,
80
+ amount: baseAsset.currency.ZERO,
81
+ nonce,
69
82
  txInput,
83
+ gasLimit,
70
84
  gasPrice: feeData.gasPrice,
71
85
  tipGasPrice: feeData.tipGasPrice,
86
+ fromAddress,
87
+ eip1559Enabled: feeData.eip1559Enabled,
88
+ })
89
+ }
90
+
91
+ // @temporary
92
+ // @deprecated use buildApproveTx instead
93
+ export const buildLegacyApproveTx = async ({
94
+ spenderAddress,
95
+ asset,
96
+ feeData,
97
+ fromAddress,
98
+ approveAmount,
99
+ gasLimit,
100
+ txInput,
101
+ nonce,
102
+ walletAccount,
103
+ }) => {
104
+ const unsignedTx = await buildApproveTx({
105
+ spenderAddress,
106
+ asset,
107
+ feeData,
108
+ fromAddress,
109
+ approveAmount,
72
110
  gasLimit,
111
+ txInput,
112
+ nonce,
113
+ walletAccount,
114
+ })
115
+
116
+ const baseAsset = asset.baseAsset
117
+
118
+ return {
119
+ asset: baseAsset.name,
120
+ receiver: {
121
+ address: unsignedTx.txData.to,
122
+ amount: buffer2currency({ asset: baseAsset, value: unsignedTx.txData.value }),
123
+ },
124
+ txInput: unsignedTx.txData.data,
125
+ gasPrice: buffer2currency({ asset: baseAsset, value: unsignedTx.txData.gasPrice }),
126
+ tipGasPrice: unsignedTx.txData.tipGasPrice
127
+ ? buffer2currency({ asset: baseAsset, value: unsignedTx.txData.tipGasPrice })
128
+ : undefined,
129
+ gasLimit: bufferToInt(unsignedTx.txData.gasLimit),
130
+ fromAddress: unsignedTx.txMeta.fromAddress,
73
131
  silent: true,
74
- fromAddress,
75
132
  }
76
133
  }
77
134
 
78
135
  // @deprecated use buildApproveTx instead
79
136
  export const createApprove =
80
- ({ sendTx }) =>
137
+ ({ assetClientInterface, sendTx }) =>
81
138
  async ({
82
139
  spenderAddress,
83
140
  asset,
@@ -86,9 +143,32 @@ export const createApprove =
86
143
  approveAmount,
87
144
  gasLimit,
88
145
  txInput,
146
+ nonce,
147
+ walletAccount,
89
148
  ...extras
90
149
  }) => {
91
- const approveTx = await buildApproveTx({
150
+ if (!assetClientInterface) {
151
+ const approveTx = await buildLegacyApproveTx({
152
+ spenderAddress,
153
+ asset,
154
+ feeData,
155
+ fromAddress,
156
+ approveAmount,
157
+ gasLimit,
158
+ txInput,
159
+ nonce,
160
+ walletAccount,
161
+ })
162
+
163
+ const txData = await sendTx({ walletAccount, ...approveTx, ...extras })
164
+
165
+ if (!txData || !txData.txId)
166
+ throw new Error(`Failed to approve ${asset.displayTicker} - ${spenderAddress}`)
167
+
168
+ return txData
169
+ }
170
+
171
+ const unsignedTx = await buildApproveTx({
92
172
  spenderAddress,
93
173
  asset,
94
174
  feeData,
@@ -96,14 +176,18 @@ export const createApprove =
96
176
  approveAmount,
97
177
  gasLimit,
98
178
  txInput,
179
+ nonce,
180
+ walletAccount,
99
181
  })
100
182
 
101
- const txData = await sendTx({ ...extras, ...approveTx })
102
-
103
- if (!txData || !txData.txId)
104
- throw new Error(`Failed to approve ${asset.displayTicker} - ${spenderAddress}`)
183
+ const { txId, rawTx } = await assetClientInterface.signTransaction({
184
+ assetName: asset.baseAsset.name,
185
+ unsignedTx,
186
+ walletAccount,
187
+ })
105
188
 
106
- return txData
189
+ await asset.baseAsset.api.broadcastTx(rawTx.toString('hex'))
190
+ return { txId }
107
191
  }
108
192
 
109
193
  const createSendApprovalAndWatchConfirmation =
@@ -1,5 +1,4 @@
1
1
  import { connectAssetsList } from '@exodus/assets'
2
- import { pick } from '@exodus/basic-utils'
3
2
  import bip44Constants from '@exodus/bip44-constants/by-ticker.js'
4
3
  import {
5
4
  createEthereumLikeAccountState,
@@ -283,7 +282,6 @@ export const createAssetFactory = ({
283
282
 
284
283
  const fullAsset = {
285
284
  ...asset,
286
- ...pick(config, ['accountReserve']),
287
285
  gasLimit,
288
286
  contractGasLimit,
289
287
  bip44,
@@ -1,6 +1,6 @@
1
1
  import { bufferToHex } from '@exodus/ethereumjs/util'
2
2
  import SolidityContract from '@exodus/solidity-contract'
3
- import EventEmitter from 'events'
3
+ import EventEmitter from 'events/events.js'
4
4
  import lodash from 'lodash'
5
5
 
6
6
  import { fromHexToString } from '../number-utils.js'
@@ -1,6 +1,6 @@
1
1
  import { bufferToHex } from '@exodus/ethereumjs/util'
2
2
  import SolidityContract from '@exodus/solidity-contract'
3
- import EventEmitter from 'events'
3
+ import EventEmitter from 'events/events.js'
4
4
  import io from 'socket.io-client'
5
5
 
6
6
  import { fromHexToString } from '../number-utils.js'
package/src/index.js CHANGED
@@ -62,6 +62,7 @@ export {
62
62
  getSpendingAllowance,
63
63
  isSpendingApprovalRequired,
64
64
  buildApproveTx,
65
+ buildLegacyApproveTx,
65
66
  createApprove,
66
67
  createApproveSpendingTokens,
67
68
  APPROVAL_GAS_LIMIT,