import { Transform } from "assemblyscript/cli/transform" ; import * as preprocess from "./preprocess" ; import { getContractInfo } from "./contract/contract" ; import { Program } from "assemblyscript" ; import * as path from "path" ; export class AskTransform extends Transform { afterInitialize ( program ) { let source = program . sources [ 0 ] ; for ( let src of program . sources ) { if ( src . sourceKind === 1 && src . simplePath !== "index-incremental" ) { source = src ; break ; } } const info = getContractInfo ( program ) ; const abi = preprocess . getAbiInfo ( info ) ; const out = preprocess . getExtCodeInfo ( info ) ; const baseDir = path . dirname ( source . normalizedPath ) ; out . entryDir = baseDir ; process . sourceModifier = out ; const abiPath = path . join ( "target" , "metadata.json" ) ; this . writeFile ( abiPath , abi , baseDir ) ; } }