Skip to content

Commit

Permalink
update proto field name
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb committed May 9, 2022
1 parent ac6876f commit 3ade815
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 154 deletions.
30 changes: 15 additions & 15 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
- [MsgIBCSend](#cosmwasm.wasm.v1.MsgIBCSend)

- [cosmwasm/wasm/v1/proposal.proto](#cosmwasm/wasm/v1/proposal.proto)
- [AccessConfigUpdate](#cosmwasm.wasm.v1.AccessConfigUpdate)
- [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 @@ -643,35 +643,35 @@ MsgIBCSend



<a name="cosmwasm.wasm.v1.ClearAdminProposal"></a>
<a name="cosmwasm.wasm.v1.AccessConfigUpdate"></a>

### ClearAdminProposal
ClearAdminProposal gov proposal content type to clear the admin of a
contract.
### AccessConfigUpdate
AccessConfigUpdate contains the code id and the access config to be
applied.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `title` | [string](#string) | | Title is a short summary |
| `description` | [string](#string) | | Description is a human readable text |
| `contract` | [string](#string) | | Contract is the address of the smart contract |
| `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.CodeAccessConfigUpdate"></a>
<a name="cosmwasm.wasm.v1.ClearAdminProposal"></a>

### CodeAccessConfigUpdate
CodeAccessConfigUpdate contains the code id and the access config to be
applied.
### ClearAdminProposal
ClearAdminProposal gov proposal content type to clear the admin of a
contract.


| 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 |
| `title` | [string](#string) | | Title is a short summary |
| `description` | [string](#string) | | Description is a human readable text |
| `contract` | [string](#string) | | Contract is the address of the smart contract |



Expand Down Expand Up @@ -845,7 +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_updates` | [CodeAccessConfigUpdate](#cosmwasm.wasm.v1.CodeAccessConfigUpdate) | repeated | CodeAccessConfigUpdate contains the list of code ids and the access config to be applied. |
| `access_config_updates` | [AccessConfigUpdate](#cosmwasm.wasm.v1.AccessConfigUpdate) | repeated | AccessConfigUpdate contains the list of code ids and the access config to be applied. |



Expand Down
10 changes: 5 additions & 5 deletions proto/cosmwasm/wasm/v1/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ message UnpinCodesProposal {
];
}

// CodeAccessConfigUpdate contains the code id and the access config to be
// AccessConfigUpdate contains the code id and the access config to be
// applied.
message CodeAccessConfigUpdate {
message AccessConfigUpdate {
// 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 ];
AccessConfig instantiate_permission = 2 [ (gogoproto.nullable) = false ];
}

// UpdateInstantiateConfigProposal gov proposal content type to update
Expand All @@ -165,8 +165,8 @@ message UpdateInstantiateConfigProposal {
string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
// Description is a human readable text
string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
// CodeAccessConfigUpdate contains the list of code ids and the access config
// AccessConfigUpdate contains the list of code ids and the access config
// to be applied.
repeated CodeAccessConfigUpdate code_updates = 3
repeated AccessConfigUpdate access_config_updates = 3
[ (gogoproto.nullable) = false ];
}
14 changes: 7 additions & 7 deletions x/wasm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ func parseAccessConfig(config string) (types.AccessConfig, error) {
}
}

func parseCodeUpdateArgs(args []string) ([]types.CodeAccessConfigUpdate, error) {
updates := make([]types.CodeAccessConfigUpdate, len(args))
func parseAccessConfigUpdates(args []string) ([]types.AccessConfigUpdate, error) {
updates := make([]types.AccessConfigUpdate, len(args))
for i, c := range args {
// format: code_id,access_config
// access_config: nobody|everybody|address
Expand All @@ -651,7 +651,7 @@ func parseCodeUpdateArgs(args []string) ([]types.CodeAccessConfigUpdate, error)
if err != nil {
return nil, err
}
updates[i] = types.CodeAccessConfigUpdate{
updates[i] = types.AccessConfigUpdate{
CodeID: codeID,
InstantiatePermission: accessConfig,
}
Expand Down Expand Up @@ -692,15 +692,15 @@ $ %s tx gov submit-proposal update-instantiate-config 1,nobody 2,everybody 3,%s1
if err != nil {
return err
}
updates, err := parseCodeUpdateArgs(args)
updates, err := parseAccessConfigUpdates(args)
if err != nil {
return err
}

content := types.UpdateInstantiateConfigProposal{
Title: proposalTitle,
Description: proposalDescr,
CodeUpdates: updates,
Title: proposalTitle,
Description: proposalDescr,
AccessConfigUpdates: updates,
}
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
if err != nil {
Expand Down
17 changes: 8 additions & 9 deletions x/wasm/client/rest/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,18 @@ func UnpinCodeProposalHandler(cliCtx client.Context) govrest.ProposalRESTHandler
type UpdateInstantiateConfigProposalJSONReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`

Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Proposer string `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`

CodeUpdates []types.CodeAccessConfigUpdate `json:"code_updates" yaml:"code_updates"`
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Proposer string `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
AccessConfigUpdates []types.AccessConfigUpdate `json:"access_config_updates" yaml:"access_config_updates"`
}

func (s UpdateInstantiateConfigProposalJSONReq) Content() govtypes.Content {
return &types.UpdateInstantiateConfigProposal{
Title: s.Title,
Description: s.Description,
CodeUpdates: s.CodeUpdates,
Title: s.Title,
Description: s.Description,
AccessConfigUpdates: s.AccessConfigUpdates,
}
}
func (s UpdateInstantiateConfigProposalJSONReq) GetProposer() string {
Expand Down
6 changes: 3 additions & 3 deletions x/wasm/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsK
return err
}

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)
for _, accessConfigUpdate := range p.AccessConfigUpdates {
if err := k.SetAccessConfig(ctx, accessConfigUpdate.CodeID, accessConfigUpdate.InstantiatePermission); err != nil {
return sdkerrors.Wrapf(err, "code id: %d", accessConfigUpdate.CodeID)
}
}
return nil
Expand Down
34 changes: 17 additions & 17 deletions x/wasm/keeper/proposal_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,38 +769,38 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) {
)

specs := map[string]struct {
codeUpdates []types.CodeAccessConfigUpdate
expErr bool
accessConfigUpdates []types.AccessConfigUpdate
expErr bool
}{
"update one": {
codeUpdates: []types.CodeAccessConfigUpdate{
accessConfigUpdates: []types.AccessConfigUpdate{
{CodeID: nobody.CodeID, InstantiatePermission: types.AllowEverybody},
},
},
"update multiple": {
codeUpdates: []types.CodeAccessConfigUpdate{
accessConfigUpdates: []types.AccessConfigUpdate{
{CodeID: everybody.CodeID, InstantiatePermission: types.AllowNobody},
{CodeID: nobody.CodeID, InstantiatePermission: withAddressAccessConfig},
{CodeID: withAddress.CodeID, InstantiatePermission: types.AllowEverybody},
},
},
"update same code id": {
codeUpdates: []types.CodeAccessConfigUpdate{
accessConfigUpdates: []types.AccessConfigUpdate{
{CodeID: everybody.CodeID, InstantiatePermission: types.AllowNobody},
{CodeID: everybody.CodeID, InstantiatePermission: types.AllowEverybody},
},
expErr: true,
},
"update non existing code id": {
codeUpdates: []types.CodeAccessConfigUpdate{
accessConfigUpdates: []types.AccessConfigUpdate{
{CodeID: 100, InstantiatePermission: types.AllowNobody},
{CodeID: everybody.CodeID, InstantiatePermission: types.AllowEverybody},
},
expErr: true,
},
"update empty list": {
codeUpdates: make([]types.CodeAccessConfigUpdate, 0),
expErr: true,
accessConfigUpdates: make([]types.AccessConfigUpdate, 0),
expErr: true,
},
}
parentCtx := ctx
Expand All @@ -809,18 +809,18 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) {

ctx, _ := parentCtx.CacheContext()

updates := make([]types.CodeAccessConfigUpdate, 0)
for _, cu := range spec.codeUpdates {
updates = append(updates, types.CodeAccessConfigUpdate{
updates := make([]types.AccessConfigUpdate, 0)
for _, cu := range spec.accessConfigUpdates {
updates = append(updates, types.AccessConfigUpdate{
CodeID: cu.CodeID,
InstantiatePermission: cu.InstantiatePermission,
})
}

proposal := types.UpdateInstantiateConfigProposal{
Title: "Foo",
Description: "Bar",
CodeUpdates: updates,
Title: "Foo",
Description: "Bar",
AccessConfigUpdates: updates,
}

// when stored
Expand All @@ -837,9 +837,9 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) {
require.NoError(t, gotErr)

// then
for i := range spec.codeUpdates {
c := wasmKeeper.GetCodeInfo(ctx, spec.codeUpdates[i].CodeID)
require.Equal(t, spec.codeUpdates[i].InstantiatePermission, c.InstantiateConfig)
for i := range spec.accessConfigUpdates {
c := wasmKeeper.GetCodeInfo(ctx, spec.accessConfigUpdates[i].CodeID)
require.Equal(t, spec.accessConfigUpdates[i].InstantiatePermission, c.InstantiateConfig)
}
})
}
Expand Down
12 changes: 6 additions & 6 deletions x/wasm/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,11 @@ func (p UpdateInstantiateConfigProposal) ValidateBasic() error {
if err := validateProposalCommons(p.Title, p.Description); err != nil {
return err
}
if len(p.CodeUpdates) == 0 {
if len(p.AccessConfigUpdates) == 0 {
return sdkerrors.Wrap(ErrEmpty, "code updates")
}
dedup := make(map[uint64]bool)
for _, codeUpdate := range p.CodeUpdates {
for _, codeUpdate := range p.AccessConfigUpdates {
_, found := dedup[codeUpdate.CodeID]
if found {
return sdkerrors.Wrapf(ErrDuplicate, "duplicate code: %d", codeUpdate.CodeID)
Expand All @@ -592,13 +592,13 @@ func (p UpdateInstantiateConfigProposal) String() string {
return fmt.Sprintf(`Update Instantiate Config Proposal:
Title: %s
Description: %s
CodeUpdates: %v
`, p.Title, p.Description, p.CodeUpdates)
AccessConfigUpdates: %v
`, p.Title, p.Description, p.AccessConfigUpdates)
}

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

0 comments on commit 3ade815

Please sign in to comment.