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,62 +0,0 @@
|
|
|
1
|
-
import { utils as ethers } from "ethers";
|
|
2
|
-
import { hexlify } from "../../bytes";
|
|
3
|
-
describe("utils.hexlify", function() {
|
|
4
|
-
it("numbers - matches ethers strings", function() {
|
|
5
|
-
var decimalValues = [
|
|
6
|
-
0,
|
|
7
|
-
4,
|
|
8
|
-
5,
|
|
9
|
-
16,
|
|
10
|
-
BigInt(0),
|
|
11
|
-
BigInt(16)
|
|
12
|
-
];
|
|
13
|
-
decimalValues.forEach(function(decimalValue) {
|
|
14
|
-
expect(hexlify(decimalValue)).toBe(ethers.hexlify(decimalValue));
|
|
15
|
-
});
|
|
16
|
-
var opts = {
|
|
17
|
-
allowMissingPrefix: true
|
|
18
|
-
};
|
|
19
|
-
expect(hexlify("22", opts)).toBe(ethers.hexlify("22", opts));
|
|
20
|
-
});
|
|
21
|
-
it("should match ethers.js - hexPad options", function() {
|
|
22
|
-
var values = [
|
|
23
|
-
[
|
|
24
|
-
"0x3342e95",
|
|
25
|
-
{
|
|
26
|
-
hexPad: "left"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
"0x41c942c42",
|
|
31
|
-
{
|
|
32
|
-
hexPad: "right"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
];
|
|
36
|
-
values.forEach(function(value) {
|
|
37
|
-
expect(hexlify(value[0], value[1])).toBe(ethers.hexlify(value[0], value[1]));
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
it("should throw error - hex data is odd-length", function() {
|
|
41
|
-
var values = [
|
|
42
|
-
"0x931",
|
|
43
|
-
"0x34414"
|
|
44
|
-
];
|
|
45
|
-
values.forEach(function(value) {
|
|
46
|
-
expect(function() {
|
|
47
|
-
return hexlify(value);
|
|
48
|
-
}).toThrow("hex data is odd-length");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
it("should throw error - invalid hexlify value", function() {
|
|
52
|
-
var values = [
|
|
53
|
-
"non-hex string",
|
|
54
|
-
false
|
|
55
|
-
];
|
|
56
|
-
values.forEach(function(value) {
|
|
57
|
-
expect(function() {
|
|
58
|
-
return hexlify(value);
|
|
59
|
-
}).toThrow("invalid hexlify value");
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { utils as ethers } from "ethers";
|
|
2
|
-
import { isBytesLike } from "../../bytes";
|
|
3
|
-
describe("utils.isBytesLike", function() {
|
|
4
|
-
it("should match ethers.js - hex string", function() {
|
|
5
|
-
var values = [
|
|
6
|
-
"0x9347",
|
|
7
|
-
"0x185754",
|
|
8
|
-
"0x00005823"
|
|
9
|
-
];
|
|
10
|
-
values.forEach(function(value) {
|
|
11
|
-
expect(isBytesLike(value)).toBe(ethers.isBytesLike(value));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
it("should match ethers.js - UInt8Array", function() {
|
|
15
|
-
var values = [
|
|
16
|
-
[
|
|
17
|
-
9,
|
|
18
|
-
58,
|
|
19
|
-
29,
|
|
20
|
-
24
|
|
21
|
-
],
|
|
22
|
-
[
|
|
23
|
-
185,
|
|
24
|
-
203
|
|
25
|
-
],
|
|
26
|
-
[
|
|
27
|
-
239,
|
|
28
|
-
30,
|
|
29
|
-
49,
|
|
30
|
-
41,
|
|
31
|
-
5,
|
|
32
|
-
10,
|
|
33
|
-
42
|
|
34
|
-
]
|
|
35
|
-
];
|
|
36
|
-
values.forEach(function(value) {
|
|
37
|
-
expect(isBytesLike(value)).toBe(ethers.isBytesLike(value));
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
it("should match ethers.js - number", function() {
|
|
41
|
-
var values = [
|
|
42
|
-
152,
|
|
43
|
-
513,
|
|
44
|
-
2354
|
|
45
|
-
];
|
|
46
|
-
values.forEach(function(value) {
|
|
47
|
-
expect(isBytesLike(value)).toBe(ethers.isBytesLike(value));
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
it("should match ethers.js - non-hex string", function() {
|
|
51
|
-
var values = [
|
|
52
|
-
"essential-eth",
|
|
53
|
-
"ethers.js",
|
|
54
|
-
"ethereum"
|
|
55
|
-
];
|
|
56
|
-
values.forEach(function(value) {
|
|
57
|
-
expect(isBytesLike(value)).toBe(ethers.isBytesLike(value));
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
it("should match ethers.js - boolean", function() {
|
|
61
|
-
var values = [
|
|
62
|
-
false,
|
|
63
|
-
true
|
|
64
|
-
];
|
|
65
|
-
values.forEach(function(value) {
|
|
66
|
-
expect(isBytesLike(value)).toBe(ethers.isBytesLike(value));
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as ethers from "ethers";
|
|
2
|
-
import { isBytes, isBytesLike } from "../../..";
|
|
3
|
-
describe("isBytesLike", function() {
|
|
4
|
-
it("matches ethers", function() {
|
|
5
|
-
var inputs = [
|
|
6
|
-
[
|
|
7
|
-
"1",
|
|
8
|
-
"2",
|
|
9
|
-
"3"
|
|
10
|
-
],
|
|
11
|
-
[
|
|
12
|
-
1,
|
|
13
|
-
2,
|
|
14
|
-
3
|
|
15
|
-
],
|
|
16
|
-
"0x123",
|
|
17
|
-
123,
|
|
18
|
-
0x123,
|
|
19
|
-
"bad",
|
|
20
|
-
false,
|
|
21
|
-
{
|
|
22
|
-
test: "bad"
|
|
23
|
-
},
|
|
24
|
-
null,
|
|
25
|
-
new Uint8Array(),
|
|
26
|
-
new Uint8Array(1)
|
|
27
|
-
];
|
|
28
|
-
inputs.forEach(function(input) {
|
|
29
|
-
expect(isBytesLike(input)).toBe(ethers.utils.isBytesLike(input));
|
|
30
|
-
expect(isBytes(input)).toBe(ethers.utils.isBytes(input));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { utils as ethers } from "ethers";
|
|
2
|
-
import { isHexString } from "../../bytes";
|
|
3
|
-
describe("utils.isHexString", function() {
|
|
4
|
-
it("should match ethers.js - hex string", function() {
|
|
5
|
-
var values = [
|
|
6
|
-
"0x9347",
|
|
7
|
-
"0x185754",
|
|
8
|
-
"0x00005823"
|
|
9
|
-
];
|
|
10
|
-
values.forEach(function(value) {
|
|
11
|
-
expect(isHexString(value)).toBe(ethers.isHexString(value));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
it("should match ethers.js - hex string of specific length", function() {
|
|
15
|
-
var values = [
|
|
16
|
-
[
|
|
17
|
-
"0x9347",
|
|
18
|
-
2
|
|
19
|
-
],
|
|
20
|
-
[
|
|
21
|
-
"0x185754",
|
|
22
|
-
5
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
"0x00005823",
|
|
26
|
-
4
|
|
27
|
-
]
|
|
28
|
-
];
|
|
29
|
-
values.forEach(function(value) {
|
|
30
|
-
expect(isHexString(value[0], value[1])).toBe(ethers.isHexString(value[0], value[1]));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
it("should match ethers.js - UInt8Array", function() {
|
|
34
|
-
var values = [
|
|
35
|
-
[
|
|
36
|
-
9,
|
|
37
|
-
58,
|
|
38
|
-
29,
|
|
39
|
-
24
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
185,
|
|
43
|
-
203
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
239,
|
|
47
|
-
30,
|
|
48
|
-
49,
|
|
49
|
-
41,
|
|
50
|
-
5,
|
|
51
|
-
10,
|
|
52
|
-
42
|
|
53
|
-
]
|
|
54
|
-
];
|
|
55
|
-
values.forEach(function(value) {
|
|
56
|
-
expect(isHexString(value)).toBe(ethers.isHexString(value));
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
it("should match ethers.js - number", function() {
|
|
60
|
-
var values = [
|
|
61
|
-
152,
|
|
62
|
-
513,
|
|
63
|
-
2354
|
|
64
|
-
];
|
|
65
|
-
values.forEach(function(value) {
|
|
66
|
-
expect(isHexString(value)).toBe(ethers.isHexString(value));
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
it("should match ethers.js - non-hex string", function() {
|
|
70
|
-
var values = [
|
|
71
|
-
"essential-eth",
|
|
72
|
-
"ethers.js",
|
|
73
|
-
"ethereum"
|
|
74
|
-
];
|
|
75
|
-
values.forEach(function(value) {
|
|
76
|
-
expect(isHexString(value)).toBe(ethers.isHexString(value));
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
it("should match ethers.js - boolean", function() {
|
|
80
|
-
var values = [
|
|
81
|
-
false,
|
|
82
|
-
true
|
|
83
|
-
];
|
|
84
|
-
values.forEach(function(value) {
|
|
85
|
-
expect(isHexString(value)).toBe(ethers.isHexString(value));
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { utils as ethers } from "ethers";
|
|
2
|
-
import { stripZeros } from "../../bytes";
|
|
3
|
-
describe("utils.stripZeros", function() {
|
|
4
|
-
it("should match ethers.js - hex string", function() {
|
|
5
|
-
var values = [
|
|
6
|
-
"0x00009347",
|
|
7
|
-
"0x00185754",
|
|
8
|
-
"0x00000000005823"
|
|
9
|
-
];
|
|
10
|
-
values.forEach(function(value) {
|
|
11
|
-
expect(stripZeros(value)).toStrictEqual(ethers.stripZeros(value));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
it("should match ethers.js - UInt8Array", function() {
|
|
15
|
-
var values = [
|
|
16
|
-
[
|
|
17
|
-
0,
|
|
18
|
-
0,
|
|
19
|
-
0,
|
|
20
|
-
9,
|
|
21
|
-
58,
|
|
22
|
-
29,
|
|
23
|
-
24
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
0,
|
|
27
|
-
185,
|
|
28
|
-
203
|
|
29
|
-
],
|
|
30
|
-
[
|
|
31
|
-
0,
|
|
32
|
-
0,
|
|
33
|
-
0,
|
|
34
|
-
0,
|
|
35
|
-
239,
|
|
36
|
-
30,
|
|
37
|
-
49,
|
|
38
|
-
41,
|
|
39
|
-
5,
|
|
40
|
-
10,
|
|
41
|
-
42
|
|
42
|
-
]
|
|
43
|
-
];
|
|
44
|
-
values.forEach(function(value) {
|
|
45
|
-
expect(stripZeros(value)).toStrictEqual(ethers.stripZeros(value));
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
it("should match ethers.js - empty array", function() {
|
|
49
|
-
var values = [
|
|
50
|
-
[],
|
|
51
|
-
"0x"
|
|
52
|
-
];
|
|
53
|
-
values.forEach(function(value) {
|
|
54
|
-
expect(stripZeros(value)).toStrictEqual(ethers.stripZeros(value));
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { utils as ethers } from "ethers";
|
|
2
|
-
import { zeroPad } from "../../bytes";
|
|
3
|
-
describe("utils.zeroPad", function() {
|
|
4
|
-
it("should match ethers.js - hex string", function() {
|
|
5
|
-
var values = [
|
|
6
|
-
[
|
|
7
|
-
"0x9347",
|
|
8
|
-
10
|
|
9
|
-
],
|
|
10
|
-
[
|
|
11
|
-
"0x185754",
|
|
12
|
-
5
|
|
13
|
-
],
|
|
14
|
-
[
|
|
15
|
-
"0x00005823",
|
|
16
|
-
7
|
|
17
|
-
]
|
|
18
|
-
];
|
|
19
|
-
values.forEach(function(value) {
|
|
20
|
-
expect(zeroPad(value[0], value[1])).toStrictEqual(ethers.zeroPad(value[0], value[1]));
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
it("should match ethers.js - UInt8Array", function() {
|
|
24
|
-
var values = [
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
9,
|
|
28
|
-
58,
|
|
29
|
-
29,
|
|
30
|
-
24
|
|
31
|
-
],
|
|
32
|
-
5
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
185,
|
|
37
|
-
203
|
|
38
|
-
],
|
|
39
|
-
4
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
239,
|
|
44
|
-
30,
|
|
45
|
-
49,
|
|
46
|
-
41,
|
|
47
|
-
5,
|
|
48
|
-
10,
|
|
49
|
-
42
|
|
50
|
-
],
|
|
51
|
-
10
|
|
52
|
-
]
|
|
53
|
-
];
|
|
54
|
-
values.forEach(function(value) {
|
|
55
|
-
expect(zeroPad(value[0], value[1])).toStrictEqual(ethers.zeroPad(value[0], value[1]));
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
it("should throw error - value out of range", function() {
|
|
59
|
-
var values = [
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
9,
|
|
63
|
-
58,
|
|
64
|
-
29,
|
|
65
|
-
24
|
|
66
|
-
],
|
|
67
|
-
3
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
"0x185754",
|
|
71
|
-
1
|
|
72
|
-
]
|
|
73
|
-
];
|
|
74
|
-
values.forEach(function(value) {
|
|
75
|
-
expect(function() {
|
|
76
|
-
return zeroPad(value[0], value[1]);
|
|
77
|
-
}).toThrow("value out of range");
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { computeAddress } from "../../index";
|
|
3
|
-
function testComputeAddress(keys) {
|
|
4
|
-
keys.forEach(function(key) {
|
|
5
|
-
expect(computeAddress(key)).toBe(utils.computeAddress(key));
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
describe("computeAddress", function() {
|
|
9
|
-
it("should match ethers.js - public key", function() {
|
|
10
|
-
var publicKeys = [
|
|
11
|
-
"0x04aaa2abcf8d119ad68b2c190abf34355a0029197911e2446007d5b44e6fddfd54352326fedac51eca491d59937c592ecffff65c6941037babbe26edfdbb32a688",
|
|
12
|
-
"0x04e8aa3d196e3a785fb5b431265074c01f571a79231e0cc0fc28e67d9c648471aca8229cafcc6cd806cd1a679f538326577bf9485c68f7a1c90b5116b669f30473",
|
|
13
|
-
"0x04110dfa471c3f04a6c9dfd857705eb080542c9672cf0f30d95f5fca382181293d6e91320916dd649d03c76818af8e7ee173781888e42e2f00bda9a8f797e0fd61",
|
|
14
|
-
"0x04593bea29e692123fda1b6f8280b8414524c7838fd448abe6dd1e072bee5e2e9c66e19976b9310ce514d8612c5736201ddc3bb966412076cd4b24e7f649e779b3"
|
|
15
|
-
];
|
|
16
|
-
testComputeAddress(publicKeys);
|
|
17
|
-
});
|
|
18
|
-
it("should match ethers.js - private key", function() {
|
|
19
|
-
var privateKeys = [
|
|
20
|
-
"0x8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f",
|
|
21
|
-
"0x42e12f76412f53de9d60df199a368699b6ec15d3798efb0b2a45b8c1b4f902a6",
|
|
22
|
-
"0x262f8fffb353d3e11be770dd4208dcab1fa5c205d574a78088829f45b1ac2487",
|
|
23
|
-
"0x1bcfb8b7a46e2f886ef61f8010426f70ce3c7fc1362973aa26d30b8f77711d93"
|
|
24
|
-
];
|
|
25
|
-
testComputeAddress(privateKeys);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { computePublicKey } from "../../index";
|
|
3
|
-
describe("computePublicKey", function() {
|
|
4
|
-
it("should match ethers.js", function() {
|
|
5
|
-
var privateKeys = [
|
|
6
|
-
"0x8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f",
|
|
7
|
-
"0x38a3159d73cefd392d0176c29b3cc60ff43e81813f5ab5782571511df9bb16e2",
|
|
8
|
-
"0xb6d36857e1f9b68e413d2496bb588f3650cdcc2398b3941963c44db8108b8671",
|
|
9
|
-
"0xf237d9763445d41150f9a199ad93ad478dff29ad8fe6fa00149ed12f40f8eb6f"
|
|
10
|
-
];
|
|
11
|
-
privateKeys.forEach(function(key) {
|
|
12
|
-
expect(computePublicKey(key)).toBe(utils.computePublicKey(key));
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Big from "big.js";
|
|
2
|
-
import { etherToGwei, tinyBig } from "../../index";
|
|
3
|
-
describe("gweiToEther", function() {
|
|
4
|
-
it("happy path", function() {
|
|
5
|
-
expect(etherToGwei("100.0").toString()).toBe("100000000000");
|
|
6
|
-
expect(etherToGwei(100.0).toString()).toBe("100000000000");
|
|
7
|
-
expect(etherToGwei("0.000000001").toNumber()).toBe(1);
|
|
8
|
-
expect(etherToGwei(0.000000001).toNumber()).toBe(1);
|
|
9
|
-
expect(etherToGwei(tinyBig(1000)).toNumber()).toBe(1000000000000);
|
|
10
|
-
expect(etherToGwei(Big(0.000000001)).toNumber()).toBe(1);
|
|
11
|
-
});
|
|
12
|
-
it("wrong types", function() {
|
|
13
|
-
expect(function() {
|
|
14
|
-
// @ts-expect-error should not accept boolean
|
|
15
|
-
etherToGwei(false);
|
|
16
|
-
}).toThrow();
|
|
17
|
-
expect(function() {
|
|
18
|
-
// @ts-expect-error should not accept array
|
|
19
|
-
etherToGwei([
|
|
20
|
-
1,
|
|
21
|
-
2,
|
|
22
|
-
3
|
|
23
|
-
]);
|
|
24
|
-
}).toThrow();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Big from "big.js";
|
|
2
|
-
import * as ethers from "ethers";
|
|
3
|
-
import web3 from "web3";
|
|
4
|
-
import { etherToWei, tinyBig } from "../../index";
|
|
5
|
-
import { scientificStrToDecimalStr } from "../../shared/tiny-big/helpers";
|
|
6
|
-
describe("ether-to-wei", function() {
|
|
7
|
-
it("happy path", function() {
|
|
8
|
-
expect(etherToWei("100").toString()).toBe("100000000000000000000");
|
|
9
|
-
expect(etherToWei(100).toString()).toBe("100000000000000000000");
|
|
10
|
-
expect(etherToWei("1000.0").toString()).toBe("1000000000000000000000");
|
|
11
|
-
expect(etherToWei(1000).toString()).toBe("1000000000000000000000");
|
|
12
|
-
expect(etherToWei("1000.0").toNumber()).toBe(1000000000000000000000);
|
|
13
|
-
expect(etherToWei(tinyBig(1000)).toString()).toBe("1000000000000000000000");
|
|
14
|
-
expect(etherToWei(tinyBig("1000.0")).toNumber()).toBe(1000000000000000000000);
|
|
15
|
-
expect(etherToWei(Big(1000)).toString()).toBe("1000000000000000000000");
|
|
16
|
-
expect(etherToWei(Big("1000.0")).toNumber()).toBe(1000000000000000000000);
|
|
17
|
-
});
|
|
18
|
-
it("matches ethers and web3 toString", function() {
|
|
19
|
-
expect(etherToWei("-09999.0").toString()).toStrictEqual(ethers.utils.parseEther("-09999.0").toString());
|
|
20
|
-
expect(etherToWei("-09999.0").toString()).toStrictEqual(web3.utils.toWei("-09999.0", "ether"));
|
|
21
|
-
});
|
|
22
|
-
it("matches ethers and web3 toNumber", function() {
|
|
23
|
-
/* easy */ expect(etherToWei("9").toNumber()).toStrictEqual(Number(ethers.utils.parseEther("9")));
|
|
24
|
-
// web3 responds with scientific notation
|
|
25
|
-
expect(etherToWei("9").toNumber()).toStrictEqual(Number(web3.utils.toWei("9", "ether")));
|
|
26
|
-
/* harder */ expect(etherToWei("-0999999.90").toNumber()).toStrictEqual(Number(ethers.utils.parseEther("-0999999.90")));
|
|
27
|
-
// web3 responds with scientific notation
|
|
28
|
-
expect(etherToWei("-0999999.9").toNumber()).toStrictEqual(Number(scientificStrToDecimalStr(web3.utils.toWei("-0999999.9", "ether"))));
|
|
29
|
-
});
|
|
30
|
-
it("should throw for wrong types", function() {
|
|
31
|
-
expect(function() {
|
|
32
|
-
// @ts-expect-error should not accept boolean
|
|
33
|
-
etherToWei(false);
|
|
34
|
-
}).toThrow();
|
|
35
|
-
expect(function() {
|
|
36
|
-
// @ts-expect-error should not accept array
|
|
37
|
-
etherToWei([
|
|
38
|
-
1,
|
|
39
|
-
2,
|
|
40
|
-
3
|
|
41
|
-
]);
|
|
42
|
-
}).toThrow();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Big from "big.js";
|
|
2
|
-
import { gweiToEther, tinyBig } from "../../index";
|
|
3
|
-
describe("gweiToEther", function() {
|
|
4
|
-
it("happy path", function() {
|
|
5
|
-
expect(gweiToEther("100000000000.0").toString()).toBe("100");
|
|
6
|
-
expect(gweiToEther(100000000000.0).toString()).toBe("100");
|
|
7
|
-
expect(gweiToEther("1000000000000.0").toNumber()).toBe(1000);
|
|
8
|
-
expect(gweiToEther(1000000000000.0).toNumber()).toBe(1000);
|
|
9
|
-
expect(gweiToEther(tinyBig("1000000000000.0")).toNumber()).toBe(1000);
|
|
10
|
-
expect(gweiToEther(tinyBig(1000000000000.0)).toNumber()).toBe(1000);
|
|
11
|
-
expect(gweiToEther(Big("1000000000000.0")).toNumber()).toBe(1000);
|
|
12
|
-
expect(gweiToEther(Big(1000000000000.0)).toNumber()).toBe(1000);
|
|
13
|
-
});
|
|
14
|
-
it("wrong types", function() {
|
|
15
|
-
expect(function() {
|
|
16
|
-
// @ts-expect-error should not accept boolean
|
|
17
|
-
gweiToEther(false);
|
|
18
|
-
}).toThrow();
|
|
19
|
-
expect(function() {
|
|
20
|
-
// @ts-expect-error should not accept array
|
|
21
|
-
gweiToEther([
|
|
22
|
-
1,
|
|
23
|
-
2,
|
|
24
|
-
3
|
|
25
|
-
]);
|
|
26
|
-
}).toThrow();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import { hashMessage } from "../../index";
|
|
3
|
-
describe("utils.hashMessage", function() {
|
|
4
|
-
it("should match ethers.js", function() {
|
|
5
|
-
var messages = [
|
|
6
|
-
"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb",
|
|
7
|
-
"27b1fdb04752bbc536007a920d24acb045561c26" /* leading "0x" is not required */ ,
|
|
8
|
-
[
|
|
9
|
-
1,
|
|
10
|
-
2
|
|
11
|
-
],
|
|
12
|
-
[
|
|
13
|
-
0x1,
|
|
14
|
-
0x2
|
|
15
|
-
]
|
|
16
|
-
];
|
|
17
|
-
messages.forEach(function(message) {
|
|
18
|
-
expect(hashMessage(message)).toStrictEqual(utils.hashMessage(message));
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { utils } from "ethers";
|
|
2
|
-
import web3 from "web3";
|
|
3
|
-
import { isAddress } from "../../index";
|
|
4
|
-
describe("is-address", function() {
|
|
5
|
-
it("should validate real addresses", function() {
|
|
6
|
-
var addresses = [
|
|
7
|
-
"0x52908400098527886E0F7030069857D2E4169EE7",
|
|
8
|
-
"0x8617E340B3D01FA5F11F306F4090FD50E238070D",
|
|
9
|
-
"0xde709f2102306220921060314715629080e2fb77",
|
|
10
|
-
"0x27b1fdb04752bbc536007a920d24acb045561c26",
|
|
11
|
-
"0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed",
|
|
12
|
-
"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359",
|
|
13
|
-
"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB",
|
|
14
|
-
"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb",
|
|
15
|
-
"27b1fdb04752bbc536007a920d24acb045561c26" /* leading "0x" is not required */
|
|
16
|
-
];
|
|
17
|
-
addresses.forEach(function(address) {
|
|
18
|
-
expect(isAddress(address)).toStrictEqual(utils.isAddress(address));
|
|
19
|
-
expect(isAddress(address)).toStrictEqual(web3.utils.isAddress(address));
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
it("should return false on invalid addresses", function() {
|
|
23
|
-
var addresses = [
|
|
24
|
-
"0x5290840009852",
|
|
25
|
-
"0x8617E340b3D01FA5F11F306F4090FD50E238070D",
|
|
26
|
-
"0x8617e340b3d01FA5F11F306F4090FD50E238070D" /* invalid checksum */ ,
|
|
27
|
-
" 0xde709f2102306220921060314715629080e2fb77",
|
|
28
|
-
"dawsbot.eth" /* ens invalid */ ,
|
|
29
|
-
"",
|
|
30
|
-
"xyz",
|
|
31
|
-
"0x123"
|
|
32
|
-
];
|
|
33
|
-
addresses.forEach(function(address) {
|
|
34
|
-
var essentialEthIsAddress = isAddress(address);
|
|
35
|
-
var ethersIsAddress = utils.isAddress(address);
|
|
36
|
-
var web3IsAddress = web3.utils.isAddress(address);
|
|
37
|
-
expect(essentialEthIsAddress).toStrictEqual(ethersIsAddress);
|
|
38
|
-
expect(essentialEthIsAddress).toStrictEqual(web3IsAddress);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
it("invalid type inputs", function() {
|
|
42
|
-
expect(function() {
|
|
43
|
-
// @ts-expect-error should not accept boolean
|
|
44
|
-
isAddress(false);
|
|
45
|
-
}).toThrow("string required. Received boolean");
|
|
46
|
-
expect(function() {
|
|
47
|
-
// @ts-expect-error should not accept array
|
|
48
|
-
isAddress([
|
|
49
|
-
1,
|
|
50
|
-
2,
|
|
51
|
-
3
|
|
52
|
-
]);
|
|
53
|
-
}).toThrow("string required. Received object");
|
|
54
|
-
});
|
|
55
|
-
});
|