Skip to content

Commit

Permalink
Add in subscribe-rate packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Dec 12, 2023
1 parent 4c79251 commit ae55467
Show file tree
Hide file tree
Showing 21 changed files with 2,051 additions and 30 deletions.
2 changes: 2 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions proto/portal/packet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 13 additions & 1 deletion proto/portal/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 33 additions & 1 deletion vue/src/store/generated/market/market.portal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'], {
Expand Down Expand Up @@ -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({})),

},
Expand Down Expand Up @@ -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)
}
}
},

}
}
3 changes: 3 additions & 0 deletions vue/src/store/generated/market/market.portal/module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 ) }),

};
};
Expand Down
2 changes: 2 additions & 0 deletions vue/src/store/generated/market/market.portal/module/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* ---------------------------------------------------------------
*/

export type PortalMsgSendSubscribeRateResponse = object;

/**
* Params defines the parameters for the module.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@ 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 = {
encode(message: PortalPacketData, writer: Writer = Writer.create()): Writer {
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;
},

Expand All @@ -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;
Expand All @@ -45,13 +67,27 @@ 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;
},

toJSON(message: PortalPacketData): unknown {
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;
},

Expand All @@ -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;
},
};
Expand Down Expand Up @@ -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>
): 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>): SubscribeRatePacketAck {
const message = { ...baseSubscribeRatePacketAck } as SubscribeRatePacketAck;
return message;
},
};

type Builtin = Date | Function | Uint8Array | string | number | undefined;
export type DeepPartial<T> = T extends Builtin
? T
Expand Down
Loading

0 comments on commit ae55467

Please sign in to comment.