@qevm/abi 5.7.1 → 5.7.3
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/README.md +3 -4
- package/lib/_version.d.ts +1 -1
- package/lib/_version.js +1 -1
- package/lib/abi-coder.d.ts.map +1 -1
- package/lib/abi-coder.js +12 -7
- package/lib/abi-coder.js.map +1 -1
- package/lib/coders/abstract-coder.d.ts.map +1 -1
- package/lib/coders/abstract-coder.js +20 -9
- package/lib/coders/abstract-coder.js.map +1 -1
- package/lib/coders/address.d.ts.map +1 -1
- package/lib/coders/address.js +2 -2
- package/lib/coders/address.js.map +1 -1
- package/lib/coders/array.d.ts.map +1 -1
- package/lib/coders/array.js +17 -11
- package/lib/coders/array.js.map +1 -1
- package/lib/coders/boolean.d.ts.map +1 -1
- package/lib/coders/boolean.js.map +1 -1
- package/lib/coders/bytes.js.map +1 -1
- package/lib/coders/fixed-bytes.d.ts.map +1 -1
- package/lib/coders/fixed-bytes.js +1 -1
- package/lib/coders/fixed-bytes.js.map +1 -1
- package/lib/coders/function.d.ts +8 -0
- package/lib/coders/function.d.ts.map +1 -0
- package/lib/coders/function.js +46 -0
- package/lib/coders/function.js.map +1 -0
- package/lib/coders/null.d.ts.map +1 -1
- package/lib/coders/null.js.map +1 -1
- package/lib/coders/number.js +1 -1
- package/lib/coders/number.js.map +1 -1
- package/lib/coders/string.d.ts.map +1 -1
- package/lib/coders/string.js +1 -1
- package/lib/coders/string.js.map +1 -1
- package/lib/coders/tuple.d.ts.map +1 -1
- package/lib/coders/tuple.js +1 -1
- package/lib/coders/tuple.js.map +1 -1
- package/lib/fragments.d.ts.map +1 -1
- package/lib/fragments.js +127 -65
- package/lib/fragments.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interface.d.ts +1 -1
- package/lib/interface.d.ts.map +1 -1
- package/lib/interface.js +84 -44
- package/lib/interface.js.map +1 -1
- package/package.json +35 -31
- package/src.ts/_version.ts +1 -1
- package/src.ts/abi-coder.ts +64 -26
- package/src.ts/coders/abstract-coder.ts +78 -33
- package/src.ts/coders/address.ts +3 -5
- package/src.ts/coders/array.ts +90 -47
- package/src.ts/coders/boolean.ts +1 -3
- package/src.ts/coders/bytes.ts +1 -3
- package/src.ts/coders/fixed-bytes.ts +7 -2
- package/src.ts/coders/function.ts +64 -0
- package/src.ts/coders/null.ts +4 -3
- package/src.ts/coders/number.ts +1 -2
- package/src.ts/coders/string.ts +1 -2
- package/src.ts/coders/tuple.ts +31 -16
- package/src.ts/fragments.ts +411 -178
- package/src.ts/index.ts +20 -8
- package/src.ts/interface.ts +405 -153
package/lib/coders/tuple.js
CHANGED
|
@@ -13,7 +13,7 @@ class TupleCoder extends abstract_coder_1.Coder {
|
|
|
13
13
|
}
|
|
14
14
|
types.push(coder.type);
|
|
15
15
|
});
|
|
16
|
-
const type =
|
|
16
|
+
const type = "tuple(" + types.join(",") + ")";
|
|
17
17
|
super("tuple", type, localName, dynamic);
|
|
18
18
|
this.coders = coders;
|
|
19
19
|
}
|
package/lib/coders/tuple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../src.ts/coders/tuple.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qDAAyD;AACzD,mCAAuC;AAEvC,MAAa,UAAW,SAAQ,sBAAK;IAGjC,YAAY,MAAoB,EAAE,SAAiB;QAC/C,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,KAAK,GAAkB,EAAE,CAAC;QAChC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../src.ts/coders/tuple.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qDAAyD;AACzD,mCAA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K,EAAE,MAAM,GAAG,aAAa;IAsB/C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa;CAG7D"}
|
package/lib/fragments.js
CHANGED
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErrorFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
|
|
4
4
|
const bignumber_1 = require("@qevm/bignumber");
|
|
5
|
-
const properties_1 = require("@
|
|
6
|
-
const logger_1 = require("@
|
|
5
|
+
const properties_1 = require("@qevm/properties");
|
|
6
|
+
const logger_1 = require("@qevm/logger");
|
|
7
7
|
const _version_1 = require("./_version");
|
|
8
8
|
const logger = new logger_1.Logger(_version_1.version);
|
|
9
|
-
;
|
|
10
9
|
const _constructorGuard = {};
|
|
11
|
-
let ModifiersBytes = {
|
|
12
|
-
|
|
10
|
+
let ModifiersBytes = {
|
|
11
|
+
calldata: true,
|
|
12
|
+
memory: true,
|
|
13
|
+
storage: true,
|
|
14
|
+
};
|
|
15
|
+
let ModifiersNest = {
|
|
16
|
+
calldata: true,
|
|
17
|
+
memory: true,
|
|
18
|
+
};
|
|
13
19
|
function checkModifier(type, name) {
|
|
14
20
|
if (type === "bytes" || type === "string") {
|
|
15
21
|
if (ModifiersBytes[name]) {
|
|
@@ -39,7 +45,12 @@ function parseParamType(param, allowIndexed) {
|
|
|
39
45
|
}
|
|
40
46
|
param = param.replace(/\s/g, " ");
|
|
41
47
|
function newNode(parent) {
|
|
42
|
-
let node = {
|
|
48
|
+
let node = {
|
|
49
|
+
type: "",
|
|
50
|
+
name: "",
|
|
51
|
+
parent: parent,
|
|
52
|
+
state: { allowType: true },
|
|
53
|
+
};
|
|
43
54
|
if (allowIndexed) {
|
|
44
55
|
node.indexed = false;
|
|
45
56
|
}
|
|
@@ -206,14 +217,14 @@ exports.FormatTypes = Object.freeze({
|
|
|
206
217
|
// Human-Readable with nice spacing, including all names
|
|
207
218
|
full: "full",
|
|
208
219
|
// JSON-format a la Solidity
|
|
209
|
-
json: "json"
|
|
220
|
+
json: "json",
|
|
210
221
|
});
|
|
211
222
|
const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
|
212
223
|
class ParamType {
|
|
213
224
|
constructor(constructorGuard, params) {
|
|
214
225
|
if (constructorGuard !== _constructorGuard) {
|
|
215
226
|
logger.throwError("use fromString", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
216
|
-
operation: "new ParamType()"
|
|
227
|
+
operation: "new ParamType()",
|
|
217
228
|
});
|
|
218
229
|
}
|
|
219
230
|
populate(this, params);
|
|
@@ -223,16 +234,16 @@ class ParamType {
|
|
|
223
234
|
arrayLength: parseInt(match[2] || "-1"),
|
|
224
235
|
arrayChildren: ParamType.fromObject({
|
|
225
236
|
type: match[1],
|
|
226
|
-
components: this.components
|
|
237
|
+
components: this.components,
|
|
227
238
|
}),
|
|
228
|
-
baseType: "array"
|
|
239
|
+
baseType: "array",
|
|
229
240
|
});
|
|
230
241
|
}
|
|
231
242
|
else {
|
|
232
243
|
populate(this, {
|
|
233
244
|
arrayLength: null,
|
|
234
245
|
arrayChildren: null,
|
|
235
|
-
baseType:
|
|
246
|
+
baseType: this.components != null ? "tuple" : this.type,
|
|
236
247
|
});
|
|
237
248
|
}
|
|
238
249
|
this._isParamType = true;
|
|
@@ -251,10 +262,10 @@ class ParamType {
|
|
|
251
262
|
}
|
|
252
263
|
if (format === exports.FormatTypes.json) {
|
|
253
264
|
let result = {
|
|
254
|
-
type:
|
|
255
|
-
name:
|
|
265
|
+
type: this.baseType === "tuple" ? "tuple" : this.type,
|
|
266
|
+
name: this.name || undefined,
|
|
256
267
|
};
|
|
257
|
-
if (typeof
|
|
268
|
+
if (typeof this.indexed === "boolean") {
|
|
258
269
|
result.indexed = this.indexed;
|
|
259
270
|
}
|
|
260
271
|
if (this.components) {
|
|
@@ -266,14 +277,22 @@ class ParamType {
|
|
|
266
277
|
// Array
|
|
267
278
|
if (this.baseType === "array") {
|
|
268
279
|
result += this.arrayChildren.format(format);
|
|
269
|
-
result +=
|
|
280
|
+
result +=
|
|
281
|
+
"[" +
|
|
282
|
+
(this.arrayLength < 0 ? "" : String(this.arrayLength)) +
|
|
283
|
+
"]";
|
|
270
284
|
}
|
|
271
285
|
else {
|
|
272
286
|
if (this.baseType === "tuple") {
|
|
273
287
|
if (format !== exports.FormatTypes.sighash) {
|
|
274
288
|
result += this.type;
|
|
275
289
|
}
|
|
276
|
-
result +=
|
|
290
|
+
result +=
|
|
291
|
+
"(" +
|
|
292
|
+
this.components
|
|
293
|
+
.map((comp) => comp.format(format))
|
|
294
|
+
.join(format === exports.FormatTypes.full ? ", " : ",") +
|
|
295
|
+
")";
|
|
277
296
|
}
|
|
278
297
|
else {
|
|
279
298
|
result += this.type;
|
|
@@ -290,7 +309,7 @@ class ParamType {
|
|
|
290
309
|
return result;
|
|
291
310
|
}
|
|
292
311
|
static from(value, allowIndexed) {
|
|
293
|
-
if (typeof
|
|
312
|
+
if (typeof value === "string") {
|
|
294
313
|
return ParamType.fromString(value, allowIndexed);
|
|
295
314
|
}
|
|
296
315
|
return ParamType.fromObject(value);
|
|
@@ -300,10 +319,12 @@ class ParamType {
|
|
|
300
319
|
return value;
|
|
301
320
|
}
|
|
302
321
|
return new ParamType(_constructorGuard, {
|
|
303
|
-
name:
|
|
322
|
+
name: value.name || null,
|
|
304
323
|
type: verifyType(value.type),
|
|
305
|
-
indexed:
|
|
306
|
-
components:
|
|
324
|
+
indexed: value.indexed == null ? null : !!value.indexed,
|
|
325
|
+
components: value.components
|
|
326
|
+
? value.components.map(ParamType.fromObject)
|
|
327
|
+
: null,
|
|
307
328
|
});
|
|
308
329
|
}
|
|
309
330
|
static fromString(value, allowIndexed) {
|
|
@@ -312,7 +333,7 @@ class ParamType {
|
|
|
312
333
|
name: node.name,
|
|
313
334
|
type: node.type,
|
|
314
335
|
indexed: node.indexed,
|
|
315
|
-
components: node.components
|
|
336
|
+
components: node.components,
|
|
316
337
|
});
|
|
317
338
|
}
|
|
318
339
|
return ParamTypify(parseParamType(value, !!allowIndexed));
|
|
@@ -322,7 +343,6 @@ class ParamType {
|
|
|
322
343
|
}
|
|
323
344
|
}
|
|
324
345
|
exports.ParamType = ParamType;
|
|
325
|
-
;
|
|
326
346
|
function parseParams(value, allowIndex) {
|
|
327
347
|
return splitNesting(value).map((param) => ParamType.fromString(param, allowIndex));
|
|
328
348
|
}
|
|
@@ -330,7 +350,7 @@ class Fragment {
|
|
|
330
350
|
constructor(constructorGuard, params) {
|
|
331
351
|
if (constructorGuard !== _constructorGuard) {
|
|
332
352
|
logger.throwError("use a static from method", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
333
|
-
operation: "new Fragment()"
|
|
353
|
+
operation: "new Fragment()",
|
|
334
354
|
});
|
|
335
355
|
}
|
|
336
356
|
populate(this, params);
|
|
@@ -341,7 +361,7 @@ class Fragment {
|
|
|
341
361
|
if (Fragment.isFragment(value)) {
|
|
342
362
|
return value;
|
|
343
363
|
}
|
|
344
|
-
if (typeof
|
|
364
|
+
if (typeof value === "string") {
|
|
345
365
|
return Fragment.fromString(value);
|
|
346
366
|
}
|
|
347
367
|
return Fragment.fromObject(value);
|
|
@@ -369,7 +389,10 @@ class Fragment {
|
|
|
369
389
|
static fromString(value) {
|
|
370
390
|
// Make sure the "returns" is surrounded by a space and all whitespace is exactly one space
|
|
371
391
|
value = value.replace(/\s/g, " ");
|
|
372
|
-
value = value
|
|
392
|
+
value = value
|
|
393
|
+
.replace(/\(/g, " (")
|
|
394
|
+
.replace(/\)/g, ") ")
|
|
395
|
+
.replace(/\s+/g, " ");
|
|
373
396
|
value = value.trim();
|
|
374
397
|
if (value.split(" ")[0] === "event") {
|
|
375
398
|
return EventFragment.fromString(value.substring(5).trim());
|
|
@@ -403,14 +426,20 @@ class EventFragment extends Fragment {
|
|
|
403
426
|
type: "event",
|
|
404
427
|
anonymous: this.anonymous,
|
|
405
428
|
name: this.name,
|
|
406
|
-
inputs: this.inputs.map((input) => JSON.parse(input.format(format)))
|
|
429
|
+
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
|
407
430
|
});
|
|
408
431
|
}
|
|
409
432
|
let result = "";
|
|
410
433
|
if (format !== exports.FormatTypes.sighash) {
|
|
411
434
|
result += "event ";
|
|
412
435
|
}
|
|
413
|
-
result +=
|
|
436
|
+
result +=
|
|
437
|
+
this.name +
|
|
438
|
+
"(" +
|
|
439
|
+
this.inputs
|
|
440
|
+
.map((input) => input.format(format))
|
|
441
|
+
.join(format === exports.FormatTypes.full ? ", " : ",") +
|
|
442
|
+
") ";
|
|
414
443
|
if (format !== exports.FormatTypes.sighash) {
|
|
415
444
|
if (this.anonymous) {
|
|
416
445
|
result += "anonymous ";
|
|
@@ -419,7 +448,7 @@ class EventFragment extends Fragment {
|
|
|
419
448
|
return result.trim();
|
|
420
449
|
}
|
|
421
450
|
static from(value) {
|
|
422
|
-
if (typeof
|
|
451
|
+
if (typeof value === "string") {
|
|
423
452
|
return EventFragment.fromString(value);
|
|
424
453
|
}
|
|
425
454
|
return EventFragment.fromObject(value);
|
|
@@ -434,8 +463,8 @@ class EventFragment extends Fragment {
|
|
|
434
463
|
const params = {
|
|
435
464
|
name: verifyIdentifier(value.name),
|
|
436
465
|
anonymous: value.anonymous,
|
|
437
|
-
inputs:
|
|
438
|
-
type: "event"
|
|
466
|
+
inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [],
|
|
467
|
+
type: "event",
|
|
439
468
|
};
|
|
440
469
|
return new EventFragment(_constructorGuard, params);
|
|
441
470
|
}
|
|
@@ -460,11 +489,11 @@ class EventFragment extends Fragment {
|
|
|
460
489
|
name: match[1].trim(),
|
|
461
490
|
anonymous: anonymous,
|
|
462
491
|
inputs: parseParams(match[2], true),
|
|
463
|
-
type: "event"
|
|
492
|
+
type: "event",
|
|
464
493
|
});
|
|
465
494
|
}
|
|
466
495
|
static isEventFragment(value) {
|
|
467
|
-
return
|
|
496
|
+
return value && value._isFragment && value.type === "event";
|
|
468
497
|
}
|
|
469
498
|
}
|
|
470
499
|
exports.EventFragment = EventFragment;
|
|
@@ -521,29 +550,35 @@ function verifyState(value) {
|
|
|
521
550
|
let result = {
|
|
522
551
|
constant: false,
|
|
523
552
|
payable: true,
|
|
524
|
-
stateMutability: "payable"
|
|
553
|
+
stateMutability: "payable",
|
|
525
554
|
};
|
|
526
555
|
if (value.stateMutability != null) {
|
|
527
556
|
result.stateMutability = value.stateMutability;
|
|
528
557
|
// Set (and check things are consistent) the constant property
|
|
529
|
-
result.constant =
|
|
558
|
+
result.constant =
|
|
559
|
+
result.stateMutability === "view" ||
|
|
560
|
+
result.stateMutability === "pure";
|
|
530
561
|
if (value.constant != null) {
|
|
531
|
-
if (
|
|
532
|
-
logger.throwArgumentError("cannot have constant function with mutability " +
|
|
562
|
+
if (!!value.constant !== result.constant) {
|
|
563
|
+
logger.throwArgumentError("cannot have constant function with mutability " +
|
|
564
|
+
result.stateMutability, "value", value);
|
|
533
565
|
}
|
|
534
566
|
}
|
|
535
567
|
// Set (and check things are consistent) the payable property
|
|
536
|
-
result.payable =
|
|
568
|
+
result.payable = result.stateMutability === "payable";
|
|
537
569
|
if (value.payable != null) {
|
|
538
|
-
if (
|
|
539
|
-
logger.throwArgumentError("cannot have payable function with mutability " +
|
|
570
|
+
if (!!value.payable !== result.payable) {
|
|
571
|
+
logger.throwArgumentError("cannot have payable function with mutability " +
|
|
572
|
+
result.stateMutability, "value", value);
|
|
540
573
|
}
|
|
541
574
|
}
|
|
542
575
|
}
|
|
543
576
|
else if (value.payable != null) {
|
|
544
577
|
result.payable = !!value.payable;
|
|
545
578
|
// If payable we can assume non-constant; otherwise we can't assume
|
|
546
|
-
if (value.constant == null &&
|
|
579
|
+
if (value.constant == null &&
|
|
580
|
+
!result.payable &&
|
|
581
|
+
value.type !== "constructor") {
|
|
547
582
|
logger.throwArgumentError("unable to determine stateMutability", "value", value);
|
|
548
583
|
}
|
|
549
584
|
result.constant = !!value.constant;
|
|
@@ -551,7 +586,7 @@ function verifyState(value) {
|
|
|
551
586
|
result.stateMutability = "view";
|
|
552
587
|
}
|
|
553
588
|
else {
|
|
554
|
-
result.stateMutability =
|
|
589
|
+
result.stateMutability = result.payable ? "payable" : "nonpayable";
|
|
555
590
|
}
|
|
556
591
|
if (result.payable && result.constant) {
|
|
557
592
|
logger.throwArgumentError("cannot have constant payable function", "value", value);
|
|
@@ -560,7 +595,7 @@ function verifyState(value) {
|
|
|
560
595
|
else if (value.constant != null) {
|
|
561
596
|
result.constant = !!value.constant;
|
|
562
597
|
result.payable = !result.constant;
|
|
563
|
-
result.stateMutability =
|
|
598
|
+
result.stateMutability = result.constant ? "view" : "payable";
|
|
564
599
|
}
|
|
565
600
|
else if (value.type !== "constructor") {
|
|
566
601
|
logger.throwArgumentError("unable to determine stateMutability", "value", value);
|
|
@@ -578,25 +613,31 @@ class ConstructorFragment extends Fragment {
|
|
|
578
613
|
if (format === exports.FormatTypes.json) {
|
|
579
614
|
return JSON.stringify({
|
|
580
615
|
type: "constructor",
|
|
581
|
-
stateMutability:
|
|
616
|
+
stateMutability: this.stateMutability !== "nonpayable"
|
|
617
|
+
? this.stateMutability
|
|
618
|
+
: undefined,
|
|
582
619
|
payable: this.payable,
|
|
583
|
-
gas:
|
|
584
|
-
inputs: this.inputs.map((input) => JSON.parse(input.format(format)))
|
|
620
|
+
gas: this.gas ? this.gas.toNumber() : undefined,
|
|
621
|
+
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
|
585
622
|
});
|
|
586
623
|
}
|
|
587
624
|
if (format === exports.FormatTypes.sighash) {
|
|
588
625
|
logger.throwError("cannot format a constructor for sighash", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
589
|
-
operation: "format(sighash)"
|
|
626
|
+
operation: "format(sighash)",
|
|
590
627
|
});
|
|
591
628
|
}
|
|
592
|
-
let result = "constructor(" +
|
|
629
|
+
let result = "constructor(" +
|
|
630
|
+
this.inputs
|
|
631
|
+
.map((input) => input.format(format))
|
|
632
|
+
.join(format === exports.FormatTypes.full ? ", " : ",") +
|
|
633
|
+
") ";
|
|
593
634
|
if (this.stateMutability && this.stateMutability !== "nonpayable") {
|
|
594
635
|
result += this.stateMutability + " ";
|
|
595
636
|
}
|
|
596
637
|
return result.trim();
|
|
597
638
|
}
|
|
598
639
|
static from(value) {
|
|
599
|
-
if (typeof
|
|
640
|
+
if (typeof value === "string") {
|
|
600
641
|
return ConstructorFragment.fromString(value);
|
|
601
642
|
}
|
|
602
643
|
return ConstructorFragment.fromObject(value);
|
|
@@ -615,10 +656,10 @@ class ConstructorFragment extends Fragment {
|
|
|
615
656
|
const params = {
|
|
616
657
|
name: null,
|
|
617
658
|
type: value.type,
|
|
618
|
-
inputs:
|
|
659
|
+
inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [],
|
|
619
660
|
payable: state.payable,
|
|
620
661
|
stateMutability: state.stateMutability,
|
|
621
|
-
gas:
|
|
662
|
+
gas: value.gas ? bignumber_1.BigNumber.from(value.gas) : null,
|
|
622
663
|
};
|
|
623
664
|
return new ConstructorFragment(_constructorGuard, params);
|
|
624
665
|
}
|
|
@@ -634,7 +675,7 @@ class ConstructorFragment extends Fragment {
|
|
|
634
675
|
return ConstructorFragment.fromObject(params);
|
|
635
676
|
}
|
|
636
677
|
static isConstructorFragment(value) {
|
|
637
|
-
return
|
|
678
|
+
return value && value._isFragment && value.type === "constructor";
|
|
638
679
|
}
|
|
639
680
|
}
|
|
640
681
|
exports.ConstructorFragment = ConstructorFragment;
|
|
@@ -651,9 +692,11 @@ class FunctionFragment extends ConstructorFragment {
|
|
|
651
692
|
type: "function",
|
|
652
693
|
name: this.name,
|
|
653
694
|
constant: this.constant,
|
|
654
|
-
stateMutability:
|
|
695
|
+
stateMutability: this.stateMutability !== "nonpayable"
|
|
696
|
+
? this.stateMutability
|
|
697
|
+
: undefined,
|
|
655
698
|
payable: this.payable,
|
|
656
|
-
gas:
|
|
699
|
+
gas: this.gas ? this.gas.toNumber() : undefined,
|
|
657
700
|
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
|
658
701
|
outputs: this.outputs.map((output) => JSON.parse(output.format(format))),
|
|
659
702
|
});
|
|
@@ -662,18 +705,29 @@ class FunctionFragment extends ConstructorFragment {
|
|
|
662
705
|
if (format !== exports.FormatTypes.sighash) {
|
|
663
706
|
result += "function ";
|
|
664
707
|
}
|
|
665
|
-
result +=
|
|
708
|
+
result +=
|
|
709
|
+
this.name +
|
|
710
|
+
"(" +
|
|
711
|
+
this.inputs
|
|
712
|
+
.map((input) => input.format(format))
|
|
713
|
+
.join(format === exports.FormatTypes.full ? ", " : ",") +
|
|
714
|
+
") ";
|
|
666
715
|
if (format !== exports.FormatTypes.sighash) {
|
|
667
716
|
if (this.stateMutability) {
|
|
668
717
|
if (this.stateMutability !== "nonpayable") {
|
|
669
|
-
result +=
|
|
718
|
+
result += this.stateMutability + " ";
|
|
670
719
|
}
|
|
671
720
|
}
|
|
672
721
|
else if (this.constant) {
|
|
673
722
|
result += "view ";
|
|
674
723
|
}
|
|
675
724
|
if (this.outputs && this.outputs.length) {
|
|
676
|
-
result +=
|
|
725
|
+
result +=
|
|
726
|
+
"returns (" +
|
|
727
|
+
this.outputs
|
|
728
|
+
.map((output) => output.format(format))
|
|
729
|
+
.join(", ") +
|
|
730
|
+
") ";
|
|
677
731
|
}
|
|
678
732
|
if (this.gas != null) {
|
|
679
733
|
result += "@" + this.gas.toString() + " ";
|
|
@@ -682,7 +736,7 @@ class FunctionFragment extends ConstructorFragment {
|
|
|
682
736
|
return result.trim();
|
|
683
737
|
}
|
|
684
738
|
static from(value) {
|
|
685
|
-
if (typeof
|
|
739
|
+
if (typeof value === "string") {
|
|
686
740
|
return FunctionFragment.fromString(value);
|
|
687
741
|
}
|
|
688
742
|
return FunctionFragment.fromObject(value);
|
|
@@ -699,11 +753,13 @@ class FunctionFragment extends ConstructorFragment {
|
|
|
699
753
|
type: value.type,
|
|
700
754
|
name: verifyIdentifier(value.name),
|
|
701
755
|
constant: state.constant,
|
|
702
|
-
inputs:
|
|
703
|
-
outputs:
|
|
756
|
+
inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [],
|
|
757
|
+
outputs: value.outputs
|
|
758
|
+
? value.outputs.map(ParamType.fromObject)
|
|
759
|
+
: [],
|
|
704
760
|
payable: state.payable,
|
|
705
761
|
stateMutability: state.stateMutability,
|
|
706
|
-
gas:
|
|
762
|
+
gas: value.gas ? bignumber_1.BigNumber.from(value.gas) : null,
|
|
707
763
|
};
|
|
708
764
|
return new FunctionFragment(_constructorGuard, params);
|
|
709
765
|
}
|
|
@@ -738,7 +794,7 @@ class FunctionFragment extends ConstructorFragment {
|
|
|
738
794
|
return FunctionFragment.fromObject(params);
|
|
739
795
|
}
|
|
740
796
|
static isFunctionFragment(value) {
|
|
741
|
-
return
|
|
797
|
+
return value && value._isFragment && value.type === "function";
|
|
742
798
|
}
|
|
743
799
|
}
|
|
744
800
|
exports.FunctionFragment = FunctionFragment;
|
|
@@ -770,11 +826,17 @@ class ErrorFragment extends Fragment {
|
|
|
770
826
|
if (format !== exports.FormatTypes.sighash) {
|
|
771
827
|
result += "error ";
|
|
772
828
|
}
|
|
773
|
-
result +=
|
|
829
|
+
result +=
|
|
830
|
+
this.name +
|
|
831
|
+
"(" +
|
|
832
|
+
this.inputs
|
|
833
|
+
.map((input) => input.format(format))
|
|
834
|
+
.join(format === exports.FormatTypes.full ? ", " : ",") +
|
|
835
|
+
") ";
|
|
774
836
|
return result.trim();
|
|
775
837
|
}
|
|
776
838
|
static from(value) {
|
|
777
|
-
if (typeof
|
|
839
|
+
if (typeof value === "string") {
|
|
778
840
|
return ErrorFragment.fromString(value);
|
|
779
841
|
}
|
|
780
842
|
return ErrorFragment.fromObject(value);
|
|
@@ -789,7 +851,7 @@ class ErrorFragment extends Fragment {
|
|
|
789
851
|
const params = {
|
|
790
852
|
type: value.type,
|
|
791
853
|
name: verifyIdentifier(value.name),
|
|
792
|
-
inputs:
|
|
854
|
+
inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [],
|
|
793
855
|
};
|
|
794
856
|
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
|
795
857
|
}
|
|
@@ -807,7 +869,7 @@ class ErrorFragment extends Fragment {
|
|
|
807
869
|
return checkForbidden(ErrorFragment.fromObject(params));
|
|
808
870
|
}
|
|
809
871
|
static isErrorFragment(value) {
|
|
810
|
-
return
|
|
872
|
+
return value && value._isFragment && value.type === "error";
|
|
811
873
|
}
|
|
812
874
|
}
|
|
813
875
|
exports.ErrorFragment = ErrorFragment;
|