From 37df84b5624effb6133a4f2be67eb61bf104b535 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 17 Sep 2024 12:41:14 +0530 Subject: [PATCH 01/13] Add command to create auctions --- src/cmds/registry-cmds/auction-cmds/create.ts | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/cmds/registry-cmds/auction-cmds/create.ts diff --git a/src/cmds/registry-cmds/auction-cmds/create.ts b/src/cmds/registry-cmds/auction-cmds/create.ts new file mode 100644 index 0000000..ad2aa2e --- /dev/null +++ b/src/cmds/registry-cmds/auction-cmds/create.ts @@ -0,0 +1,102 @@ +import { Arguments } from 'yargs'; +import assert from 'assert'; +import Long from 'long'; + +import { Account, DENOM, Registry } from '@cerc-io/registry-sdk'; + +import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util'; +import { MsgCreateAuctionResponse } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/tx'; + +export const command = 'create'; + +export const desc = 'Create auction.'; + +export const builder = { + kind: { + type: 'string' + }, + 'commits-duration': { + type: 'number' + }, + 'reveals-duration': { + type: 'number' + }, + 'commit-fee': { + type: 'string' + }, + 'reveal-fee': { + type: 'string' + }, + 'minimum-bid': { + type: 'string' + }, + 'max-price': { + type: 'string' + }, + 'num-providers': { + type: 'string' + } +}; + +export const handler = async (argv: Arguments) => { + const { config } = argv; + + const kind = argv.kind as string; + const commitsDuration = { + seconds: Long.fromNumber(argv.commitsDuration as number), + nanos: 0 + }; + const revealsDuration = { + seconds: Long.fromNumber(argv.revealsDuration as number), + nanos: 0 + }; + const commitFee = { + denom: DENOM, + amount: argv.commitFee as string + }; + 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; + + assert(kind, 'Invalid auction kind.'); + assert(commitsDuration, 'Invalid commits duration.'); + assert(revealsDuration, 'Invalid reveals duration.'); + assert(commitFee, 'Invalid commit fee.'); + assert(revealFee, 'Invalid reveal fee.'); + + const { services: { registry: registryConfig } } = getConfig(config as string); + const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(rpcEndpoint, 'Invalid registry RPC endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(privateKey, 'Invalid Transaction Key.'); + assert(chainId, 'Invalid registry Chain ID.'); + + const account = new Account(Buffer.from(privateKey, 'hex')); + await account.init(); + const signer = account.address; + + const gasPrice = getGasPrice(argv, registryConfig); + const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice }); + + const fee = getGasAndFees(argv, registryConfig); + + let result: MsgCreateAuctionResponse; + if (kind === 'vickrey') { + result = await registry.createAuction({ commitsDuration, revealsDuration, commitFee, revealFee, minimumBid, signer }, privateKey, fee); + } else { + result = await registry.createProviderAuction({ commitsDuration, revealsDuration, commitFee, revealFee, signer, maxPrice, numProviders }, privateKey, fee); + } + const jsonString = `{"auctionId":"${result.auction?.id}"}`; + + txOutput(result, jsonString, argv.output, argv.verbose); +}; -- 2.45.2 From da744f3766f1f790c2a3d079011de3328157abe8 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 17 Sep 2024 15:51:59 +0530 Subject: [PATCH 02/13] Update readme with CLI command to create a provider auction --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/README.md b/README.md index 09016fc..12b9a4b 100644 --- a/README.md +++ b/README.md @@ -659,3 +659,96 @@ Reassociate records (switch bond): ```bash laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae ``` + +Create `provider` auction: + +```bash +$ laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 3 + +{"auctionId":"73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630"} +``` + +Commit an auction bid: + +```bash +$ laconic registry auction bid commit 73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630 25000000 alnt + +{"reveal_file":"/home/isha/office/laconic-registry-cli/out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json"} +``` + +Reveal an auction bid: + +```bash +$ laconic registry auction bid reveal b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace ./out/bafyreifjkhiakayvvaasnsw7ufaax54ncow4xuycqnox7hxay34c6yod7a.json + +{"success": true} +``` + +Check the auction state on completion: + +```bash +laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace + +[ + { + "id": "b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace", + "kind": "vickrey", + "status": "completed", + "ownerAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r", + "createTime": "2024-09-17T09:51:48.605610628", + "commitsEndTime": "2024-09-17T09:52:48.605610628", + "revealsEndTime": "2024-09-17T09:53:48.605610628", + "commitFee": { + "type": "alnt", + "quantity": 1000 + }, + "revealFee": { + "type": "alnt", + "quantity": 1000 + }, + "minimumBid": { + "type": "alnt", + "quantity": 1000000 + }, + "winnerAddresses": [ + "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r" + ], + "winnerBids": [ + { + "type": "alnt", + "quantity": 25000000 + } + ], + "winnerPrice": { + "type": "alnt", + "quantity": 25000000 + }, + "maxPrice": { + "type": "", + "quantity": 0 + }, + "numProviders": 0, + "bids": [ + { + "bidderAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r", + "status": "reveal", + "commitHash": "bafyreifjkhiakayvvaasnsw7ufaax54ncow4xuycqnox7hxay34c6yod7a", + "commitTime": "2024-09-17T09:52:03.665761945", + "revealTime": "2024-09-17T09:53:00.904061323", + "commitFee": { + "type": "alnt", + "quantity": 1000 + }, + "revealFee": { + "type": "alnt", + "quantity": 1000 + }, + "bidAmount": { + "type": "alnt", + "quantity": 25000000 + } + } + ] + } +] +``` -- 2.45.2 From b18314eef45ede04ba9da12e305ec133b4c87907 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 19 Sep 2024 13:39:15 +0530 Subject: [PATCH 03/13] Add checks for args depending on auction kind --- src/cmds/registry-cmds/auction-cmds/create.ts | 76 ++++++++++++------- src/cmds/registry-cmds/bond-cmds/create.ts | 1 + test/helpers.ts | 3 + 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/cmds/registry-cmds/auction-cmds/create.ts b/src/cmds/registry-cmds/auction-cmds/create.ts index ad2aa2e..a940eb0 100644 --- a/src/cmds/registry-cmds/auction-cmds/create.ts +++ b/src/cmds/registry-cmds/auction-cmds/create.ts @@ -2,10 +2,11 @@ import { Arguments } from 'yargs'; import assert from 'assert'; import Long from 'long'; -import { Account, DENOM, Registry } from '@cerc-io/registry-sdk'; +import { Registry } from '@cerc-io/registry-sdk'; +import { MsgCreateAuctionResponse } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/tx'; import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util'; -import { MsgCreateAuctionResponse } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/tx'; +import { AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER } from '../../../../test/helpers'; export const command = 'create'; @@ -13,28 +14,40 @@ export const desc = 'Create auction.'; export const builder = { kind: { - type: 'string' + type: 'string', + describe: 'Type of auction (vickrey | provider)' }, 'commits-duration': { - type: 'number' + type: 'number', + describe: 'Duration for commits phase in seconds' }, 'reveals-duration': { - type: 'number' + type: 'number', + describe: 'Duration for reveals phase in seconds' + }, + denom: { + type: 'string', + describe: 'Denom' }, 'commit-fee': { - type: 'string' + type: 'number', + describe: 'Fee for committing to the auction' }, 'reveal-fee': { - type: 'string' + type: 'number', + describe: 'Fee for revealing bids in the auction' }, 'minimum-bid': { - type: 'string' + type: 'number', + describe: 'Minimum bid amount (only for vickrey auction)' }, 'max-price': { - type: 'string' + type: 'number', + describe: 'Maximum price (only for provider auction)' }, 'num-providers': { - type: 'string' + type: 'number', + describe: 'Number of providers (only for provider auction)' } }; @@ -50,29 +63,44 @@ export const handler = async (argv: Arguments) => { seconds: Long.fromNumber(argv.revealsDuration as number), nanos: 0 }; + const denom = argv.denom as string; const commitFee = { - denom: DENOM, + denom: denom, amount: argv.commitFee as string }; const revealFee = { - denom: DENOM, + denom: denom, amount: argv.revealFee as string }; const minimumBid = { - denom: DENOM, + denom: denom, amount: argv.minimumBid as string }; const maxPrice = { - denom: DENOM, + denom: denom, amount: argv.maxPrice as string }; const numProviders = argv.numProviders as number; - assert(kind, 'Invalid auction kind.'); - assert(commitsDuration, 'Invalid commits duration.'); - assert(revealsDuration, 'Invalid reveals duration.'); - assert(commitFee, 'Invalid commit fee.'); - assert(revealFee, 'Invalid reveal fee.'); + const validKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER]; + assert(validKinds.includes(kind), 'Invalid auction kind.'); + + if (kind === AUCTION_KIND_VICKREY) { + assert(commitsDuration, 'Invalid commits duration.'); + assert(revealsDuration, 'Invalid reveals duration.'); + assert(commitFee, 'Invalid commit fee.'); + assert(revealFee, 'Invalid reveal fee.'); + assert(!argv.maxPrice, 'Max price should not be provided for vickrey auction.'); + assert(!argv.numProviders, 'Num providers should not be provided for vickrey auction.'); + } else if (kind === AUCTION_KIND_PROVIDER) { + assert(commitsDuration, 'Invalid commits duration.'); + assert(revealsDuration, 'Invalid reveals duration.'); + assert(commitFee, 'Invalid commit fee.'); + assert(revealFee, 'Invalid reveal fee.'); + assert(maxPrice, 'Invalid max price.'); + assert(numProviders, 'Invalid number of providers.'); + assert(!argv.minimumBid, 'Minimum bid should not be provided for provider auction.'); + } const { services: { registry: registryConfig } } = getConfig(config as string); const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); @@ -81,20 +109,16 @@ export const handler = async (argv: Arguments) => { assert(privateKey, 'Invalid Transaction Key.'); assert(chainId, 'Invalid registry Chain ID.'); - const account = new Account(Buffer.from(privateKey, 'hex')); - await account.init(); - const signer = account.address; - const gasPrice = getGasPrice(argv, registryConfig); const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice }); const fee = getGasAndFees(argv, registryConfig); let result: MsgCreateAuctionResponse; - if (kind === 'vickrey') { - result = await registry.createAuction({ commitsDuration, revealsDuration, commitFee, revealFee, minimumBid, signer }, privateKey, fee); + if (kind === AUCTION_KIND_VICKREY) { + result = await registry.createAuction({ commitsDuration, revealsDuration, commitFee, revealFee, minimumBid }, privateKey, fee); } else { - result = await registry.createProviderAuction({ commitsDuration, revealsDuration, commitFee, revealFee, signer, maxPrice, numProviders }, privateKey, fee); + result = await registry.createProviderAuction({ commitsDuration, revealsDuration, commitFee, revealFee, maxPrice, numProviders }, privateKey, fee); } const jsonString = `{"auctionId":"${result.auction?.id}"}`; diff --git a/src/cmds/registry-cmds/bond-cmds/create.ts b/src/cmds/registry-cmds/bond-cmds/create.ts index 2385d94..e6440c9 100644 --- a/src/cmds/registry-cmds/bond-cmds/create.ts +++ b/src/cmds/registry-cmds/bond-cmds/create.ts @@ -1,5 +1,6 @@ import { Arguments } from 'yargs'; import assert from 'assert'; + import { Registry } from '@cerc-io/registry-sdk'; import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util'; diff --git a/test/helpers.ts b/test/helpers.ts index 84d8326..4a7ba81 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -16,6 +16,9 @@ export const AUCTION_FEES = { export const AUCTION_COMMIT_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): any { expect(result.status).toBe(0); -- 2.45.2 From cf04bc1570291687681d0bfea4323dc8ff4f0d24 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 19 Sep 2024 13:57:36 +0530 Subject: [PATCH 04/13] Update README auction example --- README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 12b9a4b..e4372c9 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ These commands require a `config.yml` file present in the current working direct Get node status: ```bash -$ laconic registry status +laconic registry status { "version": "0.3.0", "node": { @@ -186,7 +186,7 @@ $ laconic registry status Get account details: ```bash -$ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k +laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k [ { "address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k", @@ -206,7 +206,7 @@ $ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y Send tokens: ```bash -$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type alnt --quantity 1000000000 +laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type alnt --quantity 1000000000 { "tx": { "hash": "977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC", @@ -250,7 +250,7 @@ $ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y Get token TX details: ```bash -$ laconic registry tokens gettx --hash 977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC +laconic registry tokens gettx --hash 977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC { "hash": "977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC", "height": 343369, @@ -280,7 +280,7 @@ record: Publish record (see below for commands to create/query bonds): ```bash -$ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 --fees 250000alnt +laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 --fees 250000alnt { id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' } ``` @@ -288,7 +288,7 @@ $ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa Get record: ```bash -$ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba +laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba [ { "id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba", @@ -341,7 +341,7 @@ laconic registry authority reserve laconic Check authority information: ```bash -$ laconic registry authority whois laconic +laconic registry authority whois laconic [ { "ownerAddress": "", @@ -387,7 +387,7 @@ $ laconic registry authority whois laconic Get authority auction info: ```bash -$ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 +laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 [ { "id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48", @@ -425,7 +425,7 @@ $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2 Commit an auction bid: ```bash -$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 alnt +laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 alnt Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json ``` @@ -475,7 +475,7 @@ laconic registry name set lrn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsou Lookup name information: ```bash -$ laconic registry name lookup lrn://laconic/watcher/erc20 +laconic registry name lookup lrn://laconic/watcher/erc20 [ { "latest": { @@ -489,7 +489,7 @@ $ laconic registry name lookup lrn://laconic/watcher/erc20 Resolve name: ```bash -$ laconic registry name resolve lrn://laconic/watcher/erc20 +laconic registry name resolve lrn://laconic/watcher/erc20 [ { "id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba", @@ -530,9 +530,9 @@ $ laconic registry name resolve lrn://laconic/watcher/erc20 Delete name: ```bash -$ laconic registry name delete lrn://laconic/watcher/erc20 +laconic registry name delete lrn://laconic/watcher/erc20 -$ laconic registry name resolve lrn://laconic/watcher/erc20 +laconic registry name resolve lrn://laconic/watcher/erc20 [ null ] @@ -547,7 +547,7 @@ laconic registry bond create --type alnt --quantity 1000 List bonds: ```bash -$ laconic registry bond list +laconic registry bond list [ { "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", @@ -575,7 +575,7 @@ $ laconic registry bond list Get bond: ```bash -$ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 +laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 [ { "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", @@ -593,7 +593,7 @@ $ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa1953 Query bonds by owner: ```bash -$ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k +laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k [ { "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", @@ -663,7 +663,7 @@ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55b Create `provider` auction: ```bash -$ laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 3 +laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 2 {"auctionId":"73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630"} ``` @@ -671,15 +671,15 @@ $ laconic registry auction create --kind provider --commits-duration 60 --reveal Commit an auction bid: ```bash -$ laconic registry auction bid commit 73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630 25000000 alnt +laconic registry auction bid commit 73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630 25000000 alnt -{"reveal_file":"/home/isha/office/laconic-registry-cli/out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json"} +{"reveal_file":"./out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json"} ``` Reveal an auction bid: ```bash -$ laconic registry auction bid reveal b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace ./out/bafyreifjkhiakayvvaasnsw7ufaax54ncow4xuycqnox7hxay34c6yod7a.json +laconic registry auction bid reveal b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace ./out/bafyreifjkhiakayvvaasnsw7ufaax54ncow4xuycqnox7hxay34c6yod7a.json {"success": true} ``` -- 2.45.2 From f100f3fb2d2d3d6e8ca4afe4db2440f6cc3a3bfe Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 19 Sep 2024 14:49:50 +0530 Subject: [PATCH 05/13] Update README auction CLI example --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e4372c9..3e07cdd 100644 --- a/README.md +++ b/README.md @@ -692,9 +692,9 @@ laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c [ { "id": "b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace", - "kind": "vickrey", + "kind": "provider", "status": "completed", - "ownerAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r", + "ownerAddress": "laconic1maqfgs93hnvzqh5mfj9kxt4e3n27vhd0w7emrx", "createTime": "2024-09-17T09:51:48.605610628", "commitsEndTime": "2024-09-17T09:52:48.605610628", "revealsEndTime": "2024-09-17T09:53:48.605610628", @@ -707,8 +707,8 @@ laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c "quantity": 1000 }, "minimumBid": { - "type": "alnt", - "quantity": 1000000 + "type": "", + "quantity": 0 }, "winnerAddresses": [ "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r" @@ -716,18 +716,18 @@ laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c "winnerBids": [ { "type": "alnt", - "quantity": 25000000 + "quantity": 26000 } ], "winnerPrice": { "type": "alnt", - "quantity": 25000000 + "quantity": 26000 }, "maxPrice": { - "type": "", - "quantity": 0 + "type": "alnt", + "quantity": 100000 }, - "numProviders": 0, + "numProviders": 2, "bids": [ { "bidderAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r", @@ -745,7 +745,7 @@ laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c }, "bidAmount": { "type": "alnt", - "quantity": 25000000 + "quantity": 26000 } } ] -- 2.45.2 From 2299898a7b897a373817ceb53dd68291cf130b59 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 19 Sep 2024 17:35:48 +0530 Subject: [PATCH 06/13] Use proper types for duration and coin --- src/cmds/registry-cmds/auction-cmds/create.ts | 35 +++++++------------ test/helpers.ts | 3 -- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/cmds/registry-cmds/auction-cmds/create.ts b/src/cmds/registry-cmds/auction-cmds/create.ts index a940eb0..9e7d7a8 100644 --- a/src/cmds/registry-cmds/auction-cmds/create.ts +++ b/src/cmds/registry-cmds/auction-cmds/create.ts @@ -2,11 +2,12 @@ import { Arguments } from 'yargs'; import assert from 'assert'; 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 { 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 { AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER } from '../../../../test/helpers'; export const command = 'create'; @@ -31,7 +32,7 @@ export const builder = { }, 'commit-fee': { type: 'number', - describe: 'Fee for committing to the auction' + describe: 'Fee for committing a bid to the auction' }, 'reveal-fee': { type: 'number', @@ -55,31 +56,19 @@ export const handler = async (argv: Arguments) => { const { config } = argv; const kind = argv.kind as string; - const commitsDuration = { + const commitsDuration = Duration.fromPartial({ seconds: Long.fromNumber(argv.commitsDuration as number), nanos: 0 - }; - const revealsDuration = { + }); + const revealsDuration = Duration.fromPartial({ seconds: Long.fromNumber(argv.revealsDuration as number), nanos: 0 - }; + }); const denom = argv.denom as string; - const commitFee = { - denom: denom, - amount: argv.commitFee as string - }; - 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 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 numProviders = argv.numProviders as number; const validKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER]; diff --git a/test/helpers.ts b/test/helpers.ts index 4a7ba81..84d8326 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -16,9 +16,6 @@ export const AUCTION_FEES = { export const AUCTION_COMMIT_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): any { expect(result.status).toBe(0); -- 2.45.2 From 3cf35dad43419a32ded408ee3d6f2fc8ee0cdc78 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 19 Sep 2024 20:21:34 +0530 Subject: [PATCH 07/13] Update expected auction object in tests --- test/helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/helpers.ts b/test/helpers.ts index 84d8326..12d2992 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -95,7 +95,8 @@ export function getAuctionObj (params: { owner: string, status?: string }): any type: TOKEN_TYPE, quantity: AUCTION_FEES.minimumBid }, - winnerAddress: '' + winnerAddresses: [], + winnerBids: [] }; } -- 2.45.2 From d27f9ae43dd4ee5a6fa66cc6efdcb27fbb4c16c6 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Fri, 20 Sep 2024 10:59:01 +0530 Subject: [PATCH 08/13] Update create auction CLI and add auction tests --- README.md | 23 ++-- src/cmds/registry-cmds/auction-cmds/create.ts | 63 ++++----- test/README.md | 2 +- test/cli.test.ts | 130 +++++++++++++++++- test/helpers.ts | 10 ++ 5 files changed, 181 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 3e07cdd..6594f86 100644 --- a/README.md +++ b/README.md @@ -660,26 +660,29 @@ Reassociate records (switch bond): laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae ``` -Create `provider` auction: +Create a `provider` auction: ```bash -laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 2 +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 {"auctionId":"73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630"} + +# Set auction id in a variable +AUCTION= ``` Commit an auction bid: ```bash -laconic registry auction bid commit 73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630 25000000 alnt +laconic registry auction bid commit $AUCTION 25000 alnt -{"reveal_file":"./out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json"} +{"reveal_file":"/home/user/laconic-registry-cli/out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json"} ``` Reveal an auction bid: ```bash -laconic registry auction bid reveal b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace ./out/bafyreifjkhiakayvvaasnsw7ufaax54ncow4xuycqnox7hxay34c6yod7a.json +laconic registry auction bid reveal $AUCTION /home/user/laconic-registry-cli/out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json {"success": true} ``` @@ -687,7 +690,7 @@ laconic registry auction bid reveal b66b74048fc360de6a926123b760e6485276d90ad227 Check the auction state on completion: ```bash -laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace +laconic registry auction get $AUCTION [ { @@ -716,18 +719,18 @@ laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c "winnerBids": [ { "type": "alnt", - "quantity": 26000 + "quantity": 25000 } ], "winnerPrice": { "type": "alnt", - "quantity": 26000 + "quantity": 25000 }, "maxPrice": { "type": "alnt", "quantity": 100000 }, - "numProviders": 2, + "numProviders": 1, "bids": [ { "bidderAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r", @@ -745,7 +748,7 @@ laconic registry auction get b66b74048fc360de6a926123b760e6485276d90ad2274b5386c }, "bidAmount": { "type": "alnt", - "quantity": 26000 + "quantity": 25000 } } ] diff --git a/src/cmds/registry-cmds/auction-cmds/create.ts b/src/cmds/registry-cmds/auction-cmds/create.ts index 9e7d7a8..3f03b67 100644 --- a/src/cmds/registry-cmds/auction-cmds/create.ts +++ b/src/cmds/registry-cmds/auction-cmds/create.ts @@ -16,19 +16,19 @@ export const desc = 'Create auction.'; export const builder = { kind: { type: 'string', - describe: 'Type of auction (vickrey | provider)' + describe: 'Auction kind (vickrey | provider)' }, 'commits-duration': { type: 'number', - describe: 'Duration for commits phase in seconds' + describe: 'Duration for bid commit phase in seconds' }, 'reveals-duration': { type: 'number', - describe: 'Duration for reveals phase in seconds' + describe: 'Duration for bid reveal phase in seconds' }, denom: { type: 'string', - describe: 'Denom' + describe: 'Denom to use' }, 'commit-fee': { type: 'number', @@ -36,19 +36,21 @@ export const builder = { }, 'reveal-fee': { type: 'number', - describe: 'Fee for revealing bids in the auction' + describe: 'Fee for revealing a bid in the auction' }, 'minimum-bid': { type: 'number', + default: 0, describe: 'Minimum bid amount (only for vickrey auction)' }, 'max-price': { type: 'number', - describe: 'Maximum price (only for provider auction)' + default: 0, + describe: 'Max acceptable bid price (only for provider auction)' }, 'num-providers': { type: 'number', - describe: 'Number of providers (only for provider auction)' + describe: 'Number ofdesired providers (only for provider auction)' } }; @@ -56,14 +58,24 @@ export const handler = async (argv: Arguments) => { const { config } = argv; const kind = argv.kind as string; - const commitsDuration = Duration.fromPartial({ - seconds: Long.fromNumber(argv.commitsDuration as number), - nanos: 0 - }); - const revealsDuration = Duration.fromPartial({ - seconds: Long.fromNumber(argv.revealsDuration as number), - nanos: 0 - }); + 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.`); + assert(!argv.numProviders, `Num providers can only be used with ${AUCTION_KIND_PROVIDER} auction.`); + } else if (kind === AUCTION_KIND_PROVIDER) { + assert(argv.maxPrice, 'Invalid max price.'); + assert(argv.numProviders, 'Invalid num providers.'); + assert(!argv.minimumBid, `Minimum bid can only be used with ${AUCTION_KIND_VICKREY} auction.`); + } + + assert(argv.commitsDuration, 'Invalid commits duration.'); + assert(argv.revealsDuration, 'Invalid reveals duration.'); + 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 denom = argv.denom as string; const commitFee = coin(argv.commitFee as string, denom); const revealFee = coin(argv.revealFee as string, denom); @@ -71,25 +83,8 @@ export const handler = async (argv: Arguments) => { const maxPrice = coin(argv.maxPrice as string, denom); const numProviders = argv.numProviders as number; - const validKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER]; - assert(validKinds.includes(kind), 'Invalid auction kind.'); - - if (kind === AUCTION_KIND_VICKREY) { - assert(commitsDuration, 'Invalid commits duration.'); - assert(revealsDuration, 'Invalid reveals duration.'); - assert(commitFee, 'Invalid commit fee.'); - assert(revealFee, 'Invalid reveal fee.'); - assert(!argv.maxPrice, 'Max price should not be provided for vickrey auction.'); - assert(!argv.numProviders, 'Num providers should not be provided for vickrey auction.'); - } else if (kind === AUCTION_KIND_PROVIDER) { - assert(commitsDuration, 'Invalid commits duration.'); - assert(revealsDuration, 'Invalid reveals duration.'); - assert(commitFee, 'Invalid commit fee.'); - assert(revealFee, 'Invalid reveal fee.'); - assert(maxPrice, 'Invalid max price.'); - assert(numProviders, 'Invalid number of providers.'); - assert(!argv.minimumBid, 'Minimum bid should not be provided for provider auction.'); - } + 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); diff --git a/test/README.md b/test/README.md index b2eb727..1975ddd 100644 --- a/test/README.md +++ b/test/README.md @@ -1,4 +1,4 @@ -## Run CLI tests +# Run CLI tests * Follow the project `Setup` and `Account Setup` from root [README](./../README.md) diff --git a/test/cli.test.ts b/test/cli.test.ts index 4f0168a..3aba5a4 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -2,6 +2,8 @@ import fs from 'fs'; import assert from 'assert'; import { spawnSync } from 'child_process'; +import { AUCTION_KIND_VICKREY } from '@cerc-io/registry-sdk'; + import { CHAIN_ID, TOKEN_TYPE, @@ -16,7 +18,8 @@ import { getAuthorityObj, getAuctionObj, getBidObj, - updateGasAndFeesConfig + updateGasAndFeesConfig, + AUCTION_STATUS } from './helpers'; describe('Test laconic CLI commands', () => { @@ -369,7 +372,7 @@ describe('Test laconic CLI commands', () => { }); }); - describe('Auction operations', () => { + describe('Authority auction operations', () => { const bidAmount = 25000000; let bidRevealFilePath: string; @@ -587,6 +590,129 @@ describe('Test laconic CLI commands', () => { }); }); + describe('Vickrey Auction operations', () => { + const commitFee = 1000; + const revealFee = 1000; + const minimumBid = 100000; + + const bidAmount = 25000000; + let bidRevealFilePath: string; + + test('laconic registry auction create --kind --commits-duration --reveals-duration --commit-fee --reveal-fee --minimum-bid ', async () => { + const createAuctionResult = spawnSync('laconic', [ + 'registry', + 'auction', + 'create', + '--kind', AUCTION_KIND_VICKREY, + '--commits-duration', AUCTION_COMMIT_DURATION.toString(), + '--reveals-duration', AUCTION_REVEAL_DURATION.toString(), + '--denom', TOKEN_TYPE, + '--commit-fee', commitFee.toString(), + '--reveal-fee', revealFee.toString(), + '--minimum-bid', minimumBid.toString() + ]); + const outputObj = checkResultAndRetrieveOutput(createAuctionResult); + + expect(outputObj).toHaveProperty('auctionId'); + + testAuctionId = outputObj.auctionId; + const getAuctionResult = spawnSync('laconic', ['registry', 'auction', 'get', '--id', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(getAuctionResult); + + const expectedAuctionObjPartial = { + kind: AUCTION_KIND_VICKREY, + status: AUCTION_STATUS.COMMIT, + ownerAddress: testAccount, + commitFee: { quantity: commitFee }, + revealFee: { quantity: revealFee }, + minimumBid: { quantity: minimumBid }, + winnerAddresses: [], + winnerBids: [], + maxPrice: { quantity: 0 }, + numProviders: 0, + bids: [] + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + }); + + test('laconic registry auction bid commit ', async () => { + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]); + const outputObj = checkResultAndRetrieveOutput(result); + + // Expected output + expect(outputObj.reveal_file).toBeDefined(); + + bidRevealFilePath = outputObj.reveal_file; + }); + + test('laconic registry auction bid reveal ', async () => { + // Wait for auction commits duration (60s) + await delay(AUCTION_COMMIT_DURATION * 1000); + + let auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + let auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartial = { + status: AUCTION_STATUS.REVEAL, + ownerAddress: testAccount, + winnerAddresses: [], + winnerBids: [], + bids: [{ + bidderAddress: testAccount, + status: AUCTION_STATUS.COMMIT, + bidAmount: { quantity: 0 } + }] + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + + // Reveal bid + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]); + const outputObj = checkResultAndRetrieveOutput(result); + + // Expected output + expect(outputObj).toEqual({ success: true }); + + const revealObject = JSON.parse(fs.readFileSync(bidRevealFilePath, 'utf8')); + expect(revealObject).toMatchObject({ + chainId: CHAIN_ID, + auctionId: testAuctionId, + bidderAddress: testAccount, + bidAmount: `${bidAmount}${TOKEN_TYPE}` + }); + + auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartialOnBidReveal = { + status: AUCTION_STATUS.REVEAL, + winnerAddresses: [], + bids: [{ + bidderAddress: testAccount, + status: AUCTION_STATUS.REVEAL, + bidAmount: { quantity: bidAmount } + }] + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartialOnBidReveal); + }, (AUCTION_COMMIT_DURATION + 5) * 1000); + + test('laconic registry auction get ', async () => { + // Wait for auction reveals duration (60s) + await delay(AUCTION_REVEAL_DURATION * 1000); + + const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartial = { + status: AUCTION_STATUS.COMPLETED, + ownerAddress: testAccount, + winnerAddresses: [testAccount], + winnerBids: [{ quantity: bidAmount }], + winnerPrice: { quantity: bidAmount } + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + }, (AUCTION_COMMIT_DURATION + 5) * 1000); + }); + describe('Gas and fees config', () => { const bondAmount = 1000; diff --git a/test/helpers.ts b/test/helpers.ts index 12d2992..b98687e 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -8,6 +8,12 @@ import { getConfig } from '../src/util'; export const CHAIN_ID = 'laconic_9000-1'; export const TOKEN_TYPE = 'alnt'; +export enum AUCTION_STATUS { + COMMIT = 'commit', + REVEAL = 'reveal', + COMPLETED = 'completed' +} + export const AUCTION_FEES = { commit: 1000000, reveal: 1000000, @@ -17,6 +23,10 @@ export const AUCTION_COMMIT_DURATION = 60; // 60s export const AUCTION_REVEAL_DURATION = 60; // 60s export function checkResultAndRetrieveOutput (result: SpawnSyncReturns): any { + if (result.status !== 0) { + console.log('stderr', result.stderr.toString().trim()); + } + expect(result.status).toBe(0); const errorOutput = result.stderr.toString().trim(); -- 2.45.2 From 4b273f4d166f4baeb4113327f6f58021cfc8bfc7 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 20 Sep 2024 15:02:26 +0530 Subject: [PATCH 09/13] Add provider auction CLI test --- src/cmds/registry-cmds/auction-cmds/create.ts | 8 +- test/cli.test.ts | 130 +++++++++++++++++- 2 files changed, 132 insertions(+), 6 deletions(-) diff --git a/src/cmds/registry-cmds/auction-cmds/create.ts b/src/cmds/registry-cmds/auction-cmds/create.ts index 3f03b67..d16b189 100644 --- a/src/cmds/registry-cmds/auction-cmds/create.ts +++ b/src/cmds/registry-cmds/auction-cmds/create.ts @@ -2,9 +2,7 @@ import { Arguments } from 'yargs'; import assert from 'assert'; import Long from 'long'; -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 { Duration } from '@cerc-io/registry-sdk/dist/proto/google/protobuf/duration'; +import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY, Duration, Registry } from '@cerc-io/registry-sdk'; import { coin } from '@cosmjs/amino'; import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util'; @@ -98,13 +96,13 @@ export const handler = async (argv: Arguments) => { const fee = getGasAndFees(argv, registryConfig); - let result: MsgCreateAuctionResponse; + let result: any; if (kind === AUCTION_KIND_VICKREY) { result = await registry.createAuction({ commitsDuration, revealsDuration, commitFee, revealFee, minimumBid }, privateKey, fee); } else { result = await registry.createProviderAuction({ commitsDuration, revealsDuration, commitFee, revealFee, maxPrice, numProviders }, privateKey, fee); } - const jsonString = `{"auctionId":"${result.auction?.id}"}`; + const jsonString = `{"auctionId":"${result.auction?.id}"}`; txOutput(result, jsonString, argv.output, argv.verbose); }; diff --git a/test/cli.test.ts b/test/cli.test.ts index 3aba5a4..4786a5b 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -2,7 +2,7 @@ import fs from 'fs'; import assert from 'assert'; import { spawnSync } from 'child_process'; -import { AUCTION_KIND_VICKREY } from '@cerc-io/registry-sdk'; +import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY } from '@cerc-io/registry-sdk'; import { CHAIN_ID, @@ -228,6 +228,7 @@ describe('Test laconic CLI commands', () => { expect(outputObj.accounts.length).toEqual(2); expect(outputObj.accounts).toMatchObject(expectedAccounts); }); + test('laconic registry tokens gettx --hash ', async () => { const sendAmount = 1000000000; @@ -680,6 +681,133 @@ describe('Test laconic CLI commands', () => { bidAmount: `${bidAmount}${TOKEN_TYPE}` }); + // Get auction with revealed bid + auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartialOnBidReveal = { + status: AUCTION_STATUS.REVEAL, + winnerAddresses: [], + bids: [{ + bidderAddress: testAccount, + status: AUCTION_STATUS.REVEAL, + bidAmount: { quantity: bidAmount } + }] + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartialOnBidReveal); + }, (AUCTION_COMMIT_DURATION + 5) * 1000); + + test('laconic registry auction get ', async () => { + // Wait for auction reveals duration (60s) + await delay(AUCTION_REVEAL_DURATION * 1000); + + const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartial = { + status: AUCTION_STATUS.COMPLETED, + ownerAddress: testAccount, + winnerAddresses: [testAccount], + winnerBids: [{ quantity: bidAmount }], + winnerPrice: { quantity: bidAmount } + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + }, (AUCTION_COMMIT_DURATION + 5) * 1000); + }); + + describe('Provider Auction operations', () => { + const commitFee = 1000; + const revealFee = 1000; + const maxPrice = 1000000; + const numProviders = 5; + const bidAmount = 25000; + let bidRevealFilePath: string; + + test('laconic registry auction create --kind --commits-duration --reveals-duration --commit-fee --reveal-fee --max-price --num-providers ', async () => { + const createAuctionResult = spawnSync('laconic', [ + 'registry', + 'auction', + 'create', + '--kind', AUCTION_KIND_PROVIDER, + '--commits-duration', AUCTION_COMMIT_DURATION.toString(), + '--reveals-duration', AUCTION_REVEAL_DURATION.toString(), + '--denom', TOKEN_TYPE, + '--commit-fee', commitFee.toString(), + '--reveal-fee', revealFee.toString(), + '--max-price', maxPrice.toString(), + '--num-providers', numProviders.toString() + ]); + + const outputObj = checkResultAndRetrieveOutput(createAuctionResult); + + expect(outputObj).toHaveProperty('auctionId'); + + testAuctionId = outputObj.auctionId; + const getAuctionResult = spawnSync('laconic', ['registry', 'auction', 'get', '--id', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(getAuctionResult); + + const expectedAuctionObjPartial = { + kind: AUCTION_KIND_PROVIDER, + status: AUCTION_STATUS.COMMIT, + ownerAddress: testAccount, + commitFee: { quantity: commitFee }, + revealFee: { quantity: revealFee }, + minimumBid: { quantity: 0 }, + winnerAddresses: [], + winnerBids: [], + maxPrice: { quantity: maxPrice }, + numProviders: numProviders, + bids: [] + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + }); + + test('laconic registry auction bid commit ', async () => { + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]); + const outputObj = checkResultAndRetrieveOutput(result); + + // Expected output + expect(outputObj.reveal_file).toBeDefined(); + + bidRevealFilePath = outputObj.reveal_file; + }); + + test('laconic registry auction bid reveal ', async () => { + // Wait for auction commits duration (60s) + await delay(AUCTION_COMMIT_DURATION * 1000); + + let auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + let auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartial = { + status: AUCTION_STATUS.REVEAL, + ownerAddress: testAccount, + winnerAddresses: [], + winnerBids: [], + bids: [{ + bidderAddress: testAccount, + status: AUCTION_STATUS.COMMIT, + bidAmount: { quantity: 0 } + }] + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + + // Reveal bid + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]); + const outputObj = checkResultAndRetrieveOutput(result); + + // Expected output + expect(outputObj).toEqual({ success: true }); + + const revealObject = JSON.parse(fs.readFileSync(bidRevealFilePath, 'utf8')); + expect(revealObject).toMatchObject({ + chainId: CHAIN_ID, + auctionId: testAuctionId, + bidderAddress: testAccount, + bidAmount: `${bidAmount}${TOKEN_TYPE}` + }); + + // Get auction with revealed bid auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); -- 2.45.2 From fa734a4ff8f5899ddacedd75fd2bc7c9309710da Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 20 Sep 2024 18:50:09 +0530 Subject: [PATCH 10/13] Update create auction CLI with updated types --- README.md | 4 +- src/cmds/registry-cmds/auction-cmds/create.ts | 38 +++++++++---------- test/cli.test.ts | 4 +- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 6594f86..7afa70c 100644 --- a/README.md +++ b/README.md @@ -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", diff --git a/src/cmds/registry-cmds/auction-cmds/create.ts b/src/cmds/registry-cmds/auction-cmds/create.ts index d16b189..089a114 100644 --- a/src/cmds/registry-cmds/auction-cmds/create.ts +++ b/src/cmds/registry-cmds/auction-cmds/create.ts @@ -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}"}`; diff --git a/test/cli.test.ts b/test/cli.test.ts index 4786a5b..90f15f5 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -599,7 +599,7 @@ describe('Test laconic CLI commands', () => { const bidAmount = 25000000; let bidRevealFilePath: string; - test('laconic registry auction create --kind --commits-duration --reveals-duration --commit-fee --reveal-fee --minimum-bid ', async () => { + test('laconic registry auction create --kind --commits-duration --reveals-duration --denom --commit-fee --reveal-fee --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 --commits-duration --reveals-duration --commit-fee --reveal-fee --max-price --num-providers ', async () => { + test('laconic registry auction create --kind --commits-duration --reveals-duration --denom --commit-fee --reveal-fee --max-price --num-providers ', async () => { const createAuctionResult = spawnSync('laconic', [ 'registry', 'auction', -- 2.45.2 From cbf319e97e0ec0a300fd7ef31f11361d99de389d Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 23 Sep 2024 18:55:07 +0530 Subject: [PATCH 11/13] Add CLI for releasing funds of provider auction winners --- README.md | 8 +++++ .../auction-cmds/release-funds.ts | 34 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/cmds/registry-cmds/auction-cmds/release-funds.ts diff --git a/README.md b/README.md index 7afa70c..50b0f76 100644 --- a/README.md +++ b/README.md @@ -755,3 +755,11 @@ laconic registry auction get $AUCTION } ] ``` + +Release provider winning funds: + +```bash +laconic registry auction release-funds $AUCTION + +{"success": true} +``` diff --git a/src/cmds/registry-cmds/auction-cmds/release-funds.ts b/src/cmds/registry-cmds/auction-cmds/release-funds.ts new file mode 100644 index 0000000..f555f3a --- /dev/null +++ b/src/cmds/registry-cmds/auction-cmds/release-funds.ts @@ -0,0 +1,34 @@ +import { Arguments } from 'yargs'; +import assert from 'assert'; + +import { Account, Registry } from '@cerc-io/registry-sdk'; + +import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util'; + +export const command = 'release-funds [auction-id]'; + +export const desc = 'Release funds of provider auction winners.'; + +export const handler = async (argv: Arguments) => { + const auctionId = argv.auctionId as string; + assert(auctionId, 'Invalid auction ID.'); + + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(rpcEndpoint, 'Invalid registry RPC endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(privateKey, 'Invalid Transaction Key.'); + assert(chainId, 'Invalid registry Chain ID.'); + + const account = new Account(Buffer.from(privateKey, 'hex')); + await account.init(); + + const gasPrice = getGasPrice(argv, registryConfig); + const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice }); + const fee = getGasAndFees(argv, registryConfig); + + const result = await registry.releaseFunds({ auctionId }, privateKey, fee); + + const success = '{"success": true}'; + txOutput(result, success, argv.output, argv.verbose); +}; -- 2.45.2 From 15bf0a3cf24e7fc99af56347f648f925a6e49498 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Tue, 24 Sep 2024 11:47:20 +0530 Subject: [PATCH 12/13] Add a test for release-funds command and use multiple accounts --- .gitignore | 3 +- test/cli.test.ts | 170 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 124 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index c36d7c2..d1c0f4f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist/* out config.yml +.env *~ -.idea \ No newline at end of file +.idea diff --git a/test/cli.test.ts b/test/cli.test.ts index 90f15f5..f284598 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -715,13 +715,43 @@ describe('Test laconic CLI commands', () => { }, (AUCTION_COMMIT_DURATION + 5) * 1000); }); - describe('Provider Auction operations', () => { + describe.only('Provider Auction operations', () => { const commitFee = 1000; const revealFee = 1000; const maxPrice = 1000000; - const numProviders = 5; - const bidAmount = 25000; - let bidRevealFilePath: string; + const numProviders = 2; + const bidderInitialBlanace = 1000000000; + const txFees = 200000; + testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350'; + + const bidderAccounts = [ + { + privateKey: 'f40f8e2c9ba70595b6d1cf3bcc47ba539e7d6ad2bcdb16e26c1e369378fd5a55', + address: 'laconic13cd6ntlcf5y0zmafg6wf96y6vsnq46xagpmjtc', + bidAmount: 25000 + }, + { + privateKey: '2c70e81c285e12f196837911aa258b11dff7e4189fc0f11e28cb228956807881', + address: 'laconic15x7sw49w3x2pahjlr48hunp5gpr7hm54eg3f8h', + bidAmount: 25300 + }, + { + privateKey: '1d3a47900e1a5980b171419ac700e779330bc0f85389a4113ff608ca314e25bb', + address: 'laconic1lkgay8ejvcwmngj3jua2ancdxxkukecz7hty89', + bidAmount: 25200 + } + ]; + const winnerAccounts = [bidderAccounts[0], bidderAccounts[2]]; + const winnerPrice = bidderAccounts[2].bidAmount; + + const bidRevealFilePaths: string[] = []; + + beforeAll(() => { + // Fund all bidder accounts + bidderAccounts.forEach(account => { + spawnSync('laconic', ['registry', 'tokens', 'send', '--address', account.address, '--type', TOKEN_TYPE, '--quantity', bidderInitialBlanace.toString()]); + }); + }); test('laconic registry auction create --kind --commits-duration --reveals-duration --denom --commit-fee --reveal-fee --max-price --num-providers ', async () => { const createAuctionResult = spawnSync('laconic', [ @@ -763,65 +793,71 @@ describe('Test laconic CLI commands', () => { }); test('laconic registry auction bid commit ', async () => { - const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]); - const outputObj = checkResultAndRetrieveOutput(result); + for (const bidderAccount of bidderAccounts) { + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidderAccount.bidAmount.toString(), TOKEN_TYPE, '--txKey', bidderAccount.privateKey]); + const outputObj = checkResultAndRetrieveOutput(result); - // Expected output - expect(outputObj.reveal_file).toBeDefined(); + // Expected output + expect(outputObj.reveal_file).toBeDefined(); - bidRevealFilePath = outputObj.reveal_file; + bidRevealFilePaths.push(outputObj.reveal_file); + } + + const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedBids = bidderAccounts.map(account => ({ + bidderAddress: account.address, + status: AUCTION_STATUS.COMMIT, + bidAmount: { quantity: 0 } + })); + const expectedAuctionObjPartial = { + status: AUCTION_STATUS.COMMIT, + ownerAddress: testAccount, + winnerAddresses: [], + winnerBids: [], + bids: expectedBids + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); }); test('laconic registry auction bid reveal ', async () => { // Wait for auction commits duration (60s) await delay(AUCTION_COMMIT_DURATION * 1000); - let auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); - let auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); - - const expectedAuctionObjPartial = { - status: AUCTION_STATUS.REVEAL, - ownerAddress: testAccount, - winnerAddresses: [], - winnerBids: [], - bids: [{ - bidderAddress: testAccount, - status: AUCTION_STATUS.COMMIT, - bidAmount: { quantity: 0 } - }] - }; - expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); - // Reveal bid - const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]); - const outputObj = checkResultAndRetrieveOutput(result); + for (let i = 0; i < bidderAccounts.length; i++) { + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePaths[i], '--txKey', bidderAccounts[i].privateKey]); + const outputObj = checkResultAndRetrieveOutput(result); - // Expected output - expect(outputObj).toEqual({ success: true }); + // Expected output + expect(outputObj).toEqual({ success: true }); - const revealObject = JSON.parse(fs.readFileSync(bidRevealFilePath, 'utf8')); - expect(revealObject).toMatchObject({ - chainId: CHAIN_ID, - auctionId: testAuctionId, - bidderAddress: testAccount, - bidAmount: `${bidAmount}${TOKEN_TYPE}` - }); + const revealObject = JSON.parse(fs.readFileSync(bidRevealFilePaths[i], 'utf8')); + expect(revealObject).toMatchObject({ + chainId: CHAIN_ID, + auctionId: testAuctionId, + bidderAddress: bidderAccounts[i].address, + bidAmount: `${bidderAccounts[i].bidAmount}${TOKEN_TYPE}` + }); + } // Get auction with revealed bid - auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); - auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + const expectedBids = bidderAccounts.map(account => ({ + bidderAddress: account.address, + status: AUCTION_STATUS.REVEAL, + bidAmount: { quantity: account.bidAmount } + })); const expectedAuctionObjPartialOnBidReveal = { status: AUCTION_STATUS.REVEAL, winnerAddresses: [], - bids: [{ - bidderAddress: testAccount, - status: AUCTION_STATUS.REVEAL, - bidAmount: { quantity: bidAmount } - }] + bids: expectedBids }; expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartialOnBidReveal); - }, (AUCTION_COMMIT_DURATION + 5) * 1000); + }, (AUCTION_COMMIT_DURATION + 60) * 1000); test('laconic registry auction get ', async () => { // Wait for auction reveals duration (60s) @@ -830,15 +866,53 @@ describe('Test laconic CLI commands', () => { const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + const expectedWinnerAddresses = winnerAccounts.map(account => account.address); + const expectedWinnerBids = winnerAccounts.map(account => ({ quantity: account.bidAmount })); + const expectedAuctionObjPartial = { status: AUCTION_STATUS.COMPLETED, ownerAddress: testAccount, - winnerAddresses: [testAccount], - winnerBids: [{ quantity: bidAmount }], - winnerPrice: { quantity: bidAmount } + winnerAddresses: expectedWinnerAddresses, + winnerBids: expectedWinnerBids, + winnerPrice: { quantity: winnerPrice }, + fundsReleased: false }; expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); - }, (AUCTION_COMMIT_DURATION + 5) * 1000); + }, (AUCTION_REVEAL_DURATION + 5) * 1000); + + test('laconic registry auction release-funds ', async () => { + const result = spawnSync('laconic', ['registry', 'auction', 'release-funds', testAuctionId]); + const outputObj = checkResultAndRetrieveOutput(result); + + expect(outputObj).toEqual({ success: true }); + + const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); + const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); + + const expectedAuctionObjPartial = { + status: AUCTION_STATUS.COMPLETED, + ownerAddress: testAccount, + fundsReleased: true + }; + expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial); + + const expectedBalances = [ + bidderInitialBlanace - (commitFee) - (2 * txFees) + winnerPrice, + bidderInitialBlanace - (commitFee) - (2 * txFees), + bidderInitialBlanace - (commitFee) - (2 * txFees) + winnerPrice + ]; + + for (let i = 0; i < bidderAccounts.length; i++) { + const result = spawnSync('laconic', ['registry', 'account', 'get', '--address', bidderAccounts[i].address]); + const outputObj = checkResultAndRetrieveOutput(result); + + // Expected account + const expectedAccount = getAccountObj({ address: bidderAccounts[i].address, balance: expectedBalances[i] }); + + expect(outputObj.length).toEqual(1); + expect(outputObj[0]).toMatchObject(expectedAccount); + } + }); }); describe('Gas and fees config', () => { -- 2.45.2 From 3d7fd6a1de2f831f0baab4ed858cf6ebcc1d3201 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 25 Sep 2024 18:56:25 +0530 Subject: [PATCH 13/13] Upgrade dependencies and increment version --- package.json | 4 ++-- yarn.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f351c2b..c8c4b64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cerc-io/laconic-registry-cli", - "version": "0.2.8", + "version": "0.2.9", "main": "index.js", "repository": "git@github.com:cerc-io/laconic-registry-cli.git", "author": "", @@ -29,7 +29,7 @@ "typescript": "^4.6.3" }, "dependencies": { - "@cerc-io/registry-sdk": "^0.2.9", + "@cerc-io/registry-sdk": "^0.2.10", "@cosmjs/stargate": "^0.32.2", "fs-extra": "^10.1.0", "js-yaml": "^3.14.1", diff --git a/yarn.lock b/yarn.lock index a832ebf..404ec4e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -302,10 +302,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@cerc-io/registry-sdk@^0.2.9": - version "0.2.9" - resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.9/registry-sdk-0.2.9.tgz#da0645d30a1975bf6c0869dff4ab51fafd73c6ed" - integrity sha512-ZLlYa2yNvd19mA2MYr7qW0fFkouOxK5w8EzsIYXUm+YokLZXCaiUIUjvDtnebPppLZDPqNUjxJrNFC70wBhT0A== +"@cerc-io/registry-sdk@^0.2.10": + version "0.2.10" + resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.10/registry-sdk-0.2.10.tgz#15773ea36a862585cdcb0991cbf075736f845f96" + integrity sha512-xxVD7ylrN951TFoSFbluz7mt4SwSCv7z+yry3jGd8v8TWnycoBMMrrYSTfETs6Ydxwziiz/uLrRwk59vFZxLEA== dependencies: "@cosmjs/amino" "^0.28.1" "@cosmjs/crypto" "^0.28.1" -- 2.45.2