Use registry-sdk in CLI #56
@ -28,7 +28,7 @@
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cerc-io/laconic-sdk": "^0.1.15",
|
||||
"@cerc-io/registry-sdk": "^0.1.15",
|
||||
"fs-extra": "^10.1.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.21",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Account, Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Account, Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import path from 'path';
|
||||
import { Account, createBid, Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Account, createBid, Registry } from '@cerc-io/registry-sdk';
|
||||
import { ensureDir } from 'fs-extra';
|
||||
import fs from 'fs';
|
||||
|
||||
@ -29,7 +29,8 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(chainId, 'Invalid CNS Chain ID.');
|
||||
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
const bidderAddress = account.formattedCosmosAddress;
|
||||
await account.init();
|
||||
const bidderAddress = account.address;
|
||||
const bidAmount = `${quantity}${denom}`;
|
||||
const { reveal, commitHash } = await createBid(chainId, auctionId, bidderAddress, bidAmount);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import path from 'path';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
import fs from 'fs';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
@ -28,7 +28,7 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const reveal = fs.readFileSync(path.resolve(filePath));
|
||||
const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
|
||||
@ -24,7 +24,7 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -31,6 +31,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
|
||||
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -30,6 +30,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -22,6 +22,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.cancelBond({ id }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -22,6 +22,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
|
||||
@ -28,6 +28,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
|
||||
|
||||
@ -33,6 +33,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -36,6 +36,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -36,6 +36,6 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -21,8 +21,8 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.deleteName({ crn: name }, privateKey, fee);
|
||||
const result = await registry.deleteName({ lrn: name }, privateKey, fee);
|
||||
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
||||
|
||||
@ -23,8 +23,8 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee);
|
||||
const result = await registry.setName({ lrn: name, cid: id }, privateKey, fee);
|
||||
|
||||
const success = `{"success":${result.code === 0}}`;
|
||||
const success = '{"success": true}';
|
||||
txOutput(result, success, argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import yaml from 'js-yaml';
|
||||
import fs from 'fs';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../../util';
|
||||
|
||||
@ -47,5 +47,5 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee);
|
||||
|
||||
txOutput(result, JSON.stringify(result.data, undefined, 2), argv.output, argv.verbose);
|
||||
txOutput(result, JSON.stringify(result, undefined, 2), argv.output, argv.verbose);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo } from '../../util';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Account, Registry } from '@cerc-io/laconic-sdk';
|
||||
import { Account, Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, queryOutput } from '../../../util';
|
||||
|
||||
|
@ -10,7 +10,10 @@ export const parseGasAndFees = (gas: string, fees = '') => {
|
||||
.filter(([_, amount, denom]) => (denom && amount))
|
||||
.map(([_, amount, denom]) => ({ denom, amount }));
|
||||
|
||||
return { amount, denom, gas };
|
||||
return {
|
||||
amount: [{ denom, amount }],
|
||||
gas
|
||||
};
|
||||
};
|
||||
|
||||
export const getGasAndFees = (argv: Arguments, config: any = {}) => {
|
||||
|
@ -179,7 +179,7 @@ describe('Test laconic CLI commands', () => {
|
||||
|
||||
// Expect empty object
|
||||
expect(bondOutputObj.length).toEqual(1);
|
||||
expect(bondOutputObj[0]).toEqual({ id: '', owner: '', balance: [] });
|
||||
expect(bondOutputObj[0]).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
@ -398,7 +398,7 @@ describe('Test laconic CLI commands', () => {
|
||||
chainId: CHAIN_ID,
|
||||
auctionId: testAuctionId,
|
||||
bidderAddress: testAccount,
|
||||
bidAmount: `${bidAmount}aphoton`
|
||||
bidAmount: `${bidAmount}photon`
|
||||
});
|
||||
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
|
||||
});
|
||||
@ -481,7 +481,7 @@ describe('Test laconic CLI commands', () => {
|
||||
});
|
||||
|
||||
describe('Name operations', () => {
|
||||
const testName = 'crn://laconic/watcher/erc20';
|
||||
const testName = 'lrn://laconic/watcher/erc20';
|
||||
|
||||
test('laconic cns name set <name> <record_id>', async () => {
|
||||
const result = spawnSync('laconic', ['cns', 'name', 'set', testName, testRecordId]);
|
||||
|
@ -3,7 +3,7 @@ import yaml from 'js-yaml';
|
||||
import { SpawnSyncReturns, spawnSync } from 'child_process';
|
||||
|
||||
export const CHAIN_ID = 'laconic_9000-1';
|
||||
export const TOKEN_TYPE = 'aphoton';
|
||||
export const TOKEN_TYPE = 'photon';
|
||||
|
||||
export const AUCTION_FEES = {
|
||||
commit: 1000000,
|
||||
@ -21,7 +21,6 @@ export function checkResultAndRetrieveOutput (result: SpawnSyncReturns<Buffer>):
|
||||
|
||||
const output = result.stdout.toString().trim();
|
||||
expect(output.length).toBeGreaterThan(0);
|
||||
|
||||
return JSON.parse(output);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ services:
|
||||
bondId:
|
||||
chainId: $cosmos_chain_id
|
||||
gas: 200000
|
||||
fees: 200000aphoton
|
||||
fees: 200000photon
|
||||
EOL
|
||||
)
|
||||
echo "$config" > "$config_file"
|
||||
|
33
yarn.lock
33
yarn.lock
@ -302,39 +302,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@cerc-io/laconic-sdk@^0.1.15":
|
||||
version "0.1.15"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Flaconic-sdk/-/0.1.15/laconic-sdk-0.1.15.tgz#1011a07933c6f1525e05e1ba7dd6a4e4df9b6edb"
|
||||
integrity sha512-Ifl4JUGpckZsu2RkaGyGlObpu9B9GhwFVoDCt8WM9ApdtFnGEVSbDzRuh4f2vLj9WaZkbfdSI/Xci1Fugj3lZg==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.28.1"
|
||||
"@cosmjs/crypto" "^0.28.1"
|
||||
"@cosmjs/encoding" "^0.28.1"
|
||||
"@ipld/dag-cbor" "^7.0.1"
|
||||
"@ipld/dag-json" "^8.0.9"
|
||||
"@metamask/eth-sig-util" "^4.0.0"
|
||||
"@tharsis/address-converter" "^0.1.7"
|
||||
"@tharsis/eip712" "^0.2.1"
|
||||
"@tharsis/proto" "^0.1.16"
|
||||
"@tharsis/provider" "^0.2.4"
|
||||
"@tharsis/transactions" "^0.2.2"
|
||||
axios "^0.26.1"
|
||||
bip32 "3.0.1"
|
||||
bip39 "^3.0.4"
|
||||
canonical-json "^0.0.4"
|
||||
ethers "^5.6.2"
|
||||
evmosjs "^0.2.5"
|
||||
graphql.js "^0.6.8"
|
||||
js-sha256 "^0.9.0"
|
||||
js-yaml "^3.14.1"
|
||||
jsonschema "^1.4.0"
|
||||
lodash "^4.17.21"
|
||||
multiformats "^9.5.4"
|
||||
node-yaml "^4.0.1"
|
||||
secp256k1 "^4.0.1"
|
||||
semver "^7.3.5"
|
||||
tiny-secp256k1 "^1.1.6"
|
||||
|
||||
"@cosmjs/amino@^0.28.1":
|
||||
version "0.28.4"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.28.4.tgz#9315f6876dba80148cf715ced44d1dc7a9b68b94"
|
||||
|
Loading…
Reference in New Issue
Block a user