@exodus/ethereum-api 8.3.2 → 8.4.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 ADDED
@@ -0,0 +1,230 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [8.4.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.3.2...@exodus/ethereum-api@8.4.0) (2024-06-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * **ethereum:** use Syncronized time ([#2481](https://github.com/ExodusMovement/assets/issues/2481)) ([865ec0e](https://github.com/ExodusMovement/assets/commit/865ec0e3b39339525d765c0a92ddde2023701b95))
12
+
13
+
14
+
15
+ ## [8.3.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.3.1...@exodus/ethereum-api@8.3.2) (2024-06-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * evm getFeeAsync fee opts compatibility ([#2526](https://github.com/ExodusMovement/assets/issues/2526)) ([c8fcda8](https://github.com/ExodusMovement/assets/commit/c8fcda8f70225b128d7e9eaa22c1dd57664a784f))
21
+
22
+
23
+
24
+ ## [8.3.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.3.0...@exodus/ethereum-api@8.3.1) (2024-06-07)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * remove default priority fee when setting custom fee ([#2512](https://github.com/ExodusMovement/assets/issues/2512)) ([c592faa](https://github.com/ExodusMovement/assets/commit/c592faaef57aaadf77a1cb5d80aae15b9100ecaa))
30
+ * staking hook when asset is not available ([#2388](https://github.com/ExodusMovement/assets/issues/2388)) ([9bcf9fc](https://github.com/ExodusMovement/assets/commit/9bcf9fc9d3d33c2cb896d0378762890b39cab189))
31
+
32
+
33
+
34
+ ## [8.3.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.2.1...@exodus/ethereum-api@8.3.0) (2024-05-24)
35
+
36
+
37
+ ### Features
38
+
39
+ * always get gas limit for mantle networks ([#2378](https://github.com/ExodusMovement/assets/issues/2378)) ([33f9052](https://github.com/ExodusMovement/assets/commit/33f90526b3c4ea459e771848bb9e5a71edc48049))
40
+
41
+
42
+
43
+ ## [8.2.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.2.0...@exodus/ethereum-api@8.2.1) (2024-05-24)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * getBalance return value has changed ([#2369](https://github.com/ExodusMovement/assets/issues/2369)) ([902e62a](https://github.com/ExodusMovement/assets/commit/902e62ae289bc7fcfbe9424cfa5d76874f91cdb3))
49
+
50
+
51
+
52
+ ## [8.2.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.1.0...@exodus/ethereum-api@8.2.0) (2024-05-23)
53
+
54
+
55
+ ### Features
56
+
57
+ * add data to approve ([#2357](https://github.com/ExodusMovement/assets/issues/2357)) ([4c8c093](https://github.com/ExodusMovement/assets/commit/4c8c0934e46c3433a4526713b2e1e0933850acc5))
58
+ * evm getFeeAsync ([#2216](https://github.com/ExodusMovement/assets/issues/2216)) ([fe47657](https://github.com/ExodusMovement/assets/commit/fe476577793d06267b698eee1e0fd7ebd60fb366))
59
+
60
+
61
+
62
+ ## [8.1.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.0.0...@exodus/ethereum-api@8.1.0) (2024-05-17)
63
+
64
+
65
+ ### Features
66
+
67
+ * **ethereum-api:** expose `web3.simulateMessage` API ([#2302](https://github.com/ExodusMovement/assets/issues/2302)) ([fe97ec3](https://github.com/ExodusMovement/assets/commit/fe97ec3b6ae60d28b2f3ec2aed75aa228176b816))
68
+
69
+
70
+
71
+ ## [8.0.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.5.3...@exodus/ethereum-api@8.0.0) (2024-05-17)
72
+
73
+
74
+ ### ⚠ BREAKING CHANGES
75
+
76
+ * evm chain data to be factory params (#2115)
77
+ * chain id param in create and sign tx (#2282)
78
+ * moved fee data to each EVM plugin (#2233)
79
+ * evm useEip1191ChainIdChecksum param (#2110)
80
+ * clean up evms fee data monitors (#2230)
81
+
82
+ ### Features
83
+
84
+ * evm chain data to be factory params ([#2115](https://github.com/ExodusMovement/assets/issues/2115)) ([a2aeec1](https://github.com/ExodusMovement/assets/commit/a2aeec1b4da177b1e1bb85f92e93115fc97d5377))
85
+
86
+
87
+ ### Code Refactoring
88
+
89
+ * chain id param in create and sign tx ([#2282](https://github.com/ExodusMovement/assets/issues/2282)) ([4d915ac](https://github.com/ExodusMovement/assets/commit/4d915ac60e49ebe9d4e36d2fcecf7c17777f13b9))
90
+ * clean up evms fee data monitors ([#2230](https://github.com/ExodusMovement/assets/issues/2230)) ([4e7a18f](https://github.com/ExodusMovement/assets/commit/4e7a18f799e0800c01e07ca83ddaf6778ada23ce))
91
+ * evm useEip1191ChainIdChecksum param ([#2110](https://github.com/ExodusMovement/assets/issues/2110)) ([2169686](https://github.com/ExodusMovement/assets/commit/2169686cb4c11bb8f0691196b25002b6cf462e1e))
92
+ * moved fee data to each EVM plugin ([#2233](https://github.com/ExodusMovement/assets/issues/2233)) ([ec066c0](https://github.com/ExodusMovement/assets/commit/ec066c076bc36a4c7c05810e83cdd47a7a25384b))
93
+
94
+
95
+
96
+ ## [7.5.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.5.2...@exodus/ethereum-api@7.5.3) (2024-05-10)
97
+
98
+ **Note:** Version bump only for package @exodus/ethereum-api
99
+
100
+
101
+
102
+
103
+
104
+ ## [7.5.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.5.0...@exodus/ethereum-api@7.5.2) (2024-05-08)
105
+
106
+
107
+ ### Bug Fixes
108
+
109
+ * enable Base eip1559 ([#2210](https://github.com/ExodusMovement/assets/issues/2210)) ([8b7e807](https://github.com/ExodusMovement/assets/commit/8b7e807907e961aae47d3beb50cd69502e5a04e2))
110
+ * **ethereum:** evm balances ([#2211](https://github.com/ExodusMovement/assets/issues/2211)) ([7eb6d20](https://github.com/ExodusMovement/assets/commit/7eb6d208555300f329380999654756338780d84e))
111
+ * provide `assetName` to createGetKeyIdentifier ([#2191](https://github.com/ExodusMovement/assets/issues/2191)) ([55e5171](https://github.com/ExodusMovement/assets/commit/55e5171b142fd72ff88b645f02f0ad358b93ccf8))
112
+
113
+
114
+
115
+ ## [7.5.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.5.0...@exodus/ethereum-api@7.5.1) (2024-05-04)
116
+
117
+
118
+ ### Bug Fixes
119
+
120
+ * enable Base eip1559 ([#2210](https://github.com/ExodusMovement/assets/issues/2210)) ([8b7e807](https://github.com/ExodusMovement/assets/commit/8b7e807907e961aae47d3beb50cd69502e5a04e2))
121
+
122
+
123
+
124
+ ## [7.5.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.4.0...@exodus/ethereum-api@7.5.0) (2024-05-01)
125
+
126
+
127
+ ### Features
128
+
129
+ * evm baseFeePerGas fee monitor ([#2194](https://github.com/ExodusMovement/assets/issues/2194)) ([0739c97](https://github.com/ExodusMovement/assets/commit/0739c97568741394d1eb542332a4ccbbc6eaccb9))
130
+ * export signMessageWithSigner from index ([#2162](https://github.com/ExodusMovement/assets/issues/2162)) ([5849688](https://github.com/ExodusMovement/assets/commit/5849688c64761dbfe00c3d47f0654dd23e1e9167))
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * **ethereum-api:** set ZERO fee if not supplied ([#2201](https://github.com/ExodusMovement/assets/issues/2201)) ([be11417](https://github.com/ExodusMovement/assets/commit/be1141792882a7f0ffbb754d51970b30b15923ea))
136
+
137
+
138
+
139
+ ## [7.4.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.3.2...@exodus/ethereum-api@7.4.0) (2024-04-24)
140
+
141
+
142
+ ### Features
143
+
144
+ * eth unconfirmed receive/sent ([#2146](https://github.com/ExodusMovement/assets/issues/2146)) ([6b750c7](https://github.com/ExodusMovement/assets/commit/6b750c7d1f0ac633d72c285eaa31428a01cd1543))
145
+ * evm api.getBalanceForAddress ([#2148](https://github.com/ExodusMovement/assets/issues/2148)) ([4e201b6](https://github.com/ExodusMovement/assets/commit/4e201b6e3eecbe0dfeceb07028f0cf18a33b0a88))
146
+ * EVM l1 gas estimation ([#2159](https://github.com/ExodusMovement/assets/issues/2159)) ([c23584e](https://github.com/ExodusMovement/assets/commit/c23584e04e2ba47538e5134c73ecba3d337cda0f))
147
+ * set signMessageWithSigner=true for ethereum ([#2154](https://github.com/ExodusMovement/assets/issues/2154)) ([08d21bf](https://github.com/ExodusMovement/assets/commit/08d21bfe7e2be100477e60611f7e21db0e5f61a7))
148
+
149
+
150
+
151
+ ## [7.3.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.3.1...@exodus/ethereum-api@7.3.2) (2024-04-22)
152
+
153
+
154
+ ### Bug Fixes
155
+
156
+ * ethereum getFee isRbfAllowed ([#2141](https://github.com/ExodusMovement/assets/issues/2141)) ([00df858](https://github.com/ExodusMovement/assets/commit/00df8582d8117764ab1389e78a102b38b8b200aa))
157
+
158
+
159
+
160
+ ## [7.3.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.3.0...@exodus/ethereum-api@7.3.1) (2024-04-22)
161
+
162
+
163
+ ### Bug Fixes
164
+
165
+ * eslint ban bigint literals ([#2134](https://github.com/ExodusMovement/assets/issues/2134)) ([910ab73](https://github.com/ExodusMovement/assets/commit/910ab73857267c02507a699ee2582fea73de6474))
166
+
167
+
168
+
169
+ ## [7.3.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.2.1...@exodus/ethereum-api@7.3.0) (2024-04-17)
170
+
171
+
172
+ ### Features
173
+
174
+ * createAsset from Mobile (EVM 3) ([#2020](https://github.com/ExodusMovement/assets/issues/2020)) ([7831774](https://github.com/ExodusMovement/assets/commit/7831774c66a61b98dd37772b6260864d668663ca))
175
+ * eth tx-send from BE (EVM 2) ([#2018](https://github.com/ExodusMovement/assets/issues/2018)) ([d6e0de5](https://github.com/ExodusMovement/assets/commit/d6e0de5968f6697dc836b29192245c79aa6f2a0f))
176
+ * Ethereum getFee (EVM 1.1) ([#2031](https://github.com/ExodusMovement/assets/issues/2031)) ([b4ff5c7](https://github.com/ExodusMovement/assets/commit/b4ff5c72b822d7ecabe4f1202df676ba5cb4ac65))
177
+ * ethereum-plugin (EVM 4) ([#2023](https://github.com/ExodusMovement/assets/issues/2023)) ([3c897c5](https://github.com/ExodusMovement/assets/commit/3c897c572e423e54d53a5737415481ec4e3cd654))
178
+ * expose signMessage & signHardware ([#2103](https://github.com/ExodusMovement/assets/issues/2103)) ([60ea167](https://github.com/ExodusMovement/assets/commit/60ea167283e2e4b82a69530ba156c56dead8812c))
179
+ * generic evm fee monitors ([#2104](https://github.com/ExodusMovement/assets/issues/2104)) ([70ef5fd](https://github.com/ExodusMovement/assets/commit/70ef5fdb8d87b67957eb56878868145867797af5))
180
+ * new eth balances (EVM 1) ([#2013](https://github.com/ExodusMovement/assets/issues/2013)) ([5fa2375](https://github.com/ExodusMovement/assets/commit/5fa2375caccf957d2f10c76f279aa1fdc7597df1))
181
+ * rootstock-plugin ([#2088](https://github.com/ExodusMovement/assets/issues/2088)) ([22b263d](https://github.com/ExodusMovement/assets/commit/22b263db2961875b562e33c2afdd7f5eb4cd4295))
182
+ * signMessageWithSigner in ethreum plugin ([#2112](https://github.com/ExodusMovement/assets/issues/2112)) ([0fcbf9d](https://github.com/ExodusMovement/assets/commit/0fcbf9d7bf4323559236b8ea30a2525f994e544d))
183
+
184
+
185
+ ### Bug Fixes
186
+
187
+ * ethereum bigint when BN.js ([#1790](https://github.com/ExodusMovement/assets/issues/1790)) ([2c07b8d](https://github.com/ExodusMovement/assets/commit/2c07b8d2ba5cc6c609ab0c942a4ac863247df70b))
188
+ * **ethereum:** make integration tests pass ([#1989](https://github.com/ExodusMovement/assets/issues/1989)) ([97a984e](https://github.com/ExodusMovement/assets/commit/97a984e77371439638153f8c7b82939222574ce0))
189
+ * evm extra fee i18n ([#2062](https://github.com/ExodusMovement/assets/issues/2062)) ([68b134f](https://github.com/ExodusMovement/assets/commit/68b134ff89f665e09d340ef5c38d97af45bee877))
190
+
191
+
192
+
193
+ ## [7.2.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.2.0...@exodus/ethereum-api@7.2.1) (2024-04-02)
194
+
195
+
196
+ ### Bug Fixes
197
+
198
+ * indexless ghost txs ([#1931](https://github.com/ExodusMovement/assets/issues/1931)) ([4ccde83](https://github.com/ExodusMovement/assets/commit/4ccde833e139e8c457bb74261562c0368792c5d7))
199
+ * use Object.create(null) ([#1901](https://github.com/ExodusMovement/assets/issues/1901)) ([cf96d9d](https://github.com/ExodusMovement/assets/commit/cf96d9db1cc28deaa15bb8fbbd03005e3f08b0c7))
200
+
201
+
202
+
203
+ ## [7.2.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.1.0...@exodus/ethereum-api@7.2.0) (2024-03-25)
204
+
205
+
206
+ ### Features
207
+
208
+ * add support for external signer for ETH ([#1607](https://github.com/ExodusMovement/assets/issues/1607)) ([0323765](https://github.com/ExodusMovement/assets/commit/032376510205417cbbfe3ac0ea14ef203aa3823c))
209
+ * **ETH:** add Sepolia testnet ([#1855](https://github.com/ExodusMovement/assets/issues/1855)) ([a2f7c07](https://github.com/ExodusMovement/assets/commit/a2f7c07a1068c8ee0c3646f4eda3b133266f518f))
210
+ * **ethereum:** ethereum tokens cleanup - part 2 ([#1573](https://github.com/ExodusMovement/assets/issues/1573)) ([85b5a10](https://github.com/ExodusMovement/assets/commit/85b5a10e958ba883dd9fbbfc521909a27ea05a12))
211
+
212
+
213
+ ### Bug Fixes
214
+
215
+ * eth getBalanceProxied round error ([#1774](https://github.com/ExodusMovement/assets/issues/1774)) ([02fc9b0](https://github.com/ExodusMovement/assets/commit/02fc9b0989e22035cd0e4eab9bd732f47b410979))
216
+ * switch staking telemetry param to a fn ([#1579](https://github.com/ExodusMovement/assets/issues/1579)) ([8cf7a9c](https://github.com/ExodusMovement/assets/commit/8cf7a9cabf752b6e8171d6bfc9d1bfca3cf8dea3))
217
+
218
+
219
+ ### Reverts
220
+
221
+ * Revert "Publish" ([adb8015](https://github.com/ExodusMovement/assets/commit/adb8015efd51a4fa36ad0c86c28cb2d94c52a578))
222
+
223
+
224
+
225
+ # [7.1.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@7.0.18...@exodus/ethereum-api@7.1.0) (2024-02-22)
226
+
227
+
228
+ ### Features
229
+
230
+ * add ENJ as zero-allowance-token ([#1521](https://github.com/ExodusMovement/assets/issues/1521)) ([e148a3a](https://github.com/ExodusMovement/assets/commit/e148a3a7e744c21feb81d9761c1a1dfd2b81c2d7))
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.3.2",
3
+ "version": "8.4.0",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
7
7
  "src",
8
+ "CHANGELOG.md",
8
9
  "!src/**/__tests__"
9
10
  ],
10
11
  "author": "Exodus Movement, Inc.",
11
12
  "license": "UNLICENSED",
12
- "homepage": "https://github.com/ExodusMovement/assets/tree/main/ethereum",
13
+ "homepage": "https://github.com/ExodusMovement/assets/tree/master/ethereum/ethereum-api",
13
14
  "publishConfig": {
14
15
  "access": "restricted"
15
16
  },
16
17
  "scripts": {
17
18
  "test": "run -T jest",
18
- "lint": "run -T eslint src",
19
+ "lint": "run -T eslint .",
19
20
  "lint:fix": "yarn lint --fix"
20
21
  },
21
22
  "dependencies": {
@@ -40,10 +41,10 @@
40
41
  "idna-uts46-hx": "^2.3.1",
41
42
  "js-sha3": "^0.8.0",
42
43
  "lodash": "^4.17.15",
43
- "make-concurrent": "4.0.0",
44
+ "make-concurrent": "^4.0.0",
44
45
  "minimalistic-assert": "^1.0.1",
45
46
  "ms": "^2.1.1",
46
- "socket.io-client": "2.1.1",
47
+ "socket.io-client": "^2.1.1",
47
48
  "ws": "^6.1.0"
48
49
  },
49
50
  "devDependencies": {
@@ -58,5 +59,12 @@
58
59
  "cross-fetch": "^3.1.5",
59
60
  "delay": "4.0.1"
60
61
  },
61
- "gitHead": "11a9b2f22c847d15a678534743f628adf15b0a2e"
62
+ "bugs": {
63
+ "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Aethereum-api"
64
+ },
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "git+https://github.com/ExodusMovement/assets.git"
68
+ },
69
+ "gitHead": "e33a20671ce835d88a11a5a8dc97e494ba04341f"
62
70
  }
@@ -14,6 +14,7 @@ import { BaseMonitor } from '@exodus/asset-lib'
14
14
 
15
15
  import { UNCONFIRMED_TX_LIMIT } from './monitor-utils/get-derive-transactions-to-check'
16
16
  import { fromHexToString } from '../number-utils'
17
+ import { SynchronizedTime } from '@exodus/basic-utils'
17
18
 
18
19
  // The base ethereum monitor no history class handles listening for assets with no history
19
20
 
@@ -128,7 +129,7 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
128
129
  async checkPendingTransactions({ pendingTransactions, pendingTxsFromNode, walletAccount }) {
129
130
  const txsToUpdate = []
130
131
  const txsToRemove = []
131
- const now = Date.now()
132
+ const now = SynchronizedTime.now()
132
133
 
133
134
  if (isEmpty(pendingTransactions))
134
135
  return {
@@ -1,5 +1,6 @@
1
1
  import ms from 'ms'
2
2
  import getSenderNonceKey from './get-sender-nonce-key'
3
+ import { SynchronizedTime } from '@exodus/basic-utils'
3
4
 
4
5
  export const UNCONFIRMED_TX_LIMIT = ms('5m')
5
6
 
@@ -10,7 +11,7 @@ export default function getDeriveTransactionsToCheck({ getTxLog }) {
10
11
  const pendingTransactionsToCheck = new Map()
11
12
  const pendingTransactionsGroupedByAddressAndNonce = new Map()
12
13
  const simulatedTransactions = new Map()
13
- const now = Date.now()
14
+ const now = SynchronizedTime.now()
14
15
 
15
16
  for (const assetName of [_assetName, ...tokens.map(({ name }) => name)]) {
16
17
  const txSet = await getTxLog({ assetName, walletAccount })
@@ -17,7 +17,7 @@ export default function getLogItemsFromServerTx({
17
17
  assets,
18
18
  }) {
19
19
  const confirmations = isConfirmedServerTx(serverTx) ? 1 : 0
20
- const date = parseServerTxDate(serverTx.timestamp) // included even for unconfirmed txs
20
+ const date = new Date(parseInt(serverTx.timestamp, 16) * 1000) // included even for unconfirmed txs
21
21
  const txId = serverTx.hash
22
22
  const nonce = parseInt(serverTx.nonce, 16)
23
23
  const gasLimit = parseInt(serverTx.gas, 16)
@@ -141,10 +141,6 @@ export default function getLogItemsFromServerTx({
141
141
  const tryFindExternalRecipient = (transfers, ourWalletAddress) =>
142
142
  transfers.find(({ to }) => to !== ourWalletAddress)?.to || ourWalletAddress
143
143
 
144
- // If the timestamp is in the future, use the current time.
145
- const parseServerTxDate = (timestamp) =>
146
- new Date(Math.min(Date.now(), parseInt(timestamp, 16) * 1000))
147
-
148
144
  function isSelfSendTx({
149
145
  coinAmount,
150
146
  ourWalletWasSender,
@@ -7,27 +7,36 @@ import {
7
7
 
8
8
  import { isPolygonClaimUndelegate, isPolygonDelegate } from '../staking/matic'
9
9
 
10
- import {
11
- decodePolygonStakingTxInputAmount,
12
- isEthereumTxCountedForRewards,
13
- isEthereumUndelegateTx,
14
- } from './utils.js'
10
+ import { decodePolygonStakingTxInputAmount } from './utils.js'
15
11
 
16
12
  const getEthereumStakeTxType = ({ tx }) => {
17
- // only unstake txs with ZERO amount are used to calculate rewards
18
- const skipTx = tx.coinAmount.isZero && !isEthereumUndelegateTx(tx)
19
- if (skipTx) return
13
+ if (
14
+ ['delegate', 'undelegatePending', 'undelegate', 'claimUndelegate'].some(
15
+ (stakeTx) => tx.data?.[stakeTx]
16
+ )
17
+ )
18
+ return
19
+
20
+ if (isEthereumDelegate(tx)) {
21
+ return { delegate: tx.coinAmount.toDefaultString() }
22
+ }
20
23
 
21
- if (isEthereumDelegate(tx)) return { delegate: tx.coinAmount.toDefaultString() }
22
24
  // undelegate must be taken in consideration, if unstaked ETH is still
23
25
  // in the pool queue, undelgate transfers staked funds back inmediatly to the user
24
- if (isEthereumUndelegatePending(tx)) return { undelegatePending: tx.coinAmount.toDefaultString() }
25
- if (isEthereumUndelegate(tx) && !isEthereumTxCountedForRewards(tx))
26
+ if (isEthereumUndelegatePending(tx))
27
+ return {
28
+ undelegatePending: tx.coinAmount.toDefaultString(),
29
+ }
30
+
31
+ if (isEthereumUndelegate(tx)) {
26
32
  return { undelegate: tx.coinAmount.toDefaultString() }
33
+ }
34
+
27
35
  // In the case of the ETH being actually staked and earning,
28
36
  // unstake has a withdraw period, after that, unstaked can be claimed.
29
- if (isEthereumClaimUndelegate(tx) && !isEthereumTxCountedForRewards(tx))
37
+ if (isEthereumClaimUndelegate(tx)) {
30
38
  return { claimUndelegate: tx.coinAmount.toDefaultString() }
39
+ }
31
40
  }
32
41
 
33
42
  const getPolygonStakeTxType = ({ tx, currency }) => {
@@ -1,5 +1,4 @@
1
1
  import { assetStakingTxData } from './asset-staking-tx-data'
2
- import { deriveAssetTxsFactory } from './derive-txs'
3
2
  import { getStakeTxAmount } from './get-asset-tx-amount'
4
3
 
5
4
  const getTxStakeData = ({ assetName, currency, tx }) => {
@@ -9,7 +8,6 @@ const getTxStakeData = ({ assetName, currency, tx }) => {
9
8
  const processTxLog = async ({ asset, assetClientInterface: aci, walletAccount, batch }) => {
10
9
  const { name: assetName, currency } = asset
11
10
  const txs = await aci.getTxLog({ assetName, walletAccount })
12
- const deriveAssetTxs = deriveAssetTxsFactory({ assetName, currency })
13
11
 
14
12
  const newTxs = []
15
13
  for (const tx of txs) {
@@ -22,10 +20,6 @@ const processTxLog = async ({ asset, assetClientInterface: aci, walletAccount, b
22
20
  data: { ...tx.data, ...txStakeData },
23
21
  })
24
22
  }
25
-
26
- if (txStakeData && deriveAssetTxs) {
27
- newTxs.push(...deriveAssetTxs({ tx, txStakeData }))
28
- }
29
23
  }
30
24
 
31
25
  if (newTxs.length > 0) {
@@ -1,59 +0,0 @@
1
- import { decodeEthLikeStakingTxInputAmount } from './utils'
2
-
3
- const deriveEthereumTxs = ({ currency }) => {
4
- let totalUnstaked = currency.ZERO
5
-
6
- return function ({ tx, txStakeData }) {
7
- const { claimUndelegate, undelegate } = txStakeData
8
-
9
- if (claimUndelegate && totalUnstaked.isPositive) {
10
- // calculate and add a new reward tx based 'totalUnstaked' (unstaked amount counted so far)
11
- const claimedWithRewards = currency.defaultUnit(claimUndelegate)
12
- const reward = claimedWithRewards.sub(totalUnstaked)
13
- const claimed = claimedWithRewards.sub(reward)
14
- // count again for new rewards in upcoming unstake txs
15
- totalUnstaked = currency.ZERO
16
- return reward.isPositive
17
- ? [
18
- {
19
- ...tx,
20
- coinAmount: reward,
21
- data: {
22
- reward: reward.toDefaultString(),
23
- claim: claimed.toDefaultString(),
24
- countedForRewards: true,
25
- },
26
- },
27
- ]
28
- : []
29
- }
30
-
31
- if (undelegate) {
32
- // Only care about amount requested in 'unstake()'; considered to be in progress.
33
- // Counting unstake (not unstake pending) amount until 'claimUnstake()' is called,
34
- // then use the counted unstaked amount to derive rewards with:
35
- // rewards = claimUstaked - totalUnstaked
36
- const unstakeInProgress = currency.baseUnit(decodeEthLikeStakingTxInputAmount(tx))
37
- totalUnstaked = totalUnstaked.add(unstakeInProgress)
38
- return [
39
- {
40
- ...tx,
41
- coinAmount: currency.ZERO,
42
- data: { ...tx.data, countedForRewards: true },
43
- },
44
- ]
45
- }
46
-
47
- // undelegate pending excluded as unstaked funds are moved inmediatly to user address
48
- return []
49
- }
50
- }
51
-
52
- export const deriveAssetTxsFactory = ({ assetName, currency }) => {
53
- const deriveTxHandlers = {
54
- ethereum: deriveEthereumTxs({ currency }),
55
- ethereumholesky: deriveEthereumTxs({ currency }),
56
- }
57
-
58
- return deriveTxHandlers[assetName]
59
- }