Compare commits
6
Commits
v0.2.2
...
release-v0.2.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf4bf5ed42 | ||
|
|
6055da62c7 | ||
|
|
aa46032bda | ||
|
|
c67961869b | ||
|
|
acd4791355 | ||
|
|
30654bb0ef |
@@ -54,7 +54,15 @@ Registering records in registry requires an account. To get account private key
|
||||
laconicd keys export alice --keyring-backend test --unarmored-hex --unsafe
|
||||
```
|
||||
|
||||
In `config.yml` file assign the account private key to `userKey`.
|
||||
In `config.yml` file assign the account private key to `userKey`:
|
||||
|
||||
```yml
|
||||
services:
|
||||
registry:
|
||||
..
|
||||
userKey: "<user-key>"
|
||||
..
|
||||
```
|
||||
|
||||
## Gas and Fees
|
||||
|
||||
@@ -133,32 +141,61 @@ Send tokens:
|
||||
|
||||
```bash
|
||||
$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type alnt --quantity 1000000000
|
||||
[
|
||||
{
|
||||
"address": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
|
||||
"pubKey": "A68/q7/xazFzNj+rrvE07ALxkMgqw1ugL35VECkWAYvt",
|
||||
"number": "0",
|
||||
"sequence": "16",
|
||||
"balance": [
|
||||
{
|
||||
"type": "alnt",
|
||||
"quantity": "99998999999999997973999700"
|
||||
}
|
||||
]
|
||||
{
|
||||
"tx": {
|
||||
"hash": "977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC",
|
||||
"height": 343369,
|
||||
"index": 0,
|
||||
"code": 0,
|
||||
"log": "",
|
||||
"sender": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
|
||||
"recipient": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"amount": "1000000000alnt"
|
||||
},
|
||||
{
|
||||
"address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"pubKey": null,
|
||||
"number": "12",
|
||||
"sequence": "0",
|
||||
"balance": [
|
||||
{
|
||||
"type": "alnt",
|
||||
"quantity": "1000000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"accounts": [
|
||||
{
|
||||
"address": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
|
||||
"pubKey": "A68/q7/xazFzNj+rrvE07ALxkMgqw1ugL35VECkWAYvt",
|
||||
"number": "0",
|
||||
"sequence": "16",
|
||||
"balance": [
|
||||
{
|
||||
"type": "alnt",
|
||||
"quantity": "99998999999999997973999700"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"pubKey": null,
|
||||
"number": "12",
|
||||
"sequence": "0",
|
||||
"balance": [
|
||||
{
|
||||
"type": "alnt",
|
||||
"quantity": "1000000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Get token TX details:
|
||||
|
||||
```bash
|
||||
$ laconic registry tokens gettx --hash 977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC
|
||||
{
|
||||
"hash": "977152CBE474613E1BBAFEF286F12134829FAF3C9E7C8349149DE3E687B816FC",
|
||||
"height": 343369,
|
||||
"index": 0,
|
||||
"code": 0,
|
||||
"log": "",
|
||||
"sender": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
|
||||
"recipient": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"amount": "1000000000alnt",
|
||||
"raw": "0A91010A8E010A1C2F636F736D6F732E62616E6B2E763162657461312E4D736753656E64126E0A2E6C61636F6E696331347763303777613372377270707275343367396A786B7A68716E686D76666D34646765793673122E6C61636F6E6963317971706337637966657470676D71746B6B30756B657675676561617539703063776D6A6C73751A0C0A04616C6E7412043130303012680A500A460A1F2F636F736D6F732E63727970746F2E736563703235366B312E5075624B657912230A2102F3A1D077638F9FD828C4CF126FE82E0BE98388083F5BC1E1DD4D84132AEBFF8112040A020801185A12140A0E0A04616C6E7412063430303030301080B5181A4088DF7BA4B63EA68E185AB2887C9EC29EBC4158874BC037816B8494AD36D3B2433B5223CECC336D4624BB7FEF4DBB4A8B5F4707ACD8E55443312009E9473DF821"
|
||||
}
|
||||
```
|
||||
|
||||
Create record (generic):
|
||||
@@ -351,6 +388,18 @@ Create sub-authority (custom owner for sub-authority):
|
||||
$ laconic registry authority reserve kube.laconic --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
|
||||
```
|
||||
|
||||
Get all the authorities:
|
||||
|
||||
```bash
|
||||
$ laconic registry authority list
|
||||
```
|
||||
|
||||
Get all the authorities by owner:
|
||||
|
||||
```bash
|
||||
$ laconic registry authority list --owner laconic1zayjut6pd4xy9dguut56v55hktzmeq6r777hmd
|
||||
```
|
||||
|
||||
Set name:
|
||||
|
||||
```bash
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-registry-cli",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.7",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
||||
"author": "",
|
||||
@@ -29,7 +29,7 @@
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cerc-io/registry-sdk": "^0.2.5",
|
||||
"@cerc-io/registry-sdk": "^0.2.8",
|
||||
"fs-extra": "^10.1.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@@ -18,7 +18,9 @@ export const handler = async (argv: Arguments) => {
|
||||
assert(chainId, 'Invalid registry Chain ID.');
|
||||
|
||||
if (!address && privateKey) {
|
||||
address = new Account(Buffer.from(privateKey, 'hex')).address;
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
await account.init();
|
||||
address = account.address;
|
||||
}
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
|
||||
export const command = 'list';
|
||||
|
||||
export const desc = 'List authorities (optionally by owner).';
|
||||
|
||||
export const builder = {
|
||||
owner: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||
assert(chainId, 'Invalid registry Chain ID.');
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
const result = await registry.getAuthorities(argv.owner as string);
|
||||
|
||||
queryOutput(result, argv.output);
|
||||
};
|
||||
@@ -23,8 +23,15 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
|
||||
let result: any;
|
||||
|
||||
const { owner } = argv;
|
||||
const result = await registry.queryBonds({ owner });
|
||||
if (owner) {
|
||||
const [bondsByOwnerResult] = await registry.queryBondsByOwner([String(owner)]);
|
||||
result = bondsByOwnerResult.bonds;
|
||||
} else {
|
||||
result = await registry.queryBonds();
|
||||
}
|
||||
|
||||
queryOutput(result, argv.output);
|
||||
};
|
||||
|
||||
@@ -24,13 +24,23 @@ export const builder = {
|
||||
all: {
|
||||
type: 'boolean',
|
||||
default: false
|
||||
},
|
||||
refs: {
|
||||
type: 'boolean',
|
||||
default: false
|
||||
},
|
||||
limit: {
|
||||
type: 'number'
|
||||
},
|
||||
offset: {
|
||||
type: 'number'
|
||||
}
|
||||
};
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||
const { type, name, bondId, owner, all } = argv;
|
||||
const { type, name, bondId, owner, all, refs, limit, offset } = argv;
|
||||
const filters: any = {};
|
||||
|
||||
const filterArgs = argv._.slice(3);
|
||||
@@ -44,7 +54,7 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
|
||||
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean);
|
||||
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean, refs as boolean, limit as number, offset as number);
|
||||
|
||||
// Apply ex post filters.
|
||||
if (bondId) {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Arguments } from 'yargs';
|
||||
import assert from 'assert';
|
||||
import { Account, Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
||||
import { IndexedTx } from '@cosmjs/stargate/build/stargateclient';
|
||||
|
||||
export const command = 'gettx';
|
||||
|
||||
export const desc = 'Get token transfer tx info.';
|
||||
|
||||
export const builder = {
|
||||
hash: {
|
||||
type: 'string'
|
||||
}
|
||||
};
|
||||
|
||||
export const handler = async (argv: Arguments) => {
|
||||
const hash = argv.hash as string;
|
||||
|
||||
assert(hash, 'Invalid tx hash.');
|
||||
|
||||
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||
const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
||||
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
||||
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
||||
assert(privateKey, 'Invalid Transaction Key.');
|
||||
assert(chainId, 'Invalid registry Chain ID.');
|
||||
|
||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||
await account.init();
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
const laconicClient = await registry.getLaconicClient(account);
|
||||
|
||||
const txResponse: IndexedTx | null = await laconicClient.getTx(hash);
|
||||
if (txResponse) {
|
||||
const transfer = txResponse.events.find(e => e.type === 'transfer' ? e.attributes.find(a => a.key === 'msg_index') : null);
|
||||
const output = {
|
||||
hash: txResponse.hash,
|
||||
height: txResponse.height,
|
||||
index: txResponse.txIndex,
|
||||
code: txResponse.code,
|
||||
log: txResponse.rawLog,
|
||||
sender: transfer?.attributes.find(a => a.key === 'sender')?.value,
|
||||
recipient: transfer?.attributes.find(a => a.key === 'recipient')?.value,
|
||||
amount: transfer?.attributes.find(a => a.key === 'amount')?.value,
|
||||
raw: Buffer.from(txResponse.tx).toString('hex').toUpperCase()
|
||||
};
|
||||
queryOutput(output, argv.output);
|
||||
} else {
|
||||
queryOutput(null, argv.output);
|
||||
}
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import assert from 'assert';
|
||||
import { Account, Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getConnectionInfo, getGasAndFees, queryOutput } from '../../../util';
|
||||
import { DeliverTxResponse } from '@cosmjs/stargate';
|
||||
|
||||
export const command = 'send';
|
||||
|
||||
@@ -38,8 +39,38 @@ export const handler = async (argv: Arguments) => {
|
||||
const fromAddress = account.address;
|
||||
|
||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
const laconicClient = await registry.getLaconicClient(account);
|
||||
const fee = getGasAndFees(argv, registryConfig);
|
||||
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
|
||||
const result = await registry.getAccounts([fromAddress, destinationAddress]);
|
||||
queryOutput(result, argv.output);
|
||||
|
||||
const txResponse: DeliverTxResponse = await laconicClient.sendTokens(
|
||||
account.address,
|
||||
destinationAddress,
|
||||
[
|
||||
{
|
||||
denom,
|
||||
amount
|
||||
}
|
||||
],
|
||||
fee);
|
||||
|
||||
assert(txResponse.code === 0, `TX Failed - Hash: ${txResponse.transactionHash}, Code: ${txResponse.code}, Message: ${txResponse.rawLog}`);
|
||||
|
||||
const transfer = txResponse.events.find(e => e.type === 'transfer' ? e.attributes.find(a => a.key === 'msg_index') : null);
|
||||
const accountResponse = await registry.getAccounts([fromAddress, destinationAddress]);
|
||||
|
||||
const output = {
|
||||
tx: {
|
||||
hash: txResponse.transactionHash,
|
||||
height: txResponse.height,
|
||||
index: txResponse.txIndex,
|
||||
code: txResponse.code,
|
||||
log: txResponse.rawLog,
|
||||
sender: transfer?.attributes.find(a => a.key === 'sender')?.value,
|
||||
recipient: transfer?.attributes.find(a => a.key === 'recipient')?.value,
|
||||
amount: transfer?.attributes.find(a => a.key === 'amount')?.value
|
||||
},
|
||||
accounts: accountResponse
|
||||
};
|
||||
|
||||
queryOutput(output, argv.output);
|
||||
};
|
||||
|
||||
+6
-1
@@ -6,11 +6,16 @@ export const getConnectionInfo = (argv: Arguments, config: any) => {
|
||||
|
||||
const result = {
|
||||
...config,
|
||||
userKey: stripHexPrefix(config.userKey),
|
||||
...clean({ server, userKey, bondId, txKey, chainId }),
|
||||
privateKey: txKey || userKey || config.userKey,
|
||||
privateKey: stripHexPrefix(txKey || userKey || config.userKey),
|
||||
gas: String(gas || config.gas),
|
||||
fees: String(fees || config.fees)
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
function stripHexPrefix (hex: string): string {
|
||||
return hex && hex.startsWith('0x') ? hex.slice(2) : hex;
|
||||
}
|
||||
|
||||
+63
-2
@@ -217,8 +217,28 @@ describe('Test laconic CLI commands', () => {
|
||||
getAccountObj({ address: testAccount2, balance: sendAmount })
|
||||
];
|
||||
|
||||
expect(outputObj.length).toEqual(2);
|
||||
expect(outputObj).toMatchObject(expectedAccounts);
|
||||
expect(outputObj.tx.code).toEqual(0);
|
||||
expect(outputObj.tx.amount).toEqual(`${sendAmount}${TOKEN_TYPE}`);
|
||||
expect(outputObj.tx.sender).toEqual(testAccount);
|
||||
expect(outputObj.tx.recipient).toEqual(testAccount2);
|
||||
expect(outputObj.accounts.length).toEqual(2);
|
||||
expect(outputObj.accounts).toMatchObject(expectedAccounts);
|
||||
});
|
||||
test('laconic registry tokens gettx --hash <hash>', async () => {
|
||||
const sendAmount = 1000000000;
|
||||
|
||||
const sendResult = spawnSync('laconic', ['registry', 'tokens', 'send', '--address', testAccount2, '--type', TOKEN_TYPE, '--quantity', sendAmount.toString()]);
|
||||
const sendOutput = checkResultAndRetrieveOutput(sendResult);
|
||||
expect(sendOutput.tx.code).toEqual(0);
|
||||
|
||||
const gettxResult = spawnSync('laconic', ['registry', 'tokens', 'gettx', '--hash', sendOutput.tx.hash]);
|
||||
const gettxOutput = checkResultAndRetrieveOutput(gettxResult);
|
||||
|
||||
expect(gettxOutput.hash).toEqual(sendOutput.tx.hash);
|
||||
expect(gettxOutput.code).toEqual(0);
|
||||
expect(gettxOutput.amount).toEqual(`${sendAmount}${TOKEN_TYPE}`);
|
||||
expect(gettxOutput.sender).toEqual(testAccount);
|
||||
expect(gettxOutput.recipient).toEqual(testAccount2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -478,6 +498,47 @@ describe('Test laconic CLI commands', () => {
|
||||
expect(authorityOutputObj.length).toEqual(1);
|
||||
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||
});
|
||||
|
||||
test('laconic registry authority list', async () => {
|
||||
const result = spawnSync('laconic', ['registry', 'authority', 'list']);
|
||||
const authoritiesOutputObj = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected authorities
|
||||
const expectedAuthorities = [
|
||||
{ name: 'echo.laconic', entry: { ownerAddress: testAccount, status: 'active' } },
|
||||
{ name: 'kube.laconic', entry: { ownerAddress: testAccount2, status: 'active' } },
|
||||
{ name: 'laconic', entry: { ownerAddress: testAccount, status: 'active' } }
|
||||
];
|
||||
|
||||
// Expected output
|
||||
expect(authoritiesOutputObj.length).toEqual(3);
|
||||
expect(authoritiesOutputObj).toMatchObject(expectedAuthorities);
|
||||
});
|
||||
|
||||
test('laconic registry authority list --owner <owner_address>', async () => {
|
||||
let result = spawnSync('laconic', ['registry', 'authority', 'list', '--owner', testAccount]);
|
||||
const authoritiesByOwner1 = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
const expectedAuthoritiesByOwner1 = [
|
||||
{ name: 'echo.laconic', entry: { ownerAddress: testAccount, status: 'active' } },
|
||||
{ name: 'laconic', entry: { ownerAddress: testAccount, status: 'active' } }
|
||||
];
|
||||
|
||||
expect(authoritiesByOwner1.length).toEqual(2);
|
||||
expect(authoritiesByOwner1).toMatchObject(expectedAuthoritiesByOwner1);
|
||||
|
||||
result = spawnSync('laconic', ['registry', 'authority', 'list', '--owner', testAccount2]);
|
||||
const authoritiesByOwner2 = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
const expectedAuthoritiesByOwner2 = [
|
||||
{ name: 'kube.laconic', entry: { ownerAddress: testAccount2, status: 'active' } }
|
||||
];
|
||||
|
||||
expect(authoritiesByOwner2.length).toEqual(1);
|
||||
expect(authoritiesByOwner2).toMatchObject(expectedAuthoritiesByOwner2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Name operations', () => {
|
||||
|
||||
@@ -302,10 +302,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@cerc-io/registry-sdk@^0.2.5":
|
||||
version "0.2.5"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.5/registry-sdk-0.2.5.tgz#9ca19fecb2923520dd6a19946c309ecb2ec780a2"
|
||||
integrity sha512-/KXAYf9gStaX/rRBMCEeDCexEIpTOFHeHzMK9B3xfCT+SyYZE9WC9GpX299LzBYJKKPsb0/JvnDfip9S1igJtA==
|
||||
"@cerc-io/registry-sdk@^0.2.8":
|
||||
version "0.2.8"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.8/registry-sdk-0.2.8.tgz#d71837f735d998987055068457fdf8b2e94ca69c"
|
||||
integrity sha512-utK3Rq5qZrEoRs/eOsOkowcsD740nlnBs6C3KKFRHgKIiR0XedD6t33KukUPLKbGp4mYZOYXRTA7/A04x58lKw==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.28.1"
|
||||
"@cosmjs/crypto" "^0.28.1"
|
||||
|
||||
Reference in New Issue
Block a user