@exodus/ethereum-lib 1.1.5 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -21,5 +21,5 @@
21
21
  "peerDependencies": {
22
22
  "@exodus/assets": "8.0.x"
23
23
  },
24
- "gitHead": "f6642c1e3ef9004b27923176c5654103efad1181"
24
+ "gitHead": "2e5d344cb8f52ccd17e37dfa73db49a95a927e96"
25
25
  }
package/src/abi/ant.js ADDED
@@ -0,0 +1,386 @@
1
+ // https://etherscan.io/address/0x960b236A07cf122663c4303350609A66A7B288C0#code
2
+
3
+ export default [
4
+ {
5
+ constant: false,
6
+ inputs: [
7
+ { name: '_to', type: 'address' },
8
+ { name: '_value', type: 'uint256' },
9
+ { name: '_start', type: 'uint64' },
10
+ { name: '_cliff', type: 'uint64' },
11
+ { name: '_vesting', type: 'uint64' },
12
+ ],
13
+ name: 'grantVestedTokens',
14
+ outputs: [],
15
+ payable: false,
16
+ type: 'function',
17
+ },
18
+ {
19
+ constant: true,
20
+ inputs: [{ name: '_holder', type: 'address' }],
21
+ name: 'tokenGrantsCount',
22
+ outputs: [{ name: 'index', type: 'uint256' }],
23
+ payable: false,
24
+ type: 'function',
25
+ },
26
+ {
27
+ constant: true,
28
+ inputs: [],
29
+ name: 'name',
30
+ outputs: [{ name: '', type: 'string' }],
31
+ payable: false,
32
+ type: 'function',
33
+ },
34
+ {
35
+ constant: false,
36
+ inputs: [
37
+ { name: '_spender', type: 'address' },
38
+ { name: '_amount', type: 'uint256' },
39
+ ],
40
+ name: 'approve',
41
+ outputs: [{ name: 'success', type: 'bool' }],
42
+ payable: false,
43
+ type: 'function',
44
+ },
45
+ {
46
+ constant: true,
47
+ inputs: [{ name: '_holder', type: 'address' }],
48
+ name: 'spendableBalanceOf',
49
+ outputs: [{ name: '', type: 'uint256' }],
50
+ payable: false,
51
+ type: 'function',
52
+ },
53
+ {
54
+ constant: true,
55
+ inputs: [],
56
+ name: 'creationBlock',
57
+ outputs: [{ name: '', type: 'uint256' }],
58
+ payable: false,
59
+ type: 'function',
60
+ },
61
+ {
62
+ constant: true,
63
+ inputs: [],
64
+ name: 'totalSupply',
65
+ outputs: [{ name: '', type: 'uint256' }],
66
+ payable: false,
67
+ type: 'function',
68
+ },
69
+ {
70
+ constant: false,
71
+ inputs: [
72
+ { name: '_addr', type: 'address' },
73
+ { name: '_allowed', type: 'bool' },
74
+ ],
75
+ name: 'setCanCreateGrants',
76
+ outputs: [],
77
+ payable: false,
78
+ type: 'function',
79
+ },
80
+ {
81
+ constant: false,
82
+ inputs: [
83
+ { name: '_from', type: 'address' },
84
+ { name: '_to', type: 'address' },
85
+ { name: '_value', type: 'uint256' },
86
+ ],
87
+ name: 'transferFrom',
88
+ outputs: [{ name: 'success', type: 'bool' }],
89
+ payable: false,
90
+ type: 'function',
91
+ },
92
+ {
93
+ constant: true,
94
+ inputs: [
95
+ { name: '', type: 'address' },
96
+ { name: '', type: 'uint256' },
97
+ ],
98
+ name: 'grants',
99
+ outputs: [
100
+ { name: 'granter', type: 'address' },
101
+ { name: 'value', type: 'uint256' },
102
+ { name: 'cliff', type: 'uint64' },
103
+ { name: 'vesting', type: 'uint64' },
104
+ { name: 'start', type: 'uint64' },
105
+ ],
106
+ payable: false,
107
+ type: 'function',
108
+ },
109
+ {
110
+ constant: true,
111
+ inputs: [],
112
+ name: 'decimals',
113
+ outputs: [{ name: '', type: 'uint8' }],
114
+ payable: false,
115
+ type: 'function',
116
+ },
117
+ {
118
+ constant: false,
119
+ inputs: [{ name: '_newController', type: 'address' }],
120
+ name: 'changeController',
121
+ outputs: [],
122
+ payable: false,
123
+ type: 'function',
124
+ },
125
+ {
126
+ constant: true,
127
+ inputs: [
128
+ { name: '_owner', type: 'address' },
129
+ { name: '_blockNumber', type: 'uint256' },
130
+ ],
131
+ name: 'balanceOfAt',
132
+ outputs: [{ name: '', type: 'uint256' }],
133
+ payable: false,
134
+ type: 'function',
135
+ },
136
+ {
137
+ constant: true,
138
+ inputs: [],
139
+ name: 'version',
140
+ outputs: [{ name: '', type: 'string' }],
141
+ payable: false,
142
+ type: 'function',
143
+ },
144
+ {
145
+ constant: true,
146
+ inputs: [
147
+ { name: '_holder', type: 'address' },
148
+ { name: '_grantId', type: 'uint256' },
149
+ ],
150
+ name: 'tokenGrant',
151
+ outputs: [
152
+ { name: 'granter', type: 'address' },
153
+ { name: 'value', type: 'uint256' },
154
+ { name: 'vested', type: 'uint256' },
155
+ { name: 'start', type: 'uint64' },
156
+ { name: 'cliff', type: 'uint64' },
157
+ { name: 'vesting', type: 'uint64' },
158
+ ],
159
+ payable: false,
160
+ type: 'function',
161
+ },
162
+ {
163
+ constant: false,
164
+ inputs: [
165
+ { name: '_cloneTokenName', type: 'string' },
166
+ { name: '_cloneDecimalUnits', type: 'uint8' },
167
+ { name: '_cloneTokenSymbol', type: 'string' },
168
+ { name: '_snapshotBlock', type: 'uint256' },
169
+ { name: '_transfersEnabled', type: 'bool' },
170
+ ],
171
+ name: 'createCloneToken',
172
+ outputs: [{ name: '', type: 'address' }],
173
+ payable: false,
174
+ type: 'function',
175
+ },
176
+ {
177
+ constant: true,
178
+ inputs: [{ name: 'holder', type: 'address' }],
179
+ name: 'lastTokenIsTransferableDate',
180
+ outputs: [{ name: 'date', type: 'uint64' }],
181
+ payable: false,
182
+ type: 'function',
183
+ },
184
+ {
185
+ constant: true,
186
+ inputs: [{ name: '_owner', type: 'address' }],
187
+ name: 'balanceOf',
188
+ outputs: [{ name: 'balance', type: 'uint256' }],
189
+ payable: false,
190
+ type: 'function',
191
+ },
192
+ {
193
+ constant: true,
194
+ inputs: [],
195
+ name: 'parentToken',
196
+ outputs: [{ name: '', type: 'address' }],
197
+ payable: false,
198
+ type: 'function',
199
+ },
200
+ {
201
+ constant: false,
202
+ inputs: [
203
+ { name: '_owner', type: 'address' },
204
+ { name: '_amount', type: 'uint256' },
205
+ ],
206
+ name: 'generateTokens',
207
+ outputs: [{ name: '', type: 'bool' }],
208
+ payable: false,
209
+ type: 'function',
210
+ },
211
+ {
212
+ constant: true,
213
+ inputs: [],
214
+ name: 'symbol',
215
+ outputs: [{ name: '', type: 'string' }],
216
+ payable: false,
217
+ type: 'function',
218
+ },
219
+ {
220
+ constant: true,
221
+ inputs: [{ name: '_blockNumber', type: 'uint256' }],
222
+ name: 'totalSupplyAt',
223
+ outputs: [{ name: '', type: 'uint256' }],
224
+ payable: false,
225
+ type: 'function',
226
+ },
227
+ {
228
+ constant: false,
229
+ inputs: [
230
+ { name: '_to', type: 'address' },
231
+ { name: '_value', type: 'uint256' },
232
+ ],
233
+ name: 'transfer',
234
+ outputs: [{ name: 'success', type: 'bool' }],
235
+ payable: false,
236
+ type: 'function',
237
+ },
238
+ {
239
+ constant: true,
240
+ inputs: [],
241
+ name: 'transfersEnabled',
242
+ outputs: [{ name: '', type: 'bool' }],
243
+ payable: false,
244
+ type: 'function',
245
+ },
246
+ {
247
+ constant: true,
248
+ inputs: [],
249
+ name: 'parentSnapShotBlock',
250
+ outputs: [{ name: '', type: 'uint256' }],
251
+ payable: false,
252
+ type: 'function',
253
+ },
254
+ {
255
+ constant: false,
256
+ inputs: [
257
+ { name: '_spender', type: 'address' },
258
+ { name: '_amount', type: 'uint256' },
259
+ { name: '_extraData', type: 'bytes' },
260
+ ],
261
+ name: 'approveAndCall',
262
+ outputs: [{ name: 'success', type: 'bool' }],
263
+ payable: false,
264
+ type: 'function',
265
+ },
266
+ {
267
+ constant: true,
268
+ inputs: [
269
+ { name: 'holder', type: 'address' },
270
+ { name: 'time', type: 'uint64' },
271
+ ],
272
+ name: 'transferableTokens',
273
+ outputs: [{ name: '', type: 'uint256' }],
274
+ payable: false,
275
+ type: 'function',
276
+ },
277
+ {
278
+ constant: false,
279
+ inputs: [
280
+ { name: '_owner', type: 'address' },
281
+ { name: '_amount', type: 'uint256' },
282
+ ],
283
+ name: 'destroyTokens',
284
+ outputs: [{ name: '', type: 'bool' }],
285
+ payable: false,
286
+ type: 'function',
287
+ },
288
+ {
289
+ constant: true,
290
+ inputs: [
291
+ { name: '_owner', type: 'address' },
292
+ { name: '_spender', type: 'address' },
293
+ ],
294
+ name: 'allowance',
295
+ outputs: [{ name: 'remaining', type: 'uint256' }],
296
+ payable: false,
297
+ type: 'function',
298
+ },
299
+ {
300
+ constant: true,
301
+ inputs: [],
302
+ name: 'tokenFactory',
303
+ outputs: [{ name: '', type: 'address' }],
304
+ payable: false,
305
+ type: 'function',
306
+ },
307
+ {
308
+ constant: false,
309
+ inputs: [
310
+ { name: '_holder', type: 'address' },
311
+ { name: '_grantId', type: 'uint256' },
312
+ ],
313
+ name: 'revokeTokenGrant',
314
+ outputs: [],
315
+ payable: false,
316
+ type: 'function',
317
+ },
318
+ {
319
+ constant: false,
320
+ inputs: [{ name: '_transfersEnabled', type: 'bool' }],
321
+ name: 'enableTransfers',
322
+ outputs: [],
323
+ payable: false,
324
+ type: 'function',
325
+ },
326
+ {
327
+ constant: true,
328
+ inputs: [],
329
+ name: 'controller',
330
+ outputs: [{ name: '', type: 'address' }],
331
+ payable: false,
332
+ type: 'function',
333
+ },
334
+ {
335
+ constant: false,
336
+ inputs: [{ name: '_newWhitelister', type: 'address' }],
337
+ name: 'changeVestingWhitelister',
338
+ outputs: [],
339
+ payable: false,
340
+ type: 'function',
341
+ },
342
+ { inputs: [{ name: '_tokenFactory', type: 'address' }], payable: false, type: 'constructor' },
343
+ { payable: true, type: 'fallback' },
344
+ {
345
+ anonymous: false,
346
+ inputs: [
347
+ { indexed: true, name: 'from', type: 'address' },
348
+ { indexed: true, name: 'to', type: 'address' },
349
+ { indexed: false, name: 'value', type: 'uint256' },
350
+ { indexed: false, name: 'start', type: 'uint64' },
351
+ { indexed: false, name: 'cliff', type: 'uint64' },
352
+ { indexed: false, name: 'vesting', type: 'uint64' },
353
+ ],
354
+ name: 'NewTokenGrant',
355
+ type: 'event',
356
+ },
357
+ {
358
+ anonymous: false,
359
+ inputs: [
360
+ { indexed: true, name: '_cloneToken', type: 'address' },
361
+ { indexed: false, name: '_snapshotBlock', type: 'uint256' },
362
+ ],
363
+ name: 'NewCloneToken',
364
+ type: 'event',
365
+ },
366
+ {
367
+ anonymous: false,
368
+ inputs: [
369
+ { indexed: true, name: 'from', type: 'address' },
370
+ { indexed: true, name: 'to', type: 'address' },
371
+ { indexed: false, name: 'value', type: 'uint256' },
372
+ ],
373
+ name: 'Transfer',
374
+ type: 'event',
375
+ },
376
+ {
377
+ anonymous: false,
378
+ inputs: [
379
+ { indexed: true, name: 'owner', type: 'address' },
380
+ { indexed: true, name: 'spender', type: 'address' },
381
+ { indexed: false, name: 'value', type: 'uint256' },
382
+ ],
383
+ name: 'Approval',
384
+ type: 'event',
385
+ },
386
+ ]
package/src/abi/index.js CHANGED
@@ -1,9 +1,11 @@
1
+ import ant from './ant'
1
2
  import cdai from './cdai'
