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

Deploying contracts with `Address` init args breaks config

Open sisyphusSmiling opened this issue 1 year ago • 1 comments

Problem

When deploying a contract using flow accounts add-contract with an Address value in its initialization parameters, the contract deploys, but the value inserted into flow.json.deployments field breaks the config.

Steps to Reproduce

Running the emulator, try deploying the contract below with flow accounts add-contract ./contracts/C.cdc

access(all) contract C {
    access(all) let addressParam: Address
    init(addressParam: Address) {
        self.addressParam = addressParam
    }
}

Then try any other cli command and get the error

❯ flow accounts get 0xf8d6e0586b0a20c7
❌ Config Error: failed to decode JSON-Cadence value: invalid address prefix: (shown as hex) expected 3078, got 5b32

Check flow.json and see

"deployments": {
  "emulator": {
    "emulator-account": [
      {
        "name": "C",
	"args": [
	  {
	    "type": "Address",
            "value": "[248 214 224 88 107 10 32 199]"
          }
        ]
      }
    ]
}

Where value should be 0xf8d6e0586b0a20c7

Acceptance Criteria

Address values are inserted in current Cadence JSON format - see docs here

sisyphusSmiling avatar Feb 22 '24 23:02 sisyphusSmiling