TypeChain
TypeChain copied to clipboard
generate-types doesn't recognize deployer.then as a function
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});
});
}