quantumcoin 7.0.3 → 7.0.5
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/.github/workflows/publish-npmjs.yaml +22 -22
- package/.gitignore +15 -15
- package/LICENSE +21 -21
- package/README-SDK.md +758 -754
- package/README.md +165 -150
- package/SPEC.md +3845 -3843
- package/config.d.ts +50 -50
- package/config.js +115 -115
- package/examples/AllSolidityTypes.sol +184 -184
- package/examples/SimpleIERC20.sol +74 -74
- package/examples/events.js +41 -35
- package/examples/events.ts +35 -0
- package/examples/example-generator-sdk-js.js +100 -95
- package/examples/example-generator-sdk-js.ts +77 -0
- package/examples/example-generator-sdk-ts.js +100 -95
- package/examples/example-generator-sdk-ts.ts +77 -0
- package/examples/example.js +72 -61
- package/examples/example.ts +61 -0
- package/examples/offline-signing.js +79 -73
- package/examples/offline-signing.ts +66 -0
- package/examples/package-lock.json +596 -57
- package/examples/package.json +32 -16
- package/examples/read-operations.js +32 -27
- package/examples/read-operations.ts +31 -0
- package/examples/sdk-generator-erc20.inline.json +251 -251
- package/examples/solidity-types.ts +43 -43
- package/examples/wallet-offline.js +35 -29
- package/examples/wallet-offline.ts +34 -0
- package/generate-sdk.js +1824 -1490
- package/index.js +12 -12
- package/package.json +95 -75
- package/scripts/copy-declarations.js +31 -0
- package/scripts/run-all-one-by-one.js +151 -0
- package/src/abi/fragments.d.ts +42 -42
- package/src/abi/fragments.js +63 -63
- package/src/abi/index.d.ts +13 -13
- package/src/abi/index.js +9 -9
- package/src/abi/interface.d.ts +128 -132
- package/src/abi/interface.js +590 -590
- package/src/abi/js-abi-coder.d.ts +8 -0
- package/src/abi/js-abi-coder.js +474 -474
- package/src/constants.d.ts +66 -61
- package/src/constants.js +101 -94
- package/src/contract/contract-factory.d.ts +28 -28
- package/src/contract/contract-factory.js +105 -105
- package/src/contract/contract.d.ts +113 -114
- package/src/contract/contract.js +354 -354
- package/src/contract/index.d.ts +9 -9
- package/src/contract/index.js +9 -9
- package/src/errors/index.d.ts +92 -92
- package/src/errors/index.js +188 -188
- package/src/generator/index.d.ts +74 -0
- package/src/generator/index.js +1404 -1404
- package/src/index.d.ts +125 -127
- package/src/index.js +41 -41
- package/src/internal/hex.d.ts +61 -61
- package/src/internal/hex.js +144 -144
- package/src/providers/extra-providers.d.ts +139 -128
- package/src/providers/extra-providers.js +600 -575
- package/src/providers/index.d.ts +17 -16
- package/src/providers/index.js +10 -10
- package/src/providers/json-rpc-provider.d.ts +12 -12
- package/src/providers/json-rpc-provider.js +79 -79
- package/src/providers/provider.d.ts +208 -203
- package/src/providers/provider.js +393 -371
- package/src/types/index.d.ts +214 -462
- package/src/types/index.js +9 -9
- package/src/utils/address.d.ts +72 -72
- package/src/utils/address.js +181 -182
- package/src/utils/encoding.d.ts +120 -120
- package/src/utils/encoding.js +306 -306
- package/src/utils/hashing.d.ts +82 -76
- package/src/utils/hashing.js +313 -298
- package/src/utils/index.d.ts +65 -55
- package/src/utils/index.js +13 -13
- package/src/utils/result.d.ts +57 -57
- package/src/utils/result.js +128 -128
- package/src/utils/rlp.d.ts +12 -12
- package/src/utils/rlp.js +200 -200
- package/src/utils/units.d.ts +29 -29
- package/src/utils/units.js +107 -107
- package/src/wallet/index.d.ts +10 -10
- package/src/wallet/index.js +8 -8
- package/src/wallet/wallet.d.ts +168 -160
- package/src/wallet/wallet.js +500 -489
- package/test/e2e/all-solidity-types.dynamic.test.js +207 -200
- package/test/e2e/all-solidity-types.dynamic.test.ts +191 -0
- package/test/e2e/all-solidity-types.fixtures.js +231 -231
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +387 -368
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +350 -0
- package/test/e2e/helpers.js +59 -47
- package/test/e2e/signing-context-and-fee.e2e.test.js +141 -0
- package/test/e2e/signing-context-and-fee.e2e.test.ts +128 -0
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +168 -151
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +141 -0
- package/test/e2e/transactional.test.js +245 -191
- package/test/e2e/transactional.test.ts +208 -0
- package/test/e2e/typed-generator.e2e.test.js +407 -404
- package/test/e2e/typed-generator.e2e.test.ts +337 -0
- package/test/fixtures/ConstructorParam.sol +23 -23
- package/test/fixtures/MultiContracts.sol +37 -37
- package/test/fixtures/SimpleStorage.sol +18 -18
- package/test/fixtures/StakingContract.abi.json +1 -1
- package/test/integration/ipc-provider.test.js +49 -44
- package/test/integration/ipc-provider.test.ts +44 -0
- package/test/integration/provider.test.js +88 -72
- package/test/integration/provider.test.ts +85 -0
- package/test/integration/ws-provider.test.js +41 -33
- package/test/integration/ws-provider.test.ts +38 -0
- package/test/security/malformed-input.test.js +37 -31
- package/test/security/malformed-input.test.ts +35 -0
- package/test/unit/_encrypted-output.txt +6 -0
- package/test/unit/_log-encrypted-jsons.js +45 -0
- package/test/unit/_write-keystore-fixture.js +16 -0
- package/test/unit/abi-interface.test.js +103 -98
- package/test/unit/abi-interface.test.ts +102 -0
- package/test/unit/address-wallet.test.js +392 -257
- package/test/unit/address-wallet.test.ts +379 -0
- package/test/unit/browser-provider.test.js +85 -82
- package/test/unit/browser-provider.test.ts +79 -0
- package/test/unit/contract.test.js +85 -82
- package/test/unit/contract.test.ts +83 -0
- package/test/unit/encoding-units-rlp.test.js +92 -89
- package/test/unit/encoding-units-rlp.test.ts +91 -0
- package/test/unit/errors.test.js +77 -74
- package/test/unit/errors.test.ts +76 -0
- package/test/unit/filter-by-blockhash.test.js +55 -52
- package/test/unit/filter-by-blockhash.test.ts +54 -0
- package/test/unit/fixtures/encrypted-keystores-48-32-36.js +9 -0
- package/test/unit/generate-contract-cli.test.js +42 -39
- package/test/unit/generate-contract-cli.test.ts +41 -0
- package/test/unit/generate-sdk-artifacts-json.test.js +113 -110
- package/test/unit/generate-sdk-artifacts-json.test.ts +110 -0
- package/test/unit/generator.test.js +102 -99
- package/test/unit/generator.test.ts +101 -0
- package/test/unit/hashing.test.js +68 -54
- package/test/unit/hashing.test.ts +67 -0
- package/test/unit/init.test.js +39 -36
- package/test/unit/init.test.ts +38 -0
- package/test/unit/interface.test.js +56 -53
- package/test/unit/interface.test.ts +54 -0
- package/test/unit/internal-hex.test.js +50 -47
- package/test/unit/internal-hex.test.ts +49 -0
- package/test/unit/populate-transaction.test.js +65 -62
- package/test/unit/populate-transaction.test.ts +64 -0
- package/test/unit/providers.test.js +200 -144
- package/test/unit/providers.test.ts +196 -0
- package/test/unit/result.test.js +80 -77
- package/test/unit/result.test.ts +79 -0
- package/test/unit/solidity-types.test.js +49 -46
- package/test/unit/solidity-types.test.ts +39 -0
- package/test/unit/utils.test.js +57 -54
- package/test/unit/utils.test.ts +56 -0
- package/test/verbose-logger.js +74 -0
- package/tsconfig.build.json +14 -0
package/src/internal/hex.js
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Internal hex and bytes helpers.
|
|
3
|
-
*
|
|
4
|
-
* IMPORTANT:
|
|
5
|
-
* - This module intentionally avoids external dependencies.
|
|
6
|
-
* - All hex strings in this SDK are normalized to lowercase with a `0x` prefix.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const { TextEncoder, TextDecoder } = require("util");
|
|
10
|
-
|
|
11
|
-
/** @type {TextEncoder} */
|
|
12
|
-
const _utf8Encoder = new TextEncoder();
|
|
13
|
-
/** @type {TextDecoder} */
|
|
14
|
-
const _utf8Decoder = new TextDecoder("utf-8", { fatal: false });
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Return true if `value` is a Uint8Array.
|
|
18
|
-
* @param {any} value
|
|
19
|
-
* @returns {value is Uint8Array}
|
|
20
|
-
*/
|
|
21
|
-
function isUint8Array(value) {
|
|
22
|
-
return value instanceof Uint8Array;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Normalize a hex string.
|
|
27
|
-
* @param {string} hex
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
function normalizeHex(hex) {
|
|
31
|
-
if (typeof hex !== "string") throw new TypeError("hex must be a string");
|
|
32
|
-
let h = hex.toLowerCase();
|
|
33
|
-
if (!h.startsWith("0x")) h = "0x" + h;
|
|
34
|
-
if (h.length % 2 !== 0) h = "0x0" + h.slice(2);
|
|
35
|
-
return h;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Returns true if value is a hex string.
|
|
40
|
-
* @param {any} value
|
|
41
|
-
* @param {number=} lengthBytes Optional exact byte length.
|
|
42
|
-
* @returns {boolean}
|
|
43
|
-
*/
|
|
44
|
-
function isHexString(value, lengthBytes) {
|
|
45
|
-
if (typeof value !== "string") return false;
|
|
46
|
-
const v = value.startsWith("0x") ? value.slice(2) : value;
|
|
47
|
-
if (v.length === 0) return false;
|
|
48
|
-
if (!/^[0-9a-fA-F]+$/.test(v)) return false;
|
|
49
|
-
if (v.length % 2 !== 0) return false;
|
|
50
|
-
if (lengthBytes != null) return v.length === lengthBytes * 2;
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Strip 0x prefix.
|
|
56
|
-
* @param {string} hex
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
function strip0x(hex) {
|
|
60
|
-
if (typeof hex !== "string") throw new TypeError("hex must be a string");
|
|
61
|
-
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Ensure a 0x prefix.
|
|
66
|
-
* @param {string} hex
|
|
67
|
-
* @returns {string}
|
|
68
|
-
*/
|
|
69
|
-
function add0x(hex) {
|
|
70
|
-
if (typeof hex !== "string") throw new TypeError("hex must be a string");
|
|
71
|
-
return hex.startsWith("0x") ? hex : "0x" + hex;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Convert a hex string to bytes.
|
|
76
|
-
* @param {string} hex
|
|
77
|
-
* @returns {Uint8Array}
|
|
78
|
-
*/
|
|
79
|
-
function hexToBytes(hex) {
|
|
80
|
-
if (!isHexString(hex)) throw new TypeError("invalid hex string");
|
|
81
|
-
const h = strip0x(hex);
|
|
82
|
-
const out = new Uint8Array(h.length / 2);
|
|
83
|
-
for (let i = 0; i < out.length; i++) {
|
|
84
|
-
out[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
|
|
85
|
-
}
|
|
86
|
-
return out;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Convert bytes to hex string.
|
|
91
|
-
* @param {Uint8Array} bytes
|
|
92
|
-
* @returns {string}
|
|
93
|
-
*/
|
|
94
|
-
function bytesToHex(bytes) {
|
|
95
|
-
if (!isUint8Array(bytes)) throw new TypeError("bytes must be Uint8Array");
|
|
96
|
-
let out = "0x";
|
|
97
|
-
for (const b of bytes) out += b.toString(16).padStart(2, "0");
|
|
98
|
-
return out;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* UTF-8 encode a string to bytes.
|
|
103
|
-
* @param {string} str
|
|
104
|
-
* @returns {Uint8Array}
|
|
105
|
-
*/
|
|
106
|
-
function utf8ToBytes(str) {
|
|
107
|
-
if (typeof str !== "string") throw new TypeError("str must be a string");
|
|
108
|
-
return _utf8Encoder.encode(str);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* UTF-8 decode bytes to a string.
|
|
113
|
-
* @param {Uint8Array} bytes
|
|
114
|
-
* @returns {string}
|
|
115
|
-
*/
|
|
116
|
-
function bytesToUtf8(bytes) {
|
|
117
|
-
if (!isUint8Array(bytes)) throw new TypeError("bytes must be Uint8Array");
|
|
118
|
-
return _utf8Decoder.decode(bytes);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Convert BytesLike to Uint8Array.
|
|
123
|
-
* @param {string | Uint8Array} data
|
|
124
|
-
* @returns {Uint8Array}
|
|
125
|
-
*/
|
|
126
|
-
function arrayify(data) {
|
|
127
|
-
if (typeof data === "string") return hexToBytes(data);
|
|
128
|
-
if (isUint8Array(data)) return new Uint8Array(data);
|
|
129
|
-
throw new TypeError("unsupported BytesLike");
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = {
|
|
133
|
-
isUint8Array,
|
|
134
|
-
normalizeHex,
|
|
135
|
-
isHexString,
|
|
136
|
-
strip0x,
|
|
137
|
-
add0x,
|
|
138
|
-
hexToBytes,
|
|
139
|
-
bytesToHex,
|
|
140
|
-
utf8ToBytes,
|
|
141
|
-
bytesToUtf8,
|
|
142
|
-
arrayify,
|
|
143
|
-
};
|
|
144
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Internal hex and bytes helpers.
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT:
|
|
5
|
+
* - This module intentionally avoids external dependencies.
|
|
6
|
+
* - All hex strings in this SDK are normalized to lowercase with a `0x` prefix.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { TextEncoder, TextDecoder } = require("util");
|
|
10
|
+
|
|
11
|
+
/** @type {TextEncoder} */
|
|
12
|
+
const _utf8Encoder = new TextEncoder();
|
|
13
|
+
/** @type {TextDecoder} */
|
|
14
|
+
const _utf8Decoder = new TextDecoder("utf-8", { fatal: false });
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return true if `value` is a Uint8Array.
|
|
18
|
+
* @param {any} value
|
|
19
|
+
* @returns {value is Uint8Array}
|
|
20
|
+
*/
|
|
21
|
+
function isUint8Array(value) {
|
|
22
|
+
return value instanceof Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Normalize a hex string.
|
|
27
|
+
* @param {string} hex
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
function normalizeHex(hex) {
|
|
31
|
+
if (typeof hex !== "string") throw new TypeError("hex must be a string");
|
|
32
|
+
let h = hex.toLowerCase();
|
|
33
|
+
if (!h.startsWith("0x")) h = "0x" + h;
|
|
34
|
+
if (h.length % 2 !== 0) h = "0x0" + h.slice(2);
|
|
35
|
+
return h;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns true if value is a hex string.
|
|
40
|
+
* @param {any} value
|
|
41
|
+
* @param {number=} lengthBytes Optional exact byte length.
|
|
42
|
+
* @returns {boolean}
|
|
43
|
+
*/
|
|
44
|
+
function isHexString(value, lengthBytes) {
|
|
45
|
+
if (typeof value !== "string") return false;
|
|
46
|
+
const v = value.startsWith("0x") ? value.slice(2) : value;
|
|
47
|
+
if (v.length === 0) return false;
|
|
48
|
+
if (!/^[0-9a-fA-F]+$/.test(v)) return false;
|
|
49
|
+
if (v.length % 2 !== 0) return false;
|
|
50
|
+
if (lengthBytes != null) return v.length === lengthBytes * 2;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Strip 0x prefix.
|
|
56
|
+
* @param {string} hex
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
59
|
+
function strip0x(hex) {
|
|
60
|
+
if (typeof hex !== "string") throw new TypeError("hex must be a string");
|
|
61
|
+
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Ensure a 0x prefix.
|
|
66
|
+
* @param {string} hex
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
function add0x(hex) {
|
|
70
|
+
if (typeof hex !== "string") throw new TypeError("hex must be a string");
|
|
71
|
+
return hex.startsWith("0x") ? hex : "0x" + hex;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Convert a hex string to bytes.
|
|
76
|
+
* @param {string} hex
|
|
77
|
+
* @returns {Uint8Array}
|
|
78
|
+
*/
|
|
79
|
+
function hexToBytes(hex) {
|
|
80
|
+
if (!isHexString(hex)) throw new TypeError("invalid hex string");
|
|
81
|
+
const h = strip0x(hex);
|
|
82
|
+
const out = new Uint8Array(h.length / 2);
|
|
83
|
+
for (let i = 0; i < out.length; i++) {
|
|
84
|
+
out[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Convert bytes to hex string.
|
|
91
|
+
* @param {Uint8Array} bytes
|
|
92
|
+
* @returns {string}
|
|
93
|
+
*/
|
|
94
|
+
function bytesToHex(bytes) {
|
|
95
|
+
if (!isUint8Array(bytes)) throw new TypeError("bytes must be Uint8Array");
|
|
96
|
+
let out = "0x";
|
|
97
|
+
for (const b of bytes) out += b.toString(16).padStart(2, "0");
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* UTF-8 encode a string to bytes.
|
|
103
|
+
* @param {string} str
|
|
104
|
+
* @returns {Uint8Array}
|
|
105
|
+
*/
|
|
106
|
+
function utf8ToBytes(str) {
|
|
107
|
+
if (typeof str !== "string") throw new TypeError("str must be a string");
|
|
108
|
+
return _utf8Encoder.encode(str);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* UTF-8 decode bytes to a string.
|
|
113
|
+
* @param {Uint8Array} bytes
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
function bytesToUtf8(bytes) {
|
|
117
|
+
if (!isUint8Array(bytes)) throw new TypeError("bytes must be Uint8Array");
|
|
118
|
+
return _utf8Decoder.decode(bytes);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Convert BytesLike to Uint8Array.
|
|
123
|
+
* @param {string | Uint8Array} data
|
|
124
|
+
* @returns {Uint8Array}
|
|
125
|
+
*/
|
|
126
|
+
function arrayify(data) {
|
|
127
|
+
if (typeof data === "string") return hexToBytes(data);
|
|
128
|
+
if (isUint8Array(data)) return new Uint8Array(data);
|
|
129
|
+
throw new TypeError("unsupported BytesLike");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = {
|
|
133
|
+
isUint8Array,
|
|
134
|
+
normalizeHex,
|
|
135
|
+
isHexString,
|
|
136
|
+
strip0x,
|
|
137
|
+
add0x,
|
|
138
|
+
hexToBytes,
|
|
139
|
+
bytesToHex,
|
|
140
|
+
utf8ToBytes,
|
|
141
|
+
bytesToUtf8,
|
|
142
|
+
arrayify,
|
|
143
|
+
};
|
|
144
|
+
|
|
@@ -1,128 +1,139 @@
|
|
|
1
|
-
export class WebSocketProvider extends AbstractProvider {
|
|
2
|
-
/**
|
|
3
|
-
* Create a WebSocket JSON-RPC provider.
|
|
4
|
-
*
|
|
5
|
-
* This uses the built-in global `WebSocket` available in recent Node.js
|
|
6
|
-
* versions (via undici). No additional npm dependencies are required.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} url WebSocket endpoint (e.g. ws://127.0.0.1:8546)
|
|
9
|
-
* @param {number=} chainId Optional chain id (compat)
|
|
10
|
-
*/
|
|
11
|
-
constructor(url: string, chainId?: number | undefined);
|
|
12
|
-
url: string;
|
|
13
|
-
chainId: number;
|
|
14
|
-
/** @type {any|null} */
|
|
15
|
-
_ws: any | null;
|
|
16
|
-
/** @type {Promise<void>|null} */
|
|
17
|
-
_wsReady: Promise<void> | null;
|
|
18
|
-
/** @type {Map<number, { resolve: Function, reject: Function, timer: any }>} */
|
|
19
|
-
_pending: Map<number, {
|
|
20
|
-
resolve: Function;
|
|
21
|
-
reject: Function;
|
|
22
|
-
timer: any;
|
|
23
|
-
}>;
|
|
24
|
-
/**
|
|
25
|
-
* Close the underlying WebSocket connection and reject any pending requests.
|
|
26
|
-
* This is important for tests so the Node.js event loop can exit cleanly.
|
|
27
|
-
*/
|
|
28
|
-
destroy(): void;
|
|
29
|
-
_rejectAllPending(err: any): void;
|
|
30
|
-
_connect(): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
export class IpcSocketProvider extends AbstractProvider {
|
|
33
|
-
/**
|
|
34
|
-
* Create an IPC provider.
|
|
35
|
-
*
|
|
36
|
-
* On Windows, use a named pipe path like: `\\\\.\\pipe\\geth.ipc`
|
|
37
|
-
* On Unix, use a domain socket path like: `/path/to/geth.ipc`
|
|
38
|
-
*
|
|
39
|
-
* @param {string} path IPC socket path
|
|
40
|
-
*/
|
|
41
|
-
constructor(path: string);
|
|
42
|
-
path: string;
|
|
43
|
-
}
|
|
44
|
-
export class BrowserProvider extends AbstractProvider {
|
|
45
|
-
/**
|
|
46
|
-
* Create a BrowserProvider from an EIP-1193 provider (e.g. MetaMask).
|
|
47
|
-
*
|
|
48
|
-
* This is a lightweight implementation that focuses on the core behaviors:
|
|
49
|
-
* - `send(method, params)` dispatches EIP-1193 requests
|
|
50
|
-
* - `getSigner()` resolves the connected account
|
|
51
|
-
* - emits ethers-like `debug` events for request/response tracking
|
|
52
|
-
*
|
|
53
|
-
* @param {{ request: Function }} eip1193Provider
|
|
54
|
-
* @param {any=} network Unused (compat)
|
|
55
|
-
* @param {{ providerInfo?: any }=} options
|
|
56
|
-
*/
|
|
57
|
-
constructor(eip1193Provider: {
|
|
58
|
-
request: Function;
|
|
59
|
-
}, network?: any | undefined, options?: {
|
|
60
|
-
providerInfo?: any;
|
|
61
|
-
} | undefined);
|
|
62
|
-
provider: {
|
|
63
|
-
request: Function;
|
|
64
|
-
};
|
|
65
|
-
providerInfo: any;
|
|
66
|
-
/**
|
|
67
|
-
* Send an EIP-1193 JSON-RPC request.
|
|
68
|
-
* @param {string} method
|
|
69
|
-
* @param {any[]|Record<string, any>=} params
|
|
70
|
-
* @returns {Promise<any>}
|
|
71
|
-
*/
|
|
72
|
-
send(method: string, params?: (any[] | Record<string, any>) | undefined): Promise<any>;
|
|
73
|
-
/**
|
|
74
|
-
* Map an EIP-1193 error into a normalized Error.
|
|
75
|
-
* @param {{ method: string, params?: any }} payload
|
|
76
|
-
* @param {any} error
|
|
77
|
-
* @returns {Error}
|
|
78
|
-
*/
|
|
79
|
-
getRpcError(payload: {
|
|
80
|
-
method: string;
|
|
81
|
-
params?: any;
|
|
82
|
-
}, error: any): Error;
|
|
83
|
-
/**
|
|
84
|
-
* Ethers compatibility: internal send for single or batched payloads.
|
|
85
|
-
* @param {any|any[]} payload
|
|
86
|
-
* @returns {Promise<any>}
|
|
87
|
-
*/
|
|
88
|
-
_send(payload: any | any[]): Promise<any>;
|
|
89
|
-
/**
|
|
90
|
-
* Returns a signer for the specified account index or address.
|
|
91
|
-
* @param {number|string=} address
|
|
92
|
-
* @returns {Promise<JsonRpcSigner>}
|
|
93
|
-
*/
|
|
94
|
-
getSigner(address?: (number | string) | undefined): Promise<JsonRpcSigner>;
|
|
95
|
-
/**
|
|
96
|
-
* Resolve whether this provider manages the address/index.
|
|
97
|
-
* @param {number|string} address
|
|
98
|
-
* @returns {Promise<boolean>}
|
|
99
|
-
*/
|
|
100
|
-
hasSigner(address: number | string): Promise<boolean>;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* FallbackProvider - uses the first provider in the list.
|
|
104
|
-
*/
|
|
105
|
-
export class FallbackProvider extends AbstractProvider {
|
|
106
|
-
/**
|
|
107
|
-
* @param {AbstractProvider[]|AbstractProvider} providers
|
|
108
|
-
*/
|
|
109
|
-
constructor(providers: AbstractProvider[] | AbstractProvider);
|
|
110
|
-
providers: AbstractProvider[];
|
|
111
|
-
_perform(method: any, params: any): Promise<any>;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* FilterByBlockHash placeholder.
|
|
115
|
-
*/
|
|
116
|
-
export class FilterByBlockHash {
|
|
117
|
-
constructor(blockHash: any, address: any, topics: any);
|
|
118
|
-
blockHash: string;
|
|
119
|
-
address: any;
|
|
120
|
-
topics: any;
|
|
121
|
-
toJSON(): {
|
|
122
|
-
blockHash: string;
|
|
123
|
-
address: any;
|
|
124
|
-
topics: any;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
1
|
+
export class WebSocketProvider extends AbstractProvider {
|
|
2
|
+
/**
|
|
3
|
+
* Create a WebSocket JSON-RPC provider.
|
|
4
|
+
*
|
|
5
|
+
* This uses the built-in global `WebSocket` available in recent Node.js
|
|
6
|
+
* versions (via undici). No additional npm dependencies are required.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} url WebSocket endpoint (e.g. ws://127.0.0.1:8546)
|
|
9
|
+
* @param {number=} chainId Optional chain id (compat)
|
|
10
|
+
*/
|
|
11
|
+
constructor(url: string, chainId?: number | undefined);
|
|
12
|
+
url: string;
|
|
13
|
+
chainId: number;
|
|
14
|
+
/** @type {any|null} */
|
|
15
|
+
_ws: any | null;
|
|
16
|
+
/** @type {Promise<void>|null} */
|
|
17
|
+
_wsReady: Promise<void> | null;
|
|
18
|
+
/** @type {Map<number, { resolve: Function, reject: Function, timer: any }>} */
|
|
19
|
+
_pending: Map<number, {
|
|
20
|
+
resolve: Function;
|
|
21
|
+
reject: Function;
|
|
22
|
+
timer: any;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Close the underlying WebSocket connection and reject any pending requests.
|
|
26
|
+
* This is important for tests so the Node.js event loop can exit cleanly.
|
|
27
|
+
*/
|
|
28
|
+
destroy(): void;
|
|
29
|
+
_rejectAllPending(err: any): void;
|
|
30
|
+
_connect(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export class IpcSocketProvider extends AbstractProvider {
|
|
33
|
+
/**
|
|
34
|
+
* Create an IPC provider.
|
|
35
|
+
*
|
|
36
|
+
* On Windows, use a named pipe path like: `\\\\.\\pipe\\geth.ipc`
|
|
37
|
+
* On Unix, use a domain socket path like: `/path/to/geth.ipc`
|
|
38
|
+
*
|
|
39
|
+
* @param {string} path IPC socket path
|
|
40
|
+
*/
|
|
41
|
+
constructor(path: string);
|
|
42
|
+
path: string;
|
|
43
|
+
}
|
|
44
|
+
export class BrowserProvider extends AbstractProvider {
|
|
45
|
+
/**
|
|
46
|
+
* Create a BrowserProvider from an EIP-1193 provider (e.g. MetaMask).
|
|
47
|
+
*
|
|
48
|
+
* This is a lightweight implementation that focuses on the core behaviors:
|
|
49
|
+
* - `send(method, params)` dispatches EIP-1193 requests
|
|
50
|
+
* - `getSigner()` resolves the connected account
|
|
51
|
+
* - emits ethers-like `debug` events for request/response tracking
|
|
52
|
+
*
|
|
53
|
+
* @param {{ request: Function }} eip1193Provider
|
|
54
|
+
* @param {any=} network Unused (compat)
|
|
55
|
+
* @param {{ providerInfo?: any }=} options
|
|
56
|
+
*/
|
|
57
|
+
constructor(eip1193Provider: {
|
|
58
|
+
request: Function;
|
|
59
|
+
}, network?: any | undefined, options?: {
|
|
60
|
+
providerInfo?: any;
|
|
61
|
+
} | undefined);
|
|
62
|
+
provider: {
|
|
63
|
+
request: Function;
|
|
64
|
+
};
|
|
65
|
+
providerInfo: any;
|
|
66
|
+
/**
|
|
67
|
+
* Send an EIP-1193 JSON-RPC request.
|
|
68
|
+
* @param {string} method
|
|
69
|
+
* @param {any[]|Record<string, any>=} params
|
|
70
|
+
* @returns {Promise<any>}
|
|
71
|
+
*/
|
|
72
|
+
send(method: string, params?: (any[] | Record<string, any>) | undefined): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* Map an EIP-1193 error into a normalized Error.
|
|
75
|
+
* @param {{ method: string, params?: any }} payload
|
|
76
|
+
* @param {any} error
|
|
77
|
+
* @returns {Error}
|
|
78
|
+
*/
|
|
79
|
+
getRpcError(payload: {
|
|
80
|
+
method: string;
|
|
81
|
+
params?: any;
|
|
82
|
+
}, error: any): Error;
|
|
83
|
+
/**
|
|
84
|
+
* Ethers compatibility: internal send for single or batched payloads.
|
|
85
|
+
* @param {any|any[]} payload
|
|
86
|
+
* @returns {Promise<any>}
|
|
87
|
+
*/
|
|
88
|
+
_send(payload: any | any[]): Promise<any>;
|
|
89
|
+
/**
|
|
90
|
+
* Returns a signer for the specified account index or address.
|
|
91
|
+
* @param {number|string=} address
|
|
92
|
+
* @returns {Promise<JsonRpcSigner>}
|
|
93
|
+
*/
|
|
94
|
+
getSigner(address?: (number | string) | undefined): Promise<JsonRpcSigner>;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve whether this provider manages the address/index.
|
|
97
|
+
* @param {number|string} address
|
|
98
|
+
* @returns {Promise<boolean>}
|
|
99
|
+
*/
|
|
100
|
+
hasSigner(address: number | string): Promise<boolean>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* FallbackProvider - uses the first provider in the list.
|
|
104
|
+
*/
|
|
105
|
+
export class FallbackProvider extends AbstractProvider {
|
|
106
|
+
/**
|
|
107
|
+
* @param {AbstractProvider[]|AbstractProvider} providers
|
|
108
|
+
*/
|
|
109
|
+
constructor(providers: AbstractProvider[] | AbstractProvider);
|
|
110
|
+
providers: AbstractProvider[];
|
|
111
|
+
_perform(method: any, params: any): Promise<any>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* FilterByBlockHash placeholder.
|
|
115
|
+
*/
|
|
116
|
+
export class FilterByBlockHash {
|
|
117
|
+
constructor(blockHash: any, address: any, topics: any);
|
|
118
|
+
blockHash: string;
|
|
119
|
+
address: any;
|
|
120
|
+
topics: any;
|
|
121
|
+
toJSON(): {
|
|
122
|
+
blockHash: string;
|
|
123
|
+
address: any;
|
|
124
|
+
topics: any;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create a provider from an endpoint string. Detects connection type by scheme/path:
|
|
129
|
+
* - http:// or https:// → JsonRpcProvider
|
|
130
|
+
* - ws:// or wss:// → WebSocketProvider
|
|
131
|
+
* - otherwise (e.g. \\\\.\\pipe\\geth.ipc or /path/to/geth.ipc) → IpcSocketProvider
|
|
132
|
+
*
|
|
133
|
+
* @param {string=} endpoint - RPC URL (http/https), WebSocket URL (ws/wss), or IPC path. If omitted or empty, uses default from Config (HTTP).
|
|
134
|
+
* @param {number=} chainId - Chain ID (default 123123). Used for HTTP and WebSocket; ignored for IPC.
|
|
135
|
+
* @returns {AbstractProvider}
|
|
136
|
+
*/
|
|
137
|
+
export function getProvider(endpoint?: string | undefined, chainId?: number | undefined): AbstractProvider;
|
|
138
|
+
import { AbstractProvider } from "./provider";
|
|
139
|
+
import { JsonRpcSigner } from "../wallet/wallet";
|