mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-05 21:34:25 -08:00
scaffold new auction tx
This commit is contained in:
@@ -230,7 +230,35 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
async sendMsgNewAuction({ rootGetters }, { value, fee = [], memo = '' }) {
|
||||
try {
|
||||
const txClient=await initTxClient(rootGetters)
|
||||
const msg = await txClient.msgNewAuction(value)
|
||||
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
|
||||
gas: "200000" }, memo})
|
||||
return result
|
||||
} catch (e) {
|
||||
if (e == MissingWalletError) {
|
||||
throw new Error('TxClient:MsgNewAuction:Init Could not initialize signing client. Wallet is required.')
|
||||
}else{
|
||||
throw new Error('TxClient:MsgNewAuction:Send Could not broadcast Tx: '+ e.message)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async MsgNewAuction({ rootGetters }, { value }) {
|
||||
try {
|
||||
const txClient=await initTxClient(rootGetters)
|
||||
const msg = await txClient.msgNewAuction(value)
|
||||
return msg
|
||||
} catch (e) {
|
||||
if (e == MissingWalletError) {
|
||||
throw new Error('TxClient:MsgNewAuction:Init Could not initialize signing client. Wallet is required.')
|
||||
} else{
|
||||
throw new Error('TxClient:MsgNewAuction:Create Could not create message: ' + e.message)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 { MsgNewAuction } from "./types/cosmostest/tx";
|
||||
|
||||
|
||||
const types = [
|
||||
["/cosmostest.cosmostest.MsgNewAuction", MsgNewAuction],
|
||||
|
||||
];
|
||||
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),
|
||||
msgNewAuction: (data: MsgNewAuction): EncodeObject => ({ typeUrl: "/cosmostest.cosmostest.MsgNewAuction", value: MsgNewAuction.fromPartial( data ) }),
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,6 +17,10 @@ export interface CosmostestAuction {
|
||||
highestBid?: string;
|
||||
}
|
||||
|
||||
export interface CosmostestMsgNewAuctionResponse {
|
||||
auctionId?: string;
|
||||
}
|
||||
|
||||
export interface CosmostestNextAuction {
|
||||
/** @format uint64 */
|
||||
auctionId?: string;
|
||||
@@ -106,6 +110,13 @@ export interface V1Beta1PageRequest {
|
||||
* is set.
|
||||
*/
|
||||
count_total?: boolean;
|
||||
|
||||
/**
|
||||
* reverse is set to true if results are to be returned in the descending order.
|
||||
*
|
||||
* Since: cosmos-sdk 0.43
|
||||
*/
|
||||
reverse?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,6 +346,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
||||
"pagination.offset"?: string;
|
||||
"pagination.limit"?: string;
|
||||
"pagination.count_total"?: boolean;
|
||||
"pagination.reverse"?: boolean;
|
||||
},
|
||||
params: RequestParams = {},
|
||||
) =>
|
||||
|
||||
@@ -38,6 +38,12 @@ export interface PageRequest {
|
||||
* is set.
|
||||
*/
|
||||
count_total: boolean;
|
||||
/**
|
||||
* reverse is set to true if results are to be returned in the descending order.
|
||||
*
|
||||
* Since: cosmos-sdk 0.43
|
||||
*/
|
||||
reverse: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +68,12 @@ export interface PageResponse {
|
||||
total: number;
|
||||
}
|
||||
|
||||
const basePageRequest: object = { offset: 0, limit: 0, count_total: false };
|
||||
const basePageRequest: object = {
|
||||
offset: 0,
|
||||
limit: 0,
|
||||
count_total: false,
|
||||
reverse: false,
|
||||
};
|
||||
|
||||
export const PageRequest = {
|
||||
encode(message: PageRequest, writer: Writer = Writer.create()): Writer {
|
||||
@@ -78,6 +89,9 @@ export const PageRequest = {
|
||||
if (message.count_total === true) {
|
||||
writer.uint32(32).bool(message.count_total);
|
||||
}
|
||||
if (message.reverse === true) {
|
||||
writer.uint32(40).bool(message.reverse);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
@@ -100,6 +114,9 @@ export const PageRequest = {
|
||||
case 4:
|
||||
message.count_total = reader.bool();
|
||||
break;
|
||||
case 5:
|
||||
message.reverse = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
@@ -128,6 +145,11 @@ export const PageRequest = {
|
||||
} else {
|
||||
message.count_total = false;
|
||||
}
|
||||
if (object.reverse !== undefined && object.reverse !== null) {
|
||||
message.reverse = Boolean(object.reverse);
|
||||
} else {
|
||||
message.reverse = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
@@ -141,6 +163,7 @@ export const PageRequest = {
|
||||
message.limit !== undefined && (obj.limit = message.limit);
|
||||
message.count_total !== undefined &&
|
||||
(obj.count_total = message.count_total);
|
||||
message.reverse !== undefined && (obj.reverse = message.reverse);
|
||||
return obj;
|
||||
},
|
||||
|
||||
@@ -166,6 +189,11 @@ export const PageRequest = {
|
||||
} else {
|
||||
message.count_total = false;
|
||||
}
|
||||
if (object.reverse !== undefined && object.reverse !== null) {
|
||||
message.reverse = object.reverse;
|
||||
} else {
|
||||
message.reverse = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,14 +1,213 @@
|
||||
/* eslint-disable */
|
||||
import { Reader, Writer } from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "cosmostest.cosmostest";
|
||||
|
||||
export interface MsgNewAuction {
|
||||
creator: string;
|
||||
owner: string;
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface MsgNewAuctionResponse {
|
||||
auctionId: string;
|
||||
}
|
||||
|
||||
const baseMsgNewAuction: object = {
|
||||
creator: "",
|
||||
owner: "",
|
||||
name: "",
|
||||
description: "",
|
||||
};
|
||||
|
||||
export const MsgNewAuction = {
|
||||
encode(message: MsgNewAuction, writer: Writer = Writer.create()): Writer {
|
||||
if (message.creator !== "") {
|
||||
writer.uint32(10).string(message.creator);
|
||||
}
|
||||
if (message.owner !== "") {
|
||||
writer.uint32(18).string(message.owner);
|
||||
}
|
||||
if (message.name !== "") {
|
||||
writer.uint32(26).string(message.name);
|
||||
}
|
||||
if (message.description !== "") {
|
||||
writer.uint32(34).string(message.description);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgNewAuction {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgNewAuction } as MsgNewAuction;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.owner = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.name = reader.string();
|
||||
break;
|
||||
case 4:
|
||||
message.description = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgNewAuction {
|
||||
const message = { ...baseMsgNewAuction } as MsgNewAuction;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.owner !== undefined && object.owner !== null) {
|
||||
message.owner = String(object.owner);
|
||||
} else {
|
||||
message.owner = "";
|
||||
}
|
||||
if (object.name !== undefined && object.name !== null) {
|
||||
message.name = String(object.name);
|
||||
} else {
|
||||
message.name = "";
|
||||
}
|
||||
if (object.description !== undefined && object.description !== null) {
|
||||
message.description = String(object.description);
|
||||
} else {
|
||||
message.description = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgNewAuction): unknown {
|
||||
const obj: any = {};
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.owner !== undefined && (obj.owner = message.owner);
|
||||
message.name !== undefined && (obj.name = message.name);
|
||||
message.description !== undefined &&
|
||||
(obj.description = message.description);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgNewAuction>): MsgNewAuction {
|
||||
const message = { ...baseMsgNewAuction } as MsgNewAuction;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.owner !== undefined && object.owner !== null) {
|
||||
message.owner = object.owner;
|
||||
} else {
|
||||
message.owner = "";
|
||||
}
|
||||
if (object.name !== undefined && object.name !== null) {
|
||||
message.name = object.name;
|
||||
} else {
|
||||
message.name = "";
|
||||
}
|
||||
if (object.description !== undefined && object.description !== null) {
|
||||
message.description = object.description;
|
||||
} else {
|
||||
message.description = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgNewAuctionResponse: object = { auctionId: "" };
|
||||
|
||||
export const MsgNewAuctionResponse = {
|
||||
encode(
|
||||
message: MsgNewAuctionResponse,
|
||||
writer: Writer = Writer.create()
|
||||
): Writer {
|
||||
if (message.auctionId !== "") {
|
||||
writer.uint32(10).string(message.auctionId);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgNewAuctionResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgNewAuctionResponse } as MsgNewAuctionResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.auctionId = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgNewAuctionResponse {
|
||||
const message = { ...baseMsgNewAuctionResponse } as MsgNewAuctionResponse;
|
||||
if (object.auctionId !== undefined && object.auctionId !== null) {
|
||||
message.auctionId = String(object.auctionId);
|
||||
} else {
|
||||
message.auctionId = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgNewAuctionResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.auctionId !== undefined && (obj.auctionId = message.auctionId);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(
|
||||
object: DeepPartial<MsgNewAuctionResponse>
|
||||
): MsgNewAuctionResponse {
|
||||
const message = { ...baseMsgNewAuctionResponse } as MsgNewAuctionResponse;
|
||||
if (object.auctionId !== undefined && object.auctionId !== null) {
|
||||
message.auctionId = object.auctionId;
|
||||
} else {
|
||||
message.auctionId = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Msg defines the Msg service. */
|
||||
export interface Msg {}
|
||||
export interface Msg {
|
||||
/** this line is used by starport scaffolding # proto/tx/rpc */
|
||||
NewAuction(request: MsgNewAuction): Promise<MsgNewAuctionResponse>;
|
||||
}
|
||||
|
||||
export class MsgClientImpl implements Msg {
|
||||
private readonly rpc: Rpc;
|
||||
constructor(rpc: Rpc) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
NewAuction(request: MsgNewAuction): Promise<MsgNewAuctionResponse> {
|
||||
const data = MsgNewAuction.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"cosmostest.cosmostest.Msg",
|
||||
"NewAuction",
|
||||
data
|
||||
);
|
||||
return promise.then((data) =>
|
||||
MsgNewAuctionResponse.decode(new Reader(data))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
@@ -18,3 +217,14 @@ interface Rpc {
|
||||
data: Uint8Array
|
||||
): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends Array<infer U>
|
||||
? Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
Reference in New Issue
Block a user