@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
30 lines (28 loc) • 1.25 kB
JavaScript
import { tsUtils } from '@neo-one/ts-utils';
export const createWrapParam = (sb) => (param, innerOptions) => {
let type = sb.context.analysis.getType(param);
if (type !== undefined && tsUtils.parameter.isRestParameter(param)) {
type = tsUtils.type_.getArrayType(type);
}
sb.emitHelper(param, innerOptions, sb.helpers.wrapValRecursive({
type,
checkValue: true,
optional: tsUtils.initializer.getInitializer(param) !== undefined,
}));
};
export const findSuperDeployPropInfo = (contractInfo) => {
const superSmartContract = contractInfo.superSmartContract;
if (superSmartContract === undefined) {
return undefined;
}
const superDeployPropInfo = superSmartContract.propInfos.find((propInfo) => propInfo.type === 'deploy');
if (superDeployPropInfo !== undefined) {
return [superSmartContract, superDeployPropInfo];
}
return findSuperDeployPropInfo(superSmartContract);
};
export const findDeployInfo = (contractInfo) => {
const deployInfo = contractInfo.propInfos.find((propInfo) => propInfo.type === 'deploy');
return deployInfo === undefined ? findSuperDeployPropInfo(contractInfo) : [contractInfo, deployInfo];
};
//# sourceMappingURL=utils.js.map