Compare commits

..

18 Commits

Author SHA1 Message Date
Zach
37b69da3bb
Merge pull request #35 from cerc-io/dboreham/remove-lerna-file
Remove unnecessary lerna.json file
2023-04-04 09:14:47 -04:00
707b3049ef Remove unnecessary lerna.json file 2023-04-04 07:09:48 -06:00
Zach
a986e4cccb
Merge pull request #33 from cerc-io/murali/output
fix cmd outputs
2023-03-28 08:30:56 -04:00
0xmuralik
61a2aaab0f fix send output 2023-03-27 19:37:16 +05:30
0xmuralik
0c0eb79fa3 eliminate dry code 2023-03-27 18:14:42 +05:30
0xmuralik
8ebb80beed json format 2023-03-27 17:35:47 +05:30
0xmuralik
9b9e8829ec name outputs 2023-03-27 16:58:14 +05:30
0xmuralik
1de17a40ef authority and auction output 2023-03-27 13:58:41 +05:30
0xmuralik
d3020daf2e bond and records outputs 2023-03-27 13:14:02 +05:30
Zach
495bbfdb3c
Merge pull request #21 from cerc-io/integrated_testing
Integrated testing
2023-03-17 14:21:49 -04:00
Zach
64a796c421
Merge pull request #30 from cerc-io/murali/bond
get bond id
2023-03-15 21:26:47 -04:00
0xmuralik
3258e4cfe3 get bond id 2023-03-07 16:27:53 +05:30
Zach
cbcc31d6bd
Merge pull request #23 from cerc-io/0xmuralik-patch-1
Update README.md
2023-03-06 21:10:10 -05:00
Zach
a5e0a6dd22
Merge pull request #24 from cerc-io/0xmuralik-patch-2
Update README.md to fix null auction
2023-03-06 17:50:55 -05:00
Murali Krishna Komatireddy
5e0c6dd649
Update README.md 2023-03-01 14:51:15 +05:30
Murali Krishna Komatireddy
46c333985e
Update README.md 2023-03-01 11:48:50 +05:30
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
31 changed files with 127 additions and 71 deletions

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import { Account, createBid, Registry } from '@cerc-io/laconic-sdk';
import { ensureDir } from 'fs-extra'; import { ensureDir } from 'fs-extra';
import fs from 'fs'; import fs from 'fs';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
const OUT_DIR = 'out'; const OUT_DIR = 'out';
@ -43,7 +43,7 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee); 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)
} }

View File

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

View File

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

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
export const command = 'set [name] [bond-id]'; export const command = 'set [name] [bond-id]';
@ -24,5 +24,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'reserve [name]'; export const command = 'reserve [name]';
@ -31,5 +31,6 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee); 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)
} }

View File

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

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
export const command = 'associate'; export const command = 'associate';
@ -30,5 +30,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
export const command = 'cancel'; export const command = 'cancel';
@ -22,5 +22,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.cancelBond({ id }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
export const command = 'create'; export const command = 'create';
@ -34,6 +34,10 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const bondId = await registry.getNextBondId(privateKey);
const result = await registry.createBond({ denom, amount }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
export const command = 'dissociate'; export const command = 'dissociate';
@ -22,5 +22,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee); 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)
} }

View File

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

View File

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

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../../util';
export const command = 'dissociate'; export const command = 'dissociate';
@ -28,5 +28,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.dissociateRecords({ bondId }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util'; import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../../util';
export const command = 'reassociate'; export const command = 'reassociate';
@ -33,5 +33,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,8 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
import { isNil } from 'lodash';
export const command = 'refill'; export const command = 'refill';
@ -36,5 +37,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
export const command = 'withdraw'; export const command = 'withdraw';
@ -36,5 +36,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee); 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)
} }

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees ,txOutput} from '../../../util';
export const command = 'delete [name]'; export const command = 'delete [name]';
@ -23,5 +23,7 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.deleteName({ crn: name }, privateKey, fee); 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)
} }

View File

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

View File

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

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees,txOutput } from '../../../util';
export const command = 'set [name] [id]'; export const command = 'set [name] [id]';
@ -25,5 +25,7 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee); 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)
} }

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import yaml from 'js-yaml';
import fs from 'fs'; import fs from 'fs';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getGasAndFees, getConnectionInfo } from '../../../util'; import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../../util';
export const command = 'publish'; export const command = 'publish';
@ -40,5 +40,5 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee); const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee);
console.log(verbose ? JSON.stringify(result, undefined, 2) : result.data); txOutput(result,JSON.stringify(result.data,undefined,2),argv.output,argv.verbose)
} }

View File

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

View File

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

View File

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

16
src/util/output.ts Normal file
View File

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

7
watcher.yml Normal file
View File

@ -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