Rename cns to registry
This commit is contained in:
parent
a33445aa4d
commit
c696274996
@ -1,5 +1,5 @@
|
|||||||
services:
|
services:
|
||||||
cns:
|
registry:
|
||||||
restEndpoint: 'http://localhost:1317'
|
restEndpoint: 'http://localhost:1317'
|
||||||
gqlEndpoint: 'http://localhost:9473/api'
|
gqlEndpoint: 'http://localhost:9473/api'
|
||||||
userKey:
|
userKey:
|
||||||
|
@ -11,11 +11,11 @@ export const desc = 'Get account.';
|
|||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
let address = argv.address as string;
|
let address = argv.address as string;
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
if (!address && privateKey) {
|
if (!address && privateKey) {
|
||||||
address = new Account(Buffer.from(privateKey, 'hex')).address;
|
address = new Account(Buffer.from(privateKey, 'hex')).address;
|
@ -21,12 +21,12 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(quantity, 'Invalid token quantity.');
|
assert(quantity, 'Invalid token quantity.');
|
||||||
assert(denom, 'Invalid token type.');
|
assert(denom, 'Invalid token type.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
@ -41,7 +41,7 @@ export const handler = async (argv: Arguments) => {
|
|||||||
fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2));
|
fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2));
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
|
|
||||||
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee);
|
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee);
|
||||||
const revealFile = `{"reveal_file":"${revealFilePath}"}`;
|
const revealFile = `{"reveal_file":"${revealFilePath}"}`;
|
@ -16,15 +16,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(auctionId, 'Invalid auction ID.');
|
assert(auctionId, 'Invalid auction ID.');
|
||||||
assert(filePath, 'Invalid reveal file path.');
|
assert(filePath, 'Invalid reveal file path.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
|
|
||||||
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);
|
@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const { id, config } = argv;
|
const { id, config } = argv;
|
||||||
assert(id, 'Invalid auction ID.');
|
assert(id, 'Invalid auction ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(config as string);
|
const { services: { registry: registryConfig } } = getConfig(config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const result = await registry.getAuctionsByIds([id as string]);
|
const result = await registry.getAuctionsByIds([id as string]);
|
@ -14,15 +14,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(name, 'Invalid authority name.');
|
assert(name, 'Invalid authority name.');
|
||||||
assert(bondId, 'Invalid Bond ID.');
|
assert(bondId, 'Invalid Bond ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
|
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
|
|
@ -20,15 +20,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const owner = argv.owner as string;
|
const owner = argv.owner as string;
|
||||||
assert(name, 'Invalid authority name.');
|
assert(name, 'Invalid authority name.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
|
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
|
||||||
|
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const name = argv.name as string;
|
const name = argv.name as string;
|
||||||
assert(name, 'Invalid authority name.');
|
assert(name, 'Invalid authority name.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const result = await registry.lookupAuthorities([name], true);
|
const result = await registry.lookupAuthorities([name], true);
|
@ -20,15 +20,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(id, 'Invalid Record ID.');
|
assert(id, 'Invalid Record ID.');
|
||||||
assert(bondId, 'Invalid Bond ID.');
|
assert(bondId, 'Invalid Bond ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
|
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -12,15 +12,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const id = argv.id as string;
|
const id = argv.id as string;
|
||||||
assert(id, 'Invalid Bond ID.');
|
assert(id, 'Invalid Bond ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.cancelBond({ id }, privateKey, fee);
|
const result = await registry.cancelBond({ id }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -25,15 +25,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(denom, 'Invalid Type.');
|
assert(denom, 'Invalid Type.');
|
||||||
assert(amount, 'Invalid Quantity.');
|
assert(amount, 'Invalid Quantity.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(config as string);
|
const { services: { registry: registryConfig } } = getConfig(config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const bondId = await registry.getNextBondId(privateKey);
|
const bondId = await registry.getNextBondId(privateKey);
|
||||||
const result = await registry.createBond({ denom, amount }, privateKey, fee);
|
const result = await registry.createBond({ denom, amount }, privateKey, fee);
|
||||||
const jsonString = `{"bondId":"${bondId}"}`;
|
const jsonString = `{"bondId":"${bondId}"}`;
|
@ -12,15 +12,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const id = argv.id as string;
|
const id = argv.id as string;
|
||||||
assert(id, 'Invalid Record ID.');
|
assert(id, 'Invalid Record ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
|
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const { id, config } = argv;
|
const { id, config } = argv;
|
||||||
console.assert(id, 'Bond Id is required.');
|
console.assert(id, 'Bond Id is required.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(config as string);
|
const { services: { registry: registryConfig } } = getConfig(config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
@ -15,11 +15,11 @@ export const builder = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
@ -18,15 +18,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const bondId = argv.bondId as string;
|
const bondId = argv.bondId as string;
|
||||||
assert(bondId, 'Invalid Bond ID.');
|
assert(bondId, 'Invalid Bond ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
|
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -23,15 +23,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(oldBondId, 'Invalid Old Bond ID.');
|
assert(oldBondId, 'Invalid Old Bond ID.');
|
||||||
assert(newBondId, 'Invalid New Bond ID.');
|
assert(newBondId, 'Invalid New Bond ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
|
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -26,15 +26,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(denom, 'Invalid Type.');
|
assert(denom, 'Invalid Type.');
|
||||||
assert(amount, 'Invalid Quantity.');
|
assert(amount, 'Invalid Quantity.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
|
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -26,15 +26,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(denom, 'Invalid Type.');
|
assert(denom, 'Invalid Type.');
|
||||||
assert(amount, 'Invalid Quantity.');
|
assert(amount, 'Invalid Quantity.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
|
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
||||||
txOutput(result, success, argv.output, argv.verbose);
|
txOutput(result, success, argv.output, argv.verbose);
|
@ -12,15 +12,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const name = argv.name as string;
|
const name = argv.name as string;
|
||||||
assert(name, 'Invalid Name.');
|
assert(name, 'Invalid Name.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.deleteName({ lrn: name }, privateKey, fee);
|
const result = await registry.deleteName({ lrn: name }, privateKey, fee);
|
||||||
|
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
@ -18,11 +18,11 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const name = argv.name as string;
|
const name = argv.name as string;
|
||||||
assert(name, 'Invalid Name.');
|
assert(name, 'Invalid Name.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const result = await registry.lookupNames([name], argv.history as boolean);
|
const result = await registry.lookupNames([name], argv.history as boolean);
|
@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const name = argv.name as string;
|
const name = argv.name as string;
|
||||||
assert(name, 'Invalid Name.');
|
assert(name, 'Invalid Name.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
@ -14,15 +14,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(name, 'Invalid Name.');
|
assert(name, 'Invalid Name.');
|
||||||
assert(id, 'Invalid Record ID.');
|
assert(id, 'Invalid Record ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
const result = await registry.setName({ lrn: name, cid: id }, privateKey, fee);
|
const result = await registry.setName({ lrn: name, cid: id }, privateKey, fee);
|
||||||
|
|
||||||
const success = '{"success": true}';
|
const success = '{"success": true}';
|
@ -12,11 +12,11 @@ export const handler = async (argv: Arguments) => {
|
|||||||
const { id, config } = argv;
|
const { id, config } = argv;
|
||||||
assert(id, 'Invalid Record ID.');
|
assert(id, 'Invalid Record ID.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(config as string);
|
const { services: { registry: registryConfig } } = getConfig(config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const result = await registry.getRecordsByIds([id as string]);
|
const result = await registry.getRecordsByIds([id as string]);
|
@ -28,8 +28,8 @@ export const builder = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
const { type, name, bondId, owner, all } = argv;
|
const { type, name, bondId, owner, all } = argv;
|
||||||
const filters: any = {};
|
const filters: any = {};
|
||||||
|
|
||||||
@ -38,9 +38,9 @@ export const handler = async (argv: Arguments) => {
|
|||||||
filters[String(filterArgs[i]).replace(/^-+/, '')] = filterArgs[i + 1];
|
filters[String(filterArgs[i]).replace(/^-+/, '')] = filterArgs[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
@ -18,14 +18,14 @@ export const builder = {
|
|||||||
|
|
||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { txKey, filename, config } = argv;
|
const { txKey, filename, config } = argv;
|
||||||
const { services: { cns: cnsConfig } } = getConfig(config as string);
|
const { services: { registry: registryConfig } } = getConfig(config as string);
|
||||||
const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
|
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(userKey, 'Invalid User Key.');
|
assert(userKey, 'Invalid User Key.');
|
||||||
assert(bondId, 'Invalid Bond ID.');
|
assert(bondId, 'Invalid Bond ID.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
let file = null;
|
let file = null;
|
||||||
if (filename) {
|
if (filename) {
|
||||||
@ -44,7 +44,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, registryConfig);
|
||||||
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey || userKey, fee);
|
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey || userKey, fee);
|
||||||
|
|
||||||
txOutput(result, JSON.stringify(result, undefined, 2), argv.output, argv.verbose);
|
txOutput(result, JSON.stringify(result, undefined, 2), argv.output, argv.verbose);
|
@ -6,14 +6,14 @@ import { getConfig, getConnectionInfo } from '../../util';
|
|||||||
|
|
||||||
export const command = 'status';
|
export const command = 'status';
|
||||||
|
|
||||||
export const desc = 'Get CNS status.';
|
export const desc = 'Get registry status.';
|
||||||
|
|
||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { services: { cns } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cns);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
@ -26,19 +26,19 @@ export const handler = async (argv: Arguments) => {
|
|||||||
assert(denom, 'Invalid Type.');
|
assert(denom, 'Invalid Type.');
|
||||||
assert(amount, 'Invalid Quantity.');
|
assert(amount, 'Invalid Quantity.');
|
||||||
|
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid registry REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||||
assert(privateKey, 'Invalid Transaction Key.');
|
assert(privateKey, 'Invalid Transaction Key.');
|
||||||
assert(chainId, 'Invalid CNS Chain ID.');
|
assert(chainId, 'Invalid registry Chain ID.');
|
||||||
|
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const fromAddress = account.address;
|
const fromAddress = account.address;
|
||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
const fee = getGasAndFees(argv, cnsConfig);
|
const fee = getGasAndFees(argv, registryConfig);
|
||||||
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
|
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
|
||||||
const result = await registry.getAccounts([fromAddress, destinationAddress]);
|
const result = await registry.getAccounts([fromAddress, destinationAddress]);
|
||||||
queryOutput(result, argv.output);
|
queryOutput(result, argv.output);
|
@ -1,8 +1,8 @@
|
|||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
|
|
||||||
export const command = 'cns';
|
export const command = 'registry';
|
||||||
|
|
||||||
export const desc = 'CNS tools';
|
export const desc = 'Registry tools';
|
||||||
|
|
||||||
exports.builder = (yargs: yargs.Argv) => {
|
exports.builder = (yargs: yargs.Argv) => {
|
||||||
return yargs
|
return yargs
|
||||||
@ -17,7 +17,7 @@ exports.builder = (yargs: yargs.Argv) => {
|
|||||||
gas: { type: 'string' },
|
gas: { type: 'string' },
|
||||||
fees: { type: 'string' }
|
fees: { type: 'string' }
|
||||||
})
|
})
|
||||||
.commandDir('cns-cmds')
|
.commandDir('registry-cmds')
|
||||||
.demandCommand()
|
.demandCommand()
|
||||||
.help();
|
.help();
|
||||||
};
|
};
|
155
test/cli.test.ts
155
test/cli.test.ts
@ -31,8 +31,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(errorOutput).toContain('laconic <command>');
|
expect(errorOutput).toContain('laconic <command>');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns', async () => {
|
test('laconic registry', async () => {
|
||||||
const result = spawnSync('laconic', ['cns']);
|
const result = spawnSync('laconic', ['registry']);
|
||||||
expect(result.status).toBe(1);
|
expect(result.status).toBe(1);
|
||||||
|
|
||||||
const output = result.stdout.toString().trim();
|
const output = result.stdout.toString().trim();
|
||||||
@ -40,15 +40,15 @@ describe('Test laconic CLI commands', () => {
|
|||||||
|
|
||||||
// Expect error with usage string
|
// Expect error with usage string
|
||||||
expect(output).toBe('');
|
expect(output).toBe('');
|
||||||
expect(errorOutput).toContain('laconic cns');
|
expect(errorOutput).toContain('laconic registry');
|
||||||
expect(errorOutput).toContain('CNS tools');
|
expect(errorOutput).toContain('Registry tools');
|
||||||
expect(errorOutput).toContain('Commands:');
|
expect(errorOutput).toContain('Commands:');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Break up tests into separate files
|
// TODO: Break up tests into separate files
|
||||||
// TODO: Add tests for CNS commands with all available flags
|
// TODO: Add tests for registry commands with all available flags
|
||||||
|
|
||||||
describe('laconic CNS commands', () => {
|
describe('laconic registry commands', () => {
|
||||||
const testAccount = process.env.TEST_ACCOUNT;
|
const testAccount = process.env.TEST_ACCOUNT;
|
||||||
assert(testAccount, 'TEST_ACCOUNT not set in env');
|
assert(testAccount, 'TEST_ACCOUNT not set in env');
|
||||||
const testAccount2 = 'laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd';
|
const testAccount2 = 'laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd';
|
||||||
@ -58,11 +58,11 @@ describe('Test laconic CLI commands', () => {
|
|||||||
const testRecordFilePath = 'test/data/watcher-record.yml';
|
const testRecordFilePath = 'test/data/watcher-record.yml';
|
||||||
let testAuctionId: string, testRecordId: string, testRecordBondId: string;
|
let testAuctionId: string, testRecordId: string, testRecordBondId: string;
|
||||||
|
|
||||||
test('laconic cns status', async () => {
|
test('laconic registry status', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'status']);
|
const result = spawnSync('laconic', ['registry', 'status']);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expect output object to have CNS status props
|
// Expect output object to have registry status props
|
||||||
expect(outputObj).toHaveProperty('version');
|
expect(outputObj).toHaveProperty('version');
|
||||||
expect(outputObj).toHaveProperty('node');
|
expect(outputObj).toHaveProperty('node');
|
||||||
expect(outputObj).toHaveProperty('node.network', CHAIN_ID);
|
expect(outputObj).toHaveProperty('node.network', CHAIN_ID);
|
||||||
@ -80,8 +80,9 @@ describe('Test laconic CLI commands', () => {
|
|||||||
let bondBalance = 1000000000;
|
let bondBalance = 1000000000;
|
||||||
let bondId: string;
|
let bondId: string;
|
||||||
|
|
||||||
test('laconic cns bond create --type <type> --quantity <quantity> --gas <gas> --fees <fees>', async () => {
|
test('laconic registry bond create --type <type> --quantity <quantity> --gas <gas> --fees <fees>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]);
|
||||||
|
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expect output object to have resultant bond id
|
// Expect output object to have resultant bond id
|
||||||
@ -90,8 +91,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
bondId = outputObj.bondId;
|
bondId = outputObj.bondId;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond list', async () => {
|
test('laconic registry bond list', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'list']);
|
const result = spawnSync('laconic', ['registry', 'bond', 'list']);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected bond
|
// Expected bond
|
||||||
@ -101,8 +102,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toEqual(expectedBond);
|
expect(outputObj[0]).toEqual(expectedBond);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond list --owner <owner_address>', async () => {
|
test('laconic registry bond list --owner <owner_address>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'list', '--owner', bondOwner]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'list', '--owner', bondOwner]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected bond
|
// Expected bond
|
||||||
@ -112,8 +113,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toEqual(expectedBond);
|
expect(outputObj[0]).toEqual(expectedBond);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond get --id <bond_id>', async () => {
|
test('laconic registry bond get --id <bond_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected bond
|
// Expected bond
|
||||||
@ -123,18 +124,18 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toEqual(expectedBond);
|
expect(outputObj[0]).toEqual(expectedBond);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond refill --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
test('laconic registry bond refill --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
||||||
const bondRefillAmount = 1000;
|
const bondRefillAmount = 1000;
|
||||||
bondBalance += bondRefillAmount;
|
bondBalance += bondRefillAmount;
|
||||||
|
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'refill', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondRefillAmount.toString()]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'refill', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondRefillAmount.toString()]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check updated bond
|
// Check updated bond
|
||||||
const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
const bondResult = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]);
|
||||||
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
||||||
|
|
||||||
// Expected bond
|
// Expected bond
|
||||||
@ -144,18 +145,18 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(bondOutputObj[0]).toEqual(expectedBond);
|
expect(bondOutputObj[0]).toEqual(expectedBond);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond withdraw --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
test('laconic registry bond withdraw --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
||||||
const bondWithdrawAmount = 500;
|
const bondWithdrawAmount = 500;
|
||||||
bondBalance -= bondWithdrawAmount;
|
bondBalance -= bondWithdrawAmount;
|
||||||
|
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'withdraw', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondWithdrawAmount.toString()]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'withdraw', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondWithdrawAmount.toString()]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check updated bond
|
// Check updated bond
|
||||||
const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
const bondResult = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]);
|
||||||
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
||||||
|
|
||||||
// Expected bond
|
// Expected bond
|
||||||
@ -166,15 +167,15 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(bondOutputObj[0]).toEqual(expectedBond);
|
expect(bondOutputObj[0]).toEqual(expectedBond);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond cancel --id <bond_id>', async () => {
|
test('laconic registry bond cancel --id <bond_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'cancel', '--id', bondId]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'cancel', '--id', bondId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check updated bond
|
// Check updated bond
|
||||||
const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
const bondResult = spawnSync('laconic', ['registry', 'bond', 'get', '--id', bondId]);
|
||||||
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
||||||
|
|
||||||
// Expect empty object
|
// Expect empty object
|
||||||
@ -186,8 +187,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
describe('Account and tokens operations', () => {
|
describe('Account and tokens operations', () => {
|
||||||
let balanceBeforeSend: number;
|
let balanceBeforeSend: number;
|
||||||
|
|
||||||
test('laconic cns account get --address <account_address>', async () => {
|
test('laconic registry account get --address <account_address>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'account', 'get', '--address', testAccount]);
|
const result = spawnSync('laconic', ['registry', 'account', 'get', '--address', testAccount]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected account
|
// Expected account
|
||||||
@ -203,11 +204,11 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(balanceBeforeSend).toBeLessThan(initialAccountBalance);
|
expect(balanceBeforeSend).toBeLessThan(initialAccountBalance);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns tokens send --address <account_address> --type <token_type> --quantity <quantity>', async () => {
|
test('laconic registry tokens send --address <account_address> --type <token_type> --quantity <quantity>', async () => {
|
||||||
const sendAmount = 1000000000;
|
const sendAmount = 1000000000;
|
||||||
const balanceAfterSend = balanceBeforeSend - sendAmount;
|
const balanceAfterSend = balanceBeforeSend - sendAmount;
|
||||||
|
|
||||||
const result = spawnSync('laconic', ['cns', 'tokens', 'send', '--address', testAccount2, '--type', TOKEN_TYPE, '--quantity', sendAmount.toString()]);
|
const result = spawnSync('laconic', ['registry', 'tokens', 'send', '--address', testAccount2, '--type', TOKEN_TYPE, '--quantity', sendAmount.toString()]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected acconts
|
// Expected acconts
|
||||||
@ -225,11 +226,10 @@ describe('Test laconic CLI commands', () => {
|
|||||||
const gas = 250000;
|
const gas = 250000;
|
||||||
const bondBalance = 1000000000;
|
const bondBalance = 1000000000;
|
||||||
|
|
||||||
test('laconic cns record publish --filename <record_file> --bond-id <bond_id> --gas <gas>', async () => {
|
test('laconic registry record publish --filename <record_file> --bond-id <bond_id> --gas <gas>', async () => {
|
||||||
// Create a new bond to be associated with the record
|
// Create a new bond to be associated with the record
|
||||||
({ bondId: testRecordBondId } = createBond(bondBalance));
|
({ bondId: testRecordBondId } = createBond(bondBalance));
|
||||||
|
const result = spawnSync('laconic', ['registry', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString()]);
|
||||||
const result = spawnSync('laconic', ['cns', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString()]);
|
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expect output object to resultant bond id
|
// Expect output object to resultant bond id
|
||||||
@ -238,8 +238,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
testRecordId = outputObj.id;
|
testRecordId = outputObj.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns record list', async () => {
|
test('laconic registry record list', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'record', 'list']);
|
const result = spawnSync('laconic', ['registry', 'record', 'list']);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected record
|
// Expected record
|
||||||
@ -253,8 +253,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0].owners.length).toEqual(1);
|
expect(outputObj[0].owners.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns record get --id <record_id>', async () => {
|
test('laconic registry record get --id <record_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
|
const result = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected record
|
// Expected record
|
||||||
@ -267,14 +267,14 @@ describe('Test laconic CLI commands', () => {
|
|||||||
describe('Bond records operations', () => {
|
describe('Bond records operations', () => {
|
||||||
let testRecordBondId2: string;
|
let testRecordBondId2: string;
|
||||||
|
|
||||||
test('laconic cns bond dissociate --id <record_id>', async () => {
|
test('laconic registry bond dissociate --id <record_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'dissociate', '--id', testRecordId]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'dissociate', '--id', testRecordId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
|
const recordResult = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]);
|
||||||
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
|
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
|
||||||
|
|
||||||
// Expected record
|
// Expected record
|
||||||
@ -284,17 +284,17 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
|
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond associate --id <record_id> --bond-id <bond_id>', async () => {
|
test('laconic registry bond associate --id <record_id> --bond-id <bond_id>', async () => {
|
||||||
// Create a new bond to be associated with the record
|
// Create a new bond to be associated with the record
|
||||||
({ bondId: testRecordBondId2 } = createBond(bondBalance));
|
({ bondId: testRecordBondId2 } = createBond(bondBalance));
|
||||||
|
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'associate', '--id', testRecordId, '--bond-id', testRecordBondId2]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'associate', '--id', testRecordId, '--bond-id', testRecordBondId2]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
|
const recordResult = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]);
|
||||||
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
|
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
|
||||||
|
|
||||||
// Expected record
|
// Expected record
|
||||||
@ -304,14 +304,14 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
|
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns bond records reassociate --old-bond-id <old_bond_id> --new-bond-id <new_bond_id>', async () => {
|
test('laconic registry bond records reassociate --old-bond-id <old_bond_id> --new-bond-id <new_bond_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'records', 'reassociate', '--old-bond-id', testRecordBondId2, '--new-bond-id', testRecordBondId]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'records', 'reassociate', '--old-bond-id', testRecordBondId2, '--new-bond-id', testRecordBondId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
|
const recordResult = spawnSync('laconic', ['registry', 'record', 'get', '--id', testRecordId]);
|
||||||
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
|
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
|
||||||
|
|
||||||
// Expected record
|
// Expected record
|
||||||
@ -324,18 +324,17 @@ describe('Test laconic CLI commands', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Name authority operations (pre auction)', () => {
|
describe('Name authority operations (pre auction)', () => {
|
||||||
test('laconic cns authority reserve <authority_name>', async () => {
|
test('laconic registry authority reserve <authority_name>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testAuthorityName]);
|
const result = spawnSync('laconic', ['registry', 'authority', 'reserve', testAuthorityName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expect result
|
// Expect result
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns authority whois <authority_name>', async () => {
|
test('laconic registry authority whois <authority_name>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]);
|
const result = spawnSync('laconic', ['registry', 'authority', 'whois', testAuthorityName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected authority (still in auction)
|
// Expected authority (still in auction)
|
||||||
const expectedAuthority = getAuthorityObj({ owner: '', status: 'auction', auction: getAuctionObj({ owner: testAccount }) });
|
const expectedAuthority = getAuthorityObj({ owner: '', status: 'auction', auction: getAuctionObj({ owner: testAccount }) });
|
||||||
|
|
||||||
@ -352,8 +351,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
const bidAmount = 25000000;
|
const bidAmount = 25000000;
|
||||||
let bidRevealFilePath: string;
|
let bidRevealFilePath: string;
|
||||||
|
|
||||||
test('laconic cns auction get <auction_id>', async () => {
|
test('laconic registry auction get <auction_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]);
|
const result = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected auction (still in commit stage)
|
// Expected auction (still in commit stage)
|
||||||
@ -363,8 +362,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toMatchObject(expectedAuction);
|
expect(outputObj[0]).toMatchObject(expectedAuction);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns auction bid commit <auction_id> <quantity> <type>', async () => {
|
test('laconic registry auction bid commit <auction_id> <quantity> <type>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]);
|
const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
@ -373,11 +372,11 @@ describe('Test laconic CLI commands', () => {
|
|||||||
bidRevealFilePath = outputObj.reveal_file;
|
bidRevealFilePath = outputObj.reveal_file;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns auction bid reveal <auction_id> <file_path>', async () => {
|
test('laconic registry auction bid reveal <auction_id> <file_path>', async () => {
|
||||||
// Wait for auction commits duration (60s)
|
// Wait for auction commits duration (60s)
|
||||||
await delay(AUCTION_COMMIT_DURATION * 1000);
|
await delay(AUCTION_COMMIT_DURATION * 1000);
|
||||||
|
|
||||||
const auctionResult = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]);
|
const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
|
||||||
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
|
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
|
||||||
|
|
||||||
const expectedAuction = getAuctionObj({ owner: testAccount, status: 'reveal' });
|
const expectedAuction = getAuctionObj({ owner: testAccount, status: 'reveal' });
|
||||||
@ -387,7 +386,7 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(auctionOutputObj[0].bids[0]).toMatchObject(expectedBid);
|
expect(auctionOutputObj[0].bids[0]).toMatchObject(expectedBid);
|
||||||
|
|
||||||
// Reveal bid
|
// Reveal bid
|
||||||
const result = spawnSync('laconic', ['cns', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]);
|
const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
@ -407,11 +406,11 @@ describe('Test laconic CLI commands', () => {
|
|||||||
const testSubAuthorityName = 'echo.laconic';
|
const testSubAuthorityName = 'echo.laconic';
|
||||||
const testSubAuthorityName2 = 'kube.laconic';
|
const testSubAuthorityName2 = 'kube.laconic';
|
||||||
|
|
||||||
test('laconic cns authority whois <authority_name>', async () => {
|
test('laconic registry authority whois <authority_name>', async () => {
|
||||||
// Wait for auction reveals duration (60s)
|
// Wait for auction reveals duration (60s)
|
||||||
await delay(AUCTION_REVEAL_DURATION * 1000);
|
await delay(AUCTION_REVEAL_DURATION * 1000);
|
||||||
|
|
||||||
const result = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]);
|
const result = spawnSync('laconic', ['registry', 'authority', 'whois', testAuthorityName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected authority (active)
|
// Expected authority (active)
|
||||||
@ -421,19 +420,19 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toMatchObject(expectedAuthority);
|
expect(outputObj[0]).toMatchObject(expectedAuthority);
|
||||||
}, (AUCTION_REVEAL_DURATION + 5) * 1000);
|
}, (AUCTION_REVEAL_DURATION + 5) * 1000);
|
||||||
|
|
||||||
test('laconic cns authority bond set laconic <bond_id>', async () => {
|
test('laconic registry authority bond set laconic <bond_id>', async () => {
|
||||||
// Create a new bond to be set on the authority
|
// Create a new bond to be set on the authority
|
||||||
const bondBalance = 1000000000;
|
const bondBalance = 1000000000;
|
||||||
const { bondId } = createBond(bondBalance);
|
const { bondId } = createBond(bondBalance);
|
||||||
|
|
||||||
const result = spawnSync('laconic', ['cns', 'authority', 'bond', 'set', testAuthorityName, bondId]);
|
const result = spawnSync('laconic', ['registry', 'authority', 'bond', 'set', testAuthorityName, bondId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check updated authority
|
// Check updated authority
|
||||||
const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]);
|
const authorityResult = spawnSync('laconic', ['registry', 'authority', 'whois', testAuthorityName]);
|
||||||
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
||||||
|
|
||||||
// Expected authority (active with bond)
|
// Expected authority (active with bond)
|
||||||
@ -443,15 +442,15 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns authority reserve <sub_authority> (same owner)', async () => {
|
test('laconic registry authority reserve <sub_authority> (same owner)', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testSubAuthorityName]);
|
const result = spawnSync('laconic', ['registry', 'authority', 'reserve', testSubAuthorityName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check updated authority
|
// Check updated authority
|
||||||
const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testSubAuthorityName]);
|
const authorityResult = spawnSync('laconic', ['registry', 'authority', 'whois', testSubAuthorityName]);
|
||||||
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
||||||
|
|
||||||
// Expected authority (active with bond)
|
// Expected authority (active with bond)
|
||||||
@ -461,15 +460,15 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns authority reserve <sub_authority> --owner <owner_address> (different owner)', async () => {
|
test('laconic registry authority reserve <sub_authority> --owner <owner_address> (different owner)', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testSubAuthorityName2, '--owner', testAccount2]);
|
const result = spawnSync('laconic', ['registry', 'authority', 'reserve', testSubAuthorityName2, '--owner', testAccount2]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check updated authority
|
// Check updated authority
|
||||||
const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testSubAuthorityName2]);
|
const authorityResult = spawnSync('laconic', ['registry', 'authority', 'whois', testSubAuthorityName2]);
|
||||||
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
||||||
|
|
||||||
// Expected authority (active with bond)
|
// Expected authority (active with bond)
|
||||||
@ -483,16 +482,16 @@ describe('Test laconic CLI commands', () => {
|
|||||||
describe('Name operations', () => {
|
describe('Name operations', () => {
|
||||||
const testName = 'lrn://laconic/watcher/erc20';
|
const testName = 'lrn://laconic/watcher/erc20';
|
||||||
|
|
||||||
test('laconic cns name set <name> <record_id>', async () => {
|
test('laconic registry name set <name> <record_id>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'name', 'set', testName, testRecordId]);
|
const result = spawnSync('laconic', ['registry', 'name', 'set', testName, testRecordId]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns name lookup <name>', async () => {
|
test('laconic registry name lookup <name>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'name', 'lookup', testName]);
|
const result = spawnSync('laconic', ['registry', 'name', 'lookup', testName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
@ -500,8 +499,8 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toMatchObject({ latest: { id: testRecordId } });
|
expect(outputObj[0]).toMatchObject({ latest: { id: testRecordId } });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns name resolve <name>', async () => {
|
test('laconic registry name resolve <name>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'name', 'resolve', testName]);
|
const result = spawnSync('laconic', ['registry', 'name', 'resolve', testName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected resolved record
|
// Expected resolved record
|
||||||
@ -511,15 +510,15 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(outputObj[0]).toMatchObject(expectedRecord);
|
expect(outputObj[0]).toMatchObject(expectedRecord);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns name delete <name>', async () => {
|
test('laconic registry name delete <name>', async () => {
|
||||||
const result = spawnSync('laconic', ['cns', 'name', 'delete', testName]);
|
const result = spawnSync('laconic', ['registry', 'name', 'delete', testName]);
|
||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected output
|
// Expected output
|
||||||
expect(outputObj).toEqual({ success: true });
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
// Check that name doesn't resolve
|
// Check that name doesn't resolve
|
||||||
const resolveResult = spawnSync('laconic', ['cns', 'name', 'resolve', testName]);
|
const resolveResult = spawnSync('laconic', ['registry', 'name', 'resolve', testName]);
|
||||||
const resolveOutputObj = checkResultAndRetrieveOutput(resolveResult);
|
const resolveOutputObj = checkResultAndRetrieveOutput(resolveResult);
|
||||||
expect(resolveOutputObj.length).toEqual(0);
|
expect(resolveOutputObj.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ export function checkResultAndRetrieveOutput (result: SpawnSyncReturns<Buffer>):
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createBond (quantity: number): { bondId: string } {
|
export function createBond (quantity: number): { bondId: string } {
|
||||||
const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', quantity.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]);
|
const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', quantity.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]);
|
||||||
const output = result.stdout.toString().trim();
|
const output = result.stdout.toString().trim();
|
||||||
|
|
||||||
return JSON.parse(output);
|
return JSON.parse(output);
|
||||||
|
@ -15,7 +15,7 @@ laconic2d_gql_endpoint=http://127.0.0.1:9473/api
|
|||||||
config_file="config.yml"
|
config_file="config.yml"
|
||||||
config=$(cat <<EOL
|
config=$(cat <<EOL
|
||||||
services:
|
services:
|
||||||
cns:
|
registry:
|
||||||
restEndpoint: $laconic2d_rpc_endpoint
|
restEndpoint: $laconic2d_rpc_endpoint
|
||||||
gqlEndpoint: $laconic2d_gql_endpoint
|
gqlEndpoint: $laconic2d_gql_endpoint
|
||||||
userKey: $laconic2d_key
|
userKey: $laconic2d_key
|
||||||
|
Loading…
Reference in New Issue
Block a user