Compare commits

..

4 Commits

Author SHA1 Message Date
zramsay
94141b41a7
. 2023-03-07 15:57:19 -05:00
zramsay
6834a1d51e
fix 2023-03-07 15:52:43 -05:00
zramsay
e9c06733b9
trigger on test branches 2023-03-07 15:43:58 -05:00
zramsay
d6c420d722
test script 2023-03-07 15:34:28 -05:00
38 changed files with 93 additions and 254 deletions

View File

@ -1,36 +0,0 @@
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

View File

@ -1,45 +0,0 @@
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

@ -5,6 +5,7 @@ on:
branches:
- main
- release/**
- zach/**
jobs:
sdk_tests:
@ -18,10 +19,15 @@ jobs:
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
- name: Run registry-cli demo commands in registry-cli container
working-directory: ./scripts
run : ./cli-commands-test.sh
- name: Environment
run: ls -tlh && env
- 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.GITEA_PUBLISH_TOKEN }}" .
run: docker build -t cerc/laconic-registry-cli:local-test --build-arg CERC_NPM_URL=https://git.vdb.to/api/packages/cerc-io/npm/ .
- name: build containers scripts
working-directory: laconicd/tests/sdk_tests
run: ./build-laconicd-container.sh
@ -30,7 +36,7 @@ jobs:
run: docker compose up laconicd -d
- name: Run registry-cli demo commands in registry-cli container
run : ls -tla
run : ./cli-commands-test.sh
- name: stop containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down

View File

@ -10,14 +10,6 @@ CLI utility written in TS, used to interact with laconicd. Depends on [laconic-s
## Account Setup
Run the chain:
- In laconicd repo run:
```bash
TEST_AUCTION_ENABLED=true ./init.sh
```
Registering records in CNS requires an account. To get account private key run:
```bash
@ -136,18 +128,26 @@ Create record (generic):
```yaml
# watcher.yml
record:
type: WebsiteRegistrationRecord
url: 'https://cerc.io'
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.23
name: ERC20 Watcher
type: watcher
version: 1.0.0
protocol:
/: QmbQiRpLX5djUsfc2yDswHvTkHTGd9uQEy6oUJfxkBYwRq
package:
linux:
x64:
/: QmVRmLrQeLZS8Xee7YVzYYAQANWmXqsNgNkaPMxM8MtPLA
arm:
/: QmX3DDmeFunX5aVmaTNnViwQUe15Wa4UbZYcC3AwFwoWcg
macos:
x64:
/: QmXogCVZZ867qZfS3CYjYdDEziPb4ARiDfgwqbd7urVKkr
```
Publish record (see below for commands to create/query bonds):
```bash
$ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000
$ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
```

5
lerna.json Normal file
View File

@ -0,0 +1,5 @@
{
"version": "2.9.0",
"useWorkspaces": true,
"npmClient": "yarn"
}

View File

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

4
scripts/cli-commands-test.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
set -euo pipefail
echo "Hello from CLETUS"

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Account, Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get';
@ -24,5 +24,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getAccounts([address]);
queryOutput(result,argv.output);
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -5,7 +5,7 @@ import { Account, createBid, Registry } from '@cerc-io/laconic-sdk';
import { ensureDir } from 'fs-extra';
import fs from 'fs';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
const OUT_DIR = 'out';
@ -43,7 +43,7 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee);
const revealFile = `{"reveal_file":"${revealFilePath}"}`
console.log(JSON.stringify(result, undefined, 2));
txOutput(result,revealFile,argv.output,argv.verbose)
console.log(`\nReveal file: ${revealFilePath}`);
}

View File

@ -4,7 +4,7 @@ import path from 'path';
import { Registry } from '@cerc-io/laconic-sdk';
import fs from 'fs';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
export const command = 'reveal [auction-id] [file-path]';
@ -28,7 +28,5 @@ export const handler = async (argv: Arguments) => {
const reveal = fs.readFileSync(path.resolve(filePath));
const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get [id]';
@ -21,5 +21,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getAuctionsByIds([id as string]);
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
export const command = 'set [name] [bond-id]';
@ -24,7 +24,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'reserve [name]';
@ -31,6 +31,5 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'whois [name]';
@ -21,5 +21,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.lookupAuthorities([name], true);
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'associate';
@ -30,7 +30,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'cancel';
@ -22,7 +22,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.cancelBond({ id }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'create';
@ -34,10 +34,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const bondId = await registry.getNextBondId(privateKey);
const result = await registry.createBond({ denom, amount }, privateKey, fee);
const jsonString=`{"bondId":"${bondId}"}`
txOutput(result,jsonString,argv.output,argv.verbose)
console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data);
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'dissociate';
@ -22,7 +22,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get';
@ -21,6 +21,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getBondsByIds([id as string]);
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'list';
@ -25,6 +25,5 @@ export const handler = async (argv: Arguments) => {
const { owner } = argv;
const result = await registry.queryBonds({ owner });
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
export const command = 'dissociate';
@ -28,7 +28,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
export const command = 'reassociate';
@ -33,7 +33,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,8 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
import { isNil } from 'lodash';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'refill';
@ -37,7 +36,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'withdraw';
@ -36,7 +36,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'delete [name]';
@ -23,7 +23,5 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.deleteName({ crn: name }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'lookup [name]';
@ -27,5 +27,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.lookupNames([name], argv.history as boolean);
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'resolve [name]';
@ -20,8 +20,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
let result = await registry.resolveNames([name]);
result = result.filter((v: any) => v);
queryOutput(result, argv.output);
const result = await registry.resolveNames([name]);
console.log(JSON.stringify(result, undefined, 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, getGasAndFees,txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'set [name] [id]';
@ -25,7 +25,5 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee);
const success = `{"success":${result.code==0}}`
txOutput(result,success,argv.output,argv.verbose)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get';
@ -21,5 +21,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getRecordsByIds([id as string]);
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'list';
@ -12,9 +12,6 @@ export const builder = {
'bond-id': {
type: 'string'
},
owner: {
type: 'string'
},
type: {
type: 'string'
},
@ -30,13 +27,7 @@ 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, 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];
}
const { type, name, bondId, all } = argv;
assert(restEndpoint, 'Invalid CNS REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
@ -44,16 +35,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
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)
const result = await registry.queryRecords({ bondId, type, name }, all as boolean);
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -5,7 +5,7 @@ import yaml from 'js-yaml';
import fs from 'fs';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../../util';
import { getConfig, getGasAndFees, getConnectionInfo } from '../../../util';
export const command = 'publish';
@ -30,23 +30,15 @@ export const handler = async (argv: Arguments) => {
let file = null;
if (filename) {
file = filename as string;
file = path.join(process.cwd(), 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);
txOutput(result,JSON.stringify(result.data,undefined,2),argv.output,argv.verbose)
console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data);
}

View File

@ -6,6 +6,5 @@ export const desc = 'Record operations.';
exports.builder = (yargs: yargs.Argv) => {
return yargs.commandDir('record-cmds')
.parserConfiguration({'unknown-options-as-args': true})
.demandCommand()
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Account, Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, queryOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'send';
@ -40,5 +40,5 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig);
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
const result = await registry.getAccounts([fromAddress, destinationAddress]);
queryOutput(result,argv.output)
console.log(JSON.stringify(result, undefined, 2));
}

View File

@ -15,11 +15,6 @@ yargs(hideBin(process.argv))
default: 'config.yml',
describe: 'Config file path.',
type: 'string'
},
output: {
alias: 'o',
describe: 'Gives output in json format when specified.',
type: 'string'
}
})
.commandDir('cmds')

View File

@ -1,4 +1,3 @@
export * from './fees';
export * from './config';
export * from './common';
export * from './output';

View File

@ -1,22 +0,0 @@
export const txOutput = (result:any,msg:string,output:unknown,verbose:unknown) => {
if (output=="json"){
console.log(verbose ? JSON.parse(JSON.stringify(result)) : JSON.parse(msg));
} else {
console.log(verbose ? JSON.stringify(result,undefined,2) : msg);
}
};
export const queryOutput = (result: any, output: unknown) => {
if (output=="json"){
console.log(JSON.parse(JSON.stringify(result)));
} else {
console.log(JSON.stringify(result, (key, value) => {
try {
return JSON.parse(value)
} catch (e) {
return value;
}
}, 2));
}
}

View File

@ -1,7 +0,0 @@
record:
type: WebsiteRegistrationRecord
url: 'https://cerc.io'
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.35

View File

@ -2,10 +2,10 @@
# yarn lockfile v1
"@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==
"@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==
dependencies:
"@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1"