Compare commits

...
9 Commits
Author SHA1 Message Date
telackey e1da44bae7 Bump version (#47)
Reviewed-on: cerc-io/laconic-registry-cli#47
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-12-13 21:13:39 +00:00
telackey 51fd81a082 Decode JSON strings automatically. 2023-12-13 15:10:09 -06:00
telackey 3cdd930b82 0.1.5 (#46)
Reviewed-on: cerc-io/laconic-registry-cli#46
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-12-08 04:55:27 +00:00
telackey 80d1b01713 SDK 0.1.11 (#45)
Reviewed-on: cerc-io/laconic-registry-cli#45
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-12-08 04:53:08 +00:00
telackey f3c0ae8c34 Use SDK 0.1.10 (#44)
Reviewed-on: cerc-io/laconic-registry-cli#44
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-12-07 22:15:04 +00:00
telackey f5625d0c87 Take the path as-is, not relative to the current dir. (#43)
Reviewed-on: cerc-io/laconic-registry-cli#43
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-12-05 03:53:15 +00:00
telackey fb381c07f3 Fix cns name resolve (#42)
The `cns name resolve` does not return the result.  Obviously it should.

Reviewed-on: cerc-io/laconic-registry-cli#42
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-30 05:01:25 +00:00
telackey 145da8c453 v0.1.2 (#41)
Reviewed-on: cerc-io/laconic-registry-cli#41
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-29 17:39:18 +00:00
telackey 6e0829d91f Filter by arbitrary attributes (#40)
```
laconic cns record list \
  --type GeneralRecord \
  --value anything-goes-here \
  --category filter-by-this \
  --bond-id d0094c75e267abb709d631abd7bfaa8d610413f5766ddfc07db735822905d641 \
  --owner AB0A17A1EBF47DDCF6AB267CA8E07B7EA836E1AF \
  --all
```

Reviewed-on: cerc-io/laconic-registry-cli#40
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-28 23:22:57 +00:00
7 changed files with 41 additions and 15 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-registry-cli",
"version": "0.1.1",
"version": "0.1.6",
"main": "index.js",
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
"author": "",
@@ -15,7 +15,7 @@
},
"dependencies": {
"fs-extra": "^10.1.0",
"@cerc-io/laconic-sdk": "0.1.9",
"@cerc-io/laconic-sdk": "^0.1.12",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",
"lodash-clean": "^2.2.3",
+4 -4
View File
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo,txOutput } from '../../../util';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
export const command = 'resolve [name]';
@@ -20,8 +20,8 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.resolveNames([name]);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
let result = await registry.resolveNames([name]);
result = result.filter((v: any) => v);
queryOutput(result, argv.output);
}
+22 -3
View File
@@ -12,6 +12,9 @@ export const builder = {
'bond-id': {
type: 'string'
},
owner: {
type: 'string'
},
type: {
type: 'string'
},
@@ -27,7 +30,13 @@ 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 { 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(gqlEndpoint, 'Invalid CNS GQL endpoint.');
@@ -35,6 +44,16 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.queryRecords({ bondId, type, name }, all as boolean);
queryOutput(result,argv.output)
let result = await registry.queryRecords({...filters, type, name}, all as boolean);
// 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)
}
+1 -1
View File
@@ -30,7 +30,7 @@ export const handler = async (argv: Arguments) => {
let file = null;
if (filename) {
file = path.join(process.cwd(), filename as string);
file = filename as string;
} else {
file = 0; // stdin
}
+1
View File
@@ -6,5 +6,6 @@ export const desc = 'Record operations.';
exports.builder = (yargs: yargs.Argv) => {
return yargs.commandDir('record-cmds')
.parserConfiguration({'unknown-options-as-args': true})
.demandCommand()
}
+7 -1
View File
@@ -11,6 +11,12 @@ export const queryOutput = (result: any, output: unknown) => {
if (output=="json"){
console.log(JSON.parse(JSON.stringify(result)));
} else {
console.log(JSON.stringify(result,undefined,2));
console.log(JSON.stringify(result, (key, value) => {
try {
return JSON.parse(value)
} catch (e) {
return value;
}
}, 2));
}
}
+4 -4
View File
@@ -2,10 +2,10 @@
# yarn lockfile v1
"@cerc-io/laconic-sdk@0.1.9":
version "0.1.9"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.9/laconic-sdk-0.1.9.tgz#cf11d20a22c75fd61126640824d27d687f925151"
integrity sha512-LlOBZ39cYalvu9YZBpf5KUkgJJDlsuUhAaBReedwVV5O7zwy+3zRaM4HkX+3saG3a4qR8VfYWEeS5GqF9b6Ixw==
"@cerc-io/laconic-sdk@^0.1.12":
version "0.1.12"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.12/laconic-sdk-0.1.12.tgz#1507526b95ebdb6827fc569f83a2da3cca17a41d"
integrity sha512-oLkX062ohOmk9RnAoeFYyMAOF/jnBjqYEpBPzJy1A5ukrWTT01Rx94f4UKinQlvrRXgcUqDgjhCGz9zpcUtpoQ==
dependencies:
"@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1"