Skip to content

Commit

Permalink
Remove AccessTypeOnlyAddress for update config msg
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Jan 19, 2023
1 parent 2296048 commit a6a48ea
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions x/wasm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func GetTxCmd() *cobra.Command {
UpdateContractAdminCmd(),
ClearContractAdminCmd(),
GrantAuthorizationCmd(),
UpdateInstantiateConfigCmd(),
)
return txCmd
}
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/keeper/proposal_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) {
anyAddress, err := sdk.AccAddressFromBech32("cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz")
require.NoError(t, err)

withAddressAccessConfig := types.AccessTypeOnlyAddress.With(anyAddress)
withAddressAccessConfig := types.AccessTypeAnyOfAddresses.With(anyAddress)
var (
nobody = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &types.AllowNobody)
everybody = StoreRandomContractWithAccessConfig(t, ctx, keepers, &mock, &types.AllowEverybody)
Expand Down
7 changes: 7 additions & 0 deletions x/wasm/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func (msg MsgStoreCode) ValidateBasic() error {
if err := msg.InstantiatePermission.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "instantiate permission")
}
// AccessTypeOnlyAddress is still considered valid as legacy instantiation permission
// but not for new contracts
if msg.InstantiatePermission.Permission == AccessTypeOnlyAddress {
return ErrInvalid.Wrap("unsupported type, use AccessTypeAnyOfAddresses instead")
}
Expand Down Expand Up @@ -423,6 +425,11 @@ func (msg MsgUpdateInstantiateConfig) ValidateBasic() error {
if err := msg.NewInstantiatePermission.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "instantiate permission")
}
// AccessTypeOnlyAddress is still considered valid as legacy instantiation permission
// but not for new contracts
if msg.NewInstantiatePermission.Permission == AccessTypeOnlyAddress {
return ErrInvalid.Wrap("unsupported type, use AccessTypeAnyOfAddresses instead")
}

return nil
}
Expand Down
14 changes: 11 additions & 3 deletions x/wasm/types/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,32 +693,40 @@ func TestMsgUpdateInstantiateConfig(t *testing.T) {
expErr bool
}{
"all good": {
src: MsgUpdateInstantiateConfig{
Sender: goodAddress,
CodeID: 1,
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{anotherGoodAddress}},
},
},
"retained AccessTypeOnlyAddress": {
src: MsgUpdateInstantiateConfig{
Sender: goodAddress,
CodeID: 1,
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeOnlyAddress, Address: anotherGoodAddress},
},
expErr: true,
},
"bad sender": {
src: MsgUpdateInstantiateConfig{
Sender: badAddress,
CodeID: 1,
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeOnlyAddress, Address: anotherGoodAddress},
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{anotherGoodAddress}},
},
expErr: true,
},
"invalid NewInstantiatePermission": {
src: MsgUpdateInstantiateConfig{
Sender: goodAddress,
CodeID: 1,
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeOnlyAddress, Address: badAddress},
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{badAddress}},
},
expErr: true,
},
"missing code id": {
src: MsgUpdateInstantiateConfig{
Sender: goodAddress,
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeOnlyAddress, Address: anotherGoodAddress},
NewInstantiatePermission: &AccessConfig{Permission: AccessTypeAnyOfAddresses, Addresses: []string{anotherGoodAddress}},
},
expErr: true,
},
Expand Down

0 comments on commit a6a48ea

Please sign in to comment.