diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 59c1be82..ad20585b 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -51934,6 +51934,8 @@ definitions: description: |- Version defines the versioning scheme used to negotiate the IBC verison in the connection handshake. + market.portal.MsgSendSubscribeRateResponse: + type: object market.portal.Params: type: object description: Params defines the parameters for the module. diff --git a/proto/portal/packet.proto b/proto/portal/packet.proto index 89aa0ea6..562a0d40 100644 --- a/proto/portal/packet.proto +++ b/proto/portal/packet.proto @@ -9,10 +9,20 @@ message PortalPacketData { oneof packet { NoData noData = 1; // this line is used by starport scaffolding # ibc/packet/proto/field + SubscribeRatePacketData subscribeRatePacket = 2; // this line is used by starport scaffolding # ibc/packet/proto/field/number } } message NoData { } +// SubscribeRatePacketData defines a struct for the packet payload +message SubscribeRatePacketData { + string denomA = 1; + string denomB = 2; +} + +// SubscribeRatePacketAck defines a struct for the packet acknowledgment +message SubscribeRatePacketAck { + } // this line is used by starport scaffolding # ibc/packet/proto/message diff --git a/proto/portal/tx.proto b/proto/portal/tx.proto index 60c3e771..83134c06 100644 --- a/proto/portal/tx.proto +++ b/proto/portal/tx.proto @@ -7,7 +7,19 @@ option go_package = "market/x/portal/types"; // Msg defines the Msg service. service Msg { - // this line is used by starport scaffolding # proto/tx/rpc + rpc SendSubscribeRate(MsgSendSubscribeRate) returns (MsgSendSubscribeRateResponse); +// this line is used by starport scaffolding # proto/tx/rpc } +message MsgSendSubscribeRate { + string creator = 1; + string port = 2; + string channelID = 3; + uint64 timeoutTimestamp = 4; + string denomA = 5; + string denomB = 6; +} + +message MsgSendSubscribeRateResponse { +} // this line is used by starport scaffolding # proto/tx/message diff --git a/vue/src/store/generated/market/market.portal/index.ts b/vue/src/store/generated/market/market.portal/index.ts index ae2a6e04..93dd2eb5 100755 --- a/vue/src/store/generated/market/market.portal/index.ts +++ b/vue/src/store/generated/market/market.portal/index.ts @@ -2,10 +2,12 @@ import { txClient, queryClient, MissingWalletError , registry} from './module' import { PortalPacketData } from "./module/types/portal/packet" import { NoData } from "./module/types/portal/packet" +import { SubscribeRatePacketData } from "./module/types/portal/packet" +import { SubscribeRatePacketAck } from "./module/types/portal/packet" import { Params } from "./module/types/portal/params" -export { PortalPacketData, NoData, Params }; +export { PortalPacketData, NoData, SubscribeRatePacketData, SubscribeRatePacketAck, Params }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -48,6 +50,8 @@ const getDefaultState = () => { _Structure: { PortalPacketData: getStructure(PortalPacketData.fromPartial({})), NoData: getStructure(NoData.fromPartial({})), + SubscribeRatePacketData: getStructure(SubscribeRatePacketData.fromPartial({})), + SubscribeRatePacketAck: getStructure(SubscribeRatePacketAck.fromPartial({})), Params: getStructure(Params.fromPartial({})), }, @@ -139,7 +143,35 @@ export default { }, + async sendMsgSendSubscribeRate({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgSendSubscribeRate(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgSendSubscribeRate:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgSendSubscribeRate:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async MsgSendSubscribeRate({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgSendSubscribeRate(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgSendSubscribeRate:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgSendSubscribeRate:Create Could not create message: ' + e.message) + } + } + }, } } diff --git a/vue/src/store/generated/market/market.portal/module/index.ts b/vue/src/store/generated/market/market.portal/module/index.ts index 67d4b093..075b4ca5 100755 --- a/vue/src/store/generated/market/market.portal/module/index.ts +++ b/vue/src/store/generated/market/market.portal/module/index.ts @@ -4,9 +4,11 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; +import { MsgSendSubscribeRate } from "./types/portal/tx"; const types = [ + ["/market.portal.MsgSendSubscribeRate", MsgSendSubscribeRate], ]; export const MissingWalletError = new Error("wallet is required"); @@ -39,6 +41,7 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + msgSendSubscribeRate: (data: MsgSendSubscribeRate): EncodeObject => ({ typeUrl: "/market.portal.MsgSendSubscribeRate", value: MsgSendSubscribeRate.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/market/market.portal/module/rest.ts b/vue/src/store/generated/market/market.portal/module/rest.ts index 3bc2fc7a..0e8d6a09 100644 --- a/vue/src/store/generated/market/market.portal/module/rest.ts +++ b/vue/src/store/generated/market/market.portal/module/rest.ts @@ -9,6 +9,8 @@ * --------------------------------------------------------------- */ +export type PortalMsgSendSubscribeRateResponse = object; + /** * Params defines the parameters for the module. */ diff --git a/vue/src/store/generated/market/market.portal/module/types/portal/packet.ts b/vue/src/store/generated/market/market.portal/module/types/portal/packet.ts index 7f43c0cd..d4a08c49 100644 --- a/vue/src/store/generated/market/market.portal/module/types/portal/packet.ts +++ b/vue/src/store/generated/market/market.portal/module/types/portal/packet.ts @@ -4,12 +4,22 @@ import { Writer, Reader } from "protobufjs/minimal"; export const protobufPackage = "market.portal"; export interface PortalPacketData { - /** this line is used by starport scaffolding # ibc/packet/proto/field */ noData: NoData | undefined; + /** this line is used by starport scaffolding # ibc/packet/proto/field */ + subscribeRatePacket: SubscribeRatePacketData | undefined; } export interface NoData {} +/** SubscribeRatePacketData defines a struct for the packet payload */ +export interface SubscribeRatePacketData { + denomA: string; + denomB: string; +} + +/** SubscribeRatePacketAck defines a struct for the packet acknowledgment */ +export interface SubscribeRatePacketAck {} + const basePortalPacketData: object = {}; export const PortalPacketData = { @@ -17,6 +27,12 @@ export const PortalPacketData = { if (message.noData !== undefined) { NoData.encode(message.noData, writer.uint32(10).fork()).ldelim(); } + if (message.subscribeRatePacket !== undefined) { + SubscribeRatePacketData.encode( + message.subscribeRatePacket, + writer.uint32(18).fork() + ).ldelim(); + } return writer; }, @@ -30,6 +46,12 @@ export const PortalPacketData = { case 1: message.noData = NoData.decode(reader, reader.uint32()); break; + case 2: + message.subscribeRatePacket = SubscribeRatePacketData.decode( + reader, + reader.uint32() + ); + break; default: reader.skipType(tag & 7); break; @@ -45,6 +67,16 @@ export const PortalPacketData = { } else { message.noData = undefined; } + if ( + object.subscribeRatePacket !== undefined && + object.subscribeRatePacket !== null + ) { + message.subscribeRatePacket = SubscribeRatePacketData.fromJSON( + object.subscribeRatePacket + ); + } else { + message.subscribeRatePacket = undefined; + } return message; }, @@ -52,6 +84,10 @@ export const PortalPacketData = { const obj: any = {}; message.noData !== undefined && (obj.noData = message.noData ? NoData.toJSON(message.noData) : undefined); + message.subscribeRatePacket !== undefined && + (obj.subscribeRatePacket = message.subscribeRatePacket + ? SubscribeRatePacketData.toJSON(message.subscribeRatePacket) + : undefined); return obj; }, @@ -62,6 +98,16 @@ export const PortalPacketData = { } else { message.noData = undefined; } + if ( + object.subscribeRatePacket !== undefined && + object.subscribeRatePacket !== null + ) { + message.subscribeRatePacket = SubscribeRatePacketData.fromPartial( + object.subscribeRatePacket + ); + } else { + message.subscribeRatePacket = undefined; + } return message; }, }; @@ -104,6 +150,127 @@ export const NoData = { }, }; +const baseSubscribeRatePacketData: object = { denomA: "", denomB: "" }; + +export const SubscribeRatePacketData = { + encode( + message: SubscribeRatePacketData, + writer: Writer = Writer.create() + ): Writer { + if (message.denomA !== "") { + writer.uint32(10).string(message.denomA); + } + if (message.denomB !== "") { + writer.uint32(18).string(message.denomB); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SubscribeRatePacketData { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSubscribeRatePacketData, + } as SubscribeRatePacketData; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomA = reader.string(); + break; + case 2: + message.denomB = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SubscribeRatePacketData { + const message = { + ...baseSubscribeRatePacketData, + } as SubscribeRatePacketData; + if (object.denomA !== undefined && object.denomA !== null) { + message.denomA = String(object.denomA); + } else { + message.denomA = ""; + } + if (object.denomB !== undefined && object.denomB !== null) { + message.denomB = String(object.denomB); + } else { + message.denomB = ""; + } + return message; + }, + + toJSON(message: SubscribeRatePacketData): unknown { + const obj: any = {}; + message.denomA !== undefined && (obj.denomA = message.denomA); + message.denomB !== undefined && (obj.denomB = message.denomB); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SubscribeRatePacketData { + const message = { + ...baseSubscribeRatePacketData, + } as SubscribeRatePacketData; + if (object.denomA !== undefined && object.denomA !== null) { + message.denomA = object.denomA; + } else { + message.denomA = ""; + } + if (object.denomB !== undefined && object.denomB !== null) { + message.denomB = object.denomB; + } else { + message.denomB = ""; + } + return message; + }, +}; + +const baseSubscribeRatePacketAck: object = {}; + +export const SubscribeRatePacketAck = { + encode(_: SubscribeRatePacketAck, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SubscribeRatePacketAck { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSubscribeRatePacketAck } as SubscribeRatePacketAck; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): SubscribeRatePacketAck { + const message = { ...baseSubscribeRatePacketAck } as SubscribeRatePacketAck; + return message; + }, + + toJSON(_: SubscribeRatePacketAck): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): SubscribeRatePacketAck { + const message = { ...baseSubscribeRatePacketAck } as SubscribeRatePacketAck; + return message; + }, +}; + type Builtin = Date | Function | Uint8Array | string | number | undefined; export type DeepPartial = T extends Builtin ? T diff --git a/vue/src/store/generated/market/market.portal/module/types/portal/tx.ts b/vue/src/store/generated/market/market.portal/module/types/portal/tx.ts index e7f7cddf..9cc25ca0 100644 --- a/vue/src/store/generated/market/market.portal/module/types/portal/tx.ts +++ b/vue/src/store/generated/market/market.portal/module/types/portal/tx.ts @@ -1,14 +1,255 @@ /* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; + export const protobufPackage = "market.portal"; +export interface MsgSendSubscribeRate { + creator: string; + port: string; + channelID: string; + timeoutTimestamp: number; + denomA: string; + denomB: string; +} + +export interface MsgSendSubscribeRateResponse {} + +const baseMsgSendSubscribeRate: object = { + creator: "", + port: "", + channelID: "", + timeoutTimestamp: 0, + denomA: "", + denomB: "", +}; + +export const MsgSendSubscribeRate = { + encode( + message: MsgSendSubscribeRate, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.port !== "") { + writer.uint32(18).string(message.port); + } + if (message.channelID !== "") { + writer.uint32(26).string(message.channelID); + } + if (message.timeoutTimestamp !== 0) { + writer.uint32(32).uint64(message.timeoutTimestamp); + } + if (message.denomA !== "") { + writer.uint32(42).string(message.denomA); + } + if (message.denomB !== "") { + writer.uint32(50).string(message.denomB); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSendSubscribeRate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSendSubscribeRate } as MsgSendSubscribeRate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.port = reader.string(); + break; + case 3: + message.channelID = reader.string(); + break; + case 4: + message.timeoutTimestamp = longToNumber(reader.uint64() as Long); + break; + case 5: + message.denomA = reader.string(); + break; + case 6: + message.denomB = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSendSubscribeRate { + const message = { ...baseMsgSendSubscribeRate } as MsgSendSubscribeRate; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.port !== undefined && object.port !== null) { + message.port = String(object.port); + } else { + message.port = ""; + } + if (object.channelID !== undefined && object.channelID !== null) { + message.channelID = String(object.channelID); + } else { + message.channelID = ""; + } + if ( + object.timeoutTimestamp !== undefined && + object.timeoutTimestamp !== null + ) { + message.timeoutTimestamp = Number(object.timeoutTimestamp); + } else { + message.timeoutTimestamp = 0; + } + if (object.denomA !== undefined && object.denomA !== null) { + message.denomA = String(object.denomA); + } else { + message.denomA = ""; + } + if (object.denomB !== undefined && object.denomB !== null) { + message.denomB = String(object.denomB); + } else { + message.denomB = ""; + } + return message; + }, + + toJSON(message: MsgSendSubscribeRate): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.port !== undefined && (obj.port = message.port); + message.channelID !== undefined && (obj.channelID = message.channelID); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = message.timeoutTimestamp); + message.denomA !== undefined && (obj.denomA = message.denomA); + message.denomB !== undefined && (obj.denomB = message.denomB); + return obj; + }, + + fromPartial(object: DeepPartial): MsgSendSubscribeRate { + const message = { ...baseMsgSendSubscribeRate } as MsgSendSubscribeRate; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.port !== undefined && object.port !== null) { + message.port = object.port; + } else { + message.port = ""; + } + if (object.channelID !== undefined && object.channelID !== null) { + message.channelID = object.channelID; + } else { + message.channelID = ""; + } + if ( + object.timeoutTimestamp !== undefined && + object.timeoutTimestamp !== null + ) { + message.timeoutTimestamp = object.timeoutTimestamp; + } else { + message.timeoutTimestamp = 0; + } + if (object.denomA !== undefined && object.denomA !== null) { + message.denomA = object.denomA; + } else { + message.denomA = ""; + } + if (object.denomB !== undefined && object.denomB !== null) { + message.denomB = object.denomB; + } else { + message.denomB = ""; + } + return message; + }, +}; + +const baseMsgSendSubscribeRateResponse: object = {}; + +export const MsgSendSubscribeRateResponse = { + encode( + _: MsgSendSubscribeRateResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSendSubscribeRateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSendSubscribeRateResponse, + } as MsgSendSubscribeRateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSendSubscribeRateResponse { + const message = { + ...baseMsgSendSubscribeRateResponse, + } as MsgSendSubscribeRateResponse; + return message; + }, + + toJSON(_: MsgSendSubscribeRateResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgSendSubscribeRateResponse { + const message = { + ...baseMsgSendSubscribeRateResponse, + } as MsgSendSubscribeRateResponse; + return message; + }, +}; + /** Msg defines the Msg service. */ -export interface Msg {} +export interface Msg { + /** this line is used by starport scaffolding # proto/tx/rpc */ + SendSubscribeRate( + request: MsgSendSubscribeRate + ): Promise; +} export class MsgClientImpl implements Msg { private readonly rpc: Rpc; constructor(rpc: Rpc) { this.rpc = rpc; } + SendSubscribeRate( + request: MsgSendSubscribeRate + ): Promise { + const data = MsgSendSubscribeRate.encode(request).finish(); + const promise = this.rpc.request( + "market.portal.Msg", + "SendSubscribeRate", + data + ); + return promise.then((data) => + MsgSendSubscribeRateResponse.decode(new Reader(data)) + ); + } } interface Rpc { @@ -18,3 +259,36 @@ interface Rpc { data: Uint8Array ): Promise; } + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/x/portal/client/cli/tx.go b/x/portal/client/cli/tx.go index 019a1e4f..516d8227 100644 --- a/x/portal/client/cli/tx.go +++ b/x/portal/client/cli/tx.go @@ -30,6 +30,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdSendSubscribeRate()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/portal/client/cli/tx_subscribe_rate.go b/x/portal/client/cli/tx_subscribe_rate.go new file mode 100644 index 00000000..0eb6b4b4 --- /dev/null +++ b/x/portal/client/cli/tx_subscribe_rate.go @@ -0,0 +1,59 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + channelutils "github.com/cosmos/ibc-go/v3/modules/core/04-channel/client/utils" + "github.com/spf13/cobra" + "market/x/portal/types" +) + +var _ = strconv.Itoa(0) + +func CmdSendSubscribeRate() *cobra.Command { + cmd := &cobra.Command{ + Use: "send-subscribe-rate [src-port] [src-channel] [denom-a] [denom-b]", + Short: "Send a subscribe-rate over IBC", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + creator := clientCtx.GetFromAddress().String() + srcPort := args[0] + srcChannel := args[1] + + argDenomA := args[2] + argDenomB := args[3] + + // Get the relative timeout timestamp + timeoutTimestamp, err := cmd.Flags().GetUint64(flagPacketTimeoutTimestamp) + if err != nil { + return err + } + consensusState, _, _, err := channelutils.QueryLatestConsensusState(clientCtx, srcPort, srcChannel) + if err != nil { + return err + } + if timeoutTimestamp != 0 { + timeoutTimestamp = consensusState.GetTimestamp() + timeoutTimestamp + } + + msg := types.NewMsgSendSubscribeRate(creator, srcPort, srcChannel, timeoutTimestamp, argDenomA, argDenomB) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().Uint64(flagPacketTimeoutTimestamp, DefaultRelativePacketTimeoutTimestamp, "Packet timeout timestamp in nanoseconds. Default is 10 minutes.") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/portal/handler.go b/x/portal/handler.go index e72c8d7d..78a71b34 100644 --- a/x/portal/handler.go +++ b/x/portal/handler.go @@ -11,13 +11,16 @@ import ( // NewHandler ... func NewHandler(k keeper.Keeper) sdk.Handler { - // this line is used by starport scaffolding # handler/msgServer + msgServer := keeper.NewMsgServerImpl(k) return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - // this line is used by starport scaffolding # 1 + case *types.MsgSendSubscribeRate: + res, err := msgServer.SendSubscribeRate(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/portal/keeper/msg_server_subscribe_rate.go b/x/portal/keeper/msg_server_subscribe_rate.go new file mode 100644 index 00000000..b0456047 --- /dev/null +++ b/x/portal/keeper/msg_server_subscribe_rate.go @@ -0,0 +1,36 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + "market/x/portal/types" +) + +func (k msgServer) SendSubscribeRate(goCtx context.Context, msg *types.MsgSendSubscribeRate) (*types.MsgSendSubscribeRateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: logic before transmitting the packet + + // Construct the packet + var packet types.SubscribeRatePacketData + + packet.DenomA = msg.DenomA + packet.DenomB = msg.DenomB + + // Transmit the packet + err := k.TransmitSubscribeRatePacket( + ctx, + packet, + msg.Port, + msg.ChannelID, + clienttypes.ZeroHeight(), + msg.TimeoutTimestamp, + ) + if err != nil { + return nil, err + } + + return &types.MsgSendSubscribeRateResponse{}, nil +} diff --git a/x/portal/keeper/subscribe_rate.go b/x/portal/keeper/subscribe_rate.go new file mode 100644 index 00000000..697fa8dc --- /dev/null +++ b/x/portal/keeper/subscribe_rate.go @@ -0,0 +1,115 @@ +package keeper + +import ( + "errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v3/modules/core/24-host" + "market/x/portal/types" +) + +// TransmitSubscribeRatePacket transmits the packet over IBC with the specified source port and source channel +func (k Keeper) TransmitSubscribeRatePacket( + ctx sdk.Context, + packetData types.SubscribeRatePacketData, + sourcePort, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, +) error { + + sourceChannelEnd, found := k.ChannelKeeper.GetChannel(ctx, sourcePort, sourceChannel) + if !found { + return sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) + } + + destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() + destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() + + // get the next sequence + sequence, found := k.ChannelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) + if !found { + return sdkerrors.Wrapf( + channeltypes.ErrSequenceSendNotFound, + "source port: %s, source channel: %s", sourcePort, sourceChannel, + ) + } + + channelCap, ok := k.ScopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, sourceChannel)) + if !ok { + return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + } + + packetBytes, err := packetData.GetBytes() + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, "cannot marshal the packet: "+err.Error()) + } + + packet := channeltypes.NewPacket( + packetBytes, + sequence, + sourcePort, + sourceChannel, + destinationPort, + destinationChannel, + timeoutHeight, + timeoutTimestamp, + ) + + if err := k.ChannelKeeper.SendPacket(ctx, channelCap, packet); err != nil { + return err + } + + return nil +} + +// OnRecvSubscribeRatePacket processes packet reception +func (k Keeper) OnRecvSubscribeRatePacket(ctx sdk.Context, packet channeltypes.Packet, data types.SubscribeRatePacketData) (packetAck types.SubscribeRatePacketAck, err error) { + // validate packet data upon receiving + if err := data.ValidateBasic(); err != nil { + return packetAck, err + } + + // TODO: packet reception logic + + return packetAck, nil +} + +// OnAcknowledgementSubscribeRatePacket responds to the the success or failure of a packet +// acknowledgement written on the receiving chain. +func (k Keeper) OnAcknowledgementSubscribeRatePacket(ctx sdk.Context, packet channeltypes.Packet, data types.SubscribeRatePacketData, ack channeltypes.Acknowledgement) error { + switch dispatchedAck := ack.Response.(type) { + case *channeltypes.Acknowledgement_Error: + + // TODO: failed acknowledgement logic + _ = dispatchedAck.Error + + return nil + case *channeltypes.Acknowledgement_Result: + // Decode the packet acknowledgment + var packetAck types.SubscribeRatePacketAck + + if err := types.ModuleCdc.UnmarshalJSON(dispatchedAck.Result, &packetAck); err != nil { + // The counter-party module doesn't implement the correct acknowledgment format + return errors.New("cannot unmarshal acknowledgment") + } + + // TODO: successful acknowledgement logic + + return nil + default: + // The counter-party module doesn't implement the correct acknowledgment format + return errors.New("invalid acknowledgment format") + } +} + +// OnTimeoutSubscribeRatePacket responds to the case where a packet has not been transmitted because of a timeout +func (k Keeper) OnTimeoutSubscribeRatePacket(ctx sdk.Context, packet channeltypes.Packet, data types.SubscribeRatePacketData) error { + + // TODO: packet timeout logic + + return nil +} diff --git a/x/portal/module_ibc.go b/x/portal/module_ibc.go index cdf1f8f6..2d282264 100644 --- a/x/portal/module_ibc.go +++ b/x/portal/module_ibc.go @@ -138,7 +138,26 @@ func (am AppModule) OnRecvPacket( // Dispatch packet switch packet := modulePacketData.Packet.(type) { - // this line is used by starport scaffolding # ibc/packet/module/recv + case *types.PortalPacketData_SubscribeRatePacket: + packetAck, err := am.keeper.OnRecvSubscribeRatePacket(ctx, modulePacket, *packet.SubscribeRatePacket) + if err != nil { + ack = channeltypes.NewErrorAcknowledgement(err.Error()) + } else { + // Encode packet acknowledgment + packetAckBytes, err := types.ModuleCdc.MarshalJSON(&packetAck) + if err != nil { + return channeltypes.NewErrorAcknowledgement(sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()).Error()) + } + ack = channeltypes.NewResultAcknowledgement(sdk.MustSortJSON(packetAckBytes)) + } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSubscribeRatePacket, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", err != nil)), + ), + ) + // this line is used by starport scaffolding # ibc/packet/module/recv default: errMsg := fmt.Sprintf("unrecognized %s packet type: %T", types.ModuleName, packet) return channeltypes.NewErrorAcknowledgement(errMsg) @@ -171,7 +190,13 @@ func (am AppModule) OnAcknowledgementPacket( // Dispatch packet switch packet := modulePacketData.Packet.(type) { - // this line is used by starport scaffolding # ibc/packet/module/ack + case *types.PortalPacketData_SubscribeRatePacket: + err := am.keeper.OnAcknowledgementSubscribeRatePacket(ctx, modulePacket, *packet.SubscribeRatePacket, ack) + if err != nil { + return err + } + eventType = types.EventTypeSubscribeRatePacket + // this line is used by starport scaffolding # ibc/packet/module/ack default: errMsg := fmt.Sprintf("unrecognized %s packet type: %T", types.ModuleName, packet) return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) @@ -218,7 +243,12 @@ func (am AppModule) OnTimeoutPacket( // Dispatch packet switch packet := modulePacketData.Packet.(type) { - // this line is used by starport scaffolding # ibc/packet/module/timeout + case *types.PortalPacketData_SubscribeRatePacket: + err := am.keeper.OnTimeoutSubscribeRatePacket(ctx, modulePacket, *packet.SubscribeRatePacket) + if err != nil { + return err + } + // this line is used by starport scaffolding # ibc/packet/module/timeout default: errMsg := fmt.Sprintf("unrecognized %s packet type: %T", types.ModuleName, packet) return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/portal/types/codec.go b/x/portal/types/codec.go index 844157a8..e1bf6549 100644 --- a/x/portal/types/codec.go +++ b/x/portal/types/codec.go @@ -3,15 +3,19 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSendSubscribeRate{}, "portal/SendSubscribeRate", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSendSubscribeRate{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/portal/types/events_ibc.go b/x/portal/types/events_ibc.go index 07c66a43..15913f2f 100644 --- a/x/portal/types/events_ibc.go +++ b/x/portal/types/events_ibc.go @@ -2,7 +2,8 @@ package types // IBC events const ( - EventTypeTimeout = "timeout" + EventTypeTimeout = "timeout" + EventTypeSubscribeRatePacket = "subscribeRate_packet" // this line is used by starport scaffolding # ibc/packet/event AttributeKeyAckSuccess = "success" diff --git a/x/portal/types/messages_subscribe_rate.go b/x/portal/types/messages_subscribe_rate.go new file mode 100644 index 00000000..cf70fea2 --- /dev/null +++ b/x/portal/types/messages_subscribe_rate.go @@ -0,0 +1,66 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgSendSubscribeRate = "send_subscribe_rate" + +var _ sdk.Msg = &MsgSendSubscribeRate{} + +func NewMsgSendSubscribeRate( + creator string, + port string, + channelID string, + timeoutTimestamp uint64, + denomA string, + denomB string, +) *MsgSendSubscribeRate { + return &MsgSendSubscribeRate{ + Creator: creator, + Port: port, + ChannelID: channelID, + TimeoutTimestamp: timeoutTimestamp, + DenomA: denomA, + DenomB: denomB, + } +} + +func (msg *MsgSendSubscribeRate) Route() string { + return RouterKey +} + +func (msg *MsgSendSubscribeRate) Type() string { + return TypeMsgSendSubscribeRate +} + +func (msg *MsgSendSubscribeRate) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgSendSubscribeRate) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSendSubscribeRate) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + if msg.Port == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid packet port") + } + if msg.ChannelID == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid packet channel") + } + if msg.TimeoutTimestamp == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid packet timeout") + } + return nil +} diff --git a/x/portal/types/messages_subscribe_rate_test.go b/x/portal/types/messages_subscribe_rate_test.go new file mode 100644 index 00000000..4d6b2aba --- /dev/null +++ b/x/portal/types/messages_subscribe_rate_test.go @@ -0,0 +1,73 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "market/testutil/sample" +) + +func TestMsgSendSubscribeRate_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSendSubscribeRate + err error + }{ + { + name: "invalid address", + msg: MsgSendSubscribeRate{ + Creator: "invalid_address", + Port: "port", + ChannelID: "channel-0", + TimeoutTimestamp: 100, + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "invalid port", + msg: MsgSendSubscribeRate{ + Creator: sample.AccAddress(), + Port: "", + ChannelID: "channel-0", + TimeoutTimestamp: 100, + }, + err: sdkerrors.ErrInvalidRequest, + }, { + name: "invalid channel", + msg: MsgSendSubscribeRate{ + Creator: sample.AccAddress(), + Port: "port", + ChannelID: "", + TimeoutTimestamp: 100, + }, + err: sdkerrors.ErrInvalidRequest, + }, { + name: "invalid timeout", + msg: MsgSendSubscribeRate{ + Creator: sample.AccAddress(), + Port: "port", + ChannelID: "channel-0", + TimeoutTimestamp: 0, + }, + err: sdkerrors.ErrInvalidRequest, + }, { + name: "valid message", + msg: MsgSendSubscribeRate{ + Creator: sample.AccAddress(), + Port: "port", + ChannelID: "channel-0", + TimeoutTimestamp: 100, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/portal/types/packet.pb.go b/x/portal/types/packet.pb.go index 50e969a3..bfe24d75 100644 --- a/x/portal/types/packet.pb.go +++ b/x/portal/types/packet.pb.go @@ -25,6 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type PortalPacketData struct { // Types that are valid to be assigned to Packet: // *PortalPacketData_NoData + // *PortalPacketData_SubscribeRatePacket Packet isPortalPacketData_Packet `protobuf_oneof:"packet"` } @@ -70,8 +71,12 @@ type isPortalPacketData_Packet interface { type PortalPacketData_NoData struct { NoData *NoData `protobuf:"bytes,1,opt,name=noData,proto3,oneof" json:"noData,omitempty"` } +type PortalPacketData_SubscribeRatePacket struct { + SubscribeRatePacket *SubscribeRatePacketData `protobuf:"bytes,2,opt,name=subscribeRatePacket,proto3,oneof" json:"subscribeRatePacket,omitempty"` +} -func (*PortalPacketData_NoData) isPortalPacketData_Packet() {} +func (*PortalPacketData_NoData) isPortalPacketData_Packet() {} +func (*PortalPacketData_SubscribeRatePacket) isPortalPacketData_Packet() {} func (m *PortalPacketData) GetPacket() isPortalPacketData_Packet { if m != nil { @@ -87,10 +92,18 @@ func (m *PortalPacketData) GetNoData() *NoData { return nil } +func (m *PortalPacketData) GetSubscribeRatePacket() *SubscribeRatePacketData { + if x, ok := m.GetPacket().(*PortalPacketData_SubscribeRatePacket); ok { + return x.SubscribeRatePacket + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*PortalPacketData) XXX_OneofWrappers() []interface{} { return []interface{}{ (*PortalPacketData_NoData)(nil), + (*PortalPacketData_SubscribeRatePacket)(nil), } } @@ -130,25 +143,122 @@ func (m *NoData) XXX_DiscardUnknown() { var xxx_messageInfo_NoData proto.InternalMessageInfo +// SubscribeRatePacketData defines a struct for the packet payload +type SubscribeRatePacketData struct { + DenomA string `protobuf:"bytes,1,opt,name=denomA,proto3" json:"denomA,omitempty"` + DenomB string `protobuf:"bytes,2,opt,name=denomB,proto3" json:"denomB,omitempty"` +} + +func (m *SubscribeRatePacketData) Reset() { *m = SubscribeRatePacketData{} } +func (m *SubscribeRatePacketData) String() string { return proto.CompactTextString(m) } +func (*SubscribeRatePacketData) ProtoMessage() {} +func (*SubscribeRatePacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_acf0e65d77ee4aa1, []int{2} +} +func (m *SubscribeRatePacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SubscribeRatePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SubscribeRatePacketData.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 *SubscribeRatePacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubscribeRatePacketData.Merge(m, src) +} +func (m *SubscribeRatePacketData) XXX_Size() int { + return m.Size() +} +func (m *SubscribeRatePacketData) XXX_DiscardUnknown() { + xxx_messageInfo_SubscribeRatePacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_SubscribeRatePacketData proto.InternalMessageInfo + +func (m *SubscribeRatePacketData) GetDenomA() string { + if m != nil { + return m.DenomA + } + return "" +} + +func (m *SubscribeRatePacketData) GetDenomB() string { + if m != nil { + return m.DenomB + } + return "" +} + +// SubscribeRatePacketAck defines a struct for the packet acknowledgment +type SubscribeRatePacketAck struct { +} + +func (m *SubscribeRatePacketAck) Reset() { *m = SubscribeRatePacketAck{} } +func (m *SubscribeRatePacketAck) String() string { return proto.CompactTextString(m) } +func (*SubscribeRatePacketAck) ProtoMessage() {} +func (*SubscribeRatePacketAck) Descriptor() ([]byte, []int) { + return fileDescriptor_acf0e65d77ee4aa1, []int{3} +} +func (m *SubscribeRatePacketAck) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SubscribeRatePacketAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SubscribeRatePacketAck.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 *SubscribeRatePacketAck) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubscribeRatePacketAck.Merge(m, src) +} +func (m *SubscribeRatePacketAck) XXX_Size() int { + return m.Size() +} +func (m *SubscribeRatePacketAck) XXX_DiscardUnknown() { + xxx_messageInfo_SubscribeRatePacketAck.DiscardUnknown(m) +} + +var xxx_messageInfo_SubscribeRatePacketAck proto.InternalMessageInfo + func init() { proto.RegisterType((*PortalPacketData)(nil), "market.portal.PortalPacketData") proto.RegisterType((*NoData)(nil), "market.portal.NoData") + proto.RegisterType((*SubscribeRatePacketData)(nil), "market.portal.SubscribeRatePacketData") + proto.RegisterType((*SubscribeRatePacketAck)(nil), "market.portal.SubscribeRatePacketAck") } func init() { proto.RegisterFile("portal/packet.proto", fileDescriptor_acf0e65d77ee4aa1) } var fileDescriptor_acf0e65d77ee4aa1 = []byte{ - // 154 bytes of a gzipped FileDescriptorProto + // 230 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0xc8, 0x2f, 0x2a, 0x49, 0xcc, 0xd1, 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, - 0xe2, 0xcd, 0x4d, 0x2c, 0x02, 0xf3, 0xc0, 0x72, 0x4a, 0xbe, 0x5c, 0x02, 0x01, 0x60, 0x56, 0x00, - 0x58, 0x91, 0x4b, 0x62, 0x49, 0xa2, 0x90, 0x3e, 0x17, 0x5b, 0x5e, 0x3e, 0x88, 0x25, 0xc1, 0xa8, - 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xaa, 0x87, 0xa2, 0x47, 0xcf, 0x0f, 0x2c, 0xe9, 0xc1, 0x10, 0x04, - 0x55, 0xe6, 0xc4, 0xc1, 0xc5, 0x06, 0xb1, 0x43, 0x89, 0x83, 0x8b, 0x0d, 0x22, 0xeb, 0xa4, 0x7f, - 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, - 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa2, 0x10, 0xd3, 0xf4, 0x2b, 0xf4, - 0xa1, 0xee, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xbb, 0xcf, 0x18, 0x10, 0x00, 0x00, - 0xff, 0xff, 0xe6, 0xc6, 0xca, 0x49, 0xb6, 0x00, 0x00, 0x00, + 0xe2, 0xcd, 0x4d, 0x2c, 0x02, 0xf3, 0xc0, 0x72, 0x4a, 0x2b, 0x19, 0xb9, 0x04, 0x02, 0xc0, 0xcc, + 0x00, 0xb0, 0x2a, 0x97, 0xc4, 0x92, 0x44, 0x21, 0x7d, 0x2e, 0xb6, 0xbc, 0x7c, 0x10, 0x4b, 0x82, + 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x54, 0x0f, 0x45, 0x93, 0x9e, 0x1f, 0x58, 0xd2, 0x83, 0x21, + 0x08, 0xaa, 0x4c, 0x28, 0x8a, 0x4b, 0xb8, 0xb8, 0x34, 0xa9, 0x38, 0xb9, 0x28, 0x33, 0x29, 0x35, + 0x28, 0xb1, 0x24, 0x15, 0x62, 0x96, 0x04, 0x13, 0x58, 0xb7, 0x1a, 0x9a, 0xee, 0x60, 0x4c, 0x95, + 0x50, 0xe3, 0xb0, 0x19, 0xe2, 0xc4, 0xc1, 0xc5, 0x06, 0xf1, 0x80, 0x12, 0x07, 0x17, 0x1b, 0xc4, + 0x66, 0x25, 0x4f, 0x2e, 0x71, 0x1c, 0xa6, 0x08, 0x89, 0x71, 0xb1, 0xa5, 0xa4, 0xe6, 0xe5, 0xe7, + 0x3a, 0x82, 0xdd, 0xce, 0x19, 0x04, 0xe5, 0xc1, 0xc5, 0x9d, 0xc0, 0xae, 0x82, 0x89, 0x3b, 0x29, + 0x49, 0x70, 0x89, 0x61, 0x31, 0xca, 0x31, 0x39, 0xdb, 0x49, 0xff, 0xc4, 0x23, 0x39, 0xc6, 0x0b, + 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, + 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x44, 0x21, 0x1e, 0xd2, 0xaf, 0xd0, 0x87, 0x86, 0x70, 0x49, 0x65, + 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x84, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x98, 0xab, + 0x05, 0x61, 0x78, 0x01, 0x00, 0x00, } func (m *PortalPacketData) Marshal() (dAtA []byte, err error) { @@ -204,6 +314,27 @@ func (m *PortalPacketData_NoData) MarshalToSizedBuffer(dAtA []byte) (int, error) } return len(dAtA) - i, nil } +func (m *PortalPacketData_SubscribeRatePacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PortalPacketData_SubscribeRatePacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SubscribeRatePacket != nil { + { + size, err := m.SubscribeRatePacket.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} func (m *NoData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -227,6 +358,66 @@ func (m *NoData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SubscribeRatePacketData) 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 *SubscribeRatePacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SubscribeRatePacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DenomB) > 0 { + i -= len(m.DenomB) + copy(dAtA[i:], m.DenomB) + i = encodeVarintPacket(dAtA, i, uint64(len(m.DenomB))) + i-- + dAtA[i] = 0x12 + } + if len(m.DenomA) > 0 { + i -= len(m.DenomA) + copy(dAtA[i:], m.DenomA) + i = encodeVarintPacket(dAtA, i, uint64(len(m.DenomA))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SubscribeRatePacketAck) 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 *SubscribeRatePacketAck) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SubscribeRatePacketAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintPacket(dAtA []byte, offset int, v uint64) int { offset -= sovPacket(v) base := offset @@ -262,6 +453,18 @@ func (m *PortalPacketData_NoData) Size() (n int) { } return n } +func (m *PortalPacketData_SubscribeRatePacket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubscribeRatePacket != nil { + l = m.SubscribeRatePacket.Size() + n += 1 + l + sovPacket(uint64(l)) + } + return n +} func (m *NoData) Size() (n int) { if m == nil { return 0 @@ -271,6 +474,32 @@ func (m *NoData) Size() (n int) { return n } +func (m *SubscribeRatePacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DenomA) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = len(m.DenomB) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + return n +} + +func (m *SubscribeRatePacketAck) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovPacket(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -341,6 +570,41 @@ func (m *PortalPacketData) Unmarshal(dAtA []byte) error { } m.Packet = &PortalPacketData_NoData{v} iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubscribeRatePacket", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &SubscribeRatePacketData{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Packet = &PortalPacketData_SubscribeRatePacket{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPacket(dAtA[iNdEx:]) @@ -412,6 +676,170 @@ func (m *NoData) Unmarshal(dAtA []byte) error { } return nil } +func (m *SubscribeRatePacketData) 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 ErrIntOverflowPacket + } + 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: SubscribeRatePacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubscribeRatePacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomA", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomA = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomB", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + 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 ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomB = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SubscribeRatePacketAck) 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 ErrIntOverflowPacket + } + 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: SubscribeRatePacketAck: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubscribeRatePacketAck: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipPacket(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/portal/types/packet_subscribe_rate.go b/x/portal/types/packet_subscribe_rate.go new file mode 100644 index 00000000..a176f3df --- /dev/null +++ b/x/portal/types/packet_subscribe_rate.go @@ -0,0 +1,18 @@ +package types + +// ValidateBasic is used for validating the packet +func (p SubscribeRatePacketData) ValidateBasic() error { + + // TODO: Validate the packet data + + return nil +} + +// GetBytes is a helper for serialising +func (p SubscribeRatePacketData) GetBytes() ([]byte, error) { + var modulePacket PortalPacketData + + modulePacket.Packet = &PortalPacketData_SubscribeRatePacket{&p} + + return modulePacket.Marshal() +} diff --git a/x/portal/types/tx.pb.go b/x/portal/types/tx.pb.go index be094077..e109ac56 100644 --- a/x/portal/types/tx.pb.go +++ b/x/portal/types/tx.pb.go @@ -9,7 +9,11 @@ import ( grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/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,17 +27,152 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgSendSubscribeRate struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Port string `protobuf:"bytes,2,opt,name=port,proto3" json:"port,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channelID,proto3" json:"channelID,omitempty"` + TimeoutTimestamp uint64 `protobuf:"varint,4,opt,name=timeoutTimestamp,proto3" json:"timeoutTimestamp,omitempty"` + DenomA string `protobuf:"bytes,5,opt,name=denomA,proto3" json:"denomA,omitempty"` + DenomB string `protobuf:"bytes,6,opt,name=denomB,proto3" json:"denomB,omitempty"` +} + +func (m *MsgSendSubscribeRate) Reset() { *m = MsgSendSubscribeRate{} } +func (m *MsgSendSubscribeRate) String() string { return proto.CompactTextString(m) } +func (*MsgSendSubscribeRate) ProtoMessage() {} +func (*MsgSendSubscribeRate) Descriptor() ([]byte, []int) { + return fileDescriptor_6fbcff84cb2250fd, []int{0} +} +func (m *MsgSendSubscribeRate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendSubscribeRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendSubscribeRate.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 *MsgSendSubscribeRate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendSubscribeRate.Merge(m, src) +} +func (m *MsgSendSubscribeRate) XXX_Size() int { + return m.Size() +} +func (m *MsgSendSubscribeRate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendSubscribeRate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendSubscribeRate proto.InternalMessageInfo + +func (m *MsgSendSubscribeRate) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgSendSubscribeRate) GetPort() string { + if m != nil { + return m.Port + } + return "" +} + +func (m *MsgSendSubscribeRate) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgSendSubscribeRate) GetTimeoutTimestamp() uint64 { + if m != nil { + return m.TimeoutTimestamp + } + return 0 +} + +func (m *MsgSendSubscribeRate) GetDenomA() string { + if m != nil { + return m.DenomA + } + return "" +} + +func (m *MsgSendSubscribeRate) GetDenomB() string { + if m != nil { + return m.DenomB + } + return "" +} + +type MsgSendSubscribeRateResponse struct { +} + +func (m *MsgSendSubscribeRateResponse) Reset() { *m = MsgSendSubscribeRateResponse{} } +func (m *MsgSendSubscribeRateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendSubscribeRateResponse) ProtoMessage() {} +func (*MsgSendSubscribeRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6fbcff84cb2250fd, []int{1} +} +func (m *MsgSendSubscribeRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendSubscribeRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendSubscribeRateResponse.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 *MsgSendSubscribeRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendSubscribeRateResponse.Merge(m, src) +} +func (m *MsgSendSubscribeRateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSendSubscribeRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendSubscribeRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendSubscribeRateResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSendSubscribeRate)(nil), "market.portal.MsgSendSubscribeRate") + proto.RegisterType((*MsgSendSubscribeRateResponse)(nil), "market.portal.MsgSendSubscribeRateResponse") +} + func init() { proto.RegisterFile("portal/tx.proto", fileDescriptor_6fbcff84cb2250fd) } var fileDescriptor_6fbcff84cb2250fd = []byte{ - // 105 bytes of a gzipped FileDescriptorProto + // 269 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0xc8, 0x2f, 0x2a, 0x49, 0xcc, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcd, 0x4d, 0x2c, - 0xca, 0x4e, 0x2d, 0xd1, 0x83, 0x88, 0x1b, 0xb1, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x3b, 0xe9, 0x9f, - 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, 0x28, 0x44, 0xbd, 0x7e, 0x85, 0x3e, - 0xcc, 0xa4, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x69, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x57, 0xc0, 0x23, 0x86, 0x60, 0x00, 0x00, 0x00, + 0xca, 0x4e, 0x2d, 0xd1, 0x83, 0x88, 0x2b, 0xed, 0x63, 0xe4, 0x12, 0xf1, 0x2d, 0x4e, 0x0f, 0x4e, + 0xcd, 0x4b, 0x09, 0x2e, 0x4d, 0x2a, 0x4e, 0x2e, 0xca, 0x4c, 0x4a, 0x0d, 0x4a, 0x2c, 0x49, 0x15, + 0x92, 0xe0, 0x62, 0x4f, 0x2e, 0x4a, 0x4d, 0x2c, 0xc9, 0x2f, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x0c, 0x82, 0x71, 0x85, 0x84, 0xb8, 0x58, 0x40, 0x9a, 0x25, 0x98, 0xc0, 0xc2, 0x60, 0xb6, 0x90, + 0x0c, 0x17, 0x67, 0x72, 0x46, 0x62, 0x5e, 0x5e, 0x6a, 0x8e, 0xa7, 0x8b, 0x04, 0x33, 0x58, 0x02, + 0x21, 0x20, 0xa4, 0xc5, 0x25, 0x50, 0x92, 0x99, 0x9b, 0x9a, 0x5f, 0x5a, 0x12, 0x92, 0x99, 0x9b, + 0x5a, 0x5c, 0x92, 0x98, 0x5b, 0x20, 0xc1, 0xa2, 0xc0, 0xa8, 0xc1, 0x12, 0x84, 0x21, 0x2e, 0x24, + 0xc6, 0xc5, 0x96, 0x92, 0x9a, 0x97, 0x9f, 0xeb, 0x28, 0xc1, 0x0a, 0x36, 0x06, 0xca, 0x83, 0x8b, + 0x3b, 0x49, 0xb0, 0x21, 0x89, 0x3b, 0x29, 0xc9, 0x71, 0xc9, 0x60, 0x73, 0x7f, 0x50, 0x6a, 0x71, + 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x51, 0x0e, 0x17, 0xb3, 0x6f, 0x71, 0xba, 0x50, 0x2a, 0x97, 0x20, + 0xa6, 0x1f, 0x95, 0xf5, 0x50, 0x02, 0x43, 0x0f, 0x9b, 0x41, 0x52, 0xda, 0x44, 0x28, 0x82, 0xd9, + 0xe6, 0xa4, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa2, 0x10, 0x53, + 0xf4, 0x2b, 0xf4, 0x61, 0x31, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x8e, 0x15, 0x63, 0x40, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xef, 0x44, 0x13, 0x92, 0xa8, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -48,6 +187,7 @@ 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 { + SendSubscribeRate(ctx context.Context, in *MsgSendSubscribeRate, opts ...grpc.CallOption) (*MsgSendSubscribeRateResponse, error) } type msgClient struct { @@ -58,22 +198,567 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) SendSubscribeRate(ctx context.Context, in *MsgSendSubscribeRate, opts ...grpc.CallOption) (*MsgSendSubscribeRateResponse, error) { + out := new(MsgSendSubscribeRateResponse) + err := c.cc.Invoke(ctx, "/market.portal.Msg/SendSubscribeRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + SendSubscribeRate(context.Context, *MsgSendSubscribeRate) (*MsgSendSubscribeRateResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) SendSubscribeRate(ctx context.Context, req *MsgSendSubscribeRate) (*MsgSendSubscribeRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendSubscribeRate not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_SendSubscribeRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSendSubscribeRate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SendSubscribeRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/market.portal.Msg/SendSubscribeRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SendSubscribeRate(ctx, req.(*MsgSendSubscribeRate)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "market.portal.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "portal/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "SendSubscribeRate", + Handler: _Msg_SendSubscribeRate_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "portal/tx.proto", +} + +func (m *MsgSendSubscribeRate) 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 *MsgSendSubscribeRate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendSubscribeRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DenomB) > 0 { + i -= len(m.DenomB) + copy(dAtA[i:], m.DenomB) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenomB))) + i-- + dAtA[i] = 0x32 + } + if len(m.DenomA) > 0 { + i -= len(m.DenomA) + copy(dAtA[i:], m.DenomA) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenomA))) + i-- + dAtA[i] = 0x2a + } + if m.TimeoutTimestamp != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x1a + } + if len(m.Port) > 0 { + i -= len(m.Port) + copy(dAtA[i:], m.Port) + i = encodeVarintTx(dAtA, i, uint64(len(m.Port))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSendSubscribeRateResponse) 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 *MsgSendSubscribeRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendSubscribeRateResponse) 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 *MsgSendSubscribeRate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Port) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.TimeoutTimestamp != 0 { + n += 1 + sovTx(uint64(m.TimeoutTimestamp)) + } + l = len(m.DenomA) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DenomB) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSendSubscribeRateResponse) 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 *MsgSendSubscribeRate) 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: MsgSendSubscribeRate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendSubscribeRate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Port", 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.Port = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", 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.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) + } + m.TimeoutTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomA", 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.DenomA = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomB", 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.DenomB = string(dAtA[iNdEx:postIndex]) + 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 *MsgSendSubscribeRateResponse) 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: MsgSendSubscribeRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendSubscribeRateResponse: 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") +)