Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ebebaf4b6 | ||
|
|
6055da62c7 | ||
|
|
aa46032bda | ||
|
|
c67961869b | ||
|
|
acd4791355 | ||
|
|
30654bb0ef | ||
|
|
70e63c74f1 | ||
|
|
901126d23f | ||
|
|
4f5de6ff38 | ||
|
|
aa2117e472 | ||
|
|
e6b747fb48 | ||
|
|
ed06cc05a6 | ||
|
|
aff309eaad |
@@ -39,7 +39,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: "./laconicd/"
|
||||
repository: cerc-io/laconic2d # TODO: Update to laconicd after renaming repo
|
||||
repository: cerc-io/laconicd
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@ dist/*
|
||||
out
|
||||
|
||||
config.yml
|
||||
.env
|
||||
*~
|
||||
|
||||
.idea
|
||||
.idea
|
||||
@@ -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
|
||||
|
||||
@@ -68,7 +76,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 photon --quantity 1000000000 --gas 200000 --fees 200000photon
|
||||
$ laconic registry bond create --type alnt --quantity 100000000000 --gas 200000 --fees 200000alnt
|
||||
```
|
||||
|
||||
## Operations
|
||||
@@ -121,7 +129,7 @@ $ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y
|
||||
"sequence": "37",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "89998999999999991999799300"
|
||||
}
|
||||
]
|
||||
@@ -132,33 +140,62 @@ $ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y
|
||||
Send tokens:
|
||||
|
||||
```bash
|
||||
$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type photon --quantity 1000000000
|
||||
[
|
||||
{
|
||||
"address": "laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd",
|
||||
"pubKey": "A68/q7/xazFzNj+rrvE07ALxkMgqw1ugL35VECkWAYvt",
|
||||
"number": "0",
|
||||
"sequence": "16",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"quantity": "99998999999999997973999700"
|
||||
}
|
||||
]
|
||||
$ laconic registry tokens send --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k --type alnt --quantity 1000000000
|
||||
{
|
||||
"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": "photon",
|
||||
"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):
|
||||
@@ -177,7 +214,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
|
||||
$ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --gas 250000 --fees 250000alnt
|
||||
|
||||
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
|
||||
```
|
||||
@@ -255,15 +292,15 @@ $ laconic registry authority whois laconic
|
||||
"commitsEndTime": "2022-04-26T11:44:45.679728594",
|
||||
"revealsEndTime": "2022-04-26T11:45:45.679728594",
|
||||
"commitFee": {
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "1000000"
|
||||
},
|
||||
"revealFee": {
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "1000000"
|
||||
},
|
||||
"minimumBid": {
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "5000000"
|
||||
},
|
||||
"winnerAddress": "",
|
||||
@@ -294,15 +331,15 @@ $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2
|
||||
"commitsEndTime": "2022-04-26T11:44:45.679728594",
|
||||
"revealsEndTime": "2022-04-26T11:45:45.679728594",
|
||||
"commitFee": {
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "1000000"
|
||||
},
|
||||
"revealFee": {
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "1000000"
|
||||
},
|
||||
"minimumBid": {
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "5000000"
|
||||
},
|
||||
"winnerAddress": "",
|
||||
@@ -322,7 +359,7 @@ $ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2
|
||||
Commit an auction bid:
|
||||
|
||||
```bash
|
||||
$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 photon
|
||||
$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 alnt
|
||||
|
||||
Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
|
||||
```
|
||||
@@ -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
|
||||
@@ -426,7 +475,7 @@ $ laconic registry name resolve lrn://laconic/watcher/erc20
|
||||
Create bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond create --type photon --quantity 1000
|
||||
$ laconic registry bond create --type alnt --quantity 1000
|
||||
```
|
||||
|
||||
List bonds:
|
||||
@@ -439,7 +488,7 @@ $ laconic registry bond list
|
||||
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "698000000"
|
||||
}
|
||||
]
|
||||
@@ -449,7 +498,7 @@ $ laconic registry bond list
|
||||
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "1000"
|
||||
}
|
||||
]
|
||||
@@ -467,7 +516,7 @@ $ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa1953
|
||||
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "691000000"
|
||||
}
|
||||
]
|
||||
@@ -485,7 +534,7 @@ $ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7mas
|
||||
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "684000000"
|
||||
}
|
||||
]
|
||||
@@ -495,7 +544,7 @@ $ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7mas
|
||||
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
|
||||
"balance": [
|
||||
{
|
||||
"type": "photon",
|
||||
"type": "alnt",
|
||||
"quantity": "1000"
|
||||
}
|
||||
]
|
||||
@@ -506,13 +555,13 @@ $ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7mas
|
||||
Refill bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type photon --quantity 1000
|
||||
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 1000
|
||||
```
|
||||
|
||||
Withdraw funds from bond:
|
||||
|
||||
```bash
|
||||
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type photon --quantity 500
|
||||
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 500
|
||||
```
|
||||
|
||||
Cancel bond:
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ services:
|
||||
bondId:
|
||||
chainId: laconic_9000-1
|
||||
gas: 200000
|
||||
fees: 200000photon
|
||||
fees: 200000alnt
|
||||
|
||||
+5
-5
@@ -34,7 +34,7 @@
|
||||
# userKey: <ALICE_PRIVATE_KEY>
|
||||
|
||||
# Create a bond
|
||||
laconic --config config.yml registry bond create --type photon --quantity 100000000000
|
||||
laconic --config config.yml registry bond create --type alnt --quantity 100000000000
|
||||
|
||||
# Get the bond id
|
||||
laconic --config config.yml registry bond list | jq -r '.[].id'
|
||||
@@ -57,12 +57,12 @@
|
||||
|
||||
### Example
|
||||
|
||||
* Query for `ajna-watcher` deployment(s):
|
||||
* Query for `azimuth-watcher` deployment(s):
|
||||
|
||||
* Find the `WatcherRecord` for `ajna-watcher`:
|
||||
* Find the `WatcherRecord` for `azimuth-watcher`:
|
||||
|
||||
```bash
|
||||
WATCHER_RECORD_ID=$(laconic registry record list --all --type WatcherRecord --name ajna-watcher | jq -r '.[].id')
|
||||
WATCHER_RECORD_ID=$(laconic registry record list --all --type WatcherRecord --name azimuth-watcher | jq -r '.[].id')
|
||||
```
|
||||
|
||||
* Find corresponding deployment(s):
|
||||
@@ -74,7 +74,7 @@
|
||||
laconic registry record list --all --type WatcherDeploymentRecord watcher $WATCHER_RECORD_ID | jq -r '.[].attributes.url'
|
||||
|
||||
# Expected output:
|
||||
https://ajna-watcher-endpoint.example.com
|
||||
https://azimuth-watcher-endpoint.example.com
|
||||
```
|
||||
|
||||
* Query for `sushiswap-v3-subgraph` deployment(s):
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
import { config } from 'dotenv';
|
||||
import yargs from 'yargs';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import assert from 'assert';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import axios from 'axios';
|
||||
|
||||
import { Octokit } from '@octokit/rest';
|
||||
|
||||
// Load environment variables from .env file
|
||||
config();
|
||||
|
||||
const GITEA_BASE_URL = 'https://git.vdb.to';
|
||||
|
||||
interface RepoRecord {
|
||||
type: string
|
||||
version: string
|
||||
schema: string
|
||||
name: string
|
||||
url: string
|
||||
clone_url: string
|
||||
owner: {
|
||||
name: string
|
||||
type: 'Organization' | 'User'
|
||||
url: string
|
||||
}
|
||||
is_private: boolean
|
||||
is_archived: boolean
|
||||
default_branch: string
|
||||
latest_tag: {
|
||||
tag_name: string
|
||||
url: string
|
||||
} | null
|
||||
is_fork: boolean
|
||||
fork_source: {
|
||||
name: string
|
||||
url: string
|
||||
} | null
|
||||
license: {
|
||||
name: string
|
||||
spdx_id: string
|
||||
} | null
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const argv = getArgs();
|
||||
|
||||
let repoRecord: RepoRecord;
|
||||
if (argv.repoUrl.includes('github.com')) {
|
||||
repoRecord = await createRepoRecord(argv.repoUrl);
|
||||
} else {
|
||||
repoRecord = await createGiteaRepoRecord(argv.repoUrl);
|
||||
}
|
||||
|
||||
const jsonData = JSON.stringify(repoRecord, null, 2);
|
||||
|
||||
const recordsDir = path.resolve(argv.recordsDir);
|
||||
const recordFile = `${recordsDir}/${repoRecord.name}.json`;
|
||||
fs.writeFileSync(recordFile, jsonData, 'utf8');
|
||||
|
||||
console.log(`Repo record written to ${recordFile}`);
|
||||
}
|
||||
|
||||
async function createRepoRecord (repoUrl: string): Promise<RepoRecord> {
|
||||
const githubPAT = process.env.GITHUB_TOKEN;
|
||||
assert(githubPAT, 'GITHUB_TOKEN not provided');
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: githubPAT
|
||||
});
|
||||
|
||||
const { owner, repo } = extractOwnerAndRepo(repoUrl);
|
||||
|
||||
// fetch repo details
|
||||
const data = await getRepoDetails(octokit, owner, repo);
|
||||
|
||||
const repoRecord: RepoRecord = {
|
||||
type: 'RepositoryRecord',
|
||||
version: '0.1.0', // fetch from registry and increment if exists
|
||||
schema: '',
|
||||
name: data.name,
|
||||
url: data.html_url,
|
||||
clone_url: data.clone_url,
|
||||
owner: {
|
||||
name: data.owner.login,
|
||||
type: data.owner.type,
|
||||
url: data.owner.html_url
|
||||
},
|
||||
is_private: data.private,
|
||||
is_archived: data.archived,
|
||||
default_branch: data.default_branch,
|
||||
latest_tag: null,
|
||||
is_fork: data.fork,
|
||||
fork_source: null,
|
||||
license: null
|
||||
};
|
||||
|
||||
// populate fork source
|
||||
if (data.fork) {
|
||||
repoRecord.fork_source = {
|
||||
name: data.source.name,
|
||||
url: data.source.html_url
|
||||
};
|
||||
}
|
||||
|
||||
// populate license
|
||||
if (data.license) {
|
||||
repoRecord.license = {
|
||||
name: data.license.name,
|
||||
spdx_id: data.license.spdx_id
|
||||
};
|
||||
}
|
||||
|
||||
// fetch and populate latest_tag
|
||||
const latestTag = await getRepoLatestTag(octokit, owner, repo);
|
||||
if (latestTag) {
|
||||
repoRecord.latest_tag = {
|
||||
tag_name: latestTag.tag_name,
|
||||
url: latestTag.html_url
|
||||
};
|
||||
}
|
||||
|
||||
return repoRecord;
|
||||
}
|
||||
|
||||
async function createGiteaRepoRecord (repoUrl: string): Promise<RepoRecord> {
|
||||
const giteaPAT = process.env.GITEA_TOKEN;
|
||||
assert(giteaPAT, 'GITEA_TOKEN not provided');
|
||||
|
||||
const { owner, repo } = extractOwnerAndRepo(repoUrl);
|
||||
|
||||
// fetch repo details
|
||||
const data = await getGiteaRepoDetails(giteaPAT, owner, repo);
|
||||
|
||||
const repoRecord: RepoRecord = {
|
||||
type: 'RepositoryRecord',
|
||||
version: '0.1.0', // fetch from registry and increment if exists
|
||||
schema: '',
|
||||
name: data.name,
|
||||
url: data.html_url,
|
||||
clone_url: data.clone_url,
|
||||
owner: {
|
||||
name: data.owner.login,
|
||||
// type: data.owner.type,
|
||||
type: 'Organization',
|
||||
url: data.owner.html_url
|
||||
},
|
||||
is_private: data.private,
|
||||
is_archived: data.archived,
|
||||
default_branch: data.default_branch,
|
||||
latest_tag: null,
|
||||
is_fork: data.fork,
|
||||
fork_source: null,
|
||||
license: null
|
||||
};
|
||||
|
||||
// populate fork source
|
||||
if (data.fork) {
|
||||
repoRecord.fork_source = {
|
||||
name: data.parent.name,
|
||||
url: data.parent.html_url
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: populate license
|
||||
|
||||
// fetch and populate latest_tag
|
||||
const latestTag = await getGiteaRepoLatestTag(giteaPAT, owner, repo);
|
||||
if (latestTag) {
|
||||
repoRecord.latest_tag = {
|
||||
tag_name: latestTag.tag_name,
|
||||
url: latestTag.html_url
|
||||
};
|
||||
}
|
||||
|
||||
return repoRecord;
|
||||
}
|
||||
|
||||
// async function getRepoDetails (octokit: Octokit, repoUrl: string): Promise<RestEndpointMethodTypes["repos"]["get"]["response"]> {
|
||||
async function getRepoDetails (octokit: Octokit, owner: string, repo: string): Promise<any> {
|
||||
try {
|
||||
const response = await octokit.repos.get({
|
||||
owner: owner,
|
||||
repo: repo
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching repository:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getGiteaRepoDetails (token: string, owner: string, repo: string): Promise<any> {
|
||||
try {
|
||||
const response = await axios.get(`${GITEA_BASE_URL}/api/v1/repos/${owner}/${repo}`, {
|
||||
headers: { Authorization: `token ${token}` }
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching repository:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getRepoLatestTag (octokit: Octokit, owner: string, repo: string): Promise<any> {
|
||||
try {
|
||||
const response = await octokit.repos.getLatestRelease({
|
||||
owner: owner,
|
||||
repo: repo
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
if ((error as Error).message.includes('Not Found')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
console.error('Error fetching latest release:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getGiteaRepoLatestTag (token: string, owner: string, repo: string): Promise<any> {
|
||||
try {
|
||||
const response = await axios.get(`${GITEA_BASE_URL}/api/v1/repos/${owner}/${repo}/releases/latest`, {
|
||||
headers: { Authorization: `token ${token}` }
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
if ((error as Error).message.includes('code 404')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
console.error('Error fetching latest release:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function extractOwnerAndRepo (url: string): { owner: string; repo: string } {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const match = url.match(/(?:github\.com|git\.vdb\.to)\/([^\/]+)\/([^\/]+)(\/|$)/);
|
||||
if (!match) {
|
||||
throw new Error(`Unable to extract repo owner and name from the given URL: ${url}`);
|
||||
}
|
||||
|
||||
return { owner: match[1], repo: match[2] };
|
||||
}
|
||||
|
||||
function getArgs (): any {
|
||||
return yargs(hideBin(process.argv)).parserConfiguration({
|
||||
'parse-numbers': false
|
||||
}).usage('Usage: $0 [options]')
|
||||
.option('config', {
|
||||
alias: 'c',
|
||||
describe: 'Config',
|
||||
type: 'string'
|
||||
})
|
||||
.option('repoUrl', {
|
||||
alias: 'r',
|
||||
describe: 'Repository URL',
|
||||
type: 'string',
|
||||
demandOption: true
|
||||
})
|
||||
.option('recordsDir', {
|
||||
alias: 'd',
|
||||
describe: 'Directory to export the repo record to',
|
||||
type: 'string',
|
||||
demandOption: true
|
||||
})
|
||||
.help().argv;
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
+108
-18
@@ -1,17 +1,28 @@
|
||||
import yargs from 'yargs';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import yaml from 'js-yaml';
|
||||
import assert from 'assert';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
|
||||
import { StdFee } from '@cosmjs/stargate';
|
||||
import { Registry } from '@cerc-io/registry-sdk';
|
||||
|
||||
import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../src/util';
|
||||
|
||||
enum RecordType {
|
||||
RepositoryRecord = 'RepositoryRecord',
|
||||
ServiceRecord = 'ServiceRecord',
|
||||
StackRecord = 'StackRecord',
|
||||
SubgraphRecord = 'SubgraphRecord',
|
||||
WatcherRecord = 'WatcherRecord',
|
||||
DockerImageRecord = 'DockerImageRecord'
|
||||
}
|
||||
|
||||
const recordTypeToRecordField = new Map<string, string>([
|
||||
['WatcherRecord', 'watcher'],
|
||||
['SubgraphRecord', 'subgraph'],
|
||||
['ServiceRecord', 'service']
|
||||
[RecordType.WatcherRecord, 'watcher'],
|
||||
[RecordType.SubgraphRecord, 'subgraph'],
|
||||
[RecordType.ServiceRecord, 'service']
|
||||
]);
|
||||
|
||||
let registry: Registry;
|
||||
@@ -45,10 +56,8 @@ async function main () {
|
||||
async function processDir (directoryPath: string): Promise<void> {
|
||||
const files = fs.readdirSync(directoryPath);
|
||||
|
||||
// Check if any JSON record file exists in the directory
|
||||
if (files.some(file => file.endsWith('.json'))) {
|
||||
await publishRecordsFromDir(directoryPath);
|
||||
|
||||
const dirHasRecords = await publishRecordsFromDir(directoryPath);
|
||||
if (dirHasRecords) {
|
||||
// Skip further recursion in the current dir
|
||||
return;
|
||||
}
|
||||
@@ -64,24 +73,28 @@ async function processDir (directoryPath: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function publishRecordsFromDir (recordsDir: string): Promise<void> {
|
||||
async function publishRecordsFromDir (recordsDir: string): Promise<boolean> {
|
||||
// List record files
|
||||
const files = fs.readdirSync(recordsDir);
|
||||
const jsonFiles = files.filter(file => path.extname(file).toLowerCase() === '.json');
|
||||
const recordFiles = files.filter(file => ['.json', '.yaml', '.yml'].includes(path.extname(file).toLowerCase()));
|
||||
|
||||
if (recordFiles.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read record from each JSON file
|
||||
console.log('**************************************');
|
||||
console.log(`Publishing records from ${recordsDir}`);
|
||||
|
||||
let recordType;
|
||||
for (let i = 0; i < jsonFiles.length; i++) {
|
||||
const file = jsonFiles[i];
|
||||
for (let i = 0; i < recordFiles.length; i++) {
|
||||
const file = recordFiles[i];
|
||||
|
||||
const filePath = path.resolve(recordsDir, file);
|
||||
const record = readRecord(filePath);
|
||||
const record = await readRecord(filePath);
|
||||
|
||||
// Publish record
|
||||
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
|
||||
const result = await publishRecord(userKey, bondId, fee, record);
|
||||
|
||||
console.log(`Published record ${file}`);
|
||||
txOutput(result, JSON.stringify(result, undefined, 2), '', false);
|
||||
@@ -91,8 +104,8 @@ async function publishRecordsFromDir (recordsDir: string): Promise<void> {
|
||||
|
||||
// Check if deployment record files exist
|
||||
const deploymentRecordsDir = path.resolve(recordsDir, 'deployments');
|
||||
if (!fs.statSync(deploymentRecordsDir).isDirectory()) {
|
||||
return;
|
||||
if (!fs.existsSync(deploymentRecordsDir) || !fs.statSync(deploymentRecordsDir).isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
console.log('--------------------------------------');
|
||||
console.log(`Publishing deployment records from ${deploymentRecordsDir}`);
|
||||
@@ -105,7 +118,7 @@ async function publishRecordsFromDir (recordsDir: string): Promise<void> {
|
||||
const file = deploymentJsonFiles[i];
|
||||
|
||||
const filePath = path.resolve(deploymentRecordsDir, file);
|
||||
const deploymentRecord = readRecord(filePath);
|
||||
const deploymentRecord = await readRecord(filePath);
|
||||
|
||||
// Find record using name and given type
|
||||
const recordName = deploymentRecord.name;
|
||||
@@ -128,13 +141,30 @@ async function publishRecordsFromDir (recordsDir: string): Promise<void> {
|
||||
console.log(`Published record ${file}`);
|
||||
txOutput(deploymentResult, JSON.stringify(deploymentResult, undefined, 2), '', false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function readRecord (filePath: string): any {
|
||||
async function readRecord (filePath: string): Promise<any> {
|
||||
let record;
|
||||
try {
|
||||
const fileExt = path.extname(filePath).toLowerCase();
|
||||
const data = fs.readFileSync(filePath, 'utf8');
|
||||
record = JSON.parse(data);
|
||||
|
||||
if (fileExt === '.json') {
|
||||
// JSON file
|
||||
record = JSON.parse(data);
|
||||
} else {
|
||||
// YAML file
|
||||
({ record } = await yaml.load(data) as any);
|
||||
|
||||
// Convert sub-objects (other than arrays) to a JSON automatically.
|
||||
for (const [k, v] of Object.entries(record)) {
|
||||
if (v && typeof v === 'object' && !Array.isArray(v)) {
|
||||
record[k] = JSON.stringify(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Error reading file ${filePath}:`, err);
|
||||
}
|
||||
@@ -142,6 +172,66 @@ function readRecord (filePath: string): any {
|
||||
return record;
|
||||
}
|
||||
|
||||
async function publishRecord (userKey: string, bondId: string, fee: StdFee, record: any): Promise<any> {
|
||||
// Replace repository URL with record id (if type is one of RecordType)
|
||||
if (record.repository && Object.values(RecordType).includes(record.type)) {
|
||||
const repoUrl = record.repository;
|
||||
|
||||
const queryResult = await registry.queryRecords({ type: RecordType.RepositoryRecord, url: repoUrl }, true);
|
||||
if (queryResult.length === 0) {
|
||||
throw new Error(`Record not found, type: ${RecordType.RepositoryRecord}, url: ${repoUrl}`);
|
||||
}
|
||||
|
||||
// Assume the first query result
|
||||
const repoRecordId = queryResult[0].id;
|
||||
|
||||
// Replace repository URL with the repo record id
|
||||
record.repository = repoRecordId;
|
||||
}
|
||||
|
||||
// For stack records, check for attributes
|
||||
if (record.type === RecordType.StackRecord) {
|
||||
const watcherName = record.meta?.watcher;
|
||||
const dockerImages = record.docker_images;
|
||||
|
||||
// If .docker_images present, check for image records
|
||||
if (Array.isArray(dockerImages) && dockerImages.length > 0) {
|
||||
const dockerImageRecordsIdPromises = dockerImages.map(async (dockerImage) => {
|
||||
// Find the required docker image record
|
||||
const queryResult = await registry.queryRecords({ type: RecordType.DockerImageRecord, name: dockerImage }, true);
|
||||
if (queryResult.length === 0) {
|
||||
throw new Error(`Record not found, type: ${RecordType.DockerImageRecord}, name: ${dockerImage}`);
|
||||
}
|
||||
|
||||
// Assume the first query result
|
||||
const dockerImageRecordId = queryResult[0].id;
|
||||
|
||||
// Replace watcher name with the watcher record id
|
||||
return dockerImageRecordId;
|
||||
});
|
||||
|
||||
record.docker_images = await Promise.all(dockerImageRecordsIdPromises);
|
||||
}
|
||||
|
||||
// If .meta.watcher present, check for watcher record
|
||||
if (watcherName) {
|
||||
// Find the required watcher record
|
||||
const queryResult = await registry.queryRecords({ type: RecordType.WatcherRecord, name: watcherName }, true);
|
||||
if (queryResult.length === 0) {
|
||||
throw new Error(`Record not found, type: ${RecordType.WatcherRecord}, name: ${watcherName}`);
|
||||
}
|
||||
|
||||
// Assume the first query result
|
||||
const watcherRecordId = queryResult[0].id;
|
||||
|
||||
// Replace watcher name with the watcher record id
|
||||
record.meta.watcher = watcherRecordId;
|
||||
}
|
||||
}
|
||||
|
||||
return registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
|
||||
}
|
||||
|
||||
function getArgs (): any {
|
||||
return yargs(hideBin(process.argv)).parserConfiguration({
|
||||
'parse-numbers': false
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ services:
|
||||
laconicd:
|
||||
restart: unless-stopped
|
||||
image: cerc/laconicd:local
|
||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
command: ["bash", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
environment:
|
||||
- TEST_AUCTION_ENABLED
|
||||
- TEST_REGISTRY_EXPIRY
|
||||
@@ -10,7 +10,7 @@ services:
|
||||
volumes:
|
||||
- ./laconicd/scripts/init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
|
||||
test: ["CMD", "curl", "-v", "http://127.0.0.1", "6060"]
|
||||
interval: 1s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"name": "@cerc-io/laconic-registry-cli",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.6",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
||||
"author": "",
|
||||
"license": "UNLICENSED",
|
||||
"devDependencies": {
|
||||
"@octokit/rest": "^20.1.1",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
@@ -30,7 +29,7 @@
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cerc-io/registry-sdk": "^0.2.1",
|
||||
"@cerc-io/registry-sdk": "^0.2.6",
|
||||
"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);
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+71
-9
@@ -52,7 +52,7 @@ describe('Test laconic CLI commands', () => {
|
||||
const testAccount = process.env.TEST_ACCOUNT;
|
||||
assert(testAccount, 'TEST_ACCOUNT not set in env');
|
||||
const testAccount2 = 'laconic1pmuxrcnuhhf8qdllzuf2ctj2tnwwcg6yswqnyd';
|
||||
const initialAccountBalance = Number('100000000000000000000000000');
|
||||
const initialAccountBalance = Number('1000000000000000000000000000000');
|
||||
|
||||
const testAuthorityName = 'laconic';
|
||||
const testRecordFilePath = 'test/data/watcher-record.yml';
|
||||
@@ -67,12 +67,12 @@ describe('Test laconic CLI commands', () => {
|
||||
expect(outputObj).toHaveProperty('node');
|
||||
expect(outputObj).toHaveProperty('node.network', CHAIN_ID);
|
||||
expect(outputObj).toHaveProperty('sync');
|
||||
expect(Number(outputObj.sync.latest_block_height)).toBeGreaterThan(0);
|
||||
expect(Number(outputObj.sync.latestBlockHeight)).toBeGreaterThan(0);
|
||||
expect(outputObj).toHaveProperty('validator');
|
||||
expect(outputObj).toHaveProperty('validators');
|
||||
expect(outputObj).toHaveProperty('num_peers');
|
||||
expect(outputObj).toHaveProperty('numPeers');
|
||||
expect(outputObj).toHaveProperty('peers');
|
||||
expect(outputObj).toHaveProperty('disk_usage');
|
||||
expect(outputObj).toHaveProperty('diskUsage');
|
||||
});
|
||||
|
||||
describe('Bond operations', () => {
|
||||
@@ -217,19 +217,40 @@ 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);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Record operations', () => {
|
||||
const gas = 250000;
|
||||
const fees = `250000${TOKEN_TYPE}`;
|
||||
const bondBalance = 1000000000;
|
||||
|
||||
test('laconic registry 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> --fees <fees>', async () => {
|
||||
// Create a new bond to be associated with the record
|
||||
({ bondId: testRecordBondId } = createBond(bondBalance));
|
||||
const result = spawnSync('laconic', ['registry', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString()]);
|
||||
const result = spawnSync('laconic', ['registry', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString(), '--fees', fees]);
|
||||
const outputObj = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expect output object to resultant bond id
|
||||
@@ -397,7 +418,7 @@ describe('Test laconic CLI commands', () => {
|
||||
chainId: CHAIN_ID,
|
||||
auctionId: testAuctionId,
|
||||
bidderAddress: testAccount,
|
||||
bidAmount: `${bidAmount}photon`
|
||||
bidAmount: `${bidAmount}alnt`
|
||||
});
|
||||
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
|
||||
});
|
||||
@@ -477,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', () => {
|
||||
|
||||
+1
-1
@@ -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 = 'photon';
|
||||
export const TOKEN_TYPE = 'alnt';
|
||||
|
||||
export const AUCTION_FEES = {
|
||||
commit: 1000000,
|
||||
|
||||
+7
-4
@@ -1,5 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# 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"
|
||||
|
||||
# Get the key from laconicd
|
||||
laconicd_key=$(yes | docker compose exec laconicd laconicd keys export alice --keyring-backend test --unarmored-hex --unsafe)
|
||||
|
||||
@@ -22,13 +28,10 @@ services:
|
||||
bondId:
|
||||
chainId: $cosmos_chain_id
|
||||
gas: 200000
|
||||
fees: 200000photon
|
||||
fees: 200000alnt
|
||||
EOL
|
||||
)
|
||||
echo "$config" > "$config_file"
|
||||
|
||||
# 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"
|
||||
|
||||
# Run tests
|
||||
TEST_ACCOUNT=$laconicd_account_address yarn test
|
||||
|
||||
@@ -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.1":
|
||||
version "0.2.1"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.1/registry-sdk-0.2.1.tgz#c25cbfc89e469197b18e960baa4204e9e5c5511c"
|
||||
integrity sha512-rshIFOaYVyKJu4MU0OATN0JLYrjue9xvQ4Eqnd2z03lS8WMh0gt1eJHzp8A8sxs1IP/jpb6mWXhmu0oQujO2Sg==
|
||||
"@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==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.28.1"
|
||||
"@cosmjs/crypto" "^0.28.1"
|
||||
@@ -1276,101 +1276,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@octetstream/promisify/-/promisify-2.0.2.tgz#29ac3bd7aefba646db670227f895d812c1a19615"
|
||||
integrity sha512-7XHoRB61hxsz8lBQrjC1tq/3OEIgpvGWg6DKAdwi7WRzruwkmsdwmOoUXbU4Dtd4RSOMDwed0SkP3y8UlMt1Bg==
|
||||
|
||||
"@octokit/auth-token@^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7"
|
||||
integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==
|
||||
|
||||
"@octokit/core@^5.0.2":
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.2.0.tgz#ddbeaefc6b44a39834e1bb2e58a49a117672a7ea"
|
||||
integrity sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==
|
||||
dependencies:
|
||||
"@octokit/auth-token" "^4.0.0"
|
||||
"@octokit/graphql" "^7.1.0"
|
||||
"@octokit/request" "^8.3.1"
|
||||
"@octokit/request-error" "^5.1.0"
|
||||
"@octokit/types" "^13.0.0"
|
||||
before-after-hook "^2.2.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/endpoint@^9.0.1":
|
||||
version "9.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.5.tgz#e6c0ee684e307614c02fc6ac12274c50da465c44"
|
||||
integrity sha512-ekqR4/+PCLkEBF6qgj8WqJfvDq65RH85OAgrtnVp1mSxaXF03u2xW/hUdweGS5654IlC0wkNYC18Z50tSYTAFw==
|
||||
dependencies:
|
||||
"@octokit/types" "^13.1.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/graphql@^7.1.0":
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-7.1.0.tgz#9bc1c5de92f026648131f04101cab949eeffe4e0"
|
||||
integrity sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==
|
||||
dependencies:
|
||||
"@octokit/request" "^8.3.0"
|
||||
"@octokit/types" "^13.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/openapi-types@^22.2.0":
|
||||
version "22.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-22.2.0.tgz#75aa7dcd440821d99def6a60b5f014207ae4968e"
|
||||
integrity sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==
|
||||
|
||||
"@octokit/plugin-paginate-rest@11.3.1":
|
||||
version "11.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.3.1.tgz#fe92d04b49f134165d6fbb716e765c2f313ad364"
|
||||
integrity sha512-ryqobs26cLtM1kQxqeZui4v8FeznirUsksiA+RYemMPJ7Micju0WSkv50dBksTuZks9O5cg4wp+t8fZ/cLY56g==
|
||||
dependencies:
|
||||
"@octokit/types" "^13.5.0"
|
||||
|
||||
"@octokit/plugin-request-log@^4.0.0":
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-4.0.1.tgz#98a3ca96e0b107380664708111864cb96551f958"
|
||||
integrity sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA==
|
||||
|
||||
"@octokit/plugin-rest-endpoint-methods@13.2.2":
|
||||
version "13.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.2.2.tgz#af8e5dd2cddfea576f92ffaf9cb84659f302a638"
|
||||
integrity sha512-EI7kXWidkt3Xlok5uN43suK99VWqc8OaIMktY9d9+RNKl69juoTyxmLoWPIZgJYzi41qj/9zU7G/ljnNOJ5AFA==
|
||||
dependencies:
|
||||
"@octokit/types" "^13.5.0"
|
||||
|
||||
"@octokit/request-error@^5.1.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.1.0.tgz#ee4138538d08c81a60be3f320cd71063064a3b30"
|
||||
integrity sha512-GETXfE05J0+7H2STzekpKObFe765O5dlAKUTLNGeH+x47z7JjXHfsHKo5z21D/o/IOZTUEI6nyWyR+bZVP/n5Q==
|
||||
dependencies:
|
||||
"@octokit/types" "^13.1.0"
|
||||
deprecation "^2.0.0"
|
||||
once "^1.4.0"
|
||||
|
||||
"@octokit/request@^8.3.0", "@octokit/request@^8.3.1":
|
||||
version "8.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-8.4.0.tgz#7f4b7b1daa3d1f48c0977ad8fffa2c18adef8974"
|
||||
integrity sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==
|
||||
dependencies:
|
||||
"@octokit/endpoint" "^9.0.1"
|
||||
"@octokit/request-error" "^5.1.0"
|
||||
"@octokit/types" "^13.1.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/rest@^20.1.1":
|
||||
version "20.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-20.1.1.tgz#ec775864f53fb42037a954b9a40d4f5275b3dc95"
|
||||
integrity sha512-MB4AYDsM5jhIHro/dq4ix1iWTLGToIGk6cWF5L6vanFaMble5jTX/UBQyiv05HsWnwUtY8JrfHy2LWfKwihqMw==
|
||||
dependencies:
|
||||
"@octokit/core" "^5.0.2"
|
||||
"@octokit/plugin-paginate-rest" "11.3.1"
|
||||
"@octokit/plugin-request-log" "^4.0.0"
|
||||
"@octokit/plugin-rest-endpoint-methods" "13.2.2"
|
||||
|
||||
"@octokit/types@^13.0.0", "@octokit/types@^13.1.0", "@octokit/types@^13.5.0":
|
||||
version "13.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-13.5.0.tgz#4796e56b7b267ebc7c921dcec262b3d5bfb18883"
|
||||
integrity sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^22.2.0"
|
||||
|
||||
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
|
||||
@@ -2052,11 +1957,6 @@ bech32@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355"
|
||||
integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==
|
||||
|
||||
before-after-hook@^2.2.0:
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c"
|
||||
integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==
|
||||
|
||||
big-integer@1.6.36:
|
||||
version "1.6.36"
|
||||
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.36.tgz#78631076265d4ae3555c04f85e7d9d2f3a071a36"
|
||||
@@ -2471,11 +2371,6 @@ delayed-stream@~1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
|
||||
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
|
||||
|
||||
deprecation@^2.0.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
|
||||
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==
|
||||
|
||||
detect-newline@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
|
||||
@@ -4439,7 +4334,7 @@ object.values@^1.1.7:
|
||||
define-properties "^1.2.0"
|
||||
es-abstract "^1.22.1"
|
||||
|
||||
once@^1.3.0, once@^1.4.0:
|
||||
once@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
|
||||
@@ -5270,11 +5165,6 @@ undici-types@~5.26.4:
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
|
||||
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
||||
|
||||
universal-user-agent@^6.0.0:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.1.tgz#15f20f55da3c930c57bddbf1734c6654d5fd35aa"
|
||||
integrity sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==
|
||||
|
||||
universalify@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
|
||||
|
||||
Reference in New Issue
Block a user