diff --git a/CHANGELOG.md b/CHANGELOG.md index 601d0ccd54..59c8f158e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - [cronos#742](https://github.com/crypto-org-chain/cronos/pull/742) Add upgrade handler for v0.8.0-gravity-alpha2. - [cronos#750](https://github.com/crypto-org-chain/cronos/pull/750) Add upgrade handler for v0.8.0-gravity-alpha3. - [cronos#769](https://github.com/crypto-org-chain/cronos/pull/769) Prevent cancellation function to be called outside the scope of the contract that manage it. +- [cronos#775](https://github.com/crypto-org-chain/cronos/pull/775) Support turnbridge transaction. ### Improvements diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index 5fd158dbeb..10423c780d 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -1404,3 +1404,29 @@ def query_grant(self, granter, grantee): home=self.data_dir, ) ) + + def query_batches(self): + "query all gravity batches" + return json.loads( + self.raw( + "query", + "gravity", + "batch-txs", + home=self.data_dir, + ) + ) + + def turn_bridge(self, enable, **kwargs): + kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) + kwargs.setdefault("gas", DEFAULT_GAS) + return json.loads( + self.raw( + "tx", + "cronos", + "turn-bridge", + enable, + "-y", + home=self.data_dir, + **kwargs, + ) + ) diff --git a/integration_tests/test_gravity.py b/integration_tests/test_gravity.py index 998a97afce..fca8adf0a5 100644 --- a/integration_tests/test_gravity.py +++ b/integration_tests/test_gravity.py @@ -795,3 +795,74 @@ def check(): gravity.contract.functions.redeemVoucher( old_nonce, ADDRS["signer2"] ).build_transaction({"from": ADDRS["signer1"]}) + + +def test_gravity_turn_bridge(gravity): + geth = gravity.geth + cli = gravity.cronos.cosmos_cli() + cronos_w3 = gravity.cronos.w3 + + # deploy test erc20 contract + erc20 = deploy_contract( + geth, + CONTRACTS["TestERC20A"], + ) + + balance = erc20.caller.balanceOf(ADDRS["validator"]) + assert balance == 100000000000000000000000000 + amount = 1000 + + print("send to cronos crc20") + recipient = HexBytes(ADDRS["community"]) + txreceipt = send_to_cosmos( + gravity.contract, erc20, geth, recipient, amount, KEYS["validator"] + ) + assert txreceipt.status == 1, "should success" + assert erc20.caller.balanceOf(ADDRS["validator"]) == balance - amount + + denom = f"gravity{erc20.address}" + + def check_gravity_native_tokens(): + "check the balance of gravity native token" + return cli.balance(eth_to_bech32(recipient), denom=denom) == amount + + if gravity.cronos.enable_auto_deployment: + crc21_contract = None + + def local_check_auto_deployment(): + nonlocal crc21_contract + crc21_contract = check_auto_deployment( + cli, denom, cronos_w3, recipient, amount + ) + return crc21_contract + + wait_for_fn("send-to-crc21", local_check_auto_deployment) + else: + wait_for_fn("send-to-gravity-native", check_gravity_native_tokens) + + # turn off bridge + rsp = cli.turn_bridge("false", from_="community") + assert rsp["code"] != 0, "should not have the permission" + + rsp = cli.turn_bridge("false", from_="validator") + assert rsp["code"] == 0, rsp["raw_log"] + wait_for_new_blocks(cli, 1) + + if gravity.cronos.enable_auto_deployment: + # send it back to erc20, should fail + tx = crc21_contract.functions.send_to_evm_chain( + ADDRS["validator"], amount, 1, 0, b"" + ).build_transaction({"from": ADDRS["community"]}) + txreceipt = send_transaction(cronos_w3, tx, KEYS["community"]) + assert txreceipt.status == 0, "should fail" + else: + # send back the gravity native tokens, should fail + rsp = cli.send_to_ethereum( + ADDRS["validator"], f"{amount}{denom}", f"0{denom}", from_="community" + ) + assert rsp["code"] == 3, rsp["raw_log"] + + wait_for_new_blocks(cli, 10) + # check no new batch is created + rsp = cli.query_batches() + assert len(rsp["batches"]) == 0 diff --git a/proto/cronos/tx.proto b/proto/cronos/tx.proto index d3dc87627c..ae4c7812b5 100644 --- a/proto/cronos/tx.proto +++ b/proto/cronos/tx.proto @@ -10,31 +10,43 @@ option go_package = "github.com/crypto-org-chain/cronos/x/cronos/types"; // Msg defines the Cronos Msg service service Msg { - // this line is used by starport scaffolding # proto/tx/rpc + // this line is used by starport scaffolding # proto/tx/rpc - // ConvertVouchers defines a method for converting ibc voucher to cronos evm coins. - rpc ConvertVouchers(MsgConvertVouchers) returns (MsgConvertVouchersResponse); + // ConvertVouchers defines a method for converting ibc voucher to cronos evm + // coins. + rpc ConvertVouchers(MsgConvertVouchers) returns (MsgConvertVouchersResponse); - // TransferTokens defines a method to transfer cronos evm coins to another chain through IBC - rpc TransferTokens(MsgTransferTokens) returns (MsgTransferTokensResponse); + // TransferTokens defines a method to transfer cronos evm coins to another + // chain through IBC + rpc TransferTokens(MsgTransferTokens) returns (MsgTransferTokensResponse); - // UpdateTokenMapping defines a method to update token mapping - rpc UpdateTokenMapping(MsgUpdateTokenMapping) returns (MsgUpdateTokenMappingResponse); + // UpdateTokenMapping defines a method to update token mapping + rpc UpdateTokenMapping(MsgUpdateTokenMapping) + returns (MsgUpdateTokenMappingResponse); + + // TurnBridge defines a method to disable or enable the gravity bridge + rpc TurnBridge(MsgTurnBridge) returns (MsgTurnBridgeResponse); } -// MsgConvertVouchers represents a message to convert ibc voucher coins to cronos evm coins. +// MsgConvertVouchers represents a message to convert ibc voucher coins to +// cronos evm coins. message MsgConvertVouchers { - string address = 1; - repeated cosmos.base.v1beta1.Coin coins = 2 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + string address = 1; + repeated cosmos.base.v1beta1.Coin coins = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } -// MsgTransferTokens represents a message to transfer cronos evm coins through ibc. +// MsgTransferTokens represents a message to transfer cronos evm coins through +// ibc. message MsgTransferTokens { - string from = 1; - string to = 2; - repeated cosmos.base.v1beta1.Coin coins = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + string from = 1; + string to = 2; + repeated cosmos.base.v1beta1.Coin coins = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } // MsgConvertVouchersResponse defines the ConvertVouchers response type. @@ -45,16 +57,24 @@ message MsgTransferTokensResponse {} // MsgUpdateTokenMapping defines the request type message MsgUpdateTokenMapping { - string sender = 1; - string denom = 2; - string contract = 3; - // only when updating cronos (source) tokens - string symbol = 4; - uint32 decimal = 5; + string sender = 1; + string denom = 2; + string contract = 3; + // only when updating cronos (source) tokens + string symbol = 4; + uint32 decimal = 5; } // MsgUpdateTokenMappingResponse defines the response type -message MsgUpdateTokenMappingResponse { +message MsgUpdateTokenMappingResponse {} + +// MsgTurnBridge defines the request type +message MsgTurnBridge { + string sender = 1; + bool enable = 2; } +// MsgTurnBridgegResponse defines the response type +message MsgTurnBridgeResponse {} + // this line is used by starport scaffolding # proto/tx/message diff --git a/x/cronos/client/cli/tx.go b/x/cronos/client/cli/tx.go index b5c46ced10..5ffe969698 100644 --- a/x/cronos/client/cli/tx.go +++ b/x/cronos/client/cli/tx.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "strings" "github.com/cosmos/cosmos-sdk/client/flags" @@ -34,6 +35,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdConvertTokens()) cmd.AddCommand(CmdSendToCryptoOrg()) cmd.AddCommand(CmdUpdateTokenMapping()) + cmd.AddCommand(CmdTurnBridge()) return cmd } @@ -249,3 +251,31 @@ func CmdUpdateTokenMapping() *cobra.Command { return cmd } + +// CmdTurnBridge returns a CLI command handler for enable or disable the bridge +func CmdTurnBridge() *cobra.Command { + cmd := &cobra.Command{ + Use: "turn-bridge [true/false]", + Short: "Turn Bridge", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + enable, err := strconv.ParseBool(args[0]) + if err != nil { + return err + } + msg := types.NewMsgTurnBridge(clientCtx.GetFromAddress().String(), enable) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/cronos/handler.go b/x/cronos/handler.go index 970ffe30ab..97202b3160 100644 --- a/x/cronos/handler.go +++ b/x/cronos/handler.go @@ -22,13 +22,15 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgConvertVouchers: res, err := msgServer.ConvertVouchers(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgTransferTokens: res, err := msgServer.TransferTokens(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) case *types.MsgUpdateTokenMapping: res, err := msgServer.UpdateTokenMapping(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgTurnBridge: + res, err := msgServer.TurnBridge(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/cronos/keeper/msg_server.go b/x/cronos/keeper/msg_server.go index b5ee654582..91c085044e 100644 --- a/x/cronos/keeper/msg_server.go +++ b/x/cronos/keeper/msg_server.go @@ -73,3 +73,19 @@ func (k msgServer) UpdateTokenMapping(goCtx context.Context, msg *types.MsgUpdat } return &types.MsgUpdateTokenMappingResponse{}, nil } + +// TurnBridge implements the grpc method +func (k msgServer) TurnBridge(goCtx context.Context, msg *types.MsgTurnBridge) (*types.MsgTurnBridgeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + admin := k.Keeper.GetParams(ctx).CronosAdmin + // if admin is empty, no sender could be equal to it + if admin != msg.Sender { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "msg sender is authorized") + } + + gravityParams := k.gravityKeeper.GetParams(ctx) + gravityParams.BridgeActive = msg.Enable + k.gravityKeeper.SetParams(ctx, gravityParams) + + return &types.MsgTurnBridgeResponse{}, nil +} diff --git a/x/cronos/types/events.go b/x/cronos/types/events.go index 6ac349ea35..f9a27619dd 100644 --- a/x/cronos/types/events.go +++ b/x/cronos/types/events.go @@ -22,7 +22,7 @@ const ( ) // NewConvertVouchersEvent constructs a new voucher convert sdk.Event -//nolint: interfacer +// nolint: interfacer func NewConvertVouchersEvent(sender string, amount fmt.Stringer) sdk.Event { return sdk.NewEvent( EventTypeConvertVouchers, diff --git a/x/cronos/types/interfaces.go b/x/cronos/types/interfaces.go index b67ccd181d..f7daa78926 100644 --- a/x/cronos/types/interfaces.go +++ b/x/cronos/types/interfaces.go @@ -59,6 +59,7 @@ type GravityKeeper interface { ERC20ToDenomLookup(ctx sdk.Context, tokenContract common.Address) (bool, string) IterateUnbatchedSendToEthereums(ctx sdk.Context, cb func(*gravitytypes.SendToEthereum) bool) GetParams(ctx sdk.Context) (params gravitytypes.Params) + SetParams(ctx sdk.Context, params gravitytypes.Params) } // EvmLogHandler defines the interface for evm log handler diff --git a/x/cronos/types/messages.go b/x/cronos/types/messages.go index 18dbac0ad3..75838de250 100644 --- a/x/cronos/types/messages.go +++ b/x/cronos/types/messages.go @@ -10,6 +10,7 @@ const ( TypeMsgConvertVouchers = "ConvertVouchers" TypeMsgTransferTokens = "TransferTokens" TypeMsgUpdateTokenMapping = "UpdateTokenMapping" + TypeTurnBridge = "TurnBridge" ) var _ sdk.Msg = &MsgConvertVouchers{} @@ -171,3 +172,48 @@ func (msg *MsgUpdateTokenMapping) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } + +var _ sdk.Msg = &MsgTurnBridge{} + +// NewMsgTurnBridge ... +func NewMsgTurnBridge(admin string, enable bool) *MsgTurnBridge { + return &MsgTurnBridge{ + Sender: admin, + Enable: enable, + } +} + +// GetSigners ... +func (msg *MsgTurnBridge) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +// ValidateBasic ... +func (msg *MsgTurnBridge) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} + +// Route ... +func (msg MsgTurnBridge) Route() string { + return RouterKey +} + +// Type ... +func (msg MsgTurnBridge) Type() string { + return TypeTurnBridge +} + +// GetSignBytes ... +func (msg *MsgTurnBridge) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} diff --git a/x/cronos/types/tx.pb.go b/x/cronos/types/tx.pb.go index 388bfa77d3..33f4d755b6 100644 --- a/x/cronos/types/tx.pb.go +++ b/x/cronos/types/tx.pb.go @@ -333,6 +333,96 @@ func (m *MsgUpdateTokenMappingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateTokenMappingResponse proto.InternalMessageInfo +// MsgTurnBridge defines the request type +type MsgTurnBridge struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Enable bool `protobuf:"varint,2,opt,name=enable,proto3" json:"enable,omitempty"` +} + +func (m *MsgTurnBridge) Reset() { *m = MsgTurnBridge{} } +func (m *MsgTurnBridge) String() string { return proto.CompactTextString(m) } +func (*MsgTurnBridge) ProtoMessage() {} +func (*MsgTurnBridge) Descriptor() ([]byte, []int) { + return fileDescriptor_28e09e4eabb18884, []int{6} +} +func (m *MsgTurnBridge) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTurnBridge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTurnBridge.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgTurnBridge) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTurnBridge.Merge(m, src) +} +func (m *MsgTurnBridge) XXX_Size() int { + return m.Size() +} +func (m *MsgTurnBridge) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTurnBridge.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTurnBridge proto.InternalMessageInfo + +func (m *MsgTurnBridge) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgTurnBridge) GetEnable() bool { + if m != nil { + return m.Enable + } + return false +} + +// MsgTurnBridgegResponse defines the response type +type MsgTurnBridgeResponse struct { +} + +func (m *MsgTurnBridgeResponse) Reset() { *m = MsgTurnBridgeResponse{} } +func (m *MsgTurnBridgeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTurnBridgeResponse) ProtoMessage() {} +func (*MsgTurnBridgeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_28e09e4eabb18884, []int{7} +} +func (m *MsgTurnBridgeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTurnBridgeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTurnBridgeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgTurnBridgeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTurnBridgeResponse.Merge(m, src) +} +func (m *MsgTurnBridgeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTurnBridgeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTurnBridgeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTurnBridgeResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgConvertVouchers)(nil), "cronos.MsgConvertVouchers") proto.RegisterType((*MsgTransferTokens)(nil), "cronos.MsgTransferTokens") @@ -340,42 +430,47 @@ func init() { proto.RegisterType((*MsgTransferTokensResponse)(nil), "cronos.MsgTransferTokensResponse") proto.RegisterType((*MsgUpdateTokenMapping)(nil), "cronos.MsgUpdateTokenMapping") proto.RegisterType((*MsgUpdateTokenMappingResponse)(nil), "cronos.MsgUpdateTokenMappingResponse") + proto.RegisterType((*MsgTurnBridge)(nil), "cronos.MsgTurnBridge") + proto.RegisterType((*MsgTurnBridgeResponse)(nil), "cronos.MsgTurnBridgeResponse") } func init() { proto.RegisterFile("cronos/tx.proto", fileDescriptor_28e09e4eabb18884) } var fileDescriptor_28e09e4eabb18884 = []byte{ - // 476 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x8d, 0x9d, 0x26, 0xc0, 0x20, 0x5a, 0xb1, 0x2a, 0xc8, 0x31, 0xd4, 0x09, 0x96, 0x90, 0x72, - 0x89, 0x4d, 0xca, 0x1f, 0xb4, 0x47, 0x64, 0x24, 0xa2, 0xc2, 0xa1, 0xb7, 0xb5, 0xbd, 0x75, 0xac, - 0xd6, 0x3b, 0xd6, 0xce, 0xb6, 0x6a, 0xee, 0x7c, 0x00, 0x88, 0x1b, 0x9f, 0xc0, 0x97, 0xf4, 0xd8, - 0x23, 0x27, 0x40, 0xc9, 0x8f, 0xa0, 0xac, 0xed, 0x10, 0x9a, 0x96, 0x1b, 0xa7, 0x9d, 0x37, 0x4f, - 0xf3, 0xe6, 0xed, 0xec, 0x2c, 0xec, 0x24, 0x0a, 0x25, 0x52, 0xa8, 0x2f, 0x83, 0x52, 0xa1, 0x46, - 0xd6, 0xad, 0x12, 0xee, 0x6e, 0x86, 0x19, 0x9a, 0x54, 0xb8, 0x8c, 0x2a, 0xd6, 0xf5, 0x12, 0xa4, - 0x02, 0x29, 0x8c, 0x39, 0x89, 0xf0, 0x62, 0x1c, 0x0b, 0xcd, 0xc7, 0x61, 0x82, 0xb9, 0xac, 0x78, - 0xff, 0xb3, 0x05, 0x2c, 0xa2, 0xec, 0x10, 0xe5, 0x85, 0x50, 0xfa, 0x03, 0x9e, 0x27, 0x53, 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, 0xc6, 0x33, 0x67, 0xab, 0x56, 0x32, 0x68, 0xf9, 0xa0, 0xa9, - 0x48, 0xf2, 0x82, 0x9f, 0x39, 0x9d, 0x81, 0x35, 0x7c, 0x34, 0x69, 0xa0, 0xdf, 0x87, 0xbd, 0x5b, - 0x4d, 0x35, 0xb6, 0xf7, 0x3f, 0xda, 0xd0, 0x8e, 0x28, 0x63, 0xef, 0x60, 0xe7, 0xe6, 0x9a, 0xb8, - 0x41, 0xb5, 0x7c, 0xc1, 0xe6, 0x48, 0x5c, 0xff, 0x6e, 0xae, 0x91, 0x66, 0x6f, 0x61, 0xfb, 0xc6, - 0x2b, 0xf7, 0xd6, 0xaa, 0xfe, 0xa6, 0xdc, 0x17, 0x77, 0x52, 0x2b, 0xbd, 0x63, 0x60, 0xb7, 0x4c, - 0x77, 0x6f, 0xad, 0x70, 0x93, 0x76, 0x5f, 0xfe, 0x93, 0x6e, 0xb4, 0x0f, 0xde, 0x5c, 0xcd, 0x3d, - 0xeb, 0x7a, 0xee, 0x59, 0xbf, 0xe6, 0x9e, 0xf5, 0x69, 0xe1, 0xb5, 0xae, 0x17, 0x5e, 0xeb, 0xfb, - 0xc2, 0x6b, 0x1d, 0x8f, 0xd7, 0x77, 0x48, 0xcd, 0x4a, 0x8d, 0x23, 0x54, 0xd9, 0x28, 0x99, 0xf2, - 0x5c, 0x86, 0xf5, 0x77, 0xbd, 0x6c, 0x02, 0xb3, 0x52, 0x71, 0xd7, 0xfc, 0xbe, 0xd7, 0xbf, 0x03, - 0x00, 0x00, 0xff, 0xff, 0xb5, 0xc9, 0xbb, 0xc5, 0xce, 0x03, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0x93, 0x26, 0x94, 0x41, 0x6d, 0xc5, 0xaa, 0x2d, 0x8e, 0x21, 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0x86, 0x32, 0x22, 0x1f, 0xe0, 0xe8, + 0xe1, 0x01, 0x5a, 0x6e, 0x76, 0xd6, 0xee, 0xe6, 0xb2, 0x2d, 0x67, 0x37, 0x57, 0x48, 0x93, 0xf7, + 0x70, 0xf8, 0xe0, 0x7e, 0x9a, 0x6b, 0x55, 0x7f, 0x53, 0xd6, 0xcb, 0x9d, 0x54, 0xa9, 0x77, 0x09, + 0x64, 0xcb, 0x7f, 0x6b, 0xad, 0x15, 0x6e, 0xd2, 0xd6, 0xab, 0x7f, 0xd2, 0xa5, 0xf6, 0x00, 0x60, + 0x6d, 0xbb, 0x27, 0xeb, 0x66, 0xca, 0xb4, 0xd5, 0xda, 0x9a, 0x2e, 0x34, 0x06, 0xef, 0xe6, 0x0b, + 0xdb, 0xb8, 0x5b, 0xd8, 0xc6, 0xef, 0x85, 0x6d, 0x7c, 0x5e, 0xda, 0x95, 0xbb, 0xa5, 0x5d, 0xf9, + 0xb1, 0xb4, 0x2b, 0x97, 0xfd, 0xf5, 0x0b, 0x17, 0xb3, 0x54, 0x61, 0x0f, 0x45, 0xd4, 0x0b, 0xc6, + 0x34, 0xe6, 0x5e, 0xfe, 0x98, 0xdc, 0x16, 0x81, 0x3e, 0x78, 0xbf, 0xa1, 0xdf, 0x86, 0x37, 0x7f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x15, 0xce, 0x5b, 0x6c, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -396,6 +491,8 @@ type MsgClient interface { TransferTokens(ctx context.Context, in *MsgTransferTokens, opts ...grpc.CallOption) (*MsgTransferTokensResponse, error) // UpdateTokenMapping defines a method to update token mapping UpdateTokenMapping(ctx context.Context, in *MsgUpdateTokenMapping, opts ...grpc.CallOption) (*MsgUpdateTokenMappingResponse, error) + // TurnBridge defines a method to disable or enable the gravity bridge + TurnBridge(ctx context.Context, in *MsgTurnBridge, opts ...grpc.CallOption) (*MsgTurnBridgeResponse, error) } type msgClient struct { @@ -433,6 +530,15 @@ func (c *msgClient) UpdateTokenMapping(ctx context.Context, in *MsgUpdateTokenMa return out, nil } +func (c *msgClient) TurnBridge(ctx context.Context, in *MsgTurnBridge, opts ...grpc.CallOption) (*MsgTurnBridgeResponse, error) { + out := new(MsgTurnBridgeResponse) + err := c.cc.Invoke(ctx, "/cronos.Msg/TurnBridge", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // ConvertVouchers defines a method for converting ibc voucher to cronos evm coins. @@ -441,6 +547,8 @@ type MsgServer interface { TransferTokens(context.Context, *MsgTransferTokens) (*MsgTransferTokensResponse, error) // UpdateTokenMapping defines a method to update token mapping UpdateTokenMapping(context.Context, *MsgUpdateTokenMapping) (*MsgUpdateTokenMappingResponse, error) + // TurnBridge defines a method to disable or enable the gravity bridge + TurnBridge(context.Context, *MsgTurnBridge) (*MsgTurnBridgeResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -456,6 +564,9 @@ func (*UnimplementedMsgServer) TransferTokens(ctx context.Context, req *MsgTrans func (*UnimplementedMsgServer) UpdateTokenMapping(ctx context.Context, req *MsgUpdateTokenMapping) (*MsgUpdateTokenMappingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateTokenMapping not implemented") } +func (*UnimplementedMsgServer) TurnBridge(ctx context.Context, req *MsgTurnBridge) (*MsgTurnBridgeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TurnBridge not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -515,6 +626,24 @@ func _Msg_UpdateTokenMapping_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_TurnBridge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTurnBridge) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).TurnBridge(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cronos.Msg/TurnBridge", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).TurnBridge(ctx, req.(*MsgTurnBridge)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cronos.Msg", HandlerType: (*MsgServer)(nil), @@ -531,6 +660,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateTokenMapping", Handler: _Msg_UpdateTokenMapping_Handler, }, + { + MethodName: "TurnBridge", + Handler: _Msg_TurnBridge_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cronos/tx.proto", @@ -756,6 +889,69 @@ func (m *MsgUpdateTokenMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgTurnBridge) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgTurnBridge) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTurnBridge) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Enable { + i-- + if m.Enable { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTurnBridgeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgTurnBridgeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTurnBridgeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -864,6 +1060,31 @@ func (m *MsgUpdateTokenMappingResponse) Size() (n int) { return n } +func (m *MsgTurnBridge) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Enable { + n += 2 + } + return n +} + +func (m *MsgTurnBridgeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1481,6 +1702,158 @@ func (m *MsgUpdateTokenMappingResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgTurnBridge) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgTurnBridge: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTurnBridge: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enable", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enable = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgTurnBridgeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgTurnBridgeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTurnBridgeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0