Add methods for creating auctions and add auction tests #28
@ -71,9 +71,7 @@ const createAuctionTests = () => {
|
|||||||
commitFee,
|
commitFee,
|
||||||
revealFee,
|
revealFee,
|
||||||
minimumBid,
|
minimumBid,
|
||||||
maxPrice: undefined,
|
|
||||||
kind: 'vickrey',
|
kind: 'vickrey',
|
||||||
numProviders: 1,
|
|
||||||
signer: auctionCreatorAccount.address
|
signer: auctionCreatorAccount.address
|
||||||
},
|
},
|
||||||
auctionCreatorAccount.privateKey, fee);
|
auctionCreatorAccount.privateKey, fee);
|
||||||
@ -176,16 +174,15 @@ const createSPAuctionTests = () => {
|
|||||||
amount: '100000000'
|
amount: '100000000'
|
||||||
};
|
};
|
||||||
|
|
||||||
const auction = await registry.createAuction({
|
const auction = await registry.createServiceProviderAuction({
|
||||||
commitsDuration,
|
commitsDuration,
|
||||||
revealsDuration,
|
revealsDuration,
|
||||||
commitFee,
|
commitFee,
|
||||||
revealFee,
|
revealFee,
|
||||||
minimumBid: undefined,
|
signer: auctionCreatorAccount.address,
|
||||||
maxPrice,
|
|
||||||
kind: 'service_provider',
|
kind: 'service_provider',
|
||||||
numProviders: 3,
|
maxPrice,
|
||||||
signer: auctionCreatorAccount.address
|
numProviders: 3
|
||||||
},
|
},
|
||||||
auctionCreatorAccount.privateKey, fee);
|
auctionCreatorAccount.privateKey, fee);
|
||||||
|
|
||||||
|
34
src/index.ts
34
src/index.ts
@ -22,7 +22,8 @@ import {
|
|||||||
} from './types/cerc/registry/message';
|
} from './types/cerc/registry/message';
|
||||||
import {
|
import {
|
||||||
MessageMsgCommitBid,
|
MessageMsgCommitBid,
|
||||||
MessageMsgRevealBid
|
MessageMsgRevealBid,
|
||||||
|
MsgCreateVickreyAuction
|
||||||
} from './types/cerc/auction/message';
|
} from './types/cerc/auction/message';
|
||||||
import { MessageMsgSendCoins } from './types/cosmos/bank/message';
|
import { MessageMsgSendCoins } from './types/cosmos/bank/message';
|
||||||
import { MessageMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
import { MessageMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
||||||
@ -508,6 +509,35 @@ export class Registry {
|
|||||||
revealFee,
|
revealFee,
|
||||||
minimumBid,
|
minimumBid,
|
||||||
signer,
|
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,
|
kind,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
numProviders
|
numProviders
|
||||||
@ -523,7 +553,7 @@ export class Registry {
|
|||||||
revealsDuration,
|
revealsDuration,
|
||||||
commitFee,
|
commitFee,
|
||||||
revealFee,
|
revealFee,
|
||||||
minimumBid,
|
undefined,
|
||||||
signer,
|
signer,
|
||||||
kind,
|
kind,
|
||||||
maxPrice,
|
maxPrice,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
||||||
|
|
||||||
import { MsgCommitBidResponse, MsgCommitBid, MsgRevealBid, MsgRevealBidResponse, MsgCreateAuction, MsgCreateAuctionResponse } from '../../../proto/cerc/auction/v1/tx';
|
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 typeUrlMsgCreateAuction = '/cerc.auction.v1.MsgCreateAuction';
|
||||||
export const typeUrlMsgCommitBid = '/cerc.auction.v1.MsgCommitBid';
|
export const typeUrlMsgCommitBid = '/cerc.auction.v1.MsgCommitBid';
|
||||||
@ -42,3 +44,13 @@ export interface MessageMsgRevealBid {
|
|||||||
auctionId: string,
|
auctionId: string,
|
||||||
reveal: 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