UNPKG

@openzeppelin/upgrade-safe-transpiler

Version:

Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.

36 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractNatspec = extractNatspec; exports.extractContractStorageSize = extractContractStorageSize; exports.extractContractStateless = extractContractStateless; 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 ?? '', }; } } } 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; } function extractContractStateless(contract) { for (const entry of extractNatspec(contract)) { if (entry.title === 'custom' && entry.tag === 'stateless') { return true; } } return false; } //# sourceMappingURL=natspec.js.map