UNPKG

@openzeppelin/upgrade-safe-transpiler

Version:

Solidity preprocessor used to generate OpenZeppelin Contracts Upgrade Safe.

46 lines 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ASTResolverError = exports.ASTResolver = void 0; const utils_1 = require("solidity-ast/utils"); class ASTResolver { output; exclude; deref; constructor(output, exclude) { this.output = output; this.exclude = exclude; this.deref = (0, utils_1.astDereferencer)(output); } resolveContract(id) { return this.tryResolveNode('ContractDefinition', id); } resolveNode(nodeType, id) { const { node, sourceUnit } = this.deref.withSourceUnit(nodeType, id); const source = sourceUnit.absolutePath; if (this.exclude?.(source)) { throw new Error(`Symbol #${id} was imported from an excluded file (${source})`); } else { return node; } } tryResolveNode(nodeType, id) { try { const node = this.resolveNode('*', id); if ((0, utils_1.isNodeType)(nodeType, node)) { return node; } } catch (e) { if (e instanceof utils_1.ASTDereferencerError) { return undefined; } else { throw e; } } } } exports.ASTResolver = ASTResolver; exports.ASTResolverError = utils_1.ASTDereferencerError; //# sourceMappingURL=ast-resolver.js.map