diff --git a/proto/ununifi/eventhook/eventhook.proto b/proto/ununifi/eventhook/eventhook.proto index e421007b1..3c0839a78 100644 --- a/proto/ununifi/eventhook/eventhook.proto +++ b/proto/ununifi/eventhook/eventhook.proto @@ -2,16 +2,15 @@ syntax = "proto3"; package nftvault.eventhook; import "gogoproto/gogo.proto"; -import "ununifi/eventhook/params.proto"; option go_package = "github.com/UnUniFi/chain/x/eventhook/types"; message Hook { uint64 id = 1; - string event_type = 2; + string name = 2; string contract_address = 3; - string name = 4; - string git_url = 5; + string git_url = 4; + string event_type = 5; repeated KeyValuePair event_attributes = 6; } diff --git a/proto/ununifi/eventhook/proposal.proto b/proto/ununifi/eventhook/proposal.proto deleted file mode 100644 index 9a8005827..000000000 --- a/proto/ununifi/eventhook/proposal.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; -package nftvault.eventhook; - -import "gogoproto/gogo.proto"; -import "ununifi/eventhook/eventhook.proto"; - -option go_package = "github.com/UnUniFi/chain/x/eventhook/types"; - -// proposal to add new hook -message ProposalAddHook { - string title = 1; - string description = 2; - string event_type = 3; - string contract_address = 4; - string name = 5; - string git_url = 6; - repeated KeyValuePair event_attributes = 7; -} diff --git a/proto/ununifi/eventhook/tx.proto b/proto/ununifi/eventhook/tx.proto index 9969dbbef..f6d29db4d 100644 --- a/proto/ununifi/eventhook/tx.proto +++ b/proto/ununifi/eventhook/tx.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package nftvault.eventhook; +import "ununifi/eventhook/eventhook.proto"; // this line is used by starport scaffolding # proto/tx/import option go_package = "github.com/UnUniFi/chain/x/eventhook/types"; @@ -8,6 +9,29 @@ option go_package = "github.com/UnUniFi/chain/x/eventhook/types"; // Msg defines the Msg service. service Msg { // this line is used by starport scaffolding # proto/tx/rpc + rpc RegisterHook(MsgRegisterHook) returns (MsgRegisterHookResponse); + rpc UnregisterHook(MsgUnregisterHook) returns (MsgUnregisterHookResponse); } // this line is used by starport scaffolding # proto/tx/message +message MsgRegisterHook { + string sender = 1; + string name = 2; + string contract_address = 3; + string git_url = 4; + string event_type = 5; + repeated KeyValuePair event_attributes = 6; +} + +message MsgRegisterHookResponse { + uint64 id = 1; +} + +message MsgUnregisterHook { + string sender = 1; + string event_type = 2; + uint64 id = 3; +} + +message MsgUnregisterHookResponse { +} diff --git a/x/eventhook/keeper/abci.go b/x/eventhook/keeper/abci.go index 7a04b4b01..00d25987e 100644 --- a/x/eventhook/keeper/abci.go +++ b/x/eventhook/keeper/abci.go @@ -1,9 +1,13 @@ package keeper import ( + "encoding/json" + abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/UnUniFi/chain/x/eventhook/types" ) @@ -26,8 +30,26 @@ func inspectEventForHook(event sdk.Event, hook types.Hook) bool { return true } +type EventHookMsg struct { + EventType string `json:"event_type"` + EventAttributes []*types.KeyValuePair `json:"event_attributes"` +} + func (k Keeper) CallHook(ctx sdk.Context, event sdk.Event, hook types.Hook) { - // TODO: call cosmwasm contract + contractAddr := sdk.MustAccAddressFromBech32(hook.ContractAddress) + address := authtypes.NewModuleAddress(types.ModuleName) + wasmMsg, err := json.Marshal(EventHookMsg{ + EventType: hook.EventType, + EventAttributes: hook.EventAttributes, + }) + if err != nil { + k.Logger(ctx).Debug("failed to marshal wasm msg", "error", err) + } + + _, err = k.wasmKeeper.Execute(ctx, contractAddr, address, []byte(wasmMsg), sdk.Coins{}) + if err != nil { + k.Logger(ctx).Debug("failed to execute wasm contract", "error", err) + } } func (k Keeper) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { diff --git a/x/eventhook/keeper/keeper.go b/x/eventhook/keeper/keeper.go index b3743771c..42f12261c 100644 --- a/x/eventhook/keeper/keeper.go +++ b/x/eventhook/keeper/keeper.go @@ -7,38 +7,34 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/UnUniFi/chain/x/eventhook/types" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + + wasmKeeper wasmtypes.ContractOpsKeeper + authority string } ) func NewKeeper( cdc codec.BinaryCodec, - storeKey, - memKey storetypes.StoreKey, - ps paramtypes.Subspace, - + storeKey storetypes.StoreKey, + wasmKeeper wasmtypes.ContractOpsKeeper, + authority string, ) *Keeper { - // set KeyTable if it has not already been set - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } return &Keeper{ - cdc: cdc, storeKey: storeKey, - memKey: memKey, - paramstore: ps, + wasmKeeper: wasmKeeper, + authority: authority, } } diff --git a/x/eventhook/keeper/msg_server_register_hook.go b/x/eventhook/keeper/msg_server_register_hook.go new file mode 100644 index 000000000..e54321084 --- /dev/null +++ b/x/eventhook/keeper/msg_server_register_hook.go @@ -0,0 +1,31 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/UnUniFi/chain/x/eventhook/types" +) + +func (k msgServer) RegisterHook(goCtx context.Context, msg *types.MsgRegisterHook) (*types.MsgRegisterHookResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.Sender != k.authority { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "unauthorized") + } + + hook := types.Hook{ + Name: msg.Name, + ContractAddress: msg.ContractAddress, + GitUrl: msg.GitUrl, + EventType: msg.EventType, + EventAttributes: msg.EventAttributes, + } + id := k.AppendHook(ctx, msg.EventType, hook) + + return &types.MsgRegisterHookResponse{ + Id: id, + }, nil +} diff --git a/x/eventhook/keeper/msg_server_unregister_hook.go b/x/eventhook/keeper/msg_server_unregister_hook.go new file mode 100644 index 000000000..824fd1574 --- /dev/null +++ b/x/eventhook/keeper/msg_server_unregister_hook.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/UnUniFi/chain/x/eventhook/types" +) + +func (k msgServer) UnregisterHook(goCtx context.Context, msg *types.MsgUnregisterHook) (*types.MsgUnregisterHookResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.Sender != k.authority { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "unauthorized") + } + + _, found := k.GetHook(ctx, msg.EventType, msg.Id) + + if !found { + return nil, sdkerrors.Wrap(types.ErrHookNotFound, "hook not found") + } + + k.RemoveHook(ctx, msg.EventType, msg.Id) + + return &types.MsgUnregisterHookResponse{}, nil +} diff --git a/x/eventhook/keeper/params.go b/x/eventhook/keeper/params.go index 220a96b7d..64666ccee 100644 --- a/x/eventhook/keeper/params.go +++ b/x/eventhook/keeper/params.go @@ -13,5 +13,5 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { // SetParams set the params func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) + } diff --git a/x/eventhook/types/errors.go b/x/eventhook/types/errors.go index 339f9d966..84cc2c49f 100644 --- a/x/eventhook/types/errors.go +++ b/x/eventhook/types/errors.go @@ -8,5 +8,5 @@ import ( // x/eventhook module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrHookNotFound = sdkerrors.Register(ModuleName, 1, "hook not found") ) diff --git a/x/eventhook/types/eventhook.pb.go b/x/eventhook/types/eventhook.pb.go index 9979b16e8..c1339237e 100644 --- a/x/eventhook/types/eventhook.pb.go +++ b/x/eventhook/types/eventhook.pb.go @@ -25,10 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Hook struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - EventType string `protobuf:"bytes,2,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - GitUrl string `protobuf:"bytes,5,opt,name=git_url,json=gitUrl,proto3" json:"git_url,omitempty"` + GitUrl string `protobuf:"bytes,4,opt,name=git_url,json=gitUrl,proto3" json:"git_url,omitempty"` + EventType string `protobuf:"bytes,5,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` EventAttributes []*KeyValuePair `protobuf:"bytes,6,rep,name=event_attributes,json=eventAttributes,proto3" json:"event_attributes,omitempty"` } @@ -72,9 +72,9 @@ func (m *Hook) GetId() uint64 { return 0 } -func (m *Hook) GetEventType() string { +func (m *Hook) GetName() string { if m != nil { - return m.EventType + return m.Name } return "" } @@ -86,16 +86,16 @@ func (m *Hook) GetContractAddress() string { return "" } -func (m *Hook) GetName() string { +func (m *Hook) GetGitUrl() string { if m != nil { - return m.Name + return m.GitUrl } return "" } -func (m *Hook) GetGitUrl() string { +func (m *Hook) GetEventType() string { if m != nil { - return m.GitUrl + return m.EventType } return "" } @@ -167,28 +167,28 @@ func init() { func init() { proto.RegisterFile("ununifi/eventhook/eventhook.proto", fileDescriptor_8298502638ea5b43) } var fileDescriptor_8298502638ea5b43 = []byte{ - // 336 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xc1, 0x6a, 0xea, 0x40, - 0x18, 0x85, 0x1d, 0x8d, 0x5e, 0x9c, 0x7b, 0xb9, 0xca, 0x20, 0x34, 0x08, 0x1d, 0x52, 0x57, 0xb6, - 0x8b, 0x04, 0x5a, 0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 0xc0, 0x73, 0xb7, 0xe5, 0x35, 0x86, - 0x7f, 0x2f, 0x3d, 0xff, 0xb8, 0xb4, 0x3f, 0xe6, 0xc5, 0x13, 0x4b, 0x0d, 0x7f, 0x60, 0x42, 0x87, - 0x1d, 0xeb, 0x8f, 0xf6, 0x87, 0x83, 0x6b, 0xfc, 0xef, 0x30, 0x40, 0xba, 0xb8, 0xb1, 0xe4, 0x85, - 0x2d, 0xd9, 0x0e, 0x4b, 0x49, 0x7a, 0xb8, 0xb9, 0x2e, 0xf1, 0x77, 0xc1, 0xea, 0xe3, 0xe6, 0xf6, - 0x6d, 0x4b, 0xd1, 0x66, 0x4b, 0xd1, 0xe7, 0x96, 0xa2, 0xd7, 0x1d, 0xad, 0x6d, 0x76, 0xb4, 0xf6, - 0xbe, 0xa3, 0xb5, 0xe7, 0x8b, 0x44, 0xc0, 0xc2, 0xcc, 0xfc, 0x48, 0xad, 0x82, 0x89, 0x9c, 0x48, - 0x71, 0x27, 0x82, 0x68, 0xc1, 0x84, 0x0c, 0x5e, 0x0e, 0x16, 0x2e, 0x27, 0xcb, 0x67, 0x2d, 0xbb, - 0xf0, 0xd5, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x18, 0x84, 0xaf, 0xef, 0xd0, 0x01, 0x00, 0x00, + // 324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0xc1, 0x4b, 0xc3, 0x30, + 0x14, 0xc6, 0x97, 0xad, 0x9b, 0x2c, 0x8a, 0x1b, 0x61, 0x60, 0x11, 0x0c, 0x75, 0xa7, 0xe9, 0xa1, + 0x05, 0x05, 0xef, 0x13, 0x11, 0x61, 0x17, 0x29, 0xce, 0x83, 0x97, 0x91, 0xb5, 0x59, 0x17, 0xd6, + 0x25, 0x23, 0x7d, 0x19, 0xf6, 0xbf, 0xf0, 0xcf, 0xf2, 0xb8, 0xa3, 0x78, 0x92, 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0x2c, 0x78, 0x6e, 0x4b, 0xb6, 0xc3, 0x52, 0x92, 0x1e, 0x6e, 0xae, 0x4b, 0xfc, 0x53, + 0xb3, 0x7a, 0xdc, 0xde, 0xbd, 0x6f, 0x29, 0xda, 0x6c, 0x29, 0xfa, 0xda, 0x52, 0xf4, 0x56, 0xd0, + 0xda, 0xa6, 0xa0, 0xb5, 0x8f, 0x82, 0xd6, 0x5e, 0x2e, 0x13, 0x01, 0x73, 0x33, 0xf5, 0x23, 0xb5, + 0x0c, 0xc6, 0x72, 0x2c, 0xc5, 0xbd, 0x08, 0xa2, 0x39, 0x13, 0x32, 0x78, 0xdd, 0x3b, 0x47, 0x59, + 0x2d, 0x9b, 0xb6, 0xec, 0x86, 0xaf, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x45, 0xf4, 0x77, + 0xb0, 0x01, 0x00, 0x00, } func (m *Hook) Marshal() (dAtA []byte, err error) { @@ -225,18 +225,18 @@ func (m *Hook) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x32 } } + if len(m.EventType) > 0 { + i -= len(m.EventType) + copy(dAtA[i:], m.EventType) + i = encodeVarintEventhook(dAtA, i, uint64(len(m.EventType))) + i-- + dAtA[i] = 0x2a + } if len(m.GitUrl) > 0 { i -= len(m.GitUrl) copy(dAtA[i:], m.GitUrl) i = encodeVarintEventhook(dAtA, i, uint64(len(m.GitUrl))) i-- - dAtA[i] = 0x2a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintEventhook(dAtA, i, uint64(len(m.Name))) - i-- dAtA[i] = 0x22 } if len(m.ContractAddress) > 0 { @@ -246,10 +246,10 @@ func (m *Hook) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.EventType) > 0 { - i -= len(m.EventType) - copy(dAtA[i:], m.EventType) - i = encodeVarintEventhook(dAtA, i, uint64(len(m.EventType))) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintEventhook(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0x12 } @@ -318,7 +318,7 @@ func (m *Hook) Size() (n int) { if m.Id != 0 { n += 1 + sovEventhook(uint64(m.Id)) } - l = len(m.EventType) + l = len(m.Name) if l > 0 { n += 1 + l + sovEventhook(uint64(l)) } @@ -326,11 +326,11 @@ func (m *Hook) Size() (n int) { if l > 0 { n += 1 + l + sovEventhook(uint64(l)) } - l = len(m.Name) + l = len(m.GitUrl) if l > 0 { n += 1 + l + sovEventhook(uint64(l)) } - l = len(m.GitUrl) + l = len(m.EventType) if l > 0 { n += 1 + l + sovEventhook(uint64(l)) } @@ -416,7 +416,7 @@ func (m *Hook) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EventType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -444,7 +444,7 @@ func (m *Hook) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.EventType = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -480,7 +480,7 @@ func (m *Hook) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GitUrl", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -508,11 +508,11 @@ func (m *Hook) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) + m.GitUrl = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GitUrl", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EventType", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -540,7 +540,7 @@ func (m *Hook) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.GitUrl = string(dAtA[iNdEx:postIndex]) + m.EventType = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 6: if wireType != 2 { diff --git a/x/eventhook/types/tx.pb.go b/x/eventhook/types/tx.pb.go index b01d36ee9..6fe99bb82 100644 --- a/x/eventhook/types/tx.pb.go +++ b/x/eventhook/types/tx.pb.go @@ -9,7 +9,11 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,19 +27,268 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// this line is used by starport scaffolding # proto/tx/message +type MsgRegisterHook struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + GitUrl string `protobuf:"bytes,4,opt,name=git_url,json=gitUrl,proto3" json:"git_url,omitempty"` + EventType string `protobuf:"bytes,5,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` + EventAttributes []*KeyValuePair `protobuf:"bytes,6,rep,name=event_attributes,json=eventAttributes,proto3" json:"event_attributes,omitempty"` +} + +func (m *MsgRegisterHook) Reset() { *m = MsgRegisterHook{} } +func (m *MsgRegisterHook) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterHook) ProtoMessage() {} +func (*MsgRegisterHook) Descriptor() ([]byte, []int) { + return fileDescriptor_20cafb73a0f25f2d, []int{0} +} +func (m *MsgRegisterHook) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterHook) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterHook.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 *MsgRegisterHook) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterHook.Merge(m, src) +} +func (m *MsgRegisterHook) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterHook) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterHook.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterHook proto.InternalMessageInfo + +func (m *MsgRegisterHook) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgRegisterHook) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgRegisterHook) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *MsgRegisterHook) GetGitUrl() string { + if m != nil { + return m.GitUrl + } + return "" +} + +func (m *MsgRegisterHook) GetEventType() string { + if m != nil { + return m.EventType + } + return "" +} + +func (m *MsgRegisterHook) GetEventAttributes() []*KeyValuePair { + if m != nil { + return m.EventAttributes + } + return nil +} + +type MsgRegisterHookResponse struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *MsgRegisterHookResponse) Reset() { *m = MsgRegisterHookResponse{} } +func (m *MsgRegisterHookResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterHookResponse) ProtoMessage() {} +func (*MsgRegisterHookResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_20cafb73a0f25f2d, []int{1} +} +func (m *MsgRegisterHookResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterHookResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterHookResponse.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 *MsgRegisterHookResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterHookResponse.Merge(m, src) +} +func (m *MsgRegisterHookResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterHookResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterHookResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterHookResponse proto.InternalMessageInfo + +func (m *MsgRegisterHookResponse) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type MsgUnregisterHook struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + EventType string `protobuf:"bytes,2,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *MsgUnregisterHook) Reset() { *m = MsgUnregisterHook{} } +func (m *MsgUnregisterHook) String() string { return proto.CompactTextString(m) } +func (*MsgUnregisterHook) ProtoMessage() {} +func (*MsgUnregisterHook) Descriptor() ([]byte, []int) { + return fileDescriptor_20cafb73a0f25f2d, []int{2} +} +func (m *MsgUnregisterHook) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnregisterHook) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnregisterHook.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 *MsgUnregisterHook) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnregisterHook.Merge(m, src) +} +func (m *MsgUnregisterHook) XXX_Size() int { + return m.Size() +} +func (m *MsgUnregisterHook) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnregisterHook.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnregisterHook proto.InternalMessageInfo + +func (m *MsgUnregisterHook) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgUnregisterHook) GetEventType() string { + if m != nil { + return m.EventType + } + return "" +} + +func (m *MsgUnregisterHook) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type MsgUnregisterHookResponse struct { +} + +func (m *MsgUnregisterHookResponse) Reset() { *m = MsgUnregisterHookResponse{} } +func (m *MsgUnregisterHookResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnregisterHookResponse) ProtoMessage() {} +func (*MsgUnregisterHookResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_20cafb73a0f25f2d, []int{3} +} +func (m *MsgUnregisterHookResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnregisterHookResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnregisterHookResponse.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 *MsgUnregisterHookResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnregisterHookResponse.Merge(m, src) +} +func (m *MsgUnregisterHookResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUnregisterHookResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnregisterHookResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnregisterHookResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterHook)(nil), "nftvault.eventhook.MsgRegisterHook") + proto.RegisterType((*MsgRegisterHookResponse)(nil), "nftvault.eventhook.MsgRegisterHookResponse") + proto.RegisterType((*MsgUnregisterHook)(nil), "nftvault.eventhook.MsgUnregisterHook") + proto.RegisterType((*MsgUnregisterHookResponse)(nil), "nftvault.eventhook.MsgUnregisterHookResponse") +} + func init() { proto.RegisterFile("ununifi/eventhook/tx.proto", fileDescriptor_20cafb73a0f25f2d) } var fileDescriptor_20cafb73a0f25f2d = []byte{ - // 139 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0xcd, 0x2b, 0xcd, - 0xcb, 0x4c, 0xcb, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xc9, 0xc8, 0xcf, 0xcf, 0xd6, 0x2f, 0xa9, - 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xca, 0x4b, 0x2b, 0x29, 0x4b, 0x2c, 0xcd, 0x29, - 0xd1, 0x83, 0x4b, 0x1a, 0xb1, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x3b, 0xb9, 0x9c, 0x78, 0x24, 0xc7, - 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, - 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x56, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, - 0x7e, 0xae, 0x7e, 0x68, 0x5e, 0x68, 0x5e, 0xa6, 0x5b, 0xa6, 0x7e, 0x72, 0x46, 0x62, 0x66, 0x9e, - 0x7e, 0x05, 0xb2, 0x1d, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7b, 0x8c, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x8e, 0x55, 0x3f, 0xae, 0x85, 0x00, 0x00, 0x00, + // 402 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x8b, 0xd3, 0x40, + 0x18, 0x86, 0x9b, 0xa4, 0x56, 0xf6, 0x53, 0xb6, 0xeb, 0x1c, 0xdc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xfb, 0x27, 0x00, 0x00, 0xff, 0xff, 0xf2, 0xe9, 0x3c, 0x99, 0x07, 0x03, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -50,6 +303,9 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // this line is used by starport scaffolding # proto/tx/rpc + RegisterHook(ctx context.Context, in *MsgRegisterHook, opts ...grpc.CallOption) (*MsgRegisterHookResponse, error) + UnregisterHook(ctx context.Context, in *MsgUnregisterHook, opts ...grpc.CallOption) (*MsgUnregisterHookResponse, error) } type msgClient struct { @@ -60,22 +316,934 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) RegisterHook(ctx context.Context, in *MsgRegisterHook, opts ...grpc.CallOption) (*MsgRegisterHookResponse, error) { + out := new(MsgRegisterHookResponse) + err := c.cc.Invoke(ctx, "/nftvault.eventhook.Msg/RegisterHook", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnregisterHook(ctx context.Context, in *MsgUnregisterHook, opts ...grpc.CallOption) (*MsgUnregisterHookResponse, error) { + out := new(MsgUnregisterHookResponse) + err := c.cc.Invoke(ctx, "/nftvault.eventhook.Msg/UnregisterHook", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + // this line is used by starport scaffolding # proto/tx/rpc + RegisterHook(context.Context, *MsgRegisterHook) (*MsgRegisterHookResponse, error) + UnregisterHook(context.Context, *MsgUnregisterHook) (*MsgUnregisterHookResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) RegisterHook(ctx context.Context, req *MsgRegisterHook) (*MsgRegisterHookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterHook not implemented") +} +func (*UnimplementedMsgServer) UnregisterHook(ctx context.Context, req *MsgUnregisterHook) (*MsgUnregisterHookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnregisterHook not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_RegisterHook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterHook) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterHook(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nftvault.eventhook.Msg/RegisterHook", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterHook(ctx, req.(*MsgRegisterHook)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnregisterHook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnregisterHook) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnregisterHook(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nftvault.eventhook.Msg/UnregisterHook", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnregisterHook(ctx, req.(*MsgUnregisterHook)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nftvault.eventhook.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "ununifi/eventhook/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterHook", + Handler: _Msg_RegisterHook_Handler, + }, + { + MethodName: "UnregisterHook", + Handler: _Msg_UnregisterHook_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ununifi/eventhook/tx.proto", +} + +func (m *MsgRegisterHook) 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 *MsgRegisterHook) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterHook) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EventAttributes) > 0 { + for iNdEx := len(m.EventAttributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EventAttributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.EventType) > 0 { + i -= len(m.EventType) + copy(dAtA[i:], m.EventType) + i = encodeVarintTx(dAtA, i, uint64(len(m.EventType))) + i-- + dAtA[i] = 0x2a + } + if len(m.GitUrl) > 0 { + i -= len(m.GitUrl) + copy(dAtA[i:], m.GitUrl) + i = encodeVarintTx(dAtA, i, uint64(len(m.GitUrl))) + i-- + dAtA[i] = 0x22 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + 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 *MsgRegisterHookResponse) 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 *MsgRegisterHookResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterHookResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgUnregisterHook) 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 *MsgUnregisterHook) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnregisterHook) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } + if len(m.EventType) > 0 { + i -= len(m.EventType) + copy(dAtA[i:], m.EventType) + i = encodeVarintTx(dAtA, i, uint64(len(m.EventType))) + i-- + dAtA[i] = 0x12 + } + 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 *MsgUnregisterHookResponse) 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 *MsgUnregisterHookResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnregisterHookResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterHook) 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)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GitUrl) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.EventType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.EventAttributes) > 0 { + for _, e := range m.EventAttributes { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRegisterHookResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovTx(uint64(m.Id)) + } + return n +} + +func (m *MsgUnregisterHook) 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)) + } + l = len(m.EventType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovTx(uint64(m.Id)) + } + return n +} + +func (m *MsgUnregisterHookResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRegisterHook) 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: MsgRegisterHook: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterHook: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GitUrl", 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.GitUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventType", 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.EventType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventAttributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EventAttributes = append(m.EventAttributes, &KeyValuePair{}) + if err := m.EventAttributes[len(m.EventAttributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 *MsgRegisterHookResponse) 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: MsgRegisterHookResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterHookResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgUnregisterHook) 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: MsgUnregisterHook: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnregisterHook: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventType", 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.EventType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgUnregisterHookResponse) 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: MsgUnregisterHookResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnregisterHookResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)