@exodus/ethereum-api 8.42.0 → 8.42.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 +8 -0
- package/package.json +2 -2
- package/src/allowance/index.js +60 -16
- package/src/create-asset.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.42.0...@exodus/ethereum-api@8.42.1) (2025-07-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @exodus/ethereum-api
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [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
15
|
|
|
8
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.42.
|
|
3
|
+
"version": "8.42.1",
|
|
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": "
|
|
66
|
+
"gitHead": "439848922f4e7a525c4e2373c99daefd89da402b"
|
|
67
67
|
}
|
package/src/allowance/index.js
CHANGED
|
@@ -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,38 @@ export const buildApproveTx = async ({
|
|
|
60
74
|
fromAddress,
|
|
61
75
|
})
|
|
62
76
|
|
|
63
|
-
return {
|
|
64
|
-
asset
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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,
|
|
72
|
-
gasLimit,
|
|
73
|
-
silent: true,
|
|
74
86
|
fromAddress,
|
|
75
|
-
|
|
87
|
+
eip1559Enabled: feeData.eip1559Enabled,
|
|
88
|
+
})
|
|
76
89
|
}
|
|
77
90
|
|
|
91
|
+
const getLegacyApproveTxFromUnsignedTx = ({ baseAsset, unsignedTx }) => ({
|
|
92
|
+
asset: baseAsset.name,
|
|
93
|
+
receiver: {
|
|
94
|
+
address: unsignedTx.txData.to,
|
|
95
|
+
amount: buffer2currency({ asset: baseAsset, value: unsignedTx.txData.value }),
|
|
96
|
+
},
|
|
97
|
+
txInput: unsignedTx.txData.data,
|
|
98
|
+
gasPrice: buffer2currency({ asset: baseAsset, value: unsignedTx.txData.gasPrice }),
|
|
99
|
+
tipGasPrice: unsignedTx.txData.tipGasPrice
|
|
100
|
+
? buffer2currency({ asset: baseAsset, value: unsignedTx.txData.tipGasPrice })
|
|
101
|
+
: undefined,
|
|
102
|
+
gasLimit: bufferToInt(unsignedTx.txData.gasLimit),
|
|
103
|
+
fromAddress: unsignedTx.txMeta.fromAddress,
|
|
104
|
+
})
|
|
105
|
+
|
|
78
106
|
// @deprecated use buildApproveTx instead
|
|
79
107
|
export const createApprove =
|
|
80
|
-
({ sendTx }) =>
|
|
108
|
+
({ assetClientInterface, sendTx }) =>
|
|
81
109
|
async ({
|
|
82
110
|
spenderAddress,
|
|
83
111
|
asset,
|
|
@@ -86,9 +114,11 @@ export const createApprove =
|
|
|
86
114
|
approveAmount,
|
|
87
115
|
gasLimit,
|
|
88
116
|
txInput,
|
|
117
|
+
nonce,
|
|
118
|
+
walletAccount,
|
|
89
119
|
...extras
|
|
90
120
|
}) => {
|
|
91
|
-
const
|
|
121
|
+
const unsignedTx = await buildApproveTx({
|
|
92
122
|
spenderAddress,
|
|
93
123
|
asset,
|
|
94
124
|
feeData,
|
|
@@ -96,14 +126,28 @@ export const createApprove =
|
|
|
96
126
|
approveAmount,
|
|
97
127
|
gasLimit,
|
|
98
128
|
txInput,
|
|
129
|
+
nonce,
|
|
130
|
+
walletAccount,
|
|
99
131
|
})
|
|
100
132
|
|
|
101
|
-
|
|
133
|
+
if (!assetClientInterface) {
|
|
134
|
+
const approveTx = getLegacyApproveTxFromUnsignedTx({ baseAsset: asset.baseAsset, unsignedTx })
|
|
135
|
+
const txData = await sendTx({ walletAccount, ...approveTx, silent: true, ...extras })
|
|
136
|
+
|
|
137
|
+
if (!txData || !txData.txId)
|
|
138
|
+
throw new Error(`Failed to approve ${asset.displayTicker} - ${spenderAddress}`)
|
|
102
139
|
|
|
103
|
-
|
|
104
|
-
|
|
140
|
+
return txData
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const { txId, rawTx } = await assetClientInterface.signTransaction({
|
|
144
|
+
assetName: asset.baseAsset.name,
|
|
145
|
+
unsignedTx,
|
|
146
|
+
walletAccount,
|
|
147
|
+
})
|
|
105
148
|
|
|
106
|
-
|
|
149
|
+
await asset.baseAsset.api.broadcastTx(rawTx.toString('hex'))
|
|
150
|
+
return { txId }
|
|
107
151
|
}
|
|
108
152
|
|
|
109
153
|
const createSendApprovalAndWatchConfirmation =
|
package/src/create-asset.js
CHANGED
|
@@ -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,
|