Add commands for bond and records associate/dissociate
This commit is contained in:
parent
1133ac774c
commit
72c98e14a1
@ -13,7 +13,7 @@
|
|||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chiba-clonk-client": "https://github.com/vulcanize/chiba-clonk-client.git#cf7e47cde72e6807244bae7101aeb25342fc5588",
|
"chiba-clonk-client": "https://github.com/vulcanize/chiba-clonk-client.git#ec31da8cdea79170a87caf6124d9c12cd54dfbe4",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lodash-clean": "^2.2.3",
|
"lodash-clean": "^2.2.3",
|
||||||
|
34
src/cmds/cns-cmds/bond-cmds/associate.ts
Normal file
34
src/cmds/cns-cmds/bond-cmds/associate.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { Arguments } from 'yargs';
|
||||||
|
import assert from 'assert';
|
||||||
|
import { Registry } from 'chiba-clonk-client';
|
||||||
|
|
||||||
|
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||||
|
|
||||||
|
export const command = 'associate';
|
||||||
|
|
||||||
|
export const desc = 'Associate record with bond.';
|
||||||
|
|
||||||
|
export const builder = {
|
||||||
|
'bond-id': {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handler = async (argv: Arguments) => {
|
||||||
|
const id = argv.id as string;
|
||||||
|
const bondId = argv.bondId as string;
|
||||||
|
assert(id, 'Invalid Record ID.');
|
||||||
|
assert(bondId, 'Invalid Bond 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(privateKey, 'Invalid Transaction Key.');
|
||||||
|
assert(chainId, 'Invalid CNS Chain ID.');
|
||||||
|
|
||||||
|
const registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||||
|
const fee = getGasAndFees(argv, cnsConfig);
|
||||||
|
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
|
||||||
|
console.log(JSON.stringify(result, undefined, 2));
|
||||||
|
}
|
26
src/cmds/cns-cmds/bond-cmds/dissociate.ts
Normal file
26
src/cmds/cns-cmds/bond-cmds/dissociate.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { Arguments } from 'yargs';
|
||||||
|
import assert from 'assert';
|
||||||
|
import { Registry } from 'chiba-clonk-client';
|
||||||
|
|
||||||
|
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../util';
|
||||||
|
|
||||||
|
export const command = 'dissociate';
|
||||||
|
|
||||||
|
export const desc = 'Dissociate record from bond.';
|
||||||
|
|
||||||
|
export const handler = async (argv: Arguments) => {
|
||||||
|
const id = argv.id as string;
|
||||||
|
assert(id, 'Invalid Record 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(privateKey, 'Invalid Transaction Key.');
|
||||||
|
assert(chainId, 'Invalid CNS Chain ID.');
|
||||||
|
|
||||||
|
const registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||||
|
const fee = getGasAndFees(argv, cnsConfig);
|
||||||
|
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
|
||||||
|
console.log(JSON.stringify(result, undefined, 2));
|
||||||
|
}
|
32
src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts
Normal file
32
src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Arguments } from 'yargs';
|
||||||
|
import assert from 'assert';
|
||||||
|
import { Registry } from 'chiba-clonk-client';
|
||||||
|
|
||||||
|
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
|
||||||
|
|
||||||
|
export const command = 'dissociate';
|
||||||
|
|
||||||
|
export const desc = 'Dissociate all records from bond.';
|
||||||
|
|
||||||
|
export const builder = {
|
||||||
|
'bond-id': {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handler = async (argv: Arguments) => {
|
||||||
|
const bondId = argv.bondId as string;
|
||||||
|
assert(bondId, 'Invalid Bond 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(privateKey, 'Invalid Transaction Key.');
|
||||||
|
assert(chainId, 'Invalid CNS Chain ID.');
|
||||||
|
|
||||||
|
const registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||||
|
const fee = getGasAndFees(argv, cnsConfig);
|
||||||
|
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
|
||||||
|
console.log(JSON.stringify(result, undefined, 2));
|
||||||
|
}
|
37
src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts
Normal file
37
src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Arguments } from 'yargs';
|
||||||
|
import assert from 'assert';
|
||||||
|
import { Registry } from 'chiba-clonk-client';
|
||||||
|
|
||||||
|
import { getConfig, getConnectionInfo, getGasAndFees } from '../../../../util';
|
||||||
|
|
||||||
|
export const command = 'reassociate';
|
||||||
|
|
||||||
|
export const desc = 'Reassociate records with new bond.';
|
||||||
|
|
||||||
|
export const builder = {
|
||||||
|
'old-bond-id': {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
'new-bond-id': {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handler = async (argv: Arguments) => {
|
||||||
|
const oldBondId = argv.oldBondId as string;
|
||||||
|
const newBondId = argv.newBondId as string;
|
||||||
|
assert(oldBondId, 'Invalid Old Bond ID.');
|
||||||
|
assert(newBondId, 'Invalid New Bond 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(privateKey, 'Invalid Transaction Key.');
|
||||||
|
assert(chainId, 'Invalid CNS Chain ID.');
|
||||||
|
|
||||||
|
const registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||||
|
const fee = getGasAndFees(argv, cnsConfig);
|
||||||
|
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
|
||||||
|
console.log(JSON.stringify(result, undefined, 2));
|
||||||
|
}
|
10
src/cmds/cns-cmds/bond-cmds/records.ts
Normal file
10
src/cmds/cns-cmds/bond-cmds/records.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import yargs from 'yargs';
|
||||||
|
|
||||||
|
export const command = 'records';
|
||||||
|
|
||||||
|
export const desc = 'Bond records operations.';
|
||||||
|
|
||||||
|
exports.builder = (yargs: yargs.Argv) => {
|
||||||
|
return yargs.commandDir('records-cmds')
|
||||||
|
.demandCommand();
|
||||||
|
}
|
@ -714,9 +714,9 @@ chalk@^2.4.1:
|
|||||||
escape-string-regexp "^1.0.5"
|
escape-string-regexp "^1.0.5"
|
||||||
supports-color "^5.3.0"
|
supports-color "^5.3.0"
|
||||||
|
|
||||||
"chiba-clonk-client@https://github.com/vulcanize/chiba-clonk-client.git#cf7e47cde72e6807244bae7101aeb25342fc5588":
|
"chiba-clonk-client@https://github.com/vulcanize/chiba-clonk-client.git#ec31da8cdea79170a87caf6124d9c12cd54dfbe4":
|
||||||
version "0.1.0"
|
version "0.1.0"
|
||||||
resolved "https://github.com/vulcanize/chiba-clonk-client.git#cf7e47cde72e6807244bae7101aeb25342fc5588"
|
resolved "https://github.com/vulcanize/chiba-clonk-client.git#ec31da8cdea79170a87caf6124d9c12cd54dfbe4"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cosmjs/amino" "^0.28.1"
|
"@cosmjs/amino" "^0.28.1"
|
||||||
"@cosmjs/crypto" "^0.28.1"
|
"@cosmjs/crypto" "^0.28.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user