Compare commits

..
Author SHA1 Message Date
Adw8 a8dcc8a48f Import denom from registry-sdk in cli test 2024-08-01 11:44:22 +05:30
Adw8 4026195be3 Use constant for denom in README 2024-08-01 11:11:50 +05:30
9 changed files with 33 additions and 112 deletions
+12 -26
View File
@@ -54,14 +54,12 @@ 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>"
..
Set a denom for further use:
```bash
export DENOM=alnt
```
## Gas and Fees
@@ -76,7 +74,7 @@ The `gas` and `fees` can be set to some default values in the config, and can be
Example:
```bash
$ laconic registry bond create --type alnt --quantity 100000000000 --gas 200000 --fees 200000alnt
$ laconic registry bond create --type $DENOM --quantity 100000000000 --gas 200000 --fees 200000$DENOM
```
## Operations
@@ -140,7 +138,7 @@ $ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y
Send tokens:
```bash
$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type alnt --quantity 1000000000
$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type $DENOM --quantity 1000000000
[
{
"address": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
@@ -185,7 +183,7 @@ record:
Publish record (see below for commands to create/query bonds):
```bash
$ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 --fees 250000alnt
$ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 --fees 250000$DENOM
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
```
@@ -330,7 +328,7 @@ $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2
Commit an auction bid:
```bash
$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 alnt
$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 $DENOM
Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
@@ -359,18 +357,6 @@ 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
@@ -446,7 +432,7 @@ $ laconic registry name resolve lrn://laconic/watcher/erc20
Create bond:
```bash
$ laconic registry bond create --type alnt --quantity 1000
$ laconic registry bond create --type $DENOM --quantity 1000
```
List bonds:
@@ -526,13 +512,13 @@ $ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7mas
Refill bond:
```bash
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 1000
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type $DENOM --quantity 1000
```
Withdraw funds from bond:
```bash
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 500
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type $DENOM --quantity 500
```
Cancel bond:
+4 -1
View File
@@ -33,8 +33,11 @@
# Set the output as 'userKey' in config.yml
# userKey: <ALICE_PRIVATE_KEY>
# Set a denom
export DENOM=alnt
# Create a bond
laconic --config config.yml registry bond create --type alnt --quantity 100000000000
laconic --config config.yml registry bond create --type $DENOM --quantity 100000000000
# Get the bond id
laconic --config config.yml registry bond list | jq -r '.[].id'
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-registry-cli",
"version": "0.2.4",
"version": "0.2.2",
"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.6",
"@cerc-io/registry-sdk": "^0.2.5",
"fs-extra": "^10.1.0",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",
@@ -1,29 +0,0 @@
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);
};
+1 -6
View File
@@ -6,16 +6,11 @@ export const getConnectionInfo = (argv: Arguments, config: any) => {
const result = {
...config,
userKey: stripHexPrefix(config.userKey),
...clean({ server, userKey, bondId, txKey, chainId }),
privateKey: stripHexPrefix(txKey || userKey || config.userKey),
privateKey: 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;
}
+3 -42
View File
@@ -2,6 +2,8 @@ import fs from 'fs';
import assert from 'assert';
import { spawnSync } from 'child_process';
import { DENOM } from '@cerc-io/registry-sdk';
import {
CHAIN_ID,
TOKEN_TYPE,
@@ -398,7 +400,7 @@ describe('Test laconic CLI commands', () => {
chainId: CHAIN_ID,
auctionId: testAuctionId,
bidderAddress: testAccount,
bidAmount: `${bidAmount}alnt`
bidAmount: `${bidAmount}${DENOM}`
});
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
});
@@ -478,47 +480,6 @@ 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', () => {
+3 -1
View File
@@ -2,8 +2,10 @@ import fs from 'fs';
import yaml from 'js-yaml';
import { SpawnSyncReturns, spawnSync } from 'child_process';
import { DENOM } from '@cerc-io/registry-sdk';
export const CHAIN_ID = 'laconic_9000-1';
export const TOKEN_TYPE = 'alnt';
export const TOKEN_TYPE = DENOM;
export const AUCTION_FEES = {
commit: 1000000,
+4 -1
View File
@@ -3,6 +3,9 @@
set -e
set -u
# Define the token denomination
DENOM="alnt"
# Wait for the laconid endpoint to come up
docker compose exec laconicd sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api"
@@ -28,7 +31,7 @@ services:
bondId:
chainId: $cosmos_chain_id
gas: 200000
fees: 200000alnt
fees: 200000$DENOM
EOL
)
echo "$config" > "$config_file"
+4 -4
View File
@@ -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.6":
version "0.2.6"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.6/registry-sdk-0.2.6.tgz#af8a5844bdb742a01d322a9d93ace90d35aad37e"
integrity sha512-Z2rneeoPLTJk9aBTqMrR9WPKfPQZhNWShI4IYOb7kzoIorp3eD8mEals0I5bVjzStjapw/5RKf8lVnDCX9I4iA==
"@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==
dependencies:
"@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1"