UNPKG

oken-waas

Version:
27 lines (26 loc) 1.22 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const abiDir = path_1.default.join(__dirname, '..', 'abis'); const files = fs_1.default.readdirSync(abiDir); const typesPath = path_1.default.join(__dirname, '../../', 'oken-types'); const exported = files.map((file) => { const contractId = path_1.default.basename(file, '.json'); const contractReference = contractId.charAt(0).toLowerCase() + contractId.slice(1); return `${contractReference}: ({ address }: { address: string }): ${contractId} => contract('${contractId}', api, network, address)`; }); const contents = ` import { API } from '../components/api' import {contract} from './helpers' import { ${files.map(file => path_1.default.basename(file, '.json')).join(',\n')} } from '${typesPath}' export default (api: API, network: string) => ({ ${exported.join(',\n ')} })`; fs_1.default.writeFileSync(path_1.default.join(__dirname, 'index.ts'), contents); //# sourceMappingURL=codegen.js.map