Add a command to list authorities (#74)
Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8) Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Reviewed-on: #74 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
parent
70e63c74f1
commit
30654bb0ef
12
README.md
12
README.md
@ -351,6 +351,18 @@ Create sub-authority (custom owner for sub-authority):
|
||||
$ laconic registry authority reserve kube.laconic --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
|
||||
```
|
||||
|
||||
Get all the authorities:
|
||||
|
||||
```bash
|
||||
$ laconic registry authority list
|
||||
```
|
||||
|
||||
Get all the authorities by owner:
|
||||
|
||||
```bash
|
||||
$ laconic registry authority list --owner laconic1zayjut6pd4xy9dguut56v55hktzmeq6r777hmd
|
||||
```
|
||||
|
||||
Set name:
|
||||
|
||||
```bash
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-registry-cli",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"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.5",
|
||||
"@cerc-io/registry-sdk": "^0.2.6",
|
||||
"fs-extra": "^10.1.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.21",
|
||||
|
29
src/cmds/registry-cmds/authority-cmds/list.ts
Normal file
29
src/cmds/registry-cmds/authority-cmds/list.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'list';
|
||||
|
||||
export const desc = 'List authorities (optionally by owner).';
|
||||
|
||||
export const builder = {
|
||||
owner: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid registry Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
const result = await registry.getAuthorities(argv.owner as string);
|
||||
|
||||
queryOutput(result, argv.output);
|
||||
};
|
@ -478,6 +478,47 @@ describe('Test laconic CLI commands', () => {
|
||||
expect(authorityOutputObj.length).toEqual(1);
|
||||
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||
});
|
||||
|
||||
test('laconic registry authority list', async () => {
|
||||
const result = spawnSync('laconic', ['registry', 'authority', 'list']);
|
||||
const authoritiesOutputObj = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected authorities
|
||||
const expectedAuthorities = [
|
||||
{ name: 'echo.laconic', entry: { ownerAddress: testAccount, status: 'active' } },
|
||||
{ name: 'kube.laconic', entry: { ownerAddress: testAccount2, status: 'active' } },
|
||||
{ name: 'laconic', entry: { ownerAddress: testAccount, status: 'active' } }
|
||||
];
|
||||
|
||||
// Expected output
|
||||
expect(authoritiesOutputObj.length).toEqual(3);
|
||||
expect(authoritiesOutputObj).toMatchObject(expectedAuthorities);
|
||||
});
|
||||
|
||||
test('laconic registry authority list --owner <owner_address>', async () => {
|
||||
let result = spawnSync('laconic', ['registry', 'authority', 'list', '--owner', testAccount]);
|
||||
const authoritiesByOwner1 = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
const expectedAuthoritiesByOwner1 = [
|
||||
{ name: 'echo.laconic', entry: { ownerAddress: testAccount, status: 'active' } },
|
||||
{ name: 'laconic', entry: { ownerAddress: testAccount, status: 'active' } }
|
||||
];
|
||||
|
||||
expect(authoritiesByOwner1.length).toEqual(2);
|
||||
expect(authoritiesByOwner1).toMatchObject(expectedAuthoritiesByOwner1);
|
||||
|
||||
result = spawnSync('laconic', ['registry', 'authority', 'list', '--owner', testAccount2]);
|
||||
const authoritiesByOwner2 = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
const expectedAuthoritiesByOwner2 = [
|
||||
{ name: 'kube.laconic', entry: { ownerAddress: testAccount2, status: 'active' } }
|
||||
];
|
||||
|
||||
expect(authoritiesByOwner2.length).toEqual(1);
|
||||
expect(authoritiesByOwner2).toMatchObject(expectedAuthoritiesByOwner2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Name operations', () => {
|
||||
|
@ -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.5":
|
||||
version "0.2.5"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.5/registry-sdk-0.2.5.tgz#9ca19fecb2923520dd6a19946c309ecb2ec780a2"
|
||||
integrity sha512-/KXAYf9gStaX/rRBMCEeDCexEIpTOFHeHzMK9B3xfCT+SyYZE9WC9GpX299LzBYJKKPsb0/JvnDfip9S1igJtA==
|
||||
"@cerc-io/registry-sdk@^0.2.6":
|
||||
version "0.2.6"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.6/registry-sdk-0.2.6.tgz#af8a5844bdb742a01d322a9d93ace90d35aad37e"
|
||||
integrity sha512-Z2rneeoPLTJk9aBTqMrR9WPKfPQZhNWShI4IYOb7kzoIorp3eD8mEals0I5bVjzStjapw/5RKf8lVnDCX9I4iA==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.28.1"
|
||||
"@cosmjs/crypto" "^0.28.1"
|
||||
|
Loading…
Reference in New Issue
Block a user