Open simondlr opened 4 years ago
Here's some additional information:
If I start with deploying it as 'ugpradeable', it does create the 'networks' object. Subsequently, deploying a regular version of the same contract overwrites this 'networks' object with the new deployment. BUT, if deploying a regular contract from scratch, it does not create the 'networks' object.
eg, assume contract 'A':
1) Deploy 'regular' A.
-> No 'networks' object in build file (contracts/build/A.json).
1) Deploy 'upgradeable' A. (creates 'networks' object for the proxy in build file). 2) Deploy 'regular' A. (Overwrites 'networks' object).
So, I have to do this work-around.
I'm not sure what the desired behaviour should be, but I've been relying on there being a 'networks' object.
I could use the network object (eg dev-31337.json) to get addresses, but this requires extra lift in the front-end, because you have to load additional files + also add in a prefix if you rely on getting the network id from the provider.
Hi @simondlr ! I’m sorry that you had this issue.
We have been able to reproduce this issue by following these steps:
// contracts/A.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract A { }
2. Deploy contract A as a regular contract
No network object in `build/contracts/A.json`
Thanks so much for reporting it! The project owner will review and triage this issue as soon as they can. In the meantime, you can try the following workaround:
1. Add the contract to your project using the [add](https://docs.openzeppelin.com/cli/2.8/commands#add) command.
The contract will then be added to the contracts section of `.openzeppelin/project.json`
$ npx oz add A ✓ Compiled contracts with solc 0.6.10 (commit.00c0fcaf) ✓ Added contract A
2. Deploy as kind regular and the network object should be created.
$ npx oz deploy Nothing to compile, all contracts are up to date. ? Choose the kind of deployment regular ? Pick a network development ? Pick a contract to deploy A ✓ Deployed instance of A 0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab
If you aren't already, I suggest including `project.json` in version control. (See the documentation on [Configuration Files in Version Control](https://docs.openzeppelin.com/cli/2.8/configuration#configuration-files-in-version-control))
Thanks @abcoathup. This work-around works perfect. Appreciate the prompt response!
To load a contract in the dapp, I usually rely on the 'networks' object in the contract's build file. It has worked consistently. However, recently, after a fresh re-install of my code, when deploying a regular contract, it doesn't write the address into the 'networks' object.
I've tried figuring out whether this is a bug, or whether I have incorrect assumptions about the build files? Unsure if whether something I changed stopped it from working? So, uncertain whether this is a bug or working-as-intended.
Is this Truffle? (which I'm not using). Should it be happening without Truffle?