@exodus/ethereum-api 8.16.0 → 8.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 +19 -0
- package/package.json +18 -17
- package/src/allowance/index.js +4 -4
- package/src/create-asset-plugin-factory.js +1 -1
- package/src/create-asset.js +19 -17
- package/src/create-token-factory.js +6 -2
- package/src/ens/index.js +6 -3
- package/src/eth-like-util.js +3 -3
- package/src/etherscan/account.js +1 -1
- package/src/etherscan/index.js +5 -5
- package/src/etherscan/logs.js +1 -1
- package/src/etherscan/proxy.js +1 -1
- package/src/etherscan/ws.js +2 -2
- package/src/exodus-eth-server/api-coin-nodes.js +4 -2
- package/src/exodus-eth-server/api.js +2 -2
- package/src/exodus-eth-server/clarity-v2.js +26 -1
- package/src/exodus-eth-server/clarity.js +1 -1
- package/src/exodus-eth-server/index.js +4 -4
- package/src/exodus-eth-server/ws.js +2 -2
- package/src/gas-estimation.js +1 -1
- package/src/get-balances.js +3 -1
- package/src/get-fee-async.js +4 -4
- package/src/hooks/index.js +1 -1
- package/src/hooks/monitor.js +2 -2
- package/src/index.js +14 -14
- package/src/nft-utils.js +2 -2
- package/src/optimism-gas/index.js +1 -1
- package/src/server-based-fee-monitor.js +1 -1
- package/src/simulate-tx/index.js +2 -2
- package/src/simulate-tx/simulate-eth-tx.js +2 -2
- package/src/staking/api/index.js +34 -0
- package/src/staking/ethereum/api.js +1 -1
- package/src/staking/ethereum/index.js +3 -3
- package/src/staking/ethereum/service.js +130 -86
- package/src/staking/ethereum/staking-utils.js +1 -1
- package/src/staking/index.js +4 -4
- package/src/staking/matic/api.js +1 -1
- package/src/staking/matic/index.js +3 -3
- package/src/staking/matic/matic-staking-utils.js +1 -1
- package/src/staking/matic/service.js +4 -4
- package/src/tx-log/clarity-monitor.js +10 -4
- package/src/tx-log/clarity-utils/get-log-items-from-server-tx.js +7 -7
- package/src/tx-log/clarity-utils/get-names-of-tokens-transferred-by-server-tx.js +1 -1
- package/src/tx-log/clarity-utils/index.js +3 -3
- package/src/tx-log/ethereum-monitor.js +6 -4
- package/src/tx-log/ethereum-no-history-monitor.js +6 -4
- package/src/tx-log/index.js +3 -3
- package/src/tx-log/monitor-utils/check-pending-transactions.js +2 -2
- package/src/tx-log/monitor-utils/get-derive-transactions-to-check.js +1 -1
- package/src/tx-log/monitor-utils/get-history-from-server.js +1 -1
- package/src/tx-log/monitor-utils/get-log-items-from-server-tx.js +6 -6
- package/src/tx-log/monitor-utils/get-names-of-tokens-transferred-by-server-tx.js +1 -1
- package/src/tx-log/monitor-utils/index.js +7 -7
- package/src/tx-log-staking-processor/asset-staking-tx-data.js +6 -2
- package/src/tx-log-staking-processor/index.js +1 -1
- package/src/tx-log-staking-processor/utils.js +1 -1
- package/src/tx-send/get-fee-info.js +1 -1
- package/src/tx-send/index.js +2 -2
- package/src/tx-send/tx-send.js +4 -4
- package/src/web3/index.js +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isNumberUnit } from '@exodus/currency'
|
|
2
2
|
|
|
3
|
-
import { getServer } from '../../exodus-eth-server'
|
|
4
|
-
import { estimateGasLimit } from '../../gas-estimation'
|
|
5
|
-
import { fromHexToBigInt } from '../../number-utils'
|
|
6
|
-
import { stakingProviderClientFactory } from '../staking-provider-client'
|
|
7
|
-
import { EthereumStaking } from './api'
|
|
3
|
+
import { getServer } from '../../exodus-eth-server/index.js'
|
|
4
|
+
import { estimateGasLimit } from '../../gas-estimation.js'
|
|
5
|
+
import { fromHexToBigInt } from '../../number-utils.js'
|
|
6
|
+
import { stakingProviderClientFactory } from '../staking-provider-client.js'
|
|
7
|
+
import { EthereumStaking } from './api.js'
|
|
8
8
|
|
|
9
9
|
const extraGasLimit = 20_000 // extra gas Limit to prevent tx failing if something change on pool state (till tx is in mempool)
|
|
10
10
|
|
|
@@ -15,12 +15,13 @@ export function createEthereumStakingService({
|
|
|
15
15
|
}) {
|
|
16
16
|
const staking = new EthereumStaking(asset)
|
|
17
17
|
const stakingProvider = stakingProviderClientFactory()
|
|
18
|
+
const minAmount = staking.minAmount
|
|
18
19
|
|
|
19
20
|
function amountToCurrency({ asset, amount }) {
|
|
20
21
|
return isNumberUnit(amount) ? amount : asset.currency.parse(amount)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
async function delegate({ walletAccount, amount } =
|
|
24
|
+
async function delegate({ walletAccount, amount } = Object.create(null)) {
|
|
24
25
|
const address = await assetClientInterface.getReceiveAddress({
|
|
25
26
|
assetName: asset.name,
|
|
26
27
|
walletAccount,
|
|
@@ -62,95 +63,149 @@ export function createEthereumStakingService({
|
|
|
62
63
|
return txId
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
async function
|
|
66
|
+
async function getUndelegatePendingData({
|
|
67
|
+
delegatorAddress,
|
|
68
|
+
resquestedAmount,
|
|
69
|
+
pendingAmount,
|
|
70
|
+
minAmount,
|
|
71
|
+
}) {
|
|
72
|
+
const leftOver = pendingAmount.sub(resquestedAmount)
|
|
73
|
+
|
|
74
|
+
if (leftOver.isPositive && leftOver.lt(minAmount)) {
|
|
75
|
+
throw new Error(`Pending balance less than min stake amount ${minAmount}`)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const inactiveAmountToUnstake = pendingAmount.lte(resquestedAmount)
|
|
79
|
+
? pendingAmount
|
|
80
|
+
: resquestedAmount
|
|
81
|
+
const { to, data } = await staking.unstakePending({
|
|
82
|
+
address: delegatorAddress,
|
|
83
|
+
amount: inactiveAmountToUnstake,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
let feeData
|
|
87
|
+
try {
|
|
88
|
+
// could revert and break the whole fee calculation
|
|
89
|
+
feeData = await estimateTxFee(delegatorAddress, to, null, data)
|
|
90
|
+
} catch {
|
|
91
|
+
console.warn('ETH unstake pending estimation reverted')
|
|
92
|
+
return Object.create(null)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { to, txData: data, ...feeData }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function getUndelegateData({ delegatorAddress, resquestedAmount, pendingAmount }) {
|
|
99
|
+
const canUnstake = resquestedAmount.gt(pendingAmount)
|
|
100
|
+
|
|
101
|
+
if (!canUnstake) return Object.create(null)
|
|
102
|
+
|
|
103
|
+
const activeAmountToUnstake = resquestedAmount.sub(pendingAmount)
|
|
104
|
+
const { to, data } = await staking.unstake({
|
|
105
|
+
address: delegatorAddress,
|
|
106
|
+
amount: activeAmountToUnstake,
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const feeData = await estimateTxFee(delegatorAddress, to, null, data)
|
|
110
|
+
|
|
111
|
+
return { to, txData: data, ...feeData }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Unstaking may involve 2 txs; unstaking from pending and unstaking from validator.
|
|
116
|
+
* Fee estimation depends on the executed txs. Can be both.
|
|
117
|
+
* @returns total undelegete fee
|
|
118
|
+
*/
|
|
119
|
+
async function estimateUndelegate({ walletAccount, amount: resquestedAmount }) {
|
|
120
|
+
const address = await assetClientInterface.getReceiveAddress({
|
|
121
|
+
assetName: asset.name,
|
|
122
|
+
walletAccount,
|
|
123
|
+
})
|
|
124
|
+
const delegatorAddress = address.toLowerCase()
|
|
125
|
+
const pendingAmount = await staking.pendingBalanceOf(delegatorAddress)
|
|
126
|
+
|
|
127
|
+
const { fee: undelegatePendingFee = asset.currency.ZERO } = await getUndelegatePendingData({
|
|
128
|
+
delegatorAddress,
|
|
129
|
+
resquestedAmount,
|
|
130
|
+
pendingAmount,
|
|
131
|
+
minAmount,
|
|
132
|
+
})
|
|
133
|
+
const { fee: undelegateFee = asset.currency.ZERO } = await getUndelegateData({
|
|
134
|
+
delegatorAddress,
|
|
135
|
+
resquestedAmount,
|
|
136
|
+
pendingAmount,
|
|
137
|
+
minAmount,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
return undelegatePendingFee.add(undelegateFee)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function undelegate({ walletAccount, amount } = Object.create(null)) {
|
|
66
144
|
/*
|
|
67
145
|
unstakePending balance (not yet in validator) + unstake balance (in validator)
|
|
68
146
|
1. give priority to unstakePending (based on the amount)
|
|
69
147
|
2. unstake amount in validator.
|
|
70
148
|
*/
|
|
71
|
-
|
|
149
|
+
const resquestedAmount = amountToCurrency({ asset, amount })
|
|
72
150
|
|
|
73
151
|
const address = await assetClientInterface.getReceiveAddress({
|
|
74
152
|
assetName: asset.name,
|
|
75
153
|
walletAccount,
|
|
76
154
|
})
|
|
77
155
|
const delegatorAddress = address.toLowerCase()
|
|
78
|
-
|
|
79
156
|
const pendingAmount = await staking.pendingBalanceOf(delegatorAddress)
|
|
80
157
|
|
|
81
158
|
console.log(
|
|
82
|
-
`delegator address ${delegatorAddress} unstaking ${
|
|
159
|
+
`delegator address ${delegatorAddress} unstaking ${resquestedAmount.toDefaultString({
|
|
83
160
|
unit: true,
|
|
84
161
|
})} - pending amount: ${pendingAmount.toDefaultString({ unit: true })}`
|
|
85
162
|
)
|
|
86
163
|
|
|
87
164
|
let txId
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
throw new Error(`Pending balance less than min stake amount ${minStake}`)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const { to, data } = await staking.unstakePending({
|
|
99
|
-
address: delegatorAddress,
|
|
100
|
-
amount: inactiveAmountToUnstake,
|
|
165
|
+
if (pendingAmount.isPositive) {
|
|
166
|
+
const undelegatePendingData = await getUndelegatePendingData({
|
|
167
|
+
delegatorAddress,
|
|
168
|
+
resquestedAmount,
|
|
169
|
+
pendingAmount,
|
|
170
|
+
minAmount,
|
|
101
171
|
})
|
|
102
172
|
|
|
103
|
-
const { gasPrice, gasLimit, fee } = await estimateTxFee(
|
|
104
|
-
delegatorAddress.toLowerCase(),
|
|
105
|
-
to,
|
|
106
|
-
null,
|
|
107
|
-
data
|
|
108
|
-
)
|
|
109
173
|
txId = await prepareAndSendTx({
|
|
110
174
|
asset,
|
|
111
175
|
walletAccount,
|
|
112
|
-
|
|
113
|
-
txData: data,
|
|
114
|
-
gasPrice,
|
|
115
|
-
gasLimit,
|
|
116
|
-
fee,
|
|
176
|
+
...undelegatePendingData,
|
|
117
177
|
})
|
|
118
178
|
}
|
|
119
179
|
|
|
120
|
-
// need also to unstake
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
})
|
|
180
|
+
// may need also to unstake
|
|
181
|
+
const undelegateData = await getUndelegateData({
|
|
182
|
+
delegatorAddress,
|
|
183
|
+
resquestedAmount,
|
|
184
|
+
pendingAmount,
|
|
185
|
+
})
|
|
127
186
|
|
|
128
|
-
|
|
129
|
-
txId = await prepareAndSendTx({
|
|
130
|
-
asset,
|
|
131
|
-
walletAccount,
|
|
132
|
-
to,
|
|
133
|
-
txData: data,
|
|
134
|
-
gasPrice,
|
|
135
|
-
gasLimit,
|
|
136
|
-
fee,
|
|
137
|
-
})
|
|
138
|
-
}
|
|
187
|
+
if (!undelegateData) return txId
|
|
139
188
|
|
|
140
|
-
|
|
189
|
+
txId = await prepareAndSendTx({
|
|
190
|
+
asset,
|
|
191
|
+
walletAccount,
|
|
192
|
+
...undelegateData,
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
// Testnet assets do not support delegations tracking
|
|
141
196
|
if (asset.name === 'ethereum')
|
|
142
197
|
await stakingProvider.notifyUnstaking({
|
|
143
198
|
txId,
|
|
144
199
|
asset: asset.name,
|
|
145
200
|
delegator: delegatorAddress,
|
|
146
|
-
amount:
|
|
201
|
+
amount: resquestedAmount.toBaseString(),
|
|
147
202
|
})
|
|
148
203
|
|
|
149
204
|
return txId
|
|
150
205
|
}
|
|
151
206
|
|
|
152
|
-
async function claimUndelegatedBalance({ walletAccount } =
|
|
153
|
-
//
|
|
207
|
+
async function claimUndelegatedBalance({ walletAccount } = Object.create(null)) {
|
|
208
|
+
// claim withdrawable balance (of a previous unstake)
|
|
154
209
|
const address = await assetClientInterface.getReceiveAddress({
|
|
155
210
|
assetName: asset.name,
|
|
156
211
|
walletAccount,
|
|
@@ -173,11 +228,17 @@ export function createEthereumStakingService({
|
|
|
173
228
|
fee,
|
|
174
229
|
})
|
|
175
230
|
}
|
|
176
|
-
|
|
177
|
-
return null // -> no withdrawable balance
|
|
178
231
|
}
|
|
179
232
|
|
|
180
233
|
async function estimateDelegateOperation({ walletAccount, operation, args }) {
|
|
234
|
+
const requestedAmount = args.amount
|
|
235
|
+
? amountToCurrency({ asset, amount: args.amount })
|
|
236
|
+
: asset.currency.ZERO
|
|
237
|
+
|
|
238
|
+
if (operation === 'undelegate') {
|
|
239
|
+
return estimateUndelegate({ walletAccount, amount: requestedAmount })
|
|
240
|
+
}
|
|
241
|
+
|
|
181
242
|
const address = await assetClientInterface.getReceiveAddress({
|
|
182
243
|
assetName: asset.name,
|
|
183
244
|
walletAccount,
|
|
@@ -189,30 +250,18 @@ export function createEthereumStakingService({
|
|
|
189
250
|
undelegate: 'unstake',
|
|
190
251
|
claimUndelegatedBalance: 'claimWithdrawRequest',
|
|
191
252
|
}
|
|
253
|
+
|
|
192
254
|
const delegateOperation = staking[NAMING_MAP[operation]].bind(staking)
|
|
193
255
|
|
|
194
256
|
if (!delegateOperation) {
|
|
195
|
-
|
|
257
|
+
throw new Error('Invalid staking operation')
|
|
196
258
|
}
|
|
197
259
|
|
|
198
|
-
|
|
199
|
-
|
|
260
|
+
const { amount, data } = await delegateOperation({ ...args, amount: requestedAmount })
|
|
261
|
+
const toAddress =
|
|
262
|
+
operation === 'claimUndelegatedBalance' ? staking.accountingAddress : staking.poolAddress
|
|
200
263
|
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
;({ amount, data } = await delegateOperation(args))
|
|
204
|
-
const address =
|
|
205
|
-
operation === 'claimUndelegatedBalance' ? staking.accountingAddress : staking.poolAddress
|
|
206
|
-
;({ fee } = await estimateTxFee(delegatorAddress, address, amount, data))
|
|
207
|
-
} catch (e) {
|
|
208
|
-
// If the operation is to unstake and failed retry with unstakePending
|
|
209
|
-
if (operation === 'undelegate') {
|
|
210
|
-
;({ amount, data } = await staking.unstakePending(args))
|
|
211
|
-
;({ fee } = await estimateTxFee(delegatorAddress, staking.poolAddress, amount, data))
|
|
212
|
-
} else {
|
|
213
|
-
throw e
|
|
214
|
-
}
|
|
215
|
-
}
|
|
264
|
+
const { fee } = await estimateTxFee(delegatorAddress, toAddress, amount, data)
|
|
216
265
|
|
|
217
266
|
return fee
|
|
218
267
|
}
|
|
@@ -247,16 +296,11 @@ export function createEthereumStakingService({
|
|
|
247
296
|
return staking.minAmount
|
|
248
297
|
}
|
|
249
298
|
|
|
250
|
-
async function prepareAndSendTx(
|
|
251
|
-
asset,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
txData: txInput,
|
|
256
|
-
gasPrice,
|
|
257
|
-
gasLimit,
|
|
258
|
-
fee,
|
|
259
|
-
} = {}) {
|
|
299
|
+
async function prepareAndSendTx(
|
|
300
|
+
{ asset, walletAccount, to, amount, txData: txInput, gasPrice, gasLimit, fee } = Object.create(
|
|
301
|
+
null
|
|
302
|
+
)
|
|
303
|
+
) {
|
|
260
304
|
const sendTxArgs = {
|
|
261
305
|
asset,
|
|
262
306
|
walletAccount,
|
package/src/staking/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FantomStaking } from './fantom-staking'
|
|
2
|
-
export { stakingProviderClientFactory } from './staking-provider-client'
|
|
3
|
-
export * from './ethereum'
|
|
4
|
-
export * from './matic'
|
|
1
|
+
export { FantomStaking } from './fantom-staking.js'
|
|
2
|
+
export { stakingProviderClientFactory } from './staking-provider-client.js'
|
|
3
|
+
export * from './ethereum/index.js'
|
|
4
|
+
export * from './matic/index.js'
|
package/src/staking/matic/api.js
CHANGED
|
@@ -4,7 +4,7 @@ import { bufferToHex } from '@exodus/ethereumjs-util'
|
|
|
4
4
|
import { retry } from '@exodus/simple-retry'
|
|
5
5
|
import BN from 'bn.js'
|
|
6
6
|
|
|
7
|
-
import { getServerByName } from '../../exodus-eth-server'
|
|
7
|
+
import { getServerByName } from '../../exodus-eth-server/index.js'
|
|
8
8
|
|
|
9
9
|
const polygonEthToken = ethAssets.find(({ name: tokenName }) => tokenName === 'polygon')
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { MaticStakingApi } from './api'
|
|
2
|
-
export { createPolygonStakingService, getPolygonStakingInfo } from './service'
|
|
1
|
+
export { MaticStakingApi } from './api.js'
|
|
2
|
+
export { createPolygonStakingService, getPolygonStakingInfo } from './service.js'
|
|
3
3
|
export {
|
|
4
4
|
isPolygonTx,
|
|
5
5
|
isPolygonDelegate,
|
|
6
6
|
isPolygonUndelegate,
|
|
7
7
|
isPolygonReward,
|
|
8
8
|
isPolygonClaimUndelegate,
|
|
9
|
-
} from './matic-staking-utils'
|
|
9
|
+
} from './matic-staking-utils.js'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isNumberUnit } from '@exodus/currency'
|
|
2
2
|
import BN from 'bn.js'
|
|
3
3
|
|
|
4
|
-
import { getServer } from '../../exodus-eth-server'
|
|
5
|
-
import { estimateGasLimit } from '../../gas-estimation'
|
|
6
|
-
import { stakingProviderClientFactory } from '../staking-provider-client'
|
|
7
|
-
import { MaticStakingApi } from './api'
|
|
4
|
+
import { getServer } from '../../exodus-eth-server/index.js'
|
|
5
|
+
import { estimateGasLimit } from '../../gas-estimation.js'
|
|
6
|
+
import { stakingProviderClientFactory } from '../staking-provider-client.js'
|
|
7
|
+
import { MaticStakingApi } from './api.js'
|
|
8
8
|
|
|
9
9
|
export function createPolygonStakingService({ assetClientInterface, createAndBroadcastTX }) {
|
|
10
10
|
const stakingApi = new MaticStakingApi()
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { BaseMonitor } from '@exodus/asset-lib'
|
|
2
2
|
import { getAssetAddresses, isRpcBalanceAsset } from '@exodus/ethereum-lib'
|
|
3
|
-
import
|
|
3
|
+
import lodash from 'lodash'
|
|
4
4
|
|
|
5
|
-
import { fromHexToString } from '../number-utils'
|
|
6
|
-
import {
|
|
5
|
+
import { fromHexToString } from '../number-utils.js'
|
|
6
|
+
import {
|
|
7
|
+
filterEffects,
|
|
8
|
+
getDeriveDataNeededForTick,
|
|
9
|
+
getLogItemsFromServerTx,
|
|
10
|
+
} from './clarity-utils/index.js'
|
|
7
11
|
import {
|
|
8
12
|
checkPendingTransactions,
|
|
9
13
|
excludeUnchangedTokenBalances,
|
|
10
14
|
getAllLogItemsByAsset,
|
|
11
15
|
getDeriveTransactionsToCheck,
|
|
12
|
-
} from './monitor-utils'
|
|
16
|
+
} from './monitor-utils/index.js'
|
|
17
|
+
|
|
18
|
+
const { isEmpty } = lodash
|
|
13
19
|
|
|
14
20
|
export class ClarityMonitor extends BaseMonitor {
|
|
15
21
|
constructor({ server, config, ...args }) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import lodash from 'lodash'
|
|
2
2
|
|
|
3
|
-
import getFeeAmount from '../monitor-utils/get-fee-amount'
|
|
4
|
-
import getTransfersByTokenName from '../monitor-utils/get-transfers-by-token-name'
|
|
5
|
-
import getValueOfTransfers from '../monitor-utils/get-value-of-transfers'
|
|
6
|
-
import isConfirmedServerTx from '../monitor-utils/is-confirmed-server-tx'
|
|
7
|
-
import isConsideredSentTokenTx from '../monitor-utils/is-considered-sent-token-tx'
|
|
8
|
-
import filterEffects from './filter-effects'
|
|
9
|
-
import getNamesOfTokensTransferredByServerTx from './get-names-of-tokens-transferred-by-server-tx'
|
|
3
|
+
import getFeeAmount from '../monitor-utils/get-fee-amount.js'
|
|
4
|
+
import getTransfersByTokenName from '../monitor-utils/get-transfers-by-token-name.js'
|
|
5
|
+
import getValueOfTransfers from '../monitor-utils/get-value-of-transfers.js'
|
|
6
|
+
import isConfirmedServerTx from '../monitor-utils/is-confirmed-server-tx.js'
|
|
7
|
+
import isConsideredSentTokenTx from '../monitor-utils/is-considered-sent-token-tx.js'
|
|
8
|
+
import filterEffects from './filter-effects.js'
|
|
9
|
+
import getNamesOfTokensTransferredByServerTx from './get-names-of-tokens-transferred-by-server-tx.js'
|
|
10
10
|
|
|
11
11
|
// This function takes a server transaction object fetched from magnifier,
|
|
12
12
|
// and transforms it into Tx models to update the exodus state.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FEE_PAYMENT_PREFIX } from '@exodus/ethereum-lib'
|
|
2
2
|
import lodash from 'lodash'
|
|
3
3
|
|
|
4
|
-
import getValueOfTransfers from '../monitor-utils/get-value-of-transfers'
|
|
4
|
+
import getValueOfTransfers from '../monitor-utils/get-value-of-transfers.js'
|
|
5
5
|
|
|
6
6
|
// For ETH transactions, we store an array of token names inside
|
|
7
7
|
// the TX model. This array is used to display text in the UI for
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as getDeriveDataNeededForTick } from './get-derive-data-needed-for-tick'
|
|
2
|
-
export { default as getLogItemsFromServerTx } from './get-log-items-from-server-tx'
|
|
3
|
-
export { default as filterEffects } from './filter-effects'
|
|
1
|
+
export { default as getDeriveDataNeededForTick } from './get-derive-data-needed-for-tick.js'
|
|
2
|
+
export { default as getLogItemsFromServerTx } from './get-log-items-from-server-tx.js'
|
|
3
|
+
export { default as filterEffects } from './filter-effects.js'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseMonitor } from '@exodus/asset-lib'
|
|
2
2
|
import { getAssetAddresses, isRpcBalanceAsset } from '@exodus/ethereum-lib'
|
|
3
|
-
import
|
|
3
|
+
import lodash from 'lodash'
|
|
4
4
|
|
|
5
|
-
import { fromHexToString } from '../number-utils'
|
|
5
|
+
import { fromHexToString } from '../number-utils.js'
|
|
6
6
|
import {
|
|
7
7
|
checkPendingTransactions,
|
|
8
8
|
excludeUnchangedTokenBalances,
|
|
@@ -11,12 +11,14 @@ import {
|
|
|
11
11
|
getDeriveTransactionsToCheck,
|
|
12
12
|
getHistoryFromServer,
|
|
13
13
|
getLogItemsFromServerTx,
|
|
14
|
-
} from './monitor-utils'
|
|
14
|
+
} from './monitor-utils/index.js'
|
|
15
15
|
import {
|
|
16
16
|
enableWSUpdates,
|
|
17
17
|
subscribeToGasPriceNotifications,
|
|
18
18
|
subscribeToWSNotifications,
|
|
19
|
-
} from './ws-updates'
|
|
19
|
+
} from './ws-updates.js'
|
|
20
|
+
|
|
21
|
+
const { isEmpty } = lodash
|
|
20
22
|
|
|
21
23
|
// The base ethereum monitor class handles listening for, fetching,
|
|
22
24
|
// formatting, and populating-to-state all ETH/ETC/ERC20 transactions.
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { BaseMonitor } from '@exodus/asset-lib'
|
|
2
2
|
import { SynchronizedTime } from '@exodus/basic-utils'
|
|
3
3
|
import { Tx } from '@exodus/models'
|
|
4
|
-
import
|
|
4
|
+
import lodash from 'lodash'
|
|
5
5
|
|
|
6
|
-
import { fromHexToString } from '../number-utils'
|
|
6
|
+
import { fromHexToString } from '../number-utils.js'
|
|
7
|
+
import { UNCONFIRMED_TX_LIMIT } from './monitor-utils/get-derive-transactions-to-check.js'
|
|
7
8
|
import {
|
|
8
9
|
excludeUnchangedTokenBalances,
|
|
9
10
|
getDeriveDataNeededForTick,
|
|
10
11
|
getDeriveTransactionsToCheck,
|
|
11
|
-
} from './monitor-utils'
|
|
12
|
-
|
|
12
|
+
} from './monitor-utils/index.js'
|
|
13
|
+
|
|
14
|
+
const { isEmpty, unionBy, zipObject } = lodash
|
|
13
15
|
|
|
14
16
|
// The base ethereum monitor no history class handles listening for assets with no history
|
|
15
17
|
|
package/src/tx-log/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ethereum-monitor'
|
|
2
|
-
export * from './ethereum-no-history-monitor'
|
|
3
|
-
export { ClarityMonitor } from './clarity-monitor'
|
|
1
|
+
export * from './ethereum-monitor.js'
|
|
2
|
+
export * from './ethereum-no-history-monitor.js'
|
|
3
|
+
export { ClarityMonitor } from './clarity-monitor.js'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import getFeeAmount from './get-fee-amount'
|
|
2
|
-
import getSenderNonceKey from './get-sender-nonce-key'
|
|
1
|
+
import getFeeAmount from './get-fee-amount.js'
|
|
2
|
+
import getSenderNonceKey from './get-sender-nonce-key.js'
|
|
3
3
|
|
|
4
4
|
export default function checkPendingTransactions({
|
|
5
5
|
pendingTransactionsGroupedByAddressAndNonce = {},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import lodash from 'lodash'
|
|
2
2
|
|
|
3
|
-
import getFeeAmount from './get-fee-amount'
|
|
4
|
-
import getNamesOfTokensTransferredByServerTx from './get-names-of-tokens-transferred-by-server-tx'
|
|
5
|
-
import getTransfersByTokenName from './get-transfers-by-token-name'
|
|
6
|
-
import getValueOfTransfers from './get-value-of-transfers'
|
|
7
|
-
import isConfirmedServerTx from './is-confirmed-server-tx'
|
|
8
|
-
import isConsideredSentTokenTx from './is-considered-sent-token-tx'
|
|
3
|
+
import getFeeAmount from './get-fee-amount.js'
|
|
4
|
+
import getNamesOfTokensTransferredByServerTx from './get-names-of-tokens-transferred-by-server-tx.js'
|
|
5
|
+
import getTransfersByTokenName from './get-transfers-by-token-name.js'
|
|
6
|
+
import getValueOfTransfers from './get-value-of-transfers.js'
|
|
7
|
+
import isConfirmedServerTx from './is-confirmed-server-tx.js'
|
|
8
|
+
import isConsideredSentTokenTx from './is-considered-sent-token-tx.js'
|
|
9
9
|
|
|
10
10
|
// This function takes a server transaction object fetched from magnifier,
|
|
11
11
|
// and transforms it into Tx models to update the exodus state.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FEE_PAYMENT_PREFIX } from '@exodus/ethereum-lib'
|
|
2
2
|
import lodash from 'lodash'
|
|
3
3
|
|
|
4
|
-
import getValueOfTransfers from './get-value-of-transfers'
|
|
4
|
+
import getValueOfTransfers from './get-value-of-transfers.js'
|
|
5
5
|
|
|
6
6
|
// For ETH transactions, we store an array of token names inside
|
|
7
7
|
// the TX model. This array is used to display text in the UI for
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { default as getDeriveDataNeededForTick } from './get-derive-data-needed-for-tick'
|
|
1
|
+
export { default as getDeriveDataNeededForTick } from './get-derive-data-needed-for-tick.js'
|
|
2
2
|
|
|
3
|
-
export { default as getAllLogItemsByAsset } from './get-all-log-items-by-asset'
|
|
4
|
-
export { default as getLogItemsFromServerTx } from './get-log-items-from-server-tx'
|
|
5
|
-
export { default as getHistoryFromServer } from './get-history-from-server'
|
|
6
|
-
export { default as checkPendingTransactions } from './check-pending-transactions'
|
|
7
|
-
export { default as getDeriveTransactionsToCheck } from './get-derive-transactions-to-check'
|
|
8
|
-
export * from './exclude-unchanged-token-balances'
|
|
3
|
+
export { default as getAllLogItemsByAsset } from './get-all-log-items-by-asset.js'
|
|
4
|
+
export { default as getLogItemsFromServerTx } from './get-log-items-from-server-tx.js'
|
|
5
|
+
export { default as getHistoryFromServer } from './get-history-from-server.js'
|
|
6
|
+
export { default as checkPendingTransactions } from './check-pending-transactions.js'
|
|
7
|
+
export { default as getDeriveTransactionsToCheck } from './get-derive-transactions-to-check.js'
|
|
8
|
+
export * from './exclude-unchanged-token-balances.js'
|
|
@@ -3,8 +3,12 @@ import {
|
|
|
3
3
|
isEthereumDelegate,
|
|
4
4
|
isEthereumUndelegate,
|
|
5
5
|
isEthereumUndelegatePending,
|
|
6
|
-
} from '../staking/ethereum/staking-utils'
|
|
7
|
-
import {
|
|
6
|
+
} from '../staking/ethereum/staking-utils.js'
|
|
7
|
+
import {
|
|
8
|
+
isPolygonClaimUndelegate,
|
|
9
|
+
isPolygonDelegate,
|
|
10
|
+
isPolygonUndelegate,
|
|
11
|
+
} from '../staking/matic/index.js'
|
|
8
12
|
import {
|
|
9
13
|
calculateRewardsFromStakeTx,
|
|
10
14
|
decodeEthLikeStakingTxInputAmount,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { asset as ethereum } from '@exodus/ethereum-meta'
|
|
2
2
|
import { asset as ethereumholesky } from '@exodus/ethereumholesky-meta'
|
|
3
3
|
|
|
4
|
-
import { EthereumStaking, isEthereumStakingTx, MaticStakingApi } from '../staking'
|
|
4
|
+
import { EthereumStaking, isEthereumStakingTx, MaticStakingApi } from '../staking/index.js'
|
|
5
5
|
|
|
6
6
|
const polygonStakingApi = new MaticStakingApi()
|
|
7
7
|
const ethereumStakingApi = new EthereumStaking(ethereum)
|
package/src/tx-send/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as txSendFactory } from './tx-send'
|
|
2
|
-
export { default as getFeeInfo } from './get-fee-info'
|
|
1
|
+
export { default as txSendFactory } from './tx-send.js'
|
|
2
|
+
export { default as getFeeInfo } from './get-fee-info.js'
|
package/src/tx-send/tx-send.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { calculateBumpedGasPrice, isEthereumLikeToken, normalizeTxId } from '@exodus/ethereum-lib'
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
|
|
6
|
-
import * as ErrorWrapper from '../error-wrapper'
|
|
7
|
-
import { getNonce, transactionExists } from '../eth-like-util'
|
|
8
|
-
import { getNftArguments } from '../nft-utils'
|
|
9
|
-
import getFeeInfo from './get-fee-info'
|
|
6
|
+
import * as ErrorWrapper from '../error-wrapper.js'
|
|
7
|
+
import { getNonce, transactionExists } from '../eth-like-util.js'
|
|
8
|
+
import { getNftArguments } from '../nft-utils.js'
|
|
9
|
+
import getFeeInfo from './get-fee-info.js'
|
|
10
10
|
|
|
11
11
|
const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
|
|
12
12
|
assert(assetClientInterface, 'assetClientInterface is required')
|
package/src/web3/index.js
CHANGED