essential-eth 0.4.9-beta.4 → 0.4.9
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/lib/cjs/classes/Contract.js +3 -8
- package/lib/cjs/classes/utils/fetchers.d.ts +1 -1
- package/lib/cjs/classes/utils/fetchers.js +21 -3
- package/lib/cjs/index.d.ts +1 -2
- package/lib/cjs/index.js +1 -26
- package/lib/cjs/providers/JsonRpcProvider.d.ts +8 -3
- package/lib/cjs/providers/JsonRpcProvider.js +18 -23
- package/lib/cjs/providers/test/rpc-urls.d.ts +3 -0
- package/lib/cjs/providers/test/rpc-urls.js +6 -0
- package/lib/cjs/providers/utils/chains-info.d.ts +19 -1
- package/lib/cjs/providers/utils/chains-info.js +57 -3
- package/lib/esm/classes/Contract.js +3 -8
- package/lib/esm/classes/utils/fetchers.d.ts +1 -1
- package/lib/esm/classes/utils/fetchers.js +21 -3
- package/lib/esm/index.d.ts +1 -2
- package/lib/esm/index.js +1 -2
- package/lib/esm/providers/JsonRpcProvider.d.ts +4 -3
- package/lib/esm/providers/JsonRpcProvider.js +14 -23
- package/lib/esm/providers/test/rpc-urls.d.ts +3 -0
- package/lib/esm/providers/test/rpc-urls.js +3 -0
- package/lib/esm/providers/utils/chains-info.d.ts +19 -1
- package/lib/esm/providers/utils/chains-info.js +57 -3
- package/package.json +6 -10
- package/readme.md +35 -9
- package/lib/cjs/utils/index.d.ts +0 -5
- package/lib/cjs/utils/index.js +0 -11
- package/lib/esm/utils/index.d.ts +0 -5
- package/lib/esm/utils/index.js +0 -5
|
@@ -51,17 +51,12 @@ class BaseContract {
|
|
|
51
51
|
? estimateGas(data)
|
|
52
52
|
: null;
|
|
53
53
|
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return yield (0, fetchers_1.post)(this._provider._rpcUrl
|
|
55
|
-
Object.assign({ to: this._address.toLowerCase(), data
|
|
54
|
+
return yield (0, fetchers_1.post)(this._provider._rpcUrl, (0, fetchers_1.buildRPCPostBody)('eth_call', [
|
|
55
|
+
Object.assign({ to: this._address.toLowerCase(), data }, (decimalGas
|
|
56
56
|
? { gas: `0x${decimalGas.toString(16)}` }
|
|
57
57
|
: {})),
|
|
58
58
|
'latest',
|
|
59
|
-
]))
|
|
60
|
-
if (e.code === 'ENOTFOUND') {
|
|
61
|
-
this._provider._rpcUrlCounter++;
|
|
62
|
-
return req();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
59
|
+
]));
|
|
65
60
|
});
|
|
66
61
|
const nodeResponse = yield req();
|
|
67
62
|
return (0, encode_decode_transaction_1.decodeRPCResponse)(jsonABIArgument, nodeResponse);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function post(url: string, body: Record<string, unknown>): Promise<any>;
|
|
2
|
-
declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_call' | 'eth_chainId';
|
|
2
|
+
declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice';
|
|
3
3
|
export declare function buildRPCPostBody(method: RPCMethodName, params: any[]): {
|
|
4
4
|
jsonrpc: string;
|
|
5
5
|
id: number;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -13,10 +22,19 @@ function post(url, body) {
|
|
|
13
22
|
},
|
|
14
23
|
body: JSON.stringify(body),
|
|
15
24
|
})
|
|
16
|
-
.then((r) =>
|
|
25
|
+
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const t = yield r.text();
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(t);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
throw new Error(`Invalid JSON RPC response: "${t}"`);
|
|
32
|
+
}
|
|
33
|
+
}))
|
|
17
34
|
.then((response) => {
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
const result = response === null || response === void 0 ? void 0 : response.result;
|
|
36
|
+
if (!result) {
|
|
37
|
+
throw new Error(`Invalid JSON RPC response: ${JSON.stringify(response)}`);
|
|
20
38
|
}
|
|
21
39
|
return response.result;
|
|
22
40
|
});
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -5,9 +5,8 @@ import { Block } from './types/Block.types';
|
|
|
5
5
|
import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
|
|
6
6
|
import { Network } from './types/Network.types';
|
|
7
7
|
import { Transaction } from './types/Transaction.types';
|
|
8
|
-
import * as utils from './utils';
|
|
9
8
|
import { etherToWei } from './utils/ether-to-wei';
|
|
10
9
|
import { isAddress } from './utils/is-address';
|
|
11
10
|
import { toChecksumAddress } from './utils/to-checksum-address';
|
|
12
11
|
import { weiToEther } from './utils/wei-to-ether';
|
|
13
|
-
export {
|
|
12
|
+
export { etherToWei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, Contract, TinyBig, Block, ContractTypes, JSONABI, JSONABIArgument, Network, Transaction, };
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.TinyBig = exports.Contract = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToWei =
|
|
3
|
+
exports.TinyBig = exports.Contract = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToWei = void 0;
|
|
27
4
|
const Contract_1 = require("./classes/Contract");
|
|
28
5
|
Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
|
|
29
6
|
const JsonRpcProvider_1 = require("./providers/JsonRpcProvider");
|
|
@@ -32,8 +9,6 @@ Object.defineProperty(exports, "jsonRpcProvider", { enumerable: true, get: funct
|
|
|
32
9
|
const tiny_big_1 = require("./shared/tiny-big/tiny-big");
|
|
33
10
|
Object.defineProperty(exports, "tinyBig", { enumerable: true, get: function () { return tiny_big_1.tinyBig; } });
|
|
34
11
|
Object.defineProperty(exports, "TinyBig", { enumerable: true, get: function () { return tiny_big_1.TinyBig; } });
|
|
35
|
-
const utils = __importStar(require("./utils"));
|
|
36
|
-
exports.utils = utils;
|
|
37
12
|
const ether_to_wei_1 = require("./utils/ether-to-wei");
|
|
38
13
|
Object.defineProperty(exports, "etherToWei", { enumerable: true, get: function () { return ether_to_wei_1.etherToWei; } });
|
|
39
14
|
const is_address_1 = require("./utils/is-address");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { TinyBig } from '../shared/tiny-big/tiny-big';
|
|
1
2
|
import { Block } from '../types/Block.types';
|
|
2
3
|
import { Network } from '../types/Network.types';
|
|
3
4
|
export declare class JsonRpcProvider {
|
|
4
5
|
/**
|
|
5
6
|
* The URL to your Eth node. Consider POKT or Infura
|
|
6
7
|
*/
|
|
7
|
-
readonly _rpcUrl:
|
|
8
|
-
|
|
9
|
-
constructor(rpcUrl?: string | Array<string>);
|
|
8
|
+
readonly _rpcUrl: string;
|
|
9
|
+
constructor(rpcUrl?: string);
|
|
10
10
|
/**
|
|
11
11
|
* Returns the block requested
|
|
12
12
|
* Same as `web3.eth.getBlock`
|
|
@@ -16,6 +16,11 @@ export declare class JsonRpcProvider {
|
|
|
16
16
|
* Returns the network this provider is connected to
|
|
17
17
|
*/
|
|
18
18
|
getNetwork(): Promise<Network>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the current gas price in wei as TinyBig
|
|
21
|
+
* Same as `ethers.provider.getGasPrice`
|
|
22
|
+
*/
|
|
23
|
+
getGasPrice(): Promise<TinyBig>;
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* Helper function to avoid "new"
|
|
@@ -16,19 +16,11 @@ exports.jsonRpcProvider = exports.JsonRpcProvider = void 0;
|
|
|
16
16
|
const clean_block_1 = require("../classes/utils/clean-block");
|
|
17
17
|
const fetchers_1 = require("../classes/utils/fetchers");
|
|
18
18
|
const hex_to_decimal_1 = require("../classes/utils/hex-to-decimal");
|
|
19
|
+
const tiny_big_1 = require("../shared/tiny-big/tiny-big");
|
|
19
20
|
const chains_info_1 = __importDefault(require("./utils/chains-info"));
|
|
20
21
|
class JsonRpcProvider {
|
|
21
22
|
constructor(rpcUrl) {
|
|
22
|
-
this._rpcUrl =
|
|
23
|
-
if (!rpcUrl) {
|
|
24
|
-
return ['https://free-eth-node.com/api/eth'];
|
|
25
|
-
}
|
|
26
|
-
else if (!Array.isArray(rpcUrl)) {
|
|
27
|
-
return [rpcUrl];
|
|
28
|
-
}
|
|
29
|
-
return rpcUrl;
|
|
30
|
-
})();
|
|
31
|
-
this._rpcUrlCounter = 0;
|
|
23
|
+
this._rpcUrl = rpcUrl || 'https://free-eth-node.com/api/eth';
|
|
32
24
|
}
|
|
33
25
|
/**
|
|
34
26
|
* Returns the block requested
|
|
@@ -46,15 +38,10 @@ class JsonRpcProvider {
|
|
|
46
38
|
rpcTimeFrame = timeFrame;
|
|
47
39
|
}
|
|
48
40
|
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return yield (0, fetchers_1.post)(this._rpcUrl
|
|
41
|
+
return yield (0, fetchers_1.post)(this._rpcUrl, (0, fetchers_1.buildRPCPostBody)('eth_getBlockByNumber', [
|
|
50
42
|
rpcTimeFrame,
|
|
51
43
|
returnTransactionObjects,
|
|
52
|
-
]))
|
|
53
|
-
if (e.code === 'ENOTFOUND') {
|
|
54
|
-
this._rpcUrlCounter++;
|
|
55
|
-
return req();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
44
|
+
]));
|
|
58
45
|
});
|
|
59
46
|
const nodeResponse = (yield req());
|
|
60
47
|
return (0, clean_block_1.cleanBlock)(nodeResponse, returnTransactionObjects);
|
|
@@ -66,12 +53,7 @@ class JsonRpcProvider {
|
|
|
66
53
|
getNetwork() {
|
|
67
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
55
|
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
return yield (0, fetchers_1.post)(this._rpcUrl
|
|
70
|
-
if (e.code === 'ENOTFOUND') {
|
|
71
|
-
this._rpcUrlCounter++;
|
|
72
|
-
return req();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
56
|
+
return yield (0, fetchers_1.post)(this._rpcUrl, (0, fetchers_1.buildRPCPostBody)('eth_chainId', []));
|
|
75
57
|
});
|
|
76
58
|
const nodeResponse = (yield req());
|
|
77
59
|
const chainId = (0, hex_to_decimal_1.hexToDecimal)(nodeResponse);
|
|
@@ -83,6 +65,19 @@ class JsonRpcProvider {
|
|
|
83
65
|
};
|
|
84
66
|
});
|
|
85
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the current gas price in wei as TinyBig
|
|
70
|
+
* Same as `ethers.provider.getGasPrice`
|
|
71
|
+
*/
|
|
72
|
+
getGasPrice() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return yield (0, fetchers_1.post)(this._rpcUrl, (0, fetchers_1.buildRPCPostBody)('eth_gasPrice', []));
|
|
76
|
+
});
|
|
77
|
+
const nodeResponse = (yield req()); /* '0x153cfb1ad0' */
|
|
78
|
+
return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(nodeResponse));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
86
81
|
}
|
|
87
82
|
exports.JsonRpcProvider = JsonRpcProvider;
|
|
88
83
|
/**
|
|
@@ -45,6 +45,7 @@ declare const _default: {
|
|
|
45
45
|
"51": string[];
|
|
46
46
|
"52": string[];
|
|
47
47
|
"53": string[];
|
|
48
|
+
"54": string[];
|
|
48
49
|
"55": string[];
|
|
49
50
|
"56": string[];
|
|
50
51
|
"57": string[];
|
|
@@ -98,9 +99,11 @@ declare const _default: {
|
|
|
98
99
|
"127": string[];
|
|
99
100
|
"128": string[];
|
|
100
101
|
"137": string[];
|
|
102
|
+
"141": string[];
|
|
101
103
|
"142": string[];
|
|
102
104
|
"162": string[];
|
|
103
105
|
"163": string[];
|
|
106
|
+
"168": string[];
|
|
104
107
|
"170": string[];
|
|
105
108
|
"172": string[];
|
|
106
109
|
"186": string[];
|
|
@@ -109,7 +112,10 @@ declare const _default: {
|
|
|
109
112
|
"199": string[];
|
|
110
113
|
"200": string[];
|
|
111
114
|
"211": string[];
|
|
115
|
+
"218": string[];
|
|
112
116
|
"222": string[];
|
|
117
|
+
"225": string[];
|
|
118
|
+
"226": string[];
|
|
113
119
|
"246": string[];
|
|
114
120
|
"250": string[];
|
|
115
121
|
"256": string[];
|
|
@@ -145,6 +151,7 @@ declare const _default: {
|
|
|
145
151
|
"721": string[];
|
|
146
152
|
"777": string[];
|
|
147
153
|
"787": string[];
|
|
154
|
+
"788": string[];
|
|
148
155
|
"803": string[];
|
|
149
156
|
"820": string[];
|
|
150
157
|
"821": string[];
|
|
@@ -180,14 +187,18 @@ declare const _default: {
|
|
|
180
187
|
"1280": string[];
|
|
181
188
|
"1284": string[];
|
|
182
189
|
"1285": string[];
|
|
190
|
+
"1286": string[];
|
|
183
191
|
"1287": string[];
|
|
184
192
|
"1288": string[];
|
|
193
|
+
"1337": string[];
|
|
185
194
|
"1618": string[];
|
|
186
195
|
"1620": string[];
|
|
187
196
|
"1657": string[];
|
|
197
|
+
"1688": string[];
|
|
188
198
|
"1856": string[];
|
|
189
199
|
"1898": string[];
|
|
190
200
|
"1987": string[];
|
|
201
|
+
"2001": string[];
|
|
191
202
|
"2020": string[];
|
|
192
203
|
"2021": string[];
|
|
193
204
|
"2022": string[];
|
|
@@ -195,7 +206,10 @@ declare const _default: {
|
|
|
195
206
|
"2100": string[];
|
|
196
207
|
"2101": string[];
|
|
197
208
|
"2213": string[];
|
|
209
|
+
"2221": string[];
|
|
198
210
|
"2559": string[];
|
|
211
|
+
"3000": string[];
|
|
212
|
+
"3001": string[];
|
|
199
213
|
"3331": string[];
|
|
200
214
|
"3333": string[];
|
|
201
215
|
"3334": string[];
|
|
@@ -205,12 +219,14 @@ declare const _default: {
|
|
|
205
219
|
"3966": string[];
|
|
206
220
|
"3967": string[];
|
|
207
221
|
"4002": string[];
|
|
222
|
+
"4102": string[];
|
|
208
223
|
"4689": string[];
|
|
209
224
|
"4690": string[];
|
|
210
225
|
"4918": string[];
|
|
211
226
|
"5197": string[];
|
|
212
227
|
"5315": string[];
|
|
213
228
|
"5700": string[];
|
|
229
|
+
"5777": string[];
|
|
214
230
|
"5851": string[];
|
|
215
231
|
"5869": string[];
|
|
216
232
|
"6626": string[];
|
|
@@ -259,6 +275,7 @@ declare const _default: {
|
|
|
259
275
|
"43113": string[];
|
|
260
276
|
"43114": string[];
|
|
261
277
|
"44787": string[];
|
|
278
|
+
"45000": string[];
|
|
262
279
|
"47805": string[];
|
|
263
280
|
"49797": string[];
|
|
264
281
|
"53935": string[];
|
|
@@ -300,10 +317,10 @@ declare const _default: {
|
|
|
300
317
|
"110006": string[];
|
|
301
318
|
"110007": string[];
|
|
302
319
|
"110008": string[];
|
|
320
|
+
"200101": string[];
|
|
303
321
|
"200625": string[];
|
|
304
322
|
"201018": string[];
|
|
305
323
|
"201030": string[];
|
|
306
|
-
"210309": string[];
|
|
307
324
|
"210425": string[];
|
|
308
325
|
"234666": string[];
|
|
309
326
|
"246529": string[];
|
|
@@ -319,6 +336,7 @@ declare const _default: {
|
|
|
319
336
|
"1313114": string[];
|
|
320
337
|
"1313500": string[];
|
|
321
338
|
"1337702": string[];
|
|
339
|
+
"2203181": string[];
|
|
322
340
|
"7762959": string[];
|
|
323
341
|
"11155111": string[];
|
|
324
342
|
"13371337": string[];
|
|
@@ -145,6 +145,9 @@ exports.default = {
|
|
|
145
145
|
"53": [
|
|
146
146
|
"tcet"
|
|
147
147
|
],
|
|
148
|
+
"54": [
|
|
149
|
+
"OP"
|
|
150
|
+
],
|
|
148
151
|
"55": [
|
|
149
152
|
"ZYX"
|
|
150
153
|
],
|
|
@@ -304,6 +307,9 @@ exports.default = {
|
|
|
304
307
|
"137": [
|
|
305
308
|
"MATIC"
|
|
306
309
|
],
|
|
310
|
+
"141": [
|
|
311
|
+
"OPtest"
|
|
312
|
+
],
|
|
307
313
|
"142": [
|
|
308
314
|
"dax"
|
|
309
315
|
],
|
|
@@ -313,6 +319,9 @@ exports.default = {
|
|
|
313
319
|
"163": [
|
|
314
320
|
"pht"
|
|
315
321
|
],
|
|
322
|
+
"168": [
|
|
323
|
+
"aioz"
|
|
324
|
+
],
|
|
316
325
|
"170": [
|
|
317
326
|
"hoosmartchain"
|
|
318
327
|
],
|
|
@@ -337,9 +346,18 @@ exports.default = {
|
|
|
337
346
|
"211": [
|
|
338
347
|
"EDI"
|
|
339
348
|
],
|
|
349
|
+
"218": [
|
|
350
|
+
"SO1-old"
|
|
351
|
+
],
|
|
340
352
|
"222": [
|
|
341
353
|
"ASK"
|
|
342
354
|
],
|
|
355
|
+
"225": [
|
|
356
|
+
"LA"
|
|
357
|
+
],
|
|
358
|
+
"226": [
|
|
359
|
+
"TLA"
|
|
360
|
+
],
|
|
343
361
|
"246": [
|
|
344
362
|
"ewt"
|
|
345
363
|
],
|
|
@@ -445,6 +463,9 @@ exports.default = {
|
|
|
445
463
|
"787": [
|
|
446
464
|
"aca"
|
|
447
465
|
],
|
|
466
|
+
"788": [
|
|
467
|
+
"taero"
|
|
468
|
+
],
|
|
448
469
|
"803": [
|
|
449
470
|
"haic"
|
|
450
471
|
],
|
|
@@ -550,12 +571,18 @@ exports.default = {
|
|
|
550
571
|
"1285": [
|
|
551
572
|
"mriver"
|
|
552
573
|
],
|
|
574
|
+
"1286": [
|
|
575
|
+
"mrock-old"
|
|
576
|
+
],
|
|
553
577
|
"1287": [
|
|
554
578
|
"mbase"
|
|
555
579
|
],
|
|
556
580
|
"1288": [
|
|
557
581
|
"mrock"
|
|
558
582
|
],
|
|
583
|
+
"1337": [
|
|
584
|
+
"cennz-a"
|
|
585
|
+
],
|
|
559
586
|
"1618": [
|
|
560
587
|
"cate"
|
|
561
588
|
],
|
|
@@ -565,6 +592,9 @@ exports.default = {
|
|
|
565
592
|
"1657": [
|
|
566
593
|
"bta"
|
|
567
594
|
],
|
|
595
|
+
"1688": [
|
|
596
|
+
"LUDAN"
|
|
597
|
+
],
|
|
568
598
|
"1856": [
|
|
569
599
|
"tsf"
|
|
570
600
|
],
|
|
@@ -574,6 +604,9 @@ exports.default = {
|
|
|
574
604
|
"1987": [
|
|
575
605
|
"egem"
|
|
576
606
|
],
|
|
607
|
+
"2001": [
|
|
608
|
+
"milkAda"
|
|
609
|
+
],
|
|
577
610
|
"2020": [
|
|
578
611
|
"420"
|
|
579
612
|
],
|
|
@@ -595,9 +628,18 @@ exports.default = {
|
|
|
595
628
|
"2213": [
|
|
596
629
|
"evanesco"
|
|
597
630
|
],
|
|
631
|
+
"2221": [
|
|
632
|
+
"kava"
|
|
633
|
+
],
|
|
598
634
|
"2559": [
|
|
599
635
|
"ktoc"
|
|
600
636
|
],
|
|
637
|
+
"3000": [
|
|
638
|
+
"cennz-r"
|
|
639
|
+
],
|
|
640
|
+
"3001": [
|
|
641
|
+
"cennz-n"
|
|
642
|
+
],
|
|
601
643
|
"3331": [
|
|
602
644
|
"zcrbeach"
|
|
603
645
|
],
|
|
@@ -625,6 +667,9 @@ exports.default = {
|
|
|
625
667
|
"4002": [
|
|
626
668
|
"tftm"
|
|
627
669
|
],
|
|
670
|
+
"4102": [
|
|
671
|
+
"aioz-testnet"
|
|
672
|
+
],
|
|
628
673
|
"4689": [
|
|
629
674
|
"iotex-mainnet"
|
|
630
675
|
],
|
|
@@ -643,6 +688,9 @@ exports.default = {
|
|
|
643
688
|
"5700": [
|
|
644
689
|
"tsys"
|
|
645
690
|
],
|
|
691
|
+
"5777": [
|
|
692
|
+
"dgcc"
|
|
693
|
+
],
|
|
646
694
|
"5851": [
|
|
647
695
|
"Ontology Testnet"
|
|
648
696
|
],
|
|
@@ -787,6 +835,9 @@ exports.default = {
|
|
|
787
835
|
"44787": [
|
|
788
836
|
"ALFA"
|
|
789
837
|
],
|
|
838
|
+
"45000": [
|
|
839
|
+
"autobahn"
|
|
840
|
+
],
|
|
790
841
|
"47805": [
|
|
791
842
|
"REI"
|
|
792
843
|
],
|
|
@@ -910,6 +961,9 @@ exports.default = {
|
|
|
910
961
|
"110008": [
|
|
911
962
|
"qkc-d-s7"
|
|
912
963
|
],
|
|
964
|
+
"200101": [
|
|
965
|
+
"milkTAda"
|
|
966
|
+
],
|
|
913
967
|
"200625": [
|
|
914
968
|
"aka"
|
|
915
969
|
],
|
|
@@ -919,9 +973,6 @@ exports.default = {
|
|
|
919
973
|
"201030": [
|
|
920
974
|
"alayadev"
|
|
921
975
|
],
|
|
922
|
-
"210309": [
|
|
923
|
-
"platondev"
|
|
924
|
-
],
|
|
925
976
|
"210425": [
|
|
926
977
|
"platon"
|
|
927
978
|
],
|
|
@@ -967,6 +1018,9 @@ exports.default = {
|
|
|
967
1018
|
"1337702": [
|
|
968
1019
|
"kintsugi"
|
|
969
1020
|
],
|
|
1021
|
+
"2203181": [
|
|
1022
|
+
"platondev"
|
|
1023
|
+
],
|
|
970
1024
|
"7762959": [
|
|
971
1025
|
"music"
|
|
972
1026
|
],
|
|
@@ -40,17 +40,12 @@ export class BaseContract {
|
|
|
40
40
|
? estimateGas(data)
|
|
41
41
|
: null;
|
|
42
42
|
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return yield post(this._provider._rpcUrl
|
|
44
|
-
Object.assign({ to: this._address.toLowerCase(), data
|
|
43
|
+
return yield post(this._provider._rpcUrl, buildRPCPostBody('eth_call', [
|
|
44
|
+
Object.assign({ to: this._address.toLowerCase(), data }, (decimalGas
|
|
45
45
|
? { gas: `0x${decimalGas.toString(16)}` }
|
|
46
46
|
: {})),
|
|
47
47
|
'latest',
|
|
48
|
-
]))
|
|
49
|
-
if (e.code === 'ENOTFOUND') {
|
|
50
|
-
this._provider._rpcUrlCounter++;
|
|
51
|
-
return req();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
48
|
+
]));
|
|
54
49
|
});
|
|
55
50
|
const nodeResponse = yield req();
|
|
56
51
|
return decodeRPCResponse(jsonABIArgument, nodeResponse);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function post(url: string, body: Record<string, unknown>): Promise<any>;
|
|
2
|
-
declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_call' | 'eth_chainId';
|
|
2
|
+
declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice';
|
|
3
3
|
export declare function buildRPCPostBody(method: RPCMethodName, params: any[]): {
|
|
4
4
|
jsonrpc: string;
|
|
5
5
|
id: number;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import unfetch from 'isomorphic-unfetch';
|
|
2
11
|
export function post(url, body) {
|
|
3
12
|
return unfetch(url, {
|
|
@@ -7,10 +16,19 @@ export function post(url, body) {
|
|
|
7
16
|
},
|
|
8
17
|
body: JSON.stringify(body),
|
|
9
18
|
})
|
|
10
|
-
.then((r) =>
|
|
19
|
+
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const t = yield r.text();
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(t);
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
throw new Error(`Invalid JSON RPC response: "${t}"`);
|
|
26
|
+
}
|
|
27
|
+
}))
|
|
11
28
|
.then((response) => {
|
|
12
|
-
|
|
13
|
-
|
|
29
|
+
const result = response === null || response === void 0 ? void 0 : response.result;
|
|
30
|
+
if (!result) {
|
|
31
|
+
throw new Error(`Invalid JSON RPC response: ${JSON.stringify(response)}`);
|
|
14
32
|
}
|
|
15
33
|
return response.result;
|
|
16
34
|
});
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -5,9 +5,8 @@ import { Block } from './types/Block.types';
|
|
|
5
5
|
import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
|
|
6
6
|
import { Network } from './types/Network.types';
|
|
7
7
|
import { Transaction } from './types/Transaction.types';
|
|
8
|
-
import * as utils from './utils';
|
|
9
8
|
import { etherToWei } from './utils/ether-to-wei';
|
|
10
9
|
import { isAddress } from './utils/is-address';
|
|
11
10
|
import { toChecksumAddress } from './utils/to-checksum-address';
|
|
12
11
|
import { weiToEther } from './utils/wei-to-ether';
|
|
13
|
-
export {
|
|
12
|
+
export { etherToWei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, Contract, TinyBig, Block, ContractTypes, JSONABI, JSONABIArgument, Network, Transaction, };
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Contract } from './classes/Contract';
|
|
2
2
|
import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
|
|
3
3
|
import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
|
|
4
|
-
import * as utils from './utils';
|
|
5
4
|
import { etherToWei } from './utils/ether-to-wei';
|
|
6
5
|
import { isAddress } from './utils/is-address';
|
|
7
6
|
import { toChecksumAddress } from './utils/to-checksum-address';
|
|
8
7
|
import { weiToEther } from './utils/wei-to-ether';
|
|
9
|
-
export {
|
|
8
|
+
export { etherToWei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, Contract, TinyBig, };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { TinyBig } from '../shared/tiny-big/tiny-big';
|
|
1
2
|
import { Block } from '../types/Block.types';
|
|
2
3
|
import { Network } from '../types/Network.types';
|
|
3
4
|
export declare class JsonRpcProvider {
|
|
4
|
-
readonly _rpcUrl:
|
|
5
|
-
|
|
6
|
-
constructor(rpcUrl?: string | Array<string>);
|
|
5
|
+
readonly _rpcUrl: string;
|
|
6
|
+
constructor(rpcUrl?: string);
|
|
7
7
|
getBlock(timeFrame: 'latest' | 'earliest' | 'pending' | number, returnTransactionObjects?: boolean): Promise<Block>;
|
|
8
8
|
getNetwork(): Promise<Network>;
|
|
9
|
+
getGasPrice(): Promise<TinyBig>;
|
|
9
10
|
}
|
|
10
11
|
export declare function jsonRpcProvider(rpcUrl?: string): JsonRpcProvider;
|
|
@@ -10,19 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { cleanBlock } from '../classes/utils/clean-block';
|
|
11
11
|
import { buildRPCPostBody, post } from '../classes/utils/fetchers';
|
|
12
12
|
import { hexToDecimal } from '../classes/utils/hex-to-decimal';
|
|
13
|
+
import { tinyBig } from '../shared/tiny-big/tiny-big';
|
|
13
14
|
import chainsInfo from './utils/chains-info';
|
|
14
15
|
export class JsonRpcProvider {
|
|
15
16
|
constructor(rpcUrl) {
|
|
16
|
-
this._rpcUrl =
|
|
17
|
-
if (!rpcUrl) {
|
|
18
|
-
return ['https://free-eth-node.com/api/eth'];
|
|
19
|
-
}
|
|
20
|
-
else if (!Array.isArray(rpcUrl)) {
|
|
21
|
-
return [rpcUrl];
|
|
22
|
-
}
|
|
23
|
-
return rpcUrl;
|
|
24
|
-
})();
|
|
25
|
-
this._rpcUrlCounter = 0;
|
|
17
|
+
this._rpcUrl = rpcUrl || 'https://free-eth-node.com/api/eth';
|
|
26
18
|
}
|
|
27
19
|
getBlock(timeFrame, returnTransactionObjects = false) {
|
|
28
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,15 +26,10 @@ export class JsonRpcProvider {
|
|
|
34
26
|
rpcTimeFrame = timeFrame;
|
|
35
27
|
}
|
|
36
28
|
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return yield post(this._rpcUrl
|
|
29
|
+
return yield post(this._rpcUrl, buildRPCPostBody('eth_getBlockByNumber', [
|
|
38
30
|
rpcTimeFrame,
|
|
39
31
|
returnTransactionObjects,
|
|
40
|
-
]))
|
|
41
|
-
if (e.code === 'ENOTFOUND') {
|
|
42
|
-
this._rpcUrlCounter++;
|
|
43
|
-
return req();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
32
|
+
]));
|
|
46
33
|
});
|
|
47
34
|
const nodeResponse = (yield req());
|
|
48
35
|
return cleanBlock(nodeResponse, returnTransactionObjects);
|
|
@@ -51,12 +38,7 @@ export class JsonRpcProvider {
|
|
|
51
38
|
getNetwork() {
|
|
52
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
40
|
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return yield post(this._rpcUrl
|
|
55
|
-
if (e.code === 'ENOTFOUND') {
|
|
56
|
-
this._rpcUrlCounter++;
|
|
57
|
-
return req();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
41
|
+
return yield post(this._rpcUrl, buildRPCPostBody('eth_chainId', []));
|
|
60
42
|
});
|
|
61
43
|
const nodeResponse = (yield req());
|
|
62
44
|
const chainId = hexToDecimal(nodeResponse);
|
|
@@ -68,6 +50,15 @@ export class JsonRpcProvider {
|
|
|
68
50
|
};
|
|
69
51
|
});
|
|
70
52
|
}
|
|
53
|
+
getGasPrice() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return yield post(this._rpcUrl, buildRPCPostBody('eth_gasPrice', []));
|
|
57
|
+
});
|
|
58
|
+
const nodeResponse = (yield req());
|
|
59
|
+
return tinyBig(hexToDecimal(nodeResponse));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
71
62
|
}
|
|
72
63
|
export function jsonRpcProvider(rpcUrl) {
|
|
73
64
|
return new JsonRpcProvider(rpcUrl);
|
|
@@ -45,6 +45,7 @@ declare const _default: {
|
|
|
45
45
|
"51": string[];
|
|
46
46
|
"52": string[];
|
|
47
47
|
"53": string[];
|
|
48
|
+
"54": string[];
|
|
48
49
|
"55": string[];
|
|
49
50
|
"56": string[];
|
|
50
51
|
"57": string[];
|
|
@@ -98,9 +99,11 @@ declare const _default: {
|
|
|
98
99
|
"127": string[];
|
|
99
100
|
"128": string[];
|
|
100
101
|
"137": string[];
|
|
102
|
+
"141": string[];
|
|
101
103
|
"142": string[];
|
|
102
104
|
"162": string[];
|
|
103
105
|
"163": string[];
|
|
106
|
+
"168": string[];
|
|
104
107
|
"170": string[];
|
|
105
108
|
"172": string[];
|
|
106
109
|
"186": string[];
|
|
@@ -109,7 +112,10 @@ declare const _default: {
|
|
|
109
112
|
"199": string[];
|
|
110
113
|
"200": string[];
|
|
111
114
|
"211": string[];
|
|
115
|
+
"218": string[];
|
|
112
116
|
"222": string[];
|
|
117
|
+
"225": string[];
|
|
118
|
+
"226": string[];
|
|
113
119
|
"246": string[];
|
|
114
120
|
"250": string[];
|
|
115
121
|
"256": string[];
|
|
@@ -145,6 +151,7 @@ declare const _default: {
|
|
|
145
151
|
"721": string[];
|
|
146
152
|
"777": string[];
|
|
147
153
|
"787": string[];
|
|
154
|
+
"788": string[];
|
|
148
155
|
"803": string[];
|
|
149
156
|
"820": string[];
|
|
150
157
|
"821": string[];
|
|
@@ -180,14 +187,18 @@ declare const _default: {
|
|
|
180
187
|
"1280": string[];
|
|
181
188
|
"1284": string[];
|
|
182
189
|
"1285": string[];
|
|
190
|
+
"1286": string[];
|
|
183
191
|
"1287": string[];
|
|
184
192
|
"1288": string[];
|
|
193
|
+
"1337": string[];
|
|
185
194
|
"1618": string[];
|
|
186
195
|
"1620": string[];
|
|
187
196
|
"1657": string[];
|
|
197
|
+
"1688": string[];
|
|
188
198
|
"1856": string[];
|
|
189
199
|
"1898": string[];
|
|
190
200
|
"1987": string[];
|
|
201
|
+
"2001": string[];
|
|
191
202
|
"2020": string[];
|
|
192
203
|
"2021": string[];
|
|
193
204
|
"2022": string[];
|
|
@@ -195,7 +206,10 @@ declare const _default: {
|
|
|
195
206
|
"2100": string[];
|
|
196
207
|
"2101": string[];
|
|
197
208
|
"2213": string[];
|
|
209
|
+
"2221": string[];
|
|
198
210
|
"2559": string[];
|
|
211
|
+
"3000": string[];
|
|
212
|
+
"3001": string[];
|
|
199
213
|
"3331": string[];
|
|
200
214
|
"3333": string[];
|
|
201
215
|
"3334": string[];
|
|
@@ -205,12 +219,14 @@ declare const _default: {
|
|
|
205
219
|
"3966": string[];
|
|
206
220
|
"3967": string[];
|
|
207
221
|
"4002": string[];
|
|
222
|
+
"4102": string[];
|
|
208
223
|
"4689": string[];
|
|
209
224
|
"4690": string[];
|
|
210
225
|
"4918": string[];
|
|
211
226
|
"5197": string[];
|
|
212
227
|
"5315": string[];
|
|
213
228
|
"5700": string[];
|
|
229
|
+
"5777": string[];
|
|
214
230
|
"5851": string[];
|
|
215
231
|
"5869": string[];
|
|
216
232
|
"6626": string[];
|
|
@@ -259,6 +275,7 @@ declare const _default: {
|
|
|
259
275
|
"43113": string[];
|
|
260
276
|
"43114": string[];
|
|
261
277
|
"44787": string[];
|
|
278
|
+
"45000": string[];
|
|
262
279
|
"47805": string[];
|
|
263
280
|
"49797": string[];
|
|
264
281
|
"53935": string[];
|
|
@@ -300,10 +317,10 @@ declare const _default: {
|
|
|
300
317
|
"110006": string[];
|
|
301
318
|
"110007": string[];
|
|
302
319
|
"110008": string[];
|
|
320
|
+
"200101": string[];
|
|
303
321
|
"200625": string[];
|
|
304
322
|
"201018": string[];
|
|
305
323
|
"201030": string[];
|
|
306
|
-
"210309": string[];
|
|
307
324
|
"210425": string[];
|
|
308
325
|
"234666": string[];
|
|
309
326
|
"246529": string[];
|
|
@@ -319,6 +336,7 @@ declare const _default: {
|
|
|
319
336
|
"1313114": string[];
|
|
320
337
|
"1313500": string[];
|
|
321
338
|
"1337702": string[];
|
|
339
|
+
"2203181": string[];
|
|
322
340
|
"7762959": string[];
|
|
323
341
|
"11155111": string[];
|
|
324
342
|
"13371337": string[];
|
|
@@ -141,6 +141,9 @@ export default {
|
|
|
141
141
|
"53": [
|
|
142
142
|
"tcet"
|
|
143
143
|
],
|
|
144
|
+
"54": [
|
|
145
|
+
"OP"
|
|
146
|
+
],
|
|
144
147
|
"55": [
|
|
145
148
|
"ZYX"
|
|
146
149
|
],
|
|
@@ -300,6 +303,9 @@ export default {
|
|
|
300
303
|
"137": [
|
|
301
304
|
"MATIC"
|
|
302
305
|
],
|
|
306
|
+
"141": [
|
|
307
|
+
"OPtest"
|
|
308
|
+
],
|
|
303
309
|
"142": [
|
|
304
310
|
"dax"
|
|
305
311
|
],
|
|
@@ -309,6 +315,9 @@ export default {
|
|
|
309
315
|
"163": [
|
|
310
316
|
"pht"
|
|
311
317
|
],
|
|
318
|
+
"168": [
|
|
319
|
+
"aioz"
|
|
320
|
+
],
|
|
312
321
|
"170": [
|
|
313
322
|
"hoosmartchain"
|
|
314
323
|
],
|
|
@@ -333,9 +342,18 @@ export default {
|
|
|
333
342
|
"211": [
|
|
334
343
|
"EDI"
|
|
335
344
|
],
|
|
345
|
+
"218": [
|
|
346
|
+
"SO1-old"
|
|
347
|
+
],
|
|
336
348
|
"222": [
|
|
337
349
|
"ASK"
|
|
338
350
|
],
|
|
351
|
+
"225": [
|
|
352
|
+
"LA"
|
|
353
|
+
],
|
|
354
|
+
"226": [
|
|
355
|
+
"TLA"
|
|
356
|
+
],
|
|
339
357
|
"246": [
|
|
340
358
|
"ewt"
|
|
341
359
|
],
|
|
@@ -441,6 +459,9 @@ export default {
|
|
|
441
459
|
"787": [
|
|
442
460
|
"aca"
|
|
443
461
|
],
|
|
462
|
+
"788": [
|
|
463
|
+
"taero"
|
|
464
|
+
],
|
|
444
465
|
"803": [
|
|
445
466
|
"haic"
|
|
446
467
|
],
|
|
@@ -546,12 +567,18 @@ export default {
|
|
|
546
567
|
"1285": [
|
|
547
568
|
"mriver"
|
|
548
569
|
],
|
|
570
|
+
"1286": [
|
|
571
|
+
"mrock-old"
|
|
572
|
+
],
|
|
549
573
|
"1287": [
|
|
550
574
|
"mbase"
|
|
551
575
|
],
|
|
552
576
|
"1288": [
|
|
553
577
|
"mrock"
|
|
554
578
|
],
|
|
579
|
+
"1337": [
|
|
580
|
+
"cennz-a"
|
|
581
|
+
],
|
|
555
582
|
"1618": [
|
|
556
583
|
"cate"
|
|
557
584
|
],
|
|
@@ -561,6 +588,9 @@ export default {
|
|
|
561
588
|
"1657": [
|
|
562
589
|
"bta"
|
|
563
590
|
],
|
|
591
|
+
"1688": [
|
|
592
|
+
"LUDAN"
|
|
593
|
+
],
|
|
564
594
|
"1856": [
|
|
565
595
|
"tsf"
|
|
566
596
|
],
|
|
@@ -570,6 +600,9 @@ export default {
|
|
|
570
600
|
"1987": [
|
|
571
601
|
"egem"
|
|
572
602
|
],
|
|
603
|
+
"2001": [
|
|
604
|
+
"milkAda"
|
|
605
|
+
],
|
|
573
606
|
"2020": [
|
|
574
607
|
"420"
|
|
575
608
|
],
|
|
@@ -591,9 +624,18 @@ export default {
|
|
|
591
624
|
"2213": [
|
|
592
625
|
"evanesco"
|
|
593
626
|
],
|
|
627
|
+
"2221": [
|
|
628
|
+
"kava"
|
|
629
|
+
],
|
|
594
630
|
"2559": [
|
|
595
631
|
"ktoc"
|
|
596
632
|
],
|
|
633
|
+
"3000": [
|
|
634
|
+
"cennz-r"
|
|
635
|
+
],
|
|
636
|
+
"3001": [
|
|
637
|
+
"cennz-n"
|
|
638
|
+
],
|
|
597
639
|
"3331": [
|
|
598
640
|
"zcrbeach"
|
|
599
641
|
],
|
|
@@ -621,6 +663,9 @@ export default {
|
|
|
621
663
|
"4002": [
|
|
622
664
|
"tftm"
|
|
623
665
|
],
|
|
666
|
+
"4102": [
|
|
667
|
+
"aioz-testnet"
|
|
668
|
+
],
|
|
624
669
|
"4689": [
|
|
625
670
|
"iotex-mainnet"
|
|
626
671
|
],
|
|
@@ -639,6 +684,9 @@ export default {
|
|
|
639
684
|
"5700": [
|
|
640
685
|
"tsys"
|
|
641
686
|
],
|
|
687
|
+
"5777": [
|
|
688
|
+
"dgcc"
|
|
689
|
+
],
|
|
642
690
|
"5851": [
|
|
643
691
|
"Ontology Testnet"
|
|
644
692
|
],
|
|
@@ -783,6 +831,9 @@ export default {
|
|
|
783
831
|
"44787": [
|
|
784
832
|
"ALFA"
|
|
785
833
|
],
|
|
834
|
+
"45000": [
|
|
835
|
+
"autobahn"
|
|
836
|
+
],
|
|
786
837
|
"47805": [
|
|
787
838
|
"REI"
|
|
788
839
|
],
|
|
@@ -906,6 +957,9 @@ export default {
|
|
|
906
957
|
"110008": [
|
|
907
958
|
"qkc-d-s7"
|
|
908
959
|
],
|
|
960
|
+
"200101": [
|
|
961
|
+
"milkTAda"
|
|
962
|
+
],
|
|
909
963
|
"200625": [
|
|
910
964
|
"aka"
|
|
911
965
|
],
|
|
@@ -915,9 +969,6 @@ export default {
|
|
|
915
969
|
"201030": [
|
|
916
970
|
"alayadev"
|
|
917
971
|
],
|
|
918
|
-
"210309": [
|
|
919
|
-
"platondev"
|
|
920
|
-
],
|
|
921
972
|
"210425": [
|
|
922
973
|
"platon"
|
|
923
974
|
],
|
|
@@ -963,6 +1014,9 @@ export default {
|
|
|
963
1014
|
"1337702": [
|
|
964
1015
|
"kintsugi"
|
|
965
1016
|
],
|
|
1017
|
+
"2203181": [
|
|
1018
|
+
"platondev"
|
|
1019
|
+
],
|
|
966
1020
|
"7762959": [
|
|
967
1021
|
"music"
|
|
968
1022
|
],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "essential-eth",
|
|
3
3
|
"description": "Ultralight JS library for Ethereum utilities",
|
|
4
|
-
"version": "0.4.9
|
|
4
|
+
"version": "0.4.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
"tsc:esm": "tsc -p tsconfig.json",
|
|
23
23
|
"tsc:cjs": "tsc -p tsconfig-cjs.json",
|
|
24
24
|
"build": "rm -rf lib && npm run compile",
|
|
25
|
-
"prepublishOnly": "npm run build
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
26
|
"jest": "jest",
|
|
27
27
|
"build:chains-info": "npx ts-node scripts/fetch-chains-info.ts # used in getNetwork()",
|
|
28
|
-
"build:website": "sh scripts/build-website.sh",
|
|
29
|
-
"build:website:new-version": "typedoc --options typedoc/options-new-version.js",
|
|
30
28
|
"pre-commit": "sh scripts/pre-commit.sh"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
@@ -38,7 +36,6 @@
|
|
|
38
36
|
"@types/jest-dev-server": "^5.0.0",
|
|
39
37
|
"@types/node": "^16.10.1",
|
|
40
38
|
"@types/prettier": "^2.4.4",
|
|
41
|
-
"@types/supertest": "^2.0.11",
|
|
42
39
|
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
43
40
|
"@typescript-eslint/parser": "^5.17.0",
|
|
44
41
|
"body-parser": "^1.19.0",
|
|
@@ -50,15 +47,14 @@
|
|
|
50
47
|
"husky": "^4.3.0",
|
|
51
48
|
"jest": "^27.5.1",
|
|
52
49
|
"jest-dev-server": "^6.0.3",
|
|
53
|
-
"just-omit": "^
|
|
50
|
+
"just-omit": "^2.0.1",
|
|
54
51
|
"lint-staged": "^12.3.7",
|
|
55
52
|
"npm-run-all": "^4.1.5",
|
|
56
|
-
"prettier": "^2.6.
|
|
53
|
+
"prettier": "^2.6.2",
|
|
57
54
|
"prettier-plugin-organize-imports": "^2.3.4",
|
|
58
|
-
"supertest": "^6.1.6",
|
|
59
55
|
"ts-jest": "^27.1.4",
|
|
60
56
|
"ts-node": "^10.2.1",
|
|
61
|
-
"typedoc": "^0.22.
|
|
57
|
+
"typedoc": "^0.22.13",
|
|
62
58
|
"typescript": "^4.6.3",
|
|
63
59
|
"web3": "^1.7.1"
|
|
64
60
|
},
|
|
@@ -70,7 +66,7 @@
|
|
|
70
66
|
},
|
|
71
67
|
"husky": {
|
|
72
68
|
"hooks": {
|
|
73
|
-
"pre-commit": "lint-staged && run-p pre-commit test build:
|
|
69
|
+
"pre-commit": "lint-staged && run-p pre-commit test build:chains-info"
|
|
74
70
|
}
|
|
75
71
|
},
|
|
76
72
|
"lint-staged": {
|
package/readme.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a><img src="https://
|
|
2
|
+
<a><img src="https://user-images.githubusercontent.com/3408480/161474132-ae95d289-2298-46f1-b48d-9c02d88f7e38.png" title="Logo" height="400" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
<p align="center">
|
|
5
5
|
<b>
|
|
6
6
|
Essential Eth
|
|
7
7
|
</b>
|
|
8
|
-
<br
|
|
9
|
-
<i>
|
|
10
|
-
<br
|
|
8
|
+
<br/>
|
|
9
|
+
<i>A replacement for ethers & web3 that's 50x smaller</i>
|
|
10
|
+
<br/>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
<br
|
|
15
|
+
<br/>
|
|
16
16
|
|
|
17
17
|
## Why you should replace Ethers.js and web3
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
|
-
<br
|
|
29
|
+
<br/>
|
|
30
30
|
|
|
31
31
|
- ⚡️ A replacement for `web3` and `ethers`
|
|
32
32
|
- 🏎 [The TINIEST code size possible](https://bundlephobia.com/package/essential-eth)
|
|
@@ -188,12 +188,38 @@ const essentialEth = new JsonRpcProvider(
|
|
|
188
188
|
const essentialEth = new JsonRpcProvider();
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
#### `getGasPrice`
|
|
192
|
+
|
|
193
|
+
Returns the current gas price in gwei
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// Same as ethers.providers.getGasPrice
|
|
197
|
+
getGasPrice(): Promise<TinyBig>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>View Example</summary>
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { JsonRpcProvider } from 'essential-eth';
|
|
205
|
+
|
|
206
|
+
const provider = new JsonRpcProvider('https://free-eth-node.com/api/eth');
|
|
207
|
+
provider.getGasPrice().toNumber();
|
|
208
|
+
/*
|
|
209
|
+
39695942769
|
|
210
|
+
*/
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
</details>
|
|
214
|
+
|
|
215
|
+
<br/>
|
|
216
|
+
|
|
191
217
|
#### `getNetwork`
|
|
192
218
|
|
|
193
|
-
Returns a
|
|
219
|
+
Returns a Network
|
|
194
220
|
|
|
195
221
|
```typescript
|
|
196
|
-
// Same API as ethers
|
|
222
|
+
// Same API as ethers.providers.getNetwork
|
|
197
223
|
getNetwork(): Promise<Network>
|
|
198
224
|
```
|
|
199
225
|
|
|
@@ -224,7 +250,7 @@ xdaiProvider.getNetwork();
|
|
|
224
250
|
|
|
225
251
|
#### `getBlock`
|
|
226
252
|
|
|
227
|
-
Returns a
|
|
253
|
+
Returns a Block
|
|
228
254
|
|
|
229
255
|
```typescript
|
|
230
256
|
// Same API as web3.eth.getBlock
|
package/lib/cjs/utils/index.d.ts
DELETED
package/lib/cjs/utils/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.weiToEther = exports.toChecksumAddress = exports.isAddress = exports.etherToWei = void 0;
|
|
4
|
-
const ether_to_wei_1 = require("./ether-to-wei");
|
|
5
|
-
Object.defineProperty(exports, "etherToWei", { enumerable: true, get: function () { return ether_to_wei_1.etherToWei; } });
|
|
6
|
-
const is_address_1 = require("./is-address");
|
|
7
|
-
Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_address_1.isAddress; } });
|
|
8
|
-
const to_checksum_address_1 = require("./to-checksum-address");
|
|
9
|
-
Object.defineProperty(exports, "toChecksumAddress", { enumerable: true, get: function () { return to_checksum_address_1.toChecksumAddress; } });
|
|
10
|
-
const wei_to_ether_1 = require("./wei-to-ether");
|
|
11
|
-
Object.defineProperty(exports, "weiToEther", { enumerable: true, get: function () { return wei_to_ether_1.weiToEther; } });
|
package/lib/esm/utils/index.d.ts
DELETED
package/lib/esm/utils/index.js
DELETED