From d3b969ff1745313ed641eda566bbf7880fbef1e0 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 17 Sep 2024 10:14:12 +0530 Subject: [PATCH] Add separate method for creating service provider auction --- src/auction.test.ts | 11 ++++------ src/index.ts | 34 +++++++++++++++++++++++++++++-- src/types/cerc/auction/message.ts | 12 +++++++++++ 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/auction.test.ts b/src/auction.test.ts index 0ebd869..0278b00 100644 --- a/src/auction.test.ts +++ b/src/auction.test.ts @@ -71,9 +71,7 @@ const createAuctionTests = () => { commitFee, revealFee, minimumBid, - maxPrice: undefined, kind: 'vickrey', - numProviders: 1, signer: auctionCreatorAccount.address }, auctionCreatorAccount.privateKey, fee); @@ -176,16 +174,15 @@ const createSPAuctionTests = () => { amount: '100000000' }; - const auction = await registry.createAuction({ + const auction = await registry.createServiceProviderAuction({ commitsDuration, revealsDuration, commitFee, revealFee, - minimumBid: undefined, - maxPrice, + signer: auctionCreatorAccount.address, kind: 'service_provider', - numProviders: 3, - signer: auctionCreatorAccount.address + maxPrice, + numProviders: 3 }, auctionCreatorAccount.privateKey, fee); diff --git a/src/index.ts b/src/index.ts index 2636c3d..8e2d825 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,8 @@ import { } from './types/cerc/registry/message'; import { MessageMsgCommitBid, - MessageMsgRevealBid + MessageMsgRevealBid, + MsgCreateVickreyAuction } from './types/cerc/auction/message'; import { MessageMsgSendCoins } from './types/cosmos/bank/message'; import { MessageMsgOnboardParticipant } from './types/cerc/onboarding/message'; @@ -508,6 +509,35 @@ export class Registry { revealFee, minimumBid, signer, + kind + }: MsgCreateVickreyAuction, + privateKey: string, + fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER): Promise { + const account = new Account(Buffer.from(privateKey, 'hex')); + await account.init(); + const laconicClient = await this.getLaconicClient(account); + + return laconicClient.createAuction( + commitsDuration, + revealsDuration, + commitFee, + revealFee, + minimumBid, + signer, + kind, + undefined, + 0, + fee, + privateKey + ); + } + + async createServiceProviderAuction ({ + commitsDuration, + revealsDuration, + commitFee, + revealFee, + signer, kind, maxPrice, numProviders @@ -523,7 +553,7 @@ export class Registry { revealsDuration, commitFee, revealFee, - minimumBid, + undefined, signer, kind, maxPrice, diff --git a/src/types/cerc/auction/message.ts b/src/types/cerc/auction/message.ts index 6474d93..a620cb1 100644 --- a/src/types/cerc/auction/message.ts +++ b/src/types/cerc/auction/message.ts @@ -1,6 +1,8 @@ import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing'; import { MsgCommitBidResponse, MsgCommitBid, MsgRevealBid, MsgRevealBidResponse, MsgCreateAuction, MsgCreateAuctionResponse } from '../../../proto/cerc/auction/v1/tx'; +import { Coin } from '@cosmjs/amino'; +import { Duration } from '../../../proto/google/protobuf/duration'; export const typeUrlMsgCreateAuction = '/cerc.auction.v1.MsgCreateAuction'; export const typeUrlMsgCommitBid = '/cerc.auction.v1.MsgCommitBid'; @@ -42,3 +44,13 @@ export interface MessageMsgRevealBid { auctionId: string, reveal: string, } + +export interface MsgCreateVickreyAuction { + commitsDuration?: Duration; + revealsDuration?: Duration; + commitFee?: Coin; + revealFee?: Coin; + minimumBid?: Coin; + signer: string; + kind: string; +}