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,134 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
function _classCallCheck(instance, Constructor) {
|
|
8
|
-
if (!(instance instanceof Constructor)) {
|
|
9
|
-
throw new TypeError("Cannot call a class as a function");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function _getPrototypeOf(o) {
|
|
13
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
14
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
15
|
-
};
|
|
16
|
-
return _getPrototypeOf(o);
|
|
17
|
-
}
|
|
18
|
-
function _inherits(subClass, superClass) {
|
|
19
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
20
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
21
|
-
}
|
|
22
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
23
|
-
constructor: {
|
|
24
|
-
value: subClass,
|
|
25
|
-
writable: true,
|
|
26
|
-
configurable: true
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
30
|
-
}
|
|
31
|
-
function _possibleConstructorReturn(self, call) {
|
|
32
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
33
|
-
return call;
|
|
34
|
-
}
|
|
35
|
-
return _assertThisInitialized(self);
|
|
36
|
-
}
|
|
37
|
-
function _setPrototypeOf(o, p) {
|
|
38
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
39
|
-
o.__proto__ = p;
|
|
40
|
-
return o;
|
|
41
|
-
};
|
|
42
|
-
return _setPrototypeOf(o, p);
|
|
43
|
-
}
|
|
44
|
-
var _typeof = function(obj) {
|
|
45
|
-
"@swc/helpers - typeof";
|
|
46
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
47
|
-
};
|
|
48
|
-
function _isNativeReflectConstruct() {
|
|
49
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
50
|
-
if (Reflect.construct.sham) return false;
|
|
51
|
-
if (typeof Proxy === "function") return true;
|
|
52
|
-
try {
|
|
53
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
54
|
-
return true;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function _createSuper(Derived) {
|
|
60
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
61
|
-
return function _createSuperInternal() {
|
|
62
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
63
|
-
if (hasNativeReflectConstruct) {
|
|
64
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
65
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
66
|
-
} else {
|
|
67
|
-
result = Super.apply(this, arguments);
|
|
68
|
-
}
|
|
69
|
-
return _possibleConstructorReturn(this, result);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
import { logger } from "../logger/logger";
|
|
73
|
-
import { BaseProvider } from "./BaseProvider";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FallthroughProvider = void 0;
|
|
4
|
+
const logger_1 = require("../logger/logger");
|
|
5
|
+
const BaseProvider_1 = require("./BaseProvider");
|
|
74
6
|
// https://advancedweb.hu/how-to-add-timeout-to-a-promise-in-javascript/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
reject(error);
|
|
86
|
-
});
|
|
7
|
+
const promiseTimeout = (prom, time) => new Promise((resolve, reject) => {
|
|
8
|
+
const timeout = setTimeout(() => reject(new Error('Promise timed out')), time);
|
|
9
|
+
prom
|
|
10
|
+
.then((result) => {
|
|
11
|
+
clearTimeout(timeout);
|
|
12
|
+
resolve(result);
|
|
13
|
+
})
|
|
14
|
+
.catch((error) => {
|
|
15
|
+
clearTimeout(timeout);
|
|
16
|
+
reject(error);
|
|
87
17
|
});
|
|
88
|
-
};
|
|
89
|
-
|
|
18
|
+
});
|
|
19
|
+
const DEFAULT_TIMEOUT_DURATION = 8000;
|
|
90
20
|
/**
|
|
91
21
|
* @beta
|
|
92
22
|
* A JSON RPC Provider which moves to the next URL when one fails.
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
23
|
+
*/
|
|
24
|
+
class FallthroughProvider extends BaseProvider_1.BaseProvider {
|
|
25
|
+
/**
|
|
26
|
+
* @ignore
|
|
27
|
+
*/
|
|
28
|
+
selectRpcUrl() {
|
|
29
|
+
return this._rpcUrls[this.rpcUrlCounter];
|
|
30
|
+
}
|
|
31
|
+
constructor(rpcUrls, options = {}) {
|
|
101
32
|
if (!Array.isArray(rpcUrls)) {
|
|
102
|
-
logger.throwError(
|
|
103
|
-
rpcUrls: rpcUrls
|
|
104
|
-
});
|
|
33
|
+
logger_1.logger.throwError('Array required', { rpcUrls });
|
|
105
34
|
}
|
|
106
35
|
if (rpcUrls.length <= 1) {
|
|
107
|
-
logger.throwError(
|
|
108
|
-
rpcUrls: rpcUrls
|
|
109
|
-
});
|
|
36
|
+
logger_1.logger.throwError('More than one rpcUrl is required', { rpcUrls });
|
|
110
37
|
}
|
|
111
|
-
|
|
38
|
+
super(rpcUrls);
|
|
112
39
|
// index of current trusted rpc url
|
|
113
40
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
41
|
+
* @ignore
|
|
42
|
+
*/
|
|
43
|
+
this.rpcUrlCounter = 0;
|
|
116
44
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
45
|
+
* @ignore
|
|
46
|
+
*/
|
|
47
|
+
this.post = (body) => {
|
|
119
48
|
// while failing post, add to rpcUrlCounter and post again
|
|
120
|
-
|
|
121
|
-
|
|
49
|
+
const genesisCount = this.rpcUrlCounter;
|
|
50
|
+
const recursivePostRetry = () => {
|
|
122
51
|
// Times out request
|
|
123
|
-
|
|
124
|
-
|
|
52
|
+
const genesisRpcUrl = this.selectRpcUrl();
|
|
53
|
+
const res = promiseTimeout(this._post(body), this.timeoutDuration).catch((e) => {
|
|
125
54
|
// A mutex: Only add if no other instance has discovered this url as failing yet
|
|
126
|
-
if (genesisRpcUrl ===
|
|
55
|
+
if (genesisRpcUrl === this.selectRpcUrl()) {
|
|
127
56
|
// add one and handle array overflow
|
|
128
|
-
|
|
57
|
+
this.rpcUrlCounter =
|
|
58
|
+
(this.rpcUrlCounter + 1) % this._rpcUrls.length;
|
|
129
59
|
}
|
|
130
60
|
// we've already tried this rpc, throw for good
|
|
131
|
-
if (
|
|
61
|
+
if (this.rpcUrlCounter === genesisCount) {
|
|
132
62
|
throw e;
|
|
133
63
|
}
|
|
134
64
|
return recursivePostRetry();
|
|
@@ -137,14 +67,7 @@ var DEFAULT_TIMEOUT_DURATION = 8000;
|
|
|
137
67
|
};
|
|
138
68
|
return recursivePostRetry();
|
|
139
69
|
};
|
|
140
|
-
|
|
141
|
-
return _this;
|
|
70
|
+
this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
|
|
142
71
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* @ignore
|
|
146
|
-
*/ _proto.selectRpcUrl = function selectRpcUrl() {
|
|
147
|
-
return this._rpcUrls[this.rpcUrlCounter];
|
|
148
|
-
};
|
|
149
|
-
return FallthroughProvider;
|
|
150
|
-
}(BaseProvider);
|
|
72
|
+
}
|
|
73
|
+
exports.FallthroughProvider = FallthroughProvider;
|
|
@@ -1,99 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
function _classCallCheck(instance, Constructor) {
|
|
8
|
-
if (!(instance instanceof Constructor)) {
|
|
9
|
-
throw new TypeError("Cannot call a class as a function");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function _getPrototypeOf(o) {
|
|
13
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
14
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
15
|
-
};
|
|
16
|
-
return _getPrototypeOf(o);
|
|
17
|
-
}
|
|
18
|
-
function _inherits(subClass, superClass) {
|
|
19
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
20
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
21
|
-
}
|
|
22
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
23
|
-
constructor: {
|
|
24
|
-
value: subClass,
|
|
25
|
-
writable: true,
|
|
26
|
-
configurable: true
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
30
|
-
}
|
|
31
|
-
function _possibleConstructorReturn(self, call) {
|
|
32
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
33
|
-
return call;
|
|
34
|
-
}
|
|
35
|
-
return _assertThisInitialized(self);
|
|
36
|
-
}
|
|
37
|
-
function _setPrototypeOf(o, p) {
|
|
38
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
39
|
-
o.__proto__ = p;
|
|
40
|
-
return o;
|
|
41
|
-
};
|
|
42
|
-
return _setPrototypeOf(o, p);
|
|
43
|
-
}
|
|
44
|
-
var _typeof = function(obj) {
|
|
45
|
-
"@swc/helpers - typeof";
|
|
46
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
47
|
-
};
|
|
48
|
-
function _isNativeReflectConstruct() {
|
|
49
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
50
|
-
if (Reflect.construct.sham) return false;
|
|
51
|
-
if (typeof Proxy === "function") return true;
|
|
52
|
-
try {
|
|
53
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
54
|
-
return true;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function _createSuper(Derived) {
|
|
60
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
61
|
-
return function _createSuperInternal() {
|
|
62
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
63
|
-
if (hasNativeReflectConstruct) {
|
|
64
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
65
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
66
|
-
} else {
|
|
67
|
-
result = Super.apply(this, arguments);
|
|
68
|
-
}
|
|
69
|
-
return _possibleConstructorReturn(this, result);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
import { BaseProvider } from "./BaseProvider";
|
|
73
|
-
export var JsonRpcProvider = /*#__PURE__*/ function(BaseProvider) {
|
|
74
|
-
"use strict";
|
|
75
|
-
_inherits(JsonRpcProvider, BaseProvider);
|
|
76
|
-
var _super = _createSuper(JsonRpcProvider);
|
|
77
|
-
function JsonRpcProvider() {
|
|
78
|
-
var rpcUrl = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "https://free-eth-node.com/api/eth";
|
|
79
|
-
_classCallCheck(this, JsonRpcProvider);
|
|
80
|
-
return _super.call(this, [
|
|
81
|
-
rpcUrl
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
var _proto = JsonRpcProvider.prototype;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsonRpcProvider = exports.JsonRpcProvider = void 0;
|
|
4
|
+
const BaseProvider_1 = require("./BaseProvider");
|
|
5
|
+
class JsonRpcProvider extends BaseProvider_1.BaseProvider {
|
|
85
6
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
selectRpcUrl() {
|
|
88
10
|
return this._rpcUrls[0];
|
|
89
|
-
}
|
|
11
|
+
}
|
|
90
12
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
post(body) {
|
|
93
16
|
return this._post(body);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @param rpcUrl The URL to your Eth node. Consider POKT or Infura
|
|
20
|
+
* @example
|
|
21
|
+
* `https://free-eth-node.com/api/eth`
|
|
22
|
+
* @example
|
|
23
|
+
* `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
|
|
24
|
+
*/
|
|
25
|
+
constructor(rpcUrl = 'https://free-eth-node.com/api/eth') {
|
|
26
|
+
super([rpcUrl]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.JsonRpcProvider = JsonRpcProvider;
|
|
97
30
|
/**
|
|
98
31
|
* Helper function to avoid "new"
|
|
99
32
|
*
|
|
@@ -106,6 +39,8 @@ export var JsonRpcProvider = /*#__PURE__*/ function(BaseProvider) {
|
|
|
106
39
|
* })
|
|
107
40
|
* // 14530496
|
|
108
41
|
* ```
|
|
109
|
-
*/
|
|
42
|
+
*/
|
|
43
|
+
function jsonRpcProvider(rpcUrl) {
|
|
110
44
|
return new JsonRpcProvider(rpcUrl);
|
|
111
45
|
}
|
|
46
|
+
exports.jsonRpcProvider = jsonRpcProvider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Filter } from '../../../../types/Filter.types';
|
|
2
|
+
import type { RPCLog } from '../../../../types/Transaction.types';
|
|
3
|
+
export declare const STRONGBLOCK_ADDRESS = "0xfbddadd80fe7bda00b901fbaf73803f2238ae655";
|
|
4
|
+
export declare const filterAddressFromTo: Filter;
|
|
5
|
+
export declare const RARELAND_ADDRESS = "0x596a0f276ee432d8a28441e55737ff55cf30d0f7";
|
|
6
|
+
export declare const filterAddressTopics: Filter;
|
|
7
|
+
export declare const WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
|
8
|
+
export declare const filterAll: Filter;
|
|
9
|
+
export declare const mockfilterAddressFromToLogs: RPCLog[];
|
|
10
|
+
export declare const mockfilterAddressTopicsLogs: RPCLog[];
|
|
11
|
+
export declare const mockfilterAllLogs: RPCLog[];
|
|
12
|
+
export declare const mockRpcAddressFromToResponse: string;
|
|
13
|
+
export declare const mockRpcAddressTopicsResponse: string;
|
|
14
|
+
export declare const mockRpcAllResponse: string;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Example logs that should be returned
|
|
3
|
+
// https://etherscan.io/address/0xfbddadd80fe7bda00b901fbaf73803f2238ae655#events
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.mockRpcAllResponse = exports.mockRpcAddressTopicsResponse = exports.mockRpcAddressFromToResponse = exports.mockfilterAllLogs = exports.mockfilterAddressTopicsLogs = exports.mockfilterAddressFromToLogs = exports.filterAll = exports.WETH_ADDRESS = exports.filterAddressTopics = exports.RARELAND_ADDRESS = exports.filterAddressFromTo = exports.STRONGBLOCK_ADDRESS = void 0;
|
|
6
|
+
// Block(s) are 14809329
|
|
7
|
+
exports.STRONGBLOCK_ADDRESS = '0xfbddadd80fe7bda00b901fbaf73803f2238ae655';
|
|
8
|
+
exports.filterAddressFromTo = {
|
|
9
|
+
address: exports.STRONGBLOCK_ADDRESS,
|
|
10
|
+
fromBlock: '0xE1F8F1',
|
|
11
|
+
toBlock: '0xE1F8F1',
|
|
12
|
+
};
|
|
13
|
+
// Example logs that should be returned
|
|
14
|
+
// https://etherscan.io/address/0x596a0f276ee432d8a28441e55737ff55cf30d0f7#events
|
|
15
|
+
exports.RARELAND_ADDRESS = '0x596a0f276ee432d8a28441e55737ff55cf30d0f7';
|
|
16
|
+
exports.filterAddressTopics = {
|
|
17
|
+
address: exports.RARELAND_ADDRESS,
|
|
18
|
+
topics: [
|
|
19
|
+
'0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
// https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#events
|
|
23
|
+
// Address is for Wrapped Ether Contract
|
|
24
|
+
exports.WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
|
25
|
+
exports.filterAll = {
|
|
26
|
+
address: exports.WETH_ADDRESS,
|
|
27
|
+
topics: [
|
|
28
|
+
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
29
|
+
'0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
|
|
30
|
+
],
|
|
31
|
+
fromBlock: 14825027,
|
|
32
|
+
toBlock: 14825039,
|
|
33
|
+
};
|
|
34
|
+
exports.mockfilterAddressFromToLogs = [
|
|
35
|
+
{
|
|
36
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
37
|
+
topics: [
|
|
38
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
39
|
+
'0x00000000000000000000000028c2e3e17f8c61a9b7515f7bb1e1347846588b82',
|
|
40
|
+
],
|
|
41
|
+
data: '0x0000000000000000000000000000000000000000000000001dbaed81bf64db6d',
|
|
42
|
+
blockNumber: '0xe1f8f1',
|
|
43
|
+
transactionHash: '0x5dec3a55b87edac0af5c4a9afdd015bb04303fdf86525dd1cc4e7aa7653b6301',
|
|
44
|
+
transactionIndex: '0x29',
|
|
45
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
46
|
+
logIndex: '0x88',
|
|
47
|
+
removed: false,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
51
|
+
topics: [
|
|
52
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
53
|
+
'0x000000000000000000000000c3b80d78bb52fd734c4f730dad5e190ba4ecb830',
|
|
54
|
+
],
|
|
55
|
+
data: '0x0000000000000000000000000000000000000000000000001c277de315af8924',
|
|
56
|
+
blockNumber: '0xe1f8f1',
|
|
57
|
+
transactionHash: '0xae04b63efd57852e34bdc84e257bb413f9f942288f63a131d4b7071c8ee0b896',
|
|
58
|
+
transactionIndex: '0x2f',
|
|
59
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
60
|
+
logIndex: '0x95',
|
|
61
|
+
removed: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
65
|
+
topics: [
|
|
66
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
67
|
+
'0x000000000000000000000000f1a192063f0a2b2be0cbcb2978b13e95e7f35f6b',
|
|
68
|
+
],
|
|
69
|
+
data: '0x00000000000000000000000000000000000000000000000018ecfa70ea275b6d',
|
|
70
|
+
blockNumber: '0xe1f8f1',
|
|
71
|
+
transactionHash: '0xbdba7260507b4ca24757809ac9a23e5225e80a491475ccf89a04c1894a693c77',
|
|
72
|
+
transactionIndex: '0x30',
|
|
73
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
74
|
+
logIndex: '0x97',
|
|
75
|
+
removed: false,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
79
|
+
topics: [
|
|
80
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
81
|
+
'0x000000000000000000000000c78dc12c9b04858d57a108ae948020344895e910',
|
|
82
|
+
],
|
|
83
|
+
data: '0x0000000000000000000000000000000000000000000000000da5142efe16e492',
|
|
84
|
+
blockNumber: '0xe1f8f1',
|
|
85
|
+
transactionHash: '0xdcf29bd8a44ec89a3b53488dd60b76bd7f1c532db76f88e166f3de1ab216537e',
|
|
86
|
+
transactionIndex: '0x31',
|
|
87
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
88
|
+
logIndex: '0x99',
|
|
89
|
+
removed: false,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
93
|
+
topics: [
|
|
94
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
95
|
+
'0x000000000000000000000000aaf5c3760f4a77bdf23974f98d69f9ccfd778aea',
|
|
96
|
+
],
|
|
97
|
+
data: '0x0000000000000000000000000000000000000000000000001086ed3d87034000',
|
|
98
|
+
blockNumber: '0xe1f8f1',
|
|
99
|
+
transactionHash: '0x56130c6e8fdafd0e08411b21ce984eeb56dc61d99a91f03efc7edde748d7ad81',
|
|
100
|
+
transactionIndex: '0x35',
|
|
101
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
102
|
+
logIndex: '0xac',
|
|
103
|
+
removed: false,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
107
|
+
topics: [
|
|
108
|
+
'0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0',
|
|
109
|
+
'0x0000000000000000000000001753de22132990dd5ab35f13a5951431c8ba08ea',
|
|
110
|
+
],
|
|
111
|
+
data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000e3203b',
|
|
112
|
+
blockNumber: '0xe1f8f1',
|
|
113
|
+
transactionHash: '0xf5a77d85296cc670d577d3c9a76b1fa18be77239a4cb4c05493530866d60c36f',
|
|
114
|
+
transactionIndex: '0x3a',
|
|
115
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
116
|
+
logIndex: '0xb5',
|
|
117
|
+
removed: false,
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
exports.mockfilterAddressTopicsLogs = [];
|
|
121
|
+
exports.mockfilterAllLogs = [
|
|
122
|
+
{
|
|
123
|
+
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
124
|
+
topics: [
|
|
125
|
+
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
126
|
+
'0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
|
|
127
|
+
'0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45',
|
|
128
|
+
],
|
|
129
|
+
data: '0x000000000000000000000000000000000000000000000000005f862ee352a38a',
|
|
130
|
+
blockNumber: '0xe23645',
|
|
131
|
+
transactionHash: '0xbd49031be16f8fd1775f4e0fe79b408ffd8ae9c65b2827ee47e3238e3f51f4c0',
|
|
132
|
+
transactionIndex: '0xe2',
|
|
133
|
+
blockHash: '0x8e0dfac2f704851960f866c8708b3bef2f66c0fee0329cf25ff0261b264ca6bc',
|
|
134
|
+
logIndex: '0x180',
|
|
135
|
+
removed: false,
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
exports.mockRpcAddressFromToResponse = JSON.stringify({
|
|
139
|
+
jsonrpc: '2.0',
|
|
140
|
+
id: 1,
|
|
141
|
+
result: exports.mockfilterAddressFromToLogs,
|
|
142
|
+
});
|
|
143
|
+
exports.mockRpcAddressTopicsResponse = JSON.stringify({
|
|
144
|
+
jsonrpc: '2.0',
|
|
145
|
+
id: 1,
|
|
146
|
+
result: exports.mockfilterAddressTopicsLogs,
|
|
147
|
+
});
|
|
148
|
+
exports.mockRpcAllResponse = JSON.stringify({
|
|
149
|
+
jsonrpc: '2.0',
|
|
150
|
+
id: 1,
|
|
151
|
+
result: exports.mockfilterAllLogs,
|
|
152
|
+
});
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mockOf = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Helper function for mocking other functions.
|
|
3
6
|
*
|
|
4
|
-
* Import it using this:
|
|
5
|
-
* ```ts
|
|
6
|
-
* import { mockOf } from '@earnifi/shared/src/utils/testing/mock-of';
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
7
|
* @param fn
|
|
10
8
|
* @example mockOf(stripe.checkout.sessions.create).mockResolvedValue(mockSession);
|
|
11
9
|
* @see https://twitter.com/scastiel/status/1631354119192473601?s=20
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
*/
|
|
11
|
+
const mockOf = (fn) => fn;
|
|
12
|
+
exports.mockOf = mockOf;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rpcUrls = exports.fakeUrls = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
exports.fakeUrls = {
|
|
9
|
+
notRPCButRealHttp: 'https://httpstat.us/200',
|
|
10
|
+
};
|
|
11
|
+
const RPC_ORIGIN = 'https://free-eth-node.com';
|
|
12
|
+
zod_1.default.string({
|
|
13
|
+
required_error: '"RPC_ORIGIN" required but not found',
|
|
14
|
+
})
|
|
15
|
+
.url('Expected url for "RPC_ORIGIN"')
|
|
16
|
+
.parse(RPC_ORIGIN);
|
|
17
|
+
exports.rpcUrls = {
|
|
18
|
+
mainnet: `${RPC_ORIGIN}/api/eth`,
|
|
19
|
+
oeth: `${RPC_ORIGIN}/api/oeth`,
|
|
20
|
+
matic: `${RPC_ORIGIN}/api/MATIC`,
|
|
21
|
+
gno: `${RPC_ORIGIN}/api/gno`,
|
|
22
|
+
bnb: `${RPC_ORIGIN}/api/bnb`,
|
|
23
|
+
arb1: `${RPC_ORIGIN}/api/arb1`,
|
|
24
|
+
gor: `${RPC_ORIGIN}/api/gor`,
|
|
16
25
|
};
|