Trey asked on Telegram
Is there any way to keep the original name. i.e. instead of the name of my contract being "Box", then "BoxV2" then "BoxV3", for each implementation contract to just be "Box"?
Trey asked on Telegram
Is there any way to keep the original name. i.e. instead of the name of my contract being "Box", then "BoxV2" then "BoxV3", for each implementation contract to just be "Box"?
Trey pointed out that the documentation has the following:
_From: https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades#migrations-usage_
Then, in a future migration, you can use theupgradeProxy
function to upgrade the deployed instance to a new version. The new version can be a different contract (such asBoxV2
), or you can just modify the existingBox
contract and recompile it - the plugin will note it changed.
The initial version can be deployed with the following:
// migrations/2_deploy_box.js
const Box = artifacts.require('Box');
const { deployProxy } = require('@openzeppelin/truffle-upgrades');
module.exports = async function (deployer) {
await deployProxy(Box, [42], { deployer, initializer: 'store' });
};
The Box contract can then be updated, and then upgraded with the following migration
// migrations/3_upgrade_box.js
const Box = artifacts.require('Box');
const { upgradeProxy } = require('@openzeppelin/truffle-upgrades');
module.exports = async function (deployer) {
const existing = await Box.deployed();
const instance = await upgradeProxy(existing.address, Box, { deployer });
};
This doesn't allow for easy reproduction of the upgrade process.
I would recommend using versioned contract names for a project being used in production.