mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-07 19:34:25 -08:00
scaffold newBid tx
This commit is contained in:
@@ -232,6 +232,21 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
async sendMsgNewBid({ rootGetters }, { value, fee = [], memo = '' }) {
|
||||
try {
|
||||
const txClient=await initTxClient(rootGetters)
|
||||
const msg = await txClient.msgNewBid(value)
|
||||
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
|
||||
gas: "200000" }, memo})
|
||||
return result
|
||||
} catch (e) {
|
||||
if (e == MissingWalletError) {
|
||||
throw new Error('TxClient:MsgNewBid:Init Could not initialize signing client. Wallet is required.')
|
||||
}else{
|
||||
throw new Error('TxClient:MsgNewBid:Send Could not broadcast Tx: '+ e.message)
|
||||
}
|
||||
}
|
||||
},
|
||||
async sendMsgNewAuction({ rootGetters }, { value, fee = [], memo = '' }) {
|
||||
try {
|
||||
const txClient=await initTxClient(rootGetters)
|
||||
@@ -248,6 +263,19 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
async MsgNewBid({ rootGetters }, { value }) {
|
||||
try {
|
||||
const txClient=await initTxClient(rootGetters)
|
||||
const msg = await txClient.msgNewBid(value)
|
||||
return msg
|
||||
} catch (e) {
|
||||
if (e == MissingWalletError) {
|
||||
throw new Error('TxClient:MsgNewBid:Init Could not initialize signing client. Wallet is required.')
|
||||
} else{
|
||||
throw new Error('TxClient:MsgNewBid:Create Could not create message: ' + e.message)
|
||||
}
|
||||
}
|
||||
},
|
||||
async MsgNewAuction({ rootGetters }, { value }) {
|
||||
try {
|
||||
const txClient=await initTxClient(rootGetters)
|
||||
|
||||
@@ -4,10 +4,12 @@ import { StdFee } from "@cosmjs/launchpad";
|
||||
import { SigningStargateClient } from "@cosmjs/stargate";
|
||||
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||
import { Api } from "./rest";
|
||||
import { MsgNewBid } from "./types/cosmostest/tx";
|
||||
import { MsgNewAuction } from "./types/cosmostest/tx";
|
||||
|
||||
|
||||
const types = [
|
||||
["/cosmostest.cosmostest.MsgNewBid", MsgNewBid],
|
||||
["/cosmostest.cosmostest.MsgNewAuction", MsgNewAuction],
|
||||
|
||||
];
|
||||
@@ -41,6 +43,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),
|
||||
msgNewBid: (data: MsgNewBid): EncodeObject => ({ typeUrl: "/cosmostest.cosmostest.MsgNewBid", value: MsgNewBid.fromPartial( data ) }),
|
||||
msgNewAuction: (data: MsgNewAuction): EncodeObject => ({ typeUrl: "/cosmostest.cosmostest.MsgNewAuction", value: MsgNewAuction.fromPartial( data ) }),
|
||||
|
||||
};
|
||||
|
||||
@@ -25,6 +25,8 @@ export interface CosmostestMsgNewAuctionResponse {
|
||||
auctionId?: string;
|
||||
}
|
||||
|
||||
export type CosmostestMsgNewBidResponse = object;
|
||||
|
||||
export interface CosmostestNextAuction {
|
||||
/** @format uint64 */
|
||||
auctionId?: string;
|
||||
@@ -114,13 +116,6 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +345,6 @@ 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,12 +38,6 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,12 +62,7 @@ export interface PageResponse {
|
||||
total: number;
|
||||
}
|
||||
|
||||
const basePageRequest: object = {
|
||||
offset: 0,
|
||||
limit: 0,
|
||||
count_total: false,
|
||||
reverse: false,
|
||||
};
|
||||
const basePageRequest: object = { offset: 0, limit: 0, count_total: false };
|
||||
|
||||
export const PageRequest = {
|
||||
encode(message: PageRequest, writer: Writer = Writer.create()): Writer {
|
||||
@@ -89,9 +78,6 @@ 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;
|
||||
},
|
||||
|
||||
@@ -114,9 +100,6 @@ export const PageRequest = {
|
||||
case 4:
|
||||
message.count_total = reader.bool();
|
||||
break;
|
||||
case 5:
|
||||
message.reverse = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
@@ -145,11 +128,6 @@ 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;
|
||||
},
|
||||
|
||||
@@ -163,7 +141,6 @@ 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;
|
||||
},
|
||||
|
||||
@@ -189,11 +166,6 @@ 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;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,6 +14,14 @@ export interface MsgNewAuctionResponse {
|
||||
auctionId: string;
|
||||
}
|
||||
|
||||
export interface MsgNewBid {
|
||||
creator: string;
|
||||
auctionIndex: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export interface MsgNewBidResponse {}
|
||||
|
||||
const baseMsgNewAuction: object = {
|
||||
creator: "",
|
||||
owner: "",
|
||||
@@ -186,10 +194,139 @@ export const MsgNewAuctionResponse = {
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgNewBid: object = { creator: "", auctionIndex: "", amount: "" };
|
||||
|
||||
export const MsgNewBid = {
|
||||
encode(message: MsgNewBid, writer: Writer = Writer.create()): Writer {
|
||||
if (message.creator !== "") {
|
||||
writer.uint32(10).string(message.creator);
|
||||
}
|
||||
if (message.auctionIndex !== "") {
|
||||
writer.uint32(18).string(message.auctionIndex);
|
||||
}
|
||||
if (message.amount !== "") {
|
||||
writer.uint32(26).string(message.amount);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgNewBid {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgNewBid } as MsgNewBid;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.creator = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.auctionIndex = reader.string();
|
||||
break;
|
||||
case 3:
|
||||
message.amount = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgNewBid {
|
||||
const message = { ...baseMsgNewBid } as MsgNewBid;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = String(object.creator);
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.auctionIndex !== undefined && object.auctionIndex !== null) {
|
||||
message.auctionIndex = String(object.auctionIndex);
|
||||
} else {
|
||||
message.auctionIndex = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = String(object.amount);
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgNewBid): unknown {
|
||||
const obj: any = {};
|
||||
message.creator !== undefined && (obj.creator = message.creator);
|
||||
message.auctionIndex !== undefined &&
|
||||
(obj.auctionIndex = message.auctionIndex);
|
||||
message.amount !== undefined && (obj.amount = message.amount);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgNewBid>): MsgNewBid {
|
||||
const message = { ...baseMsgNewBid } as MsgNewBid;
|
||||
if (object.creator !== undefined && object.creator !== null) {
|
||||
message.creator = object.creator;
|
||||
} else {
|
||||
message.creator = "";
|
||||
}
|
||||
if (object.auctionIndex !== undefined && object.auctionIndex !== null) {
|
||||
message.auctionIndex = object.auctionIndex;
|
||||
} else {
|
||||
message.auctionIndex = "";
|
||||
}
|
||||
if (object.amount !== undefined && object.amount !== null) {
|
||||
message.amount = object.amount;
|
||||
} else {
|
||||
message.amount = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgNewBidResponse: object = {};
|
||||
|
||||
export const MsgNewBidResponse = {
|
||||
encode(_: MsgNewBidResponse, writer: Writer = Writer.create()): Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: Reader | Uint8Array, length?: number): MsgNewBidResponse {
|
||||
const reader = input instanceof Uint8Array ? new Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgNewBidResponse } as MsgNewBidResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgNewBidResponse {
|
||||
const message = { ...baseMsgNewBidResponse } as MsgNewBidResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgNewBidResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgNewBidResponse>): MsgNewBidResponse {
|
||||
const message = { ...baseMsgNewBidResponse } as MsgNewBidResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Msg defines the Msg service. */
|
||||
export interface Msg {
|
||||
/** this line is used by starport scaffolding # proto/tx/rpc */
|
||||
NewAuction(request: MsgNewAuction): Promise<MsgNewAuctionResponse>;
|
||||
/** this line is used by starport scaffolding # proto/tx/rpc */
|
||||
NewBid(request: MsgNewBid): Promise<MsgNewBidResponse>;
|
||||
}
|
||||
|
||||
export class MsgClientImpl implements Msg {
|
||||
@@ -208,6 +345,16 @@ export class MsgClientImpl implements Msg {
|
||||
MsgNewAuctionResponse.decode(new Reader(data))
|
||||
);
|
||||
}
|
||||
|
||||
NewBid(request: MsgNewBid): Promise<MsgNewBidResponse> {
|
||||
const data = MsgNewBid.encode(request).finish();
|
||||
const promise = this.rpc.request(
|
||||
"cosmostest.cosmostest.Msg",
|
||||
"NewBid",
|
||||
data
|
||||
);
|
||||
return promise.then((data) => MsgNewBidResponse.decode(new Reader(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
|
||||
Reference in New Issue
Block a user