How to use the typechain.parse 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 ethereum-ts / TypeChain / packages / typechain-target-web3-v2 / lib / index.ts View on Github external
transformFile(file: TFileDesc): TFileDesc | void {
    const abi = extractAbi(file.contents);
    const isEmptyAbi = abi.length === 0;
    if (isEmptyAbi) {
      return;
    }

    const name = getFilename(file.path);

    const contract = parse(abi, name);

    return {
      path: join(this.outDirAbs, `${name}.d.ts`),
      contents: codegen(contract),
    };
  }
github ethereum-ts / TypeChain / packages / typechain-target-ethers / lib / index.ts View on Github external
transformAbiOrFullJsonFile(file: TFileDesc): TFileDesc[] | void {
    const name = getFilename(file.path);
    const abi = extractAbi(file.contents);

    if (abi.length === 0) {
      return;
    }

    const contract = parse(abi, name);
    const bytecode = extractBytecode(file.contents) || this.bytecodeCache[name];

    if (bytecode) {
      return [
        this.genContractTypingsFile(contract),
        this.genContractFactoryFile(contract, abi, bytecode),
      ];
    } else {
      this.contractCache[name] = { abi, contract };
      return [this.genContractTypingsFile(contract)];
    }
  }
github ethereum-ts / TypeChain / packages / typechain-target-web3-v1 / lib / index.ts View on Github external
transformFile(file: TFileDesc): TFileDesc | void {
    const abi = extractAbi(file.contents);
    const isEmptyAbi = abi.length === 0;
    if (isEmptyAbi) {
      return;
    }

    const name = getFilename(file.path);

    const contract = parse(abi, name);

    return {
      path: join(this.outDirAbs, `${name}.d.ts`),
      contents: codegen(contract),
    };
  }
github ethereum-ts / TypeChain / packages / typechain-target-truffle-v4 / lib / index.ts View on Github external
transformFile(file: TFileDesc): TFileDesc | void {
    const abi = extractAbi(file.contents);
    const isEmptyAbi = abi.length === 0;
    if (isEmptyAbi) {
      return;
    }

    const name = getFilename(file.path);

    const contract = parse(abi, name);

    this.contracts.push(contract);
  }