How to use the typechain.abiToWrapper function in typechain

To help you get started, we’ve selected a few typechain examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krzkaczor / ts-generator / example / ts-gen-plugins / typechain / index.ts View on Github external
transformFile(fd: TFileDesc): TFileDesc[] {
    const pathDetails = parse(fd.path);
    const outputDir = this.genPath || pathDetails.dir;

    const contractName = getFilenameWithoutAnyExtensions(pathDetails.name);
    const abi = JSON.parse(fd.contents);
    const relativeRuntimePath = getRelativeModulePath(outputDir, this.runtimePathAbs);

    const types = abiToWrapper(abi, {
      fileName: contractName,
      relativeRuntimePath,
    });

    return [
      {
        path: join(outputDir, contractName + ".ts"),
        contents: types,
      },
    ];
  }
}