essential-eth 0.9.0 → 0.9.1-next.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/dist/cjs/classes/Contract.js +66 -307
- package/dist/cjs/classes/test/Contract/crv-abi.js +256 -252
- package/dist/cjs/classes/test/Contract/ens-abi.d.ts +1 -1
- package/dist/cjs/classes/test/Contract/ens-abi.js +212 -497
- package/dist/cjs/classes/test/Contract/fei-abi.js +284 -605
- package/dist/cjs/classes/test/Contract/foo-abi.d.ts +1 -1
- package/dist/cjs/classes/test/Contract/foo-abi.js +21 -44
- package/dist/cjs/classes/test/Contract/uniswap-abi.js +68 -64
- package/dist/cjs/classes/utils/clean-block.js +30 -52
- package/dist/cjs/classes/utils/clean-log.js +20 -42
- package/dist/cjs/classes/utils/clean-transaction-receipt.js +30 -51
- package/dist/cjs/classes/utils/clean-transaction.js +30 -52
- package/dist/cjs/classes/utils/encode-decode-transaction.js +107 -148
- package/dist/cjs/classes/utils/fetchers.d.ts +8 -2
- package/dist/cjs/classes/utils/fetchers.js +52 -166
- package/dist/cjs/classes/utils/hex-to-decimal.js +6 -1
- package/dist/cjs/classes/utils/prepare-transaction.js +36 -59
- package/dist/cjs/index.d.ts +21 -22
- package/dist/cjs/index.js +56 -26
- package/dist/cjs/index.umd.js +1 -1
- package/dist/cjs/index.umd.js.map +1 -1
- package/dist/cjs/logger/logger.js +23 -79
- package/dist/cjs/logger/package-version.d.ts +1 -1
- package/dist/cjs/logger/package-version.js +4 -1
- package/dist/cjs/providers/AlchemyProvider.js +9 -82
- package/dist/cjs/providers/BaseProvider.js +511 -882
- package/dist/cjs/providers/FallthroughProvider.js +46 -123
- package/dist/cjs/providers/JsonRpcProvider.js +28 -93
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +152 -0
- package/dist/cjs/providers/test/mock-of.js +6 -8
- package/dist/cjs/providers/test/rpc-urls.d.ts +1 -0
- package/dist/cjs/providers/test/rpc-urls.js +23 -14
- package/dist/cjs/providers/utils/chains-info.d.ts +5 -448
- package/dist/cjs/providers/utils/chains-info.js +16 -1345
- package/dist/cjs/shared/tiny-big/helpers.js +42 -93
- package/dist/cjs/shared/tiny-big/tiny-big.js +72 -161
- package/dist/cjs/shared/validate-type.d.ts +1 -1
- package/dist/cjs/shared/validate-type.js +7 -7
- package/dist/cjs/types/Block.types.d.ts +3 -3
- package/dist/cjs/types/Block.types.js +2 -1
- package/dist/cjs/types/Contract.types.d.ts +4 -4
- package/dist/cjs/types/Contract.types.js +2 -1
- package/dist/cjs/types/FeeData.types.js +2 -1
- package/dist/cjs/types/Filter.types.js +2 -1
- package/dist/cjs/types/Network.types.js +2 -3
- package/dist/cjs/types/Transaction.types.d.ts +5 -5
- package/dist/cjs/types/Transaction.types.js +2 -1
- package/dist/cjs/utils/bytes.d.ts +4 -4
- package/dist/cjs/utils/bytes.js +318 -286
- package/dist/cjs/utils/compute-address.js +15 -8
- package/dist/cjs/utils/compute-public-key.js +10 -5
- package/dist/cjs/utils/ether-to-gwei.js +11 -10
- package/dist/cjs/utils/ether-to-wei.js +11 -10
- package/dist/cjs/utils/gwei-to-ether.js +11 -10
- package/dist/cjs/utils/hash-message.js +16 -11
- package/dist/cjs/utils/is-address.js +12 -8
- package/dist/cjs/utils/keccak256.js +14 -8
- package/dist/cjs/utils/solidity-keccak256.js +60 -49
- package/dist/cjs/utils/split-signature.js +73 -55
- package/dist/cjs/utils/to-checksum-address.js +20 -15
- package/dist/cjs/utils/to-utf8-bytes.js +6 -1
- package/dist/cjs/utils/wei-to-ether.js +15 -13
- package/dist/esm/classes/test/Contract/ens-abi.d.ts +1 -1
- package/dist/esm/classes/test/Contract/foo-abi.d.ts +1 -1
- package/dist/esm/classes/utils/fetchers.d.ts +8 -2
- package/dist/esm/classes/utils/fetchers.js +6 -3
- package/dist/esm/index.d.ts +21 -22
- package/dist/esm/index.js +16 -17
- package/dist/esm/logger/package-version.d.ts +1 -1
- package/dist/esm/logger/package-version.js +1 -1
- package/dist/esm/providers/FallthroughProvider.js +3 -3
- package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
- package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +142 -0
- package/dist/esm/providers/test/rpc-urls.d.ts +1 -0
- package/dist/esm/providers/test/rpc-urls.js +7 -4
- package/dist/esm/providers/utils/chains-info.d.ts +5 -448
- package/dist/esm/providers/utils/chains-info.js +13 -1344
- package/dist/esm/shared/validate-type.d.ts +1 -1
- package/dist/esm/types/Block.types.d.ts +3 -3
- package/dist/esm/types/Contract.types.d.ts +4 -4
- package/dist/esm/types/Transaction.types.d.ts +5 -5
- package/dist/esm/utils/bytes.d.ts +4 -4
- package/package.json +23 -51
- package/readme.md +15 -38
- package/dist/cjs/classes/test/Contract/crv.test.js +0 -690
- package/dist/cjs/classes/test/Contract/ens.test.js +0 -217
- package/dist/cjs/classes/test/Contract/fei.test.js +0 -224
- package/dist/cjs/classes/test/Contract/foo.test.js +0 -33
- package/dist/cjs/classes/test/Contract/uni.test.js +0 -387
- package/dist/cjs/providers/test/fallthrough-provider/get-gas-price.test.js +0 -228
- package/dist/cjs/providers/test/get-transaction-count.test.js +0 -276
- package/dist/cjs/providers/test/json-rpc-provider/call.test.js +0 -436
- package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +0 -288
- package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +0 -261
- package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +0 -159
- package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +0 -477
- package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +0 -311
- package/dist/cjs/providers/test/json-rpc-provider/get-fee-data.test.js +0 -212
- package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +0 -164
- package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +0 -361
- package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +0 -274
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +0 -301
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +0 -307
- package/dist/cjs/providers/test/test-alchemy-provider.test.js +0 -151
- package/dist/cjs/shared/tiny-big/helpers.test.js +0 -29
- package/dist/cjs/shared/tiny-big/tiny-big.test.js +0 -34
- package/dist/cjs/utils/tests/bytes/arrayify.test.js +0 -40
- package/dist/cjs/utils/tests/bytes/concat.test.js +0 -15
- package/dist/cjs/utils/tests/bytes/hex-concat.test.js +0 -63
- package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +0 -49
- package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +0 -52
- package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +0 -58
- package/dist/cjs/utils/tests/bytes/hex-value.test.js +0 -85
- package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +0 -62
- package/dist/cjs/utils/tests/bytes/hexlify.test.js +0 -62
- package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +0 -69
- package/dist/cjs/utils/tests/bytes/is-bytes.test.js +0 -33
- package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +0 -88
- package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +0 -57
- package/dist/cjs/utils/tests/bytes/zero-pad.test.js +0 -80
- package/dist/cjs/utils/tests/compute-address.test.js +0 -27
- package/dist/cjs/utils/tests/compute-public-key.test.js +0 -15
- package/dist/cjs/utils/tests/ether-to-gwei.test.js +0 -26
- package/dist/cjs/utils/tests/ether-to-wei.test.js +0 -44
- package/dist/cjs/utils/tests/gwei-to-ether.test.js +0 -28
- package/dist/cjs/utils/tests/hash-message.test.js +0 -21
- package/dist/cjs/utils/tests/is-address.test.js +0 -55
- package/dist/cjs/utils/tests/keccak256.test.js +0 -97
- package/dist/cjs/utils/tests/solidity-keccak256.test.js +0 -310
- package/dist/cjs/utils/tests/split-signature.test.js +0 -25
- package/dist/cjs/utils/tests/to-checksum-address.test.js +0 -42
- package/dist/cjs/utils/tests/to-utf8-bytes.test.js +0 -14
- package/dist/cjs/utils/tests/wei-to-ether.test.js +0 -51
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { keccak256 } from "./../keccak256";
|
|
3
|
-
import { toUtf8Bytes } from "./../to-utf8-bytes";
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param inputs
|
|
7
|
-
*/ function testKeccak256(inputs) {
|
|
8
|
-
inputs.forEach(function(input) {
|
|
9
|
-
expect(keccak256(input)).toBe(utils.keccak256(input));
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe("keccak256", function() {
|
|
13
|
-
it("should match ethers.js hex strings", function() {
|
|
14
|
-
var inputs = [
|
|
15
|
-
"0x4d7F1790644Af787933c9fF0e2cff9a9B4299Abb",
|
|
16
|
-
"0xB5503a7db1A9105cd459D99153e69a76a8EF1530",
|
|
17
|
-
"0xaa0fc255b079e775f9307e5cfec472a555cebc3a"
|
|
18
|
-
];
|
|
19
|
-
testKeccak256(inputs);
|
|
20
|
-
});
|
|
21
|
-
it("should match ethers.js bytes", function() {
|
|
22
|
-
var inputs = [
|
|
23
|
-
[
|
|
24
|
-
2,
|
|
25
|
-
182,
|
|
26
|
-
145
|
|
27
|
-
],
|
|
28
|
-
[
|
|
29
|
-
0,
|
|
30
|
-
16,
|
|
31
|
-
255
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
0x12,
|
|
35
|
-
0x34
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
0x12
|
|
39
|
-
]
|
|
40
|
-
];
|
|
41
|
-
testKeccak256(inputs);
|
|
42
|
-
});
|
|
43
|
-
it("should match ethers.js numbers", function() {
|
|
44
|
-
var inputs = [
|
|
45
|
-
23874234,
|
|
46
|
-
123346,
|
|
47
|
-
12395712
|
|
48
|
-
].map(function(n) {
|
|
49
|
-
return toUtf8Bytes(n.toString());
|
|
50
|
-
});
|
|
51
|
-
testKeccak256(inputs);
|
|
52
|
-
});
|
|
53
|
-
it("should match ethers.js strings", function() {
|
|
54
|
-
var inputs = [
|
|
55
|
-
"essential-eth",
|
|
56
|
-
"firstText",
|
|
57
|
-
"secondString",
|
|
58
|
-
"example1",
|
|
59
|
-
"2934823",
|
|
60
|
-
"true"
|
|
61
|
-
].map(toUtf8Bytes);
|
|
62
|
-
testKeccak256(inputs);
|
|
63
|
-
});
|
|
64
|
-
// it('should match ethers.js bytes (dynamic size) & BytesLike', () => {
|
|
65
|
-
// const inputs = [
|
|
66
|
-
// [115, 101, 99, 114, 101, 116],
|
|
67
|
-
// ['0x62797465734c696b65'],
|
|
68
|
-
// '0x657373656e7469616c2d657468',
|
|
69
|
-
// [115, 109, 97, 108, 108, 101, 115, 116],
|
|
70
|
-
// ];
|
|
71
|
-
// testKeccak256(inputs);
|
|
72
|
-
// });
|
|
73
|
-
// it('should match ethers.js bytes (static size)', () => {
|
|
74
|
-
// const inputs = [
|
|
75
|
-
// { types: ['bytes4'], values: [[116, 101, 115, 116]] },
|
|
76
|
-
// {
|
|
77
|
-
// types: ['bytes13', 'bytes1', 'bytes2', 'bytes5', 'bytes1'],
|
|
78
|
-
// values: [
|
|
79
|
-
// [101, 115, 115, 101, 110, 116, 105, 97, 108, 45, 101, 116, 104],
|
|
80
|
-
// [32],
|
|
81
|
-
// [105, 115],
|
|
82
|
-
// [103, 114, 101, 97, 116],
|
|
83
|
-
// [33],
|
|
84
|
-
// ],
|
|
85
|
-
// },
|
|
86
|
-
// ];
|
|
87
|
-
// testKeccak256(inputs);
|
|
88
|
-
// });
|
|
89
|
-
// it('should match ethers.js (signed and unsigned) integers', () => {
|
|
90
|
-
// const inputs = [
|
|
91
|
-
// { types: ['int16'], values: [-1] },
|
|
92
|
-
// { types: ['uint48'], values: [12] },
|
|
93
|
-
// { types: ['int16', 'uint48'], values: [-1, 12] },
|
|
94
|
-
// ];
|
|
95
|
-
// testKeccak256(inputs);
|
|
96
|
-
// });
|
|
97
|
-
});
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { solidityKeccak256 } from "../../index";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param inputs
|
|
6
|
-
*/ function testSolidityKeccak256(inputs) {
|
|
7
|
-
inputs.forEach(function(input) {
|
|
8
|
-
expect(solidityKeccak256(input.types, input.values)).toBe(utils.solidityKeccak256(input.types, input.values));
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
describe("solidityKeccak256", function() {
|
|
12
|
-
it("should match ethers.js addresses", function() {
|
|
13
|
-
var inputs = [
|
|
14
|
-
{
|
|
15
|
-
types: [
|
|
16
|
-
"address"
|
|
17
|
-
],
|
|
18
|
-
values: [
|
|
19
|
-
"0x4d7F1790644Af787933c9fF0e2cff9a9B4299Abb"
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
types: [
|
|
24
|
-
"address",
|
|
25
|
-
"address"
|
|
26
|
-
],
|
|
27
|
-
values: [
|
|
28
|
-
"0xB5503a7db1A9105cd459D99153e69a76a8EF1530",
|
|
29
|
-
"0xaa0fc255b079e775f9307e5cfec472a555cebc3a"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
testSolidityKeccak256(inputs);
|
|
34
|
-
});
|
|
35
|
-
it("should match ethers.js strings", function() {
|
|
36
|
-
var inputs = [
|
|
37
|
-
{
|
|
38
|
-
types: [
|
|
39
|
-
"string"
|
|
40
|
-
],
|
|
41
|
-
values: [
|
|
42
|
-
"essential-eth"
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
types: [
|
|
47
|
-
"string",
|
|
48
|
-
"string"
|
|
49
|
-
],
|
|
50
|
-
values: [
|
|
51
|
-
"firstText",
|
|
52
|
-
"secondString"
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
types: [
|
|
57
|
-
"string",
|
|
58
|
-
"string",
|
|
59
|
-
"string"
|
|
60
|
-
],
|
|
61
|
-
values: [
|
|
62
|
-
"example1",
|
|
63
|
-
"2934823",
|
|
64
|
-
"true"
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
testSolidityKeccak256(inputs);
|
|
69
|
-
});
|
|
70
|
-
it("should match ethers.js bytes (dynamic size) & BytesLike", function() {
|
|
71
|
-
var inputs = [
|
|
72
|
-
{
|
|
73
|
-
types: [
|
|
74
|
-
"bytes"
|
|
75
|
-
],
|
|
76
|
-
values: [
|
|
77
|
-
[
|
|
78
|
-
115,
|
|
79
|
-
101,
|
|
80
|
-
99,
|
|
81
|
-
114,
|
|
82
|
-
101,
|
|
83
|
-
116
|
|
84
|
-
]
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
types: [
|
|
89
|
-
"bytes"
|
|
90
|
-
],
|
|
91
|
-
values: [
|
|
92
|
-
"0x62797465734c696b65"
|
|
93
|
-
]
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
types: [
|
|
97
|
-
"bytes",
|
|
98
|
-
"bytes"
|
|
99
|
-
],
|
|
100
|
-
values: [
|
|
101
|
-
"0x657373656e7469616c2d657468",
|
|
102
|
-
[
|
|
103
|
-
115,
|
|
104
|
-
109,
|
|
105
|
-
97,
|
|
106
|
-
108,
|
|
107
|
-
108,
|
|
108
|
-
101,
|
|
109
|
-
115,
|
|
110
|
-
116
|
|
111
|
-
]
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
];
|
|
115
|
-
testSolidityKeccak256(inputs);
|
|
116
|
-
});
|
|
117
|
-
it("should match ethers.js bytes (static size)", function() {
|
|
118
|
-
var inputs = [
|
|
119
|
-
{
|
|
120
|
-
types: [
|
|
121
|
-
"bytes4"
|
|
122
|
-
],
|
|
123
|
-
values: [
|
|
124
|
-
[
|
|
125
|
-
116,
|
|
126
|
-
101,
|
|
127
|
-
115,
|
|
128
|
-
116
|
|
129
|
-
]
|
|
130
|
-
]
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
types: [
|
|
134
|
-
"bytes13",
|
|
135
|
-
"bytes1",
|
|
136
|
-
"bytes2",
|
|
137
|
-
"bytes5",
|
|
138
|
-
"bytes1"
|
|
139
|
-
],
|
|
140
|
-
values: [
|
|
141
|
-
[
|
|
142
|
-
101,
|
|
143
|
-
115,
|
|
144
|
-
115,
|
|
145
|
-
101,
|
|
146
|
-
110,
|
|
147
|
-
116,
|
|
148
|
-
105,
|
|
149
|
-
97,
|
|
150
|
-
108,
|
|
151
|
-
45,
|
|
152
|
-
101,
|
|
153
|
-
116,
|
|
154
|
-
104
|
|
155
|
-
],
|
|
156
|
-
[
|
|
157
|
-
32
|
|
158
|
-
],
|
|
159
|
-
[
|
|
160
|
-
105,
|
|
161
|
-
115
|
|
162
|
-
],
|
|
163
|
-
[
|
|
164
|
-
103,
|
|
165
|
-
114,
|
|
166
|
-
101,
|
|
167
|
-
97,
|
|
168
|
-
116
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
33
|
|
172
|
-
]
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
];
|
|
176
|
-
testSolidityKeccak256(inputs);
|
|
177
|
-
});
|
|
178
|
-
it('should match ethers.js booleans (specified as type "bool" to match solidity)', function() {
|
|
179
|
-
var inputs = [
|
|
180
|
-
{
|
|
181
|
-
types: [
|
|
182
|
-
"bool"
|
|
183
|
-
],
|
|
184
|
-
values: [
|
|
185
|
-
true
|
|
186
|
-
]
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
types: [
|
|
190
|
-
"bool",
|
|
191
|
-
"bool"
|
|
192
|
-
],
|
|
193
|
-
values: [
|
|
194
|
-
false,
|
|
195
|
-
false
|
|
196
|
-
]
|
|
197
|
-
}
|
|
198
|
-
];
|
|
199
|
-
testSolidityKeccak256(inputs);
|
|
200
|
-
});
|
|
201
|
-
it("should match ethers.js (signed and unsigned) integers", function() {
|
|
202
|
-
var inputs = [
|
|
203
|
-
{
|
|
204
|
-
types: [
|
|
205
|
-
"int16"
|
|
206
|
-
],
|
|
207
|
-
values: [
|
|
208
|
-
-1
|
|
209
|
-
]
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
types: [
|
|
213
|
-
"uint48"
|
|
214
|
-
],
|
|
215
|
-
values: [
|
|
216
|
-
12
|
|
217
|
-
]
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
types: [
|
|
221
|
-
"int16",
|
|
222
|
-
"uint48"
|
|
223
|
-
],
|
|
224
|
-
values: [
|
|
225
|
-
-1,
|
|
226
|
-
12
|
|
227
|
-
]
|
|
228
|
-
}
|
|
229
|
-
];
|
|
230
|
-
testSolidityKeccak256(inputs);
|
|
231
|
-
});
|
|
232
|
-
it("should match ethers.js array parsing", function() {
|
|
233
|
-
var inputs = [
|
|
234
|
-
{
|
|
235
|
-
types: [
|
|
236
|
-
"string[2]"
|
|
237
|
-
],
|
|
238
|
-
values: [
|
|
239
|
-
[
|
|
240
|
-
"some-text",
|
|
241
|
-
"additional-text"
|
|
242
|
-
]
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
];
|
|
246
|
-
testSolidityKeccak256(inputs);
|
|
247
|
-
});
|
|
248
|
-
it("should match ethers.js when passing different types into the same solidityKeccak256 function call", function() {
|
|
249
|
-
var inputs = [
|
|
250
|
-
{
|
|
251
|
-
types: [
|
|
252
|
-
"int16",
|
|
253
|
-
"string",
|
|
254
|
-
"bool"
|
|
255
|
-
],
|
|
256
|
-
values: [
|
|
257
|
-
-5,
|
|
258
|
-
"essential-eth",
|
|
259
|
-
true
|
|
260
|
-
]
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
types: [
|
|
264
|
-
"address",
|
|
265
|
-
"uint48",
|
|
266
|
-
"bytes4"
|
|
267
|
-
],
|
|
268
|
-
values: [
|
|
269
|
-
"0xB5503a7db1A9105cd459D99153e69a76a8EF1530",
|
|
270
|
-
20,
|
|
271
|
-
[
|
|
272
|
-
116,
|
|
273
|
-
101,
|
|
274
|
-
115,
|
|
275
|
-
116
|
|
276
|
-
]
|
|
277
|
-
]
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
types: [
|
|
281
|
-
"string[3]",
|
|
282
|
-
"bytes",
|
|
283
|
-
"bool[2]"
|
|
284
|
-
],
|
|
285
|
-
values: [
|
|
286
|
-
[
|
|
287
|
-
"ethereum",
|
|
288
|
-
"blockchain",
|
|
289
|
-
"204"
|
|
290
|
-
],
|
|
291
|
-
[
|
|
292
|
-
115,
|
|
293
|
-
111,
|
|
294
|
-
108,
|
|
295
|
-
105,
|
|
296
|
-
100,
|
|
297
|
-
105,
|
|
298
|
-
116,
|
|
299
|
-
121
|
|
300
|
-
],
|
|
301
|
-
[
|
|
302
|
-
false,
|
|
303
|
-
true
|
|
304
|
-
]
|
|
305
|
-
]
|
|
306
|
-
}
|
|
307
|
-
];
|
|
308
|
-
testSolidityKeccak256(inputs);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { splitSignature } from "../split-signature";
|
|
3
|
-
describe("splitSignature", function() {
|
|
4
|
-
it("should match ethers.js", function() {
|
|
5
|
-
var signatures = [
|
|
6
|
-
"0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee331b",
|
|
7
|
-
"0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33"
|
|
8
|
-
];
|
|
9
|
-
signatures.forEach(function(signature) {
|
|
10
|
-
expect(splitSignature(signature)).toStrictEqual(utils.splitSignature(signature));
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
it("should throw error on invalid signature", function() {
|
|
14
|
-
var signature = "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33238423849234765127"; //invalid signature length
|
|
15
|
-
expect(function() {
|
|
16
|
-
splitSignature(signature);
|
|
17
|
-
}).toThrow("invalid signature string");
|
|
18
|
-
});
|
|
19
|
-
it("should throw error on invalid v byte", function() {
|
|
20
|
-
var signature = "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee3305";
|
|
21
|
-
expect(function() {
|
|
22
|
-
splitSignature(signature);
|
|
23
|
-
}).toThrow("signature invalid v byte");
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import web3 from "web3";
|
|
3
|
-
import { toChecksumAddress } from "../../index";
|
|
4
|
-
describe("ether-to-wei", function() {
|
|
5
|
-
it("happy path", function() {
|
|
6
|
-
var addresses = [
|
|
7
|
-
"0x52908400098527886E0F7030069857D2E4169EE7",
|
|
8
|
-
"0x8617E340B3D01FA5F11F306F4090FD50E238070D",
|
|
9
|
-
"0xde709f2102306220921060314715629080e2fb77",
|
|
10
|
-
"0x27b1fdb04752bbc536007a920d24acb045561c26",
|
|
11
|
-
"0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed",
|
|
12
|
-
"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359",
|
|
13
|
-
"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB",
|
|
14
|
-
"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb"
|
|
15
|
-
];
|
|
16
|
-
addresses.forEach(function(address) {
|
|
17
|
-
expect(toChecksumAddress(address)).toStrictEqual(utils.getAddress(address));
|
|
18
|
-
expect(toChecksumAddress(address)).toStrictEqual(web3.utils.toChecksumAddress(address));
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
it("invalid inputs", function() {
|
|
22
|
-
var invalidChecksumAddress = "0x8617E340b3D01FA5F11F306F4090FD50E238070D";
|
|
23
|
-
expect(function() {
|
|
24
|
-
toChecksumAddress(invalidChecksumAddress);
|
|
25
|
-
}).toThrow('Invalid Checksum address for "'.concat(invalidChecksumAddress, '"'));
|
|
26
|
-
expect(function() {
|
|
27
|
-
// @ts-expect-error should not accept boolean
|
|
28
|
-
toChecksumAddress(false);
|
|
29
|
-
}).toThrow("string required. Received boolean");
|
|
30
|
-
expect(function() {
|
|
31
|
-
// @ts-expect-error should not accept array
|
|
32
|
-
toChecksumAddress([
|
|
33
|
-
1,
|
|
34
|
-
2,
|
|
35
|
-
3
|
|
36
|
-
]);
|
|
37
|
-
}).toThrow("string required. Received object");
|
|
38
|
-
expect(function() {
|
|
39
|
-
toChecksumAddress("0x1");
|
|
40
|
-
}).toThrow('Invalid Ethereum address "0x1"');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { toUtf8Bytes } from "../../index";
|
|
3
|
-
describe("utils.toUtf8Bytes", function() {
|
|
4
|
-
it("should match ethers.js", function() {
|
|
5
|
-
var inputs = [
|
|
6
|
-
"0xa",
|
|
7
|
-
"1",
|
|
8
|
-
"false"
|
|
9
|
-
];
|
|
10
|
-
inputs.forEach(function(input) {
|
|
11
|
-
expect(toUtf8Bytes(input)).toStrictEqual(utils.toUtf8Bytes(input));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import Big from "big.js";
|
|
2
|
-
import * as ethers from "ethers";
|
|
3
|
-
import web3 from "web3";
|
|
4
|
-
import { tinyBig, weiToEther } from "../../index";
|
|
5
|
-
describe("wei-to-ether", function() {
|
|
6
|
-
it("happy path", function() {
|
|
7
|
-
expect(weiToEther("100000000000000000000.0").toString()).toBe("100");
|
|
8
|
-
expect(weiToEther(100000000000000000000.0).toString()).toBe("100");
|
|
9
|
-
expect(weiToEther("1000000000000000000000.0").toNumber()).toBe(1000);
|
|
10
|
-
expect(weiToEther(1000000000000000000000.0).toNumber()).toBe(1000);
|
|
11
|
-
expect(weiToEther(tinyBig("1000000000000000000000.0")).toNumber()).toBe(1000);
|
|
12
|
-
expect(weiToEther(tinyBig(1000000000000000000000.0)).toNumber()).toBe(1000);
|
|
13
|
-
expect(weiToEther(Big("1000000000000000000000.0")).toNumber()).toBe(1000);
|
|
14
|
-
expect(weiToEther(Big(1000000000000000000000.0)).toNumber()).toBe(1000);
|
|
15
|
-
});
|
|
16
|
-
describe("matches ethers and web3 toString", function() {
|
|
17
|
-
it("toString", function() {
|
|
18
|
-
expect(weiToEther("10").toString()).toStrictEqual(ethers.utils.formatEther("10"));
|
|
19
|
-
expect(weiToEther("1000000000000000000000").toString()).toBe("1000");
|
|
20
|
-
expect(weiToEther("10").toString()).toStrictEqual(web3.utils.fromWei("10", "ether"));
|
|
21
|
-
expect(weiToEther("1000000000000000000000").toString()).toStrictEqual(web3.utils.fromWei("1000000000000000000000", "ether"));
|
|
22
|
-
});
|
|
23
|
-
it("toNumber", function() {
|
|
24
|
-
/* easy */ expect(weiToEther("9").toNumber()).toStrictEqual(Number(ethers.utils.formatEther("9")));
|
|
25
|
-
// expect(weiToEther("9").toNumber()).toStrictEqual(
|
|
26
|
-
// Number(ethers.utils.formatEther("9")),
|
|
27
|
-
// );
|
|
28
|
-
expect(weiToEther("9").toNumber()).toStrictEqual(Number(web3.utils.fromWei("9", "ether")));
|
|
29
|
-
/* hard because they respond with scientific notation or overflowing */ expect(weiToEther("999999").toNumber()).toStrictEqual(Number(ethers.utils.formatEther("999999")));
|
|
30
|
-
expect(weiToEther("999999").toNumber()).toStrictEqual(Number(web3.utils.fromWei("999999", "ether")));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
it("support hex", function() {
|
|
34
|
-
expect(weiToEther("0x14").toString()).toStrictEqual(ethers.utils.formatEther("20"));
|
|
35
|
-
expect(weiToEther(0x14).toString()).toStrictEqual(ethers.utils.formatEther("20"));
|
|
36
|
-
});
|
|
37
|
-
it("wrong types", function() {
|
|
38
|
-
expect(function() {
|
|
39
|
-
// @ts-expect-error should not accept boolean
|
|
40
|
-
weiToEther(false);
|
|
41
|
-
}).toThrow();
|
|
42
|
-
expect(function() {
|
|
43
|
-
// @ts-expect-error should not accept array
|
|
44
|
-
weiToEther([
|
|
45
|
-
1,
|
|
46
|
-
2,
|
|
47
|
-
3
|
|
48
|
-
]);
|
|
49
|
-
}).toThrow();
|
|
50
|
-
});
|
|
51
|
-
});
|