I am attempting to call a function that only exists on an upgraded contract by executing the following in Truffle Develop:
migrate
foo = await FooV1.deployed()
await foo.Bar()
I get the error foo.Bar is not a function
. The code to reproduce is of course highly simplified. I understand that upgradeProxy
returns a proxy that I can call on. But I wish to call methods later in Truffle Develop. How can I do this?
Code to reproduce
FooV1
contract FooV1 {}
FooV2
contract FooV2 {
function Bar() public {}
}
Migrations
const FooV1 = artifacts.require("FooV1");
const FooV2 = artifacts.require("FooV1");
const { deployProxy, upgradeProxy } = require('@openzeppelin/truffle-upgrades');
module.exports = async function (deployer) {
const proxy = await deployProxy(FooV1, [], { deployer });
await upgradeProxy(proxy.address, FooV2, { deployer });
};
Environment
Truffle v5.4.15 (core: 5.4.15)
Solidity - ^0.8.0 (solc-js)
Node v14.18.0
Web3.js v1.5.3