@openzeppelin/upgrade-safe-transpiler
Version:
Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.
37 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractContractStateless = exports.extractContractStorageSize = exports.extractNatspec = void 0;
const execall_1 = require("./execall");
function* extractNatspec(node) {
const doc = typeof node.documentation === 'string' ? node.documentation : node.documentation?.text ?? '';
for (const { groups } of (0, execall_1.execall)(/^\s*(?:@(?<title>\w+)(?::(?<tag>[a-z][a-z-]*))?)?(?: (?<args>(?:(?!^\s@\w+)[^])*))?/m, doc)) {
if (groups) {
yield {
title: groups.title ?? '',
tag: groups.tag ?? '',
args: groups.args ?? '',
};
}
}
}
exports.extractNatspec = extractNatspec;
function extractContractStorageSize(contract) {
let targetSlots;
for (const entry of extractNatspec(contract)) {
if (entry.title === 'custom' && entry.tag === 'storage-size') {
targetSlots = parseInt(entry.args);
}
}
return targetSlots;
}
exports.extractContractStorageSize = extractContractStorageSize;
function extractContractStateless(contract) {
for (const entry of extractNatspec(contract)) {
if (entry.title === 'custom' && entry.tag === 'stateless') {
return true;
}
}
return false;
}
exports.extractContractStateless = extractContractStateless;
//# sourceMappingURL=natspec.js.map