From 9c992ebe71b6ba40d39f8fd9a3e496b1a650ca86 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Tue, 19 Mar 2024 04:42:42 +0000 Subject: [PATCH] Rename cns to registry in CLI (#57) Part of https://www.notion.so/Create-laconic-registry-SDK-d3a636d4aba44f7cbba3bd99b7146811 Co-authored-by: neeraj Reviewed-on: https://git.vdb.to/cerc-io/laconic-registry-cli/pulls/57 Co-authored-by: Nabarun Co-committed-by: Nabarun --- README.md | 96 +++++------ config.example.yml | 2 +- package.json | 2 +- .../account-cmds/get.ts | 10 +- .../{cns-cmds => registry-cmds}/account.ts | 0 .../auction-cmds/bid-cmds/commit.ts | 12 +- .../auction-cmds/bid-cmds/reveal.ts | 12 +- .../auction-cmds/bid.ts | 0 .../auction-cmds/get.ts | 10 +- .../{cns-cmds => registry-cmds}/auction.ts | 0 .../authority-cmds/bond-cmds/set.ts | 12 +- .../authority-cmds/bond.ts | 0 .../authority-cmds/reserve.ts | 12 +- .../authority-cmds/whois.ts | 10 +- .../{cns-cmds => registry-cmds}/authority.ts | 0 .../bond-cmds/associate.ts | 12 +- .../bond-cmds/cancel.ts | 12 +- .../bond-cmds/create.ts | 12 +- .../bond-cmds/dissociate.ts | 12 +- .../bond-cmds/get.ts | 10 +- .../bond-cmds/list.ts | 10 +- .../bond-cmds/records-cmds/dissociate.ts | 12 +- .../bond-cmds/records-cmds/reassociate.ts | 12 +- .../bond-cmds/records.ts | 0 .../bond-cmds/refill.ts | 12 +- .../bond-cmds/withdraw.ts | 12 +- src/cmds/{cns-cmds => registry-cmds}/bond.ts | 0 .../name-cmds/delete.ts | 12 +- .../name-cmds/lookup.ts | 10 +- .../name-cmds/resolve.ts | 10 +- .../name-cmds/set.ts | 12 +- src/cmds/{cns-cmds => registry-cmds}/name.ts | 0 .../record-cmds/get.ts | 10 +- .../record-cmds/list.ts | 10 +- .../record-cmds/publish.ts | 12 +- .../{cns-cmds => registry-cmds}/record.ts | 0 .../{cns-cmds => registry-cmds}/status.ts | 12 +- .../tokens-cmds/send.ts | 12 +- .../{cns-cmds => registry-cmds}/tokens.ts | 0 src/cmds/{cns.ts => registry.ts} | 6 +- test/cli.test.ts | 155 +++++++++--------- test/helpers.ts | 2 +- test/run-tests.sh | 2 +- 43 files changed, 279 insertions(+), 280 deletions(-) rename src/cmds/{cns-cmds => registry-cmds}/account-cmds/get.ts (70%) rename src/cmds/{cns-cmds => registry-cmds}/account.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/auction-cmds/bid-cmds/commit.ts (83%) rename src/cmds/{cns-cmds => registry-cmds}/auction-cmds/bid-cmds/reveal.ts (75%) rename src/cmds/{cns-cmds => registry-cmds}/auction-cmds/bid.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/auction-cmds/get.ts (70%) rename src/cmds/{cns-cmds => registry-cmds}/auction.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/authority-cmds/bond-cmds/set.ts (72%) rename src/cmds/{cns-cmds => registry-cmds}/authority-cmds/bond.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/authority-cmds/reserve.ts (72%) rename src/cmds/{cns-cmds => registry-cmds}/authority-cmds/whois.ts (70%) rename src/cmds/{cns-cmds => registry-cmds}/authority.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/associate.ts (73%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/cancel.ts (68%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/create.ts (75%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/dissociate.ts (69%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/get.ts (69%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/list.ts (69%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/records-cmds/dissociate.ts (71%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/records-cmds/reassociate.ts (75%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/records.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/refill.ts (74%) rename src/cmds/{cns-cmds => registry-cmds}/bond-cmds/withdraw.ts (75%) rename src/cmds/{cns-cmds => registry-cmds}/bond.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/name-cmds/delete.ts (70%) rename src/cmds/{cns-cmds => registry-cmds}/name-cmds/lookup.ts (72%) rename src/cmds/{cns-cmds => registry-cmds}/name-cmds/resolve.ts (70%) rename src/cmds/{cns-cmds => registry-cmds}/name-cmds/set.ts (71%) rename src/cmds/{cns-cmds => registry-cmds}/name.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/record-cmds/get.ts (69%) rename src/cmds/{cns-cmds => registry-cmds}/record-cmds/list.ts (81%) rename src/cmds/{cns-cmds => registry-cmds}/record-cmds/publish.ts (79%) rename src/cmds/{cns-cmds => registry-cmds}/record.ts (100%) rename src/cmds/{cns-cmds => registry-cmds}/status.ts (60%) rename src/cmds/{cns-cmds => registry-cmds}/tokens-cmds/send.ts (77%) rename src/cmds/{cns-cmds => registry-cmds}/tokens.ts (100%) rename src/cmds/{cns.ts => registry.ts} (81%) diff --git a/README.md b/README.md index d288b0d..aa847f9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# laconic-cns-client +# laconic-registry-client -CLI utility written in TS, used to interact with laconicd. Depends on [laconic-sdk](https://github.com/cerc-io/laconic-sdk). +CLI utility written in TS, used to interact with laconicd. Depends on [registry-sdk](https://git.vdb.to/cerc-io/registry-sdk). ## Setup @@ -18,7 +18,7 @@ Run the chain: TEST_AUCTION_ENABLED=true ./init.sh ``` -Registering records in CNS requires an account. To get account private key run: +Registering records in registry requires an account. To get account private key run: ```bash $ laconicd keys export mykey --unarmored-hex --unsafe @@ -38,7 +38,7 @@ The `gas` and `fees` can be set to some default values in the config, and can be Example: ```bash -$ laconic cns bond create --type aphoton --quantity 1000000000 --gas 200000 --fees 200000aphoton +$ laconic registry bond create --type photon --quantity 1000000000 --gas 200000 --fees 200000photon ``` ## Operations @@ -48,7 +48,7 @@ These commands require a `config.yml` file present in the current working direct Get node status: ```bash -$ laconic cns status +$ laconic registry status { "version": "0.3.0", "node": { @@ -82,7 +82,7 @@ $ laconic cns status Get account details: ```bash -$ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52 +$ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52 [ { "address": "ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52", @@ -91,7 +91,7 @@ $ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52 "sequence": "37", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "89998999999999991999799300" } ] @@ -102,7 +102,7 @@ $ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52 Send tokens: ```bash -$ laconic cns tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type aphoton --quantity 1000000000 +$ laconic registry tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type photon --quantity 1000000000 [ { "address": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", @@ -111,7 +111,7 @@ $ laconic cns tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu "sequence": "16", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "99998999999999997973999700" } ] @@ -123,7 +123,7 @@ $ laconic cns tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu "sequence": "0", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "1000000000" } ] @@ -147,7 +147,7 @@ record: Publish record (see below for commands to create/query bonds): ```bash -$ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 +$ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 { id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' } ``` @@ -155,7 +155,7 @@ $ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18 Get record: ```bash -$ laconic cns record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba +$ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba [ { "id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba", @@ -196,19 +196,19 @@ $ laconic cns record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln List records: ```bash -$ laconic cns record list +$ laconic registry record list ``` Reserve authority: ```bash -$ laconic cns authority reserve laconic +$ laconic registry authority reserve laconic ``` Check authority information: ```bash -$ laconic cns authority whois laconic +$ laconic registry authority whois laconic [ { "ownerAddress": "", @@ -225,15 +225,15 @@ $ laconic cns authority whois laconic "commitsEndTime": "2022-04-26T11:44:45.679728594", "revealsEndTime": "2022-04-26T11:45:45.679728594", "commitFee": { - "type": "aphoton", + "type": "photon", "quantity": "1000000" }, "revealFee": { - "type": "aphoton", + "type": "photon", "quantity": "1000000" }, "minimumBid": { - "type": "aphoton", + "type": "photon", "quantity": "5000000" }, "winnerAddress": "", @@ -254,7 +254,7 @@ $ laconic cns authority whois laconic Get authority auction info: ```bash -$ laconic cns auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 +$ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 [ { "id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48", @@ -264,15 +264,15 @@ $ laconic cns auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5 "commitsEndTime": "2022-04-26T11:44:45.679728594", "revealsEndTime": "2022-04-26T11:45:45.679728594", "commitFee": { - "type": "aphoton", + "type": "photon", "quantity": "1000000" }, "revealFee": { - "type": "aphoton", + "type": "photon", "quantity": "1000000" }, "minimumBid": { - "type": "aphoton", + "type": "photon", "quantity": "5000000" }, "winnerAddress": "", @@ -292,7 +292,7 @@ $ laconic cns auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5 Commit an auction bid: ```bash -$ laconic cns auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 aphoton +$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 photon Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json ``` @@ -300,37 +300,37 @@ Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.j Reveal an auction bid: ```bash -$ laconic cns auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json +$ laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json ``` Set authority bond (after winning auction): ```bash -$ laconic cns authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 +$ laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 ``` Create sub-authority (same owner as parent authority): ```bash -$ laconic cns authority reserve echo.laconic +$ laconic registry authority reserve echo.laconic ``` Create sub-authority (custom owner for sub-authority): ```bash -$ laconic cns authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu +$ laconic registry authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu ``` Set name: ```bash -$ laconic cns name set crn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba +$ laconic registry name set lrn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba ``` Lookup name information: ```bash -$ laconic cns name lookup crn://laconic/watcher/erc20 +$ laconic registry name lookup lrn://laconic/watcher/erc20 [ { "latest": { @@ -344,7 +344,7 @@ $ laconic cns name lookup crn://laconic/watcher/erc20 Resolve name: ```bash -$ laconic cns name resolve crn://laconic/watcher/erc20 +$ laconic registry name resolve lrn://laconic/watcher/erc20 [ { "id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba", @@ -385,9 +385,9 @@ $ laconic cns name resolve crn://laconic/watcher/erc20 Delete name: ```bash -$ laconic cns name delete crn://laconic/watcher/erc20 +$ laconic registry name delete lrn://laconic/watcher/erc20 -$ laconic cns name resolve crn://laconic/watcher/erc20 +$ laconic registry name resolve lrn://laconic/watcher/erc20 [ null ] @@ -396,20 +396,20 @@ $ laconic cns name resolve crn://laconic/watcher/erc20 Create bond: ```bash -$ laconic cns bond create --type aphoton --quantity 1000 +$ laconic registry bond create --type photon --quantity 1000 ``` List bonds: ```bash -$ laconic cns bond list +$ laconic registry bond list [ { "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", "owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "698000000" } ] @@ -419,7 +419,7 @@ $ laconic cns bond list "owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "1000" } ] @@ -430,14 +430,14 @@ $ laconic cns bond list Get bond: ```bash -$ laconic cns bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 +$ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 [ { "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", "owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "691000000" } ] @@ -448,14 +448,14 @@ $ laconic cns bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335 Query bonds by owner: ```bash -$ laconic cns bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8 +$ laconic registry bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8 [ { "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", "owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "684000000" } ] @@ -465,7 +465,7 @@ $ laconic cns bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8 "owner": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", "balance": [ { - "type": "aphoton", + "type": "photon", "quantity": "1000" } ] @@ -476,41 +476,41 @@ $ laconic cns bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8 Refill bond: ```bash -$ laconic cns bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 1000 +$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type photon --quantity 1000 ``` Withdraw funds from bond: ```bash -$ laconic cns bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 500 +$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type photon --quantity 500 ``` Cancel bond: ```bash -$ laconic cns bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 +$ laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 ``` Associate bond (with record): ```bash -$ laconic cns bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 +$ laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 ``` Disassociate bond (from record): ```bash -$ laconic cns bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba +$ laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba ``` Dissociate all records from bond: ```bash -$ laconic cns bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 +$ laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 ``` Reassociate records (switch bond): ```bash -$ laconic cns bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae +$ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae ``` diff --git a/config.example.yml b/config.example.yml index b96ee87..a424c65 100644 --- a/config.example.yml +++ b/config.example.yml @@ -1,5 +1,5 @@ services: - cns: + registry: restEndpoint: 'http://localhost:1317' gqlEndpoint: 'http://localhost:9473/api' userKey: diff --git a/package.json b/package.json index ab1c7d2..4ffc8e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cerc-io/laconic-registry-cli", - "version": "0.1.10", + "version": "0.2.0", "main": "index.js", "repository": "git@github.com:cerc-io/laconic-registry-cli.git", "author": "", diff --git a/src/cmds/cns-cmds/account-cmds/get.ts b/src/cmds/registry-cmds/account-cmds/get.ts similarity index 70% rename from src/cmds/cns-cmds/account-cmds/get.ts rename to src/cmds/registry-cmds/account-cmds/get.ts index d3b4c34..05e7c0f 100644 --- a/src/cmds/cns-cmds/account-cmds/get.ts +++ b/src/cmds/registry-cmds/account-cmds/get.ts @@ -11,11 +11,11 @@ export const desc = 'Get account.'; export const handler = async (argv: Arguments) => { let address = argv.address as string; - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); if (!address && privateKey) { address = new Account(Buffer.from(privateKey, 'hex')).address; diff --git a/src/cmds/cns-cmds/account.ts b/src/cmds/registry-cmds/account.ts similarity index 100% rename from src/cmds/cns-cmds/account.ts rename to src/cmds/registry-cmds/account.ts diff --git a/src/cmds/cns-cmds/auction-cmds/bid-cmds/commit.ts b/src/cmds/registry-cmds/auction-cmds/bid-cmds/commit.ts similarity index 83% rename from src/cmds/cns-cmds/auction-cmds/bid-cmds/commit.ts rename to src/cmds/registry-cmds/auction-cmds/bid-cmds/commit.ts index 1a6dd9d..460086e 100644 --- a/src/cmds/cns-cmds/auction-cmds/bid-cmds/commit.ts +++ b/src/cmds/registry-cmds/auction-cmds/bid-cmds/commit.ts @@ -21,12 +21,12 @@ export const handler = async (argv: Arguments) => { assert(quantity, 'Invalid token quantity.'); assert(denom, 'Invalid token type.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const account = new Account(Buffer.from(privateKey, 'hex')); await account.init(); @@ -41,7 +41,7 @@ export const handler = async (argv: Arguments) => { fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2)); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee); const revealFile = `{"reveal_file":"${revealFilePath}"}`; diff --git a/src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts b/src/cmds/registry-cmds/auction-cmds/bid-cmds/reveal.ts similarity index 75% rename from src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts rename to src/cmds/registry-cmds/auction-cmds/bid-cmds/reveal.ts index eb164d4..8c27687 100644 --- a/src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts +++ b/src/cmds/registry-cmds/auction-cmds/bid-cmds/reveal.ts @@ -16,15 +16,15 @@ export const handler = async (argv: Arguments) => { assert(auctionId, 'Invalid auction ID.'); assert(filePath, 'Invalid reveal file path.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const reveal = fs.readFileSync(path.resolve(filePath)); const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee); diff --git a/src/cmds/cns-cmds/auction-cmds/bid.ts b/src/cmds/registry-cmds/auction-cmds/bid.ts similarity index 100% rename from src/cmds/cns-cmds/auction-cmds/bid.ts rename to src/cmds/registry-cmds/auction-cmds/bid.ts diff --git a/src/cmds/cns-cmds/auction-cmds/get.ts b/src/cmds/registry-cmds/auction-cmds/get.ts similarity index 70% rename from src/cmds/cns-cmds/auction-cmds/get.ts rename to src/cmds/registry-cmds/auction-cmds/get.ts index 21fe9fa..01daac5 100644 --- a/src/cmds/cns-cmds/auction-cmds/get.ts +++ b/src/cmds/registry-cmds/auction-cmds/get.ts @@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => { const { id, config } = argv; assert(id, 'Invalid auction ID.'); - const { services: { cns: cnsConfig } } = getConfig(config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const result = await registry.getAuctionsByIds([id as string]); diff --git a/src/cmds/cns-cmds/auction.ts b/src/cmds/registry-cmds/auction.ts similarity index 100% rename from src/cmds/cns-cmds/auction.ts rename to src/cmds/registry-cmds/auction.ts diff --git a/src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts b/src/cmds/registry-cmds/authority-cmds/bond-cmds/set.ts similarity index 72% rename from src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts rename to src/cmds/registry-cmds/authority-cmds/bond-cmds/set.ts index 715b98c..77a8f4c 100644 --- a/src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts +++ b/src/cmds/registry-cmds/authority-cmds/bond-cmds/set.ts @@ -14,15 +14,15 @@ export const handler = async (argv: Arguments) => { assert(name, 'Invalid authority name.'); assert(bondId, 'Invalid Bond ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee); const success = '{"success": true}'; diff --git a/src/cmds/cns-cmds/authority-cmds/bond.ts b/src/cmds/registry-cmds/authority-cmds/bond.ts similarity index 100% rename from src/cmds/cns-cmds/authority-cmds/bond.ts rename to src/cmds/registry-cmds/authority-cmds/bond.ts diff --git a/src/cmds/cns-cmds/authority-cmds/reserve.ts b/src/cmds/registry-cmds/authority-cmds/reserve.ts similarity index 72% rename from src/cmds/cns-cmds/authority-cmds/reserve.ts rename to src/cmds/registry-cmds/authority-cmds/reserve.ts index 8fd33d9..e437f8e 100644 --- a/src/cmds/cns-cmds/authority-cmds/reserve.ts +++ b/src/cmds/registry-cmds/authority-cmds/reserve.ts @@ -20,15 +20,15 @@ export const handler = async (argv: Arguments) => { const owner = argv.owner as string; assert(name, 'Invalid authority name.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.reserveAuthority({ name, owner }, privateKey, fee); const success = '{"success": true}'; diff --git a/src/cmds/cns-cmds/authority-cmds/whois.ts b/src/cmds/registry-cmds/authority-cmds/whois.ts similarity index 70% rename from src/cmds/cns-cmds/authority-cmds/whois.ts rename to src/cmds/registry-cmds/authority-cmds/whois.ts index 06e4f01..fa34a89 100644 --- a/src/cmds/cns-cmds/authority-cmds/whois.ts +++ b/src/cmds/registry-cmds/authority-cmds/whois.ts @@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => { const name = argv.name as string; assert(name, 'Invalid authority name.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const result = await registry.lookupAuthorities([name], true); diff --git a/src/cmds/cns-cmds/authority.ts b/src/cmds/registry-cmds/authority.ts similarity index 100% rename from src/cmds/cns-cmds/authority.ts rename to src/cmds/registry-cmds/authority.ts diff --git a/src/cmds/cns-cmds/bond-cmds/associate.ts b/src/cmds/registry-cmds/bond-cmds/associate.ts similarity index 73% rename from src/cmds/cns-cmds/bond-cmds/associate.ts rename to src/cmds/registry-cmds/bond-cmds/associate.ts index fcbb1bc..01f394b 100644 --- a/src/cmds/cns-cmds/bond-cmds/associate.ts +++ b/src/cmds/registry-cmds/bond-cmds/associate.ts @@ -20,15 +20,15 @@ export const handler = async (argv: Arguments) => { assert(id, 'Invalid Record ID.'); assert(bondId, 'Invalid Bond ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond-cmds/cancel.ts b/src/cmds/registry-cmds/bond-cmds/cancel.ts similarity index 68% rename from src/cmds/cns-cmds/bond-cmds/cancel.ts rename to src/cmds/registry-cmds/bond-cmds/cancel.ts index 91be07c..ea904fc 100644 --- a/src/cmds/cns-cmds/bond-cmds/cancel.ts +++ b/src/cmds/registry-cmds/bond-cmds/cancel.ts @@ -12,15 +12,15 @@ export const handler = async (argv: Arguments) => { const id = argv.id as string; assert(id, 'Invalid Bond ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.cancelBond({ id }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond-cmds/create.ts b/src/cmds/registry-cmds/bond-cmds/create.ts similarity index 75% rename from src/cmds/cns-cmds/bond-cmds/create.ts rename to src/cmds/registry-cmds/bond-cmds/create.ts index 5f57c6f..2ad5dc8 100644 --- a/src/cmds/cns-cmds/bond-cmds/create.ts +++ b/src/cmds/registry-cmds/bond-cmds/create.ts @@ -25,15 +25,15 @@ export const handler = async (argv: Arguments) => { assert(denom, 'Invalid Type.'); assert(amount, 'Invalid Quantity.'); - const { services: { cns: cnsConfig } } = getConfig(config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const bondId = await registry.getNextBondId(privateKey); const result = await registry.createBond({ denom, amount }, privateKey, fee); const jsonString = `{"bondId":"${bondId}"}`; diff --git a/src/cmds/cns-cmds/bond-cmds/dissociate.ts b/src/cmds/registry-cmds/bond-cmds/dissociate.ts similarity index 69% rename from src/cmds/cns-cmds/bond-cmds/dissociate.ts rename to src/cmds/registry-cmds/bond-cmds/dissociate.ts index c2b4212..f1dce52 100644 --- a/src/cmds/cns-cmds/bond-cmds/dissociate.ts +++ b/src/cmds/registry-cmds/bond-cmds/dissociate.ts @@ -12,15 +12,15 @@ export const handler = async (argv: Arguments) => { const id = argv.id as string; assert(id, 'Invalid Record ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.dissociateBond({ recordId: id }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond-cmds/get.ts b/src/cmds/registry-cmds/bond-cmds/get.ts similarity index 69% rename from src/cmds/cns-cmds/bond-cmds/get.ts rename to src/cmds/registry-cmds/bond-cmds/get.ts index acea1b3..a987188 100644 --- a/src/cmds/cns-cmds/bond-cmds/get.ts +++ b/src/cmds/registry-cmds/bond-cmds/get.ts @@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => { const { id, config } = argv; console.assert(id, 'Bond Id is required.'); - const { services: { cns: cnsConfig } } = getConfig(config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); diff --git a/src/cmds/cns-cmds/bond-cmds/list.ts b/src/cmds/registry-cmds/bond-cmds/list.ts similarity index 69% rename from src/cmds/cns-cmds/bond-cmds/list.ts rename to src/cmds/registry-cmds/bond-cmds/list.ts index ec18c89..eb457f2 100644 --- a/src/cmds/cns-cmds/bond-cmds/list.ts +++ b/src/cmds/registry-cmds/bond-cmds/list.ts @@ -15,11 +15,11 @@ export const builder = { }; export const handler = async (argv: Arguments) => { - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); diff --git a/src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts b/src/cmds/registry-cmds/bond-cmds/records-cmds/dissociate.ts similarity index 71% rename from src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts rename to src/cmds/registry-cmds/bond-cmds/records-cmds/dissociate.ts index 4e1b229..ea7d90b 100644 --- a/src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts +++ b/src/cmds/registry-cmds/bond-cmds/records-cmds/dissociate.ts @@ -18,15 +18,15 @@ export const handler = async (argv: Arguments) => { const bondId = argv.bondId as string; assert(bondId, 'Invalid Bond ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.dissociateRecords({ bondId }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts b/src/cmds/registry-cmds/bond-cmds/records-cmds/reassociate.ts similarity index 75% rename from src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts rename to src/cmds/registry-cmds/bond-cmds/records-cmds/reassociate.ts index 6ee2206..2c3c555 100644 --- a/src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts +++ b/src/cmds/registry-cmds/bond-cmds/records-cmds/reassociate.ts @@ -23,15 +23,15 @@ export const handler = async (argv: Arguments) => { assert(oldBondId, 'Invalid Old Bond ID.'); assert(newBondId, 'Invalid New Bond ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond-cmds/records.ts b/src/cmds/registry-cmds/bond-cmds/records.ts similarity index 100% rename from src/cmds/cns-cmds/bond-cmds/records.ts rename to src/cmds/registry-cmds/bond-cmds/records.ts diff --git a/src/cmds/cns-cmds/bond-cmds/refill.ts b/src/cmds/registry-cmds/bond-cmds/refill.ts similarity index 74% rename from src/cmds/cns-cmds/bond-cmds/refill.ts rename to src/cmds/registry-cmds/bond-cmds/refill.ts index d55ac25..47ed860 100644 --- a/src/cmds/cns-cmds/bond-cmds/refill.ts +++ b/src/cmds/registry-cmds/bond-cmds/refill.ts @@ -26,15 +26,15 @@ export const handler = async (argv: Arguments) => { assert(denom, 'Invalid Type.'); assert(amount, 'Invalid Quantity.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.refillBond({ id, denom, amount }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond-cmds/withdraw.ts b/src/cmds/registry-cmds/bond-cmds/withdraw.ts similarity index 75% rename from src/cmds/cns-cmds/bond-cmds/withdraw.ts rename to src/cmds/registry-cmds/bond-cmds/withdraw.ts index 01fa526..8fb615f 100644 --- a/src/cmds/cns-cmds/bond-cmds/withdraw.ts +++ b/src/cmds/registry-cmds/bond-cmds/withdraw.ts @@ -26,15 +26,15 @@ export const handler = async (argv: Arguments) => { assert(denom, 'Invalid Type.'); assert(amount, 'Invalid Quantity.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee); const success = '{"success": true}'; txOutput(result, success, argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/bond.ts b/src/cmds/registry-cmds/bond.ts similarity index 100% rename from src/cmds/cns-cmds/bond.ts rename to src/cmds/registry-cmds/bond.ts diff --git a/src/cmds/cns-cmds/name-cmds/delete.ts b/src/cmds/registry-cmds/name-cmds/delete.ts similarity index 70% rename from src/cmds/cns-cmds/name-cmds/delete.ts rename to src/cmds/registry-cmds/name-cmds/delete.ts index da939d8..d56677e 100644 --- a/src/cmds/cns-cmds/name-cmds/delete.ts +++ b/src/cmds/registry-cmds/name-cmds/delete.ts @@ -12,15 +12,15 @@ export const handler = async (argv: Arguments) => { const name = argv.name as string; assert(name, 'Invalid Name.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.deleteName({ lrn: name }, privateKey, fee); const success = '{"success": true}'; diff --git a/src/cmds/cns-cmds/name-cmds/lookup.ts b/src/cmds/registry-cmds/name-cmds/lookup.ts similarity index 72% rename from src/cmds/cns-cmds/name-cmds/lookup.ts rename to src/cmds/registry-cmds/name-cmds/lookup.ts index bc8fe93..888c0b2 100644 --- a/src/cmds/cns-cmds/name-cmds/lookup.ts +++ b/src/cmds/registry-cmds/name-cmds/lookup.ts @@ -18,11 +18,11 @@ export const handler = async (argv: Arguments) => { const name = argv.name as string; assert(name, 'Invalid Name.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const result = await registry.lookupNames([name], argv.history as boolean); diff --git a/src/cmds/cns-cmds/name-cmds/resolve.ts b/src/cmds/registry-cmds/name-cmds/resolve.ts similarity index 70% rename from src/cmds/cns-cmds/name-cmds/resolve.ts rename to src/cmds/registry-cmds/name-cmds/resolve.ts index d0ddb65..3a5242a 100644 --- a/src/cmds/cns-cmds/name-cmds/resolve.ts +++ b/src/cmds/registry-cmds/name-cmds/resolve.ts @@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => { const name = argv.name as string; assert(name, 'Invalid Name.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); diff --git a/src/cmds/cns-cmds/name-cmds/set.ts b/src/cmds/registry-cmds/name-cmds/set.ts similarity index 71% rename from src/cmds/cns-cmds/name-cmds/set.ts rename to src/cmds/registry-cmds/name-cmds/set.ts index 8522df0..87d9e9d 100644 --- a/src/cmds/cns-cmds/name-cmds/set.ts +++ b/src/cmds/registry-cmds/name-cmds/set.ts @@ -14,15 +14,15 @@ export const handler = async (argv: Arguments) => { assert(name, 'Invalid Name.'); assert(id, 'Invalid Record ID.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.setName({ lrn: name, cid: id }, privateKey, fee); const success = '{"success": true}'; diff --git a/src/cmds/cns-cmds/name.ts b/src/cmds/registry-cmds/name.ts similarity index 100% rename from src/cmds/cns-cmds/name.ts rename to src/cmds/registry-cmds/name.ts diff --git a/src/cmds/cns-cmds/record-cmds/get.ts b/src/cmds/registry-cmds/record-cmds/get.ts similarity index 69% rename from src/cmds/cns-cmds/record-cmds/get.ts rename to src/cmds/registry-cmds/record-cmds/get.ts index 5496349..a842166 100644 --- a/src/cmds/cns-cmds/record-cmds/get.ts +++ b/src/cmds/registry-cmds/record-cmds/get.ts @@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => { const { id, config } = argv; assert(id, 'Invalid Record ID.'); - const { services: { cns: cnsConfig } } = getConfig(config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const result = await registry.getRecordsByIds([id as string]); diff --git a/src/cmds/cns-cmds/record-cmds/list.ts b/src/cmds/registry-cmds/record-cmds/list.ts similarity index 81% rename from src/cmds/cns-cmds/record-cmds/list.ts rename to src/cmds/registry-cmds/record-cmds/list.ts index 2d6d847..c3fe8a7 100644 --- a/src/cmds/cns-cmds/record-cmds/list.ts +++ b/src/cmds/registry-cmds/record-cmds/list.ts @@ -28,8 +28,8 @@ export const builder = { }; export const handler = async (argv: Arguments) => { - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); const { type, name, bondId, owner, all } = argv; const filters: any = {}; @@ -38,9 +38,9 @@ export const handler = async (argv: Arguments) => { filters[String(filterArgs[i]).replace(/^-+/, '')] = filterArgs[i + 1]; } - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); diff --git a/src/cmds/cns-cmds/record-cmds/publish.ts b/src/cmds/registry-cmds/record-cmds/publish.ts similarity index 79% rename from src/cmds/cns-cmds/record-cmds/publish.ts rename to src/cmds/registry-cmds/record-cmds/publish.ts index 9a0e612..6eba8af 100644 --- a/src/cmds/cns-cmds/record-cmds/publish.ts +++ b/src/cmds/registry-cmds/record-cmds/publish.ts @@ -18,14 +18,14 @@ export const builder = { export const handler = async (argv: Arguments) => { const { txKey, filename, config } = argv; - const { services: { cns: cnsConfig } } = getConfig(config as string); - const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig); + const { services: { registry: registryConfig } } = getConfig(config as string); + const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, registryConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(userKey, 'Invalid User Key.'); assert(bondId, 'Invalid Bond ID.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); let file = null; if (filename) { @@ -44,7 +44,7 @@ export const handler = async (argv: Arguments) => { } const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey || userKey, fee); txOutput(result, JSON.stringify(result, undefined, 2), argv.output, argv.verbose); diff --git a/src/cmds/cns-cmds/record.ts b/src/cmds/registry-cmds/record.ts similarity index 100% rename from src/cmds/cns-cmds/record.ts rename to src/cmds/registry-cmds/record.ts diff --git a/src/cmds/cns-cmds/status.ts b/src/cmds/registry-cmds/status.ts similarity index 60% rename from src/cmds/cns-cmds/status.ts rename to src/cmds/registry-cmds/status.ts index 9935258..8e6aa82 100644 --- a/src/cmds/cns-cmds/status.ts +++ b/src/cmds/registry-cmds/status.ts @@ -6,14 +6,14 @@ import { getConfig, getConnectionInfo } from '../../util'; export const command = 'status'; -export const desc = 'Get CNS status.'; +export const desc = 'Get registry status.'; export const handler = async (argv: Arguments) => { - const { services: { cns } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cns); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); - assert(chainId, 'Invalid CNS Chain ID.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); + assert(chainId, 'Invalid registry Chain ID.'); const registry = new Registry(gqlEndpoint, restEndpoint, chainId); diff --git a/src/cmds/cns-cmds/tokens-cmds/send.ts b/src/cmds/registry-cmds/tokens-cmds/send.ts similarity index 77% rename from src/cmds/cns-cmds/tokens-cmds/send.ts rename to src/cmds/registry-cmds/tokens-cmds/send.ts index b57cd76..35d79c1 100644 --- a/src/cmds/cns-cmds/tokens-cmds/send.ts +++ b/src/cmds/registry-cmds/tokens-cmds/send.ts @@ -26,19 +26,19 @@ export const handler = async (argv: Arguments) => { assert(denom, 'Invalid Type.'); assert(amount, 'Invalid Quantity.'); - const { services: { cns: cnsConfig } } = getConfig(argv.config as string); - const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); - assert(restEndpoint, 'Invalid CNS REST endpoint.'); - assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); + const { services: { registry: registryConfig } } = getConfig(argv.config as string); + const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig); + assert(restEndpoint, 'Invalid registry REST endpoint.'); + assert(gqlEndpoint, 'Invalid registry GQL endpoint.'); assert(privateKey, 'Invalid Transaction Key.'); - assert(chainId, 'Invalid CNS Chain ID.'); + assert(chainId, 'Invalid registry Chain ID.'); const account = new Account(Buffer.from(privateKey, 'hex')); await account.init(); const fromAddress = account.address; const registry = new Registry(gqlEndpoint, restEndpoint, chainId); - const fee = getGasAndFees(argv, cnsConfig); + const fee = getGasAndFees(argv, registryConfig); await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee); const result = await registry.getAccounts([fromAddress, destinationAddress]); queryOutput(result, argv.output); diff --git a/src/cmds/cns-cmds/tokens.ts b/src/cmds/registry-cmds/tokens.ts similarity index 100% rename from src/cmds/cns-cmds/tokens.ts rename to src/cmds/registry-cmds/tokens.ts diff --git a/src/cmds/cns.ts b/src/cmds/registry.ts similarity index 81% rename from src/cmds/cns.ts rename to src/cmds/registry.ts index c5674c9..5097edd 100644 --- a/src/cmds/cns.ts +++ b/src/cmds/registry.ts @@ -1,8 +1,8 @@ import yargs from 'yargs'; -export const command = 'cns'; +export const command = 'registry'; -export const desc = 'CNS tools'; +export const desc = 'Registry tools'; exports.builder = (yargs: yargs.Argv) => { return yargs @@ -17,7 +17,7 @@ exports.builder = (yargs: yargs.Argv) => { gas: { type: 'string' }, fees: { type: 'string' } }) - .commandDir('cns-cmds') + .commandDir('registry-cmds') .demandCommand() .help(); }; diff --git a/test/cli.test.ts b/test/cli.test.ts index 15f5131..c8d37e7 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -31,8 +31,8 @@ describe('Test laconic CLI commands', () => { expect(errorOutput).toContain('laconic '); }); - test('laconic cns', async () => { - const result = spawnSync('laconic', ['cns']); + test('laconic registry', async () => { + const result = spawnSync('laconic', ['registry']); expect(result.status).toBe(1); const output = result.stdout.toString().trim(); @@ -40,15 +40,15 @@ describe('Test laconic CLI commands', () => { // Expect error with usage string expect(output).toBe(''); - expect(errorOutput).toContain('laconic cns'); - expect(errorOutput).toContain('CNS tools'); + expect(errorOutput).toContain('laconic registry'); + expect(errorOutput).toContain('Registry tools'); expect(errorOutput).toContain('Commands:'); }); // TODO: Break up tests into separate files - // TODO: Add tests for CNS commands with all available flags + // TODO: Add tests for registry commands with all available flags - describe('laconic CNS commands', () => { + describe('laconic registry commands', () => { const testAccount = process.env.TEST_ACCOUNT; assert(testAccount, 'TEST_ACCOUNT not set in env'); const testAccount2 = 'laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd'; @@ -58,11 +58,11 @@ describe('Test laconic CLI commands', () => { const testRecordFilePath = 'test/data/watcher-record.yml'; let testAuctionId: string, testRecordId: string, testRecordBondId: string; - test('laconic cns status', async () => { - const result = spawnSync('laconic', ['cns', 'status']); + test('laconic registry status', async () => { + const result = spawnSync('laconic', ['registry', 'status']); const outputObj = checkResultAndRetrieveOutput(result); - // Expect output object to have CNS status props + // Expect output object to have registry status props expect(outputObj).toHaveProperty('version'); expect(outputObj).toHaveProperty('node'); expect(outputObj).toHaveProperty('node.network', CHAIN_ID); @@ -80,8 +80,9 @@ describe('Test laconic CLI commands', () => { let bondBalance = 1000000000; let bondId: string; - test('laconic cns bond create --type --quantity --gas --fees ', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]); + test('laconic registry bond create --type --quantity --gas --fees ', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]); + const outputObj = checkResultAndRetrieveOutput(result); // Expect output object to have resultant bond id @@ -90,8 +91,8 @@ describe('Test laconic CLI commands', () => { bondId = outputObj.bondId; }); - test('laconic cns bond list', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'list']); + test('laconic registry bond list', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'list']); const outputObj = checkResultAndRetrieveOutput(result); // Expected bond @@ -101,8 +102,8 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toEqual(expectedBond); }); - test('laconic cns bond list --owner ', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'list', '--owner', bondOwner]); + test('laconic registry bond list --owner ', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'list', '--owner', bondOwner]); const outputObj = checkResultAndRetrieveOutput(result); // Expected bond @@ -112,8 +113,8 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toEqual(expectedBond); }); - test('laconic cns bond get --id ', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]); + test('laconic registry bond get --id ', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected bond @@ -123,18 +124,18 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toEqual(expectedBond); }); - test('laconic cns bond refill --id --type --quantity ', async () => { + test('laconic registry bond refill --id --type --quantity ', async () => { const bondRefillAmount = 1000; bondBalance += bondRefillAmount; - const result = spawnSync('laconic', ['cns', 'bond', 'refill', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondRefillAmount.toString()]); + const result = spawnSync('laconic', ['registry', 'bond', 'refill', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondRefillAmount.toString()]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check updated bond - const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]); + const bondResult = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]); const bondOutputObj = checkResultAndRetrieveOutput(bondResult); // Expected bond @@ -144,18 +145,18 @@ describe('Test laconic CLI commands', () => { expect(bondOutputObj[0]).toEqual(expectedBond); }); - test('laconic cns bond withdraw --id --type --quantity ', async () => { + test('laconic registry bond withdraw --id --type --quantity ', async () => { const bondWithdrawAmount = 500; bondBalance -= bondWithdrawAmount; - const result = spawnSync('laconic', ['cns', 'bond', 'withdraw', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondWithdrawAmount.toString()]); + const result = spawnSync('laconic', ['registry', 'bond', 'withdraw', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondWithdrawAmount.toString()]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check updated bond - const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]); + const bondResult = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]); const bondOutputObj = checkResultAndRetrieveOutput(bondResult); // Expected bond @@ -166,15 +167,15 @@ describe('Test laconic CLI commands', () => { expect(bondOutputObj[0]).toEqual(expectedBond); }); - test('laconic cns bond cancel --id ', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'cancel', '--id', bondId]); + test('laconic registry bond cancel --id ', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'cancel', '--id', bondId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check updated bond - const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]); + const bondResult = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]); const bondOutputObj = checkResultAndRetrieveOutput(bondResult); // Expect empty object @@ -186,8 +187,8 @@ describe('Test laconic CLI commands', () => { describe('Account and tokens operations', () => { let balanceBeforeSend: number; - test('laconic cns account get --address ', async () => { - const result = spawnSync('laconic', ['cns', 'account', 'get', '--address', testAccount]); + test('laconic registry account get --address ', async () => { + const result = spawnSync('laconic', ['registry', 'account', 'get', '--address', testAccount]); const outputObj = checkResultAndRetrieveOutput(result); // Expected account @@ -203,11 +204,11 @@ describe('Test laconic CLI commands', () => { expect(balanceBeforeSend).toBeLessThan(initialAccountBalance); }); - test('laconic cns tokens send --address --type --quantity ', async () => { + test('laconic registry tokens send --address --type --quantity ', async () => { const sendAmount = 1000000000; const balanceAfterSend = balanceBeforeSend - sendAmount; - const result = spawnSync('laconic', ['cns', 'tokens', 'send', '--address', testAccount2, '--type', TOKEN_TYPE, '--quantity', sendAmount.toString()]); + const result = spawnSync('laconic', ['registry', 'tokens', 'send', '--address', testAccount2, '--type', TOKEN_TYPE, '--quantity', sendAmount.toString()]); const outputObj = checkResultAndRetrieveOutput(result); // Expected acconts @@ -225,11 +226,10 @@ describe('Test laconic CLI commands', () => { const gas = 250000; const bondBalance = 1000000000; - test('laconic cns record publish --filename --bond-id --gas ', async () => { + test('laconic registry record publish --filename --bond-id --gas ', async () => { // Create a new bond to be associated with the record ({ bondId: testRecordBondId } = createBond(bondBalance)); - - const result = spawnSync('laconic', ['cns', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString()]); + const result = spawnSync('laconic', ['registry', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString()]); const outputObj = checkResultAndRetrieveOutput(result); // Expect output object to resultant bond id @@ -238,8 +238,8 @@ describe('Test laconic CLI commands', () => { testRecordId = outputObj.id; }); - test('laconic cns record list', async () => { - const result = spawnSync('laconic', ['cns', 'record', 'list']); + test('laconic registry record list', async () => { + const result = spawnSync('laconic', ['registry', 'record', 'list']); const outputObj = checkResultAndRetrieveOutput(result); // Expected record @@ -253,8 +253,8 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0].owners.length).toEqual(1); }); - test('laconic cns record get --id ', async () => { - const result = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]); + test('laconic registry record get --id ', async () => { + const result = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected record @@ -267,14 +267,14 @@ describe('Test laconic CLI commands', () => { describe('Bond records operations', () => { let testRecordBondId2: string; - test('laconic cns bond dissociate --id ', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'dissociate', '--id', testRecordId]); + test('laconic registry bond dissociate --id ', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'dissociate', '--id', testRecordId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); - const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]); + const recordResult = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]); const recordOutputObj = checkResultAndRetrieveOutput(recordResult); // Expected record @@ -284,17 +284,17 @@ describe('Test laconic CLI commands', () => { expect(recordOutputObj[0]).toMatchObject(expectedRecord); }); - test('laconic cns bond associate --id --bond-id ', async () => { + test('laconic registry bond associate --id --bond-id ', async () => { // Create a new bond to be associated with the record ({ bondId: testRecordBondId2 } = createBond(bondBalance)); - const result = spawnSync('laconic', ['cns', 'bond', 'associate', '--id', testRecordId, '--bond-id', testRecordBondId2]); + const result = spawnSync('laconic', ['registry', 'bond', 'associate', '--id', testRecordId, '--bond-id', testRecordBondId2]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); - const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]); + const recordResult = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]); const recordOutputObj = checkResultAndRetrieveOutput(recordResult); // Expected record @@ -304,14 +304,14 @@ describe('Test laconic CLI commands', () => { expect(recordOutputObj[0]).toMatchObject(expectedRecord); }); - test('laconic cns bond records reassociate --old-bond-id --new-bond-id ', async () => { - const result = spawnSync('laconic', ['cns', 'bond', 'records', 'reassociate', '--old-bond-id', testRecordBondId2, '--new-bond-id', testRecordBondId]); + test('laconic registry bond records reassociate --old-bond-id --new-bond-id ', async () => { + const result = spawnSync('laconic', ['registry', 'bond', 'records', 'reassociate', '--old-bond-id', testRecordBondId2, '--new-bond-id', testRecordBondId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); - const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]); + const recordResult = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]); const recordOutputObj = checkResultAndRetrieveOutput(recordResult); // Expected record @@ -324,18 +324,17 @@ describe('Test laconic CLI commands', () => { }); describe('Name authority operations (pre auction)', () => { - test('laconic cns authority reserve ', async () => { - const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testAuthorityName]); + test('laconic registry authority reserve ', async () => { + const result = spawnSync('laconic', ['registry', 'authority', 'reserve', testAuthorityName]); const outputObj = checkResultAndRetrieveOutput(result); // Expect result expect(outputObj).toEqual({ success: true }); }); - test('laconic cns authority whois ', async () => { - const result = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]); + test('laconic registry authority whois ', async () => { + const result = spawnSync('laconic', ['registry', 'authority', 'whois', testAuthorityName]); const outputObj = checkResultAndRetrieveOutput(result); - // Expected authority (still in auction) const expectedAuthority = getAuthorityObj({ owner: '', status: 'auction', auction: getAuctionObj({ owner: testAccount }) }); @@ -352,8 +351,8 @@ describe('Test laconic CLI commands', () => { const bidAmount = 25000000; let bidRevealFilePath: string; - test('laconic cns auction get ', async () => { - const result = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]); + test('laconic registry auction get ', async () => { + const result = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected auction (still in commit stage) @@ -363,8 +362,8 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toMatchObject(expectedAuction); }); - test('laconic cns auction bid commit ', async () => { - const result = spawnSync('laconic', ['cns', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]); + 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 @@ -373,11 +372,11 @@ describe('Test laconic CLI commands', () => { bidRevealFilePath = outputObj.reveal_file; }); - test('laconic cns auction bid reveal ', async () => { + test('laconic registry auction bid reveal ', async () => { // Wait for auction commits duration (60s) await delay(AUCTION_COMMIT_DURATION * 1000); - const auctionResult = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]); + const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]); const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult); const expectedAuction = getAuctionObj({ owner: testAccount, status: 'reveal' }); @@ -387,7 +386,7 @@ describe('Test laconic CLI commands', () => { expect(auctionOutputObj[0].bids[0]).toMatchObject(expectedBid); // Reveal bid - const result = spawnSync('laconic', ['cns', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]); + const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output @@ -407,11 +406,11 @@ describe('Test laconic CLI commands', () => { const testSubAuthorityName = 'echo.laconic'; const testSubAuthorityName2 = 'kube.laconic'; - test('laconic cns authority whois ', async () => { + test('laconic registry authority whois ', async () => { // Wait for auction reveals duration (60s) await delay(AUCTION_REVEAL_DURATION * 1000); - const result = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]); + const result = spawnSync('laconic', ['registry', 'authority', 'whois', testAuthorityName]); const outputObj = checkResultAndRetrieveOutput(result); // Expected authority (active) @@ -421,19 +420,19 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toMatchObject(expectedAuthority); }, (AUCTION_REVEAL_DURATION + 5) * 1000); - test('laconic cns authority bond set laconic ', async () => { + test('laconic registry authority bond set laconic ', async () => { // Create a new bond to be set on the authority const bondBalance = 1000000000; const { bondId } = createBond(bondBalance); - const result = spawnSync('laconic', ['cns', 'authority', 'bond', 'set', testAuthorityName, bondId]); + const result = spawnSync('laconic', ['registry', 'authority', 'bond', 'set', testAuthorityName, bondId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check updated authority - const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]); + const authorityResult = spawnSync('laconic', ['registry', 'authority', 'whois', testAuthorityName]); const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult); // Expected authority (active with bond) @@ -443,15 +442,15 @@ describe('Test laconic CLI commands', () => { expect(authorityOutputObj[0]).toMatchObject(expectedAuthority); }); - test('laconic cns authority reserve (same owner)', async () => { - const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testSubAuthorityName]); + test('laconic registry authority reserve (same owner)', async () => { + const result = spawnSync('laconic', ['registry', 'authority', 'reserve', testSubAuthorityName]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check updated authority - const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testSubAuthorityName]); + const authorityResult = spawnSync('laconic', ['registry', 'authority', 'whois', testSubAuthorityName]); const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult); // Expected authority (active with bond) @@ -461,15 +460,15 @@ describe('Test laconic CLI commands', () => { expect(authorityOutputObj[0]).toMatchObject(expectedAuthority); }); - test('laconic cns authority reserve --owner (different owner)', async () => { - const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testSubAuthorityName2, '--owner', testAccount2]); + test('laconic registry authority reserve --owner (different owner)', async () => { + const result = spawnSync('laconic', ['registry', 'authority', 'reserve', testSubAuthorityName2, '--owner', testAccount2]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check updated authority - const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testSubAuthorityName2]); + const authorityResult = spawnSync('laconic', ['registry', 'authority', 'whois', testSubAuthorityName2]); const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult); // Expected authority (active with bond) @@ -483,16 +482,16 @@ describe('Test laconic CLI commands', () => { describe('Name operations', () => { const testName = 'lrn://laconic/watcher/erc20'; - test('laconic cns name set ', async () => { - const result = spawnSync('laconic', ['cns', 'name', 'set', testName, testRecordId]); + test('laconic registry name set ', async () => { + const result = spawnSync('laconic', ['registry', 'name', 'set', testName, testRecordId]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); }); - test('laconic cns name lookup ', async () => { - const result = spawnSync('laconic', ['cns', 'name', 'lookup', testName]); + test('laconic registry name lookup ', async () => { + const result = spawnSync('laconic', ['registry', 'name', 'lookup', testName]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output @@ -500,8 +499,8 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toMatchObject({ latest: { id: testRecordId } }); }); - test('laconic cns name resolve ', async () => { - const result = spawnSync('laconic', ['cns', 'name', 'resolve', testName]); + test('laconic registry name resolve ', async () => { + const result = spawnSync('laconic', ['registry', 'name', 'resolve', testName]); const outputObj = checkResultAndRetrieveOutput(result); // Expected resolved record @@ -511,15 +510,15 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toMatchObject(expectedRecord); }); - test('laconic cns name delete ', async () => { - const result = spawnSync('laconic', ['cns', 'name', 'delete', testName]); + test('laconic registry name delete ', async () => { + const result = spawnSync('laconic', ['registry', 'name', 'delete', testName]); const outputObj = checkResultAndRetrieveOutput(result); // Expected output expect(outputObj).toEqual({ success: true }); // Check that name doesn't resolve - const resolveResult = spawnSync('laconic', ['cns', 'name', 'resolve', testName]); + const resolveResult = spawnSync('laconic', ['registry', 'name', 'resolve', testName]); const resolveOutputObj = checkResultAndRetrieveOutput(resolveResult); expect(resolveOutputObj.length).toEqual(0); }); diff --git a/test/helpers.ts b/test/helpers.ts index 28549c8..f511091 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -25,7 +25,7 @@ export function checkResultAndRetrieveOutput (result: SpawnSyncReturns): } export function createBond (quantity: number): { bondId: string } { - const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', quantity.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]); + const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', quantity.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]); const output = result.stdout.toString().trim(); return JSON.parse(output); diff --git a/test/run-tests.sh b/test/run-tests.sh index 5ab7906..8653fdb 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -15,7 +15,7 @@ laconic2d_gql_endpoint=http://127.0.0.1:9473/api config_file="config.yml" config=$(cat <