Skip to content

Commit

Permalink
update UpdateInstantiateConfigProposal proto definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb committed May 4, 2022
1 parent 3cc80d8 commit 9edcfef
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 187 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ proto-lint:
@$(DOCKER_BUF) lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against-input $(HTTPS_GIT)#branch=master
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main

.PHONY: all install install-debug \
go-mod-cache draw-deps clean build format \
Expand Down
23 changes: 20 additions & 3 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

- [cosmwasm/wasm/v1/proposal.proto](#cosmwasm/wasm/v1/proposal.proto)
- [ClearAdminProposal](#cosmwasm.wasm.v1.ClearAdminProposal)
- [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate)
- [ExecuteContractProposal](#cosmwasm.wasm.v1.ExecuteContractProposal)
- [InstantiateContractProposal](#cosmwasm.wasm.v1.InstantiateContractProposal)
- [MigrateContractProposal](#cosmwasm.wasm.v1.MigrateContractProposal)
Expand Down Expand Up @@ -660,6 +661,23 @@ contract.



<a name="cosmwasm.wasm.v1.CodeAccessConfigUpdate"></a>

### CodeAccessConfigUpdate
CodeAccessConfigUpdate contains the code id and the access config to be
applied.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code to be updated |
| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids |






<a name="cosmwasm.wasm.v1.ExecuteContractProposal"></a>

### ExecuteContractProposal
Expand Down Expand Up @@ -717,7 +735,7 @@ MigrateContractProposal gov proposal content type to migrate a contract.

Note: skipping 3 as this was previously used for unneeded run_as |
| `contract` | [string](#string) | | Contract is the address of the smart contract |
| `code_id` | [uint64](#uint64) | | CodeID references the new WASM codesudo |
| `code_id` | [uint64](#uint64) | | CodeID references the new WASM code |
| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract on migration |


Expand Down Expand Up @@ -827,8 +845,7 @@ instantiate config to a set of code ids.
| ----- | ---- | ----- | ----------- |
| `title` | [string](#string) | | Title is a short summary |
| `description` | [string](#string) | | Description is a human readable text |
| `code_ids` | [uint64](#uint64) | repeated | CodeIDs references the WASM codes |
| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply to the set of code ids |
| `code_updates` | [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate) | repeated | CodeAccessConfigUpdate contains the list of code ids and the access config to be applied. |



Expand Down
22 changes: 14 additions & 8 deletions proto/cosmwasm/wasm/v1/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ message MigrateContractProposal {

// Contract is the address of the smart contract
string contract = 4;
// CodeID references the new WASM codesudo
// CodeID references the new WASM code
uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
// Msg json encoded message to be passed to the contract on migration
bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ];
Expand Down Expand Up @@ -149,18 +149,24 @@ message UnpinCodesProposal {
];
}

// CodeAccessConfigUpdate contains the code id and the access config to be
// applied.
message CodeAccessConfigUpdate {
// CodeID is the reference to the stored WASM code to be updated
uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
// InstantiatePermission to apply to the set of code ids
AccessConfig instantiate_permission = 4 [ (gogoproto.nullable) = false ];
}

// UpdateInstantiateConfigProposal gov proposal content type to update
// instantiate config to a set of code ids.
message UpdateInstantiateConfigProposal {
// Title is a short summary
string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
// Description is a human readable text
string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
// CodeIDs references the WASM codes
repeated uint64 code_ids = 3 [
(gogoproto.customname) = "CodeIDs",
(gogoproto.moretags) = "yaml:\"code_ids\""
];
// InstantiatePermission to apply to the set of code ids
AccessConfig instantiate_permission = 4 [ (gogoproto.nullable) = false ];
// CodeAccessConfigUpdate contains the list of code ids and the access config
// to be applied.
repeated CodeAccessConfigUpdate code_updates = 3
[ (gogoproto.nullable) = false ];
}
7 changes: 4 additions & 3 deletions x/wasm/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsK
if err := p.ValidateBasic(); err != nil {
return err
}
for _, v := range p.CodeIDs {
if err := k.SetAccessConfig(ctx, v, p.InstantiatePermission); err != nil {
return sdkerrors.Wrapf(err, "code id: %d", v)

for _, codeUpdate := range p.CodeUpdates {
if err := k.SetAccessConfig(ctx, codeUpdate.CodeID, codeUpdate.InstantiatePermission); err != nil {
return sdkerrors.Wrapf(err, "code id: %d", codeUpdate.CodeID)
}
}
return nil
Expand Down
23 changes: 16 additions & 7 deletions x/wasm/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,13 @@ func (p UpdateInstantiateConfigProposal) ValidateBasic() error {
if err := validateProposalCommons(p.Title, p.Description); err != nil {
return err
}
if len(p.CodeIDs) == 0 {
return sdkerrors.Wrap(ErrEmpty, "code ids")
if len(p.CodeUpdates) == 0 {
return sdkerrors.Wrap(ErrEmpty, "code updates")
}
if err := p.InstantiatePermission.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "instantiate permission")
for _, codeUpdate := range p.CodeUpdates {
if err := codeUpdate.InstantiatePermission.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "instantiate permission")
}
}
return nil
}
Expand All @@ -582,7 +584,14 @@ func (p UpdateInstantiateConfigProposal) String() string {
return fmt.Sprintf(`Update Instantiate Config Proposal:
Title: %s
Description: %s
Codes: %v
InstantiatePermission: %v
`, p.Title, p.Description, p.CodeIDs, p.InstantiatePermission)
CodeUpdates: %v
`, p.Title, p.Description, p.CodeUpdates)
}

// String implements the Stringer interface.
func (c CodeAccessConfigUpdate) String() string {
return fmt.Sprintf(`CodeAccessUpdate:
CodeID: %d
AccessConfig: %v
`, c.CodeID, c.InstantiatePermission)
}
Loading

0 comments on commit 9edcfef

Please sign in to comment.