Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

oz deploy should support --init and --args, same as oz create in 2.7 #1568

Open
pash7ka opened this issue Jul 23, 2020 · 8 comments
Open

oz deploy should support --init and --args, same as oz create in 2.7 #1568

pash7ka opened this issue Jul 23, 2020 · 8 comments

Comments

@pash7ka
Copy link

pash7ka commented Jul 23, 2020

With upgrade to 2.8 create command is replaced with deploy. But the latter does not support --init abd --args arguments, so it's impossible to specify initializer from command line.

@abcoathup
Copy link
Contributor

Hi @pash7ka ! I’m sorry that you had this issue.

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:

Continue to use create for where you need to specify an initializer from the command line for an upgradeable contract.

@pash7ka
Copy link
Author

pash7ka commented Jul 30, 2020

Thank you! That's the workaround I'm currently using.

@oberstet
Copy link

unfortunately, the workaround does not work for me. is there any public example for non-interactive scripted use of oz cli?

below is output from first trying non-interactive (fails) and then interactive (succeeds):

(cpy382_1) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ npx oz create --no-interactive --network ganache --init initialize XBRToken
The create command is deprecated. Use deploy instead.
✓ Compiling contracts with Truffle, using settings from truffle.js file
Truffle output:
 
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/XBRCatalog.sol
> Compiling ./contracts/XBRChannel.sol
> Compiling ./contracts/XBRDomain.sol
> Compiling ./contracts/XBRMaintained.sol
> Compiling ./contracts/XBRMarket.sol
> Compiling ./contracts/XBRNetwork.sol
> Compiling ./contracts/XBRNetworkProxy.sol
> Compiling ./contracts/XBRTest.sol
> Compiling ./contracts/XBRToken.sol
> Compiling ./contracts/XBRTypes.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/cryptography/ECDSA.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol
> Artifacts written to /home/oberstet/scm/crossbario/xbr-protocol/build/contracts
> Compiled successfully using:
   - solc: 0.6.2+commit.bacdbe57.Emscripten.clang


Contract XBRToken is not deployed to dev-5777.
(cpy382_1) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ npx oz create --network ganache XBRToken
The create command is deprecated. Use deploy instead.
✓ Compiling contracts with Truffle, using settings from truffle.js file
Truffle output:
 
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/XBRCatalog.sol
> Compiling ./contracts/XBRChannel.sol
> Compiling ./contracts/XBRDomain.sol
> Compiling ./contracts/XBRMaintained.sol
> Compiling ./contracts/XBRMarket.sol
> Compiling ./contracts/XBRNetwork.sol
> Compiling ./contracts/XBRNetworkProxy.sol
> Compiling ./contracts/XBRTest.sol
> Compiling ./contracts/XBRToken.sol
> Compiling ./contracts/XBRTypes.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/cryptography/ECDSA.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol
> Compiling @openzeppelin/contracts-ethereum-package/contracts/utils/EnumerableSet.sol
> Artifacts written to /home/oberstet/scm/crossbario/xbr-protocol/build/contracts
> Compiled successfully using:
   - solc: 0.6.2+commit.bacdbe57.Emscripten.clang


✓ XBRTypes library uploaded
✓ Contract XBRToken deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize()
✓ Setting everything up to create contract instances
✓ Instance created at 0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B
To upgrade this instance run 'oz upgrade'
0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B
(cpy382_1) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ 

@pash7ka
Copy link
Author

pash7ka commented Aug 27, 2020

Hi @oberstet
I'm using it this way:

npx oz create MyContract --network rinkeby --init "initialize(address _myArgument)" --args 0x6B175474E89094C44Da98b954EedeAC495271d0F

This way it does not ask any interactive questions.

@oberstet
Copy link

fantastic! thanks, that works for me=)

npx oz create XBRToken --network ganache --init "initialize()"
npx oz create XBRNetwork --network ganache --init "initialize(address _arg1, address _arg2)" \
    --args 0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B,0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
npx oz create XBRDomain --network ganache --init "initialize(address _arg1)" \
    --args 0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
npx oz create XBRCatalog --network ganache --init "initialize(address _arg1)" \
    --args 0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
npx oz create XBRMarket --network ganache --init "initialize(address _arg1, address _arg2)" \
    --args 0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb,0x0290FB167208Af455bB137780163b7B7a9a10C16
npx oz create XBRChannel --network ganache --init "initialize(address _arg1)" \
    --args 0x67B5656d60a809915323Bf2C40A8bEF15A152e3e```

may I ask 1 more Q? only slightly related .. but related to "how to deploy using non-interactive scripting". as in: how do I get rid of the hard-coded addresses in ^ (forwarding addresses of deployed contracts as constructor arguments in subsequent contract deployments)

IOW: how do you manage dependencies between multiple contracts using os cli?

in truffle, I am using

await deployer.link(XBRTypes, XBRMarket);
await deployer.link(XBRNetwork, XBRMarket);
await deployer.link(XBRCatalog, XBRMarket);
await deployer.deploy(XBRMarket, XBRNetwork.address, XBRCatalog.address, {gas: gas, from: organization});

to establish dependencies, and also to await dependent contracts so that their addresses can be used as constructor arguments

https://github.com/crossbario/xbr-protocol/blob/825d54c9e222582dfae60504f6827ed561dd1d49/migrations/2_deploy_contracts.js#L69

@frangio
Copy link
Contributor

frangio commented Sep 8, 2020

forwarding addresses of deployed contracts as constructor arguments in subsequent contract deployments

@oberstet You can read the address from stdout of the oz create command. However, for non-interactive deployment scripts I would recommend using the OpenZeppelin Upgrades Plugins for Buidler and Truffle.

@oberstet
Copy link

oberstet commented Sep 8, 2020

@frangio thanks! yeah, I've found out about the truffle plugin stuff in the meantime - and it works, including links=)

const { deployProxy } = require('@openzeppelin/truffle-upgrades');

// ...

await deployer.link(XBRTypes, XBRToken);
const token_instance = await deployProxy(XBRToken, [],
   { deployer, unsafeAllowCustomTypes: true });

await deployer.link(XBRTypes, XBRNetwork);
const network_instance = await deployProxy(XBRNetwork, [token_instance.address, organization],
  { deployer, unsafeAllowCustomTypes: true });

@frangio
Copy link
Contributor

frangio commented Sep 8, 2020

@oberstet Note that since your XBRTypes library doesn't have external functions, it's not necessary to link it. Linking it does nothing, in fact.

Contracts which require linking an external library are not yet supported by the plugins, but we're working in that direction. See OpenZeppelin/openzeppelin-upgrades#144 and OpenZeppelin/openzeppelin-upgrades#52.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants