TypeChain icon indicating copy to clipboard operation
TypeChain copied to clipboard

generate-types doesn't recognize deployer.then as a function

Open lebed2045 opened this issue 4 years ago • 0 comments

This code is generated after the run of typechain --target=truffle-v5 'build/contracts/*.json' from examples. This code generates these types for the Deployer

  interface Deployer {
    link(
      library: Truffle.Contract<any>,
      destination: Truffle.Contract<any>
    ): Deployer;
    link(
      library: Truffle.Contract<any>,
      destinations: Array<Truffle.Contract<any>>
    ): Deployer;
    deploy<T extends any[]>(c: ContractNew<T>, ...args: T): Deployer;
  }

unfortunately function then(param: () => Promise<void>): void; is't part of that. Therefore migration script that waits until deployer is ready and only after that doing logic would yield an error during compilation time. Example of such script:

module.exports = function (deployer, network, accounts) {
    const [alice, bob] = accounts;

    deployer.then(async () => {
            await deployer.deploy(Contract, {from: bob});
            const contractInstance = await Contract.deployed();
            await contractInstance.transferOwnership(alice, {from: bob});
        
    });
}

lebed2045 avatar Oct 12 '21 14:10 lebed2045