Compare commits

..
Author SHA1 Message Date
Zach 8e594d9664 TODO finish cleaning up 2023-03-06 15:53:11 -05:00
dboreham 2ef028a671 Update to latest sdk (#22) 2023-02-20 12:37:20 -07:00
Michael e7121de87b Merge pull request #20 from cerc-io/integrated_testing
Create manual_npm_publish.yml
2023-02-15 15:54:07 -05:00
Michael 1ebc7f9d8a Create manual_npm_publish.yml 2023-02-15 15:47:35 -05:00
dboreham 3176c0452d Merge pull request #19 from cerc-io/dboreham/update-sdk-version
Update laconic-sdk version to latest
2023-01-19 10:53:58 -07:00
dboreham 2b3d4f2e8b Update laconic-sdk version to latest 2023-01-19 10:53:08 -07:00
41 changed files with 228 additions and 186 deletions
+40
View File
@@ -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: lerna publish
run: |
lerna publish from-package --no-git-tag-version --yes
+36 -34
View File
@@ -1,16 +1,18 @@
# 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).
## Setup
* Run `yarn` to install all dependencies.
`npm config set registry https://git.vdb.to/api/packages/cerc-io/npm/`
* Run `yarn && yarn build` to install all dependencies.
* Create a `config.yml` file from [config.example.yml](./config.example.yml) file.
## Account Setup
Registering records in the Laconic Registry requires an account. To get account private key run:
Registering records in CNS requires an account. To get account private key run:
```bash
$ laconicd keys export mykey --unarmored-hex --unsafe
@@ -30,7 +32,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 +42,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 +76,7 @@ $ laconic registry status
Get account details:
```bash
$ laconic registry account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
$ laconic cns account get --address ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52
[
{
"address": "ethm133y09mveksh76uc99h4rl38nd033tk4e3y2z52",
@@ -94,7 +96,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",
@@ -147,7 +149,7 @@ record:
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
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
```
@@ -155,7 +157,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 +198,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 +256,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 +294,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 +302,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 +346,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 +387,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 +398,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 +432,7 @@ $ laconic registry bond list
Get bond:
```bash
$ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
$ laconic cns bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
@@ -448,7 +450,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 +478,41 @@ $ 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
```
+1 -1
View File
@@ -1,5 +1,5 @@
services:
registry:
cns:
restEndpoint: 'http://localhost:1317'
gqlEndpoint: 'http://localhost:9473/api'
userKey:
+1 -1
View File
@@ -15,7 +15,7 @@
},
"dependencies": {
"fs-extra": "^10.1.0",
"@cerc-io/laconic-sdk": "0.1.4",
"@cerc-io/laconic-sdk": "0.1.6",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",
"lodash-clean": "^2.2.3",
@@ -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();
@@ -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,7 +40,7 @@ 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));
@@ -16,15 +16,15 @@ 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);
@@ -12,11 +12,11 @@ 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]);
@@ -14,15 +14,15 @@ 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));
}
@@ -20,15 +20,15 @@ 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));
@@ -12,11 +12,11 @@ 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);
@@ -20,15 +20,15 @@ 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));
}
@@ -12,15 +12,15 @@ 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));
}
@@ -25,15 +25,15 @@ 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 result = await registry.createBond({ denom, amount }, privateKey, fee);
console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data);
}
@@ -12,15 +12,15 @@ 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));
}
@@ -12,11 +12,11 @@ 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);
@@ -15,11 +15,11 @@ 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);
@@ -18,15 +18,15 @@ 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));
}
@@ -23,15 +23,15 @@ 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));
}
@@ -26,15 +26,15 @@ 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));
}
@@ -26,15 +26,15 @@ 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));
}
@@ -12,15 +12,15 @@ 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));
@@ -18,11 +18,11 @@ 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);
@@ -12,11 +12,11 @@ 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);
@@ -14,15 +14,15 @@ 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));
@@ -12,11 +12,11 @@ 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]);
@@ -25,13 +25,13 @@ 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);
@@ -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,7 +37,7 @@ 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);
@@ -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);
@@ -26,18 +26,18 @@ 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));
+3 -3
View File
@@ -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()
}