Compare commits

..

9 Commits

Author SHA1 Message Date
zramsay
b3735ab7bf
revert readme to lrn 2023-01-11 13:01:24 -05:00
zramsay
1d47318073
cns -> lns to avoid variable collision 2023-01-11 13:00:00 -05:00
zramsay
e0bb3ae3af
rename command and directory 2023-01-11 12:55:47 -05:00
zramsay
1788c1e4c3
still need lrn (upstream?) 2023-01-11 12:52:02 -05:00
zramsay
8eb86556b2
last 2023-01-11 12:50:42 -05:00
zramsay
d6833ff9fa
rename src/cmds/cns* -> src/cmds/registry 2023-01-11 12:50:41 -05:00
zramsay
8795f43979
sed s/cns/registry/g 2023-01-11 12:50:41 -05:00
zramsay
312bdb6b39
sed s/crn/lrn/g 2023-01-11 12:50:38 -05:00
zramsay
8d703e580b
src: sed s/CNS/Registry/g (error msgs) 2023-01-11 12:21:31 -05:00
53 changed files with 296 additions and 631 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

@ -1,40 +0,0 @@
name: Manual npm publish
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
jobs:
npm_publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://npm.pkg.github.com'
- run: yarn
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT_PACKAGES }}
- name: Run yarn build
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT_PACKAGES }}
run: |
yarn build
- name: Configure git.vdb.to npm registry
run: |
npm config set @cerc-io: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.GITEA_PUBLISH_TOKEN }}"
- name: npm publish
run: npm publish

View File

