@exodus/ethereum-lib 0.0.9 → 0.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 +3 -6
- package/src/abi/cdai.js +609 -0
- package/src/abi/dai.js +348 -0
- package/src/abi/index.js +7 -0
- package/src/constants.js +1 -0
- package/src/create-contract/erc20.js +77 -0
- package/src/create-contract/index.js +8 -0
- package/src/encode.js +36 -0
- package/src/fee-data/ethereum.js +11 -0
- package/src/fee-data/ethereumclassic.js +11 -0
- package/src/fee-data/index.js +2 -0
- package/src/index.js +8 -0
- package/src/unsigned-tx/create-and-sign-tx.js +13 -0
- package/src/unsigned-tx/create-unsigned-tx.js +62 -0
- package/src/unsigned-tx/index.js +4 -0
- package/src/unsigned-tx/parse-unsigned-tx.js +44 -0
- package/src/unsigned-tx/sign-unsigned-tx.js +19 -0
- package/src/utils.js +28 -0
- package/lib/abi/cdai.js +0 -900
- package/lib/abi/dai.js +0 -451
- package/lib/abi/index.js +0 -18
- package/lib/constants.js +0 -11
- package/lib/create-contract/erc20.js +0 -72
- package/lib/create-contract/index.js +0 -17
- package/lib/encode.js +0 -50
- package/lib/fee-data/ethereum.js +0 -16
- package/lib/fee-data/ethereumclassic.js +0 -16
- package/lib/fee-data/index.js +0 -23
- package/lib/index.js +0 -79
- package/lib/unsigned-tx/create-and-sign-tx.js +0 -17
- package/lib/unsigned-tx/create-unsigned-tx.js +0 -70
- package/lib/unsigned-tx/index.js +0 -39
- package/lib/unsigned-tx/parse-unsigned-tx.js +0 -69
- package/lib/unsigned-tx/sign-unsigned-tx.js +0 -25
- package/lib/utils.js +0 -47
package/lib/abi/dai.js
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = [{
|
|
8
|
-
inputs: [{
|
|
9
|
-
internalType: 'uint256',
|
|
10
|
-
name: 'chainId_',
|
|
11
|
-
type: 'uint256'
|
|
12
|
-
}],
|
|
13
|
-
payable: false,
|
|
14
|
-
stateMutability: 'nonpayable',
|
|
15
|
-
type: 'constructor'
|
|
16
|
-
}, {
|
|
17
|
-
anonymous: false,
|
|
18
|
-
inputs: [{
|
|
19
|
-
indexed: true,
|
|
20
|
-
internalType: 'address',
|
|
21
|
-
name: 'src',
|
|
22
|
-
type: 'address'
|
|
23
|
-
}, {
|
|
24
|
-
indexed: true,
|
|
25
|
-
internalType: 'address',
|
|
26
|
-
name: 'guy',
|
|
27
|
-
type: 'address'
|
|
28
|
-
}, {
|
|
29
|
-
indexed: false,
|
|
30
|
-
internalType: 'uint256',
|
|
31
|
-
name: 'wad',
|
|
32
|
-
type: 'uint256'
|
|
33
|
-
}],
|
|
34
|
-
name: 'Approval',
|
|
35
|
-
type: 'event'
|
|
36
|
-
}, {
|
|
37
|
-
anonymous: true,
|
|
38
|
-
inputs: [{
|
|
39
|
-
indexed: true,
|
|
40
|
-
internalType: 'bytes4',
|
|
41
|
-
name: 'sig',
|
|
42
|
-
type: 'bytes4'
|
|
43
|
-
}, {
|
|
44
|
-
indexed: true,
|
|
45
|
-
internalType: 'address',
|
|
46
|
-
name: 'usr',
|
|
47
|
-
type: 'address'
|
|
48
|
-
}, {
|
|
49
|
-
indexed: true,
|
|
50
|
-
internalType: 'bytes32',
|
|
51
|
-
name: 'arg1',
|
|
52
|
-
type: 'bytes32'
|
|
53
|
-
}, {
|
|
54
|
-
indexed: true,
|
|
55
|
-
internalType: 'bytes32',
|
|
56
|
-
name: 'arg2',
|
|
57
|
-
type: 'bytes32'
|
|
58
|
-
}, {
|
|
59
|
-
indexed: false,
|
|
60
|
-
internalType: 'bytes',
|
|
61
|
-
name: 'data',
|
|
62
|
-
type: 'bytes'
|
|
63
|
-
}],
|
|
64
|
-
name: 'LogNote',
|
|
65
|
-
type: 'event'
|
|
66
|
-
}, {
|
|
67
|
-
anonymous: false,
|
|
68
|
-
inputs: [{
|
|
69
|
-
indexed: true,
|
|
70
|
-
internalType: 'address',
|
|
71
|
-
name: 'src',
|
|
72
|
-
type: 'address'
|
|
73
|
-
}, {
|
|
74
|
-
indexed: true,
|
|
75
|
-
internalType: 'address',
|
|
76
|
-
name: 'dst',
|
|
77
|
-
type: 'address'
|
|
78
|
-
}, {
|
|
79
|
-
indexed: false,
|
|
80
|
-
internalType: 'uint256',
|
|
81
|
-
name: 'wad',
|
|
82
|
-
type: 'uint256'
|
|
83
|
-
}],
|
|
84
|
-
name: 'Transfer',
|
|
85
|
-
type: 'event'
|
|
86
|
-
}, {
|
|
87
|
-
constant: true,
|
|
88
|
-
inputs: [],
|
|
89
|
-
name: 'DOMAIN_SEPARATOR',
|
|
90
|
-
outputs: [{
|
|
91
|
-
internalType: 'bytes32',
|
|
92
|
-
name: '',
|
|
93
|
-
type: 'bytes32'
|
|
94
|
-
}],
|
|
95
|
-
payable: false,
|
|
96
|
-
stateMutability: 'view',
|
|
97
|
-
type: 'function'
|
|
98
|
-
}, {
|
|
99
|
-
constant: true,
|
|
100
|
-
inputs: [],
|
|
101
|
-
name: 'PERMIT_TYPEHASH',
|
|
102
|
-
outputs: [{
|
|
103
|
-
internalType: 'bytes32',
|
|
104
|
-
name: '',
|
|
105
|
-
type: 'bytes32'
|
|
106
|
-
}],
|
|
107
|
-
payable: false,
|
|
108
|
-
stateMutability: 'view',
|
|
109
|
-
type: 'function'
|
|
110
|
-
}, {
|
|
111
|
-
constant: true,
|
|
112
|
-
inputs: [{
|
|
113
|
-
internalType: 'address',
|
|
114
|
-
name: '',
|
|
115
|
-
type: 'address'
|
|
116
|
-
}, {
|
|
117
|
-
internalType: 'address',
|
|
118
|
-
name: '',
|
|
119
|
-
type: 'address'
|
|
120
|
-
}],
|
|
121
|
-
name: 'allowance',
|
|
122
|
-
outputs: [{
|
|
123
|
-
internalType: 'uint256',
|
|
124
|
-
name: '',
|
|
125
|
-
type: 'uint256'
|
|
126
|
-
}],
|
|
127
|
-
payable: false,
|
|
128
|
-
stateMutability: 'view',
|
|
129
|
-
type: 'function'
|
|
130
|
-
}, {
|
|
131
|
-
constant: false,
|
|
132
|
-
inputs: [{
|
|
133
|
-
internalType: 'address',
|
|
134
|
-
name: 'usr',
|
|
135
|
-
type: 'address'
|
|
136
|
-
}, {
|
|
137
|
-
internalType: 'uint256',
|
|
138
|
-
name: 'wad',
|
|
139
|
-
type: 'uint256'
|
|
140
|
-
}],
|
|
141
|
-
name: 'approve',
|
|
142
|
-
outputs: [{
|
|
143
|
-
internalType: 'bool',
|
|
144
|
-
name: '',
|
|
145
|
-
type: 'bool'
|
|
146
|
-
}],
|
|
147
|
-
payable: false,
|
|
148
|
-
stateMutability: 'nonpayable',
|
|
149
|
-
type: 'function'
|
|
150
|
-
}, {
|
|
151
|
-
constant: true,
|
|
152
|
-
inputs: [{
|
|
153
|
-
internalType: 'address',
|
|
154
|
-
name: '',
|
|
155
|
-
type: 'address'
|
|
156
|
-
}],
|
|
157
|
-
name: 'balanceOf',
|
|
158
|
-
outputs: [{
|
|
159
|
-
internalType: 'uint256',
|
|
160
|
-
name: '',
|
|
161
|
-
type: 'uint256'
|
|
162
|
-
}],
|
|
163
|
-
payable: false,
|
|
164
|
-
stateMutability: 'view',
|
|
165
|
-
type: 'function'
|
|
166
|
-
}, {
|
|
167
|
-
constant: false,
|
|
168
|
-
inputs: [{
|
|
169
|
-
internalType: 'address',
|
|
170
|
-
name: 'usr',
|
|
171
|
-
type: 'address'
|
|
172
|
-
}, {
|
|
173
|
-
internalType: 'uint256',
|
|
174
|
-
name: 'wad',
|
|
175
|
-
type: 'uint256'
|
|
176
|
-
}],
|
|
177
|
-
name: 'burn',
|
|
178
|
-
outputs: [],
|
|
179
|
-
payable: false,
|
|
180
|
-
stateMutability: 'nonpayable',
|
|
181
|
-
type: 'function'
|
|
182
|
-
}, {
|
|
183
|
-
constant: true,
|
|
184
|
-
inputs: [],
|
|
185
|
-
name: 'decimals',
|
|
186
|
-
outputs: [{
|
|
187
|
-
internalType: 'uint8',
|
|
188
|
-
name: '',
|
|
189
|
-
type: 'uint8'
|
|
190
|
-
}],
|
|
191
|
-
payable: false,
|
|
192
|
-
stateMutability: 'view',
|
|
193
|
-
type: 'function'
|
|
194
|
-
}, {
|
|
195
|
-
constant: false,
|
|
196
|
-
inputs: [{
|
|
197
|
-
internalType: 'address',
|
|
198
|
-
name: 'guy',
|
|
199
|
-
type: 'address'
|
|
200
|
-
}],
|
|
201
|
-
name: 'deny',
|
|
202
|
-
outputs: [],
|
|
203
|
-
payable: false,
|
|
204
|
-
stateMutability: 'nonpayable',
|
|
205
|
-
type: 'function'
|
|
206
|
-
}, {
|
|
207
|
-
constant: false,
|
|
208
|
-
inputs: [{
|
|
209
|
-
internalType: 'address',
|
|
210
|
-
name: 'usr',
|
|
211
|
-
type: 'address'
|
|
212
|
-
}, {
|
|
213
|
-
internalType: 'uint256',
|
|
214
|
-
name: 'wad',
|
|
215
|
-
type: 'uint256'
|
|
216
|
-
}],
|
|
217
|
-
name: 'mint',
|
|
218
|
-
outputs: [],
|
|
219
|
-
payable: false,
|
|
220
|
-
stateMutability: 'nonpayable',
|
|
221
|
-
type: 'function'
|
|
222
|
-
}, {
|
|
223
|
-
constant: false,
|
|
224
|
-
inputs: [{
|
|
225
|
-
internalType: 'address',
|
|
226
|
-
name: 'src',
|
|
227
|
-
type: 'address'
|
|
228
|
-
}, {
|
|
229
|
-
internalType: 'address',
|
|
230
|
-
name: 'dst',
|
|
231
|
-
type: 'address'
|
|
232
|
-
}, {
|
|
233
|
-
internalType: 'uint256',
|
|
234
|
-
name: 'wad',
|
|
235
|
-
type: 'uint256'
|
|
236
|
-
}],
|
|
237
|
-
name: 'move',
|
|
238
|
-
outputs: [],
|
|
239
|
-
payable: false,
|
|
240
|
-
stateMutability: 'nonpayable',
|
|
241
|
-
type: 'function'
|
|
242
|
-
}, {
|
|
243
|
-
constant: true,
|
|
244
|
-
inputs: [],
|
|
245
|
-
name: 'name',
|
|
246
|
-
outputs: [{
|
|
247
|
-
internalType: 'string',
|
|
248
|
-
name: '',
|
|
249
|
-
type: 'string'
|
|
250
|
-
}],
|
|
251
|
-
payable: false,
|
|
252
|
-
stateMutability: 'view',
|
|
253
|
-
type: 'function'
|
|
254
|
-
}, {
|
|
255
|
-
constant: true,
|
|
256
|
-
inputs: [{
|
|
257
|
-
internalType: 'address',
|
|
258
|
-
name: '',
|
|
259
|
-
type: 'address'
|
|
260
|
-
}],
|
|
261
|
-
name: 'nonces',
|
|
262
|
-
outputs: [{
|
|
263
|
-
internalType: 'uint256',
|
|
264
|
-
name: '',
|
|
265
|
-
type: 'uint256'
|
|
266
|
-
}],
|
|
267
|
-
payable: false,
|
|
268
|
-
stateMutability: 'view',
|
|
269
|
-
type: 'function'
|
|
270
|
-
}, {
|
|
271
|
-
constant: false,
|
|
272
|
-
inputs: [{
|
|
273
|
-
internalType: 'address',
|
|
274
|
-
name: 'holder',
|
|
275
|
-
type: 'address'
|
|
276
|
-
}, {
|
|
277
|
-
internalType: 'address',
|
|
278
|
-
name: 'spender',
|
|
279
|
-
type: 'address'
|
|
280
|
-
}, {
|
|
281
|
-
internalType: 'uint256',
|
|
282
|
-
name: 'nonce',
|
|
283
|
-
type: 'uint256'
|
|
284
|
-
}, {
|
|
285
|
-
internalType: 'uint256',
|
|
286
|
-
name: 'expiry',
|
|
287
|
-
type: 'uint256'
|
|
288
|
-
}, {
|
|
289
|
-
internalType: 'bool',
|
|
290
|
-
name: 'allowed',
|
|
291
|
-
type: 'bool'
|
|
292
|
-
}, {
|
|
293
|
-
internalType: 'uint8',
|
|
294
|
-
name: 'v',
|
|
295
|
-
type: 'uint8'
|
|
296
|
-
}, {
|
|
297
|
-
internalType: 'bytes32',
|
|
298
|
-
name: 'r',
|
|
299
|
-
type: 'bytes32'
|
|
300
|
-
}, {
|
|
301
|
-
internalType: 'bytes32',
|
|
302
|
-
name: 's',
|
|
303
|
-
type: 'bytes32'
|
|
304
|
-
}],
|
|
305
|
-
name: 'permit',
|
|
306
|
-
outputs: [],
|
|
307
|
-
payable: false,
|
|
308
|
-
stateMutability: 'nonpayable',
|
|
309
|
-
type: 'function'
|
|
310
|
-
}, {
|
|
311
|
-
constant: false,
|
|
312
|
-
inputs: [{
|
|
313
|
-
internalType: 'address',
|
|
314
|
-
name: 'usr',
|
|
315
|
-
type: 'address'
|
|
316
|
-
}, {
|
|
317
|
-
internalType: 'uint256',
|
|
318
|
-
name: 'wad',
|
|
319
|
-
type: 'uint256'
|
|
320
|
-
}],
|
|
321
|
-
name: 'pull',
|
|
322
|
-
outputs: [],
|
|
323
|
-
payable: false,
|
|
324
|
-
stateMutability: 'nonpayable',
|
|
325
|
-
type: 'function'
|
|
326
|
-
}, {
|
|
327
|
-
constant: false,
|
|
328
|
-
inputs: [{
|
|
329
|
-
internalType: 'address',
|
|
330
|
-
name: 'usr',
|
|
331
|
-
type: 'address'
|
|
332
|
-
}, {
|
|
333
|
-
internalType: 'uint256',
|
|
334
|
-
name: 'wad',
|
|
335
|
-
type: 'uint256'
|
|
336
|
-
}],
|
|
337
|
-
name: 'push',
|
|
338
|
-
outputs: [],
|
|
339
|
-
payable: false,
|
|
340
|
-
stateMutability: 'nonpayable',
|
|
341
|
-
type: 'function'
|
|
342
|
-
}, {
|
|
343
|
-
constant: false,
|
|
344
|
-
inputs: [{
|
|
345
|
-
internalType: 'address',
|
|
346
|
-
name: 'guy',
|
|
347
|
-
type: 'address'
|
|
348
|
-
}],
|
|
349
|
-
name: 'rely',
|
|
350
|
-
outputs: [],
|
|
351
|
-
payable: false,
|
|
352
|
-
stateMutability: 'nonpayable',
|
|
353
|
-
type: 'function'
|
|
354
|
-
}, {
|
|
355
|
-
constant: true,
|
|
356
|
-
inputs: [],
|
|
357
|
-
name: 'symbol',
|
|
358
|
-
outputs: [{
|
|
359
|
-
internalType: 'string',
|
|
360
|
-
name: '',
|
|
361
|
-
type: 'string'
|
|
362
|
-
}],
|
|
363
|
-
payable: false,
|
|
364
|
-
stateMutability: 'view',
|
|
365
|
-
type: 'function'
|
|
366
|
-
}, {
|
|
367
|
-
constant: true,
|
|
368
|
-
inputs: [],
|
|
369
|
-
name: 'totalSupply',
|
|
370
|
-
outputs: [{
|
|
371
|
-
internalType: 'uint256',
|
|
372
|
-
name: '',
|
|
373
|
-
type: 'uint256'
|
|
374
|
-
}],
|
|
375
|
-
payable: false,
|
|
376
|
-
stateMutability: 'view',
|
|
377
|
-
type: 'function'
|
|
378
|
-
}, {
|
|
379
|
-
constant: false,
|
|
380
|
-
inputs: [{
|
|
381
|
-
internalType: 'address',
|
|
382
|
-
name: 'dst',
|
|
383
|
-
type: 'address'
|
|
384
|
-
}, {
|
|
385
|
-
internalType: 'uint256',
|
|
386
|
-
name: 'wad',
|
|
387
|
-
type: 'uint256'
|
|
388
|
-
}],
|
|
389
|
-
name: 'transfer',
|
|
390
|
-
outputs: [{
|
|
391
|
-
internalType: 'bool',
|
|
392
|
-
name: '',
|
|
393
|
-
type: 'bool'
|
|
394
|
-
}],
|
|
395
|
-
payable: false,
|
|
396
|
-
stateMutability: 'nonpayable',
|
|
397
|
-
type: 'function'
|
|
398
|
-
}, {
|
|
399
|
-
constant: false,
|
|
400
|
-
inputs: [{
|
|
401
|
-
internalType: 'address',
|
|
402
|
-
name: 'src',
|
|
403
|
-
type: 'address'
|
|
404
|
-
}, {
|
|
405
|
-
internalType: 'address',
|
|
406
|
-
name: 'dst',
|
|
407
|
-
type: 'address'
|
|
408
|
-
}, {
|
|
409
|
-
internalType: 'uint256',
|
|
410
|
-
name: 'wad',
|
|
411
|
-
type: 'uint256'
|
|
412
|
-
}],
|
|
413
|
-
name: 'transferFrom',
|
|
414
|
-
outputs: [{
|
|
415
|
-
internalType: 'bool',
|
|
416
|
-
name: '',
|
|
417
|
-
type: 'bool'
|
|
418
|
-
}],
|
|
419
|
-
payable: false,
|
|
420
|
-
stateMutability: 'nonpayable',
|
|
421
|
-
type: 'function'
|
|
422
|
-
}, {
|
|
423
|
-
constant: true,
|
|
424
|
-
inputs: [],
|
|
425
|
-
name: 'version',
|
|
426
|
-
outputs: [{
|
|
427
|
-
internalType: 'string',
|
|
428
|
-
name: '',
|
|
429
|
-
type: 'string'
|
|
430
|
-
}],
|
|
431
|
-
payable: false,
|
|
432
|
-
stateMutability: 'view',
|
|
433
|
-
type: 'function'
|
|
434
|
-
}, {
|
|
435
|
-
constant: true,
|
|
436
|
-
inputs: [{
|
|
437
|
-
internalType: 'address',
|
|
438
|
-
name: '',
|
|
439
|
-
type: 'address'
|
|
440
|
-
}],
|
|
441
|
-
name: 'wards',
|
|
442
|
-
outputs: [{
|
|
443
|
-
internalType: 'uint256',
|
|
444
|
-
name: '',
|
|
445
|
-
type: 'uint256'
|
|
446
|
-
}],
|
|
447
|
-
payable: false,
|
|
448
|
-
stateMutability: 'view',
|
|
449
|
-
type: 'function'
|
|
450
|
-
}];
|
|
451
|
-
exports.default = _default;
|
package/lib/abi/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _cdai = _interopRequireDefault(require("./cdai"));
|
|
9
|
-
|
|
10
|
-
var _dai = _interopRequireDefault(require("./dai"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
var _default = {
|
|
15
|
-
cdai: _cdai.default,
|
|
16
|
-
dai: _dai.default
|
|
17
|
-
};
|
|
18
|
-
exports.default = _default;
|
package/lib/constants.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = createContract;
|
|
7
|
-
|
|
8
|
-
var _ethereumjsUtil = _interopRequireDefault(require("ethereumjs-util"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
// TODO: migrate to using solidity-contract
|
|
13
|
-
function createContract(addresses, currency) {
|
|
14
|
-
// First 4 bytes of Keccak256('transfer(address,uint256)')
|
|
15
|
-
// const TRANSFER_METHOD_ID = ethUtil.bufferToHex(ethUtil.sha3('transfer(address,uint256)').slice(0, 4))
|
|
16
|
-
const TRANSFER_METHOD_ID = '0xa9059cbb'; // Keccak256('Transfer(address,address,uint256)')
|
|
17
|
-
// const TRANSFER_EVENT_ID = ethUtil.bufferToHex(ethUtil.sha3('Transfer(address,address,uint256)'))
|
|
18
|
-
|
|
19
|
-
const TRANSFER_EVENT_ID = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
|
|
20
|
-
const transfer = {
|
|
21
|
-
METHOD_ID: TRANSFER_METHOD_ID,
|
|
22
|
-
EVENT_ID: TRANSFER_EVENT_ID,
|
|
23
|
-
|
|
24
|
-
build(to, bufAmount) {
|
|
25
|
-
return Buffer.concat([_ethereumjsUtil.default.toBuffer(TRANSFER_METHOD_ID), _ethereumjsUtil.default.zeros(12), _ethereumjsUtil.default.toBuffer(to), _ethereumjsUtil.default.zeros(32 - bufAmount.length), bufAmount]);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
test(data) {
|
|
29
|
-
return _ethereumjsUtil.default.bufferToHex(data.slice(0, 4)) === TRANSFER_METHOD_ID;
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
parse(data) {
|
|
33
|
-
if (!transfer.test(data)) throw new Error('It is not transfer data');
|
|
34
|
-
return {
|
|
35
|
-
to: _ethereumjsUtil.default.bufferToHex(data.slice(16, 36)),
|
|
36
|
-
amount: currency.baseUnit(_ethereumjsUtil.default.bufferToHex(data.slice(36, 68)))
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}; // ethUtil.bufferToHex(ethUtil.sha3('approve(address,uint256)').slice(0, 4))
|
|
41
|
-
|
|
42
|
-
const APPROVE_METHOD_ID = '0x095ea7b3'; // TODO: not verified:
|
|
43
|
-
// ethUtil.bufferToHex(ethUtil.sha3('Approve(address,address,uint256)'))
|
|
44
|
-
|
|
45
|
-
const APPROVE_EVENT_ID = '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925';
|
|
46
|
-
const approve = {
|
|
47
|
-
METHOD_ID: APPROVE_METHOD_ID,
|
|
48
|
-
EVENT_ID: APPROVE_EVENT_ID,
|
|
49
|
-
|
|
50
|
-
build(address, bufAmount) {
|
|
51
|
-
return Buffer.concat([_ethereumjsUtil.default.toBuffer(APPROVE_METHOD_ID), _ethereumjsUtil.default.zeros(12), _ethereumjsUtil.default.toBuffer(address), _ethereumjsUtil.default.zeros(32 - bufAmount.length), bufAmount]);
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
test(data) {
|
|
55
|
-
return _ethereumjsUtil.default.bufferToHex(data.slice(0, 4)) === APPROVE_METHOD_ID;
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
parse(data) {
|
|
59
|
-
if (!approve.test(data)) throw new Error('It is not approve data');
|
|
60
|
-
return {
|
|
61
|
-
address: _ethereumjsUtil.default.bufferToHex(data.slice(16, 36)),
|
|
62
|
-
amount: currency.baseUnit(_ethereumjsUtil.default.bufferToHex(data.slice(36, 68)))
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
addresses,
|
|
69
|
-
transfer,
|
|
70
|
-
approve
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = createContract;
|
|
7
|
-
|
|
8
|
-
var _erc = _interopRequireDefault(require("./erc20"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
function createContract(addresses, currency, assetName) {
|
|
13
|
-
switch (assetName) {
|
|
14
|
-
default:
|
|
15
|
-
return (0, _erc.default)(addresses, currency);
|
|
16
|
-
}
|
|
17
|
-
}
|
package/lib/encode.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validate = validate;
|
|
7
|
-
exports.hasChecksum = hasChecksum;
|
|
8
|
-
exports.encodePrivate = encodePrivate;
|
|
9
|
-
exports.encodePublic = encodePublic;
|
|
10
|
-
exports.isValidPrivate = isValidPrivate;
|
|
11
|
-
exports.encodePublicFromPrivate = encodePublicFromPrivate;
|
|
12
|
-
|
|
13
|
-
var _ethereumjsUtil = _interopRequireDefault(require("ethereumjs-util"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function validate(address) {
|
|
18
|
-
if (typeof address !== 'string') return false; // https://github.com/ethereumjs/ethereumjs-util/issues/54
|
|
19
|
-
|
|
20
|
-
if (address.slice(0, 2) !== '0x' || address.length !== 42) return false;
|
|
21
|
-
if (!hasChecksum(address)) return true;
|
|
22
|
-
return _ethereumjsUtil.default.isValidChecksumAddress(address);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function hasChecksum(address) {
|
|
26
|
-
if (/^0x[0-9A-F]{40}$/.test(address) || /^0x[0-9a-f]{40}$/.test(address)) return false;
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function encodePrivate(privKey) {
|
|
31
|
-
return '0x' + privKey.toString('hex');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function encodePublic(compressedPubKey) {
|
|
35
|
-
const hash160bits = _ethereumjsUtil.default.publicToAddress(compressedPubKey, true);
|
|
36
|
-
|
|
37
|
-
return _ethereumjsUtil.default.toChecksumAddress(hash160bits.toString('hex'));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function isValidPrivate(privateKey) {
|
|
41
|
-
if (privateKey.length !== 32 || !_ethereumjsUtil.default.isValidPrivate(privateKey)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function encodePublicFromPrivate(privateKey) {
|
|
49
|
-
return _ethereumjsUtil.default.toChecksumAddress(_ethereumjsUtil.default.privateToAddress(privateKey).toString('hex'));
|
|
50
|
-
}
|
package/lib/fee-data/ethereum.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _assetLib = require("@exodus/asset-lib");
|
|
9
|
-
|
|
10
|
-
var _default = new _assetLib.FeeData({
|
|
11
|
-
gasPrice: '20 Gwei',
|
|
12
|
-
max: '250 Gwei',
|
|
13
|
-
min: '1 Gwei'
|
|
14
|
-
}, 'gasPrice', 'ethereum');
|
|
15
|
-
|
|
16
|
-
exports.default = _default;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _assetLib = require("@exodus/asset-lib");
|
|
9
|
-
|
|
10
|
-
var _default = new _assetLib.FeeData({
|
|
11
|
-
gasPrice: '20 Gwei',
|
|
12
|
-
max: '250 Gwei',
|
|
13
|
-
min: '1 Gwei'
|
|
14
|
-
}, 'gasPrice', 'ethereumclassic');
|
|
15
|
-
|
|
16
|
-
exports.default = _default;
|
package/lib/fee-data/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "ethereum", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _ethereum.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ethereumclassic", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _ethereumclassic.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _ethereum = _interopRequireDefault(require("./ethereum"));
|
|
20
|
-
|
|
21
|
-
var _ethereumclassic = _interopRequireDefault(require("./ethereumclassic"));
|
|
22
|
-
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|