Implement CLI/REST server support for new messages#131
Conversation
|
I did some manual tests with a local instance: wasmcli keys add fred
wasmcli tx send $(wasmcli keys show validator -a) $(wasmcli keys show fred -a) 5000000ucosm --chain-id=testing
# store first version
wasmcli tx wasm store contract.wasm --from validator --gas 600000 -y --chain-id=testing
wasmcli query wasm list-code
# create instance with admin: fred
wasmcli tx wasm instantiate 1 '{"verifier":"cosmos1rsj2m3qas3jy50s8psns95qka09lhwhx2wvdq8","beneficiary":"cosmos1rsj2m3qas3jy50s8psns95qka09lhwhx2wvdq8"}' --from validator --amount=50000ucosm --label "escrow 1" -y --chain-id=testing --admin=$(wasmcli keys show fred -a)
# migrate with user validator => fails
wasmcli tx wasm migrate cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5 2 "{}" --from validator --chain-id=testing
# migrate with user fred => ok
wasmcli tx wasm migrate cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5 2 "{}" --from fred --chain-id=testing
# show status
wasmcli query wasm contract cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5
{
"code_id": 2,
"creator": "cosmos1r5kgu6y7fqfh4dksw4c28hv7ns9ydnusf33vgs",
"admin": "cosmos1rsj2m3qas3jy50s8psns95qka09lhwhx2wvdq8",
"label": "escrow 1",
"init_msg": {
"verifier": "cosmos1rsj2m3qas3jy50s8psns95qka09lhwhx2wvdq8",
"beneficiary": "cosmos1rsj2m3qas3jy50s8psns95qka09lhwhx2wvdq8"
},
"address": "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5"
}
|
Codecov Report
@@ Coverage Diff @@
## 0.9 #131 +/- ##
==========================================
- Coverage 62.13% 62.06% -0.08%
==========================================
Files 20 20
Lines 1764 1766 +2
==========================================
Hits 1096 1096
- Misses 576 578 +2
Partials 92 92
Continue to review full report at Codecov.
|
ethanfrey
left a comment
There was a problem hiding this comment.
Looks good. And there are unfortunately no tests for CLI/REST (most anywhere).
I just ask you to test them out manually before merging (honor system).
The PR looks good for adding TX support. However, it doesn't close the linked issues. For that it must add query support - adding the administrator field to the contract info - this is essential info to know if I want to trust a contract, as important as the code behind it.
| cmd := &cobra.Command{ | ||
| Use: "set-contract-admin [contract_addr_bech32] [optional_new_admin_addr_bech32]", | ||
| Short: "Set new admin for a contract. Can be empty to prevent further migrations", | ||
| Args: cobra.RangeArgs(1, 2), |
There was a problem hiding this comment.
i didn't know this one. I like it.
i kind of think setting it to nil should require a bit more intention than a missing argument. but cli ux is definitely not high on my list of concerns (or anyone's I think).
Maybe a flag for this? Fine to leave as is.
There was a problem hiding this comment.
👍 A flag is a good idea. Will add it.
|
If you add the field to query and manually test, feel free to merge without another review |
|
Sorry @alpe, I missed that the field was there. I expected it needed a code change and didn't come automatically. Good to merge as is |
|
Manual CLI tests for set new contract admin |
* Cleanup ContractInfo type * Add admin to contract instanciation * Add cli commands for new TX * Add rest support for new TX * Update changelog * Make optional admin flag for better UX * Add flag to not accidentally clear admin on update
🚧 After #124
CLI/REST Support:
Reviewer note
--
docs/)godoccomments.Unreleasedsection inCHANGELOG.mdFiles changedin the Github PR explorerFor admin use:
WIP,R4R,docs, etc)