Compare commits

...

12 Commits

Author SHA1 Message Date
6814707752 Update SDK version. (#48)
Reviewed-on: cerc-io/laconic-registry-cli#48
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-12-21 21:38:11 +00:00
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
51fd81a082 Decode JSON strings automatically. 2023-12-13 15:10:09 -06:00
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
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
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
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
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
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
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
1fa32a3cc1 Add .gitea workflows (#39)
Reviewed-on: cerc-io/laconic-registry-cli#39
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-22 04:19:39 +00:00
129019105d Convert sub-objects (other than arrays) in YAML to JSON strings automatically. (#38)
This allows us to support attributes in YAML like this:

```
  meta:
    foo: bar
    bar:
      baz: boz
```

Which will automatically become:

```
"meta": "{\"foo\":\"bar\",\"bar\":{\"baz\":\"boz\"}}"
```

> Note: cosmos-sdk's protobuf code does not support maps (https://github.com/cosmos/cosmos-sdk/issues/15254), or else we would just use a map.

Reviewed-on: cerc-io/laconic-registry-cli#38
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2023-11-20 22:01:39 +00:00
9 changed files with 130 additions and 15 deletions

View File

@ -0,0 +1,36 @@
name: Publish npm package to gitea
on:
release:
types: [published]
jobs:
npm_publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download yarn
run: |
curl -fsSL -o /usr/local/bin/yarn https://github.com/yarnpkg/yarn/releases/download/v1.22.21/yarn-1.22.21.js
chmod +x /usr/local/bin/yarn
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- name: Run yarn build
run: |
yarn build
- name: Configure git.vdb.to npm registry
run: |
npm config set registry https://git.vdb.to/api/packages/cerc-io/npm/
- name: Authenticate to git.vdb.to registry
run: |
npm config set -- '//git.vdb.to/api/packages/cerc-io/npm/:_authToken' "${{ secrets.CICD_PUBLISH_TOKEN }}"
- name: npm publish
run: |
npm publish

45
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,45 @@
name: Tests
on:
pull_request:
branches:
- '*'
push:
branches:
- main
- release/**
env:
DOCKER_HOST: unix:///var/run/dind.sock
jobs:
sdk_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout laconicd
uses: actions/checkout@v3
with:
path: "./laconicd/"
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
- name: Environment
run: ls -tlh && env
- name: Start dockerd
run: |
dockerd -H $DOCKER_HOST --userland-proxy=false &
sleep 5
- name: build registry-cli container
run: docker build -t cerc/laconic-registry-cli:local-test --build-arg CERC_NPM_URL=https://git.vdb.to/api/packages/cerc-io/npm/ --build-arg CERC_NPM_AUTH_TOKEN="${{ secrets.CICD_PUBLISH_TOKEN }}" .
- name: build containers scripts
working-directory: laconicd/tests/sdk_tests
run: ./build-laconicd-container.sh
- name: start laconicd container
working-directory: laconicd/tests/sdk_tests
run: docker compose up laconicd -d
- name: Run registry-cli demo commands in registry-cli container
run : ls -tla
- name: stop containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-registry-cli",
"version": "0.1.0",
"version": "0.1.7",
"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.6",
"@cerc-io/laconic-sdk": "^0.1.13",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",
"lodash-clean": "^2.2.3",

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);
}

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);
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)
}

View File

@ -30,12 +30,20 @@ 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
}
const { record } = await yaml.load(fs.readFileSync(file, 'utf-8')) as any;
// Convert sub-objects (other than arrays) to a JSON automatically.
for (const [k, v] of Object.entries(record)) {
if (v && typeof v === "object" && !Array.isArray(v)) {
record[k] = JSON.stringify(v);
}
}
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee);

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()
}

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));
}
}

View File

@ -2,10 +2,10 @@
# yarn lockfile v1
"@cerc-io/laconic-sdk@0.1.6":
version "0.1.6"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.6/laconic-sdk-0.1.6.tgz#2c4e678800467e7c92c3198fe332401d2ab395ce"
integrity sha512-o7G/QpfmNTFkmKQEuCf8mdZc8AePRMQ9T5kLqW30aHi9vzwA5rI7I6dXmPLzGYwdMWUdeeQcePOQhwD2qccryw==
"@cerc-io/laconic-sdk@^0.1.13":
version "0.1.13"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.13/laconic-sdk-0.1.13.tgz#a51c601f50f3c96656556b7c3f28bc544aac8aef"
integrity sha512-P5dCEZjpQTGupSDz1mBfGl3SK/95KKHP0Yww6zlz9xva8l66P9t6juYcF//Os2vA4PzDujCTETPr15kJHSFcTQ==
dependencies:
"@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1"