flow-cli
flow-cli copied to clipboard
Broken flow.json when deploying contract with [String] as init arg
Problem
Whenever using CLI to deploy a contract with an array of String in init args - e.g. init(_ a: [String]) - deployment succeeds but the init args as defined in the flow.json break the config file.
Steps to Reproduce
Init project:
flow init
Add the contract
access(all) contract C {
access(all) let arr: [String]
init(arr: [String]) {
self.arr = arr
}
}
Run emulator and deploy the contract with
flow accounts add-contract ./contracts/C.cdc '["a", "b"]'
Try to run any other CLI command and get
❌ Config Error: failed to decode JSON-Cadence value: invalid type: [String]
Looking at the flow.json, we see
{
"name": "C",
"args": [
{
"type": "[String]",
"value": "[a b]"
}
]
}
Which should be
{
"name": "C",
"args": [
{
"type": "Array",
"value": [
{
"type": "String",
"value": "a"
},
{
"type": "String",
"value": "b"
}
]
}
]
}