Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uibc): ICS20 hooks gov switch #2459

Merged
merged 8 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions proto/umee/uibc/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ message EventBadRevert {
message EventIBCTransferStatus {
IBCTransferStatus status = 1;
}

// EventICS20Hooks is emitted on MsgGovToggleICS20Hooks.
message EventICS20Hooks {
bool enabled = 1;
}
2 changes: 2 additions & 0 deletions proto/umee/uibc/v1/quota.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ message Params {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// ics20_hooks enables or disables the ICS20 transfer hooks.
bool ics20_hooks = 8;
}

// IBCTransferStatus status of ibc-transfer quota check for inflow and outflow
Expand Down
25 changes: 24 additions & 1 deletion proto/umee/uibc/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ service Msg {

// GovSetIBCStatus sets IBC ICS20 status. Must be called by x/gov.
rpc GovSetIBCStatus(MsgGovSetIBCStatus) returns (MsgGovSetIBCStatusResponse);

// GovToggleICS20Hooks enables / disables ICS20 hooks support. Must be called by x/gov.
rpc GovToggleICS20Hooks(MsgGovToggleICS20Hooks) returns (MsgGovToggleICS20HooksResponse);
}

// MsgGovUpdateQuota defines the Msg/GovUpdateQuota request type.
Expand Down Expand Up @@ -100,5 +103,25 @@ message MsgGovSetIBCStatus {
IBCTransferStatus ibc_status = 4;
}

// MsgGovSetIBCStatusResponse define the response type for Msg/MsgGovSetIBCStatus with x/gov proposals.
// MsgGovSetIBCStatusResponse is a response type for Msg/GovSetIBCStatus.
message MsgGovSetIBCStatusResponse {}

// MsgGovToggleICS20Hooks is a request type for GovToggleICS20Hooks handler.
message MsgGovToggleICS20Hooks {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account or the Emergency Group.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// description motivating the change. Should be used only when executing by the
// Emergency Group. Otherwise the x/gov Proposal metadata should be used.
string description = 2;

// enabled defines if the IBC transfer hooks should be enabled or disabled.
bool enabled = 3;
}

// MsgGovToggleICS20HooksResponse is a response type for Msg/GovToggleICS20Hooks.
message MsgGovToggleICS20HooksResponse {}
9 changes: 9 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3661,6 +3661,9 @@ paths:
title: >-
inflow_outflow_token_quota_base defines the inflow outflow
quota base for token
ics20_hooks:
type: boolean
description: ics20_hooks enables or disables the ICS20 transfer hooks.
title: Params of x/uibc module
description: >-
QueryParamsResponse defines the response structure for the Params
Expand Down Expand Up @@ -9212,6 +9215,9 @@ definitions:
title: >-
inflow_outflow_token_quota_base defines the inflow outflow quota base
for token
ics20_hooks:
type: boolean
description: ics20_hooks enables or disables the ICS20 transfer hooks.
title: Params of x/uibc module
umee.uibc.v1.QueryAllOutflowsResponse:
type: object
Expand Down Expand Up @@ -9305,6 +9311,9 @@ definitions:
title: >-
inflow_outflow_token_quota_base defines the inflow outflow quota
base for token
ics20_hooks:
type: boolean
description: ics20_hooks enables or disables the ICS20 transfer hooks.
title: Params of x/uibc module
description: |-
QueryParamsResponse defines the response structure for the Params gRPC
Expand Down
15 changes: 15 additions & 0 deletions tests/tcheckers/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package tcheckers

import (
"testing"

"gotest.tools/v3/assert"
)

func ErrorContains(t *testing.T, err error, expectedErr, testName string) {
if expectedErr == "" {
assert.NilError(t, err, testName)
} else {
assert.ErrorContains(t, err, expectedErr, testName)
}
}
192 changes: 174 additions & 18 deletions x/uibc/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions x/uibc/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
var (
_ sdk.Msg = &MsgGovUpdateQuota{}
_ sdk.Msg = &MsgGovSetIBCStatus{}
_ sdk.Msg = &MsgGovToggleICS20Hooks{}
)

//
Expand Down Expand Up @@ -87,3 +88,31 @@ func (msg *MsgGovSetIBCStatus) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}

//
// MsgGovToggleICS20Hooks
//

// String implements the Stringer interface.
func (msg *MsgGovToggleICS20Hooks) String() string {
out, _ := json.Marshal(msg)
return string(out)
}

// ValidateBasic implements Msg
func (msg *MsgGovToggleICS20Hooks) ValidateBasic() error {
return checkers.Proposal(msg.Authority, msg.Description)
}

// GetSigners implements Msg
func (msg *MsgGovToggleICS20Hooks) GetSigners() []sdk.AccAddress {
return checkers.Signers(msg.Authority)
}

// LegacyMsg.Type implementations
func (msg MsgGovToggleICS20Hooks) Route() string { return "" }
func (msg MsgGovToggleICS20Hooks) Type() string { return sdk.MsgTypeURL(&msg) }
func (msg *MsgGovToggleICS20Hooks) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
Loading
Loading