Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb381c07f3 | ||
|
|
145da8c453 | ||
|
|
6e0829d91f |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cerc-io/laconic-registry-cli",
|
"name": "@cerc-io/laconic-registry-cli",
|
||||||
"version": "0.1.1",
|
"version": "0.1.3",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { Registry } from '@cerc-io/laconic-sdk';
|
import { Registry } from '@cerc-io/laconic-sdk';
|
||||||
|
|
||||||
import { getConfig, getConnectionInfo,txOutput } from '../../../util';
|
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||||
|
|
||||||
export const command = 'resolve [name]';
|
export const command = 'resolve [name]';
|
||||||
|
|
||||||
@@ -20,8 +20,8 @@ export const handler = async (argv: Arguments) => {
|
|||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
const result = await registry.resolveNames([name]);
|
let result = await registry.resolveNames([name]);
|
||||||
const success = `{"success":${result.code==0}}`
|
result = result.filter((v: any) => v);
|
||||||
txOutput(result,success,argv.output,argv.verbose)
|
|
||||||
|
|
||||||
|
queryOutput(result, argv.output);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ export const builder = {
|
|||||||
'bond-id': {
|
'bond-id': {
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
|
owner: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
type: {
|
type: {
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
@@ -27,7 +30,13 @@ export const builder = {
|
|||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||||
const { type, name, bondId, all } = argv;
|
const { type, name, bondId, owner, all } = argv;
|
||||||
|
const filters: any = {};
|
||||||
|
|
||||||
|
const filterArgs = argv._.slice(3);
|
||||||
|
for (let i = 0; i < filterArgs.length-1; i+=2) {
|
||||||
|
filters[String(filterArgs[i]).replace(/^-+/,"")] = filterArgs[i+1];
|
||||||
|
}
|
||||||
|
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||||
@@ -35,6 +44,16 @@ export const handler = async (argv: Arguments) => {
|
|||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
const result = await registry.queryRecords({ bondId, type, name }, all as boolean);
|
let result = await registry.queryRecords({...filters, type, name}, all as boolean);
|
||||||
queryOutput(result,argv.output)
|
|
||||||
|
// Apply ex post filters.
|
||||||
|
if (bondId) {
|
||||||
|
result = result.filter((v: any) => v.bondId === bondId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owner) {
|
||||||
|
result = result.filter((v: any) => v.owners?.find((e: string) => e === owner));
|
||||||
|
}
|
||||||
|
|
||||||
|
queryOutput(result, argv.output)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ export const desc = 'Record operations.';
|
|||||||
|
|
||||||
exports.builder = (yargs: yargs.Argv) => {
|
exports.builder = (yargs: yargs.Argv) => {
|
||||||
return yargs.commandDir('record-cmds')
|
return yargs.commandDir('record-cmds')
|
||||||
|
.parserConfiguration({'unknown-options-as-args': true})
|
||||||
.demandCommand()
|
.demandCommand()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user