From 3b8dac0b2d3543bbe7a278df9f20a05074e2b8bf Mon Sep 17 00:00:00 2001 From: Tugay Emin Date: Tue, 7 Feb 2023 13:11:45 +0200 Subject: [PATCH] implement auctions + script for generating proto-types --- generate-proto-types.sh | 19 + package.json | 6 +- src/stargate/cudos-signingstargateclient.ts | 61 ++ src/stargate/modules/index.ts | 1 + src/stargate/modules/marketplace/auctions.ts | 32 + .../marketplace/clients/queryClient.ts | 12 +- src/stargate/modules/marketplace/module.ts | 89 ++- .../marketplace/proto-types/auction.ts | 436 +++++++++++++ .../modules/marketplace/proto-types/nft.ts | 26 +- .../modules/marketplace/proto-types/query.ts | 421 ++++++++++-- .../modules/marketplace/proto-types/tx.ts | 615 ++++++++++++++++-- src/stargate/modules/marketplace/queries.ts | 14 +- src/stargate/modules/marketplace/types.ts | 27 + tests/marketplace-tx.test.ts | 13 + 14 files changed, 1634 insertions(+), 138 deletions(-) create mode 100755 generate-proto-types.sh create mode 100644 src/stargate/modules/marketplace/auctions.ts create mode 100644 src/stargate/modules/marketplace/proto-types/auction.ts diff --git a/generate-proto-types.sh b/generate-proto-types.sh new file mode 100755 index 0000000..e661df8 --- /dev/null +++ b/generate-proto-types.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck >/dev/null && shellcheck "$0" + +read -p "Enter full path to your cudos-node root directory:" CUDOS_NODE_DIR +CUDOS_NODE_PROTO_DIR="$(realpath $CUDOS_NODE_DIR/proto)" +THIRD_PARTY_PROTO_DIR="$(realpath $CUDOS_NODE_DIR/third_party/proto)" +TS_PROTO_OPTS="esModuleInterop=true,forceLong=long,useOptionals=messages,useDate=false" + +read -p "Enter output folder:" OUT_DIR +mkdir -p "$OUT_DIR" + +protoc \ +--plugin="$(yarn bin protoc-gen-ts_proto)" \ +--ts_proto_out="$OUT_DIR" \ +--proto_path="$CUDOS_NODE_PROTO_DIR" \ +--proto_path="$THIRD_PARTY_PROTO_DIR" \ +--ts_proto_opt="$TS_PROTO_OPTS" \ +$CUDOS_NODE_PROTO_DIR/*/**.proto \ No newline at end of file diff --git a/package.json b/package.json index 7e451c5..4e20431 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "test": "cd tests && chmod u+x run-tests.sh && ./run-tests.sh", "build": "rm -rf ./build && tsc", "build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build", - "pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js" + "pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js", + "generate-proto-types": "./generate-proto-types.sh" }, "files": [ "build/", @@ -49,9 +50,10 @@ "ts-jest": "^28.0.5", "ts-loader": "^9.2.6", "ts-node": "^8", + "ts-proto": "^1.139.0", "tslib": "^2.4.1", "typescript": "^4.4.3", "webpack": "^5.53.0", "webpack-cli": "^4.8.0" } -} +} \ No newline at end of file diff --git a/src/stargate/cudos-signingstargateclient.ts b/src/stargate/cudos-signingstargateclient.ts index fdb8373..b6a2ac9 100644 --- a/src/stargate/cudos-signingstargateclient.ts +++ b/src/stargate/cudos-signingstargateclient.ts @@ -31,6 +31,8 @@ import { Int53 } from "../math"; import { MarketplaceModule } from "./modules/marketplace/module"; import { AddressbookModule } from "./modules/addressbook/module"; import { Royalty } from "./modules/marketplace/proto-types/royalty"; +import { Duration } from "cosmjs-types/google/protobuf/duration"; +import { DutchAuctionRequest, EnglishAuctionRequest } from "./modules/marketplace/auctions"; export class CudosSigningStargateClient extends SigningStargateClient { private readonly directSigner: OfflineDirectSigner | undefined; @@ -730,4 +732,63 @@ export class CudosSigningStargateClient extends SigningStargateClient { ); return this.signAndBroadcast(creator, [msg], fee, memo); } + + public async marketplacePublishAuction( + creator: string, + tokenId: string, + denomId: string, + duration: Duration, + auction: EnglishAuctionRequest | DutchAuctionRequest, + gasPrice: GasPrice, + gasMultiplier = DEFAULT_GAS_MULTIPLIER, + memo = "" + ): Promise { + const { msg, fee } = await this.marketplaceModule.msgPublishAuction( + creator, + tokenId, + denomId, + duration, + auction, + gasPrice, + gasMultiplier, + memo + ); + return this.signAndBroadcast(creator, [msg], fee, memo); + } + + public async marketplacePlaceBid( + bidder: string, + auctionId: string, + amount: Coin, + gasPrice: GasPrice, + gasMultiplier = DEFAULT_GAS_MULTIPLIER, + memo = "" + ): Promise { + const { msg, fee } = await this.marketplaceModule.msgPlaceBid( + bidder, + auctionId, + amount, + gasPrice, + gasMultiplier, + memo + ); + return this.signAndBroadcast(bidder, [msg], fee, memo); + } + + public async marketplaceAcceptBid( + sender: string, + auctionId: string, + gasPrice: GasPrice, + gasMultiplier = DEFAULT_GAS_MULTIPLIER, + memo = "" + ): Promise { + const { msg, fee } = await this.marketplaceModule.msgAcceptBid( + sender, + auctionId, + gasPrice, + gasMultiplier, + memo + ); + return this.signAndBroadcast(sender, [msg], fee, memo); + } } diff --git a/src/stargate/modules/index.ts b/src/stargate/modules/index.ts index 1eddc31..74a5da4 100644 --- a/src/stargate/modules/index.ts +++ b/src/stargate/modules/index.ts @@ -9,6 +9,7 @@ export * as nftQueryProto from './nft/proto-types/query' export * as marketplaceMsgProto from './marketplace/proto-types/tx' export * as marketplaceQueryProto from './marketplace/proto-types/query' +export * as marketplaceAuctionProto from './marketplace/proto-types/auction' export * as addressbookMsgProto from './addressbook/proto-types/tx' export * as addressbookQueryProto from './addressbook/proto-types/query' \ No newline at end of file diff --git a/src/stargate/modules/marketplace/auctions.ts b/src/stargate/modules/marketplace/auctions.ts new file mode 100644 index 0000000..99dbe28 --- /dev/null +++ b/src/stargate/modules/marketplace/auctions.ts @@ -0,0 +1,32 @@ +import { Any } from "cosmjs-types/google/protobuf/any"; +import { EnglishAuction, DutchAuction } from "./proto-types/auction"; +import { Coin } from "./proto-types/coin"; +import { dutchAuction, englishAuction } from "./types"; + +export type EnglishAuctionRequest = { + minPrice: Coin; +}; + +export type DutchAuctionRequest = { + startPrice: Coin; + minPrice: Coin; +}; + +export function encodeAuction(auctionReq: EnglishAuctionRequest | DutchAuctionRequest): Any { + if ("startPrice" in auctionReq) { + return { + typeUrl: dutchAuction.typeUrl, + value: DutchAuction.encode(DutchAuction.fromPartial({ + minPrice: auctionReq.minPrice, + startPrice: auctionReq.startPrice, + })).finish() + }; + } else { + return { + typeUrl: englishAuction.typeUrl, + value: EnglishAuction.encode(EnglishAuction.fromPartial({ + minPrice: auctionReq.minPrice, + })).finish() + }; + } +} diff --git a/src/stargate/modules/marketplace/clients/queryClient.ts b/src/stargate/modules/marketplace/clients/queryClient.ts index 233aa07..d4f121d 100644 --- a/src/stargate/modules/marketplace/clients/queryClient.ts +++ b/src/stargate/modules/marketplace/clients/queryClient.ts @@ -8,7 +8,9 @@ import { QueryGetNftResponse, QueryAllNftResponse, QueryParamsResponse, - QueryListAdminsResponse + QueryListAdminsResponse, + QueryAllAuctionResponse, + QueryGetAuctionResponse } from '../proto-types/query'; import { PageRequest } from 'cosmjs-types/cosmos/base/query/v1beta1/pagination'; @@ -50,4 +52,12 @@ export class MarketplaceQueryClient { public async getAdmins(): Promise { return this.queryClient.marketplace.admins(); } + + public async getAuction(id: Long): Promise { + return this.queryClient.marketplace.auction(id); + } + + public async getAllAuctions(pagination?: PageRequest): Promise { + return this.queryClient.marketplace.allAuctions(pagination); + } } \ No newline at end of file diff --git a/src/stargate/modules/marketplace/module.ts b/src/stargate/modules/marketplace/module.ts index d80c794..2b7ea7b 100644 --- a/src/stargate/modules/marketplace/module.ts +++ b/src/stargate/modules/marketplace/module.ts @@ -12,7 +12,10 @@ import { MsgCreateCollection, MsgPublishCollection, MsgPublishNft, MsgMintNft, MsgAddAdmin, MsgRemoveAdmin } from './proto-types/tx'; import { Royalty } from './proto-types/royalty'; - +import { msgPublishAuction, msgPlaceBid, msgAcceptBid } from './types'; +import { Duration } from 'cosmjs-types/google/protobuf/duration'; +import { MsgPublishAuction, MsgPlaceBid, MsgAcceptBid } from './proto-types/tx'; +import { encodeAuction, EnglishAuctionRequest, DutchAuctionRequest } from './auctions'; export class MarketplaceModule { private readonly _client: ClientSimulateFn; @@ -31,7 +34,10 @@ export class MarketplaceModule { msgVerifyCollection, msgUnverifyCollection, msgAddAdmin, - msgRemoveAdmin + msgRemoveAdmin, + msgPublishAuction, + msgPlaceBid, + msgAcceptBid ]); } @@ -366,4 +372,81 @@ export class MarketplaceModule { fee: fee } } -} \ No newline at end of file + + public async msgPublishAuction( + creator: string, + tokenId: string, + denomId: string, + duration: Duration, + auction: EnglishAuctionRequest | DutchAuctionRequest, + gasPrice: GasPrice, + gasMultiplier = DEFAULT_GAS_MULTIPLIER, + memo = "" + ): Promise<{ msg: EncodeObject; fee: StdFee }> { + const msgEncoded = { + typeUrl: msgPublishAuction.typeUrl, + value: MsgPublishAuction.fromPartial({ + creator: creator, + denomId: denomId, + tokenId: tokenId, + duration: duration, + auction: encodeAuction(auction) + }) + }; + + const fee = await estimateFee(this._client, creator, [msgEncoded], gasPrice, gasMultiplier, memo); + + return { + msg: msgEncoded, + fee: fee + }; + } + + public async msgPlaceBid( + bidder: string, + auctionId: string, + amount: Coin, + gasPrice: GasPrice, + gasMultiplier = DEFAULT_GAS_MULTIPLIER, + memo = "" + ): Promise<{ msg: EncodeObject; fee: StdFee }> { + const msgEncoded = { + typeUrl: msgPlaceBid.typeUrl, + value: MsgPlaceBid.fromPartial({ + bidder: bidder, + auctionId: auctionId, + amount: amount + }) + }; + + const fee = await estimateFee(this._client, bidder, [msgEncoded], gasPrice, gasMultiplier, memo); + + return { + msg: msgEncoded, + fee: fee + }; + } + + public async msgAcceptBid( + sender: string, + auctionId: string, + gasPrice: GasPrice, + gasMultiplier = DEFAULT_GAS_MULTIPLIER, + memo = "" + ): Promise<{ msg: EncodeObject; fee: StdFee }> { + const msgEncoded = { + typeUrl: msgAcceptBid.typeUrl, + value: MsgAcceptBid.fromPartial({ + sender: sender, + auctionId: auctionId + }) + }; + + const fee = await estimateFee(this._client, sender, [msgEncoded], gasPrice, gasMultiplier, memo); + + return { + msg: msgEncoded, + fee: fee, + }; + } +} diff --git a/src/stargate/modules/marketplace/proto-types/auction.ts b/src/stargate/modules/marketplace/proto-types/auction.ts new file mode 100644 index 0000000..7fab8e5 --- /dev/null +++ b/src/stargate/modules/marketplace/proto-types/auction.ts @@ -0,0 +1,436 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Coin } from "./coin"; +import { Timestamp } from "cosmjs-types/google/protobuf/timestamp"; + +export const protobufPackage = "cudoventures.cudosnode.marketplace"; + +export interface BaseAuction { + id: Long; + denomId: string; + tokenId: string; + startTime?: Timestamp; + endTime?: Timestamp; + creator: string; +} + +export interface Bid { + amount?: Coin; + bidder: string; +} + +export interface EnglishAuction { + baseAuction?: BaseAuction; + minPrice?: Coin; + currentBid?: Bid; +} + +export interface DutchAuction { + baseAuction?: BaseAuction; + startPrice?: Coin; + minPrice?: Coin; + currentPrice?: Coin; + nextDiscountTime?: Timestamp; +} + +function createBaseBaseAuction(): BaseAuction { + return { id: Long.UZERO, denomId: "", tokenId: "", startTime: undefined, endTime: undefined, creator: "" }; +} + +export const BaseAuction = { + encode(message: BaseAuction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.id.isZero()) { + writer.uint32(8).uint64(message.id); + } + if (message.denomId !== "") { + writer.uint32(18).string(message.denomId); + } + if (message.tokenId !== "") { + writer.uint32(26).string(message.tokenId); + } + if (message.startTime !== undefined) { + Timestamp.encode(message.startTime, writer.uint32(34).fork()).ldelim(); + } + if (message.endTime !== undefined) { + Timestamp.encode(message.endTime, writer.uint32(42).fork()).ldelim(); + } + if (message.creator !== "") { + writer.uint32(50).string(message.creator); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): BaseAuction { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBaseAuction(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint64() as Long; + break; + case 2: + message.denomId = reader.string(); + break; + case 3: + message.tokenId = reader.string(); + break; + case 4: + message.startTime = Timestamp.decode(reader, reader.uint32()); + break; + case 5: + message.endTime = Timestamp.decode(reader, reader.uint32()); + break; + case 6: + message.creator = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BaseAuction { + return { + id: isSet(object.id) ? Long.fromValue(object.id) : Long.UZERO, + denomId: isSet(object.denomId) ? String(object.denomId) : "", + tokenId: isSet(object.tokenId) ? String(object.tokenId) : "", + startTime: isSet(object.startTime) ? fromJsonTimestamp(object.startTime) : undefined, + endTime: isSet(object.endTime) ? fromJsonTimestamp(object.endTime) : undefined, + creator: isSet(object.creator) ? String(object.creator) : "", + }; + }, + + toJSON(message: BaseAuction): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || Long.UZERO).toString()); + message.denomId !== undefined && (obj.denomId = message.denomId); + message.tokenId !== undefined && (obj.tokenId = message.tokenId); + message.startTime !== undefined && (obj.startTime = fromTimestamp(message.startTime).toISOString()); + message.endTime !== undefined && (obj.endTime = fromTimestamp(message.endTime).toISOString()); + message.creator !== undefined && (obj.creator = message.creator); + return obj; + }, + + create, I>>(base?: I): BaseAuction { + return BaseAuction.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): BaseAuction { + const message = createBaseBaseAuction(); + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; + message.denomId = object.denomId ?? ""; + message.tokenId = object.tokenId ?? ""; + message.startTime = (object.startTime !== undefined && object.startTime !== null) + ? Timestamp.fromPartial(object.startTime) + : undefined; + message.endTime = (object.endTime !== undefined && object.endTime !== null) + ? Timestamp.fromPartial(object.endTime) + : undefined; + message.creator = object.creator ?? ""; + return message; + }, +}; + +function createBaseBid(): Bid { + return { amount: undefined, bidder: "" }; +} + +export const Bid = { + encode(message: Bid, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(10).fork()).ldelim(); + } + if (message.bidder !== "") { + writer.uint32(18).string(message.bidder); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Bid { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBid(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.bidder = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Bid { + return { + amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined, + bidder: isSet(object.bidder) ? String(object.bidder) : "", + }; + }, + + toJSON(message: Bid): unknown { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + message.bidder !== undefined && (obj.bidder = message.bidder); + return obj; + }, + + create, I>>(base?: I): Bid { + return Bid.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): Bid { + const message = createBaseBid(); + message.amount = (object.amount !== undefined && object.amount !== null) + ? Coin.fromPartial(object.amount) + : undefined; + message.bidder = object.bidder ?? ""; + return message; + }, +}; + +function createBaseEnglishAuction(): EnglishAuction { + return { baseAuction: undefined, minPrice: undefined, currentBid: undefined }; +} + +export const EnglishAuction = { + encode(message: EnglishAuction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.baseAuction !== undefined) { + BaseAuction.encode(message.baseAuction, writer.uint32(10).fork()).ldelim(); + } + if (message.minPrice !== undefined) { + Coin.encode(message.minPrice, writer.uint32(18).fork()).ldelim(); + } + if (message.currentBid !== undefined) { + Bid.encode(message.currentBid, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): EnglishAuction { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnglishAuction(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAuction = BaseAuction.decode(reader, reader.uint32()); + break; + case 2: + message.minPrice = Coin.decode(reader, reader.uint32()); + break; + case 3: + message.currentBid = Bid.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnglishAuction { + return { + baseAuction: isSet(object.baseAuction) ? BaseAuction.fromJSON(object.baseAuction) : undefined, + minPrice: isSet(object.minPrice) ? Coin.fromJSON(object.minPrice) : undefined, + currentBid: isSet(object.currentBid) ? Bid.fromJSON(object.currentBid) : undefined, + }; + }, + + toJSON(message: EnglishAuction): unknown { + const obj: any = {}; + message.baseAuction !== undefined && + (obj.baseAuction = message.baseAuction ? BaseAuction.toJSON(message.baseAuction) : undefined); + message.minPrice !== undefined && (obj.minPrice = message.minPrice ? Coin.toJSON(message.minPrice) : undefined); + message.currentBid !== undefined && + (obj.currentBid = message.currentBid ? Bid.toJSON(message.currentBid) : undefined); + return obj; + }, + + create, I>>(base?: I): EnglishAuction { + return EnglishAuction.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): EnglishAuction { + const message = createBaseEnglishAuction(); + message.baseAuction = (object.baseAuction !== undefined && object.baseAuction !== null) + ? BaseAuction.fromPartial(object.baseAuction) + : undefined; + message.minPrice = (object.minPrice !== undefined && object.minPrice !== null) + ? Coin.fromPartial(object.minPrice) + : undefined; + message.currentBid = (object.currentBid !== undefined && object.currentBid !== null) + ? Bid.fromPartial(object.currentBid) + : undefined; + return message; + }, +}; + +function createBaseDutchAuction(): DutchAuction { + return { + baseAuction: undefined, + startPrice: undefined, + minPrice: undefined, + currentPrice: undefined, + nextDiscountTime: undefined, + }; +} + +export const DutchAuction = { + encode(message: DutchAuction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.baseAuction !== undefined) { + BaseAuction.encode(message.baseAuction, writer.uint32(10).fork()).ldelim(); + } + if (message.startPrice !== undefined) { + Coin.encode(message.startPrice, writer.uint32(18).fork()).ldelim(); + } + if (message.minPrice !== undefined) { + Coin.encode(message.minPrice, writer.uint32(26).fork()).ldelim(); + } + if (message.currentPrice !== undefined) { + Coin.encode(message.currentPrice, writer.uint32(34).fork()).ldelim(); + } + if (message.nextDiscountTime !== undefined) { + Timestamp.encode(message.nextDiscountTime, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DutchAuction { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDutchAuction(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAuction = BaseAuction.decode(reader, reader.uint32()); + break; + case 2: + message.startPrice = Coin.decode(reader, reader.uint32()); + break; + case 3: + message.minPrice = Coin.decode(reader, reader.uint32()); + break; + case 4: + message.currentPrice = Coin.decode(reader, reader.uint32()); + break; + case 5: + message.nextDiscountTime = Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DutchAuction { + return { + baseAuction: isSet(object.baseAuction) ? BaseAuction.fromJSON(object.baseAuction) : undefined, + startPrice: isSet(object.startPrice) ? Coin.fromJSON(object.startPrice) : undefined, + minPrice: isSet(object.minPrice) ? Coin.fromJSON(object.minPrice) : undefined, + currentPrice: isSet(object.currentPrice) ? Coin.fromJSON(object.currentPrice) : undefined, + nextDiscountTime: isSet(object.nextDiscountTime) ? fromJsonTimestamp(object.nextDiscountTime) : undefined, + }; + }, + + toJSON(message: DutchAuction): unknown { + const obj: any = {}; + message.baseAuction !== undefined && + (obj.baseAuction = message.baseAuction ? BaseAuction.toJSON(message.baseAuction) : undefined); + message.startPrice !== undefined && + (obj.startPrice = message.startPrice ? Coin.toJSON(message.startPrice) : undefined); + message.minPrice !== undefined && (obj.minPrice = message.minPrice ? Coin.toJSON(message.minPrice) : undefined); + message.currentPrice !== undefined && + (obj.currentPrice = message.currentPrice ? Coin.toJSON(message.currentPrice) : undefined); + message.nextDiscountTime !== undefined && + (obj.nextDiscountTime = fromTimestamp(message.nextDiscountTime).toISOString()); + return obj; + }, + + create, I>>(base?: I): DutchAuction { + return DutchAuction.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): DutchAuction { + const message = createBaseDutchAuction(); + message.baseAuction = (object.baseAuction !== undefined && object.baseAuction !== null) + ? BaseAuction.fromPartial(object.baseAuction) + : undefined; + message.startPrice = (object.startPrice !== undefined && object.startPrice !== null) + ? Coin.fromPartial(object.startPrice) + : undefined; + message.minPrice = (object.minPrice !== undefined && object.minPrice !== null) + ? Coin.fromPartial(object.minPrice) + : undefined; + message.currentPrice = (object.currentPrice !== undefined && object.currentPrice !== null) + ? Coin.fromPartial(object.currentPrice) + : undefined; + message.nextDiscountTime = (object.nextDiscountTime !== undefined && object.nextDiscountTime !== null) + ? Timestamp.fromPartial(object.nextDiscountTime) + : undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function toTimestamp(date: Date): Timestamp { + const seconds = numberToLong(date.getTime() / 1_000); + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds.toNumber() * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Timestamp { + if (o instanceof Date) { + return toTimestamp(o); + } else if (typeof o === "string") { + return toTimestamp(new Date(o)); + } else { + return Timestamp.fromJSON(o); + } +} + +function numberToLong(number: number) { + return Long.fromNumber(number); +} + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/src/stargate/modules/marketplace/proto-types/nft.ts b/src/stargate/modules/marketplace/proto-types/nft.ts index 1f76ba6..912998c 100644 --- a/src/stargate/modules/marketplace/proto-types/nft.ts +++ b/src/stargate/modules/marketplace/proto-types/nft.ts @@ -88,13 +88,16 @@ export const Nft = { return obj; }, + create, I>>(base?: I): Nft { + return Nft.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): Nft { const message = createBaseNft(); - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; message.tokenId = object.tokenId ?? ""; message.denomId = object.denomId ?? ""; - message.price = - object.price !== undefined && object.price !== null ? Coin.fromPartial(object.price) : undefined; + message.price = (object.price !== undefined && object.price !== null) ? Coin.fromPartial(object.price) : undefined; message.owner = object.owner ?? ""; return message; }, @@ -102,21 +105,14 @@ export const Nft = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Long - ? string | number | Long - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; if (_m0.util.Long !== Long) { diff --git a/src/stargate/modules/marketplace/proto-types/query.ts b/src/stargate/modules/marketplace/proto-types/query.ts index e717861..e17bc90 100644 --- a/src/stargate/modules/marketplace/proto-types/query.ts +++ b/src/stargate/modules/marketplace/proto-types/query.ts @@ -2,6 +2,7 @@ import Long from "long"; import _m0 from "protobufjs/minimal"; import { PageRequest, PageResponse } from "cosmjs-types/cosmos/base/query/v1beta1/pagination"; +import { Any } from "cosmjs-types/google/protobuf/any"; import { Collection } from "./collection"; import { Nft } from "./nft"; import { Params } from "./params"; @@ -9,7 +10,8 @@ import { Params } from "./params"; export const protobufPackage = "cudoventures.cudosnode.marketplace"; /** QueryParamsRequest is request type for the Query/Params RPC method. */ -export interface QueryParamsRequest {} +export interface QueryParamsRequest { +} /** QueryParamsResponse is response type for the Query/Params RPC method. */ export interface QueryParamsResponse { @@ -59,12 +61,30 @@ export interface QueryCollectionByDenomIdResponse { Collection?: Collection; } -export interface QueryListAdminsRequest {} +export interface QueryListAdminsRequest { +} export interface QueryListAdminsResponse { Admins: string[]; } +export interface QueryGetAuctionRequest { + id: Long; +} + +export interface QueryGetAuctionResponse { + Auction?: Any; +} + +export interface QueryAllAuctionRequest { + pagination?: PageRequest; +} + +export interface QueryAllAuctionResponse { + Auctions: Any[]; + pagination?: PageResponse; +} + function createBaseQueryParamsRequest(): QueryParamsRequest { return {}; } @@ -98,6 +118,10 @@ export const QueryParamsRequest = { return obj; }, + create, I>>(base?: I): QueryParamsRequest { + return QueryParamsRequest.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -144,10 +168,15 @@ export const QueryParamsResponse = { return obj; }, + create, I>>(base?: I): QueryParamsResponse { + return QueryParamsResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); - message.params = - object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; + message.params = (object.params !== undefined && object.params !== null) + ? Params.fromPartial(object.params) + : undefined; return message; }, }; @@ -192,11 +221,13 @@ export const QueryGetCollectionRequest = { return obj; }, - fromPartial, I>>( - object: I, - ): QueryGetCollectionRequest { + create, I>>(base?: I): QueryGetCollectionRequest { + return QueryGetCollectionRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryGetCollectionRequest { const message = createBaseQueryGetCollectionRequest(); - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; return message; }, }; @@ -242,14 +273,15 @@ export const QueryGetCollectionResponse = { return obj; }, - fromPartial, I>>( - object: I, - ): QueryGetCollectionResponse { + create, I>>(base?: I): QueryGetCollectionResponse { + return QueryGetCollectionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryGetCollectionResponse { const message = createBaseQueryGetCollectionResponse(); - message.Collection = - object.Collection !== undefined && object.Collection !== null - ? Collection.fromPartial(object.Collection) - : undefined; + message.Collection = (object.Collection !== undefined && object.Collection !== null) + ? Collection.fromPartial(object.Collection) + : undefined; return message; }, }; @@ -295,14 +327,15 @@ export const QueryAllCollectionRequest = { return obj; }, - fromPartial, I>>( - object: I, - ): QueryAllCollectionRequest { + create, I>>(base?: I): QueryAllCollectionRequest { + return QueryAllCollectionRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryAllCollectionRequest { const message = createBaseQueryAllCollectionRequest(); - message.pagination = - object.pagination !== undefined && object.pagination !== null - ? PageRequest.fromPartial(object.pagination) - : undefined; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageRequest.fromPartial(object.pagination) + : undefined; return message; }, }; @@ -345,9 +378,7 @@ export const QueryAllCollectionResponse = { fromJSON(object: any): QueryAllCollectionResponse { return { - Collection: Array.isArray(object?.Collection) - ? object.Collection.map((e: any) => Collection.fromJSON(e)) - : [], + Collection: Array.isArray(object?.Collection) ? object.Collection.map((e: any) => Collection.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; }, @@ -355,7 +386,7 @@ export const QueryAllCollectionResponse = { toJSON(message: QueryAllCollectionResponse): unknown { const obj: any = {}; if (message.Collection) { - obj.Collection = message.Collection.map((e) => (e ? Collection.toJSON(e) : undefined)); + obj.Collection = message.Collection.map((e) => e ? Collection.toJSON(e) : undefined); } else { obj.Collection = []; } @@ -364,15 +395,16 @@ export const QueryAllCollectionResponse = { return obj; }, - fromPartial, I>>( - object: I, - ): QueryAllCollectionResponse { + create, I>>(base?: I): QueryAllCollectionResponse { + return QueryAllCollectionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryAllCollectionResponse { const message = createBaseQueryAllCollectionResponse(); message.Collection = object.Collection?.map((e) => Collection.fromPartial(e)) || []; - message.pagination = - object.pagination !== undefined && object.pagination !== null - ? PageResponse.fromPartial(object.pagination) - : undefined; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageResponse.fromPartial(object.pagination) + : undefined; return message; }, }; @@ -417,9 +449,13 @@ export const QueryGetNftRequest = { return obj; }, + create, I>>(base?: I): QueryGetNftRequest { + return QueryGetNftRequest.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): QueryGetNftRequest { const message = createBaseQueryGetNftRequest(); - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; return message; }, }; @@ -464,9 +500,13 @@ export const QueryGetNftResponse = { return obj; }, + create, I>>(base?: I): QueryGetNftResponse { + return QueryGetNftResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): QueryGetNftResponse { const message = createBaseQueryGetNftResponse(); - message.Nft = object.Nft !== undefined && object.Nft !== null ? Nft.fromPartial(object.Nft) : undefined; + message.Nft = (object.Nft !== undefined && object.Nft !== null) ? Nft.fromPartial(object.Nft) : undefined; return message; }, }; @@ -512,12 +552,15 @@ export const QueryAllNftRequest = { return obj; }, + create, I>>(base?: I): QueryAllNftRequest { + return QueryAllNftRequest.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): QueryAllNftRequest { const message = createBaseQueryAllNftRequest(); - message.pagination = - object.pagination !== undefined && object.pagination !== null - ? PageRequest.fromPartial(object.pagination) - : undefined; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageRequest.fromPartial(object.pagination) + : undefined; return message; }, }; @@ -568,7 +611,7 @@ export const QueryAllNftResponse = { toJSON(message: QueryAllNftResponse): unknown { const obj: any = {}; if (message.Nft) { - obj.Nft = message.Nft.map((e) => (e ? Nft.toJSON(e) : undefined)); + obj.Nft = message.Nft.map((e) => e ? Nft.toJSON(e) : undefined); } else { obj.Nft = []; } @@ -577,13 +620,16 @@ export const QueryAllNftResponse = { return obj; }, + create, I>>(base?: I): QueryAllNftResponse { + return QueryAllNftResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): QueryAllNftResponse { const message = createBaseQueryAllNftResponse(); message.Nft = object.Nft?.map((e) => Nft.fromPartial(e)) || []; - message.pagination = - object.pagination !== undefined && object.pagination !== null - ? PageResponse.fromPartial(object.pagination) - : undefined; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageResponse.fromPartial(object.pagination) + : undefined; return message; }, }; @@ -628,6 +674,10 @@ export const QueryCollectionByDenomIdRequest = { return obj; }, + create, I>>(base?: I): QueryCollectionByDenomIdRequest { + return QueryCollectionByDenomIdRequest.fromPartial(base ?? {}); + }, + fromPartial, I>>( object: I, ): QueryCollectionByDenomIdRequest { @@ -678,14 +728,19 @@ export const QueryCollectionByDenomIdResponse = { return obj; }, + create, I>>( + base?: I, + ): QueryCollectionByDenomIdResponse { + return QueryCollectionByDenomIdResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>( object: I, ): QueryCollectionByDenomIdResponse { const message = createBaseQueryCollectionByDenomIdResponse(); - message.Collection = - object.Collection !== undefined && object.Collection !== null - ? Collection.fromPartial(object.Collection) - : undefined; + message.Collection = (object.Collection !== undefined && object.Collection !== null) + ? Collection.fromPartial(object.Collection) + : undefined; return message; }, }; @@ -723,6 +778,10 @@ export const QueryListAdminsRequest = { return obj; }, + create, I>>(base?: I): QueryListAdminsRequest { + return QueryListAdminsRequest.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): QueryListAdminsRequest { const message = createBaseQueryListAdminsRequest(); return message; @@ -773,6 +832,10 @@ export const QueryListAdminsResponse = { return obj; }, + create, I>>(base?: I): QueryListAdminsResponse { + return QueryListAdminsResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): QueryListAdminsResponse { const message = createBaseQueryListAdminsResponse(); message.Admins = object.Admins?.map((e) => e) || []; @@ -780,6 +843,233 @@ export const QueryListAdminsResponse = { }, }; +function createBaseQueryGetAuctionRequest(): QueryGetAuctionRequest { + return { id: Long.UZERO }; +} + +export const QueryGetAuctionRequest = { + encode(message: QueryGetAuctionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.id.isZero()) { + writer.uint32(8).uint64(message.id); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryGetAuctionRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGetAuctionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetAuctionRequest { + return { id: isSet(object.id) ? Long.fromValue(object.id) : Long.UZERO }; + }, + + toJSON(message: QueryGetAuctionRequest): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || Long.UZERO).toString()); + return obj; + }, + + create, I>>(base?: I): QueryGetAuctionRequest { + return QueryGetAuctionRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryGetAuctionRequest { + const message = createBaseQueryGetAuctionRequest(); + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; + return message; + }, +}; + +function createBaseQueryGetAuctionResponse(): QueryGetAuctionResponse { + return { Auction: undefined }; +} + +export const QueryGetAuctionResponse = { + encode(message: QueryGetAuctionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.Auction !== undefined) { + Any.encode(message.Auction, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryGetAuctionResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGetAuctionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.Auction = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetAuctionResponse { + return { Auction: isSet(object.Auction) ? Any.fromJSON(object.Auction) : undefined }; + }, + + toJSON(message: QueryGetAuctionResponse): unknown { + const obj: any = {}; + message.Auction !== undefined && (obj.Auction = message.Auction ? Any.toJSON(message.Auction) : undefined); + return obj; + }, + + create, I>>(base?: I): QueryGetAuctionResponse { + return QueryGetAuctionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryGetAuctionResponse { + const message = createBaseQueryGetAuctionResponse(); + message.Auction = (object.Auction !== undefined && object.Auction !== null) + ? Any.fromPartial(object.Auction) + : undefined; + return message; + }, +}; + +function createBaseQueryAllAuctionRequest(): QueryAllAuctionRequest { + return { pagination: undefined }; +} + +export const QueryAllAuctionRequest = { + encode(message: QueryAllAuctionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllAuctionRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllAuctionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllAuctionRequest { + return { pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined }; + }, + + toJSON(message: QueryAllAuctionRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + create, I>>(base?: I): QueryAllAuctionRequest { + return QueryAllAuctionRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryAllAuctionRequest { + const message = createBaseQueryAllAuctionRequest(); + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageRequest.fromPartial(object.pagination) + : undefined; + return message; + }, +}; + +function createBaseQueryAllAuctionResponse(): QueryAllAuctionResponse { + return { Auctions: [], pagination: undefined }; +} + +export const QueryAllAuctionResponse = { + encode(message: QueryAllAuctionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.Auctions) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllAuctionResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllAuctionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.Auctions.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllAuctionResponse { + return { + Auctions: Array.isArray(object?.Auctions) ? object.Auctions.map((e: any) => Any.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllAuctionResponse): unknown { + const obj: any = {}; + if (message.Auctions) { + obj.Auctions = message.Auctions.map((e) => e ? Any.toJSON(e) : undefined); + } else { + obj.Auctions = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + create, I>>(base?: I): QueryAllAuctionResponse { + return QueryAllAuctionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): QueryAllAuctionResponse { + const message = createBaseQueryAllAuctionResponse(); + message.Auctions = object.Auctions?.map((e) => Any.fromPartial(e)) || []; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageResponse.fromPartial(object.pagination) + : undefined; + return message; + }, +}; + /** Query defines the gRPC querier service. */ export interface Query { /** Parameters queries the parameters of the module. */ @@ -796,6 +1086,10 @@ export interface Query { CollectionByDenomId(request: QueryCollectionByDenomIdRequest): Promise; /** Queries a list of ListAdmins items. */ ListAdmins(request: QueryListAdminsRequest): Promise; + /** Queries a Auction by id. */ + Auction(request: QueryGetAuctionRequest): Promise; + /** Queries a list of Auction items. */ + AuctionAll(request: QueryAllAuctionRequest): Promise; } export class QueryClientImpl implements Query { @@ -811,6 +1105,8 @@ export class QueryClientImpl implements Query { this.NftAll = this.NftAll.bind(this); this.CollectionByDenomId = this.CollectionByDenomId.bind(this); this.ListAdmins = this.ListAdmins.bind(this); + this.Auction = this.Auction.bind(this); + this.AuctionAll = this.AuctionAll.bind(this); } Params(request: QueryParamsRequest): Promise { const data = QueryParamsRequest.encode(request).finish(); @@ -853,6 +1149,18 @@ export class QueryClientImpl implements Query { const promise = this.rpc.request(this.service, "ListAdmins", data); return promise.then((data) => QueryListAdminsResponse.decode(new _m0.Reader(data))); } + + Auction(request: QueryGetAuctionRequest): Promise { + const data = QueryGetAuctionRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "Auction", data); + return promise.then((data) => QueryGetAuctionResponse.decode(new _m0.Reader(data))); + } + + AuctionAll(request: QueryAllAuctionRequest): Promise { + const data = QueryAllAuctionRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "AuctionAll", data); + return promise.then((data) => QueryAllAuctionResponse.decode(new _m0.Reader(data))); + } } interface Rpc { @@ -861,21 +1169,14 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Long - ? string | number | Long - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; if (_m0.util.Long !== Long) { diff --git a/src/stargate/modules/marketplace/proto-types/tx.ts b/src/stargate/modules/marketplace/proto-types/tx.ts index e3983c5..6d5b777 100644 --- a/src/stargate/modules/marketplace/proto-types/tx.ts +++ b/src/stargate/modules/marketplace/proto-types/tx.ts @@ -2,6 +2,8 @@ import Long from "long"; import _m0 from "protobufjs/minimal"; import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; +import { Any } from "cosmjs-types/google/protobuf/any"; +import { Duration } from "cosmjs-types/google/protobuf/duration"; import { Royalty } from "./royalty"; export const protobufPackage = "cudoventures.cudosnode.marketplace"; @@ -13,7 +15,8 @@ export interface MsgPublishCollection { resaleRoyalties: Royalty[]; } -export interface MsgPublishCollectionResponse {} +export interface MsgPublishCollectionResponse { +} export interface MsgPublishNft { creator: string; @@ -22,14 +25,16 @@ export interface MsgPublishNft { price?: Coin; } -export interface MsgPublishNftResponse {} +export interface MsgPublishNftResponse { +} export interface MsgBuyNft { creator: string; id: Long; } -export interface MsgBuyNftResponse {} +export interface MsgBuyNftResponse { +} export interface MsgMintNft { creator: string; @@ -42,28 +47,32 @@ export interface MsgMintNft { uid: string; } -export interface MsgMintNftResponse {} +export interface MsgMintNftResponse { +} export interface MsgRemoveNft { creator: string; id: Long; } -export interface MsgRemoveNftResponse {} +export interface MsgRemoveNftResponse { +} export interface MsgVerifyCollection { creator: string; id: Long; } -export interface MsgVerifyCollectionResponse {} +export interface MsgVerifyCollectionResponse { +} export interface MsgUnverifyCollection { creator: string; id: Long; } -export interface MsgUnverifyCollectionResponse {} +export interface MsgUnverifyCollectionResponse { +} export interface MsgCreateCollection { creator: string; @@ -80,7 +89,8 @@ export interface MsgCreateCollection { verified: boolean; } -export interface MsgCreateCollectionResponse {} +export interface MsgCreateCollectionResponse { +} export interface MsgUpdateRoyalties { creator: string; @@ -89,7 +99,8 @@ export interface MsgUpdateRoyalties { resaleRoyalties: Royalty[]; } -export interface MsgUpdateRoyaltiesResponse {} +export interface MsgUpdateRoyaltiesResponse { +} export interface MsgUpdatePrice { creator: string; @@ -97,21 +108,52 @@ export interface MsgUpdatePrice { price?: Coin; } -export interface MsgUpdatePriceResponse {} +export interface MsgUpdatePriceResponse { +} export interface MsgAddAdmin { creator: string; address: string; } -export interface MsgAddAdminResponse {} +export interface MsgAddAdminResponse { +} export interface MsgRemoveAdmin { creator: string; address: string; } -export interface MsgRemoveAdminResponse {} +export interface MsgRemoveAdminResponse { +} + +export interface MsgPublishAuction { + denomId: string; + tokenId: string; + duration?: Duration; + auction?: Any; + creator: string; +} + +export interface MsgPublishAuctionResponse { +} + +export interface MsgPlaceBid { + auctionId: Long; + amount?: Coin; + bidder: string; +} + +export interface MsgPlaceBidResponse { +} + +export interface MsgAcceptBid { + auctionId: Long; + sender: string; +} + +export interface MsgAcceptBidResponse { +} function createBaseMsgPublishCollection(): MsgPublishCollection { return { creator: "", denomId: "", mintRoyalties: [], resaleRoyalties: [] }; @@ -179,18 +221,22 @@ export const MsgPublishCollection = { message.creator !== undefined && (obj.creator = message.creator); message.denomId !== undefined && (obj.denomId = message.denomId); if (message.mintRoyalties) { - obj.mintRoyalties = message.mintRoyalties.map((e) => (e ? Royalty.toJSON(e) : undefined)); + obj.mintRoyalties = message.mintRoyalties.map((e) => e ? Royalty.toJSON(e) : undefined); } else { obj.mintRoyalties = []; } if (message.resaleRoyalties) { - obj.resaleRoyalties = message.resaleRoyalties.map((e) => (e ? Royalty.toJSON(e) : undefined)); + obj.resaleRoyalties = message.resaleRoyalties.map((e) => e ? Royalty.toJSON(e) : undefined); } else { obj.resaleRoyalties = []; } return obj; }, + create, I>>(base?: I): MsgPublishCollection { + return MsgPublishCollection.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgPublishCollection { const message = createBaseMsgPublishCollection(); message.creator = object.creator ?? ""; @@ -234,9 +280,11 @@ export const MsgPublishCollectionResponse = { return obj; }, - fromPartial, I>>( - _: I, - ): MsgPublishCollectionResponse { + create, I>>(base?: I): MsgPublishCollectionResponse { + return MsgPublishCollectionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgPublishCollectionResponse { const message = createBaseMsgPublishCollectionResponse(); return message; }, @@ -308,13 +356,16 @@ export const MsgPublishNft = { return obj; }, + create, I>>(base?: I): MsgPublishNft { + return MsgPublishNft.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgPublishNft { const message = createBaseMsgPublishNft(); message.creator = object.creator ?? ""; message.tokenId = object.tokenId ?? ""; message.denomId = object.denomId ?? ""; - message.price = - object.price !== undefined && object.price !== null ? Coin.fromPartial(object.price) : undefined; + message.price = (object.price !== undefined && object.price !== null) ? Coin.fromPartial(object.price) : undefined; return message; }, }; @@ -352,6 +403,10 @@ export const MsgPublishNftResponse = { return obj; }, + create, I>>(base?: I): MsgPublishNftResponse { + return MsgPublishNftResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgPublishNftResponse { const message = createBaseMsgPublishNftResponse(); return message; @@ -408,10 +463,14 @@ export const MsgBuyNft = { return obj; }, + create, I>>(base?: I): MsgBuyNft { + return MsgBuyNft.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgBuyNft { const message = createBaseMsgBuyNft(); message.creator = object.creator ?? ""; - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; return message; }, }; @@ -449,6 +508,10 @@ export const MsgBuyNftResponse = { return obj; }, + create, I>>(base?: I): MsgBuyNftResponse { + return MsgBuyNftResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgBuyNftResponse { const message = createBaseMsgBuyNftResponse(); return message; @@ -553,13 +616,16 @@ export const MsgMintNft = { return obj; }, + create, I>>(base?: I): MsgMintNft { + return MsgMintNft.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgMintNft { const message = createBaseMsgMintNft(); message.creator = object.creator ?? ""; message.denomId = object.denomId ?? ""; message.recipient = object.recipient ?? ""; - message.price = - object.price !== undefined && object.price !== null ? Coin.fromPartial(object.price) : undefined; + message.price = (object.price !== undefined && object.price !== null) ? Coin.fromPartial(object.price) : undefined; message.name = object.name ?? ""; message.uri = object.uri ?? ""; message.data = object.data ?? ""; @@ -601,6 +667,10 @@ export const MsgMintNftResponse = { return obj; }, + create, I>>(base?: I): MsgMintNftResponse { + return MsgMintNftResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgMintNftResponse { const message = createBaseMsgMintNftResponse(); return message; @@ -657,10 +727,14 @@ export const MsgRemoveNft = { return obj; }, + create, I>>(base?: I): MsgRemoveNft { + return MsgRemoveNft.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgRemoveNft { const message = createBaseMsgRemoveNft(); message.creator = object.creator ?? ""; - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; return message; }, }; @@ -698,6 +772,10 @@ export const MsgRemoveNftResponse = { return obj; }, + create, I>>(base?: I): MsgRemoveNftResponse { + return MsgRemoveNftResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgRemoveNftResponse { const message = createBaseMsgRemoveNftResponse(); return message; @@ -754,10 +832,14 @@ export const MsgVerifyCollection = { return obj; }, + create, I>>(base?: I): MsgVerifyCollection { + return MsgVerifyCollection.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgVerifyCollection { const message = createBaseMsgVerifyCollection(); message.creator = object.creator ?? ""; - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; return message; }, }; @@ -795,9 +877,11 @@ export const MsgVerifyCollectionResponse = { return obj; }, - fromPartial, I>>( - _: I, - ): MsgVerifyCollectionResponse { + create, I>>(base?: I): MsgVerifyCollectionResponse { + return MsgVerifyCollectionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgVerifyCollectionResponse { const message = createBaseMsgVerifyCollectionResponse(); return message; }, @@ -853,10 +937,14 @@ export const MsgUnverifyCollection = { return obj; }, + create, I>>(base?: I): MsgUnverifyCollection { + return MsgUnverifyCollection.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgUnverifyCollection { const message = createBaseMsgUnverifyCollection(); message.creator = object.creator ?? ""; - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; return message; }, }; @@ -894,9 +982,11 @@ export const MsgUnverifyCollectionResponse = { return obj; }, - fromPartial, I>>( - _: I, - ): MsgUnverifyCollectionResponse { + create, I>>(base?: I): MsgUnverifyCollectionResponse { + return MsgUnverifyCollectionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgUnverifyCollectionResponse { const message = createBaseMsgUnverifyCollectionResponse(); return message; }, @@ -1044,12 +1134,12 @@ export const MsgCreateCollection = { message.minter !== undefined && (obj.minter = message.minter); message.data !== undefined && (obj.data = message.data); if (message.mintRoyalties) { - obj.mintRoyalties = message.mintRoyalties.map((e) => (e ? Royalty.toJSON(e) : undefined)); + obj.mintRoyalties = message.mintRoyalties.map((e) => e ? Royalty.toJSON(e) : undefined); } else { obj.mintRoyalties = []; } if (message.resaleRoyalties) { - obj.resaleRoyalties = message.resaleRoyalties.map((e) => (e ? Royalty.toJSON(e) : undefined)); + obj.resaleRoyalties = message.resaleRoyalties.map((e) => e ? Royalty.toJSON(e) : undefined); } else { obj.resaleRoyalties = []; } @@ -1057,6 +1147,10 @@ export const MsgCreateCollection = { return obj; }, + create, I>>(base?: I): MsgCreateCollection { + return MsgCreateCollection.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgCreateCollection { const message = createBaseMsgCreateCollection(); message.creator = object.creator ?? ""; @@ -1108,9 +1202,11 @@ export const MsgCreateCollectionResponse = { return obj; }, - fromPartial, I>>( - _: I, - ): MsgCreateCollectionResponse { + create, I>>(base?: I): MsgCreateCollectionResponse { + return MsgCreateCollectionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgCreateCollectionResponse { const message = createBaseMsgCreateCollectionResponse(); return message; }, @@ -1182,22 +1278,26 @@ export const MsgUpdateRoyalties = { message.creator !== undefined && (obj.creator = message.creator); message.id !== undefined && (obj.id = (message.id || Long.UZERO).toString()); if (message.mintRoyalties) { - obj.mintRoyalties = message.mintRoyalties.map((e) => (e ? Royalty.toJSON(e) : undefined)); + obj.mintRoyalties = message.mintRoyalties.map((e) => e ? Royalty.toJSON(e) : undefined); } else { obj.mintRoyalties = []; } if (message.resaleRoyalties) { - obj.resaleRoyalties = message.resaleRoyalties.map((e) => (e ? Royalty.toJSON(e) : undefined)); + obj.resaleRoyalties = message.resaleRoyalties.map((e) => e ? Royalty.toJSON(e) : undefined); } else { obj.resaleRoyalties = []; } return obj; }, + create, I>>(base?: I): MsgUpdateRoyalties { + return MsgUpdateRoyalties.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgUpdateRoyalties { const message = createBaseMsgUpdateRoyalties(); message.creator = object.creator ?? ""; - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; message.mintRoyalties = object.mintRoyalties?.map((e) => Royalty.fromPartial(e)) || []; message.resaleRoyalties = object.resaleRoyalties?.map((e) => Royalty.fromPartial(e)) || []; return message; @@ -1237,6 +1337,10 @@ export const MsgUpdateRoyaltiesResponse = { return obj; }, + create, I>>(base?: I): MsgUpdateRoyaltiesResponse { + return MsgUpdateRoyaltiesResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgUpdateRoyaltiesResponse { const message = createBaseMsgUpdateRoyaltiesResponse(); return message; @@ -1301,12 +1405,15 @@ export const MsgUpdatePrice = { return obj; }, + create, I>>(base?: I): MsgUpdatePrice { + return MsgUpdatePrice.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgUpdatePrice { const message = createBaseMsgUpdatePrice(); message.creator = object.creator ?? ""; - message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; - message.price = - object.price !== undefined && object.price !== null ? Coin.fromPartial(object.price) : undefined; + message.id = (object.id !== undefined && object.id !== null) ? Long.fromValue(object.id) : Long.UZERO; + message.price = (object.price !== undefined && object.price !== null) ? Coin.fromPartial(object.price) : undefined; return message; }, }; @@ -1344,6 +1451,10 @@ export const MsgUpdatePriceResponse = { return obj; }, + create, I>>(base?: I): MsgUpdatePriceResponse { + return MsgUpdatePriceResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgUpdatePriceResponse { const message = createBaseMsgUpdatePriceResponse(); return message; @@ -1400,6 +1511,10 @@ export const MsgAddAdmin = { return obj; }, + create, I>>(base?: I): MsgAddAdmin { + return MsgAddAdmin.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgAddAdmin { const message = createBaseMsgAddAdmin(); message.creator = object.creator ?? ""; @@ -1441,6 +1556,10 @@ export const MsgAddAdminResponse = { return obj; }, + create, I>>(base?: I): MsgAddAdminResponse { + return MsgAddAdminResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgAddAdminResponse { const message = createBaseMsgAddAdminResponse(); return message; @@ -1497,6 +1616,10 @@ export const MsgRemoveAdmin = { return obj; }, + create, I>>(base?: I): MsgRemoveAdmin { + return MsgRemoveAdmin.fromPartial(base ?? {}); + }, + fromPartial, I>>(object: I): MsgRemoveAdmin { const message = createBaseMsgRemoveAdmin(); message.creator = object.creator ?? ""; @@ -1538,12 +1661,377 @@ export const MsgRemoveAdminResponse = { return obj; }, + create, I>>(base?: I): MsgRemoveAdminResponse { + return MsgRemoveAdminResponse.fromPartial(base ?? {}); + }, + fromPartial, I>>(_: I): MsgRemoveAdminResponse { const message = createBaseMsgRemoveAdminResponse(); return message; }, }; +function createBaseMsgPublishAuction(): MsgPublishAuction { + return { denomId: "", tokenId: "", duration: undefined, auction: undefined, creator: "" }; +} + +export const MsgPublishAuction = { + encode(message: MsgPublishAuction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.denomId !== "") { + writer.uint32(10).string(message.denomId); + } + if (message.tokenId !== "") { + writer.uint32(18).string(message.tokenId); + } + if (message.duration !== undefined) { + Duration.encode(message.duration, writer.uint32(26).fork()).ldelim(); + } + if (message.auction !== undefined) { + Any.encode(message.auction, writer.uint32(34).fork()).ldelim(); + } + if (message.creator !== "") { + writer.uint32(42).string(message.creator); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgPublishAuction { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPublishAuction(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomId = reader.string(); + break; + case 2: + message.tokenId = reader.string(); + break; + case 3: + message.duration = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.auction = Any.decode(reader, reader.uint32()); + break; + case 5: + message.creator = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgPublishAuction { + return { + denomId: isSet(object.denomId) ? String(object.denomId) : "", + tokenId: isSet(object.tokenId) ? String(object.tokenId) : "", + duration: isSet(object.duration) ? Duration.fromJSON(object.duration) : undefined, + auction: isSet(object.auction) ? Any.fromJSON(object.auction) : undefined, + creator: isSet(object.creator) ? String(object.creator) : "", + }; + }, + + toJSON(message: MsgPublishAuction): unknown { + const obj: any = {}; + message.denomId !== undefined && (obj.denomId = message.denomId); + message.tokenId !== undefined && (obj.tokenId = message.tokenId); + message.duration !== undefined && (obj.duration = message.duration ? Duration.toJSON(message.duration) : undefined); + message.auction !== undefined && (obj.auction = message.auction ? Any.toJSON(message.auction) : undefined); + message.creator !== undefined && (obj.creator = message.creator); + return obj; + }, + + create, I>>(base?: I): MsgPublishAuction { + return MsgPublishAuction.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): MsgPublishAuction { + const message = createBaseMsgPublishAuction(); + message.denomId = object.denomId ?? ""; + message.tokenId = object.tokenId ?? ""; + message.duration = (object.duration !== undefined && object.duration !== null) + ? Duration.fromPartial(object.duration) + : undefined; + message.auction = (object.auction !== undefined && object.auction !== null) + ? Any.fromPartial(object.auction) + : undefined; + message.creator = object.creator ?? ""; + return message; + }, +}; + +function createBaseMsgPublishAuctionResponse(): MsgPublishAuctionResponse { + return {}; +} + +export const MsgPublishAuctionResponse = { + encode(_: MsgPublishAuctionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgPublishAuctionResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPublishAuctionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgPublishAuctionResponse { + return {}; + }, + + toJSON(_: MsgPublishAuctionResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): MsgPublishAuctionResponse { + return MsgPublishAuctionResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgPublishAuctionResponse { + const message = createBaseMsgPublishAuctionResponse(); + return message; + }, +}; + +function createBaseMsgPlaceBid(): MsgPlaceBid { + return { auctionId: Long.UZERO, amount: undefined, bidder: "" }; +} + +export const MsgPlaceBid = { + encode(message: MsgPlaceBid, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.auctionId.isZero()) { + writer.uint32(8).uint64(message.auctionId); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(18).fork()).ldelim(); + } + if (message.bidder !== "") { + writer.uint32(26).string(message.bidder); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgPlaceBid { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPlaceBid(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auctionId = reader.uint64() as Long; + break; + case 2: + message.amount = Coin.decode(reader, reader.uint32()); + break; + case 3: + message.bidder = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgPlaceBid { + return { + auctionId: isSet(object.auctionId) ? Long.fromValue(object.auctionId) : Long.UZERO, + amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined, + bidder: isSet(object.bidder) ? String(object.bidder) : "", + }; + }, + + toJSON(message: MsgPlaceBid): unknown { + const obj: any = {}; + message.auctionId !== undefined && (obj.auctionId = (message.auctionId || Long.UZERO).toString()); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + message.bidder !== undefined && (obj.bidder = message.bidder); + return obj; + }, + + create, I>>(base?: I): MsgPlaceBid { + return MsgPlaceBid.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): MsgPlaceBid { + const message = createBaseMsgPlaceBid(); + message.auctionId = (object.auctionId !== undefined && object.auctionId !== null) + ? Long.fromValue(object.auctionId) + : Long.UZERO; + message.amount = (object.amount !== undefined && object.amount !== null) + ? Coin.fromPartial(object.amount) + : undefined; + message.bidder = object.bidder ?? ""; + return message; + }, +}; + +function createBaseMsgPlaceBidResponse(): MsgPlaceBidResponse { + return {}; +} + +export const MsgPlaceBidResponse = { + encode(_: MsgPlaceBidResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgPlaceBidResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPlaceBidResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgPlaceBidResponse { + return {}; + }, + + toJSON(_: MsgPlaceBidResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): MsgPlaceBidResponse { + return MsgPlaceBidResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgPlaceBidResponse { + const message = createBaseMsgPlaceBidResponse(); + return message; + }, +}; + +function createBaseMsgAcceptBid(): MsgAcceptBid { + return { auctionId: Long.UZERO, sender: "" }; +} + +export const MsgAcceptBid = { + encode(message: MsgAcceptBid, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.auctionId.isZero()) { + writer.uint32(8).uint64(message.auctionId); + } + if (message.sender !== "") { + writer.uint32(18).string(message.sender); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgAcceptBid { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAcceptBid(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auctionId = reader.uint64() as Long; + break; + case 2: + message.sender = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgAcceptBid { + return { + auctionId: isSet(object.auctionId) ? Long.fromValue(object.auctionId) : Long.UZERO, + sender: isSet(object.sender) ? String(object.sender) : "", + }; + }, + + toJSON(message: MsgAcceptBid): unknown { + const obj: any = {}; + message.auctionId !== undefined && (obj.auctionId = (message.auctionId || Long.UZERO).toString()); + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + + create, I>>(base?: I): MsgAcceptBid { + return MsgAcceptBid.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): MsgAcceptBid { + const message = createBaseMsgAcceptBid(); + message.auctionId = (object.auctionId !== undefined && object.auctionId !== null) + ? Long.fromValue(object.auctionId) + : Long.UZERO; + message.sender = object.sender ?? ""; + return message; + }, +}; + +function createBaseMsgAcceptBidResponse(): MsgAcceptBidResponse { + return {}; +} + +export const MsgAcceptBidResponse = { + encode(_: MsgAcceptBidResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgAcceptBidResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAcceptBidResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgAcceptBidResponse { + return {}; + }, + + toJSON(_: MsgAcceptBidResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): MsgAcceptBidResponse { + return MsgAcceptBidResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): MsgAcceptBidResponse { + const message = createBaseMsgAcceptBidResponse(); + return message; + }, +}; + /** Msg defines the Msg service. */ export interface Msg { PublishCollection(request: MsgPublishCollection): Promise; @@ -1557,8 +2045,11 @@ export interface Msg { UpdateRoyalties(request: MsgUpdateRoyalties): Promise; UpdatePrice(request: MsgUpdatePrice): Promise; AddAdmin(request: MsgAddAdmin): Promise; - /** this line is used by starport scaffolding # proto/tx/rpc */ RemoveAdmin(request: MsgRemoveAdmin): Promise; + PublishAuction(request: MsgPublishAuction): Promise; + PlaceBid(request: MsgPlaceBid): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + AcceptBid(request: MsgAcceptBid): Promise; } export class MsgClientImpl implements Msg { @@ -1579,6 +2070,9 @@ export class MsgClientImpl implements Msg { this.UpdatePrice = this.UpdatePrice.bind(this); this.AddAdmin = this.AddAdmin.bind(this); this.RemoveAdmin = this.RemoveAdmin.bind(this); + this.PublishAuction = this.PublishAuction.bind(this); + this.PlaceBid = this.PlaceBid.bind(this); + this.AcceptBid = this.AcceptBid.bind(this); } PublishCollection(request: MsgPublishCollection): Promise { const data = MsgPublishCollection.encode(request).finish(); @@ -1651,6 +2145,24 @@ export class MsgClientImpl implements Msg { const promise = this.rpc.request(this.service, "RemoveAdmin", data); return promise.then((data) => MsgRemoveAdminResponse.decode(new _m0.Reader(data))); } + + PublishAuction(request: MsgPublishAuction): Promise { + const data = MsgPublishAuction.encode(request).finish(); + const promise = this.rpc.request(this.service, "PublishAuction", data); + return promise.then((data) => MsgPublishAuctionResponse.decode(new _m0.Reader(data))); + } + + PlaceBid(request: MsgPlaceBid): Promise { + const data = MsgPlaceBid.encode(request).finish(); + const promise = this.rpc.request(this.service, "PlaceBid", data); + return promise.then((data) => MsgPlaceBidResponse.decode(new _m0.Reader(data))); + } + + AcceptBid(request: MsgAcceptBid): Promise { + const data = MsgAcceptBid.encode(request).finish(); + const promise = this.rpc.request(this.service, "AcceptBid", data); + return promise.then((data) => MsgAcceptBidResponse.decode(new _m0.Reader(data))); + } } interface Rpc { @@ -1659,21 +2171,14 @@ interface Rpc { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Long - ? string | number | Long - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Long ? string | number | Long : T extends Array ? Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; if (_m0.util.Long !== Long) { diff --git a/src/stargate/modules/marketplace/queries.ts b/src/stargate/modules/marketplace/queries.ts index fdc63ee..f81136d 100644 --- a/src/stargate/modules/marketplace/queries.ts +++ b/src/stargate/modules/marketplace/queries.ts @@ -11,7 +11,9 @@ import { QueryGetNftResponse, QueryAllNftResponse, QueryParamsResponse, - QueryListAdminsResponse + QueryListAdminsResponse, + QueryAllAuctionResponse, + QueryGetAuctionResponse } from './proto-types/query'; export interface MarketplaceExtension { @@ -22,7 +24,9 @@ export interface MarketplaceExtension { readonly nft: (id: Long) => Promise, readonly allNfts: (pagination?: PageRequest) => Promise, readonly params: () => Promise, - readonly admins: () => Promise + readonly admins: () => Promise, + readonly auction: (id: Long) => Promise, + readonly allAuctions: (pagination?: PageRequest) => Promise } } @@ -52,6 +56,12 @@ export function setupMarketplaceExtension(base: QueryClient): MarketplaceExtensi }, admins: async() => { return queryService.ListAdmins({}); + }, + auction: async(id: Long) => { + return queryService.Auction({id: id}); + }, + allAuctions: async(pagination?: PageRequest) => { + return queryService.AuctionAll({pagination: pagination}); } } }; diff --git a/src/stargate/modules/marketplace/types.ts b/src/stargate/modules/marketplace/types.ts index 2ea823a..d7dbc3e 100644 --- a/src/stargate/modules/marketplace/types.ts +++ b/src/stargate/modules/marketplace/types.ts @@ -1,3 +1,5 @@ +import { DutchAuction, EnglishAuction } from './proto-types/auction'; +import { MsgPublishAuction, MsgPlaceBid, MsgAcceptBid } from './proto-types/tx'; import { MsgCreateCollection, MsgPublishCollection, MsgPublishNft, MsgBuyNft, MsgUpdateRoyalties, MsgUpdatePrice, MsgRemoveNft, MsgVerifyCollection, MsgUnverifyCollection, @@ -63,4 +65,29 @@ export const msgAddAdmin = { export const msgRemoveAdmin = { typeUrl: PREFIX.concat('MsgRemoveAdmin'), type: MsgRemoveAdmin +}; + +export const msgPublishAuction = { + typeUrl: PREFIX.concat('MsgPublishAuction'), + type: MsgPublishAuction +}; + +export const msgPlaceBid = { + typeUrl: PREFIX.concat('MsgPlaceBid'), + type: MsgPlaceBid +}; + +export const msgAcceptBid = { + typeUrl: PREFIX.concat('MsgAcceptBid'), + type: MsgAcceptBid +}; + +export const englishAuction = { + typeUrl: PREFIX.concat('EnglishAuction'), + type: EnglishAuction +}; + +export const dutchAuction = { + typeUrl: PREFIX.concat('DutchAuction'), + type: DutchAuction }; \ No newline at end of file diff --git a/tests/marketplace-tx.test.ts b/tests/marketplace-tx.test.ts index 72ddeda..524846d 100644 --- a/tests/marketplace-tx.test.ts +++ b/tests/marketplace-tx.test.ts @@ -8,6 +8,9 @@ describe('marketplace', () => { const mnemonic5 = 'tape soul absorb cabin luxury practice rally clerk love kiss throw avoid' const gasPrice = GasPrice.fromString('6000000000000acudos'); + const duration = { seconds: Long.fromInt(1111111), nanos: 5 }; + const minPrice = coin('1', 'acudos'); + const startPrice = coin('1000', 'acudos'); let mainAddress: string; let mainSigningClient: SigningStargateClient; @@ -52,5 +55,15 @@ describe('marketplace', () => { // The marketplace NFT id starts from 0 await alice.marketplaceBuyNft(aliceAddress, Long.fromNumber(0), gasPrice); + + await alice.marketplacePublishAuction(aliceAddress, '1', denomId, duration, { startPrice, minPrice }, gasPrice); + + await mainSigningClient.marketplacePlaceBid(mainAddress, '1', startPrice, gasPrice); + + await mainSigningClient.marketplacePublishAuction(mainAddress, '1', denomId, duration, { minPrice }, gasPrice); + + await alice.marketplacePlaceBid(aliceAddress, '2', minPrice, gasPrice); + + await mainSigningClient.marketplaceAcceptBid(mainAddress, '2', gasPrice); }); }) \ No newline at end of file