Add command to create an auction and add auction CLI tests #83
@ -2,11 +2,12 @@ import { Arguments } from 'yargs';
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
|
|
||||||
import { Registry } from '@cerc-io/registry-sdk';
|
import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY, Registry } from '@cerc-io/registry-sdk';
|
||||||
import { MsgCreateAuctionResponse } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/tx';
|
import { MsgCreateAuctionResponse } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/tx';
|
||||||
|
import { Duration } from '@cerc-io/registry-sdk/dist/proto/google/protobuf/duration';
|
||||||
|
import { coin } from '@cosmjs/amino';
|
||||||
|
|
||||||
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
|
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
|
||||||
import { AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER } from '../../../../test/helpers';
|
|
||||||
|
|
||||||
export const command = 'create';
|
export const command = 'create';
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ export const builder = {
|
|||||||
},
|
},
|
||||||
'commit-fee': {
|
'commit-fee': {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
describe: 'Fee for committing to the auction'
|
describe: 'Fee for committing a bid to the auction'
|
||||||
},
|
},
|
||||||
'reveal-fee': {
|
'reveal-fee': {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
@ -55,31 +56,19 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const { config } = argv;
|
const { config } = argv;
|
||||||
|
|
||||||
const kind = argv.kind as string;
|
const kind = argv.kind as string;
|
||||||
const commitsDuration = {
|
const commitsDuration = Duration.fromPartial({
|
||||||
seconds: Long.fromNumber(argv.commitsDuration as number),
|
seconds: Long.fromNumber(argv.commitsDuration as number),
|
||||||
nanos: 0
|
nanos: 0
|
||||||
};
|
});
|
||||||
const revealsDuration = {
|
const revealsDuration = Duration.fromPartial({
|
||||||
seconds: Long.fromNumber(argv.revealsDuration as number),
|
seconds: Long.fromNumber(argv.revealsDuration as number),
|
||||||
nanos: 0
|
nanos: 0
|
||||||
};
|
});
|
||||||
const denom = argv.denom as string;
|
const denom = argv.denom as string;
|
||||||
const commitFee = {
|
const commitFee = coin(argv.commitFee as string, denom);
|
||||||
denom: denom,
|
const revealFee = coin(argv.revealFee as string, denom);
|
||||||
amount: argv.commitFee as string
|
const minimumBid = coin(argv.minimumBid as string, denom);
|
||||||
};
|
const maxPrice = coin(argv.maxPrice as string, denom);
|
||||||
const revealFee = {
|
|
||||||
denom: denom,
|
|
||||||
amount: argv.revealFee as string
|
|
||||||
};
|
|
||||||
const minimumBid = {
|
|
||||||
denom: denom,
|
|
||||||
amount: argv.minimumBid as string
|
|
||||||
};
|
|
||||||
const maxPrice = {
|
|
||||||
denom: denom,
|
|
||||||
amount: argv.maxPrice as string
|
|
||||||
};
|
|
||||||
const numProviders = argv.numProviders as number;
|
const numProviders = argv.numProviders as number;
|
||||||
|
|
||||||
const validKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER];
|
const validKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER];
|
||||||
|
@ -16,9 +16,6 @@ export const AUCTION_FEES = {
|
|||||||
export const AUCTION_COMMIT_DURATION = 60; // 60s
|
export const AUCTION_COMMIT_DURATION = 60; // 60s
|
||||||
export const AUCTION_REVEAL_DURATION = 60; // 60s
|
export const AUCTION_REVEAL_DURATION = 60; // 60s
|
||||||
|
|
||||||
export const AUCTION_KIND_VICKREY = 'vickrey';
|
|
||||||
export const AUCTION_KIND_PROVIDER = 'provider';
|
|
||||||
|
|
||||||
export function checkResultAndRetrieveOutput (result: SpawnSyncReturns<Buffer>): any {
|
export function checkResultAndRetrieveOutput (result: SpawnSyncReturns<Buffer>): any {
|
||||||
expect(result.status).toBe(0);
|
expect(result.status).toBe(0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user