Hey guys! I'm trying to enable typescript support for my ERC1155 Upgradable via @typechain/truffle-v5. It is a bit of an overhead since there are known limitations, like migrations scripts need to be transpiled to js for them to run, but hey, some1 needs to do it. ![]()
During this, after following this example of the guys from typechain I ran into a type mismatch in the migrations. Code example below.
Code to reproduce
import { deployProxy } from '@openzeppelin/truffle-upgrades';
module.exports = async function (deployer) {
const Pass = artifacts.require('Loyalty');
const instace = await deployProxy(Pass, ["0xesadas", "0xasdasd"], { deployer});
console.log('Deployed', instace.address);
} as Truffle.Migration;
export { }
Environment
Package.json
{
"scripts": {
"generate-types": "npx typechain --target=truffle-v5 'build/contracts/*.json'",
"postinstall": "npx truffle compile && npm run generate-types",
"migrate": "tsc -p ./tsconfig.migrate.json --outDir ./migrations && truffle migrate",
"typecheck": "tsc --noEmit",
"test" : "truffle test",
"compile" : "truffle compile"
},
"devDependencies": {
"@openzeppelin/contracts-upgradeable": "^4.2.0",
"@openzeppelin/truffle-upgrades": "^1.8.0",
"@typechain/truffle-v5": "^5.0.0",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.0.0",
"@types/node": "^16.4.13",
"solc": "^0.8.6",
"truffle": "^5.4.3",
"ts-node": "^10.1.0",
"typechain": "^5.1.2",
"typescript": "^4.3.5"
}
}
Error
The error is on line 5 of the code snippet, where:
Argument of type 'LoyaltyContract' is not assignable to parameter of type 'ContractClass'.
Type 'LoyaltyContract' is missing the following properties from type 'ContractClass': setProvider, defaults, bytecode, currentProvider, class_defaults
Contract:
*contract Loyalty is ERC1155Upgradeable, OwnableUpgradeable * and *has a valid initializer* .