essential-eth 0.9.1-next.0 → 0.9.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,313 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
var info = gen[key](arg);
|
|
10
|
-
var value = info.value;
|
|
11
|
-
} catch (error) {
|
|
12
|
-
reject(error);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (info.done) {
|
|
16
|
-
resolve(value);
|
|
17
|
-
} else {
|
|
18
|
-
Promise.resolve(value).then(_next, _throw);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function _async_to_generator(fn) {
|
|
22
|
-
return function() {
|
|
23
|
-
var self = this, args = arguments;
|
|
24
|
-
return new Promise(function(resolve, reject) {
|
|
25
|
-
var gen = fn.apply(self, args);
|
|
26
|
-
function _next(value) {
|
|
27
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
28
|
-
}
|
|
29
|
-
function _throw(err) {
|
|
30
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
31
|
-
}
|
|
32
|
-
_next(undefined);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function _class_call_check(instance, Constructor) {
|
|
37
|
-
if (!(instance instanceof Constructor)) {
|
|
38
|
-
throw new TypeError("Cannot call a class as a function");
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function _define_property(obj, key, value) {
|
|
42
|
-
if (key in obj) {
|
|
43
|
-
Object.defineProperty(obj, key, {
|
|
44
|
-
value: value,
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
obj[key] = value;
|
|
51
|
-
}
|
|
52
|
-
return obj;
|
|
53
|
-
}
|
|
54
|
-
function _get_prototype_of(o) {
|
|
55
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
56
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
57
|
-
};
|
|
58
|
-
return _get_prototype_of(o);
|
|
59
|
-
}
|
|
60
|
-
function _inherits(subClass, superClass) {
|
|
61
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
62
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
63
|
-
}
|
|
64
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
65
|
-
constructor: {
|
|
66
|
-
value: subClass,
|
|
67
|
-
writable: true,
|
|
68
|
-
configurable: true
|
|
69
|
-
}
|
|
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());
|
|
70
9
|
});
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
76
|
-
var ownKeys = Object.keys(source);
|
|
77
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
78
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
79
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
ownKeys.forEach(function(key) {
|
|
83
|
-
_define_property(target, key, source[key]);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return target;
|
|
87
|
-
}
|
|
88
|
-
function _possible_constructor_return(self, call) {
|
|
89
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
90
|
-
return call;
|
|
91
|
-
}
|
|
92
|
-
return _assert_this_initialized(self);
|
|
93
|
-
}
|
|
94
|
-
function _set_prototype_of(o, p) {
|
|
95
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
96
|
-
o.__proto__ = p;
|
|
97
|
-
return o;
|
|
98
|
-
};
|
|
99
|
-
return _set_prototype_of(o, p);
|
|
100
|
-
}
|
|
101
|
-
function _type_of(obj) {
|
|
102
|
-
"@swc/helpers - typeof";
|
|
103
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
104
|
-
}
|
|
105
|
-
function _is_native_reflect_construct() {
|
|
106
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
107
|
-
if (Reflect.construct.sham) return false;
|
|
108
|
-
if (typeof Proxy === "function") return true;
|
|
109
|
-
try {
|
|
110
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
111
|
-
return true;
|
|
112
|
-
} catch (e) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function _create_super(Derived) {
|
|
117
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
118
|
-
return function _createSuperInternal() {
|
|
119
|
-
var Super = _get_prototype_of(Derived), result;
|
|
120
|
-
if (hasNativeReflectConstruct) {
|
|
121
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
122
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
123
|
-
} else {
|
|
124
|
-
result = Super.apply(this, arguments);
|
|
125
|
-
}
|
|
126
|
-
return _possible_constructor_return(this, result);
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function _ts_generator(thisArg, body) {
|
|
130
|
-
var f, y, t, g, _ = {
|
|
131
|
-
label: 0,
|
|
132
|
-
sent: function() {
|
|
133
|
-
if (t[0] & 1) throw t[1];
|
|
134
|
-
return t[1];
|
|
135
|
-
},
|
|
136
|
-
trys: [],
|
|
137
|
-
ops: []
|
|
138
|
-
};
|
|
139
|
-
return(g = {
|
|
140
|
-
next: verb(0),
|
|
141
|
-
"throw": verb(1),
|
|
142
|
-
"return": verb(2)
|
|
143
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
144
|
-
return this;
|
|
145
|
-
}), g);
|
|
146
|
-
function verb(n) {
|
|
147
|
-
return function(v) {
|
|
148
|
-
return step([
|
|
149
|
-
n,
|
|
150
|
-
v
|
|
151
|
-
]);
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function step(op) {
|
|
155
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
156
|
-
while(_)try {
|
|
157
|
-
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;
|
|
158
|
-
if (y = 0, t) op = [
|
|
159
|
-
op[0] & 2,
|
|
160
|
-
t.value
|
|
161
|
-
];
|
|
162
|
-
switch(op[0]){
|
|
163
|
-
case 0:
|
|
164
|
-
case 1:
|
|
165
|
-
t = op;
|
|
166
|
-
break;
|
|
167
|
-
case 4:
|
|
168
|
-
_.label++;
|
|
169
|
-
return {
|
|
170
|
-
value: op[1],
|
|
171
|
-
done: false
|
|
172
|
-
};
|
|
173
|
-
case 5:
|
|
174
|
-
_.label++;
|
|
175
|
-
y = op[1];
|
|
176
|
-
op = [
|
|
177
|
-
0
|
|
178
|
-
];
|
|
179
|
-
continue;
|
|
180
|
-
case 7:
|
|
181
|
-
op = _.ops.pop();
|
|
182
|
-
_.trys.pop();
|
|
183
|
-
continue;
|
|
184
|
-
default:
|
|
185
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
186
|
-
_ = 0;
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
190
|
-
_.label = op[1];
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
194
|
-
_.label = t[1];
|
|
195
|
-
t = op;
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
if (t && _.label < t[2]) {
|
|
199
|
-
_.label = t[2];
|
|
200
|
-
_.ops.push(op);
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
if (t[2]) _.ops.pop();
|
|
204
|
-
_.trys.pop();
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
op = body.call(thisArg, _);
|
|
208
|
-
} catch (e) {
|
|
209
|
-
op = [
|
|
210
|
-
6,
|
|
211
|
-
e
|
|
212
|
-
];
|
|
213
|
-
y = 0;
|
|
214
|
-
} finally{
|
|
215
|
-
f = t = 0;
|
|
216
|
-
}
|
|
217
|
-
if (op[0] & 5) throw op[1];
|
|
218
|
-
return {
|
|
219
|
-
value: op[0] ? op[1] : void 0,
|
|
220
|
-
done: true
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
import { decodeRPCResponse, encodeData } from "./utils/encode-decode-transaction";
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Contract = exports.defineReadOnly = exports.BaseContract = void 0;
|
|
13
|
+
const encode_decode_transaction_1 = require("./utils/encode-decode-transaction");
|
|
225
14
|
/**
|
|
226
15
|
* @param txnData
|
|
227
16
|
* @example
|
|
228
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
function estimateGas(txnData) {
|
|
229
19
|
// https://ethereum.stackexchange.com/questions/1570/what-does-intrinsic-gas-too-low-mean/1694
|
|
230
|
-
txnData.split(
|
|
20
|
+
txnData.split('').reduce((previousValue, currentValue) => {
|
|
231
21
|
// 0 characters are 4 gwei, all others are 48 gwei
|
|
232
|
-
|
|
22
|
+
const characterCost = currentValue === '0' ? 4 : 68;
|
|
233
23
|
return previousValue + characterCost;
|
|
234
24
|
}, 0);
|
|
235
25
|
}
|
|
236
|
-
|
|
237
|
-
"use strict";
|
|
238
|
-
var _this = this;
|
|
239
|
-
_class_call_check(this, BaseContract);
|
|
26
|
+
class BaseContract {
|
|
240
27
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
contractInterface
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
lastArg = _args[_args.length - 1];
|
|
263
|
-
if (!Array.isArray(lastArg) && typeof lastArg === "object") {
|
|
264
|
-
options = lastArg;
|
|
265
|
-
functionArguments = _args.slice(0, _args.length - 1);
|
|
266
|
-
}
|
|
267
|
-
data = encodeData(jsonABIArgument, functionArguments);
|
|
268
|
-
decimalGas = typeof options.gasLimit === "number" ? options.gasLimit /* user passed in "gasLimit" directly */ : typeof (jsonABIArgument === null || jsonABIArgument === void 0 ? void 0 : jsonABIArgument.gas) === "number" /* ABI specified "gas". */ ? estimateGas(data) : null;
|
|
269
|
-
req = function() {
|
|
270
|
-
var _ref = _async_to_generator(function() {
|
|
271
|
-
return _ts_generator(this, function(_state) {
|
|
272
|
-
switch(_state.label){
|
|
273
|
-
case 0:
|
|
274
|
-
return [
|
|
275
|
-
4,
|
|
276
|
-
_this1._provider.call(_object_spread({
|
|
277
|
-
to: _this1._address.toLowerCase(),
|
|
278
|
-
data: data
|
|
279
|
-
}, decimalGas ? {
|
|
280
|
-
gas: "0x".concat(decimalGas.toString(16))
|
|
281
|
-
} : {}), "latest")
|
|
282
|
-
];
|
|
283
|
-
case 1:
|
|
284
|
-
return [
|
|
285
|
-
2,
|
|
286
|
-
_state.sent()
|
|
287
|
-
];
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
return function req() {
|
|
292
|
-
return _ref.apply(this, arguments);
|
|
293
|
-
};
|
|
294
|
-
}();
|
|
295
|
-
return [
|
|
296
|
-
4,
|
|
297
|
-
req()
|
|
298
|
-
];
|
|
299
|
-
case 1:
|
|
300
|
-
nodeResponse = _state.sent();
|
|
301
|
-
return [
|
|
302
|
-
2,
|
|
303
|
-
decodeRPCResponse(jsonABIArgument, nodeResponse)
|
|
304
|
-
];
|
|
28
|
+
* @param addressOrName The ethereum address of the smart-contract
|
|
29
|
+
* @param contractInterface The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
|
|
30
|
+
* @param signerOrProvider An instantiated essential-eth provider
|
|
31
|
+
* @example
|
|
32
|
+
*/
|
|
33
|
+
constructor(addressOrName, contractInterface, signerOrProvider) {
|
|
34
|
+
this._address = addressOrName;
|
|
35
|
+
this._provider = signerOrProvider;
|
|
36
|
+
contractInterface
|
|
37
|
+
.filter((jsonABIArgument) => jsonABIArgument.type === 'function')
|
|
38
|
+
.forEach((jsonABIArgument) => {
|
|
39
|
+
if ('name' in jsonABIArgument &&
|
|
40
|
+
typeof jsonABIArgument.name === 'string') {
|
|
41
|
+
defineReadOnly(this, jsonABIArgument.name, (..._args) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
let functionArguments = _args;
|
|
43
|
+
let options = {};
|
|
44
|
+
// remove options from encoding
|
|
45
|
+
const lastArg = _args[_args.length - 1];
|
|
46
|
+
if (!Array.isArray(lastArg) && typeof lastArg === 'object') {
|
|
47
|
+
options = lastArg;
|
|
48
|
+
functionArguments = _args.slice(0, _args.length - 1);
|
|
305
49
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
50
|
+
const data = (0, encode_decode_transaction_1.encodeData)(jsonABIArgument, functionArguments);
|
|
51
|
+
const decimalGas = typeof options.gasLimit === 'number'
|
|
52
|
+
? options.gasLimit /* user passed in "gasLimit" directly */
|
|
53
|
+
: typeof (jsonABIArgument === null || jsonABIArgument === void 0 ? void 0 : jsonABIArgument.gas) ===
|
|
54
|
+
'number' /* ABI specified "gas". */
|
|
55
|
+
? estimateGas(data)
|
|
56
|
+
: null;
|
|
57
|
+
const req = () => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return yield this._provider.call(Object.assign({ to: this._address.toLowerCase(), data }, (decimalGas
|
|
59
|
+
? { gas: `0x${decimalGas.toString(16)}` }
|
|
60
|
+
: {})), 'latest');
|
|
61
|
+
});
|
|
62
|
+
const nodeResponse = yield req();
|
|
63
|
+
return (0, encode_decode_transaction_1.decodeRPCResponse)(jsonABIArgument, nodeResponse);
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.BaseContract = BaseContract;
|
|
311
70
|
/**
|
|
312
71
|
* Applies the unique contract's methods to the instantiated Contract in the constructor based-upon the provided ABI
|
|
313
72
|
*
|
|
@@ -316,13 +75,15 @@ export var BaseContract = function BaseContract(addressOrName, contractInterface
|
|
|
316
75
|
* @param value
|
|
317
76
|
* @internal
|
|
318
77
|
* @example
|
|
319
|
-
*/
|
|
78
|
+
*/
|
|
79
|
+
function defineReadOnly(object, name, value) {
|
|
320
80
|
Object.defineProperty(object, name, {
|
|
321
81
|
enumerable: true,
|
|
322
82
|
value: value,
|
|
323
|
-
writable: false
|
|
83
|
+
writable: false,
|
|
324
84
|
});
|
|
325
85
|
}
|
|
86
|
+
exports.defineReadOnly = defineReadOnly;
|
|
326
87
|
/**
|
|
327
88
|
* @alpha
|
|
328
89
|
* Only accepts ABIS in JSON format. This allows for stronger typing and assurances of data-types
|
|
@@ -371,13 +132,7 @@ export var BaseContract = function BaseContract(addressOrName, contractInterface
|
|
|
371
132
|
*
|
|
372
133
|
*
|
|
373
134
|
* ```
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
function Contract() {
|
|
379
|
-
_class_call_check(this, Contract);
|
|
380
|
-
return _super.apply(this, arguments);
|
|
381
|
-
}
|
|
382
|
-
return Contract;
|
|
383
|
-
}(BaseContract);
|
|
135
|
+
*/
|
|
136
|
+
class Contract extends BaseContract {
|
|
137
|
+
}
|
|
138
|
+
exports.Contract = Contract;
|