soliddgen 0.6.0-beta.36
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/common/helpers.d.ts +9 -0
- package/dist/common/helpers.d.ts.map +1 -0
- package/dist/common/helpers.js +25 -0
- package/dist/common/helpers.js.map +1 -0
- package/dist/common/properties.d.ts +25 -0
- package/dist/common/properties.d.ts.map +1 -0
- package/dist/common/properties.js +129 -0
- package/dist/common/properties.js.map +1 -0
- package/dist/config.d.ts +59 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -0
- package/dist/doc-item.d.ts +6 -0
- package/dist/doc-item.d.ts.map +1 -0
- package/dist/doc-item.js +21 -0
- package/dist/doc-item.js.map +1 -0
- package/dist/hardhat/index.d.ts +2 -0
- package/dist/hardhat/index.d.ts.map +1 -0
- package/dist/hardhat/index.js +50 -0
- package/dist/hardhat/index.js.map +1 -0
- package/dist/hardhat/type-extensions.d.ts +12 -0
- package/dist/hardhat/type-extensions.d.ts.map +1 -0
- package/dist/hardhat/type-extensions.js +5 -0
- package/dist/hardhat/type-extensions.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +9 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +30 -0
- package/dist/main.js.map +1 -0
- package/dist/render.d.ts +9 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +66 -0
- package/dist/render.js.map +1 -0
- package/dist/render.test.d.ts +2 -0
- package/dist/render.test.d.ts.map +1 -0
- package/dist/render.test.js +42 -0
- package/dist/render.test.js.map +1 -0
- package/dist/site.d.ts +42 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +86 -0
- package/dist/site.js.map +1 -0
- package/dist/site.test.d.ts +2 -0
- package/dist/site.test.d.ts.map +1 -0
- package/dist/site.test.js +52 -0
- package/dist/site.test.js.map +1 -0
- package/dist/templates.d.ts +23 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +124 -0
- package/dist/templates.js.map +1 -0
- package/dist/themes/markdown/helpers.d.ts +21 -0
- package/dist/themes/markdown/helpers.d.ts.map +1 -0
- package/dist/themes/markdown/helpers.js +49 -0
- package/dist/themes/markdown/helpers.js.map +1 -0
- package/dist/utils/ItemError.d.ts +5 -0
- package/dist/utils/ItemError.d.ts.map +1 -0
- package/dist/utils/ItemError.js +18 -0
- package/dist/utils/ItemError.js.map +1 -0
- package/dist/utils/arrays-equal.d.ts +3 -0
- package/dist/utils/arrays-equal.d.ts.map +1 -0
- package/dist/utils/arrays-equal.js +8 -0
- package/dist/utils/arrays-equal.js.map +1 -0
- package/dist/utils/assert-equal-types.d.ts +2 -0
- package/dist/utils/assert-equal-types.d.ts.map +1 -0
- package/dist/utils/assert-equal-types.js +3 -0
- package/dist/utils/assert-equal-types.js.map +1 -0
- package/dist/utils/clone.d.ts +7 -0
- package/dist/utils/clone.d.ts.map +1 -0
- package/dist/utils/clone.js +11 -0
- package/dist/utils/clone.js.map +1 -0
- package/dist/utils/ensure-array.d.ts +4 -0
- package/dist/utils/ensure-array.d.ts.map +1 -0
- package/dist/utils/ensure-array.js +13 -0
- package/dist/utils/ensure-array.js.map +1 -0
- package/dist/utils/execall.d.ts +7 -0
- package/dist/utils/execall.d.ts.map +1 -0
- package/dist/utils/execall.js +21 -0
- package/dist/utils/execall.js.map +1 -0
- package/dist/utils/fs-exists.d.ts +4 -0
- package/dist/utils/fs-exists.d.ts.map +1 -0
- package/dist/utils/fs-exists.js +31 -0
- package/dist/utils/fs-exists.js.map +1 -0
- package/dist/utils/is-child.d.ts +2 -0
- package/dist/utils/is-child.d.ts.map +1 -0
- package/dist/utils/is-child.js +12 -0
- package/dist/utils/is-child.js.map +1 -0
- package/dist/utils/item-type.d.ts +3 -0
- package/dist/utils/item-type.d.ts.map +1 -0
- package/dist/utils/item-type.js +10 -0
- package/dist/utils/item-type.js.map +1 -0
- package/dist/utils/map-keys.d.ts +2 -0
- package/dist/utils/map-keys.d.ts.map +1 -0
- package/dist/utils/map-keys.js +8 -0
- package/dist/utils/map-keys.js.map +1 -0
- package/dist/utils/map-values.d.ts +4 -0
- package/dist/utils/map-values.d.ts.map +1 -0
- package/dist/utils/map-values.js +22 -0
- package/dist/utils/map-values.js.map +1 -0
- package/dist/utils/memoized-getter.d.ts +4 -0
- package/dist/utils/memoized-getter.d.ts.map +1 -0
- package/dist/utils/memoized-getter.js +25 -0
- package/dist/utils/memoized-getter.js.map +1 -0
- package/dist/utils/natspec.d.ts +19 -0
- package/dist/utils/natspec.d.ts.map +1 -0
- package/dist/utils/natspec.js +117 -0
- package/dist/utils/natspec.js.map +1 -0
- package/dist/utils/read-item-docs.d.ts +3 -0
- package/dist/utils/read-item-docs.d.ts.map +1 -0
- package/dist/utils/read-item-docs.js +29 -0
- package/dist/utils/read-item-docs.js.map +1 -0
- package/dist/utils/scope.d.ts +6 -0
- package/dist/utils/scope.d.ts.map +1 -0
- package/dist/utils/scope.js +53 -0
- package/dist/utils/scope.js.map +1 -0
- package/dist/utils/test.d.ts +8 -0
- package/dist/utils/test.d.ts.map +1 -0
- package/dist/utils/test.js +14 -0
- package/dist/utils/test.js.map +1 -0
- package/lc3cxy2s.cjs +1 -0
- package/package.json +41 -0
- package/src/common/helpers.ts +22 -0
- package/src/common/properties.ts +138 -0
- package/src/config.ts +84 -0
- package/src/doc-item.ts +27 -0
- package/src/hardhat/index.ts +35 -0
- package/src/hardhat/type-extensions.ts +14 -0
- package/src/index.ts +13 -0
- package/src/main.ts +26 -0
- package/src/render.test.ts +64 -0
- package/src/render.ts +87 -0
- package/src/site.test.ts +68 -0
- package/src/site.ts +144 -0
- package/src/templates.ts +116 -0
- package/src/themes/markdown/common.hbs +34 -0
- package/src/themes/markdown/contract.hbs +8 -0
- package/src/themes/markdown/enum.hbs +9 -0
- package/src/themes/markdown/error.hbs +1 -0
- package/src/themes/markdown/event.hbs +1 -0
- package/src/themes/markdown/function.hbs +1 -0
- package/src/themes/markdown/helpers.ts +49 -0
- package/src/themes/markdown/modifier.hbs +1 -0
- package/src/themes/markdown/page.hbs +8 -0
- package/src/themes/markdown/struct.hbs +9 -0
- package/src/themes/markdown/user-defined-value-type.hbs +1 -0
- package/src/themes/markdown/variable.hbs +1 -0
- package/src/utils/ItemError.ts +13 -0
- package/src/utils/arrays-equal.ts +5 -0
- package/src/utils/assert-equal-types.ts +1 -0
- package/src/utils/clone.ts +6 -0
- package/src/utils/ensure-array.ts +12 -0
- package/src/utils/execall.ts +18 -0
- package/src/utils/fs-exists.ts +23 -0
- package/src/utils/is-child.ts +5 -0
- package/src/utils/item-type.ts +7 -0
- package/src/utils/map-keys.ts +4 -0
- package/src/utils/map-values.ts +19 -0
- package/src/utils/memoized-getter.ts +23 -0
- package/src/utils/natspec.ts +145 -0
- package/src/utils/read-item-docs.ts +26 -0
- package/src/utils/scope.ts +63 -0
- package/src/utils/test.ts +18 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assert-equal-types.d.ts","sourceRoot":"","sources":["../../src/utils/assert-equal-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assert-equal-types.js","sourceRoot":"","sources":["../../src/utils/assert-equal-types.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Deep cloning good enough for simple objects like solc output. Types are not
|
3
|
+
* sound because the function may lose information: non-enumerable properties,
|
4
|
+
* symbols, undefined values, prototypes, etc.
|
5
|
+
*/
|
6
|
+
export declare const clone: <T>(obj: T) => T;
|
7
|
+
//# sourceMappingURL=clone.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/utils/clone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,KAAK,kBAAoD,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.clone = void 0;
|
4
|
+
/**
|
5
|
+
* Deep cloning good enough for simple objects like solc output. Types are not
|
6
|
+
* sound because the function may lose information: non-enumerable properties,
|
7
|
+
* symbols, undefined values, prototypes, etc.
|
8
|
+
*/
|
9
|
+
const clone = (obj) => JSON.parse(JSON.stringify(obj));
|
10
|
+
exports.clone = clone;
|
11
|
+
//# sourceMappingURL=clone.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../src/utils/clone.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,KAAK,GAAG,CAAI,GAAM,EAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAA1D,QAAA,KAAK,SAAqD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ensure-array.d.ts","sourceRoot":"","sources":["../../src/utils/ensure-array.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAE9C,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAM3D"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ensureArray = void 0;
|
4
|
+
function ensureArray(x) {
|
5
|
+
if (Array.isArray(x)) {
|
6
|
+
return x;
|
7
|
+
}
|
8
|
+
else {
|
9
|
+
return [x];
|
10
|
+
}
|
11
|
+
}
|
12
|
+
exports.ensureArray = ensureArray;
|
13
|
+
//# sourceMappingURL=ensure-array.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ensure-array.js","sourceRoot":"","sources":["../../src/utils/ensure-array.ts"],"names":[],"mappings":";;;AAKA,SAAgB,WAAW,CAAI,CAAU;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACpB,OAAO,CAAC,CAAC;KACV;SAAM;QACL,OAAO,CAAC,CAAC,CAAC,CAAC;KACZ;AACH,CAAC;AAND,kCAMC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Iterates over all contiguous matches of the regular expression over the
|
3
|
+
* text. Stops as soon as the regular expression no longer matches at the
|
4
|
+
* current position.
|
5
|
+
*/
|
6
|
+
export declare function execAll(re: RegExp, text: string): Generator<RegExpExecArray, void, unknown>;
|
7
|
+
//# sourceMappingURL=execall.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"execall.d.ts","sourceRoot":"","sources":["../../src/utils/execall.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAiB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6CAYhD"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.execAll = void 0;
|
4
|
+
/**
|
5
|
+
* Iterates over all contiguous matches of the regular expression over the
|
6
|
+
* text. Stops as soon as the regular expression no longer matches at the
|
7
|
+
* current position.
|
8
|
+
*/
|
9
|
+
function* execAll(re, text) {
|
10
|
+
re = new RegExp(re, re.flags + (re.sticky ? '' : 'y'));
|
11
|
+
while (true) {
|
12
|
+
const match = re.exec(text);
|
13
|
+
// We break out of the loop if there is no match or if the empty string is
|
14
|
+
// matched because no progress will be made and it will loop indefinitely.
|
15
|
+
if (!match?.[0])
|
16
|
+
break;
|
17
|
+
yield match;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
exports.execAll = execAll;
|
21
|
+
//# sourceMappingURL=execall.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"execall.js","sourceRoot":"","sources":["../../src/utils/execall.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,QAAe,CAAC,CAAC,OAAO,CAAC,EAAU,EAAE,IAAY;IAC/C,EAAE,GAAG,IAAI,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,OAAO,IAAI,EAAE;QACX,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5B,0EAA0E;QAC1E,0EAA0E;QAC1E,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAAE,MAAM;QAEvB,MAAM,KAAK,CAAC;KACb;AACH,CAAC;AAZD,0BAYC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export declare function exists(path: string, mode?: number): Promise<boolean>;
|
2
|
+
export declare function findExists(...paths: string[]): Promise<string | undefined>;
|
3
|
+
export declare function findIn(f: string, dirs: string[]): Promise<string | undefined>;
|
4
|
+
//# sourceMappingURL=fs-exists.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fs-exists.d.ts","sourceRoot":"","sources":["../../src/utils/fs-exists.ts"],"names":[],"mappings":"AAGA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAO1F;AAED,wBAAsB,UAAU,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAMhF;AAED,wBAAsB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEnF"}
|
@@ -0,0 +1,31 @@
|
|
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.findIn = exports.findExists = exports.exists = void 0;
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const path_1 = __importDefault(require("path"));
|
9
|
+
async function exists(path, mode = fs_1.constants.R_OK) {
|
10
|
+
try {
|
11
|
+
await fs_1.promises.access(path, mode);
|
12
|
+
return true;
|
13
|
+
}
|
14
|
+
catch {
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
exports.exists = exists;
|
19
|
+
async function findExists(...paths) {
|
20
|
+
for (const p of paths) {
|
21
|
+
if (await exists(p)) {
|
22
|
+
return p;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
exports.findExists = findExists;
|
27
|
+
async function findIn(f, dirs) {
|
28
|
+
return findExists(...dirs.map(d => path_1.default.resolve(d, f)));
|
29
|
+
}
|
30
|
+
exports.findIn = findIn;
|
31
|
+
//# sourceMappingURL=fs-exists.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fs-exists.js","sourceRoot":"","sources":["../../src/utils/fs-exists.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA+C;AAC/C,gDAAwB;AAEjB,KAAK,UAAU,MAAM,CAAC,IAAY,EAAE,OAAe,cAAS,CAAC,IAAI;IACtE,IAAI;QACF,MAAM,aAAE,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAPD,wBAOC;AAEM,KAAK,UAAU,UAAU,CAAC,GAAG,KAAe;IACjD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;QACrB,IAAI,MAAM,MAAM,CAAC,CAAC,CAAC,EAAE;YACnB,OAAO,CAAC,CAAC;SACV;KACF;AACH,CAAC;AAND,gCAMC;AAEM,KAAK,UAAU,MAAM,CAAC,CAAS,EAAE,IAAc;IACpD,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAFD,wBAEC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"is-child.d.ts","sourceRoot":"","sources":["../../src/utils/is-child.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAEnD"}
|
@@ -0,0 +1,12 @@
|
|
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.isChild = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
function isChild(file, parent) {
|
9
|
+
return path_1.default.normalize(file + path_1.default.sep).startsWith(path_1.default.normalize(parent + path_1.default.sep));
|
10
|
+
}
|
11
|
+
exports.isChild = isChild;
|
12
|
+
//# sourceMappingURL=is-child.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"is-child.js","sourceRoot":"","sources":["../../src/utils/is-child.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,SAAgB,OAAO,CAAC,IAAY,EAAE,MAAc;IAClD,OAAO,cAAI,CAAC,SAAS,CAAC,IAAI,GAAG,cAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,cAAI,CAAC,SAAS,CAAC,MAAM,GAAG,cAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACvF,CAAC;AAFD,0BAEC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"item-type.d.ts","sourceRoot":"","sources":["../../src/utils/item-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAI9C"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.itemType = void 0;
|
4
|
+
function itemType(item) {
|
5
|
+
return item.nodeType
|
6
|
+
.replace(/(Definition|Declaration)$/, '')
|
7
|
+
.replace(/(\w)([A-Z])/g, '$1 $2');
|
8
|
+
}
|
9
|
+
exports.itemType = itemType;
|
10
|
+
//# sourceMappingURL=item-type.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"item-type.js","sourceRoot":"","sources":["../../src/utils/item-type.ts"],"names":[],"mappings":";;;AAEA,SAAgB,QAAQ,CAAC,IAAa;IACpC,OAAO,IAAI,CAAC,QAAQ;SACjB,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC;SACxC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAJD,4BAIC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"map-keys.d.ts","sourceRoot":"","sources":["../../src/utils/map-keys.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAEjG"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mapKeys = void 0;
|
4
|
+
function mapKeys(obj, fn) {
|
5
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [fn(k), v]));
|
6
|
+
}
|
7
|
+
exports.mapKeys = mapKeys;
|
8
|
+
//# sourceMappingURL=map-keys.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"map-keys.js","sourceRoot":"","sources":["../../src/utils/map-keys.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAI,GAAsB,EAAE,EAA2B;IAC5E,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC;AAFD,0BAEC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export declare function mapValues<T, U>(obj: Record<string, T>, fn: (value: T) => U): Record<string, U>;
|
2
|
+
export declare function filterValues<T, U extends T>(obj: Record<string, T>, fn: (value: T) => value is U): Record<string, U>;
|
3
|
+
export declare function filterValues<T>(obj: Record<string, T>, fn: (value: T) => boolean): Record<string, T>;
|
4
|
+
//# sourceMappingURL=map-values.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"map-values.d.ts","sourceRoot":"","sources":["../../src/utils/map-values.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM9F;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACtH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.filterValues = exports.mapValues = void 0;
|
4
|
+
function mapValues(obj, fn) {
|
5
|
+
const res = {};
|
6
|
+
for (const [k, v] of Object.entries(obj)) {
|
7
|
+
res[k] = fn(v);
|
8
|
+
}
|
9
|
+
return res;
|
10
|
+
}
|
11
|
+
exports.mapValues = mapValues;
|
12
|
+
function filterValues(obj, fn) {
|
13
|
+
const res = {};
|
14
|
+
for (const [k, v] of Object.entries(obj)) {
|
15
|
+
if (fn(v)) {
|
16
|
+
res[k] = v;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return res;
|
20
|
+
}
|
21
|
+
exports.filterValues = filterValues;
|
22
|
+
//# sourceMappingURL=map-values.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"map-values.js","sourceRoot":"","sources":["../../src/utils/map-values.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAO,GAAsB,EAAE,EAAmB;IACzE,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACxC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAND,8BAMC;AAID,SAAgB,YAAY,CAAI,GAAsB,EAAE,EAAyB;IAC/E,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACxC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;YACT,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACZ;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AARD,oCAQC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"memoized-getter.d.ts","sourceRoot":"","sources":["../../src/utils/memoized-getter.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,SAAS;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;CAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAsBvH"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.defineGetterMemoized = void 0;
|
4
|
+
function defineGetterMemoized(obj, key, getter) {
|
5
|
+
let state = 'todo';
|
6
|
+
let value;
|
7
|
+
Object.defineProperty(obj, key, {
|
8
|
+
enumerable: true,
|
9
|
+
get() {
|
10
|
+
switch (state) {
|
11
|
+
case 'done':
|
12
|
+
return value;
|
13
|
+
case 'doing':
|
14
|
+
throw new Error("Detected recursion");
|
15
|
+
case 'todo':
|
16
|
+
state = 'doing';
|
17
|
+
value = getter();
|
18
|
+
state = 'done';
|
19
|
+
return value;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
});
|
23
|
+
}
|
24
|
+
exports.defineGetterMemoized = defineGetterMemoized;
|
25
|
+
//# sourceMappingURL=memoized-getter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"memoized-getter.js","sourceRoot":"","sources":["../../src/utils/memoized-getter.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAAqD,GAAM,EAAE,GAAM,EAAE,MAAe;IACtH,IAAI,KAAK,GAA8B,MAAM,CAAC;IAC9C,IAAI,KAAQ,CAAC;IAEb,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE;QAC9B,UAAU,EAAE,IAAI;QAChB,GAAG;YACD,QAAQ,KAAK,EAAE;gBACb,KAAK,MAAM;oBACT,OAAO,KAAK,CAAC;gBAEf,KAAK,OAAO;oBACV,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBAExC,KAAK,MAAM;oBACT,KAAK,GAAG,OAAO,CAAC;oBAChB,KAAK,GAAG,MAAM,EAAE,CAAC;oBACjB,KAAK,GAAG,MAAM,CAAC;oBACf,OAAO,KAAK,CAAC;aAChB;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAtBD,oDAsBC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { DocItemWithContext } from '../site';
|
2
|
+
export interface NatSpec {
|
3
|
+
title?: string;
|
4
|
+
notice?: string;
|
5
|
+
dev?: string;
|
6
|
+
params?: {
|
7
|
+
name: string;
|
8
|
+
description: string;
|
9
|
+
}[];
|
10
|
+
returns?: {
|
11
|
+
name?: string;
|
12
|
+
description: string;
|
13
|
+
}[];
|
14
|
+
custom?: {
|
15
|
+
[tag: string]: string;
|
16
|
+
};
|
17
|
+
}
|
18
|
+
export declare function parseNatspec(item: DocItemWithContext): NatSpec;
|
19
|
+
//# sourceMappingURL=natspec.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"natspec.d.ts","sourceRoot":"","sources":["../../src/utils/natspec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,SAAS,CAAC;AAQ/D,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;IACJ,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAsG9D"}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.parseNatspec = void 0;
|
4
|
+
const utils_1 = require("solidity-ast/utils");
|
5
|
+
const site_1 = require("../site");
|
6
|
+
const arrays_equal_1 = require("./arrays-equal");
|
7
|
+
const execall_1 = require("./execall");
|
8
|
+
const item_type_1 = require("./item-type");
|
9
|
+
const ItemError_1 = require("./ItemError");
|
10
|
+
const read_item_docs_1 = require("./read-item-docs");
|
11
|
+
const scope_1 = require("./scope");
|
12
|
+
function parseNatspec(item) {
|
13
|
+
var _a;
|
14
|
+
if (!item[site_1.DOC_ITEM_CONTEXT])
|
15
|
+
throw new Error(`Not an item or item is missing context`);
|
16
|
+
let res = {};
|
17
|
+
const docSource = (0, read_item_docs_1.readItemDocs)(item);
|
18
|
+
const docString = docSource !== undefined
|
19
|
+
? cleanUpDocstringFromSource(docSource)
|
20
|
+
: 'documentation' in item && item.documentation
|
21
|
+
? typeof item.documentation === 'string'
|
22
|
+
? item.documentation
|
23
|
+
: cleanUpDocstringFromSolc(item.documentation.text)
|
24
|
+
: '';
|
25
|
+
const tagMatches = (0, execall_1.execAll)(/^(?:@(\w+|custom:[a-z][a-z-]*) )?((?:(?!^@(?:\w+|custom:[a-z][a-z-]*) )[^])*)/m, docString);
|
26
|
+
let inheritFrom;
|
27
|
+
for (const [, tag = 'notice', content] of tagMatches) {
|
28
|
+
if (content === undefined)
|
29
|
+
throw new ItemError_1.ItemError('Unexpected error', item);
|
30
|
+
if (tag === 'dev' || tag === 'notice') {
|
31
|
+
res[tag] ?? (res[tag] = '');
|
32
|
+
res[tag] += content;
|
33
|
+
}
|
34
|
+
if (tag === 'title') {
|
35
|
+
res.title = content.trim();
|
36
|
+
}
|
37
|
+
if (tag === 'param') {
|
38
|
+
const paramMatches = content.match(/(\w+) ([^]*)/);
|
39
|
+
if (paramMatches) {
|
40
|
+
const [, name, description] = paramMatches;
|
41
|
+
res.params ?? (res.params = []);
|
42
|
+
res.params.push({ name, description: description.trim() });
|
43
|
+
}
|
44
|
+
}
|
45
|
+
if (tag === 'return') {
|
46
|
+
if (!('returnParameters' in item)) {
|
47
|
+
throw new ItemError_1.ItemError(`Item does not contain return parameters`, item);
|
48
|
+
}
|
49
|
+
res.returns ?? (res.returns = []);
|
50
|
+
const i = res.returns.length;
|
51
|
+
const p = item.returnParameters.parameters[i];
|
52
|
+
if (p === undefined) {
|
53
|
+
throw new ItemError_1.ItemError('Got more @return tags than expected', item);
|
54
|
+
}
|
55
|
+
if (!p.name) {
|
56
|
+
res.returns.push({ description: content.trim() });
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
const paramMatches = content.match(/(\w+)( ([^]*))?/);
|
60
|
+
if (!paramMatches || paramMatches[1] !== p.name) {
|
61
|
+
throw new ItemError_1.ItemError(`Expected @return tag to start with name '${p.name}'`, item);
|
62
|
+
}
|
63
|
+
const [, name, description] = paramMatches;
|
64
|
+
res.returns.push({ name, description: description?.trim() ?? '' });
|
65
|
+
}
|
66
|
+
}
|
67
|
+
if (tag?.startsWith('custom:')) {
|
68
|
+
const key = tag.replace(/^custom:/, '');
|
69
|
+
res.custom ?? (res.custom = {});
|
70
|
+
(_a = res.custom)[key] ?? (_a[key] = '');
|
71
|
+
res.custom[key] += content;
|
72
|
+
}
|
73
|
+
if (tag === 'inheritdoc') {
|
74
|
+
if (!(item.nodeType === 'FunctionDefinition' || item.nodeType === 'VariableDeclaration')) {
|
75
|
+
throw new ItemError_1.ItemError(`Expected function or variable but saw ${(0, item_type_1.itemType)(item)}`, item);
|
76
|
+
}
|
77
|
+
const parentContractName = content.trim();
|
78
|
+
const parentContract = (0, scope_1.getContractsInScope)(item)[parentContractName];
|
79
|
+
if (!parentContract) {
|
80
|
+
throw new ItemError_1.ItemError(`Parent contract '${parentContractName}' not found`, item);
|
81
|
+
}
|
82
|
+
inheritFrom = [...(0, utils_1.findAll)('FunctionDefinition', parentContract)].find(f => item.baseFunctions?.includes(f.id));
|
83
|
+
}
|
84
|
+
}
|
85
|
+
if (docString.length === 0) {
|
86
|
+
if ('baseFunctions' in item && item.baseFunctions?.length === 1) {
|
87
|
+
const baseFn = item[site_1.DOC_ITEM_CONTEXT].build.deref('FunctionDefinition', item.baseFunctions[0]);
|
88
|
+
const shouldInherit = item.nodeType === 'VariableDeclaration' || (0, arrays_equal_1.arraysEqual)(item.parameters.parameters, baseFn.parameters.parameters, p => p.name);
|
89
|
+
if (shouldInherit) {
|
90
|
+
inheritFrom = baseFn;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
if (res.dev)
|
95
|
+
res.dev = res.dev.trim();
|
96
|
+
if (res.notice)
|
97
|
+
res.notice = res.notice.trim();
|
98
|
+
if (inheritFrom) {
|
99
|
+
res = { ...parseNatspec(inheritFrom), ...res };
|
100
|
+
}
|
101
|
+
return res;
|
102
|
+
}
|
103
|
+
exports.parseNatspec = parseNatspec;
|
104
|
+
// Fix solc buggy parsing of doc comments.
|
105
|
+
// Reverse engineered from solc behavior.
|
106
|
+
function cleanUpDocstringFromSolc(text) {
|
107
|
+
return text
|
108
|
+
.replace(/\n\n?^[ \t]*(?:\*|\/\/\/)/mg, '\n\n')
|
109
|
+
.replace(/^[ \t]?/mg, '');
|
110
|
+
}
|
111
|
+
function cleanUpDocstringFromSource(text) {
|
112
|
+
return text
|
113
|
+
.replace(/^\/\*\*(.*)\*\/$/s, '$1')
|
114
|
+
.trim()
|
115
|
+
.replace(/^[ \t]*(\*|\/\/\/)[ \t]?/mg, '');
|
116
|
+
}
|
117
|
+
//# sourceMappingURL=natspec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"natspec.js","sourceRoot":"","sources":["../../src/utils/natspec.ts"],"names":[],"mappings":";;;AACA,8CAA6C;AAC7C,kCAA+D;AAC/D,iDAA6C;AAC7C,uCAAoC;AACpC,2CAAuC;AACvC,2CAAwC;AACxC,qDAAgD;AAChD,mCAA8C;AAmB9C,SAAgB,YAAY,CAAC,IAAwB;;IACnD,IAAI,CAAC,IAAI,CAAC,uBAAgB,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAEvF,IAAI,GAAG,GAAY,EAAE,CAAC;IAEtB,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,IAAI,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,SAAS,KAAK,SAAS;QACvC,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC;QACvC,CAAC,CAAC,eAAe,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa;YAC/C,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ;gBACxC,CAAC,CAAC,IAAI,CAAC,aAAa;gBACpB,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACnD,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,UAAU,GAAG,IAAA,iBAAO,EACxB,gFAAgF,EAChF,SAAS,CACV,CAAC;IAEF,IAAI,WAA2C,CAAC;IAEhD,KAAK,MAAM,CAAC,EAAE,GAAG,GAAG,QAAQ,EAAE,OAAO,CAAC,IAAI,UAAU,EAAE;QACpD,IAAI,OAA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AAG,EAAE,GAAG,YAAY,CAAC,WAAiC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;KACtE;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAtGD,oCAsGC;AAED,0CAA0C;AAC1C,yCAAyC;AACzC,SAAS,wBAAwB,CAAC,IAAY;IAC5C,OAAO,IAAI;SACR,OAAO,CAAC,6BAA6B,EAAE,MAAM,CAAC;SAC9C,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,0BAA0B,CAAC,IAAY;IAC9C,OAAO,IAAI;SACR,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC;SAClC,IAAI,EAAE;SACN,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"read-item-docs.d.ts","sourceRoot":"","sources":["../../src/utils/read-item-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,SAAS,CAAC;AAEtE,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAWzE"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.readItemDocs = void 0;
|
4
|
+
const site_1 = require("../site");
|
5
|
+
function readItemDocs(item) {
|
6
|
+
const { build } = item[site_1.DOC_ITEM_CONTEXT];
|
7
|
+
// Note that Solidity 0.5 has item.documentation: string even though the
|
8
|
+
// types do not reflect that. This is why we check typeof === object.
|
9
|
+
if ('documentation' in item && item.documentation && typeof item.documentation === 'object') {
|
10
|
+
const { source, start, length } = decodeSrc(item.documentation.src, build);
|
11
|
+
const content = build.input.sources[source]?.content;
|
12
|
+
if (content !== undefined) {
|
13
|
+
return Buffer.from(content, 'utf8').slice(start, start + length).toString('utf8');
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
exports.readItemDocs = readItemDocs;
|
18
|
+
function decodeSrc(src, build) {
|
19
|
+
const [start, length, sourceId] = src.split(':').map(s => parseInt(s));
|
20
|
+
if (start === undefined || length === undefined || sourceId === undefined) {
|
21
|
+
throw new Error(`Bad source string ${src}`);
|
22
|
+
}
|
23
|
+
const source = Object.keys(build.output.sources).find(s => build.output.sources[s]?.id === sourceId);
|
24
|
+
if (source === undefined) {
|
25
|
+
throw new Error(`No source with id ${sourceId}`);
|
26
|
+
}
|
27
|
+
return { source, start, length };
|
28
|
+
}
|
29
|
+
//# sourceMappingURL=read-item-docs.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"read-item-docs.js","sourceRoot":"","sources":["../../src/utils/read-item-docs.ts"],"names":[],"mappings":";;;AAAA,kCAAsE;AAEtE,SAAgB,YAAY,CAAC,IAAwB;IACnD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,uBAAgB,CAAC,CAAC;IACzC,wEAAwE;IACxE,qEAAqE;IACrE,IAAI,eAAe,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE;QAC3F,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QACrD,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACnF;KACF;AACH,CAAC;AAXD,oCAWC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,KAAY;IAC1C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE;QACzE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;KAC7C;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,QAAQ,CAAC,CAAC;IACrG,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;KAClD;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/utils/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAO7C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB;;GAwC3D"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getContractsInScope = void 0;
|
4
|
+
const utils_1 = require("solidity-ast/utils");
|
5
|
+
const map_values_1 = require("./map-values");
|
6
|
+
const map_keys_1 = require("./map-keys");
|
7
|
+
function getContractsInScope(item) {
|
8
|
+
const cache = new WeakMap();
|
9
|
+
return (0, map_values_1.filterValues)(flattenScope(run(item.__item_context.file)), (0, utils_1.isNodeType)('ContractDefinition'));
|
10
|
+
function run(file) {
|
11
|
+
if (cache.has(file)) {
|
12
|
+
return cache.get(file);
|
13
|
+
}
|
14
|
+
const scope = {};
|
15
|
+
cache.set(file, scope);
|
16
|
+
for (const c of file.nodes) {
|
17
|
+
if ('name' in c) {
|
18
|
+
scope[c.name] = () => ({ definition: c });
|
19
|
+
}
|
20
|
+
}
|
21
|
+
for (const i of (0, utils_1.findAll)('ImportDirective', file)) {
|
22
|
+
const importedFile = item.__item_context.build.deref('SourceUnit', i.sourceUnit);
|
23
|
+
const importedScope = run(importedFile);
|
24
|
+
if (i.unitAlias) {
|
25
|
+
scope[i.unitAlias] = () => ({ namespace: importedScope });
|
26
|
+
}
|
27
|
+
else if (i.symbolAliases.length === 0) {
|
28
|
+
Object.assign(scope, importedScope);
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
for (const a of i.symbolAliases) {
|
32
|
+
// Delayed function call supports circular dependencies
|
33
|
+
scope[a.local ?? a.foreign.name] = importedScope[a.foreign.name] ?? (() => importedScope[a.foreign.name]());
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
;
|
38
|
+
return scope;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
exports.getContractsInScope = getContractsInScope;
|
42
|
+
function flattenScope(scope) {
|
43
|
+
return Object.fromEntries(Object.entries(scope).flatMap(([k, fn]) => {
|
44
|
+
const v = fn();
|
45
|
+
if ('definition' in v) {
|
46
|
+
return [[k, v.definition]];
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
return Object.entries((0, map_keys_1.mapKeys)(flattenScope(v.namespace), k2 => k + '.' + k2));
|
50
|
+
}
|
51
|
+
}));
|
52
|
+
}
|
53
|
+
//# sourceMappingURL=scope.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/utils/scope.ts"],"names":[],"mappings":";;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,CAAC;CACpB;AAED,QAAA,MAAM,IAAI,iBAA2B,CAAC;AAQtC,eAAe,IAAI,CAAC"}
|
@@ -0,0 +1,14 @@
|
|
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
|
+
const ava_1 = __importDefault(require("ava"));
|
7
|
+
const hardhat_1 = __importDefault(require("hardhat"));
|
8
|
+
const fs_1 = require("fs");
|
9
|
+
const test = ava_1.default;
|
10
|
+
test.before('reading build info', async (t) => {
|
11
|
+
t.context.build = await Promise.all((await hardhat_1.default.artifacts.getBuildInfoPaths()).map(async (p) => JSON.parse(await fs_1.promises.readFile(p, 'utf8'))));
|
12
|
+
});
|
13
|
+
exports.default = test;
|
14
|
+
//# sourceMappingURL=test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/utils/test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAoC;AACpC,sDAA0B;AAE1B,2BAAoC;AAMpC,MAAM,IAAI,GAAG,aAAwB,CAAC;AAEtC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC1C,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,CAAC,MAAM,iBAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,aAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CACnG,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAe,IAAI,CAAC"}
|