2
3
  import dai from './dai'
3
4
  import repv2 from './repv2'
4
5
  import scdMcdMigration from './scd-mcd-migration'
5
6
 
6
7
  export default {
8
+ ant,
7
9
  cdai,
8
10
  dai,
9
11
  repv2,
@@ -9,6 +9,8 @@ export default function createContract(address, assetName) {
9
9
  // return new SolidityContract(ABI.cdai, address)
10
10
  case 'augurv2':
11
11
  return new SolidityContract(ABI.repv2, address)
12
+ case 'aragon':
13
+ return new SolidityContract(ABI.ant, address)
12
14
  default:
13
15
  return SolidityContract.erc20(address)
14
16
  }
@@ -28,18 +28,14 @@ export default (
28
28
 
29
29
  const walletAccountBalances = getWalletAccountBalances(activeWalletAccount)
30
30
  const assetName = tx.coinName
31
- const { gasPrice } = getFeeData(assetName)
31
+ const { gasPrice: currentGasPrice } = getFeeData(assetName)
32
32
  const usedGasPrice = tx.feeAmount.div(tx.data.gasLimit)
33
- if (usedGasPrice.gte(gasPrice)) {
34
- return BumpType.NONE
35
- }
36
- const fee = getFee(
37
- { asset: assetName, walletAccount: activeWalletAccount },
38
- { gasLimit: tx.data.gasLimit }
39
- )
40
- .mul(12) // new gas price should be at least 20% higher
41
- .div(10)
42
- if (walletAccountBalances[assetName].lt(fee)) return BumpType.NONE
33
+ // new gas price should be at least 20% higher and not less than the current gas price
34
+ const bumpedGasPrice = usedGasPrice.mul(12).div(10)
35
+ const gasPriceToUse = currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
36
+ const replacementFee = gasPriceToUse.mul(tx.data.gasLimit)
37
+ const extraEthNeeded = replacementFee.sub(tx.feeAmount)
38
+ if (walletAccountBalances[assetName].lt(extraEthNeeded)) return BumpType.NONE
43
39
 
44
40
  return BumpType.RBF
45
41
  }