Update create auction CLI with updated types
This commit is contained in:
parent
4b273f4d16
commit
fa734a4ff8
@ -663,7 +663,7 @@ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55b
|
||||
Create a `provider` auction:
|
||||
|
||||
```bash
|
||||
laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --denom alnt --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 1
|
||||
laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --denom alnt --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 5
|
||||
|
||||
{"auctionId":"73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630"}
|
||||
|
||||
@ -730,7 +730,7 @@ laconic registry auction get $AUCTION
|
||||
"type": "alnt",
|
||||
"quantity": 100000
|
||||
},
|
||||
"numProviders": 1,
|
||||
"numProviders": 5,
|
||||
"bids": [
|
||||
{
|
||||
"bidderAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r",
|
||||
|
@ -1,9 +1,7 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import Long from 'long';
|
||||
|
||||
import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY, Duration, Registry } from '@cerc-io/registry-sdk';
|
||||
import { coin } from '@cosmjs/amino';
|
||||
import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY, Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
|
||||
|
||||
@ -17,11 +15,11 @@ export const builder = {
|
||||
describe: 'Auction kind (vickrey | provider)'
|
||||
},
|
||||
'commits-duration': {
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
describe: 'Duration for bid commit phase in seconds'
|
||||
},
|
||||
'reveals-duration': {
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
describe: 'Duration for bid reveal phase in seconds'
|
||||
},
|
||||
denom: {
|
||||
@ -29,20 +27,20 @@ export const builder = {
|
||||
describe: 'Denom to use'
|
||||
},
|
||||
'commit-fee': {
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
describe: 'Fee for committing a bid to the auction'
|
||||
},
|
||||
'reveal-fee': {
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
describe: 'Fee for revealing a bid in the auction'
|
||||
},
|
||||
'minimum-bid': {
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
default: 0,
|
||||
describe: 'Minimum bid amount (only for vickrey auction)'
|
||||
},
|
||||
'max-price': {
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
default: 0,
|
||||
describe: 'Max acceptable bid price (only for provider auction)'
|
||||
},
|
||||
@ -56,6 +54,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const { config } = argv;
|
||||
|
||||
const kind = argv.kind as string;
|
||||
const validAuctionKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER];
|
||||
assert(validAuctionKinds.includes(kind), `Invalid auction kind, has to be one of ${validAuctionKinds}.`);
|
||||
|
||||
if (kind === AUCTION_KIND_VICKREY) {
|
||||
assert(argv.minimumBid, 'Invalid minimum bid.');
|
||||
assert(!argv.maxPrice, `Max price can only be used with ${AUCTION_KIND_PROVIDER} auction.`);
|
||||
@ -71,19 +72,16 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(argv.commitFee, 'Invalid commit fee.');
|
||||
assert(argv.revealFee, 'Invalid reveal fee.');
|
||||
|
||||
const commitsDuration = Duration.fromPartial({ seconds: Long.fromNumber(argv.commitsDuration as number) });
|
||||
const revealsDuration = Duration.fromPartial({ seconds: Long.fromNumber(argv.revealsDuration as number) });
|
||||
const commitsDuration = argv.commitsDuration as string;
|
||||
const revealsDuration = argv.revealsDuration as string;
|
||||
|
||||
const denom = argv.denom as string;
|
||||
const commitFee = coin(argv.commitFee as string, denom);
|
||||
const revealFee = coin(argv.revealFee as string, denom);
|
||||
const minimumBid = coin(argv.minimumBid as string, denom);
|
||||
const maxPrice = coin(argv.maxPrice as string, denom);
|
||||
const commitFee = argv.commitFee as string;
|
||||
const revealFee = argv.revealFee as string;
|
||||
const minimumBid = argv.minimumBid as string;
|
||||
const maxPrice = argv.maxPrice as string;
|
||||
const numProviders = argv.numProviders as number;
|
||||
|
||||
const validAuctionKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER];
|
||||
assert(validAuctionKinds.includes(kind), `Invalid auction kind, has to be one of ${validAuctionKinds}.`);
|
||||
|
||||
const { services: { registry: registryConfig } } = getConfig(config as string);
|
||||
const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
||||
@ -98,9 +96,9 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
let result: any;
|
||||
if (kind === AUCTION_KIND_VICKREY) {
|
||||
result = await registry.createAuction({ commitsDuration, revealsDuration, commitFee, revealFee, minimumBid }, privateKey, fee);
|
||||
result = await registry.createAuction({ commitsDuration, revealsDuration, denom, commitFee, revealFee, minimumBid }, privateKey, fee);
|
||||
} else {
|
||||
result = await registry.createProviderAuction({ commitsDuration, revealsDuration, commitFee, revealFee, maxPrice, numProviders }, privateKey, fee);
|
||||
result = await registry.createProviderAuction({ commitsDuration, revealsDuration, denom, commitFee, revealFee, maxPrice, numProviders }, privateKey, fee);
|
||||
}
|
||||
|
||||
const jsonString = `{"auctionId":"${result.auction?.id}"}`;
|
||||
|
@ -599,7 +599,7 @@ describe('Test laconic CLI commands', () => {
|
||||
const bidAmount = 25000000;
|
||||
let bidRevealFilePath: string;
|
||||
|
||||
test('laconic registry auction create --kind <kind> --commits-duration <commits_duration> --reveals-duration <reveals_duration> --commit-fee <commit_fee> --reveal-fee <reveal_fee> --minimum-bid <minimum_bid>', async () => {
|
||||
test('laconic registry auction create --kind <kind> --commits-duration <commits_duration> --reveals-duration <reveals_duration> --denom <denom> --commit-fee <commit_fee> --reveal-fee <reveal_fee> --minimum-bid <minimum_bid>', async () => {
|
||||
const createAuctionResult = spawnSync('laconic', [
|
||||
'registry',
|
||||
'auction',
|
||||
@ -723,7 +723,7 @@ describe('Test laconic CLI commands', () => {
|
||||
const bidAmount = 25000;
|
||||
let bidRevealFilePath: string;
|
||||
|
||||
test('laconic registry auction create --kind <kind> --commits-duration <commits_duration> --reveals-duration <reveals_duration> --commit-fee <commit_fee> --reveal-fee <reveal_fee> --max-price <max_price> --num-providers <num_providers>', async () => {
|
||||
test('laconic registry auction create --kind <kind> --commits-duration <commits_duration> --reveals-duration <reveals_duration> --denom <denom> --commit-fee <commit_fee> --reveal-fee <reveal_fee> --max-price <max_price> --num-providers <num_providers>', async () => {
|
||||
const createAuctionResult = spawnSync('laconic', [
|
||||
'registry',
|
||||
'auction',
|
||||
|
Loading…
Reference in New Issue
Block a user