Add methods for creating auctions and add auction tests #28
@ -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);
|
||||
|
||||
|
34
src/index.ts
34
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<MsgCreateAuctionResponse> {
|
||||
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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user