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 7 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
23 changes: 23 additions & 0 deletions proto/umee/uibc/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

// 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 @@ -102,3 +105,23 @@

// MsgGovSetIBCStatusResponse define the response type for Msg/MsgGovSetIBCStatus with x/gov proposals.
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;
}


message MsgGovToggleICS20HooksResponse{}

Check failure on line 127 in proto/umee/uibc/v1/tx.proto

View workflow job for this annotation

GitHub Actions / buf-lint

Message "MsgGovToggleICS20HooksResponse" should have a non-empty comment for documentation.
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
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