@ -1,37 +0,0 @@
name: Tests
on:
pull_request:
push:
branches:
- main
- release/**
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: 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 }}" .
- 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

3
.gitignore vendored
View File

@ -4,6 +4,3 @@ dist/*
out out
config.yml config.yml
*~
.idea

View File

@ -1,56 +0,0 @@
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=16-bullseye
FROM node:${VARIANT}
ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global
# This container pulls npm packages from a local registry configured via these env vars
ARG CERC_NPM_URL
ARG CERC_NPM_AUTH_TOKEN
# Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
RUN \
# Configure global npm install location, use group to adapt to UID/GID changes
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
&& usermod -a -G npm ${USERNAME} \
&& umask 0002 \
&& mkdir -p ${NPM_GLOBAL} \
&& touch /usr/local/etc/npmrc \
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
&& chmod g+s ${NPM_GLOBAL} \
&& npm config -g set prefix ${NPM_GLOBAL} \
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
# Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
&& npm cache clean --force > /dev/null 2>&1
# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends jq
# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
# Configure the local npm registry
RUN npm config set @lirewine:registry ${CERC_NPM_URL} \
&& npm config set @cerc-io:registry ${CERC_NPM_URL} \
&& npm config set -- ${CERC_NPM_URL}:_authToken ${CERC_NPM_AUTH_TOKEN}
# TODO: the image at this point could be made a base image for several different CLI images
# that install different Node-based CLI commands
# DEBUG, remove
RUN yarn info @cerc-io/laconic-registry-cli
# Globally install the cli package
RUN yarn global add @cerc-io/laconic-registry-cli
ENTRYPOINT ["laconic"]

View File

@ -1,4 +1,4 @@
# laconic-cns-client # laconic-registry-client
CLI utility written in TS, used to interact with laconicd. Depends on [laconic-sdk](https://github.com/cerc-io/laconic-sdk). CLI utility written in TS, used to interact with laconicd. Depends on [laconic-sdk](https://github.com/cerc-io/laconic-sdk).
@ -10,15 +10,7 @@ CLI utility written in TS, used to interact with laconicd. Depends on [laconic-s
## Account Setup ## Account Setup
Run the chain: Registering records in the Laconic Registry requires an account. To get account private key run:
- 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 ```bash
$ laconicd keys export mykey --unarmored-hex --unsafe $ laconicd keys export mykey --unarmored-hex --unsafe
@ -38,7 +30,7 @@ The `gas` and `fees` can be set to some default values in the config, and can be
Example: Example:
```bash ```bash
$ laconic cns bond create --type aphoton --quantity 1000000000 --gas 200000 --fees 200000aphoton $ laconic registry bond create --type aphoton --quantity 1000000000 --gas 200000 --fees 200000aphoton
``` ```
## Operations ## Operations
@ -48,7 +40,7 @@ These commands require a `config.yml` file present in the current working direct
Get node status: Get node status:
```bash ```bash
$ laconic cns status $ laconic registry status
{ {
"version": "0.3.0", "version": "0.3.0",
"node": { "node": {
@ -82,7 +74,7 @@ $ laconic cns status
Get account details: Get account details:
```bash ```bash
$ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52 $ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
[ [
{ {
"address": "ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52", "address": "ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52",
@ -102,7 +94,7 @@ $ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
Send tokens: Send tokens:
```bash ```bash
$ laconic cns tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type aphoton --quantity 1000000000 $ laconic registry tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type aphoton --quantity 1000000000
[ [
{ {
"address": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8", "address": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
@ -136,18 +128,26 @@ Create record (generic):
```yaml ```yaml
# watcher.yml # watcher.yml
record: record:
type: WebsiteRegistrationRecord name: ERC20 Watcher
url: 'https://cerc.io' type: watcher
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D version: 1.0.0
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9 protocol:
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR /: QmbQiRpLX5djUsfc2yDswHvTkHTGd9uQEy6oUJfxkBYwRq
version: 1.0.23 package:
linux:
x64:
/: QmVRmLrQeLZS8Xee7YVzYYAQANWmXqsNgNkaPMxM8MtPLA
arm:
/: QmX3DDmeFunX5aVmaTNnViwQUe15Wa4UbZYcC3AwFwoWcg
macos:
x64:
/: QmXogCVZZ867qZfS3CYjYdDEziPb4ARiDfgwqbd7urVKkr
``` ```
Publish record (see below for commands to create/query bonds): Publish record (see below for commands to create/query bonds):
```bash ```bash
$ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 $ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' } { id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
``` ```
@ -155,7 +155,7 @@ $ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18
Get record: Get record:
```bash ```bash
$ laconic cns record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba $ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
[ [
{ {
"id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba", "id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba",
@ -196,19 +196,19 @@ $ laconic cns record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln
List records: List records:
```bash ```bash
$ laconic cns record list $ laconic registry record list
``` ```
Reserve authority: Reserve authority:
```bash ```bash
$ laconic cns authority reserve laconic $ laconic registry authority reserve laconic
``` ```
Check authority information: Check authority information:
```bash ```bash
$ laconic cns authority whois laconic $ laconic registry authority whois laconic
[ [
{ {
"ownerAddress": "", "ownerAddress": "",
@ -254,7 +254,7 @@ $ laconic cns authority whois laconic
Get authority auction info: Get authority auction info:
```bash ```bash
$ laconic cns auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48
[ [
{ {
"id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48", "id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48",
@ -292,7 +292,7 @@ $ laconic cns auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5
Commit an auction bid: Commit an auction bid:
```bash ```bash
$ laconic cns auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 aphoton $ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 aphoton
Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
``` ```
@ -300,37 +300,37 @@ Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.j
Reveal an auction bid: Reveal an auction bid:
```bash ```bash
$ laconic cns auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json $ laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
``` ```
Set authority bond (after winning auction): Set authority bond (after winning auction):
```bash ```bash
$ laconic cns authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 $ laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
``` ```
Create sub-authority (same owner as parent authority): Create sub-authority (same owner as parent authority):
```bash ```bash
$ laconic cns authority reserve echo.laconic $ laconic registry authority reserve echo.laconic
``` ```
Create sub-authority (custom owner for sub-authority): Create sub-authority (custom owner for sub-authority):
```bash ```bash
$ laconic cns authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu $ laconic registry authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu
``` ```
Set name: Set name:
```bash ```bash
$ laconic cns name set crn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba $ laconic registry name set crn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
``` ```
Lookup name information: Lookup name information:
```bash ```bash
$ laconic cns name lookup crn://laconic/watcher/erc20 $ laconic registry name lookup crn://laconic/watcher/erc20
[ [
{ {
"latest": { "latest": {
@ -344,7 +344,7 @@ $ laconic cns name lookup crn://laconic/watcher/erc20
Resolve name: Resolve name:
```bash ```bash
$ laconic cns name resolve crn://laconic/watcher/erc20 $ laconic registry name resolve crn://laconic/watcher/erc20
[ [
{ {
"id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba", "id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba",
@ -385,9 +385,9 @@ $ laconic cns name resolve crn://laconic/watcher/erc20
Delete name: Delete name:
```bash ```bash
$ laconic cns name delete crn://laconic/watcher/erc20 $ laconic registry name delete crn://laconic/watcher/erc20
$ laconic cns name resolve crn://laconic/watcher/erc20 $ laconic registry name resolve crn://laconic/watcher/erc20
[ [
null null
] ]
@ -396,13 +396,13 @@ $ laconic cns name resolve crn://laconic/watcher/erc20
Create bond: Create bond:
```bash ```bash
$ laconic cns bond create --type aphoton --quantity 1000 $ laconic registry bond create --type aphoton --quantity 1000
``` ```
List bonds: List bonds:
```bash ```bash
$ laconic cns bond list $ laconic registry bond list
[ [
{ {
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
@ -430,7 +430,7 @@ $ laconic cns bond list
Get bond: Get bond:
```bash ```bash
$ laconic cns bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 $ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
[ [
{ {
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
@ -448,7 +448,7 @@ $ laconic cns bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335
Query bonds by owner: Query bonds by owner:
```bash ```bash
$ laconic cns bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8 $ laconic registry bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
[ [
{ {
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785", "id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
@ -476,41 +476,41 @@ $ laconic cns bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
Refill bond: Refill bond:
```bash ```bash
$ laconic cns bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 1000 $ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 1000
``` ```
Withdraw funds from bond: Withdraw funds from bond:
```bash ```bash
$ laconic cns bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 500 $ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 500
``` ```
Cancel bond: Cancel bond:
```bash ```bash
$ laconic cns bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 $ laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
``` ```
Associate bond (with record): Associate bond (with record):
```bash ```bash
$ laconic cns bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 $ laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
``` ```
Disassociate bond (from record): Disassociate bond (from record):
```bash ```bash
$ laconic cns bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba $ laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
``` ```
Dissociate all records from bond: Dissociate all records from bond:
```bash ```bash
$ laconic cns bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 $ laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
``` ```
Reassociate records (switch bond): Reassociate records (switch bond):
```bash ```bash
$ laconic cns bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae $ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae
``` ```

View File

@ -1,5 +1,5 @@
services: services:
cns: registry:
restEndpoint: 'http://localhost:1317' restEndpoint: 'http://localhost:1317'
gqlEndpoint: 'http://localhost:9473/api' gqlEndpoint: 'http://localhost:9473/api'
userKey: userKey:

View File

@ -1,29 +0,0 @@
services:
laconicd:
restart: unless-stopped
image: cerc-io/laconicd:local-test
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
volumes:
- laconicd/init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
healthcheck:
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
interval: 1s
timeout: 5s
retries: 30
ports:
- "6060"
- "26657"
- "26656"
- "9473"
- "8545"
- "8546"
- "9090"
- "9091"
- "1317"
cli-test-runner:
image: cerc/laconic-registry-cli:local-test
depends_on:
laconicd:
condition: service_healthy
command: tail -F /dev/null

View File

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

View File

@ -1,59 +0,0 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
export const command = 'list';
export const desc = 'List records.';
export const builder = {
'bond-id': {
type: 'string'
},
owner: {
type: 'string'
},
type: {
type: 'string'
},
name: {
type: 'string'
},
all: {
type: 'boolean',
default: false
}
}
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];
}
assert(restEndpoint, 'Invalid CNS REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.');
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)
}

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Account, Registry } from '@cerc-io/laconic-sdk'; import { Account, Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get'; export const command = 'get';
@ -11,11 +11,11 @@ export const desc = 'Get account.';
export const handler = async (argv: Arguments) => { export const handler = async (argv: Arguments) => {
let address = argv.address as string; let address = argv.address as string;
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
if (!address && privateKey) { if (!address && privateKey) {
address = new Account(Buffer.from(privateKey, 'hex')).getCosmosAddress(); address = new Account(Buffer.from(privateKey, 'hex')).getCosmosAddress();
@ -24,5 +24,5 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getAccounts([address]); 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 { ensureDir } from 'fs-extra';
import fs from 'fs'; import fs from 'fs';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
const OUT_DIR = 'out'; const OUT_DIR = 'out';
@ -21,12 +21,12 @@ export const handler = async (argv: Arguments) => {
assert(quantity, 'Invalid token quantity.'); assert(quantity, 'Invalid token quantity.');
assert(denom, 'Invalid token type.'); assert(denom, 'Invalid token type.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const account = new Account(Buffer.from(privateKey, 'hex')); const account = new Account(Buffer.from(privateKey, 'hex'));
const bidderAddress = account.formattedCosmosAddress; const bidderAddress = account.formattedCosmosAddress;
@ -40,10 +40,10 @@ export const handler = async (argv: Arguments) => {
fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2)); fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2));
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee); 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 { Registry } from '@cerc-io/laconic-sdk';
import fs from 'fs'; 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]'; export const command = 'reveal [auction-id] [file-path]';
@ -16,19 +16,17 @@ export const handler = async (argv: Arguments) => {
assert(auctionId, 'Invalid auction ID.'); assert(auctionId, 'Invalid auction ID.');
assert(filePath, 'Invalid reveal file path.'); assert(filePath, 'Invalid reveal file path.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const reveal = fs.readFileSync(path.resolve(filePath)); const reveal = fs.readFileSync(path.resolve(filePath));
const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee); const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, queryOutput } from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get [id]'; export const command = 'get [id]';
@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
const { id, config } = argv; const { id, config } = argv;
assert(id, 'Invalid auction ID.'); assert(id, 'Invalid auction ID.');
const { services: { cns: cnsConfig } } = getConfig(config as string) const { services: { lns: lnsConfig } } = getConfig(config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getAuctionsByIds([id as string]); 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 assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; 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]'; export const command = 'set [name] [bond-id]';
@ -14,17 +14,15 @@ export const handler = async (argv: Arguments) => {
assert(name, 'Invalid authority name.'); assert(name, 'Invalid authority name.');
assert(bondId, 'Invalid Bond ID.'); assert(bondId, 'Invalid Bond ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee); const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees, txOutput } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'reserve [name]'; export const command = 'reserve [name]';
@ -20,17 +20,16 @@ export const handler = async (argv: Arguments) => {
const owner = argv.owner as string; const owner = argv.owner as string;
assert(name, 'Invalid authority name.'); assert(name, 'Invalid authority name.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee); const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, queryOutput } from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'whois [name]'; export const command = 'whois [name]';
@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
const name = argv.name as string; const name = argv.name as string;
assert(name, 'Invalid authority name.'); assert(name, 'Invalid authority name.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.lookupAuthorities([name], true); 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 assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'associate'; export const command = 'associate';
@ -20,17 +20,15 @@ export const handler = async (argv: Arguments) => {
assert(id, 'Invalid Record ID.'); assert(id, 'Invalid Record ID.');
assert(bondId, 'Invalid Bond ID.'); assert(bondId, 'Invalid Bond ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee); const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees,txOutput } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'cancel'; export const command = 'cancel';
@ -12,17 +12,15 @@ export const handler = async (argv: Arguments) => {
const id = argv.id as string const id = argv.id as string
assert(id, 'Invalid Bond ID.'); assert(id, 'Invalid Bond ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.cancelBond({ id }, privateKey, fee); const result = await registry.cancelBond({ id }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees ,txOutput} from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'create'; export const command = 'create';
@ -25,19 +25,15 @@ export const handler = async (argv: Arguments) => {
assert(denom, 'Invalid Type.'); assert(denom, 'Invalid Type.');
assert(amount, 'Invalid Quantity.'); assert(amount, 'Invalid Quantity.');
const { services: { cns: cnsConfig } } = getConfig(config as string) const { services: { lns: lnsConfig } } = getConfig(config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const bondId = await registry.getNextBondId(privateKey);
const result = await registry.createBond({ denom, amount }, privateKey, fee); const result = await registry.createBond({ denom, amount }, privateKey, fee);
const jsonString=`{"bondId":"${bondId}"}` console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data);
txOutput(result,jsonString,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees ,txOutput} from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'dissociate'; export const command = 'dissociate';
@ -12,17 +12,15 @@ export const handler = async (argv: Arguments) => {
const id = argv.id as string; const id = argv.id as string;
assert(id, 'Invalid Record ID.'); assert(id, 'Invalid Record ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee); const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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 ,queryOutput} from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get'; export const command = 'get';
@ -12,15 +12,14 @@ export const handler = async (argv: Arguments) => {
const { id, config } = argv; const { id, config } = argv;
console.assert(id, 'Bond Id is required.'); console.assert(id, 'Bond Id is required.');
const { services: { cns: cnsConfig } } = getConfig(config as string) const { services: { lns: lnsConfig } } = getConfig(config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getBondsByIds([id as string]); const result = await registry.getBondsByIds([id as string]);
console.log(JSON.stringify(result, undefined, 2));
queryOutput(result,argv.output)
} }

View File

@ -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 ,queryOutput} from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'list'; export const command = 'list';
@ -15,16 +15,15 @@ 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: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const { owner } = argv; const { owner } = argv;
const result = await registry.queryBonds({ owner }); const result = await registry.queryBonds({ owner });
console.log(JSON.stringify(result, undefined, 2));
queryOutput(result,argv.output)
} }

View File

@ -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, getGasAndFees,txOutput } from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
export const command = 'dissociate'; export const command = 'dissociate';
@ -18,17 +18,15 @@ export const handler = async (argv: Arguments) => {
const bondId = argv.bondId as string; const bondId = argv.bondId as string;
assert(bondId, 'Invalid Bond ID.'); assert(bondId, 'Invalid Bond ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.dissociateRecords({ bondId }, privateKey, fee); const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees ,txOutput} from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
export const command = 'reassociate'; export const command = 'reassociate';
@ -23,17 +23,15 @@ export const handler = async (argv: Arguments) => {
assert(oldBondId, 'Invalid Old Bond ID.'); assert(oldBondId, 'Invalid Old Bond ID.');
assert(newBondId, 'Invalid New Bond ID.'); assert(newBondId, 'Invalid New Bond ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee); const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -2,8 +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, getGasAndFees ,txOutput} from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
import { isNil } from 'lodash';
export const command = 'refill'; export const command = 'refill';
@ -27,17 +26,15 @@ export const handler = async (argv: Arguments) => {
assert(denom, 'Invalid Type.'); assert(denom, 'Invalid Type.');
assert(amount, 'Invalid Quantity.'); assert(amount, 'Invalid Quantity.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee); const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees,txOutput } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'withdraw'; export const command = 'withdraw';
@ -26,17 +26,15 @@ export const handler = async (argv: Arguments) => {
assert(denom, 'Invalid Type.'); assert(denom, 'Invalid Type.');
assert(amount, 'Invalid Quantity.'); assert(amount, 'Invalid Quantity.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee); const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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, getGasAndFees ,txOutput} from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'delete [name]'; export const command = 'delete [name]';
@ -12,18 +12,16 @@ export const handler = async (argv: Arguments) => {
const name = argv.name as string; const name = argv.name as string;
assert(name, 'Invalid Name.'); assert(name, 'Invalid Name.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.deleteName({ crn: name }, privateKey, fee); const result = await registry.deleteName({ crn: name }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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 ,queryOutput} from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'lookup [name]'; export const command = 'lookup [name]';
@ -18,14 +18,14 @@ export const handler = async (argv: Arguments) => {
const name = argv.name as string; const name = argv.name as string;
assert(name, 'Invalid Name.'); assert(name, 'Invalid Name.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.lookupNames([name], argv.history as boolean); 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 assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'resolve [name]'; export const command = 'resolve [name]';
@ -12,16 +12,14 @@ export const handler = async (argv: Arguments) => {
const name = argv.name as string; const name = argv.name as string;
assert(name, 'Invalid Name.'); assert(name, 'Invalid Name.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
let result = await registry.resolveNames([name]); const result = await registry.resolveNames([name]);
result = result.filter((v: any) => v); console.log(JSON.stringify(result, undefined, 4));
queryOutput(result, argv.output);
} }

View File

@ -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, getGasAndFees,txOutput } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
export const command = 'set [name] [id]'; export const command = 'set [name] [id]';
@ -14,18 +14,16 @@ export const handler = async (argv: Arguments) => {
assert(name, 'Invalid Name.'); assert(name, 'Invalid Name.');
assert(id, 'Invalid Record ID.'); assert(id, 'Invalid Record ID.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee); const result = await registry.setName({ crn: name, cid: id }, privateKey, fee);
const success = `{"success":${result.code==0}}` console.log(JSON.stringify(result, undefined, 2));
txOutput(result,success,argv.output,argv.verbose)
} }

View File

@ -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 ,queryOutput} from '../../../util'; import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'get'; export const command = 'get';
@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
const { id, config } = argv; const { id, config } = argv;
assert(id, 'Invalid Record ID.'); assert(id, 'Invalid Record ID.');
const { services: { cns: cnsConfig } } = getConfig(config as string) const { services: { lns: lnsConfig } } = getConfig(config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const result = await registry.getRecordsByIds([id as string]); const result = await registry.getRecordsByIds([id as string]);
queryOutput(result,argv.output) console.log(JSON.stringify(result, undefined, 2));
} }

View File

@ -0,0 +1,40 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo } from '../../../util';
export const command = 'list';
export const desc = 'List records.';
export const builder = {
'bond-id': {
type: 'string'
},
type: {
type: 'string'
},
name: {
type: 'string'
},
all: {
type: 'boolean',
default: false
}
}
export const handler = async (argv: Arguments) => {
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
const { type, name, bondId, all } = argv;
assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
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 fs from 'fs';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../../util'; import { getConfig, getGasAndFees, getConnectionInfo } from '../../../util';
export const command = 'publish'; export const command = 'publish';
@ -19,34 +19,26 @@ export const builder = {
export const handler = async (argv: Arguments) => { export const handler = async (argv: Arguments) => {
const { txKey, filename, verbose, config } = argv; const { txKey, filename, verbose, config } = argv;
const { services: { cns: cnsConfig } } = getConfig(config as string) const { services: { lns: lnsConfig } } = getConfig(config as string)
const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(userKey, 'Invalid User Key.'); assert(userKey, 'Invalid User Key.');
assert(bondId, 'Invalid Bond ID.'); assert(bondId, 'Invalid Bond ID.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
let file = null; let file = null;
if (filename) { if (filename) {
file = filename as string; file = path.join(process.cwd(), filename as string);
} else { } else {
file = 0; // stdin file = 0; // stdin
} }
const { record } = await yaml.load(fs.readFileSync(file, 'utf-8')) as any; 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 registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee); 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) => { exports.builder = (yargs: yargs.Argv) => {
return yargs.commandDir('record-cmds') return yargs.commandDir('record-cmds')
.parserConfiguration({'unknown-options-as-args': true})
.demandCommand() .demandCommand()
} }

View File

@ -6,14 +6,14 @@ import { getConfig, getConnectionInfo } from '../../util';
export const command = 'status'; export const command = 'status';
export const desc = 'Get CNS status.'; export const desc = 'Get Registry status.';
export const handler = async (argv: Arguments) => { export const handler = async (argv: Arguments) => {
const { services: { cns } } = getConfig(argv.config as string) const { services: { lns } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cns); const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lns);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Account, Registry } from '@cerc-io/laconic-sdk'; 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'; export const command = 'send';
@ -26,19 +26,19 @@ export const handler = async (argv: Arguments) => {
assert(denom, 'Invalid Type.'); assert(denom, 'Invalid Type.');
assert(amount, 'Invalid Quantity.'); assert(amount, 'Invalid Quantity.');
const { services: { cns: cnsConfig } } = getConfig(argv.config as string) const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
assert(restEndpoint, 'Invalid CNS REST endpoint.'); assert(restEndpoint, 'Invalid Registry REST endpoint.');
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.'); assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.'); assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid CNS Chain ID.'); assert(chainId, 'Invalid Registry Chain ID.');
const account = new Account(Buffer.from(privateKey, 'hex')); const account = new Account(Buffer.from(privateKey, 'hex'));
const fromAddress = account.formattedCosmosAddress; const fromAddress = account.formattedCosmosAddress;
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, lnsConfig);
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee); await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
const result = await registry.getAccounts([fromAddress, destinationAddress]); const result = await registry.getAccounts([fromAddress, destinationAddress]);
queryOutput(result,argv.output) console.log(JSON.stringify(result, undefined, 2));
} }

View File

@ -1,8 +1,8 @@
import yargs from 'yargs'; import yargs from 'yargs';
export const command = 'cns'; export const command = 'registry';
export const desc = 'CNS tools'; export const desc = 'Laconic Registry Tools';
exports.builder = (yargs: yargs.Argv) => { exports.builder = (yargs: yargs.Argv) => {
return yargs return yargs
@ -17,7 +17,7 @@ exports.builder = (yargs: yargs.Argv) => {
'gas': { type: 'string' }, 'gas': { type: 'string' },
'fees': { type: 'string' } 'fees': { type: 'string' }
}) })
.commandDir('cns-cmds') .commandDir('registry-cmds')
.demandCommand() .demandCommand()
.help() .help()
} }

View File

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

View File

@ -1,4 +1,3 @@
export * from './fees'; export * from './fees';
export * from './config'; export * from './config';
export * from './common'; 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 # yarn lockfile v1
"@cerc-io/laconic-sdk@^0.1.13": "@cerc-io/laconic-sdk@0.1.4":
version "0.1.13" version "0.1.4"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.13/laconic-sdk-0.1.13.tgz#a51c601f50f3c96656556b7c3f28bc544aac8aef" resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.4/laconic-sdk-0.1.4.tgz#06159cb3c9c48325b53eba9bd642cf63420351d9"
integrity sha512-P5dCEZjpQTGupSDz1mBfGl3SK/95KKHP0Yww6zlz9xva8l66P9t6juYcF//Os2vA4PzDujCTETPr15kJHSFcTQ== integrity sha512-IsXUnz5S14zF+VPWydKy52PkCdyFqRJiMs9FCv8YEJVtUasXkU9xJLBmGaz7Nuo2MyNyKy2NHM7LoB1A75ZHAQ==
dependencies: dependencies:
"@cosmjs/amino" "^0.28.1" "@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1" "@cosmjs/crypto" "^0.28.1"
@ -25,6 +25,7 @@
ethers "^5.6.2" ethers "^5.6.2"
evmosjs "^0.2.5" evmosjs "^0.2.5"
graphql.js "^0.6.8" graphql.js "^0.6.8"
is-url "^1.2.4"
js-sha256 "^0.9.0" js-sha256 "^0.9.0"
js-yaml "^3.14.1" js-yaml "^3.14.1"
jsonschema "^1.4.0" jsonschema "^1.4.0"
@ -1130,6 +1131,11 @@ is-hex-prefixed@1.0.0:
resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554" resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554"
integrity sha1-fY035q135dEnFIkTxXPggtd39VQ= integrity sha1-fY035q135dEnFIkTxXPggtd39VQ=
is-url@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52"
integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==
js-sha256@^0.9.0: js-sha256@^0.9.0:
version "0.9.0" version "0.9.0"
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"