flow-cli icon indicating copy to clipboard operation
flow-cli copied to clipboard

Support contract initializitation arguments with `flow dev`

Open nvdtf opened this issue 2 years ago • 3 comments

Currently, contract initialization parameters are not supported in flow.json. If you try to use flow dev with a contract that has init params, you'll get this error:

Deploying a contract failed because it requires initialization arguments. We currently don't support passing initialization arguments, so we suggest you hardcode the initialization arguments in the init function to be used during development.

There is a corresponding TODO item in the code:

https://github.com/onflow/flow-cli/blob/9cf919d34f6684c483fc68307753fcdb7401f5d2/internal/super/output.go#L120-L126

We probably need to change the syntax of deployments section to support arguments per contract deployed. Using deployments has the benefit of deploying multiple instances of the same contract using different param sets.

nvdtf avatar Apr 05 '23 22:04 nvdtf

@nvdtf defining deployment arguments should be possible already https://developers.flow.com/tools/flow-cli/deploy-project-contracts#initialization-arguments

The problem with making flow dev work with that is that flow dev builds it's own flow.json based on the contracts and folder structure. The problem is we have no good way of defining deployment arguments for flow dev. One option could be adding that to flow.json and then flow dev being smart enough to not overwrite them or to have some kind of pragma comment in the code defining arguments.

devbugging avatar Apr 06 '23 12:04 devbugging

Thanks @sideninja I updated the issue to only target flow dev support. I like the idea of not overwriting if a contract is already defined.

nvdtf avatar Apr 06 '23 16:04 nvdtf

Related to #865

devbugging avatar Apr 11 '23 10:04 devbugging