Compare commits
48
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58c6d0ff06 | ||
|
|
ddbd0826bd | ||
|
|
dfbef9fe65 | ||
|
|
cf978e4490 | ||
|
|
59c709debd | ||
|
|
679313d960 | ||
|
|
9a45237b2d | ||
|
|
85411f3b06 | ||
|
|
2cc5ae6245 | ||
|
|
b76f52013b | ||
|
|
c3fa657687 | ||
|
|
2ceb7d8483 | ||
|
|
b7a8e7c234 | ||
|
|
a2237f3559 | ||
|
|
30861621cf | ||
|
|
85f350dea9 | ||
|
|
277744e52b | ||
|
|
772eca8c85 | ||
|
|
d1e1a00cf4 | ||
|
|
a986e4cccb | ||
|
|
61a2aaab0f | ||
|
|
0c0eb79fa3 | ||
|
|
8ebb80beed | ||
|
|
9b9e8829ec | ||
|
|
1de17a40ef | ||
|
|
d3020daf2e | ||
|
|
5f92f288c2 | ||
|
|
65c4c12891 | ||
|
|
6c35fc1980 | ||
|
|
84df789ccd | ||
|
|
495bbfdb3c | ||
|
|
64a796c421 | ||
|
|
3258e4cfe3 | ||
|
|
cbcc31d6bd | ||
|
|
a5e0a6dd22 | ||
|
|
5e0c6dd649 | ||
|
|
46c333985e | ||
|
|
2ef028a671 | ||
|
|
93e3f5c301 | ||
|
|
723c2be857 | ||
|
|
c0280b7352 | ||
|
|
b7b77fb04e | ||
|
|
b05b550c43 | ||
|
|
49c4c1f049 | ||
|
|
e7121de87b | ||
|
|
1ebc7f9d8a | ||
|
|
3176c0452d | ||
|
|
2b3d4f2e8b |
@@ -0,0 +1,40 @@
|
||||
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
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
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 : |
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
./create-config.sh $laconicd_key
|
||||
echo ./config.yml
|
||||
ls -tla
|
||||
- name: stop containers
|
||||
working-directory: laconicd/tests/sdk_tests
|
||||
run: docker compose down
|
||||
|
||||
@@ -4,3 +4,6 @@ dist/*
|
||||
out
|
||||
|
||||
config.yml
|
||||
*~
|
||||
|
||||
.idea
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
# 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"]
|
||||
@@ -1,4 +1,4 @@
|
||||
# laconic-registry-client
|
||||
# laconic-cns-client
|
||||
|
||||
CLI utility written in TS, used to interact with laconicd. Depends on [laconic-sdk](https://github.com/cerc-io/laconic-sdk).
|
||||
|
||||
@@ -10,7 +10,15 @@ CLI utility written in TS, used to interact with laconicd. Depends on [laconic-s
|
||||
|
||||
## Account Setup
|
||||
|
||||
Registering records in the Laconic Registry requires an account. To get account private key run:
|
||||
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
|
||||
$ laconicd keys export mykey --unarmored-hex --unsafe
|
||||
@@ -30,7 +38,7 @@ The `gas` and `fees` can be set to some default values in the config, and can be
|
||||
Example:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond create --type aphoton --quantity 1000000000 --gas 200000 --fees 200000aphoton
|
||||
$ laconic cns bond create --type aphoton --quantity 1000000000 --gas 200000 --fees 200000aphoton
|
||||
```
|
||||
|
||||
## Operations
|
||||
@@ -40,7 +48,7 @@ These commands require a `config.yml` file present in the current working direct
|
||||
Get node status:
|
||||
|
||||
```bash
|
||||
$ laconic registry status
|
||||
$ laconic cns status
|
||||
{
|
||||
"version": "0.3.0",
|
||||
"node": {
|
||||
@@ -74,7 +82,7 @@ $ laconic registry status
|
||||
Get account details:
|
||||
|
||||
```bash
|
||||
$ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
|
||||
$ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
|
||||
[
|
||||
{
|
||||
"address": "ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52",
|
||||
@@ -94,7 +102,7 @@ $ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y
|
||||
Send tokens:
|
||||
|
||||
```bash
|
||||
$ laconic registry tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type aphoton --quantity 1000000000
|
||||
$ laconic cns tokens send --address ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu --type aphoton --quantity 1000000000
|
||||
[
|
||||
{
|
||||
"address": "ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8",
|
||||
@@ -128,26 +136,18 @@ Create record (generic):
|
||||
```yaml
|
||||
# watcher.yml
|
||||
record:
|
||||
name: ERC20 Watcher
|
||||
type: watcher
|
||||
version: 1.0.0
|
||||
protocol:
|
||||
/: QmbQiRpLX5djUsfc2yDswHvTkHTGd9uQEy6oUJfxkBYwRq
|
||||
package:
|
||||
linux:
|
||||
x64:
|
||||
/: QmVRmLrQeLZS8Xee7YVzYYAQANWmXqsNgNkaPMxM8MtPLA
|
||||
arm:
|
||||
/: QmX3DDmeFunX5aVmaTNnViwQUe15Wa4UbZYcC3AwFwoWcg
|
||||
macos:
|
||||
x64:
|
||||
/: QmXogCVZZ867qZfS3CYjYdDEziPb4ARiDfgwqbd7urVKkr
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://cerc.io'
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.23
|
||||
```
|
||||
|
||||
Publish record (see below for commands to create/query bonds):
|
||||
|
||||
```bash
|
||||
$ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
$ laconic cns record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000
|
||||
|
||||
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
|
||||
```
|
||||
@@ -155,7 +155,7 @@ $ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa
|
||||
Get record:
|
||||
|
||||
```bash
|
||||
$ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
|
||||
$ laconic cns record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
|
||||
[
|
||||
{
|
||||
"id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba",
|
||||
@@ -196,19 +196,19 @@ $ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf
|
||||
List records:
|
||||
|
||||
```bash
|
||||
$ laconic registry record list
|
||||
$ laconic cns record list
|
||||
```
|
||||
|
||||
Reserve authority:
|
||||
|
||||
```bash
|
||||
$ laconic registry authority reserve laconic
|
||||
$ laconic cns authority reserve laconic
|
||||
```
|
||||
|
||||
Check authority information:
|
||||
|
||||
```bash
|
||||
$ laconic registry authority whois laconic
|
||||
$ laconic cns authority whois laconic
|
||||
[
|
||||
{
|
||||
"ownerAddress": "",
|
||||
@@ -254,7 +254,7 @@ $ laconic registry authority whois laconic
|
||||
Get authority auction info:
|
||||
|
||||
```bash
|
||||
$ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48
|
||||
$ laconic cns auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48
|
||||
[
|
||||
{
|
||||
"id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48",
|
||||
@@ -292,7 +292,7 @@ $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2
|
||||
Commit an auction bid:
|
||||
|
||||
```bash
|
||||
$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 aphoton
|
||||
$ laconic cns auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 aphoton
|
||||
|
||||
Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
|
||||
```
|
||||
@@ -300,37 +300,37 @@ Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.j
|
||||
Reveal an auction bid:
|
||||
|
||||
```bash
|
||||
$ laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
|
||||
$ laconic cns auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
|
||||
```
|
||||
|
||||
Set authority bond (after winning auction):
|
||||
|
||||
```bash
|
||||
$ laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
$ laconic cns authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
```
|
||||
|
||||
Create sub-authority (same owner as parent authority):
|
||||
|
||||
```bash
|
||||
$ laconic registry authority reserve echo.laconic
|
||||
$ laconic cns authority reserve echo.laconic
|
||||
```
|
||||
|
||||
Create sub-authority (custom owner for sub-authority):
|
||||
|
||||
```bash
|
||||
$ laconic registry authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu
|
||||
$ laconic cns authority reserve kube.laconic --owner ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu
|
||||
```
|
||||
|
||||
Set name:
|
||||
|
||||
```bash
|
||||
$ laconic registry name set crn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
|
||||
$ laconic cns name set crn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
|
||||
```
|
||||
|
||||
Lookup name information:
|
||||
|
||||
```bash
|
||||
$ laconic registry name lookup crn://laconic/watcher/erc20
|
||||
$ laconic cns name lookup crn://laconic/watcher/erc20
|
||||
[
|
||||
{
|
||||
"latest": {
|
||||
@@ -344,7 +344,7 @@ $ laconic registry name lookup crn://laconic/watcher/erc20
|
||||
Resolve name:
|
||||
|
||||
```bash
|
||||
$ laconic registry name resolve crn://laconic/watcher/erc20
|
||||
$ laconic cns name resolve crn://laconic/watcher/erc20
|
||||
[
|
||||
{
|
||||
"id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba",
|
||||
@@ -385,9 +385,9 @@ $ laconic registry name resolve crn://laconic/watcher/erc20
|
||||
Delete name:
|
||||
|
||||
```bash
|
||||
$ laconic registry name delete crn://laconic/watcher/erc20
|
||||
$ laconic cns name delete crn://laconic/watcher/erc20
|
||||
|
||||
$ laconic registry name resolve crn://laconic/watcher/erc20
|
||||
$ laconic cns name resolve crn://laconic/watcher/erc20
|
||||
[
|
||||
null
|
||||
]
|
||||
@@ -396,13 +396,13 @@ $ laconic registry name resolve crn://laconic/watcher/erc20
|
||||
Create bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond create --type aphoton --quantity 1000
|
||||
$ laconic cns bond create --type aphoton --quantity 1000
|
||||
```
|
||||
|
||||
List bonds:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond list
|
||||
$ laconic cns bond list
|
||||
[
|
||||
{
|
||||
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
|
||||
@@ -430,7 +430,7 @@ $ laconic registry bond list
|
||||
Get bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
$ laconic cns bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
[
|
||||
{
|
||||
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
|
||||
@@ -448,7 +448,7 @@ $ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa1953
|
||||
Query bonds by owner:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
|
||||
$ laconic cns bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
|
||||
[
|
||||
{
|
||||
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
|
||||
@@ -476,41 +476,91 @@ $ laconic registry bond list --owner ethm1lfekr7gvqtnhpp2kwdc6u2n569cqsp4ww0m4y8
|
||||
Refill bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 1000
|
||||
$ laconic cns bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 1000
|
||||
```
|
||||
|
||||
Withdraw funds from bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 500
|
||||
$ laconic cns bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type aphoton --quantity 500
|
||||
```
|
||||
|
||||
Cancel bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
$ laconic cns bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
|
||||
```
|
||||
|
||||
Associate bond (with record):
|
||||
|
||||
```bash
|
||||
$ laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
|
||||
$ laconic cns bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
|
||||
```
|
||||
|
||||
Disassociate bond (from record):
|
||||
|
||||
```bash
|
||||
$ laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
|
||||
$ laconic cns bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
|
||||
```
|
||||
|
||||
Dissociate all records from bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
|
||||
$ laconic cns bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
|
||||
```
|
||||
|
||||
Reassociate records (switch bond):
|
||||
|
||||
```bash
|
||||
$ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae
|
||||
$ laconic cns bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
Follow these steps to run the tests:
|
||||
|
||||
- After cloning this repo run:
|
||||
|
||||
```bash
|
||||
yarn
|
||||
```
|
||||
|
||||
- Copy [config.example.yml](./config.example.yml) file and create a `config.yml` file.
|
||||
|
||||
- Clone the [laconicd repo](https://github.com/cerc-io/laconicd) and change to repo directory.
|
||||
|
||||
- Run the chain using `./init.sh`.
|
||||
|
||||
- Export the private key using:
|
||||
|
||||
```bash
|
||||
laconicd keys export mykey --unarmored-hex --unsafe
|
||||
```
|
||||
|
||||
- Copy the private key and assign it to variable `PRIVATE_KEY` in the `config.yml` file.
|
||||
|
||||
- Run the tests in laconic-sdk repo:
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
- Run the tests with auctions enabled
|
||||
|
||||
- In laconicd repo run:
|
||||
|
||||
```bash
|
||||
TEST_AUCTION_ENABLED=true ./init.sh
|
||||
```
|
||||
|
||||
- Export the private key and change it in `config.yml` file again using:
|
||||
|
||||
```bash
|
||||
laconicd keys export mykey --unarmored-hex --unsafe
|
||||
```
|
||||
|
||||
- Run tests:
|
||||
|
||||
```bash
|
||||
yarn test:auctions
|
||||
```
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
services:
|
||||
registry:
|
||||
cns:
|
||||
restEndpoint: 'http://localhost:1317'
|
||||
gqlEndpoint: 'http://localhost:9473/api'
|
||||
userKey:
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <new-key>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Assign the arguments to variables
|
||||
new_key=$1
|
||||
file_path=./config.yml
|
||||
|
||||
# Check if the file exists
|
||||
if [[ ! -f "$file_path" ]]; then
|
||||
echo "Creating file: $file_path"
|
||||
# Create the YAML file
|
||||
cat > $file_path <<EOF
|
||||
services:
|
||||
cns:
|
||||
restEndpoint: 'http://localhost:1317'
|
||||
gqlEndpoint: 'http://localhost:9473/api'
|
||||
userKey: $new_key
|
||||
bondId:
|
||||
chainId: laconic_9000-1
|
||||
gas: 300000
|
||||
fees: 300000aphoton
|
||||
EOF
|
||||
else
|
||||
# Use yq to update the value in the file
|
||||
yq eval ".services.cns.userKey = \"$new_key\"" "$file_path" --inplace
|
||||
fi
|
||||
@@ -0,0 +1,29 @@
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "2.9.0",
|
||||
"useWorkspaces": true,
|
||||
"npmClient": "yarn"
|
||||
}
|
||||
+8
-2
@@ -7,15 +7,19 @@
|
||||
"license": "UNLICENSED",
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/jest": "^29.5.0",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/node": "^17.0.25",
|
||||
"@types/semver": "^7.3.13",
|
||||
"@types/yargs": "^17.0.10",
|
||||
"jest": "^29.5.0",
|
||||
"ts-jest": "^29.0.5",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cerc-io/laconic-sdk": "0.1.6",
|
||||
"fs-extra": "^10.1.0",
|
||||
"@cerc-io/laconic-sdk": "0.1.4",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-clean": "^2.2.3",
|
||||
@@ -24,7 +28,9 @@
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"clean": "rm -rf ./dist",
|
||||
"build": "tsc"
|
||||
"build": "tsc",
|
||||
"test": "jest --runInBand --verbose",
|
||||
"test:auctions": "TEST_AUCTIONS_ENABLED=1 jest --runInBand --verbose test/auction.test.ts"
|
||||
},
|
||||
"bin": {
|
||||
"laconic": "bin/laconic"
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Account, Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'get';
|
||||
|
||||
@@ -11,11 +11,11 @@ export const desc = 'Get account.';
|
||||
export const handler = async (argv: Arguments) => {
|
||||
let address = argv.address as string;
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
if (!address && privateKey) {
|
||||
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 result = await registry.getAccounts([address]);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output);
|
||||
}
|
||||
+9
-9
@@ -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 } from '../../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
|
||||
const OUT_DIR = 'out';
|
||||
|
||||
@@ -21,12 +21,12 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(quantity, 'Invalid token quantity.');
|
||||
assert(denom, 'Invalid token type.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
const bidderAddress = account.formattedCosmosAddress;
|
||||
@@ -40,10 +40,10 @@ export const handler = async (argv: Arguments) => {
|
||||
fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2));
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
|
||||
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const revealFile = `{"reveal_file":"${revealFilePath}"}`
|
||||
|
||||
console.log(`\nReveal file: ${revealFilePath}`);
|
||||
txOutput(result,revealFile,argv.output,argv.verbose)
|
||||
}
|
||||
+10
-8
@@ -4,7 +4,7 @@ import path from 'path';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import fs from 'fs';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
|
||||
export const command = 'reveal [auction-id] [file-path]';
|
||||
|
||||
@@ -16,17 +16,19 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(auctionId, 'Invalid auction ID.');
|
||||
assert(filePath, 'Invalid reveal file path.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
|
||||
const reveal = fs.readFileSync(path.resolve(filePath));
|
||||
const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'get [id]';
|
||||
|
||||
@@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
|
||||
const { id, config } = argv;
|
||||
assert(id, 'Invalid auction ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
const result = await registry.getAuctionsByIds([id as string]);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
+10
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
|
||||
export const command = 'set [name] [bond-id]';
|
||||
|
||||
@@ -14,15 +14,17 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(name, 'Invalid authority name.');
|
||||
assert(bondId, 'Invalid Bond ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
}
|
||||
+9
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
export const command = 'reserve [name]';
|
||||
|
||||
@@ -20,16 +20,17 @@ export const handler = async (argv: Arguments) => {
|
||||
const owner = argv.owner as string;
|
||||
assert(name, 'Invalid authority name.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
}
|
||||
+7
-7
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'whois [name]';
|
||||
|
||||
@@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
|
||||
const name = argv.name as string;
|
||||
assert(name, 'Invalid authority name.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
const result = await registry.lookupAuthorities([name], true);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
+10
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
|
||||
|
||||
export const command = 'associate';
|
||||
|
||||
@@ -20,15 +20,17 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(id, 'Invalid Record ID.');
|
||||
assert(bondId, 'Invalid Bond ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
|
||||
|
||||
export const command = 'cancel';
|
||||
|
||||
@@ -12,15 +12,17 @@ export const handler = async (argv: Arguments) => {
|
||||
const id = argv.id as string
|
||||
assert(id, 'Invalid Bond ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.cancelBond({ id }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
|
||||
|
||||
export const command = 'create';
|
||||
|
||||
@@ -25,15 +25,19 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(denom, 'Invalid Type.');
|
||||
assert(amount, 'Invalid Quantity.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const bondId = await registry.getNextBondId(privateKey);
|
||||
const result = await registry.createBond({ denom, amount }, privateKey, fee);
|
||||
console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data);
|
||||
const jsonString=`{"bondId":"${bondId}"}`
|
||||
|
||||
txOutput(result,jsonString,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
+10
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
|
||||
|
||||
export const command = 'dissociate';
|
||||
|
||||
@@ -12,15 +12,17 @@ export const handler = async (argv: Arguments) => {
|
||||
const id = argv.id as string;
|
||||
assert(id, 'Invalid Record ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
|
||||
|
||||
export const command = 'get';
|
||||
|
||||
@@ -12,14 +12,15 @@ export const handler = async (argv: Arguments) => {
|
||||
const { id, config } = argv;
|
||||
console.assert(id, 'Bond Id is required.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
|
||||
const result = await registry.getBondsByIds([id as string]);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
|
||||
|
||||
export const command = 'list';
|
||||
|
||||
@@ -15,15 +15,16 @@ export const builder = {
|
||||
}
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
|
||||
const { owner } = argv;
|
||||
const result = await registry.queryBonds({ owner });
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
+10
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../../util';
|
||||
|
||||
export const command = 'dissociate';
|
||||
|
||||
@@ -18,15 +18,17 @@ export const handler = async (argv: Arguments) => {
|
||||
const bondId = argv.bondId as string;
|
||||
assert(bondId, 'Invalid Bond ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
+10
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../../util';
|
||||
|
||||
export const command = 'reassociate';
|
||||
|
||||
@@ -23,15 +23,17 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(oldBondId, 'Invalid Old Bond ID.');
|
||||
assert(newBondId, 'Invalid New Bond ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,8 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
|
||||
import { isNil } from 'lodash';
|
||||
|
||||
export const command = 'refill';
|
||||
|
||||
@@ -26,15 +27,17 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(denom, 'Invalid Type.');
|
||||
assert(amount, 'Invalid Quantity.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
+10
-8
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
|
||||
|
||||
export const command = 'withdraw';
|
||||
|
||||
@@ -26,15 +26,17 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(denom, 'Invalid Type.');
|
||||
assert(amount, 'Invalid Quantity.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
|
||||
|
||||
export const command = 'delete [name]';
|
||||
|
||||
@@ -12,16 +12,18 @@ export const handler = async (argv: Arguments) => {
|
||||
const name = argv.name as string;
|
||||
assert(name, 'Invalid Name.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.deleteName({ crn: name }, privateKey, fee);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
|
||||
|
||||
export const command = 'lookup [name]';
|
||||
|
||||
@@ -18,14 +18,14 @@ export const handler = async (argv: Arguments) => {
|
||||
const name = argv.name as string;
|
||||
assert(name, 'Invalid Name.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
const result = await registry.lookupNames([name], argv.history as boolean);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
+7
-7
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo,queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'resolve [name]';
|
||||
|
||||
@@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
|
||||
const name = argv.name as string;
|
||||
assert(name, 'Invalid Name.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
|
||||
const result = await registry.resolveNames([name]);
|
||||
console.log(JSON.stringify(result, undefined, 4));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
|
||||
|
||||
export const command = 'set [name] [id]';
|
||||
|
||||
@@ -14,16 +14,18 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(name, 'Invalid Name.');
|
||||
assert(id, 'Invalid Record ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
const success = `{"success":${result.code==0}}`
|
||||
txOutput(result,success,argv.output,argv.verbose)
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
|
||||
|
||||
export const command = 'get';
|
||||
|
||||
@@ -12,14 +12,14 @@ export const handler = async (argv: Arguments) => {
|
||||
const { id, config } = argv;
|
||||
assert(id, 'Invalid Record ID.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
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);
|
||||
const result = await registry.getRecordsByIds([id as string]);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getConnectionInfo ,queryOutput} from '../../../util';
|
||||
|
||||
export const command = 'list';
|
||||
|
||||
@@ -25,16 +25,16 @@ export const builder = {
|
||||
}
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
const { type, name, bondId, all } = argv;
|
||||
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
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);
|
||||
|
||||
const result = await registry.queryRecords({ bondId, type, name }, all as boolean);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
+8
-8
@@ -5,7 +5,7 @@ import yaml from 'js-yaml';
|
||||
import fs from 'fs';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getGasAndFees, getConnectionInfo } from '../../../util';
|
||||
import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../../util';
|
||||
|
||||
export const command = 'publish';
|
||||
|
||||
@@ -19,14 +19,14 @@ export const builder = {
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { txKey, filename, verbose, config } = argv;
|
||||
const { services: { lns: lnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
const { services: { cns: cnsConfig } } = getConfig(config as string)
|
||||
const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(userKey, 'Invalid User Key.');
|
||||
assert(bondId, 'Invalid Bond ID.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
let file = null;
|
||||
if (filename) {
|
||||
@@ -37,8 +37,8 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const { record } = await yaml.load(fs.readFileSync(file, 'utf-8')) as any;
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee);
|
||||
|
||||
console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data);
|
||||
txOutput(result,JSON.stringify(result.data,undefined,2),argv.output,argv.verbose)
|
||||
}
|
||||
@@ -6,14 +6,14 @@ import { getConfig, getConnectionInfo } from '../../util';
|
||||
|
||||
export const command = 'status';
|
||||
|
||||
export const desc = 'Get Registry status.';
|
||||
export const desc = 'Get CNS status.';
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { services: { lns } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, lns);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
const { services: { cns } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cns);
|
||||
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);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Account, Registry } from '@cerc-io/laconic-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'send';
|
||||
|
||||
@@ -26,19 +26,19 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(denom, 'Invalid Type.');
|
||||
assert(amount, 'Invalid Quantity.');
|
||||
|
||||
const { services: { lns: lnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, lnsConfig);
|
||||
assert(restEndpoint, 'Invalid Registry REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid Registry GQL endpoint.');
|
||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid Registry Chain ID.');
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
const fromAddress = account.formattedCosmosAddress;
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, lnsConfig);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
|
||||
const result = await registry.getAccounts([fromAddress, destinationAddress]);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
queryOutput(result,argv.output)
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import yargs from 'yargs';
|
||||
|
||||
export const command = 'registry';
|
||||
export const command = 'cns';
|
||||
|
||||
export const desc = 'Laconic Registry Tools';
|
||||
export const desc = 'CNS tools';
|
||||
|
||||
exports.builder = (yargs: yargs.Argv) => {
|
||||
return yargs
|
||||
@@ -17,7 +17,7 @@ exports.builder = (yargs: yargs.Argv) => {
|
||||
'gas': { type: 'string' },
|
||||
'fees': { type: 'string' }
|
||||
})
|
||||
.commandDir('registry-cmds')
|
||||
.commandDir('cns-cmds')
|
||||
.demandCommand()
|
||||
.help()
|
||||
}
|
||||
@@ -15,6 +15,11 @@ 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')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './fees';
|
||||
export * from './config';
|
||||
export * from './common';
|
||||
export * from './output';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
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,undefined,2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "account "
|
||||
const type= "aphoton"
|
||||
const quantity="10"
|
||||
const address="ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu"
|
||||
|
||||
describe("test account",() => {
|
||||
it("get account should return account details",async ()=>{
|
||||
// send tokens to account to avoid account not found error
|
||||
const sendResp=cliTest("tokens send --address "+address+" --type "+type+" --quantity "+quantity)
|
||||
expect(sendResp).toBeDefined();
|
||||
|
||||
const resp=cliTest(args+"get --address "+address);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp[0].address).toEqual(address)
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import {cliTest,createAuthority, getAuctionId} from './helper';
|
||||
|
||||
jest.setTimeout(3 * 60 * 1000);
|
||||
|
||||
const args= "auction ";
|
||||
const quantity=25000000
|
||||
const type="aphoton"
|
||||
const name=`laconic-auction-${Date.now()}`
|
||||
|
||||
|
||||
var auctionId: string;
|
||||
var filepath: string;
|
||||
|
||||
if (!process.env.TEST_AUCTIONS_ENABLED) {
|
||||
// Required as jest complains if file has no tests.
|
||||
test('skipping auction tests', () => {});
|
||||
} else {
|
||||
describe("test auction",() => {
|
||||
beforeAll(async () => {
|
||||
// reserve authority
|
||||
createAuthority(name)
|
||||
auctionId = getAuctionId(name)
|
||||
});
|
||||
|
||||
it("get auction",async ()=>{
|
||||
const resp=cliTest(args+"get "+auctionId);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.length).toEqual(1);
|
||||
expect(resp[0].id).toEqual(auctionId)
|
||||
});
|
||||
|
||||
it("bid commit",async ()=>{
|
||||
const resp=cliTest(args+"bid commit "+auctionId+" "+quantity+" "+type);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.reveal_file).toBeDefined();
|
||||
|
||||
filepath = resp.reveal_file
|
||||
|
||||
const auction=cliTest(args+"get "+auctionId);
|
||||
expect(auction).toBeDefined;
|
||||
expect(auction.length).toEqual(1);
|
||||
expect(auction[0].bids.length).toEqual(1);
|
||||
expect(auction[0].bids[0].bidAmount.quantity).toEqual("0")
|
||||
});
|
||||
|
||||
it("Wait for reveal phase.", (done) => {
|
||||
setTimeout(done, 60 * 1000);
|
||||
});
|
||||
|
||||
it("bid reveal", async ()=>{
|
||||
const resp=cliTest(args+"bid reveal "+auctionId+" "+filepath);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
const auction=cliTest(args+"get "+auctionId);
|
||||
expect(auction).toBeDefined;
|
||||
expect(auction.length).toEqual(1);
|
||||
expect(auction[0].bids.length).toEqual(1);
|
||||
expect(auction[0].bids[0].bidAmount.quantity).toEqual(quantity+"")
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import {cliTest,createBond} from './helper';
|
||||
|
||||
const args= "authority "
|
||||
const name=`laconic-${Date.now()}`
|
||||
|
||||
var bondId: string;
|
||||
|
||||
describe("test authority",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bond id
|
||||
bondId=createBond("aphoton","1000000000")
|
||||
});
|
||||
|
||||
|
||||
it("reserve authority",async ()=>{
|
||||
const resp=cliTest(args+"reserve "+name);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
});
|
||||
|
||||
it("lookup authority information.",async ()=>{
|
||||
const resp=cliTest(args+"whois "+ name);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.length).toEqual(1);
|
||||
expect(resp[0].status).toEqual("active")
|
||||
expect(resp[0].bondId).toEqual("")
|
||||
});
|
||||
|
||||
it("set authority bond",async ()=>{
|
||||
const bondSet=cliTest(args+"bond set "+name+" "+bondId);
|
||||
expect(bondSet).toBeDefined();
|
||||
expect(bondSet.success).toBeTruthy();
|
||||
|
||||
const resp=cliTest(args+"whois "+ name);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.length).toEqual(1);
|
||||
expect(resp[0].status).toEqual("active")
|
||||
expect(resp[0].bondId).toEqual(bondId)
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,169 @@
|
||||
import {cliTest,createBond,createRecord} from './helper';
|
||||
|
||||
const args= "bond "
|
||||
const quantity=1000000000
|
||||
const refillQuantity=100
|
||||
const withdrawQuantity=100
|
||||
const type="aphoton"
|
||||
|
||||
var bondId: string;
|
||||
var address: string;
|
||||
var recordId: string;
|
||||
|
||||
describe("test bond",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const resp=cliTest("account get");
|
||||
expect(resp).toBeDefined();
|
||||
address=resp[0].address
|
||||
});
|
||||
|
||||
|
||||
it("create bond",async ()=>{
|
||||
const resp=cliTest(args+"create --type "+type+" --quantity "+quantity);
|
||||
expect(resp.bondId).toBeDefined();
|
||||
bondId=resp.bondId
|
||||
});
|
||||
|
||||
it("list bond",async ()=>{
|
||||
const resp=cliTest(args+"list");
|
||||
expect(resp.length).toBeGreaterThan(0);
|
||||
const lenghtBefore=resp.length
|
||||
|
||||
createBond(type,quantity+"")
|
||||
|
||||
const respAfter=cliTest(args+"list");
|
||||
expect(respAfter.length-lenghtBefore).toEqual(1)
|
||||
|
||||
});
|
||||
|
||||
it("get bond",async ()=>{
|
||||
const resp=cliTest(args+"get --id "+bondId);
|
||||
expect(resp.length).toEqual(1);
|
||||
expect(resp[0].id).toEqual(bondId);
|
||||
expect(Number(resp[0].balance[0].quantity)).toEqual(quantity);
|
||||
});
|
||||
|
||||
it("list bonds by owner",async ()=>{
|
||||
const resp=cliTest(args+"list --owner "+address);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.length).toBeGreaterThan(0);
|
||||
expect(resp[0].owner).toEqual(address);
|
||||
});
|
||||
|
||||
it("refill bond",async ()=>{
|
||||
const resp=cliTest(args+"refill --id "+bondId+" --type "+type+" --quantity "+refillQuantity);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
const getResp=cliTest(args+"get --id "+bondId);
|
||||
expect(getResp.length).toEqual(1);
|
||||
expect(getResp[0].id).toEqual(bondId);
|
||||
expect(Number(getResp[0].balance[0].quantity)).toEqual(quantity+refillQuantity);
|
||||
});
|
||||
|
||||
it("withdraw funds from bond, insufficient",async ()=>{
|
||||
const resp=cliTest(args+"withdraw --id "+bondId+" --type "+type+" --quantity "+withdrawQuantity+quantity*2);
|
||||
expect(resp.stderr).toBeDefined();
|
||||
expect(resp.stderr.toString()).toContain("Insufficient bond balance.: insufficient funds")
|
||||
});
|
||||
|
||||
it("withdraw funds from bond",async ()=>{
|
||||
const resp=cliTest(args+"withdraw --id "+bondId+" --type "+type+" --quantity "+withdrawQuantity);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
const getResp=cliTest(args+"get --id "+bondId);
|
||||
expect(getResp.length).toEqual(1);
|
||||
expect(getResp[0].id).toEqual(bondId);
|
||||
expect(Number(getResp[0].balance[0].quantity)).toEqual(quantity+refillQuantity-withdrawQuantity);
|
||||
});
|
||||
|
||||
it("cancel bond",async ()=>{
|
||||
const resp=cliTest(args+"cancel --id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
const getResp=cliTest(args+"get --id "+bondId);
|
||||
expect(getResp.length).toEqual(1);
|
||||
expect(getResp[0].id).toEqual("");
|
||||
});
|
||||
|
||||
it("associate bond with record",async ()=>{
|
||||
// get new bond Id
|
||||
bondId=createBond(type,quantity+"")
|
||||
// get record Id
|
||||
recordId=createRecord("./test/examples/watcher.yml",bondId)
|
||||
|
||||
// dissociate bond from record
|
||||
const dissociate=cliTest(args+"dissociate --id "+recordId);
|
||||
expect(dissociate).toBeDefined;
|
||||
expect(dissociate.success).toBeTruthy();
|
||||
|
||||
// get new bond Id
|
||||
const newbondId=createBond(type,quantity+"")
|
||||
|
||||
const resp=cliTest(args+"associate --id "+recordId+" --bond-id "+newbondId);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
// check for bond id in record
|
||||
const getRecord=cliTest(" record get --id "+recordId)
|
||||
expect(getRecord).toBeDefined();
|
||||
expect(getRecord.length).toEqual(1);
|
||||
expect(getRecord[0].id).toEqual(recordId);
|
||||
expect(getRecord[0].bondId).toEqual(newbondId);
|
||||
});
|
||||
|
||||
it("dissociate bond from record",async ()=>{
|
||||
const resp=cliTest(args+"dissociate --id "+recordId);
|
||||
expect(resp).toBeDefined;
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
// check for bond id in record
|
||||
const getRecord=cliTest(" record get --id "+recordId)
|
||||
expect(getRecord).toBeDefined();
|
||||
expect(getRecord.length).toEqual(1);
|
||||
expect(getRecord[0].id).toEqual(recordId);
|
||||
expect(getRecord[0].bondId).toEqual("");
|
||||
});
|
||||
|
||||
it("dissociate all records from bond",async ()=>{
|
||||
// associate bond to record
|
||||
const associate=cliTest(args+"associate --id "+recordId+" --bond-id "+bondId);
|
||||
expect(associate).toBeDefined;
|
||||
expect(associate.success).toBeTruthy();
|
||||
|
||||
const resp=cliTest(args+"records dissociate --bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
// check for bond id in record
|
||||
const getRecord=cliTest(" record get --id "+recordId)
|
||||
expect(getRecord).toBeDefined();
|
||||
expect(getRecord.length).toEqual(1);
|
||||
expect(getRecord[0].id).toEqual(recordId);
|
||||
expect(getRecord[0].bondId).toEqual("");
|
||||
});
|
||||
|
||||
it("reassociate all records from bond",async ()=>{
|
||||
// get new bondid
|
||||
const newBondId =createBond(type,quantity+"")
|
||||
|
||||
// associate bond to record
|
||||
const associate=cliTest(args+"associate --id "+recordId+" --bond-id "+bondId);
|
||||
expect(associate).toBeDefined;
|
||||
expect(associate.success).toBeTruthy();
|
||||
|
||||
const resp=cliTest(args+"records reassociate --old-bond-id "+bondId+" --new-bond-id "+newBondId);
|
||||
expect(resp).toBeDefined;
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
// check for bond id in record
|
||||
const getRecord=cliTest(" record get --id "+recordId)
|
||||
expect(getRecord).toBeDefined();
|
||||
expect(getRecord.length).toEqual(1);
|
||||
expect(getRecord[0].id).toEqual(recordId);
|
||||
expect(getRecord[0].bondId).toEqual(newBondId);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://cerc.io'
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.35
|
||||
@@ -0,0 +1,49 @@
|
||||
import yaml from 'js-yaml'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import semver from 'semver';
|
||||
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
export const updateRecord = (filePath: string) => {
|
||||
const resolvedFilePath = path.resolve(process.cwd(), filePath);
|
||||
const file = fs.readFileSync(resolvedFilePath, 'utf-8')
|
||||
const data = yaml.load(file) as any;
|
||||
|
||||
data.record.version=semver.inc(data.record.version, 'patch');
|
||||
|
||||
fs.writeFileSync(resolvedFilePath, yaml.dump(data));
|
||||
};
|
||||
|
||||
export const cliTest = (args: any) => {
|
||||
try{
|
||||
return JSON.parse(execSync(`./bin/laconic cns ${args}`));
|
||||
}catch(err){
|
||||
return(err)
|
||||
}
|
||||
};
|
||||
|
||||
export function createBond(type: string, quantity: string):string{
|
||||
const resp=cliTest("bond create --type aphoton --quantity 1000000000");
|
||||
expect(resp.bondId).toBeDefined();
|
||||
return resp.bondId
|
||||
};
|
||||
|
||||
export function createRecord(filepath: string, bondId: string):string{
|
||||
const resp=cliTest("record publish --filename "+filepath+" --bond-id "+bondId);
|
||||
expect(resp.id).toBeDefined();
|
||||
return resp.id
|
||||
}
|
||||
|
||||
export function createAuthority(name:string):any{
|
||||
const resp=cliTest("authority reserve "+name);
|
||||
expect(resp).toBeDefined;
|
||||
expect(resp.success).toBeTruthy();
|
||||
return resp
|
||||
}
|
||||
|
||||
export function getAuctionId(name:string):string{
|
||||
const jsonResp = cliTest("authority whois "+name)
|
||||
expect(jsonResp).toBeDefined;
|
||||
return jsonResp[0].auction.id
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import {cliTest,createAuthority,createBond,createRecord} from './helper';
|
||||
|
||||
const args= "name ";
|
||||
const name=`laconic-${Date.now()}`;
|
||||
const crn=`crn://${name}/app/test`;
|
||||
|
||||
var recordId: string;
|
||||
var bondId: string;
|
||||
|
||||
describe("test names",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bond id
|
||||
bondId = createBond("aphoton","10000000")
|
||||
|
||||
// get record id
|
||||
recordId=createRecord("./test/examples/watcher.yml",bondId)
|
||||
|
||||
// reserve authority
|
||||
createAuthority(name)
|
||||
|
||||
// set authority bond
|
||||
const resp=cliTest("authority bond set "+name+" "+bondId);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
it("set name",async ()=>{
|
||||
const resp=cliTest(args+"set "+crn+" "+recordId);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
});
|
||||
|
||||
it("lookup name",async ()=>{
|
||||
const resp=cliTest(args+"lookup "+ crn);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp[0].latest.id).toEqual(recordId)
|
||||
});
|
||||
|
||||
it("resolve name",async ()=>{
|
||||
const resp=cliTest(args+"resolve "+crn);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp[0].id).toEqual(recordId)
|
||||
});
|
||||
|
||||
it("delete name",async ()=>{
|
||||
const resp=cliTest(args+"delete "+crn);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.success).toBeTruthy();
|
||||
|
||||
const resolve=cliTest(args+"resolve "+crn);
|
||||
expect(resolve).toBeDefined();
|
||||
expect(resolve[0]).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import {cliTest,createBond, updateRecord} from './helper';
|
||||
|
||||
const args= "record "
|
||||
const filename = "./test/examples/watcher.yml"
|
||||
|
||||
var recordId: string;
|
||||
var bondId: string;
|
||||
|
||||
describe("test record",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bondId
|
||||
bondId=createBond("aphoton","1000000000")
|
||||
updateRecord(filename)
|
||||
});
|
||||
|
||||
it("publish record",async ()=>{
|
||||
const resp=cliTest(args+"publish --filename "+filename+" --bond-id "+bondId);
|
||||
expect(resp).toBeDefined();
|
||||
console.log(resp.toString())
|
||||
expect(resp.id).toBeDefined();
|
||||
|
||||
recordId=resp.id
|
||||
});
|
||||
|
||||
it("get record",async ()=>{
|
||||
const resp=cliTest(args+"get --id "+recordId);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.length).toEqual(1);
|
||||
expect(resp[0].id).toEqual(recordId)
|
||||
expect(resp[0].bondId).toEqual(bondId)
|
||||
});
|
||||
|
||||
it("list records",async ()=>{
|
||||
const resp=cliTest(args+"list");
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "status "
|
||||
|
||||
describe("test status",() => {
|
||||
|
||||
it("get status",async ()=>{
|
||||
const resp=cliTest(args);
|
||||
expect(resp).toBeDefined();
|
||||
expect(resp.node.network).toContain("laconic")
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "tokens "
|
||||
const type= "aphoton"
|
||||
const quantity=10
|
||||
const address="ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu"
|
||||
|
||||
describe("test account",() => {
|
||||
it("get account should return account details",async ()=>{
|
||||
// balance before
|
||||
var balanceBefore;
|
||||
const beforeResp=cliTest("account get --address "+address);
|
||||
if (beforeResp.stderr){
|
||||
expect(beforeResp.stderr.toString()).toContain("account "+address+ " not found")
|
||||
balanceBefore=0
|
||||
} else{
|
||||
balanceBefore=beforeResp[0].balance[0].quantity
|
||||
}
|
||||
|
||||
// send tokens to account
|
||||
const sendResp=cliTest(args+"send --address "+address+" --type "+type+" --quantity "+quantity)
|
||||
expect(sendResp).toBeDefined();
|
||||
|
||||
// balance after
|
||||
var balanceAfter;
|
||||
const afterResp=cliTest("account get --address "+address);
|
||||
if (afterResp.stderr){
|
||||
expect(afterResp.stderr.toString()).toContain("account "+address+ " not found")
|
||||
balanceAfter=0
|
||||
} else{
|
||||
balanceAfter=afterResp[0].balance[0].quantity
|
||||
}
|
||||
|
||||
expect(balanceAfter-balanceBefore).toEqual(quantity)
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://cerc.io'
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.35
|
||||
Reference in New Issue
Block a user