solc-typed-ast 19.0.0 → 19.2.0
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/ast/ast_reader.d.ts +1 -0
- package/dist/ast/ast_reader.d.ts.map +1 -1
- package/dist/ast/ast_reader.js +7 -0
- package/dist/ast/ast_reader.js.map +1 -1
- package/dist/misc/utils.d.ts +1 -1
- package/dist/misc/utils.d.ts.map +1 -1
- package/dist/misc/utils.js +2 -2
- package/dist/misc/utils.js.map +1 -1
- package/dist/typeIdentifiers/abi.d.ts +15 -0
- package/dist/typeIdentifiers/abi.d.ts.map +1 -0
- package/dist/typeIdentifiers/abi.js +94 -0
- package/dist/typeIdentifiers/abi.js.map +1 -0
- package/dist/typeIdentifiers/ast/pointer.d.ts +1 -1
- package/dist/typeIdentifiers/ast/pointer.d.ts.map +1 -1
- package/dist/typeIdentifiers/ast/rational_num.d.ts.map +1 -1
- package/dist/typeIdentifiers/ast/rational_num.js +0 -2
- package/dist/typeIdentifiers/ast/rational_num.js.map +1 -1
- package/dist/typeIdentifiers/ast/tuple.d.ts +2 -2
- package/dist/typeIdentifiers/ast/tuple.d.ts.map +1 -1
- package/dist/typeIdentifiers/ast/tuple.js.map +1 -1
- package/dist/typeIdentifiers/constants.d.ts +18 -0
- package/dist/typeIdentifiers/constants.d.ts.map +1 -0
- package/dist/typeIdentifiers/constants.js +22 -0
- package/dist/typeIdentifiers/constants.js.map +1 -0
- package/dist/typeIdentifiers/index.d.ts +2 -0
- package/dist/typeIdentifiers/index.d.ts.map +1 -1
- package/dist/typeIdentifiers/index.js +2 -0
- package/dist/typeIdentifiers/index.js.map +1 -1
- package/dist/typeIdentifiers/signature.d.ts +4 -0
- package/dist/typeIdentifiers/signature.d.ts.map +1 -0
- package/dist/typeIdentifiers/signature.js +157 -0
- package/dist/typeIdentifiers/signature.js.map +1 -0
- package/dist/typeIdentifiers/utils.d.ts +42 -1
- package/dist/typeIdentifiers/utils.d.ts.map +1 -1
- package/dist/typeIdentifiers/utils.js +127 -1
- package/dist/typeIdentifiers/utils.js.map +1 -1
- package/package.json +4 -2
package/dist/ast/ast_reader.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare class ASTContext {
|
|
|
40
40
|
unregister(...nodes: ASTNode[]): void;
|
|
41
41
|
locate(id: number): ASTNode;
|
|
42
42
|
require(id: number): ASTNode;
|
|
43
|
+
requireType<T extends ASTNode>(id: number, constr: ASTNodeConstructor<T>): T;
|
|
43
44
|
contains(node: ASTNode): boolean;
|
|
44
45
|
}
|
|
45
46
|
export declare class ASTPostprocessor {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast_reader.d.ts","sourceRoot":"","sources":["../../src/ast/ast_reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAQ/D,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE9C,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,OAAO;IAC/C,OAAO,CACH,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,sBAAsB,EAC9B,GAAG,EAAE,GAAG,GACT,qBAAqB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,OAAO;IACnD,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/D,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,cAAc;IAC3B,WAAW,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAA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AM7E,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAQxE,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;CAS/D;AAED,oBAAY,OAAO;IACf,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,qBAAa,SAAS;IAClB;;OAEG;IACH,OAAO,EAAE,UAAU,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,gBAAgB,CAAC;gBAEpB,OAAO,aAAmB,EAAE,aAAa,mBAAyB;IAK9E;;;;;;;;;;OAUG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,UAAc,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,EAAE;IA0CpE;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO;IAkB1D;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,EAAE;CAatE"}
|
package/dist/ast/ast_reader.js
CHANGED
|
@@ -64,6 +64,13 @@ class ASTContext {
|
|
|
64
64
|
}
|
|
65
65
|
throw new Error("Required node not found for id " + id);
|
|
66
66
|
}
|
|
67
|
+
requireType(id, constr) {
|
|
68
|
+
const node = this.locate(id);
|
|
69
|
+
if (node instanceof constr) {
|
|
70
|
+
return node;
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`Required node of type ${constr.name} for id ${id}, not ${node}`);
|
|
73
|
+
}
|
|
67
74
|
contains(node) {
|
|
68
75
|
return this.locate(node.id) === node;
|
|
69
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast_reader.js","sourceRoot":"","sources":["../../src/ast/ast_reader.ts"],"names":[],"mappings":";;;AAEA,qCAA+C;AAC/C,qC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CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAExF,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAExC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,KAAU,EAAE,MAA8B;QACnD,MAAM,MAAM,GAAc,EAAE,CAAC;QAE7B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YACzB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;gBACtB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAEvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA9GD,8BA8GC"}
|
package/dist/misc/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PPIsh } from "
|
|
1
|
+
import { PPIsh } from "./pretty_printing";
|
|
2
2
|
export declare function forAll<T>(iterable: Iterable<T>, cb: (v: T) => boolean): boolean;
|
|
3
3
|
export declare function forAny<T>(iterable: Iterable<T>, cb: (v: T) => boolean): boolean;
|
|
4
4
|
export declare function assert(condition: boolean, message: string, ...details: PPIsh[]): asserts condition;
|
package/dist/misc/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/misc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/misc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,wBAAgB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAQ/E;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAQ/E;AAED,wBAAgB,MAAM,CAClB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,GAAG,OAAO,EAAE,KAAK,EAAE,GACpB,OAAO,CAAC,SAAS,CAMnB;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAO9C"}
|
package/dist/misc/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.repeat = exports.assert = exports.forAny = exports.forAll = void 0;
|
|
4
|
-
const
|
|
4
|
+
const pretty_printing_1 = require("./pretty_printing");
|
|
5
5
|
function forAll(iterable, cb) {
|
|
6
6
|
for (const el of iterable) {
|
|
7
7
|
if (!cb(el)) {
|
|
@@ -24,7 +24,7 @@ function assert(condition, message, ...details) {
|
|
|
24
24
|
if (condition) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
throw new Error((0,
|
|
27
|
+
throw new Error((0, pretty_printing_1.fmt)(message, ...details));
|
|
28
28
|
}
|
|
29
29
|
exports.assert = assert;
|
|
30
30
|
function repeat(x, n) {
|
package/dist/misc/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/misc/utils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/misc/utils.ts"],"names":[],"mappings":";;;AAAA,uDAA+C;AAE/C,SAAgB,MAAM,CAAI,QAAqB,EAAE,EAAqB;IAClE,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QACxB,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AARD,wBAQC;AAED,SAAgB,MAAM,CAAI,QAAqB,EAAE,EAAqB;IAClE,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QACxB,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;YACT,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AARD,wBAQC;AAED,SAAgB,MAAM,CAClB,SAAkB,EAClB,OAAe,EACf,GAAG,OAAgB;IAEnB,IAAI,SAAS,EAAE,CAAC;QACZ,OAAO;IACX,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,IAAA,qBAAG,EAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;AAC9C,CAAC;AAVD,wBAUC;AAED,SAAgB,MAAM,CAAI,CAAI,EAAE,CAAS;IACrC,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAPD,wBAOC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ASTContext, EnumDefinition } from "../ast";
|
|
2
|
+
import { TypeIdentifier, IntTypeId } from "./ast";
|
|
3
|
+
/**
|
|
4
|
+
* Return the int typeIdentifier corresponding to a given Enum
|
|
5
|
+
* @param decl
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function enumToIntTypeId(decl: EnumDefinition): IntTypeId;
|
|
9
|
+
/**
|
|
10
|
+
* Given an function argument's `TypeIdentifier` `from`, return the
|
|
11
|
+
* `TypeIdentifier` that this argument would be encoded as in calldata.
|
|
12
|
+
* @param from
|
|
13
|
+
*/
|
|
14
|
+
export declare function toABIType(from: TypeIdentifier, ctx: ASTContext): TypeIdentifier;
|
|
15
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/abi.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAGV,cAAc,EAEjB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACH,cAAc,EAMd,SAAS,EAUZ,MAAM,OAAO,CAAC;AAIf;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAoB/D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,GAAG,cAAc,CA8E/E"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toABIType = exports.enumToIntTypeId = void 0;
|
|
4
|
+
const ast_1 = require("../ast");
|
|
5
|
+
const misc_1 = require("../misc");
|
|
6
|
+
const ast_2 = require("./ast");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
/**
|
|
10
|
+
* Return the int typeIdentifier corresponding to a given Enum
|
|
11
|
+
* @param decl
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function enumToIntTypeId(decl) {
|
|
15
|
+
const length = decl.children.length;
|
|
16
|
+
let size;
|
|
17
|
+
for (let n = 8; n <= 32; n += 8) {
|
|
18
|
+
if (length <= 2 ** n) {
|
|
19
|
+
size = n;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
(0, misc_1.assert)(size !== undefined, "Unable to detect enum type size - member count exceeds 2 ** 32", decl);
|
|
24
|
+
return new ast_2.IntTypeId(size, false);
|
|
25
|
+
}
|
|
26
|
+
exports.enumToIntTypeId = enumToIntTypeId;
|
|
27
|
+
/**
|
|
28
|
+
* Given an function argument's `TypeIdentifier` `from`, return the
|
|
29
|
+
* `TypeIdentifier` that this argument would be encoded as in calldata.
|
|
30
|
+
* @param from
|
|
31
|
+
*/
|
|
32
|
+
function toABIType(from, ctx) {
|
|
33
|
+
if (from instanceof ast_2.AddressTypeId) {
|
|
34
|
+
// normalize payable -> address
|
|
35
|
+
return constants_1.addressT;
|
|
36
|
+
}
|
|
37
|
+
// Simple case - these are passed unchanged
|
|
38
|
+
if (from instanceof ast_2.BoolTypeId ||
|
|
39
|
+
from instanceof ast_2.BytesTypeId ||
|
|
40
|
+
from instanceof ast_2.StringTypeId ||
|
|
41
|
+
from instanceof ast_2.FixedBytesTypeId ||
|
|
42
|
+
from instanceof ast_2.IntTypeId) {
|
|
43
|
+
return from;
|
|
44
|
+
}
|
|
45
|
+
if ((0, utils_1.isTypeInStorage)(from)) {
|
|
46
|
+
return constants_1.uint256T;
|
|
47
|
+
}
|
|
48
|
+
if (from instanceof ast_2.PointerTypeId) {
|
|
49
|
+
(0, misc_1.assert)(from.location !== ast_1.DataLocation.Storage, `Unexpected pointer {0}`, from);
|
|
50
|
+
return toABIType(from.toType, ctx);
|
|
51
|
+
}
|
|
52
|
+
// Size arrays are passed as tuples, unsized arrays as arrays
|
|
53
|
+
if (from instanceof ast_2.ArrayTypeId) {
|
|
54
|
+
const elT = toABIType(from.elT, ctx);
|
|
55
|
+
return from.size === undefined
|
|
56
|
+
? new ast_2.ArrayTypeId(elT, from.size)
|
|
57
|
+
: new ast_2.TupleTypeId((0, misc_1.repeat)(elT, Number(from.size)));
|
|
58
|
+
}
|
|
59
|
+
if (from instanceof ast_2.UserDefinedValueTypeId) {
|
|
60
|
+
const def = ctx.requireType(from.id, ast_1.UserDefinedValueTypeDefinition);
|
|
61
|
+
const innerT = (0, utils_1.typeOf)(def.underlyingType);
|
|
62
|
+
return toABIType(innerT, ctx);
|
|
63
|
+
}
|
|
64
|
+
// Contracts are passed as addresses
|
|
65
|
+
if (from instanceof ast_2.ContractTypeId) {
|
|
66
|
+
return constants_1.addressT;
|
|
67
|
+
}
|
|
68
|
+
// Enums are passed as the smallest number that fits
|
|
69
|
+
if (from instanceof ast_2.EnumTypeId) {
|
|
70
|
+
const def = ctx.requireType(from.id, ast_1.EnumDefinition);
|
|
71
|
+
return enumToIntTypeId(def);
|
|
72
|
+
}
|
|
73
|
+
// Structs are passed as tuples
|
|
74
|
+
if (from instanceof ast_2.StructTypeId) {
|
|
75
|
+
const def = ctx.requireType(from.id, ast_1.StructDefinition);
|
|
76
|
+
let fieldTs = def.vMembers.map((decl) => (0, utils_1.typeOf)(decl));
|
|
77
|
+
// Remove any mappings
|
|
78
|
+
fieldTs = fieldTs.filter((fieldT) => !(fieldT instanceof ast_2.MappingTypeId));
|
|
79
|
+
// Convert the fields to ABI types and filter out any empty tuples.
|
|
80
|
+
// Empty tuples can result if a field is a struct contains only mappings.
|
|
81
|
+
// Also note that struct fields have "storage" as a default location.
|
|
82
|
+
// Convert to Memory to avoid treating them as storage pointers.
|
|
83
|
+
const abiFieldTs = fieldTs
|
|
84
|
+
.map((fieldT) => toABIType((0, utils_1.changeLocationTo)(fieldT, ast_1.DataLocation.Memory), ctx))
|
|
85
|
+
.filter((abiFieldT) => !(abiFieldT instanceof ast_2.TupleTypeId && abiFieldT.components.length === 0));
|
|
86
|
+
return new ast_2.TupleTypeId(abiFieldTs);
|
|
87
|
+
}
|
|
88
|
+
if (from instanceof ast_2.FunctionTypeId && from.kind === "external") {
|
|
89
|
+
return constants_1.bytes24T;
|
|
90
|
+
}
|
|
91
|
+
(0, misc_1.assert)(false, `Cannot abi encode type ${from.pp()}`);
|
|
92
|
+
}
|
|
93
|
+
exports.toABIType = toABIType;
|
|
94
|
+
//# sourceMappingURL=abi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../../src/typeIdentifiers/abi.ts"],"names":[],"mappings":";;;AAAA,gCAMgB;AAChB,kCAAyC;AACzC,+BAiBe;AACf,2CAA2D;AAC3D,mCAAoE;AAEpE;;;;GAIG;AACH,SAAgB,eAAe,CAAC,IAAoB;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAEpC,IAAI,IAAwB,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,IAAI,GAAG,CAAC,CAAC;YAET,MAAM;QACV,CAAC;IACL,CAAC;IAED,IAAA,aAAM,EACF,IAAI,KAAK,SAAS,EAClB,gEAAgE,EAChE,IAAI,CACP,CAAC;IAEF,OAAO,IAAI,eAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AApBD,0CAoBC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,IAAoB,EAAE,GAAe;IAC3D,IAAI,IAAI,YAAY,mBAAa,EAAE,CAAC;QAChC,+BAA+B;QAC/B,OAAO,oBAAQ,CAAC;IACp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C;IAED,IAAA,aAAM,EAAC,KAAK,EAAE,0BAA0B,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AA9ED,8BA8EC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/pointer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/pointer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,aAAc,SAAQ,cAAc;aAEzB,MAAM,EAAE,cAAc;aACtB,QAAQ,EAAE,YAAY;aACtB,SAAS,EAAE,OAAO;gBAFlB,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,OAAO;IAKtC,EAAE,IAAI,MAAM;CAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational_num.d.ts","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/rational_num.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rational_num.d.ts","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/rational_num.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,qBAAa,iBAAkB,SAAQ,cAAc;aAE7B,SAAS,EAAE,MAAM;aACjB,WAAW,EAAE,MAAM;gBADnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM;IAKvC,EAAE,IAAI,MAAM;CAGf"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RationalNumTypeId = void 0;
|
|
4
|
-
const misc_1 = require("../../misc");
|
|
5
4
|
const type_identifier_1 = require("./type_identifier");
|
|
6
5
|
const utils_1 = require("./utils");
|
|
7
6
|
class RationalNumTypeId extends type_identifier_1.TypeIdentifier {
|
|
8
7
|
constructor(numerator, denominator) {
|
|
9
|
-
(0, misc_1.assert)(denominator > 0n, ``);
|
|
10
8
|
super();
|
|
11
9
|
this.numerator = numerator;
|
|
12
10
|
this.denominator = denominator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational_num.js","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/rational_num.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"rational_num.js","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/rational_num.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mCAAoC;AAEpC,MAAa,iBAAkB,SAAQ,gCAAc;IACjD,YACoB,SAAiB,EACjB,WAAmB;QAEnC,KAAK,EAAE,CAAC;QAHQ,cAAS,GAAT,SAAS,CAAQ;QACjB,gBAAW,GAAX,WAAW,CAAQ;IAGvC,CAAC;IAED,EAAE;QACE,OAAO,aAAa,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,IAAA,iBAAS,EAAC,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IACjH,CAAC;CACJ;AAXD,8CAWC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TypeIdentifier } from "./type_identifier";
|
|
2
2
|
export declare class TupleTypeId extends TypeIdentifier {
|
|
3
|
-
readonly components:
|
|
4
|
-
constructor(components:
|
|
3
|
+
readonly components: TypeIdentifier[];
|
|
4
|
+
constructor(components: TypeIdentifier[]);
|
|
5
5
|
pp(): string;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=tuple.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,qBAAa,WAAY,SAAQ,cAAc;aACf,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,qBAAa,WAAY,SAAQ,cAAc;aACf,UAAU,EAAE,cAAc,EAAE;gBAA5B,UAAU,EAAE,cAAc,EAAE;IAIxD,EAAE,IAAI,MAAM;CAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/tuple.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mCAA+C;AAE/C,MAAa,WAAY,SAAQ,gCAAc;IAC3C,YAA4B,
|
|
1
|
+
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../../src/typeIdentifiers/ast/tuple.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mCAA+C;AAE/C,MAAa,WAAY,SAAQ,gCAAc;IAC3C,YAA4B,UAA4B;QACpD,KAAK,EAAE,CAAC;QADgB,eAAU,GAAV,UAAU,CAAkB;IAExD,CAAC;IAED,EAAE;QACE,OAAO,UAAU,IAAA,4BAAoB,EAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAC7D,CAAC;CACJ;AARD,kCAQC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IntTypeId, AddressTypeId, BytesTypeId, StringTypeId, BoolTypeId, FixedBytesTypeId, PointerTypeId } from "./ast";
|
|
2
|
+
export declare const uint256T: IntTypeId;
|
|
3
|
+
export declare const uint8T: IntTypeId;
|
|
4
|
+
export declare const int256T: IntTypeId;
|
|
5
|
+
export declare const int8T: IntTypeId;
|
|
6
|
+
export declare const bytes1T: FixedBytesTypeId;
|
|
7
|
+
export declare const bytes2T: FixedBytesTypeId;
|
|
8
|
+
export declare const bytes4T: FixedBytesTypeId;
|
|
9
|
+
export declare const bytes20T: FixedBytesTypeId;
|
|
10
|
+
export declare const bytes24T: FixedBytesTypeId;
|
|
11
|
+
export declare const bytes32T: FixedBytesTypeId;
|
|
12
|
+
export declare const addressT: AddressTypeId;
|
|
13
|
+
export declare const bytesT: BytesTypeId;
|
|
14
|
+
export declare const stringT: StringTypeId;
|
|
15
|
+
export declare const memStringPtrT: PointerTypeId;
|
|
16
|
+
export declare const memBytesPtrT: PointerTypeId;
|
|
17
|
+
export declare const boolT: BoolTypeId;
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/constants.ts"],"names":[],"mappings":"AACA,OAAO,EACH,SAAS,EACT,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,aAAa,EAChB,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,QAAQ,WAA4B,CAAC;AAClD,eAAO,MAAM,MAAM,WAA0B,CAAC;AAC9C,eAAO,MAAM,OAAO,WAA2B,CAAC;AAChD,eAAO,MAAM,KAAK,WAAyB,CAAC;AAC5C,eAAO,MAAM,OAAO,kBAA0B,CAAC;AAC/C,eAAO,MAAM,OAAO,kBAA0B,CAAC;AAC/C,eAAO,MAAM,OAAO,kBAA0B,CAAC;AAC/C,eAAO,MAAM,QAAQ,kBAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,kBAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,kBAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,eAA2B,CAAC;AACjD,eAAO,MAAM,MAAM,aAAoB,CAAC;AACxC,eAAO,MAAM,OAAO,cAAqB,CAAC;AAC1C,eAAO,MAAM,aAAa,eAAwD,CAAC;AACnF,eAAO,MAAM,YAAY,eAAuD,CAAC;AACjF,eAAO,MAAM,KAAK,YAAmB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.boolT = exports.memBytesPtrT = exports.memStringPtrT = exports.stringT = exports.bytesT = exports.addressT = exports.bytes32T = exports.bytes24T = exports.bytes20T = exports.bytes4T = exports.bytes2T = exports.bytes1T = exports.int8T = exports.int256T = exports.uint8T = exports.uint256T = void 0;
|
|
4
|
+
const constants_1 = require("../ast/constants");
|
|
5
|
+
const ast_1 = require("./ast");
|
|
6
|
+
exports.uint256T = new ast_1.IntTypeId(256, false);
|
|
7
|
+
exports.uint8T = new ast_1.IntTypeId(8, false);
|
|
8
|
+
exports.int256T = new ast_1.IntTypeId(256, true);
|
|
9
|
+
exports.int8T = new ast_1.IntTypeId(8, true);
|
|
10
|
+
exports.bytes1T = new ast_1.FixedBytesTypeId(1);
|
|
11
|
+
exports.bytes2T = new ast_1.FixedBytesTypeId(2);
|
|
12
|
+
exports.bytes4T = new ast_1.FixedBytesTypeId(4);
|
|
13
|
+
exports.bytes20T = new ast_1.FixedBytesTypeId(20);
|
|
14
|
+
exports.bytes24T = new ast_1.FixedBytesTypeId(24);
|
|
15
|
+
exports.bytes32T = new ast_1.FixedBytesTypeId(32);
|
|
16
|
+
exports.addressT = new ast_1.AddressTypeId(false);
|
|
17
|
+
exports.bytesT = new ast_1.BytesTypeId();
|
|
18
|
+
exports.stringT = new ast_1.StringTypeId();
|
|
19
|
+
exports.memStringPtrT = new ast_1.PointerTypeId(exports.stringT, constants_1.DataLocation.Memory, true);
|
|
20
|
+
exports.memBytesPtrT = new ast_1.PointerTypeId(exports.bytesT, constants_1.DataLocation.Memory, true);
|
|
21
|
+
exports.boolT = new ast_1.BoolTypeId();
|
|
22
|
+
//# sourceM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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.parseTypeIdentifier = void 0;
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
19
|
__exportStar(require("./ast"), exports);
|
|
20
|
+
__exportStar(require("./abi"), exports);
|
|
21
|
+
__exportStar(require("./signature"), exports);
|
|
20
22
|
var typeIdentifier_parser_gen_1 = require("./typeIdentifier_parser_gen");
|
|
21
23
|
Object.defineProperty(exports, "parseTypeIdentifier", { enumerable: true, get: function () { return typeIdentifier_parser_gen_1.parseTypeIdentifier; } });
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/typeIdentifiers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,wCAAsB;AACtB,yEAAkE;AAAzD,gIAAA,mBAAmB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/typeIdentifiers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,wCAAsB;AACtB,wCAAsB;AACtB,8CAA4B;AAC5B,yEAAkE;AAAzD,gIAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FunctionDefinition, VariableDeclaration, EventDefinition, ErrorDefinition } from "../ast";
|
|
2
|
+
export declare function signature(nd: FunctionDefinition | VariableDeclaration | EventDefinition | ErrorDefinition): string;
|
|
3
|
+
export declare function signatureHash(nd: FunctionDefinition | VariableDeclaration | EventDefinition | ErrorDefinition): Uint8Array;
|
|
4
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/signature.ts"],"names":[],"mappings":"AACA,OAAO,EAOH,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,eAAe,EAElB,MAAM,QAAQ,CAAC;AAuLhB,wBAAgB,SAAS,CACrB,EAAE,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,eAAe,GAAG,eAAe,GACjF,MAAM,CA8BR;AAED,wBAAgB,aAAa,CACzB,EAAE,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,eAAe,GAAG,eAAe,GACjF,UAAU,CAIZ"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signatureHash = exports.signature = void 0;
|
|
4
|
+
const utils_1 = require("ethereum-cryptography/utils");
|
|
5
|
+
const ast_1 = require("../ast");
|
|
6
|
+
const misc_1 = require("../misc");
|
|
7
|
+
const ast_2 = require("./ast");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const utils_2 = require("./utils");
|
|
10
|
+
const keccak_1 = require("ethereum-cryptography/keccak");
|
|
11
|
+
const abi_1 = require("./abi");
|
|
12
|
+
/**
|
|
13
|
+
* Given a function argument `TypeIdentifier` `from`, return the
|
|
14
|
+
* `TypeIdentifier` as it should appear in the function signature.
|
|
15
|
+
*
|
|
16
|
+
* This differs from `toAbiType` in how it treats:
|
|
17
|
+
* - storage pointers
|
|
18
|
+
* - structs
|
|
19
|
+
* - functions types
|
|
20
|
+
*
|
|
21
|
+
* @param from
|
|
22
|
+
*/
|
|
23
|
+
function toSignatureType(from, ctx, isLibrary) {
|
|
24
|
+
if (from instanceof ast_2.AddressTypeId) {
|
|
25
|
+
// normalize payable -> address
|
|
26
|
+
return constants_1.addressT;
|
|
27
|
+
}
|
|
28
|
+
// Simple case - these are passed unchanged
|
|
29
|
+
if (from instanceof ast_2.BoolTypeId ||
|
|
30
|
+
from instanceof ast_2.BytesTypeId ||
|
|
31
|
+
from instanceof ast_2.StringTypeId ||
|
|
32
|
+
from instanceof ast_2.FixedBytesTypeId ||
|
|
33
|
+
from instanceof ast_2.IntTypeId) {
|
|
34
|
+
return from;
|
|
35
|
+
}
|
|
36
|
+
if (from instanceof ast_2.PointerTypeId) {
|
|
37
|
+
return toSignatureType(from.toType, ctx, isLibrary);
|
|
38
|
+
}
|
|
39
|
+
// Arrays appear just as arrays in signatures
|
|
40
|
+
if (from instanceof ast_2.ArrayTypeId) {
|
|
41
|
+
const elT = toSignatureType(from.elT, ctx, isLibrary);
|
|
42
|
+
return new ast_2.ArrayTypeId(elT, from.size);
|
|
43
|
+
}
|
|
44
|
+
if (from instanceof ast_2.UserDefinedValueTypeId) {
|
|
45
|
+
const def = ctx.requireType(from.id, ast_1.UserDefinedValueTypeDefinition);
|
|
46
|
+
const innerT = (0, utils_2.typeOf)(def.underlyingType);
|
|
47
|
+
return toSignatureType(innerT, ctx, isLibrary);
|
|
48
|
+
}
|
|
49
|
+
// Contracts are passed as addresses for normal contracts, and by name for libraries
|
|
50
|
+
if (from instanceof ast_2.ContractTypeId) {
|
|
51
|
+
return isLibrary ? from : constants_1.addressT;
|
|
52
|
+
}
|
|
53
|
+
if (from instanceof ast_2.EnumTypeId) {
|
|
54
|
+
if (isLibrary) {
|
|
55
|
+
return from;
|
|
56
|
+
}
|
|
57
|
+
const def = ctx.requireType(from.id, ast_1.EnumDefinition);
|
|
58
|
+
return isLibrary ? from : (0, abi_1.enumToIntTypeId)(def);
|
|
59
|
+
}
|
|
60
|
+
// Structs appear by name in library signatures, and as tuples in normal function signatures
|
|
61
|
+
if (from instanceof ast_2.StructTypeId) {
|
|
62
|
+
if (isLibrary) {
|
|
63
|
+
return from;
|
|
64
|
+
}
|
|
65
|
+
const def = ctx.requireType(from.id, ast_1.StructDefinition);
|
|
66
|
+
let fieldTs = def.vMembers.map((decl) => (0, utils_2.typeOf)(decl));
|
|
67
|
+
// Remove any mappings
|
|
68
|
+
fieldTs = fieldTs.filter((fieldT) => !(fieldT instanceof ast_2.MappingTypeId));
|
|
69
|
+
// Convert the fields to ABI signature types and filter out any empty tuples.
|
|
70
|
+
// Empty tuples can result if a field is a struct contains only mappings.
|
|
71
|
+
// Also note that struct fields have "storage" as a default location.
|
|
72
|
+
// Convert to Memory to avoid treating them as storage pointers.
|
|
73
|
+
const abiFieldTs = fieldTs
|
|
74
|
+
.map((fieldT) => toSignatureType((0, utils_2.changeLocationTo)(fieldT, ast_1.DataLocation.Memory), ctx, isLibrary))
|
|
75
|
+
.filter((abiFieldT) => !(abiFieldT instanceof ast_2.TupleTypeId && abiFieldT.components.length === 0));
|
|
76
|
+
return new ast_2.TupleTypeId(abiFieldTs);
|
|
77
|
+
}
|
|
78
|
+
if (from instanceof ast_2.FunctionTypeId && from.kind === "external") {
|
|
79
|
+
return from;
|
|
80
|
+
}
|
|
81
|
+
if (from instanceof ast_2.MappingTypeId) {
|
|
82
|
+
return new ast_2.MappingTypeId(toSignatureType((0, utils_2.changeLocationTo)(from.keyType, ast_1.DataLocation.Memory), ctx, isLibrary), toSignatureType((0, utils_2.changeLocationTo)(from.valueType, ast_1.DataLocation.Memory), ctx, isLibrary));
|
|
83
|
+
}
|
|
84
|
+
(0, misc_1.assert)(false, `Cannot abi encode type ${from.pp()}`);
|
|
85
|
+
}
|
|
86
|
+
function scopedName(n) {
|
|
87
|
+
const scope = n.vScope;
|
|
88
|
+
return scope instanceof ast_1.ContractDefinition ? `${scope.name}.${n.name}` : n.name;
|
|
89
|
+
}
|
|
90
|
+
function abiTypeIdToCanonicalName(t, ctx) {
|
|
91
|
+
if (t instanceof ast_2.IntTypeId ||
|
|
92
|
+
t instanceof ast_2.FixedBytesTypeId ||
|
|
93
|
+
t instanceof ast_2.BoolTypeId ||
|
|
94
|
+
t instanceof ast_2.BytesTypeId ||
|
|
95
|
+
t instanceof ast_2.StringTypeId) {
|
|
96
|
+
// Skip the t_
|
|
97
|
+
return t.pp().slice(2);
|
|
98
|
+
}
|
|
99
|
+
// Payable is ignored in canonical names
|
|
100
|
+
if (t instanceof ast_2.AddressTypeId) {
|
|
101
|
+
return "address";
|
|
102
|
+
}
|
|
103
|
+
if (t instanceof ast_2.ArrayTypeId) {
|
|
104
|
+
return `${abiTypeIdToCanonicalName(t.elT, ctx)}[${t.size ? t.size.toString(10) : ""}]`;
|
|
105
|
+
}
|
|
106
|
+
if (t instanceof ast_2.TupleTypeId) {
|
|
107
|
+
return `(${t.components.map((compT) => abiTypeIdToCanonicalName(compT, ctx)).join(",")})`;
|
|
108
|
+
}
|
|
109
|
+
if (t instanceof ast_2.FunctionTypeId) {
|
|
110
|
+
return "function";
|
|
111
|
+
}
|
|
112
|
+
if (t instanceof ast_2.MappingTypeId) {
|
|
113
|
+
return `mapping(${abiTypeIdToCanonicalName(t.keyType, ctx)} => ${abiTypeIdToCanonicalName(t.valueType, ctx)})`;
|
|
114
|
+
}
|
|
115
|
+
if (t instanceof ast_2.StructTypeId) {
|
|
116
|
+
return scopedName(ctx.requireType(t.id, ast_1.StructDefinition));
|
|
117
|
+
}
|
|
118
|
+
if (t instanceof ast_2.ContractTypeId) {
|
|
119
|
+
return scopedName(ctx.requireType(t.id, ast_1.ContractDefinition));
|
|
120
|
+
}
|
|
121
|
+
if (t instanceof ast_2.EnumTypeId) {
|
|
122
|
+
return scopedName(ctx.requireType(t.id, ast_1.EnumDefinition));
|
|
123
|
+
}
|
|
124
|
+
(0, misc_1.assert)(false, "Unexpected ABI Type: {0}", t);
|
|
125
|
+
}
|
|
126
|
+
function signature(nd) {
|
|
127
|
+
const ctx = nd.requiredContext;
|
|
128
|
+
let argTs;
|
|
129
|
+
if (nd instanceof ast_1.FunctionDefinition ||
|
|
130
|
+
nd instanceof ast_1.EventDefinition ||
|
|
131
|
+
nd instanceof ast_1.ErrorDefinition) {
|
|
132
|
+
argTs = nd.vParameters.vParameters.map(utils_2.typeOf);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
[argTs] = (0, utils_2.getterArgsAndReturn)(nd);
|
|
136
|
+
}
|
|
137
|
+
const isLibFun = nd instanceof ast_1.FunctionDefinition &&
|
|
138
|
+
nd.vScope instanceof ast_1.ContractDefinition &&
|
|
139
|
+
nd.vScope.kind === ast_1.ContractKind.Library;
|
|
140
|
+
const argSigTs = argTs.map((t) => [
|
|
141
|
+
toSignatureType(t, ctx, isLibFun),
|
|
142
|
+
(0, utils_2.isTypeInStorage)(t)
|
|
143
|
+
]);
|
|
144
|
+
return `${nd.name}(${argSigTs
|
|
145
|
+
.map(([t, isStorage]) => {
|
|
146
|
+
const tName = abiTypeIdToCanonicalName(t, ctx);
|
|
147
|
+
return isStorage ? `${tName} storage` : tName;
|
|
148
|
+
})
|
|
149
|
+
.join(",")})`;
|
|
150
|
+
}
|
|
151
|
+
exports.signature = signature;
|
|
152
|
+
function signatureHash(nd) {
|
|
153
|
+
const sig = signature(nd);
|
|
154
|
+
return (0, keccak_1.keccak256)((0, utils_1.utf8ToBytes)(sig)).slice(0, 4);
|
|
155
|
+
}
|
|
156
|
+
exports.signatureHash = signatureHash;
|
|
157
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/typeIdentifiers/signature.ts"],"names":[],"mappings":";;;AAAA,uDAA0D;AAC1D,gCAYgB;AAChB,kCAAiC;AACjC,+BAiBe;AACf,2CAAuC;AAC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AAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC;AAND,sCAMC"}
|
|
@@ -1,7 +1,48 @@
|
|
|
1
|
-
import { Expression, TypeName, VariableDeclaration } from "../ast";
|
|
1
|
+
import { DataLocation, Expression, TypeName, VariableDeclaration } from "../ast";
|
|
2
2
|
import { TypeIdentifier } from "./ast";
|
|
3
3
|
/**
|
|
4
4
|
* Return the parsed `TypeIdentifier` for the given node.
|
|
5
5
|
*/
|
|
6
6
|
export declare function typeOf(nd: Expression | VariableDeclaration | TypeName): TypeIdentifier;
|
|
7
|
+
/**
|
|
8
|
+
* Given a `TypeIdentifier` `t` return a new `TypeIdentifier` with all pointer locations changed to `loc`.
|
|
9
|
+
* @param t
|
|
10
|
+
* @param loc
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function changeLocationTo(t: TypeIdentifier, loc: DataLocation): TypeIdentifier;
|
|
14
|
+
/**
|
|
15
|
+
* Given a public state variable declaration `v` return the ABI types of the arguments and the returns for this var.
|
|
16
|
+
* This will account for:
|
|
17
|
+
* - indexing into arrays/maps
|
|
18
|
+
* - converting returned structs to tuples
|
|
19
|
+
* - omitting arrays and maps
|
|
20
|
+
*
|
|
21
|
+
* @param t
|
|
22
|
+
* @param loc
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function getterArgsAndReturn(v: VariableDeclaration): [TypeIdentifier[], TypeIdentifier];
|
|
26
|
+
/**
|
|
27
|
+
* Given a `TypeIdentifier` `t` return a new generalized `TypeIdentifier` with all pointers removed (i.e. no specifications for locations)
|
|
28
|
+
* @param t
|
|
29
|
+
* @param loc
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare function generalize(t: TypeIdentifier): TypeIdentifier;
|
|
33
|
+
/**
|
|
34
|
+
* Given an already generalized `TypeIdentifier` `t` and a location return a new
|
|
35
|
+
* specialized `TypeIdentifier` with all reference types wrapped in a pointer to
|
|
36
|
+
* the given location
|
|
37
|
+
* @param t
|
|
38
|
+
* @param loc
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function specialize(t: TypeIdentifier, loc: DataLocation): TypeIdentifier;
|
|
42
|
+
/**
|
|
43
|
+
* Return true IFF the `TypeIdentifier` `t` must live in storage.
|
|
44
|
+
* @param t
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export declare function isTypeInStorage(t: TypeIdentifier): boolean;
|
|
7
48
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/typeIdentifiers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,YAAY,EACZ,UAAU,EAEV,QAAQ,EACR,mBAAmB,EACtB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAQH,cAAc,EACjB,MAAM,OAAO,CAAC;AAMf;;GAEG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,UAAU,GAAG,mBAAmB,GAAG,QAAQ,GAAG,cAAc,CAgBtF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,GAAG,cAAc,CA2BrF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,mBAAmB,GAAG,CAAC,cAAc,EAAE,EAAE,cAAc,CAAC,CAyC9F;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,GAAG,cAAc,CAkB5D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,GAAG,cAAc,CAkB/E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAK1D"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.typeOf = void 0;
|
|
3
|
+
exports.isTypeInStorage = exports.specialize = exports.generalize = exports.getterArgsAndReturn = exports.changeLocationTo = exports.typeOf = void 0;
|
|
4
|
+
const ast_1 = require("../ast");
|
|
4
5
|
const misc_1 = require("../misc");
|
|
6
|
+
const abi_1 = require("./abi");
|
|
7
|
+
const ast_2 = require("./ast");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
5
9
|
const typeIdentifier_parser_gen_1 = require("./typeIdentifier_parser_gen");
|
|
6
10
|
const cache = new Map();
|
|
7
11
|
/**
|
|
@@ -23,4 +27,126 @@ function typeOf(nd) {
|
|
|
23
27
|
return cached;
|
|
24
28
|
}
|
|
25
29
|
exports.typeOf = typeOf;
|
|
30
|
+
/**
|
|
31
|
+
* Given a `TypeIdentifier` `t` return a new `TypeIdentifier` with all pointer locations changed to `loc`.
|
|
32
|
+
* @param t
|
|
33
|
+
* @param loc
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
function changeLocationTo(t, loc) {
|
|
37
|
+
if (t instanceof ast_2.PointerTypeId) {
|
|
38
|
+
return new ast_2.PointerTypeId(changeLocationTo(t.toType, loc), loc, t.isPointer);
|
|
39
|
+
}
|
|
40
|
+
if (t instanceof ast_2.ArrayTypeId) {
|
|
41
|
+
return new ast_2.ArrayTypeId(changeLocationTo(t.elT, loc), t.size);
|
|
42
|
+
}
|
|
43
|
+
if (t instanceof ast_2.ArraySliceTypeId) {
|
|
44
|
+
return new ast_2.ArraySliceTypeId(changeLocationTo(t.toType, loc));
|
|
45
|
+
}
|
|
46
|
+
if (t instanceof ast_2.MappingTypeId) {
|
|
47
|
+
return new ast_2.MappingTypeId(changeLocationTo(t.keyType, loc), changeLocationTo(t.valueType, loc));
|
|
48
|
+
}
|
|
49
|
+
if (t instanceof ast_2.TupleTypeId) {
|
|
50
|
+
return new ast_2.TupleTypeId(t.components.map((c) => (c === null ? c : changeLocationTo(c, loc))));
|
|
51
|
+
}
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
exports.changeLocationTo = changeLocationTo;
|
|
55
|
+
/**
|
|
56
|
+
* Given a public state variable declaration `v` return the ABI types of the arguments and the returns for this var.
|
|
57
|
+
* This will account for:
|
|
58
|
+
* - indexing into arrays/maps
|
|
59
|
+
* - converting returned structs to tuples
|
|
60
|
+
* - omitting arrays and maps
|
|
61
|
+
*
|
|
62
|
+
* @param t
|
|
63
|
+
* @param loc
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
function getterArgsAndReturn(v) {
|
|
67
|
+
const argTypes = [];
|
|
68
|
+
const ctx = v.requiredContext;
|
|
69
|
+
let type = v.vType;
|
|
70
|
+
(0, misc_1.assert)(type !== undefined, "Called getterArgsAndReturn() on variable declaration without type", v);
|
|
71
|
+
while (true) {
|
|
72
|
+
if (type instanceof ast_1.ArrayTypeName) {
|
|
73
|
+
argTypes.push(constants_1.uint256T);
|
|
74
|
+
type = type.vBaseType;
|
|
75
|
+
}
|
|
76
|
+
else if (type instanceof ast_1.Mapping) {
|
|
77
|
+
// Make sure to change default storage pointer location for string/bytes to Memory as to not
|
|
78
|
+
// confuse `toABIType`.
|
|
79
|
+
argTypes.push((0, abi_1.toABIType)(changeLocationTo(typeOf(type.vKeyType), ast_1.DataLocation.Memory), ctx));
|
|
80
|
+
type = type.vValueType;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let retType = (0, abi_1.toABIType)(changeLocationTo(typeOf(type), ast_1.DataLocation.Memory), ctx);
|
|
87
|
+
// Filter out top-level arrays. Maps are already filtered by toABIType
|
|
88
|
+
if (retType instanceof ast_2.TupleTypeId) {
|
|
89
|
+
const filteredComps = retType.components.filter((compT) => !(compT instanceof ast_2.ArrayTypeId));
|
|
90
|
+
// For top-level tuples remove any arrays from the tuple
|
|
91
|
+
retType = filteredComps.length === 1 ? filteredComps[0] : new ast_2.TupleTypeId(filteredComps);
|
|
92
|
+
}
|
|
93
|
+
return [argTypes, retType];
|
|
94
|
+
}
|
|
95
|
+
exports.getterArgsAndReturn = getterArgsAndReturn;
|
|
96
|
+
/**
|
|
97
|
+
* Given a `TypeIdentifier` `t` return a new generalized `TypeIdentifier` with all pointers removed (i.e. no specifications for locations)
|
|
98
|
+
* @param t
|
|
99
|
+
* @param loc
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
function generalize(t) {
|
|
103
|
+
if (t instanceof ast_2.PointerTypeId) {
|
|
104
|
+
return generalize(t.toType);
|
|
105
|
+
}
|
|
106
|
+
if (t instanceof ast_2.ArrayTypeId) {
|
|
107
|
+
return new ast_2.ArrayTypeId(generalize(t.elT), t.size);
|
|
108
|
+
}
|
|
109
|
+
if (t instanceof ast_2.ArraySliceTypeId || t instanceof ast_2.MappingTypeId) {
|
|
110
|
+
throw new Error(`Cannot generalize ${t.pp()}`);
|
|
111
|
+
}
|
|
112
|
+
if (t instanceof ast_2.TupleTypeId) {
|
|
113
|
+
return new ast_2.TupleTypeId(t.components.map((c) => (c === null ? c : generalize(c))));
|
|
114
|
+
}
|
|
115
|
+
return t;
|
|
116
|
+
}
|
|
117
|
+
exports.generalize = generalize;
|
|
118
|
+
/**
|
|
119
|
+
* Given an already generalized `TypeIdentifier` `t` and a location return a new
|
|
120
|
+
* specialized `TypeIdentifier` with all reference types wrapped in a pointer to
|
|
121
|
+
* the given location
|
|
122
|
+
* @param t
|
|
123
|
+
* @param loc
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
function specialize(t, loc) {
|
|
127
|
+
if (t instanceof ast_2.ArraySliceTypeId || t instanceof ast_2.PointerTypeId || t instanceof ast_2.MappingTypeId) {
|
|
128
|
+
throw new Error(`Cannot specialize ${t.pp()}`);
|
|
129
|
+
}
|
|
130
|
+
if (t instanceof ast_2.ArrayTypeId) {
|
|
131
|
+
return new ast_2.PointerTypeId(new ast_2.ArrayTypeId(specialize(t.elT, loc), t.size), loc, true);
|
|
132
|
+
}
|
|
133
|
+
if (t instanceof ast_2.BytesTypeId || t instanceof ast_2.StringTypeId) {
|
|
134
|
+
return new ast_2.PointerTypeId(t, loc, true);
|
|
135
|
+
}
|
|
136
|
+
if (t instanceof ast_2.TupleTypeId) {
|
|
137
|
+
return new ast_2.TupleTypeId(t.components.map((c) => (c === null ? c : specialize(c, loc))));
|
|
138
|
+
}
|
|
139
|
+
return t;
|
|
140
|
+
}
|
|
141
|
+
exports.specialize = specialize;
|
|
142
|
+
/**
|
|
143
|
+
* Return true IFF the `TypeIdentifier` `t` must live in storage.
|
|
144
|
+
* @param t
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
function isTypeInStorage(t) {
|
|
148
|
+
return (t instanceof ast_2.MappingTypeId ||
|
|
149
|
+
(t instanceof ast_2.PointerTypeId && t.location === ast_1.DataLocation.Storage));
|
|
150
|
+
}
|
|
151
|
+
exports.isTypeInStorage = isTypeInStorage;
|
|
26
152
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/typeIdentifiers/utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/typeIdentifiers/utils.ts"],"names":[],"mappings":";;;AAAA,gCAOgB;AAChB,kCAAiC;AACjC,+BAAkC;AAClC,+BASe;AACf,2CAAuC;AACvC,2EAAkE;AAElE,MAAM,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEhD;;GAEG;AACH,SAAgB,MAAM,CAAC,EAA+C;IAClE,IAAA,aAAM,EAAC,EAAE,CAAC,cAAc,KAAK,SAAS,EAAE,+BAA+B,EAAE,EAAE,CAAC,CAAC;IAC7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Script library providing a normalized typed Solidity AST along with the utilities necessary to generate the AST (from Solc) and traverse/manipulate it.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"semver": "^7.6.0",
|
|
39
39
|
"solc": "0.8.25",
|
|
40
40
|
"src-location": "^1.1.0",
|
|
41
|
-
"web3-eth-abi": "^4.2.0"
|
|
41
|
+
"web3-eth-abi": "^4.2.0",
|
|
42
|
+
"ethereum-cryptography": "3.2.0",
|
|
43
|
+
"@ethereumjs/util": "10.1.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@types/fs-extra": "^11.0.4",
|