essential-eth 0.9.1-next.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 -311
- package/dist/cjs/classes/test/Contract/crv-abi.js +256 -252
- 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.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.js +44 -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.js +56 -25
- package/dist/cjs/index.umd.js +1 -1
- package/dist/cjs/index.umd.js.map +1 -1
- package/dist/cjs/logger/logger.js +29 -123
- 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 +520 -958
- package/dist/cjs/providers/FallthroughProvider.js +47 -156
- package/dist/cjs/providers/JsonRpcProvider.js +28 -114
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +104 -101
- package/dist/cjs/providers/test/mock-of.js +6 -3
- package/dist/cjs/providers/test/rpc-urls.js +23 -15
- package/dist/cjs/providers/utils/chains-info.js +3 -1
- package/dist/cjs/shared/tiny-big/helpers.js +42 -93
- package/dist/cjs/shared/tiny-big/tiny-big.js +81 -210
- package/dist/cjs/shared/validate-type.js +7 -7
- package/dist/cjs/types/Block.types.js +2 -1
- 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.js +2 -1
- 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/logger/package-version.d.ts +1 -1
- package/dist/esm/logger/package-version.js +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
- package/dist/cjs/classes/test/Contract/crv.test.js +0 -497
- package/dist/cjs/classes/test/Contract/ens.test.js +0 -160
- 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 -289
- 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 -239
- package/dist/cjs/providers/test/json-rpc-provider/call.test.js +0 -375
- package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +0 -217
- package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +0 -223
- package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +0 -163
- package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +0 -414
- package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +0 -282
- package/dist/cjs/providers/test/json-rpc-provider/get-fee-data.test.js +0 -187
- package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +0 -167
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/get-logs.test.js +0 -219
- package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +0 -232
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +0 -280
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +0 -266
- 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 -64
- package/dist/cjs/utils/tests/bytes/concat.test.js +0 -17
- package/dist/cjs/utils/tests/bytes/hex-concat.test.js +0 -65
- package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +0 -66
- package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +0 -51
- package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +0 -75
- package/dist/cjs/utils/tests/bytes/hex-value.test.js +0 -141
- package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +0 -100
- package/dist/cjs/utils/tests/bytes/hexlify.test.js +0 -78
- package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +0 -68
- package/dist/cjs/utils/tests/bytes/is-bytes.test.js +0 -76
- package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +0 -97
- package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +0 -106
- package/dist/cjs/utils/tests/bytes/zero-pad.test.js +0 -144
- package/dist/cjs/utils/tests/compute-address.test.js +0 -49
- package/dist/cjs/utils/tests/compute-public-key.test.js +0 -26
- package/dist/cjs/utils/tests/ether-to-gwei.test.js +0 -26
- package/dist/cjs/utils/tests/ether-to-wei.test.js +0 -36
- package/dist/cjs/utils/tests/gwei-to-ether.test.js +0 -28
- package/dist/cjs/utils/tests/hash-message.test.js +0 -32
- package/dist/cjs/utils/tests/is-address.test.js +0 -48
- package/dist/cjs/utils/tests/keccak256.test.js +0 -121
- package/dist/cjs/utils/tests/solidity-keccak256.test.js +0 -311
- package/dist/cjs/utils/tests/split-signature.test.js +0 -46
- package/dist/cjs/utils/tests/to-checksum-address.test.js +0 -39
- package/dist/cjs/utils/tests/to-utf8-bytes.test.js +0 -34
- package/dist/cjs/utils/tests/wei-to-ether.test.js +0 -41
|
@@ -1,162 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
function _class_call_check(instance, Constructor) {
|
|
8
|
-
if (!(instance instanceof Constructor)) {
|
|
9
|
-
throw new TypeError("Cannot call a class as a function");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function _defineProperties(target, props) {
|
|
13
|
-
for(var i = 0; i < props.length; i++){
|
|
14
|
-
var descriptor = props[i];
|
|
15
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
16
|
-
descriptor.configurable = true;
|
|
17
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
18
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
22
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
|
-
return Constructor;
|
|
25
|
-
}
|
|
26
|
-
function _define_property(obj, key, value) {
|
|
27
|
-
if (key in obj) {
|
|
28
|
-
Object.defineProperty(obj, key, {
|
|
29
|
-
value: value,
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
obj[key] = value;
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
|
-
function _get_prototype_of(o) {
|
|
40
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
41
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
42
|
-
};
|
|
43
|
-
return _get_prototype_of(o);
|
|
44
|
-
}
|
|
45
|
-
function _inherits(subClass, superClass) {
|
|
46
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
47
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
48
|
-
}
|
|
49
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
50
|
-
constructor: {
|
|
51
|
-
value: subClass,
|
|
52
|
-
writable: true,
|
|
53
|
-
configurable: true
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
57
|
-
}
|
|
58
|
-
function _possible_constructor_return(self, call) {
|
|
59
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
60
|
-
return call;
|
|
61
|
-
}
|
|
62
|
-
return _assert_this_initialized(self);
|
|
63
|
-
}
|
|
64
|
-
function _set_prototype_of(o, p) {
|
|
65
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
66
|
-
o.__proto__ = p;
|
|
67
|
-
return o;
|
|
68
|
-
};
|
|
69
|
-
return _set_prototype_of(o, p);
|
|
70
|
-
}
|
|
71
|
-
function _type_of(obj) {
|
|
72
|
-
"@swc/helpers - typeof";
|
|
73
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
74
|
-
}
|
|
75
|
-
function _is_native_reflect_construct() {
|
|
76
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
77
|
-
if (Reflect.construct.sham) return false;
|
|
78
|
-
if (typeof Proxy === "function") return true;
|
|
79
|
-
try {
|
|
80
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
81
|
-
return true;
|
|
82
|
-
} catch (e) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function _create_super(Derived) {
|
|
87
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
88
|
-
return function _createSuperInternal() {
|
|
89
|
-
var Super = _get_prototype_of(Derived), result;
|
|
90
|
-
if (hasNativeReflectConstruct) {
|
|
91
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
92
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
93
|
-
} else {
|
|
94
|
-
result = Super.apply(this, arguments);
|
|
95
|
-
}
|
|
96
|
-
return _possible_constructor_return(this, result);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
import { logger } from "../logger/logger";
|
|
100
|
-
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");
|
|
101
6
|
// https://advancedweb.hu/how-to-add-timeout-to-a-promise-in-javascript/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
reject(error);
|
|
113
|
-
});
|
|
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);
|
|
114
17
|
});
|
|
115
|
-
};
|
|
116
|
-
|
|
18
|
+
});
|
|
19
|
+
const DEFAULT_TIMEOUT_DURATION = 8000;
|
|
117
20
|
/**
|
|
118
21
|
* @beta
|
|
119
22
|
* A JSON RPC Provider which moves to the next URL when one fails.
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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 = {}) {
|
|
128
32
|
if (!Array.isArray(rpcUrls)) {
|
|
129
|
-
logger.throwError(
|
|
130
|
-
rpcUrls: rpcUrls
|
|
131
|
-
});
|
|
33
|
+
logger_1.logger.throwError('Array required', { rpcUrls });
|
|
132
34
|
}
|
|
133
35
|
if (rpcUrls.length <= 1) {
|
|
134
|
-
logger.throwError(
|
|
135
|
-
rpcUrls: rpcUrls
|
|
136
|
-
});
|
|
36
|
+
logger_1.logger.throwError('More than one rpcUrl is required', { rpcUrls });
|
|
137
37
|
}
|
|
138
|
-
|
|
38
|
+
super(rpcUrls);
|
|
139
39
|
// index of current trusted rpc url
|
|
140
40
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
41
|
+
* @ignore
|
|
42
|
+
*/
|
|
43
|
+
this.rpcUrlCounter = 0;
|
|
144
44
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
45
|
+
* @ignore
|
|
46
|
+
*/
|
|
47
|
+
this.post = (body) => {
|
|
147
48
|
// while failing post, add to rpcUrlCounter and post again
|
|
148
|
-
|
|
149
|
-
|
|
49
|
+
const genesisCount = this.rpcUrlCounter;
|
|
50
|
+
const recursivePostRetry = () => {
|
|
150
51
|
// Times out request
|
|
151
|
-
|
|
152
|
-
|
|
52
|
+
const genesisRpcUrl = this.selectRpcUrl();
|
|
53
|
+
const res = promiseTimeout(this._post(body), this.timeoutDuration).catch((e) => {
|
|
153
54
|
// A mutex: Only add if no other instance has discovered this url as failing yet
|
|
154
|
-
if (genesisRpcUrl ===
|
|
55
|
+
if (genesisRpcUrl === this.selectRpcUrl()) {
|
|
155
56
|
// add one and handle array overflow
|
|
156
|
-
|
|
57
|
+
this.rpcUrlCounter =
|
|
58
|
+
(this.rpcUrlCounter + 1) % this._rpcUrls.length;
|
|
157
59
|
}
|
|
158
60
|
// we've already tried this rpc, throw for good
|
|
159
|
-
if (
|
|
61
|
+
if (this.rpcUrlCounter === genesisCount) {
|
|
160
62
|
throw e;
|
|
161
63
|
}
|
|
162
64
|
return recursivePostRetry();
|
|
@@ -164,19 +66,8 @@ var DEFAULT_TIMEOUT_DURATION = 8000;
|
|
|
164
66
|
return res;
|
|
165
67
|
};
|
|
166
68
|
return recursivePostRetry();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return _this;
|
|
69
|
+
};
|
|
70
|
+
this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
|
|
170
71
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
key: "selectRpcUrl",
|
|
174
|
-
value: /**
|
|
175
|
-
* @ignore
|
|
176
|
-
*/ function selectRpcUrl() {
|
|
177
|
-
return this._rpcUrls[this.rpcUrlCounter];
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
]);
|
|
181
|
-
return FallthroughProvider;
|
|
182
|
-
}(BaseProvider);
|
|
72
|
+
}
|
|
73
|
+
exports.FallthroughProvider = FallthroughProvider;
|
|
@@ -1,120 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
selectRpcUrl() {
|
|
10
|
+
return this._rpcUrls[0];
|
|
4
11
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function _defineProperties(target, props) {
|
|
13
|
-
for(var i = 0; i < props.length; i++){
|
|
14
|
-
var descriptor = props[i];
|
|
15
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
16
|
-
descriptor.configurable = true;
|
|
17
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
18
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
22
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
|
-
return Constructor;
|
|
25
|
-
}
|
|
26
|
-
function _get_prototype_of(o) {
|
|
27
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
28
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
29
|
-
};
|
|
30
|
-
return _get_prototype_of(o);
|
|
31
|
-
}
|
|
32
|
-
function _inherits(subClass, superClass) {
|
|
33
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
34
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
post(body) {
|
|
16
|
+
return this._post(body);
|
|
35
17
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function _possible_constructor_return(self, call) {
|
|
46
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
47
|
-
return call;
|
|
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]);
|
|
48
27
|
}
|
|
49
|
-
return _assert_this_initialized(self);
|
|
50
|
-
}
|
|
51
|
-
function _set_prototype_of(o, p) {
|
|
52
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
53
|
-
o.__proto__ = p;
|
|
54
|
-
return o;
|
|
55
|
-
};
|
|
56
|
-
return _set_prototype_of(o, p);
|
|
57
28
|
}
|
|
58
|
-
|
|
59
|
-
"@swc/helpers - typeof";
|
|
60
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
61
|
-
}
|
|
62
|
-
function _is_native_reflect_construct() {
|
|
63
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
64
|
-
if (Reflect.construct.sham) return false;
|
|
65
|
-
if (typeof Proxy === "function") return true;
|
|
66
|
-
try {
|
|
67
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
68
|
-
return true;
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function _create_super(Derived) {
|
|
74
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
75
|
-
return function _createSuperInternal() {
|
|
76
|
-
var Super = _get_prototype_of(Derived), result;
|
|
77
|
-
if (hasNativeReflectConstruct) {
|
|
78
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
79
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
80
|
-
} else {
|
|
81
|
-
result = Super.apply(this, arguments);
|
|
82
|
-
}
|
|
83
|
-
return _possible_constructor_return(this, result);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
import { BaseProvider } from "./BaseProvider";
|
|
87
|
-
export var JsonRpcProvider = /*#__PURE__*/ function(BaseProvider) {
|
|
88
|
-
"use strict";
|
|
89
|
-
_inherits(JsonRpcProvider, BaseProvider);
|
|
90
|
-
var _super = _create_super(JsonRpcProvider);
|
|
91
|
-
function JsonRpcProvider() {
|
|
92
|
-
var rpcUrl = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "https://free-eth-node.com/api/eth";
|
|
93
|
-
_class_call_check(this, JsonRpcProvider);
|
|
94
|
-
return _super.call(this, [
|
|
95
|
-
rpcUrl
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
98
|
-
_create_class(JsonRpcProvider, [
|
|
99
|
-
{
|
|
100
|
-
/**
|
|
101
|
-
* @ignore
|
|
102
|
-
*/ key: "selectRpcUrl",
|
|
103
|
-
value: function selectRpcUrl() {
|
|
104
|
-
return this._rpcUrls[0];
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
/**
|
|
109
|
-
* @ignore
|
|
110
|
-
*/ key: "post",
|
|
111
|
-
value: function post(body) {
|
|
112
|
-
return this._post(body);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
]);
|
|
116
|
-
return JsonRpcProvider;
|
|
117
|
-
}(BaseProvider);
|
|
29
|
+
exports.JsonRpcProvider = JsonRpcProvider;
|
|
118
30
|
/**
|
|
119
31
|
* Helper function to avoid "new"
|
|
120
32
|
*
|
|
@@ -127,6 +39,8 @@ export var JsonRpcProvider = /*#__PURE__*/ function(BaseProvider) {
|
|
|
127
39
|
* })
|
|
128
40
|
* // 14530496
|
|
129
41
|
* ```
|
|
130
|
-
*/
|
|
42
|
+
*/
|
|
43
|
+
function jsonRpcProvider(rpcUrl) {
|
|
131
44
|
return new JsonRpcProvider(rpcUrl);
|
|
132
45
|
}
|
|
46
|
+
exports.jsonRpcProvider = jsonRpcProvider;
|
|
@@ -1,149 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Example logs that should be returned
|
|
2
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;
|
|
3
6
|
// Block(s) are 14809329
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
address: STRONGBLOCK_ADDRESS,
|
|
7
|
-
fromBlock:
|
|
8
|
-
toBlock:
|
|
7
|
+
exports.STRONGBLOCK_ADDRESS = '0xfbddadd80fe7bda00b901fbaf73803f2238ae655';
|
|
8
|
+
exports.filterAddressFromTo = {
|
|
9
|
+
address: exports.STRONGBLOCK_ADDRESS,
|
|
10
|
+
fromBlock: '0xE1F8F1',
|
|
11
|
+
toBlock: '0xE1F8F1',
|
|
9
12
|
};
|
|
10
13
|
// Example logs that should be returned
|
|
11
14
|
// https://etherscan.io/address/0x596a0f276ee432d8a28441e55737ff55cf30d0f7#events
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
address: RARELAND_ADDRESS,
|
|
15
|
+
exports.RARELAND_ADDRESS = '0x596a0f276ee432d8a28441e55737ff55cf30d0f7';
|
|
16
|
+
exports.filterAddressTopics = {
|
|
17
|
+
address: exports.RARELAND_ADDRESS,
|
|
15
18
|
topics: [
|
|
16
|
-
|
|
17
|
-
]
|
|
19
|
+
'0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',
|
|
20
|
+
],
|
|
18
21
|
};
|
|
19
22
|
// https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#events
|
|
20
23
|
// Address is for Wrapped Ether Contract
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
address: WETH_ADDRESS,
|
|
24
|
+
exports.WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
|
25
|
+
exports.filterAll = {
|
|
26
|
+
address: exports.WETH_ADDRESS,
|
|
24
27
|
topics: [
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
29
|
+
'0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
|
|
27
30
|
],
|
|
28
31
|
fromBlock: 14825027,
|
|
29
|
-
toBlock: 14825039
|
|
32
|
+
toBlock: 14825039,
|
|
30
33
|
};
|
|
31
|
-
|
|
34
|
+
exports.mockfilterAddressFromToLogs = [
|
|
32
35
|
{
|
|
33
|
-
address:
|
|
36
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
34
37
|
topics: [
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
39
|
+
'0x00000000000000000000000028c2e3e17f8c61a9b7515f7bb1e1347846588b82',
|
|
37
40
|
],
|
|
38
|
-
data:
|
|
39
|
-
blockNumber:
|
|
40
|
-
transactionHash:
|
|
41
|
-
transactionIndex:
|
|
42
|
-
blockHash:
|
|
43
|
-
logIndex:
|
|
44
|
-
removed: false
|
|
41
|
+
data: '0x0000000000000000000000000000000000000000000000001dbaed81bf64db6d',
|
|
42
|
+
blockNumber: '0xe1f8f1',
|
|
43
|
+
transactionHash: '0x5dec3a55b87edac0af5c4a9afdd015bb04303fdf86525dd1cc4e7aa7653b6301',
|
|
44
|
+
transactionIndex: '0x29',
|
|
45
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
46
|
+
logIndex: '0x88',
|
|
47
|
+
removed: false,
|
|
45
48
|
},
|
|
46
49
|
{
|
|
47
|
-
address:
|
|
50
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
48
51
|
topics: [
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
53
|
+
'0x000000000000000000000000c3b80d78bb52fd734c4f730dad5e190ba4ecb830',
|
|
51
54
|
],
|
|
52
|
-
data:
|
|
53
|
-
blockNumber:
|
|
54
|
-
transactionHash:
|
|
55
|
-
transactionIndex:
|
|
56
|
-
blockHash:
|
|
57
|
-
logIndex:
|
|
58
|
-
removed: false
|
|
55
|
+
data: '0x0000000000000000000000000000000000000000000000001c277de315af8924',
|
|
56
|
+
blockNumber: '0xe1f8f1',
|
|
57
|
+
transactionHash: '0xae04b63efd57852e34bdc84e257bb413f9f942288f63a131d4b7071c8ee0b896',
|
|
58
|
+
transactionIndex: '0x2f',
|
|
59
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
60
|
+
logIndex: '0x95',
|
|
61
|
+
removed: false,
|
|
59
62
|
},
|
|
60
63
|
{
|
|
61
|
-
address:
|
|
64
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
62
65
|
topics: [
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
67
|
+
'0x000000000000000000000000f1a192063f0a2b2be0cbcb2978b13e95e7f35f6b',
|
|
65
68
|
],
|
|
66
|
-
data:
|
|
67
|
-
blockNumber:
|
|
68
|
-
transactionHash:
|
|
69
|
-
transactionIndex:
|
|
70
|
-
blockHash:
|
|
71
|
-
logIndex:
|
|
72
|
-
removed: false
|
|
69
|
+
data: '0x00000000000000000000000000000000000000000000000018ecfa70ea275b6d',
|
|
70
|
+
blockNumber: '0xe1f8f1',
|
|
71
|
+
transactionHash: '0xbdba7260507b4ca24757809ac9a23e5225e80a491475ccf89a04c1894a693c77',
|
|
72
|
+
transactionIndex: '0x30',
|
|
73
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
74
|
+
logIndex: '0x97',
|
|
75
|
+
removed: false,
|
|
73
76
|
},
|
|
74
77
|
{
|
|
75
|
-
address:
|
|
78
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
76
79
|
topics: [
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
81
|
+
'0x000000000000000000000000c78dc12c9b04858d57a108ae948020344895e910',
|
|
79
82
|
],
|
|
80
|
-
data:
|
|
81
|
-
blockNumber:
|
|
82
|
-
transactionHash:
|
|
83
|
-
transactionIndex:
|
|
84
|
-
blockHash:
|
|
85
|
-
logIndex:
|
|
86
|
-
removed: false
|
|
83
|
+
data: '0x0000000000000000000000000000000000000000000000000da5142efe16e492',
|
|
84
|
+
blockNumber: '0xe1f8f1',
|
|
85
|
+
transactionHash: '0xdcf29bd8a44ec89a3b53488dd60b76bd7f1c532db76f88e166f3de1ab216537e',
|
|
86
|
+
transactionIndex: '0x31',
|
|
87
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
88
|
+
logIndex: '0x99',
|
|
89
|
+
removed: false,
|
|
87
90
|
},
|
|
88
91
|
{
|
|
89
|
-
address:
|
|
92
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
90
93
|
topics: [
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
'0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
|
|
95
|
+
'0x000000000000000000000000aaf5c3760f4a77bdf23974f98d69f9ccfd778aea',
|
|
93
96
|
],
|
|
94
|
-
data:
|
|
95
|
-
blockNumber:
|
|
96
|
-
transactionHash:
|
|
97
|
-
transactionIndex:
|
|
98
|
-
blockHash:
|
|
99
|
-
logIndex:
|
|
100
|
-
removed: false
|
|
97
|
+
data: '0x0000000000000000000000000000000000000000000000001086ed3d87034000',
|
|
98
|
+
blockNumber: '0xe1f8f1',
|
|
99
|
+
transactionHash: '0x56130c6e8fdafd0e08411b21ce984eeb56dc61d99a91f03efc7edde748d7ad81',
|
|
100
|
+
transactionIndex: '0x35',
|
|
101
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
102
|
+
logIndex: '0xac',
|
|
103
|
+
removed: false,
|
|
101
104
|
},
|
|
102
105
|
{
|
|
103
|
-
address:
|
|
106
|
+
address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
|
|
104
107
|
topics: [
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
'0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0',
|
|
109
|
+
'0x0000000000000000000000001753de22132990dd5ab35f13a5951431c8ba08ea',
|
|
107
110
|
],
|
|
108
|
-
data:
|
|
109
|
-
blockNumber:
|
|
110
|
-
transactionHash:
|
|
111
|
-
transactionIndex:
|
|
112
|
-
blockHash:
|
|
113
|
-
logIndex:
|
|
114
|
-
removed: false
|
|
115
|
-
}
|
|
111
|
+
data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000e3203b',
|
|
112
|
+
blockNumber: '0xe1f8f1',
|
|
113
|
+
transactionHash: '0xf5a77d85296cc670d577d3c9a76b1fa18be77239a4cb4c05493530866d60c36f',
|
|
114
|
+
transactionIndex: '0x3a',
|
|
115
|
+
blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
|
|
116
|
+
logIndex: '0xb5',
|
|
117
|
+
removed: false,
|
|
118
|
+
},
|
|
116
119
|
];
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
exports.mockfilterAddressTopicsLogs = [];
|
|
121
|
+
exports.mockfilterAllLogs = [
|
|
119
122
|
{
|
|
120
|
-
address:
|
|
123
|
+
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
121
124
|
topics: [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
|
|
126
|
+
'0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
|
|
127
|
+
'0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45',
|
|
125
128
|
],
|
|
126
|
-
data:
|
|
127
|
-
blockNumber:
|
|
128
|
-
transactionHash:
|
|
129
|
-
transactionIndex:
|
|
130
|
-
blockHash:
|
|
131
|
-
logIndex:
|
|
132
|
-
removed: false
|
|
133
|
-
}
|
|
129
|
+
data: '0x000000000000000000000000000000000000000000000000005f862ee352a38a',
|
|
130
|
+
blockNumber: '0xe23645',
|
|
131
|
+
transactionHash: '0xbd49031be16f8fd1775f4e0fe79b408ffd8ae9c65b2827ee47e3238e3f51f4c0',
|
|
132
|
+
transactionIndex: '0xe2',
|
|
133
|
+
blockHash: '0x8e0dfac2f704851960f866c8708b3bef2f66c0fee0329cf25ff0261b264ca6bc',
|
|
134
|
+
logIndex: '0x180',
|
|
135
|
+
removed: false,
|
|
136
|
+
},
|
|
134
137
|
];
|
|
135
|
-
|
|
136
|
-
jsonrpc:
|
|
138
|
+
exports.mockRpcAddressFromToResponse = JSON.stringify({
|
|
139
|
+
jsonrpc: '2.0',
|
|
137
140
|
id: 1,
|
|
138
|
-
result: mockfilterAddressFromToLogs
|
|
141
|
+
result: exports.mockfilterAddressFromToLogs,
|
|
139
142
|
});
|
|
140
|
-
|
|
141
|
-
jsonrpc:
|
|
143
|
+
exports.mockRpcAddressTopicsResponse = JSON.stringify({
|
|
144
|
+
jsonrpc: '2.0',
|
|
142
145
|
id: 1,
|
|
143
|
-
result: mockfilterAddressTopicsLogs
|
|
146
|
+
result: exports.mockfilterAddressTopicsLogs,
|
|
144
147
|
});
|
|
145
|
-
|
|
146
|
-
jsonrpc:
|
|
148
|
+
exports.mockRpcAllResponse = JSON.stringify({
|
|
149
|
+
jsonrpc: '2.0',
|
|
147
150
|
id: 1,
|
|
148
|
-
result: mockfilterAllLogs
|
|
151
|
+
result: exports.mockfilterAllLogs,
|
|
149
152
|
});
|
|
@@ -1,9 +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
7
|
* @param fn
|
|
5
8
|
* @example mockOf(stripe.checkout.sessions.create).mockResolvedValue(mockSession);
|
|
6
9
|
* @see https://twitter.com/scastiel/status/1631354119192473601?s=20
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
*/
|
|
11
|
+
const mockOf = (fn) => fn;
|
|
12
|
+
exports.mockOf = mockOf;
|