Do any of you know of any good tutorials on getting a reference to the proxy contract interface from within a Truffle test suite? In the most minimal, Truffle-like way, not via the zos test helpers like
If so I can make a PR to add this to the Truffle migrate example, because then it’s a more complete example for someone who’s already bought into the Truffle ecosystem for their contract project but wants to add in zos.
I would want to get a reference to the latest implementation in order to use the Truffle Contract abstraction for calling methods (but then I’d want to change the address for that abstraction to point to the proxy). I should be able to look up the deployed implementation contract by doing
.deployed() with the name of the contract so that it uses the Truffle artifact package to find a deployed contract locally matching that Truffle-style ABI.
Next I would want to get a reference to the proxy to find its address, and then I would use the
.at() command to use a contract abstraction around the implementation ABI but found at the proxy address.
I would want to get a reference to the proxy instance by using
.deployed() with the name of the proxy, again using the Truffle artifact package. It’s hard to do since we don’t have the proxy abi locally in
/build/contracts/ in the Truffle-style json format, so first I’d have to know to look for the particular proxy .sol file
AdminUpgradeabilityProxy as opposed to the other proxy-related files from the zos repo in the proxy inheritance tree, clone the zos example project, and compile the
AdminUpgradeabilityProxy.sol file. Since the zos project itself isn’t using Truffle, the compiled artifact wouldn’t be the Truffle-style artifact (I’m pretty sure of this, anyway). I tried pasting in the .sol file into the legacy project I’m working on adding zos to and compiling it that way, but it’s on a different solc version, so to get the Truffle-style artifact of
AdminUpgradeabilityProxy.sol I would have to spin up a new Truffle project with the right solc version and compile the artifact for
AdminUpgradeabilityProxy.sol from there.
I think an example project where are few of these things are done would go a long way towards making users not have to grok too much of this and make the steps to set up a Truffle-style test of a zos contract pretty easy to follow, though.
After inspecting some recent PRs to
zos, I know
Contracts - which are used in the other zos examples - have been moving over to a web3-1.0-style of testing contracts away from Truffle - a perfectly sensible choice. But I think the user base of Truffle is large enough that having an example where you use zos but stick to the Truffle-y way of doing things would help with growing the ZeppelinOS community.
Thanks! Looking forward to hearing people’s thoughts.