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,128 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
reject(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
31
|
-
var f, y, t, g, _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.buildRPCPostBody = exports.post = exports.buildFetchInit = void 0;
|
|
16
|
+
const isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
|
|
17
|
+
/**
|
|
18
|
+
* Forms the init field for http fetching
|
|
19
|
+
*
|
|
20
|
+
* @param body
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
function buildFetchInit(body) {
|
|
24
|
+
return {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
36
28
|
},
|
|
37
|
-
|
|
38
|
-
ops: []
|
|
29
|
+
body: JSON.stringify(body),
|
|
39
30
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"throw": verb(1),
|
|
43
|
-
"return": verb(2)
|
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
-
return this;
|
|
46
|
-
}), g);
|
|
47
|
-
function verb(n) {
|
|
48
|
-
return function(v) {
|
|
49
|
-
return step([
|
|
50
|
-
n,
|
|
51
|
-
v
|
|
52
|
-
]);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function step(op) {
|
|
56
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while(_)try {
|
|
58
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
-
if (y = 0, t) op = [
|
|
60
|
-
op[0] & 2,
|
|
61
|
-
t.value
|
|
62
|
-
];
|
|
63
|
-
switch(op[0]){
|
|
64
|
-
case 0:
|
|
65
|
-
case 1:
|
|
66
|
-
t = op;
|
|
67
|
-
break;
|
|
68
|
-
case 4:
|
|
69
|
-
_.label++;
|
|
70
|
-
return {
|
|
71
|
-
value: op[1],
|
|
72
|
-
done: false
|
|
73
|
-
};
|
|
74
|
-
case 5:
|
|
75
|
-
_.label++;
|
|
76
|
-
y = op[1];
|
|
77
|
-
op = [
|
|
78
|
-
0
|
|
79
|
-
];
|
|
80
|
-
continue;
|
|
81
|
-
case 7:
|
|
82
|
-
op = _.ops.pop();
|
|
83
|
-
_.trys.pop();
|
|
84
|
-
continue;
|
|
85
|
-
default:
|
|
86
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
-
_ = 0;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
-
_.label = op[1];
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
-
_.label = t[1];
|
|
96
|
-
t = op;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
if (t && _.label < t[2]) {
|
|
100
|
-
_.label = t[2];
|
|
101
|
-
_.ops.push(op);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
if (t[2]) _.ops.pop();
|
|
105
|
-
_.trys.pop();
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
op = body.call(thisArg, _);
|
|
109
|
-
} catch (e) {
|
|
110
|
-
op = [
|
|
111
|
-
6,
|
|
112
|
-
e
|
|
113
|
-
];
|
|
114
|
-
y = 0;
|
|
115
|
-
} finally{
|
|
116
|
-
f = t = 0;
|
|
117
|
-
}
|
|
118
|
-
if (op[0] & 5) throw op[1];
|
|
119
|
-
return {
|
|
120
|
-
value: op[0] ? op[1] : void 0,
|
|
121
|
-
done: true
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
import unfetch from "isomorphic-unfetch";
|
|
31
|
+
}
|
|
32
|
+
exports.buildFetchInit = buildFetchInit;
|
|
126
33
|
/**
|
|
127
34
|
* Makes a post request with the specified JSON data, normally to the a Ethereum JSON RPC API endpoint
|
|
128
35
|
*
|
|
@@ -138,50 +45,27 @@ import unfetch from "isomorphic-unfetch";
|
|
|
138
45
|
* post('https://free-eth-node.com/api/eth', { jsonrpc: '2.0', id: 1, method: 'eth_getBalance', params: [ '0x4a986a6dCA6dbf99bC3d17F8D71aFb0d60e740f8', 'latest' ] });
|
|
139
46
|
* // '0x312faeb995df61d4'
|
|
140
47
|
* ```
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
4,
|
|
156
|
-
r.text()
|
|
157
|
-
];
|
|
158
|
-
case 1:
|
|
159
|
-
t = _state.sent();
|
|
160
|
-
try {
|
|
161
|
-
return [
|
|
162
|
-
2,
|
|
163
|
-
JSON.parse(t)
|
|
164
|
-
];
|
|
165
|
-
} catch (e) {
|
|
166
|
-
throw new Error('Invalid JSON RPC response: "'.concat(t, '"'));
|
|
167
|
-
}
|
|
168
|
-
return [
|
|
169
|
-
2
|
|
170
|
-
];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
return function(r) {
|
|
175
|
-
return _ref.apply(this, arguments);
|
|
176
|
-
};
|
|
177
|
-
}()).then(function(response) {
|
|
178
|
-
var result = response === null || response === void 0 ? void 0 : response.result;
|
|
48
|
+
*/
|
|
49
|
+
function post(url, body) {
|
|
50
|
+
return (0, isomorphic_unfetch_1.default)(url, buildFetchInit(body))
|
|
51
|
+
.then((r) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const t = yield r.text();
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(t);
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
throw new Error(`Invalid JSON RPC response: "${t}"`);
|
|
58
|
+
}
|
|
59
|
+
}))
|
|
60
|
+
.then((response) => {
|
|
61
|
+
const result = response === null || response === void 0 ? void 0 : response.result;
|
|
179
62
|
if (!result) {
|
|
180
|
-
throw new Error(
|
|
63
|
+
throw new Error(`Invalid JSON RPC response: ${JSON.stringify(response)}`);
|
|
181
64
|
}
|
|
182
65
|
return response.result;
|
|
183
66
|
});
|
|
184
67
|
}
|
|
68
|
+
exports.post = post;
|
|
185
69
|
/**
|
|
186
70
|
* Prepares data to be sent using the {@link post} function. Data is prepared per the {@link https://en.wikipedia.org/wiki/JSON-RPC#Examples JSON RPC v2 spec}
|
|
187
71
|
*
|
|
@@ -197,12 +81,14 @@ import unfetch from "isomorphic-unfetch";
|
|
|
197
81
|
* buildRPCPostBody('eth_getBalance', ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', 'latest']);
|
|
198
82
|
* // { jsonrpc: '2.0', id: 1, method: 'eth_getBalance', params: [ '0x4a986a6dCA6dbf99bC3d17F8D71aFb0d60e740f8', 'latest' ] }
|
|
199
83
|
* ```
|
|
200
|
-
*/
|
|
84
|
+
*/
|
|
85
|
+
function buildRPCPostBody(method, params) {
|
|
201
86
|
return {
|
|
202
|
-
jsonrpc:
|
|
87
|
+
jsonrpc: '2.0',
|
|
203
88
|
// TODO: Increment ID will be needed when websocket support is added
|
|
204
89
|
id: 1,
|
|
205
|
-
method
|
|
206
|
-
params
|
|
90
|
+
method,
|
|
91
|
+
params,
|
|
207
92
|
};
|
|
208
93
|
}
|
|
94
|
+
exports.buildRPCPostBody = buildRPCPostBody;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hexToDecimal = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Converts a hexadecimal string it's decimal equivalent.
|
|
3
6
|
* This is needed instead of parseInt because parseInt loses precision.
|
|
@@ -14,6 +17,8 @@
|
|
|
14
17
|
* hexToDecimal('0x628608');
|
|
15
18
|
* // 6456840
|
|
16
19
|
* ```
|
|
17
|
-
*/
|
|
20
|
+
*/
|
|
21
|
+
function hexToDecimal(hex) {
|
|
18
22
|
return BigInt(hex).toString();
|
|
19
23
|
}
|
|
24
|
+
exports.hexToDecimal = hexToDecimal;
|
|
@@ -1,68 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
function _instanceof(left, right) {
|
|
15
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
16
|
-
return !!right[Symbol.hasInstance](left);
|
|
17
|
-
} else {
|
|
18
|
-
return left instanceof right;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function _objectSpread(target) {
|
|
22
|
-
for(var i = 1; i < arguments.length; i++){
|
|
23
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
24
|
-
var ownKeys = Object.keys(source);
|
|
25
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
26
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
27
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
ownKeys.forEach(function(key) {
|
|
31
|
-
_defineProperty(target, key, source[key]);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
}
|
|
36
|
-
import Big from "big.js";
|
|
37
|
-
import { TinyBig } from "../../shared/tiny-big/tiny-big";
|
|
38
|
-
import { hexlify } from "../../utils/bytes";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prepareTransaction = void 0;
|
|
7
|
+
const big_js_1 = __importDefault(require("big.js"));
|
|
8
|
+
const tiny_big_1 = require("../../shared/tiny-big/tiny-big");
|
|
9
|
+
const bytes_1 = require("../../utils/bytes");
|
|
39
10
|
/**
|
|
40
11
|
* @param transaction
|
|
41
12
|
* @example
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
Object.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
case
|
|
48
|
-
case
|
|
49
|
-
case
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else preparedTransaction[key] = transaction[key].toString();
|
|
60
|
-
break;
|
|
13
|
+
*/
|
|
14
|
+
function prepareTransaction(transaction) {
|
|
15
|
+
const preparedTransaction = Object.assign({}, transaction);
|
|
16
|
+
Object.keys(transaction).forEach((key) => {
|
|
17
|
+
switch (key) {
|
|
18
|
+
case 'gas':
|
|
19
|
+
case 'gasPrice':
|
|
20
|
+
case 'nonce':
|
|
21
|
+
case 'maxFeePerGas':
|
|
22
|
+
case 'maxPriorityFeePerGas':
|
|
23
|
+
case 'value': {
|
|
24
|
+
const value = transaction[key];
|
|
25
|
+
if (value instanceof tiny_big_1.TinyBig) {
|
|
26
|
+
preparedTransaction[key] = value.toHexString();
|
|
27
|
+
}
|
|
28
|
+
else if (value instanceof big_js_1.default) {
|
|
29
|
+
preparedTransaction[key] = `0x${BigInt(value.toString()).toString(16)}`;
|
|
61
30
|
}
|
|
62
|
-
|
|
63
|
-
|
|
31
|
+
else if (typeof transaction[key] === 'number')
|
|
32
|
+
preparedTransaction[key] =
|
|
33
|
+
'0x' + transaction[key].toString(16);
|
|
34
|
+
else
|
|
35
|
+
preparedTransaction[key] = transaction[key].toString();
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case 'data':
|
|
39
|
+
preparedTransaction[key] = (0, bytes_1.hexlify)(transaction[key]);
|
|
64
40
|
break;
|
|
65
41
|
}
|
|
66
42
|
});
|
|
67
43
|
return preparedTransaction;
|
|
68
44
|
}
|
|
45
|
+
exports.prepareTransaction = prepareTransaction;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
export { Contract, BaseContract } from './classes/Contract';
|
|
2
|
+
export { AlchemyProvider } from './providers/AlchemyProvider';
|
|
3
|
+
export { FallthroughProvider, ConstructorOptions, } from './providers/FallthroughProvider';
|
|
4
|
+
export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
|
|
5
|
+
export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
|
|
6
|
+
export { BlockResponse, RPCBlock, BlockTag } from './types/Block.types';
|
|
7
|
+
export { ContractTypes, JSONABI, JSONABIArgument, } from './types/Contract.types';
|
|
8
|
+
export { Filter, FilterByBlockHash } from './types/Filter.types';
|
|
9
|
+
export { Network } from './types/Network.types';
|
|
10
|
+
export { TransactionResponse, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, RPCLog, Log, BlockTransactionResponse, } from './types/Transaction.types';
|
|
11
|
+
export { computeAddress } from './utils/compute-address';
|
|
12
|
+
export { computePublicKey } from './utils/compute-public-key';
|
|
13
|
+
export { etherToGwei } from './utils/ether-to-gwei';
|
|
14
|
+
export { etherToWei } from './utils/ether-to-wei';
|
|
15
|
+
export { gweiToEther } from './utils/gwei-to-ether';
|
|
16
|
+
export { hashMessage } from './utils/hash-message';
|
|
17
|
+
export { isAddress } from './utils/is-address';
|
|
18
|
+
export { splitSignature } from './utils/split-signature';
|
|
19
|
+
export { toChecksumAddress } from './utils/to-checksum-address';
|
|
20
|
+
export { toUtf8Bytes } from './utils/to-utf8-bytes';
|
|
21
|
+
export { weiToEther } from './utils/wei-to-ether';
|
|
22
22
|
export * from './utils/bytes';
|
|
23
23
|
export * from './utils/hash-message';
|
|
24
24
|
export * from './utils/keccak256';
|
|
25
25
|
export * from './utils/solidity-keccak256';
|
|
26
|
-
export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, AlchemyProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, BlockResponse, ContractTypes, Filter, FilterByBlockHash, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions, };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,26 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.weiToEther = exports.toUtf8Bytes = exports.toChecksumAddress = exports.splitSignature = exports.isAddress = exports.hashMessage = exports.gweiToEther = exports.etherToWei = exports.etherToGwei = exports.computePublicKey = exports.computeAddress = exports.TinyBig = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.FallthroughProvider = exports.AlchemyProvider = exports.BaseContract = exports.Contract = void 0;
|
|
18
|
+
var Contract_1 = require("./classes/Contract");
|
|
19
|
+
Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
|
|
20
|
+
Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return Contract_1.BaseContract; } });
|
|
21
|
+
var AlchemyProvider_1 = require("./providers/AlchemyProvider");
|
|
22
|
+
Object.defineProperty(exports, "AlchemyProvider", { enumerable: true, get: function () { return AlchemyProvider_1.AlchemyProvider; } });
|
|
23
|
+
var FallthroughProvider_1 = require("./providers/FallthroughProvider");
|
|
24
|
+
Object.defineProperty(exports, "FallthroughProvider", { enumerable: true, get: function () { return FallthroughProvider_1.FallthroughProvider; } });
|
|
25
|
+
var JsonRpcProvider_1 = require("./providers/JsonRpcProvider");
|
|
26
|
+
Object.defineProperty(exports, "jsonRpcProvider", { enumerable: true, get: function () { return JsonRpcProvider_1.jsonRpcProvider; } });
|
|
27
|
+
Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return JsonRpcProvider_1.JsonRpcProvider; } });
|
|
28
|
+
var tiny_big_1 = require("./shared/tiny-big/tiny-big");
|
|
29
|
+
Object.defineProperty(exports, "tinyBig", { enumerable: true, get: function () { return tiny_big_1.tinyBig; } });
|
|
30
|
+
Object.defineProperty(exports, "TinyBig", { enumerable: true, get: function () { return tiny_big_1.TinyBig; } });
|
|
31
|
+
var compute_address_1 = require("./utils/compute-address");
|
|
32
|
+
Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function () { return compute_address_1.computeAddress; } });
|
|
33
|
+
var compute_public_key_1 = require("./utils/compute-public-key");
|
|
34
|
+
Object.defineProperty(exports, "computePublicKey", { enumerable: true, get: function () { return compute_public_key_1.computePublicKey; } });
|
|
35
|
+
var ether_to_gwei_1 = require("./utils/ether-to-gwei");
|
|
36
|
+
Object.defineProperty(exports, "etherToGwei", { enumerable: true, get: function () { return ether_to_gwei_1.etherToGwei; } });
|
|
37
|
+
var ether_to_wei_1 = require("./utils/ether-to-wei");
|
|
38
|
+
Object.defineProperty(exports, "etherToWei", { enumerable: true, get: function () { return ether_to_wei_1.etherToWei; } });
|
|
39
|
+
var gwei_to_ether_1 = require("./utils/gwei-to-ether");
|
|
40
|
+
Object.defineProperty(exports, "gweiToEther", { enumerable: true, get: function () { return gwei_to_ether_1.gweiToEther; } });
|
|
41
|
+
var hash_message_1 = require("./utils/hash-message");
|
|
42
|
+
Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return hash_message_1.hashMessage; } });
|
|
43
|
+
var is_address_1 = require("./utils/is-address");
|
|
44
|
+
Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_address_1.isAddress; } });
|
|
45
|
+
var split_signature_1 = require("./utils/split-signature");
|
|
46
|
+
Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function () { return split_signature_1.splitSignature; } });
|
|
47
|
+
var to_checksum_address_1 = require("./utils/to-checksum-address");
|
|
48
|
+
Object.defineProperty(exports, "toChecksumAddress", { enumerable: true, get: function () { return to_checksum_address_1.toChecksumAddress; } });
|
|
49
|
+
var to_utf8_bytes_1 = require("./utils/to-utf8-bytes");
|
|
50
|
+
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return to_utf8_bytes_1.toUtf8Bytes; } });
|
|
51
|
+
var wei_to_ether_1 = require("./utils/wei-to-ether");
|
|
52
|
+
Object.defineProperty(exports, "weiToEther", { enumerable: true, get: function () { return wei_to_ether_1.weiToEther; } });
|
|
53
|
+
__exportStar(require("./utils/bytes"), exports);
|
|
54
|
+
__exportStar(require("./utils/hash-message"), exports);
|
|
55
|
+
__exportStar(require("./utils/keccak256"), exports);
|
|
56
|
+
__exportStar(require("./utils/solidity-keccak256"), exports);
|