Compare commits

..

2 Commits

47 changed files with 603 additions and 1329 deletions

View File

@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@v3
with:
path: "./laconicd/"
repository: cerc-io/laconicd
repository: cerc-io/laconic2d # TODO: Update to laconicd after renaming repo
fetch-depth: 0
ref: main

379
README.md
View File

@ -4,7 +4,7 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
## Install
* Add `.npmrc` file in desired project to resolve package
- Add `.npmrc` file in desired project to resolve package
```bash
@cerc-io:registry=https://git.vdb.to/api/packages/cerc-io/npm/
@ -12,13 +12,13 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
This will set the registry for `cerc-io` scoped packages in the project
* Install the CLI using package manager
- Install the CLI using package manager
```bash
yarn add @cerc-io/laconic-registry-cli
```
* For installing CLI globally add `.npmrc` file above in home directory and run
- For installing CLI globally add `.npmrc` file above in home directory and run
```bash
yarn global add @cerc-io/laconic-registry-cli
@ -42,7 +42,7 @@ CLI utility written in TS, used to interact with laconicd. Depends on [registry-
Run the chain:
* In laconicd repo run:
- In laconicd repo run:
```bash
TEST_AUCTION_ENABLED=true ./scripts/init.sh clean
@ -54,96 +54,22 @@ 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`:
```yml
services:
registry:
..
userKey: "<user-key>"
..
```
In `config.yml` file assign the account private key to `userKey`.
## Gas and Fees
* Gas and fees in `cosmos-sdk`:
* <https://docs.cosmos.network/v0.50/learn/beginner/gas-fees>
* `gas` is a special unit that is used to track the consumption of resources during execution of a transaction
* The maximum value a tx is allowed to consume can be capped by setting `gas` in the config
* `fees` have to be paid by sender to allow the transaction into the mempool and is calculated using `gasPrice`:
https://docs.evmos.org/users/basics/gas.html
```bash
fees = gas * gasPrice
```
* Transactions require `gas`, set to the maximum value the transaction is allowed to consume.
* Typically, validators also require transaction `fees` to be provided to allow the transaction into the mempool.
* Typically, validators / full nodes set `min-gas-prices` to only allow txs providing minimum amount of fees
* Using `cosmjs`, there are two ways max fees amount can be given for a tx:
* Either by specifying `fees` and `gas` (in which case `fees` should be >= `gas` * `min-gas-price`)
* Or by specifying a `gasPrice` (in which case `gasPrice` should be >= `min-gas-price` set by the node and fees is `auto` calculated by simulating the tx)
The `gas` and `fees` can be set to some default values in the config, and can be overriden for each command using the `--gas` and `--fees` arguments.
When using the `auto` fees calculation, the gas estimation by tx simulation is typically multiplied by a multiplier
* As such, following `gas`, `fees` and `gasPrice` combinations can be used in `laconic-registry-cli`:
* Gas set, fees set to `Xalnt`:
Example:
```bash
# Example
gas: 500000
fees: 500000alnt
gasPrice:
```
* `gasPrice` config ignored
* tx rejected if given `fees` < `gas` * `min-gas-price` set by the node
* tx fails mid-execution if it runs out of given `gas`
* Fees not set, gas price set to `Xalnt`:
```bash
# Example
gas:
fees:
gasPrice: 1alnt
```
* `gas` config ignored
* uses `auto` fee calculation using gas estimation with [default multiplier](https://git.vdb.to/cerc-io/registry-sdk/src/branch/main/src/constants.ts) value from `registry-sdk`
* tx rejected if given `gasPrice` < `min-gas-price` set by the node
* tx fails mid-execution if it runs out of calculated gas
* Fees set to a `X` (without `alnt` suffix), gas price set to `Yalnt`:
```bash
# Example
gas:
fees: 1.8
gasPrice: 1alnt
```
* `gas` config ignored
* uses `auto` fee calculation using gas estimation with `fees` as the multiplier
* tx rejected if given `gasPrice` < `min-gas-price` set by the node
* tx fails mid-execution if it runs out of calculated gas, can be retried with a higher gas estimation multiplier (`fees`)
* Fees and gas price both not set:
```bash
# Example
gas:
fees:
gasPrice:
```
* `gas` config ignored
* uses `auto` fee calculation using gas estimation
* throws error:
```bash
Gas price must be set in the client options when auto gas is used.
```
* The `gas`, `fees` and `gasPrice` can be set to some default values in the config as shown above, and can be overriden for each command using the `--gas`, `--fees` and `--gasPrice` arguments:
```bash
# Example:
laconic registry bond create --type alnt --quantity 100000000000 --gas 200000 --fees 200000alnt
```
```bash
$ laconic registry bond create --type photon --quantity 1000000000 --gas 200000 --fees 200000photon
```
## Operations
@ -152,7 +78,7 @@ These commands require a `config.yml` file present in the current working direct
Get node status:
```bash
laconic registry status
$ laconic registry status
{
"version": "0.3.0",
"node": {
@ -186,7 +112,7 @@ laconic registry status
Get account details:
```bash
laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
$ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
[
{
"address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
@ -195,7 +121,7 @@ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7m
"sequence": "37",
"balance": [
{
"type": "alnt",
"type": "photon",
"quantity": "89998999999999991999799300"
}
]
@ -206,62 +132,33 @@ laconic registry account get --address laconic15za32wly5exgcrt2zfr8php4ya49n5y7m
Send tokens:
```bash
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"
$ 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"
}
]
},
"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"
}
{
"address": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"pubKey": null,
"number": "12",
"sequence": "0",
"balance": [
{
"type": "photon",
"quantity": "1000000000"
}
]
}
]
```
Create record (generic):
@ -280,7 +177,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
{ id: 'bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba' }
```
@ -288,7 +185,7 @@ laconic registry record publish --filename watcher.yml --bond-id 58508984500aa2e
Get record:
```bash
laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
$ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
[
{
"id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba",
@ -329,19 +226,19 @@ laconic registry record get --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf27
List records:
```bash
laconic registry record list
$ laconic registry record list
```
Reserve authority:
```bash
laconic registry authority reserve laconic
$ laconic registry authority reserve laconic
```
Check authority information:
```bash
laconic registry authority whois laconic
$ laconic registry authority whois laconic
[
{
"ownerAddress": "",
@ -358,15 +255,15 @@ laconic registry authority whois laconic
"commitsEndTime": "2022-04-26T11:44:45.679728594",
"revealsEndTime": "2022-04-26T11:45:45.679728594",
"commitFee": {
"type": "alnt",
"type": "photon",
"quantity": "1000000"
},
"revealFee": {
"type": "alnt",
"type": "photon",
"quantity": "1000000"
},
"minimumBid": {
"type": "alnt",
"type": "photon",
"quantity": "5000000"
},
"winnerAddress": "",
@ -387,7 +284,7 @@ laconic registry authority whois laconic
Get authority auction info:
```bash
laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48
$ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48
[
{
"id": "0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48",
@ -397,15 +294,15 @@ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d246
"commitsEndTime": "2022-04-26T11:44:45.679728594",
"revealsEndTime": "2022-04-26T11:45:45.679728594",
"commitFee": {
"type": "alnt",
"type": "photon",
"quantity": "1000000"
},
"revealFee": {
"type": "alnt",
"type": "photon",
"quantity": "1000000"
},
"minimumBid": {
"type": "alnt",
"type": "photon",
"quantity": "5000000"
},
"winnerAddress": "",
@ -425,7 +322,7 @@ laconic registry auction get 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d246
Commit an auction bid:
```bash
laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 alnt
$ laconic registry auction bid commit 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 25000000 photon
Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
@ -433,49 +330,37 @@ Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.j
Reveal an auction bid:
```bash
laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
$ laconic registry auction bid reveal 0294fb2e3659c347b53a6faf4bef041fd934f0f3ab13df6d2468d5d63abacd48 ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
Set authority bond (after winning auction):
```bash
laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
$ laconic registry authority bond set laconic 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
```
Create sub-authority (same owner as parent authority):
```bash
laconic registry authority reserve echo.laconic
$ laconic registry authority reserve echo.laconic
```
Create sub-authority (custom owner for sub-authority):
```bash
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
$ laconic registry authority reserve kube.laconic --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
```
Set name:
```bash
laconic registry name set lrn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
$ laconic registry name set lrn://laconic/watcher/erc20 bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
```
Lookup name information:
```bash
laconic registry name lookup lrn://laconic/watcher/erc20
$ laconic registry name lookup lrn://laconic/watcher/erc20
[
{
"latest": {
@ -489,7 +374,7 @@ laconic registry name lookup lrn://laconic/watcher/erc20
Resolve name:
```bash
laconic registry name resolve lrn://laconic/watcher/erc20
$ laconic registry name resolve lrn://laconic/watcher/erc20
[
{
"id": "bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba",
@ -530,9 +415,9 @@ laconic registry name resolve lrn://laconic/watcher/erc20
Delete name:
```bash
laconic registry name delete lrn://laconic/watcher/erc20
$ laconic registry name delete lrn://laconic/watcher/erc20
laconic registry name resolve lrn://laconic/watcher/erc20
$ laconic registry name resolve lrn://laconic/watcher/erc20
[
null
]
@ -541,20 +426,20 @@ laconic registry name resolve lrn://laconic/watcher/erc20
Create bond:
```bash
laconic registry bond create --type alnt --quantity 1000
$ laconic registry bond create --type photon --quantity 1000
```
List bonds:
```bash
laconic registry bond list
$ laconic registry bond list
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "alnt",
"type": "photon",
"quantity": "698000000"
}
]
@ -564,7 +449,7 @@ laconic registry bond list
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "alnt",
"type": "photon",
"quantity": "1000"
}
]
@ -575,14 +460,14 @@ laconic registry bond list
Get bond:
```bash
laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
$ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "alnt",
"type": "photon",
"quantity": "691000000"
}
]
@ -593,14 +478,14 @@ laconic registry bond get --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361
Query bonds by owner:
```bash
laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
$ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k
[
{
"id": "58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785",
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "alnt",
"type": "photon",
"quantity": "684000000"
}
]
@ -610,7 +495,7 @@ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7
"owner": "laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7k",
"balance": [
{
"type": "alnt",
"type": "photon",
"quantity": "1000"
}
]
@ -621,145 +506,41 @@ laconic registry bond list --owner laconic15za32wly5exgcrt2zfr8php4ya49n5y7masu7
Refill bond:
```bash
laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 1000
$ laconic registry bond refill --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type photon --quantity 1000
```
Withdraw funds from bond:
```bash
laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type alnt --quantity 500
$ laconic registry bond withdraw --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785 --type photon --quantity 500
```
Cancel bond:
```bash
laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
$ laconic registry bond cancel --id 58508984500aa2ed18e059fa8203b40fbc9828e3bfa195361335c4e4524c4785
```
Associate bond (with record):
```bash
laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
$ laconic registry bond associate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
```
Disassociate bond (from record):
```bash
laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
$ laconic registry bond dissociate --id bafyreic3auqajvgszh3vfjsouew2rsctswukc346dmlf273ln4g6iyyhba
```
Dissociate all records from bond:
```bash
laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
$ laconic registry bond records dissociate --bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0
```
Reassociate records (switch bond):
```bash
laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae
```
Create a `provider` auction:
```bash
laconic registry auction create --kind provider --commits-duration 60 --reveals-duration 60 --denom alnt --commit-fee 1000 --reveal-fee 1000 --max-price 100000 --num-providers 5
{"auctionId":"73c5fa4b91bb973641ccbb6901a8404745fb8793c95485b00d5a791e6b6c1630"}
# Set auction id in a variable
AUCTION=
```
Commit an auction bid:
```bash
laconic registry auction bid commit $AUCTION 25000 alnt
{"reveal_file":"/home/user/laconic-registry-cli/out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json"}
```
Reveal an auction bid:
```bash
laconic registry auction bid reveal $AUCTION /home/user/laconic-registry-cli/out/bafyreiai5upey4562ont54pe7m3buiphtd6n3q2vr5lxdcj3gpyklbbgvy.json
{"success": true}
```
Check the auction state on completion:
```bash
laconic registry auction get $AUCTION
[
{
"id": "b66b74048fc360de6a926123b760e6485276d90ad2274b5386c02664cd04bace",
"kind": "provider",
"status": "completed",
"ownerAddress": "laconic1maqfgs93hnvzqh5mfj9kxt4e3n27vhd0w7emrx",
"createTime": "2024-09-17T09:51:48.605610628",
"commitsEndTime": "2024-09-17T09:52:48.605610628",
"revealsEndTime": "2024-09-17T09:53:48.605610628",
"commitFee": {
"type": "alnt",
"quantity": 1000
},
"revealFee": {
"type": "alnt",
"quantity": 1000
},
"minimumBid": {
"type": "",
"quantity": 0
},
"winnerAddresses": [
"laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r"
],
"winnerBids": [
{
"type": "alnt",
"quantity": 25000
}
],
"winnerPrice": {
"type": "alnt",
"quantity": 25000
},
"maxPrice": {
"type": "alnt",
"quantity": 100000
},
"numProviders": 5,
"bids": [
{
"bidderAddress": "laconic13qrlfkgl02wgwpw0n4j8kswygwnukphy92249r",
"status": "reveal",
"commitHash": "bafyreifjkhiakayvvaasnsw7ufaax54ncow4xuycqnox7hxay34c6yod7a",
"commitTime": "2024-09-17T09:52:03.665761945",
"revealTime": "2024-09-17T09:53:00.904061323",
"commitFee": {
"type": "alnt",
"quantity": 1000
},
"revealFee": {
"type": "alnt",
"quantity": 1000
},
"bidAmount": {
"type": "alnt",
"quantity": 25000
}
}
]
}
]
```
Release provider winning funds:
```bash
laconic registry auction release-funds $AUCTION
{"success": true}
$ laconic registry bond records reassociate --old-bond-id 5c40abd336ae1561f2a1b55be73b12f5a083080bf879b4c9288d182d238badb0 --new-bond-id 3e11c61f179897e4b12e9b63de35d36f88ac146755e7a28ce0bcdd07cf3a03ae
```

View File

@ -6,5 +6,4 @@ services:
bondId:
chainId: laconic_9000-1
gas: 200000
fees: 200000alnt
gasPrice:
fees: 200000photon

View File

@ -26,7 +26,6 @@
# Update the gas value in config.yml
# gas: 500000
# fees: 500000alnt
# Get user private key
laconicd keys export alice --unarmored-hex --unsafe --keyring-backend test --home ~/.laconicd
@ -35,7 +34,7 @@
# userKey: <ALICE_PRIVATE_KEY>
# Create a bond
laconic --config config.yml registry bond create --type alnt --quantity 100000000000
laconic --config config.yml registry bond create --type photon --quantity 100000000000
# Get the bond id
laconic --config config.yml registry bond list | jq -r '.[].id'
@ -58,12 +57,12 @@
### Example
* Query for `azimuth-watcher` deployment(s):
* Query for `ajna-watcher` deployment(s):
* Find the `WatcherRecord` for `azimuth-watcher`:
* Find the `WatcherRecord` for `ajna-watcher`:
```bash
WATCHER_RECORD_ID=$(laconic registry record list --all --type WatcherRecord --name azimuth-watcher | jq -r '.[].id')
WATCHER_RECORD_ID=$(laconic registry record list --all --type WatcherRecord --name ajna-watcher | jq -r '.[].id')
```
* Find corresponding deployment(s):
@ -75,7 +74,7 @@
laconic registry record list --all --type WatcherDeploymentRecord watcher $WATCHER_RECORD_ID | jq -r '.[].attributes.url'
# Expected output:
https://azimuth-watcher-endpoint.example.com
https://ajna-watcher-endpoint.example.com
```
* Query for `sushiswap-v3-subgraph` deployment(s):

View File

@ -0,0 +1,276 @@
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);
});

View File

@ -1,27 +1,17 @@
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',
}
const recordTypeToRecordField = new Map<string, string>([
[RecordType.WatcherRecord, 'watcher'],
[RecordType.SubgraphRecord, 'subgraph'],
[RecordType.ServiceRecord, 'service']
['WatcherRecord', 'watcher'],
['SubgraphRecord', 'subgraph'],
['ServiceRecord', 'service']
]);
let registry: Registry;
@ -46,7 +36,7 @@ async function main () {
let rpcEndpoint, gqlEndpoint, chainId: string;
({ rpcEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, registryConfig));
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
fee = getGasAndFees(argv, registryConfig);
await processDir(path.resolve(recordsDir));
@ -55,8 +45,10 @@ async function main () {
async function processDir (directoryPath: string): Promise<void> {
const files = fs.readdirSync(directoryPath);
const dirHasRecords = await publishRecordsFromDir(directoryPath);
if (dirHasRecords) {
// Check if any JSON record file exists in the directory
if (files.some(file => file.endsWith('.json'))) {
await publishRecordsFromDir(directoryPath);
// Skip further recursion in the current dir
return;
}
@ -72,28 +64,24 @@ async function processDir (directoryPath: string): Promise<void> {
}
}
async function publishRecordsFromDir (recordsDir: string): Promise<boolean> {
async function publishRecordsFromDir (recordsDir: string): Promise<void> {
// List record files
const files = fs.readdirSync(recordsDir);
const recordFiles = files.filter(file => ['.json', '.yaml', '.yml'].includes(path.extname(file).toLowerCase()));
if (recordFiles.length === 0) {
return false;
}
const jsonFiles = files.filter(file => path.extname(file).toLowerCase() === '.json');
// Read record from each JSON file
console.log('**************************************');
console.log(`Publishing records from ${recordsDir}`);
let recordType;
for (let i = 0; i < recordFiles.length; i++) {
const file = recordFiles[i];
for (let i = 0; i < jsonFiles.length; i++) {
const file = jsonFiles[i];
const filePath = path.resolve(recordsDir, file);
const record = await readRecord(filePath);
const record = readRecord(filePath);
// Publish record
const result = await publishRecord(userKey, bondId, fee, record);
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
console.log(`Published record ${file}`);
txOutput(result, JSON.stringify(result, undefined, 2), '', false);
@ -103,8 +91,8 @@ async function publishRecordsFromDir (recordsDir: string): Promise<boolean> {
// Check if deployment record files exist
const deploymentRecordsDir = path.resolve(recordsDir, 'deployments');
if (!fs.existsSync(deploymentRecordsDir) || !fs.statSync(deploymentRecordsDir).isDirectory()) {
return true;
if (!fs.statSync(deploymentRecordsDir).isDirectory()) {
return;
}
console.log('--------------------------------------');
console.log(`Publishing deployment records from ${deploymentRecordsDir}`);
@ -117,7 +105,7 @@ async function publishRecordsFromDir (recordsDir: string): Promise<boolean> {
const file = deploymentJsonFiles[i];
const filePath = path.resolve(deploymentRecordsDir, file);
const deploymentRecord = await readRecord(filePath);
const deploymentRecord = readRecord(filePath);
// Find record using name and given type
const recordName = deploymentRecord.name;
@ -140,30 +128,13 @@ async function publishRecordsFromDir (recordsDir: string): Promise<boolean> {
console.log(`Published record ${file}`);
txOutput(deploymentResult, JSON.stringify(deploymentResult, undefined, 2), '', false);
}
return true;
}
async function readRecord (filePath: string): Promise<any> {
function readRecord (filePath: string): any {
let record;
try {
const fileExt = path.extname(filePath).toLowerCase();
const data = fs.readFileSync(filePath, 'utf8');
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);
}
}
}
record = JSON.parse(data);
} catch (err) {
console.error(`Error reading file ${filePath}:`, err);
}
@ -171,26 +142,6 @@ async function readRecord (filePath: string): Promise<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;
}
return registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
}
function getArgs (): any {
return yargs(hideBin(process.argv)).parserConfiguration({
'parse-numbers': false

View File

@ -2,7 +2,7 @@ services:
laconicd:
restart: unless-stopped
image: cerc/laconicd:local
command: ["bash", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
command: ["sh", "/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

View File

@ -1,11 +1,12 @@
{
"name": "@cerc-io/laconic-registry-cli",
"version": "0.2.10",
"version": "0.2.0",
"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",
@ -29,8 +30,7 @@
"typescript": "^4.6.3"
},
"dependencies": {
"@cerc-io/registry-sdk": "^0.2.11",
"@cosmjs/stargate": "^0.32.2",
"@cerc-io/registry-sdk": "^0.2.1",
"fs-extra": "^10.1.0",
"js-yaml": "^3.14.1",
"lodash": "^4.17.21",

View File

@ -18,12 +18,10 @@ export const handler = async (argv: Arguments) => {
assert(chainId, 'Invalid registry Chain ID.');
if (!address && privateKey) {
const account = new Account(Buffer.from(privateKey, 'hex'));
await account.init();
address = account.address;
address = new Account(Buffer.from(privateKey, 'hex')).address;
}
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.getAccounts([address]);
queryOutput(result, argv.output);

View File

@ -5,7 +5,7 @@ import { Account, createBid, Registry } from '@cerc-io/registry-sdk';
import { ensureDir } from 'fs-extra';
import fs from 'fs';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
const OUT_DIR = 'out';
@ -40,8 +40,7 @@ export const handler = async (argv: Arguments) => {
await ensureDir(outDirPath);
fs.writeFileSync(revealFilePath, JSON.stringify(reveal, undefined, 2));
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee);

View File

@ -4,7 +4,7 @@ import path from 'path';
import { Registry } from '@cerc-io/registry-sdk';
import fs from 'fs';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
export const command = 'reveal [auction-id] [file-path]';
@ -23,8 +23,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const reveal = fs.readFileSync(path.resolve(filePath));

View File

@ -1,106 +0,0 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY, Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
export const command = 'create';
export const desc = 'Create auction.';
export const builder = {
kind: {
type: 'string',
describe: 'Auction kind (vickrey | provider)'
},
'commits-duration': {
type: 'string',
describe: 'Duration for bid commit phase in seconds'
},
'reveals-duration': {
type: 'string',
describe: 'Duration for bid reveal phase in seconds'
},
denom: {
type: 'string',
describe: 'Denom to use'
},
'commit-fee': {
type: 'string',
describe: 'Fee for committing a bid to the auction'
},
'reveal-fee': {
type: 'string',
describe: 'Fee for revealing a bid in the auction'
},
'minimum-bid': {
type: 'string',
default: 0,
describe: 'Minimum bid amount (only for vickrey auction)'
},
'max-price': {
type: 'string',
default: 0,
describe: 'Max acceptable bid price (only for provider auction)'
},
'num-providers': {
type: 'number',
describe: 'Number ofdesired providers (only for provider auction)'
}
};
export const handler = async (argv: Arguments) => {
const { config } = argv;
const kind = argv.kind as string;
const validAuctionKinds = [AUCTION_KIND_VICKREY, AUCTION_KIND_PROVIDER];
assert(validAuctionKinds.includes(kind), `Invalid auction kind, has to be one of ${validAuctionKinds}.`);
if (kind === AUCTION_KIND_VICKREY) {
assert(argv.minimumBid, 'Invalid minimum bid.');
assert(!argv.maxPrice, `Max price can only be used with ${AUCTION_KIND_PROVIDER} auction.`);
assert(!argv.numProviders, `Num providers can only be used with ${AUCTION_KIND_PROVIDER} auction.`);
} else if (kind === AUCTION_KIND_PROVIDER) {
assert(argv.maxPrice, 'Invalid max price.');
assert(argv.numProviders, 'Invalid num providers.');
assert(!argv.minimumBid, `Minimum bid can only be used with ${AUCTION_KIND_VICKREY} auction.`);
}
assert(argv.commitsDuration, 'Invalid commits duration.');
assert(argv.revealsDuration, 'Invalid reveals duration.');
assert(argv.commitFee, 'Invalid commit fee.');
assert(argv.revealFee, 'Invalid reveal fee.');
const commitsDuration = argv.commitsDuration as string;
const revealsDuration = argv.revealsDuration as string;
const denom = argv.denom as string;
const commitFee = argv.commitFee as string;
const revealFee = argv.revealFee as string;
const minimumBid = argv.minimumBid as string;
const maxPrice = argv.maxPrice as string;
const numProviders = argv.numProviders as number;
const { services: { registry: registryConfig } } = getConfig(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 gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const fee = getGasAndFees(argv, registryConfig);
let result: any;
if (kind === AUCTION_KIND_VICKREY) {
result = await registry.createAuction({ commitsDuration, revealsDuration, denom, commitFee, revealFee, minimumBid }, privateKey, fee);
} else {
result = await registry.createProviderAuction({ commitsDuration, revealsDuration, denom, commitFee, revealFee, maxPrice, numProviders }, privateKey, fee);
}
const jsonString = `{"auctionId":"${result.auction?.id}"}`;
txOutput(result, jsonString, argv.output, argv.verbose);
};

View File

@ -18,7 +18,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.getAuctionsByIds([id as string]);
queryOutput(result, argv.output);

View File

@ -1,34 +0,0 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Account, Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
export const command = 'release-funds [auction-id]';
export const desc = 'Release funds of provider auction winners.';
export const handler = async (argv: Arguments) => {
const auctionId = argv.auctionId as string;
assert(auctionId, 'Invalid auction ID.');
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 gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.releaseFunds({ auctionId }, privateKey, fee);
const success = '{"success": true}';
txOutput(result, success, argv.output, argv.verbose);
};

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
export const command = 'set [name] [bond-id]';
@ -21,8 +21,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
const success = '{"success": true}';

View File

@ -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);
};

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'reserve [name]';
@ -27,8 +27,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);

View File

@ -18,7 +18,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.lookupAuthorities([name], true);
queryOutput(result, argv.output);

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'associate';
@ -27,8 +27,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
const success = '{"success": true}';

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'cancel';
@ -19,8 +19,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.cancelBond({ id }, privateKey, fee);
const success = '{"success": true}';

View File

@ -1,9 +1,8 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'create';
@ -33,9 +32,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const bondId = await registry.getNextBondId(privateKey);
const result = await registry.createBond({ denom, amount }, privateKey, fee);

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'dissociate';
@ -19,8 +19,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
const success = '{"success": true}';

View File

@ -18,7 +18,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.getBondsByIds([id as string]);

View File

@ -21,17 +21,10 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
let result: any;
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const { owner } = argv;
if (owner) {
const [bondsByOwnerResult] = await registry.queryBondsByOwners([String(owner)]);
result = bondsByOwnerResult.bonds;
} else {
result = await registry.queryBonds();
}
const result = await registry.queryBonds({ owner });
queryOutput(result, argv.output);
};

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
export const command = 'dissociate';
@ -25,8 +25,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
const success = '{"success": true}';

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../../util';
export const command = 'reassociate';
@ -30,8 +30,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
const success = '{"success": true}';

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'refill';
@ -33,8 +33,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
const success = '{"success": true}';

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'withdraw';
@ -33,8 +33,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
const success = '{"success": true}';

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'delete [name]';
@ -19,8 +19,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.deleteName({ lrn: name }, privateKey, fee);

View File

@ -24,7 +24,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.lookupNames([name], argv.history as boolean);
queryOutput(result, argv.output);

View File

@ -18,7 +18,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
let result = await registry.resolveNames([name]);
result = result.filter((v: any) => v);

View File

@ -2,7 +2,7 @@ import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
export const command = 'set [name] [id]';
@ -21,8 +21,7 @@ export const handler = async (argv: Arguments) => {
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.setName({ lrn: name, cid: id }, privateKey, fee);

View File

@ -18,7 +18,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.getRecordsByIds([id as string]);
queryOutput(result, argv.output);

View File

@ -24,23 +24,13 @@ 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, refs, limit, offset } = argv;
const { type, name, bondId, owner, all } = argv;
const filters: any = {};
const filterArgs = argv._.slice(3);
@ -52,9 +42,9 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean, refs as boolean, limit as number, offset as number);
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean);
// Apply ex post filters.
if (bondId) {

View File

@ -4,7 +4,7 @@ import yaml from 'js-yaml';
import fs from 'fs';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getGasAndFees, getConnectionInfo, getGasPrice, txOutput } from '../../../util';
import { getConfig, getGasAndFees, getConnectionInfo, txOutput } from '../../../util';
export const command = 'publish';
@ -43,9 +43,7 @@ export const handler = async (argv: Arguments) => {
}
}
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey || userKey, fee);

View File

@ -15,7 +15,7 @@ export const handler = async (argv: Arguments) => {
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(chainId, 'Invalid registry Chain ID.');
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const result = await registry.getStatus();
console.log(JSON.stringify(result, undefined, 2));

View File

@ -1,54 +0,0 @@
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);
}
};

View File

@ -1,10 +1,8 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Account, Registry } from '@cerc-io/registry-sdk';
import { Account, Registry, DEFAULT_GAS_ESTIMATION_MULTIPLIER } from '@cerc-io/registry-sdk';
import { DeliverTxResponse } from '@cosmjs/stargate';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, queryOutput } from '../../../util';
import { getConfig, getConnectionInfo, getGasAndFees, queryOutput } from '../../../util';
export const command = 'send';
@ -39,40 +37,9 @@ export const handler = async (argv: Arguments) => {
await account.init();
const fromAddress = account.address;
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const laconicClient = await registry.getLaconicClient(account);
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
const fee = getGasAndFees(argv, registryConfig);
const txResponse: DeliverTxResponse = await laconicClient.sendTokens(
account.address,
destinationAddress,
[
{
denom,
amount
}
],
fee || DEFAULT_GAS_ESTIMATION_MULTIPLIER);
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);
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
const result = await registry.getAccounts([fromAddress, destinationAddress]);
queryOutput(result, argv.output);
};

View File

@ -15,8 +15,7 @@ exports.builder = (yargs: yargs.Argv) => {
id: { type: 'string' },
address: { type: 'string' },
gas: { type: 'string' },
fees: { type: 'string' },
gasPrice: { type: 'string' }
fees: { type: 'string' }
})
.commandDir('registry-cmds')
.demandCommand()

View File

@ -26,5 +26,4 @@ yargs(hideBin(process.argv))
.commandDir('cmds')
.demandCommand()
.help()
.alias('h', 'help')
.argv;

View File

@ -2,21 +2,15 @@ import { Arguments } from 'yargs';
import clean from 'lodash-clean';
export const getConnectionInfo = (argv: Arguments, config: any) => {
const { server, userKey, bondId, txKey, chainId, fees, gas, gasPrice } = argv;
const { server, userKey, bondId, txKey, chainId, fees, gas } = argv;
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),
gasPrice: String(gasPrice || config.gasPrice)
fees: String(fees || config.fees)
};
return result;
};
function stripHexPrefix (hex: string): string {
return hex && hex.startsWith('0x') ? hex.slice(2) : hex;
}

View File

@ -1,17 +1,24 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import assert from 'assert';
import { Arguments } from 'yargs';
import { parseGasAndFees, getGasPrice as registryGetGasPrice } from '@cerc-io/registry-sdk';
import { StdFee, GasPrice } from '@cosmjs/stargate';
export const parseGasAndFees = (gas: string, fees = '') => {
assert(gas, 'Invalid gas.');
export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => {
const [{ amount, denom }] = fees.trim().split(',')
.map(fee => fee.trim().split(/(\d+)/))
.filter(([_, amount, denom]) => (denom && amount))
.map(([_, amount, denom]) => ({ denom, amount }));
return {
amount: [{ denom, amount }],
gas
};
};
export const getGasAndFees = (argv: Arguments, config: any = {}) => {
return parseGasAndFees(
argv.gas || config.gas,
argv.fees || config.fees
String(argv.gas || config.gas),
String(argv.fees || config.fees)
);
};
export const getGasPrice = (argv: Arguments, config: any = {}): GasPrice | undefined => {
const gasPriceString = argv.gasPrice || config.gasPrice;
return registryGetGasPrice(gasPriceString);
};

View File

@ -1,4 +1,4 @@
# Run CLI tests
## Run CLI tests
* Follow the project `Setup` and `Account Setup` from root [README](./../README.md)

View File

@ -2,8 +2,6 @@ import fs from 'fs';
import assert from 'assert';
import { spawnSync } from 'child_process';
import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY } from '@cerc-io/registry-sdk';
import {
CHAIN_ID,
TOKEN_TYPE,
@ -17,10 +15,7 @@ import {
getRecordObj,
getAuthorityObj,
getAuctionObj,
getBidObj,
updateGasAndFeesConfig,
AUCTION_STATUS,
getFeesConfig
getBidObj
} from './helpers';
describe('Test laconic CLI commands', () => {
@ -57,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('1000000000000000000000000000000');
const initialAccountBalance = Number('100000000000000000000000000');
const testAuthorityName = 'laconic';
const testRecordFilePath = 'test/data/watcher-record.yml';
@ -72,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.latestBlockHeight)).toBeGreaterThan(0);
expect(Number(outputObj.sync.latest_block_height)).toBeGreaterThan(0);
expect(outputObj).toHaveProperty('validator');
expect(outputObj).toHaveProperty('validators');
expect(outputObj).toHaveProperty('numPeers');
expect(outputObj).toHaveProperty('num_peers');
expect(outputObj).toHaveProperty('peers');
expect(outputObj).toHaveProperty('diskUsage');
expect(outputObj).toHaveProperty('disk_usage');
});
describe('Bond operations', () => {
@ -222,41 +217,19 @@ describe('Test laconic CLI commands', () => {
getAccountObj({ address: testAccount2, balance: sendAmount })
];
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);
expect(outputObj.length).toEqual(2);
expect(outputObj).toMatchObject(expectedAccounts);
});
});
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> --fees <fees>', async () => {
test('laconic registry record publish --filename <record_file> --bond-id <bond_id> --gas <gas>', async () => {
// Create a new bond to be associated with the record
({ bondId: testRecordBondId } = createBond(bondBalance));
const result = spawnSync('laconic', ['registry', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString(), '--fees', fees]);
const result = spawnSync('laconic', ['registry', 'record', 'publish', '--filename', testRecordFilePath, '--bond-id', testRecordBondId, '--gas', gas.toString()]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expect output object to resultant bond id
@ -374,7 +347,7 @@ describe('Test laconic CLI commands', () => {
});
});
describe('Authority auction operations', () => {
describe('Auction operations', () => {
const bidAmount = 25000000;
let bidRevealFilePath: string;
@ -424,7 +397,7 @@ describe('Test laconic CLI commands', () => {
chainId: CHAIN_ID,
auctionId: testAuctionId,
bidderAddress: testAccount,
bidAmount: `${bidAmount}alnt`
bidAmount: `${bidAmount}photon`
});
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
});
@ -504,47 +477,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', () => {
@ -591,378 +523,5 @@ describe('Test laconic CLI commands', () => {
expect(resolveOutputObj.length).toEqual(0);
});
});
describe('Vickrey Auction operations', () => {
const commitFee = 1000;
const revealFee = 1000;
const minimumBid = 100000;
const bidAmount = 25000000;
let bidRevealFilePath: string;
test('laconic registry auction create --kind <kind> --commits-duration <commits_duration> --reveals-duration <reveals_duration> --denom <denom> --commit-fee <commit_fee> --reveal-fee <reveal_fee> --minimum-bid <minimum_bid>', async () => {
const createAuctionResult = spawnSync('laconic', [
'registry',
'auction',
'create',
'--kind', AUCTION_KIND_VICKREY,
'--commits-duration', AUCTION_COMMIT_DURATION.toString(),
'--reveals-duration', AUCTION_REVEAL_DURATION.toString(),
'--denom', TOKEN_TYPE,
'--commit-fee', commitFee.toString(),
'--reveal-fee', revealFee.toString(),
'--minimum-bid', minimumBid.toString()
]);
const outputObj = checkResultAndRetrieveOutput(createAuctionResult);
expect(outputObj).toHaveProperty('auctionId');
testAuctionId = outputObj.auctionId;
const getAuctionResult = spawnSync('laconic', ['registry', 'auction', 'get', '--id', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(getAuctionResult);
const expectedAuctionObjPartial = {
kind: AUCTION_KIND_VICKREY,
status: AUCTION_STATUS.COMMIT,
ownerAddress: testAccount,
commitFee: { quantity: commitFee },
revealFee: { quantity: revealFee },
minimumBid: { quantity: minimumBid },
winnerAddresses: [],
winnerBids: [],
maxPrice: { quantity: 0 },
numProviders: 0,
bids: []
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
});
test('laconic registry auction bid commit <auction_id> <quantity> <type>', async () => {
const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidAmount.toString(), TOKEN_TYPE]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj.reveal_file).toBeDefined();
bidRevealFilePath = outputObj.reveal_file;
});
test('laconic registry auction bid reveal <auction_id> <file_path>', async () => {
// Wait for auction commits duration (60s)
await delay(AUCTION_COMMIT_DURATION * 1000);
let auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
let auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedAuctionObjPartial = {
status: AUCTION_STATUS.REVEAL,
ownerAddress: testAccount,
winnerAddresses: [],
winnerBids: [],
bids: [{
bidderAddress: testAccount,
status: AUCTION_STATUS.COMMIT,
bidAmount: { quantity: 0 }
}]
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
// Reveal bid
const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePath]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj).toEqual({ success: true });
const revealObject = JSON.parse(fs.readFileSync(bidRevealFilePath, 'utf8'));
expect(revealObject).toMatchObject({
chainId: CHAIN_ID,
auctionId: testAuctionId,
bidderAddress: testAccount,
bidAmount: `${bidAmount}${TOKEN_TYPE}`
});
// Get auction with revealed bid
auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedAuctionObjPartialOnBidReveal = {
status: AUCTION_STATUS.REVEAL,
winnerAddresses: [],
bids: [{
bidderAddress: testAccount,
status: AUCTION_STATUS.REVEAL,
bidAmount: { quantity: bidAmount }
}]
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartialOnBidReveal);
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
test('laconic registry auction get <auction_id>', async () => {
// Wait for auction reveals duration (60s)
await delay(AUCTION_REVEAL_DURATION * 1000);
const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedAuctionObjPartial = {
status: AUCTION_STATUS.COMPLETED,
ownerAddress: testAccount,
winnerAddresses: [testAccount],
winnerBids: [{ quantity: bidAmount }],
winnerPrice: { quantity: bidAmount }
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
});
describe('Provider Auction operations', () => {
const txFees = getFeesConfig();
const commitFee = 1000;
const revealFee = 1000;
const maxPrice = 1000000;
const numProviders = 2;
const bidderInitialBlanace = 1000000000;
testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350';
const bidderAccounts = [
{
privateKey: 'f40f8e2c9ba70595b6d1cf3bcc47ba539e7d6ad2bcdb16e26c1e369378fd5a55',
address: 'laconic13cd6ntlcf5y0zmafg6wf96y6vsnq46xagpmjtc',
bidAmount: 25000
},
{
privateKey: '2c70e81c285e12f196837911aa258b11dff7e4189fc0f11e28cb228956807881',
address: 'laconic15x7sw49w3x2pahjlr48hunp5gpr7hm54eg3f8h',
bidAmount: 25300
},
{
privateKey: '1d3a47900e1a5980b171419ac700e779330bc0f85389a4113ff608ca314e25bb',
address: 'laconic1lkgay8ejvcwmngj3jua2ancdxxkukecz7hty89',
bidAmount: 25200
}
];
const winnerAccounts = [bidderAccounts[0], bidderAccounts[2]];
const winnerPrice = bidderAccounts[2].bidAmount;
const bidRevealFilePaths: string[] = [];
beforeAll(() => {
// Fund all bidder accounts
bidderAccounts.forEach(account => {
spawnSync('laconic', ['registry', 'tokens', 'send', '--address', account.address, '--type', TOKEN_TYPE, '--quantity', bidderInitialBlanace.toString()]);
});
});
test('laconic registry auction create --kind <kind> --commits-duration <commits_duration> --reveals-duration <reveals_duration> --denom <denom> --commit-fee <commit_fee> --reveal-fee <reveal_fee> --max-price <max_price> --num-providers <num_providers>', async () => {
const createAuctionResult = spawnSync('laconic', [
'registry',
'auction',
'create',
'--kind', AUCTION_KIND_PROVIDER,
'--commits-duration', AUCTION_COMMIT_DURATION.toString(),
'--reveals-duration', AUCTION_REVEAL_DURATION.toString(),
'--denom', TOKEN_TYPE,
'--commit-fee', commitFee.toString(),
'--reveal-fee', revealFee.toString(),
'--max-price', maxPrice.toString(),
'--num-providers', numProviders.toString()
]);
const outputObj = checkResultAndRetrieveOutput(createAuctionResult);
expect(outputObj).toHaveProperty('auctionId');
testAuctionId = outputObj.auctionId;
const getAuctionResult = spawnSync('laconic', ['registry', 'auction', 'get', '--id', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(getAuctionResult);
const expectedAuctionObjPartial = {
kind: AUCTION_KIND_PROVIDER,
status: AUCTION_STATUS.COMMIT,
ownerAddress: testAccount,
commitFee: { quantity: commitFee },
revealFee: { quantity: revealFee },
minimumBid: { quantity: 0 },
winnerAddresses: [],
winnerBids: [],
maxPrice: { quantity: maxPrice },
numProviders: numProviders,
bids: []
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
});
test('laconic registry auction bid commit <auction_id> <quantity> <type>', async () => {
for (const bidderAccount of bidderAccounts) {
const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'commit', testAuctionId, bidderAccount.bidAmount.toString(), TOKEN_TYPE, '--txKey', bidderAccount.privateKey]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj.reveal_file).toBeDefined();
bidRevealFilePaths.push(outputObj.reveal_file);
}
const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedBids = bidderAccounts.map(account => ({
bidderAddress: account.address,
status: AUCTION_STATUS.COMMIT,
bidAmount: { quantity: 0 }
}));
const expectedAuctionObjPartial = {
status: AUCTION_STATUS.COMMIT,
ownerAddress: testAccount,
winnerAddresses: [],
winnerBids: [],
bids: expectedBids
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
});
test('laconic registry auction bid reveal <auction_id> <file_path>', async () => {
// Wait for auction commits duration (60s)
await delay(AUCTION_COMMIT_DURATION * 1000);
// Reveal bid
for (let i = 0; i < bidderAccounts.length; i++) {
const result = spawnSync('laconic', ['registry', 'auction', 'bid', 'reveal', testAuctionId, bidRevealFilePaths[i], '--txKey', bidderAccounts[i].privateKey]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj).toEqual({ success: true });
const revealObject = JSON.parse(fs.readFileSync(bidRevealFilePaths[i], 'utf8'));
expect(revealObject).toMatchObject({
chainId: CHAIN_ID,
auctionId: testAuctionId,
bidderAddress: bidderAccounts[i].address,
bidAmount: `${bidderAccounts[i].bidAmount}${TOKEN_TYPE}`
});
}
// Get auction with revealed bid
const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedBids = bidderAccounts.map(account => ({
bidderAddress: account.address,
status: AUCTION_STATUS.REVEAL,
bidAmount: { quantity: account.bidAmount }
}));
const expectedAuctionObjPartialOnBidReveal = {
status: AUCTION_STATUS.REVEAL,
winnerAddresses: [],
bids: expectedBids
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartialOnBidReveal);
}, (AUCTION_COMMIT_DURATION + 60) * 1000);
test('laconic registry auction get <auction_id>', async () => {
// Wait for auction reveals duration (60s)
await delay(AUCTION_REVEAL_DURATION * 1000);
const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedWinnerAddresses = winnerAccounts.map(account => account.address);
const expectedWinnerBids = winnerAccounts.map(account => ({ quantity: account.bidAmount }));
const expectedAuctionObjPartial = {
status: AUCTION_STATUS.COMPLETED,
ownerAddress: testAccount,
winnerAddresses: expectedWinnerAddresses,
winnerBids: expectedWinnerBids,
winnerPrice: { quantity: winnerPrice },
fundsReleased: false
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
}, (AUCTION_REVEAL_DURATION + 5) * 1000);
test('laconic registry auction release-funds <auction_id>', async () => {
const result = spawnSync('laconic', ['registry', 'auction', 'release-funds', testAuctionId]);
const outputObj = checkResultAndRetrieveOutput(result);
expect(outputObj).toEqual({ success: true });
const auctionResult = spawnSync('laconic', ['registry', 'auction', 'get', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedAuctionObjPartial = {
status: AUCTION_STATUS.COMPLETED,
ownerAddress: testAccount,
fundsReleased: true
};
expect(auctionOutputObj[0]).toMatchObject(expectedAuctionObjPartial);
const expectedBalances = [
bidderInitialBlanace - (commitFee) - (2 * txFees) + winnerPrice,
bidderInitialBlanace - (commitFee) - (2 * txFees),
bidderInitialBlanace - (commitFee) - (2 * txFees) + winnerPrice
];
for (let i = 0; i < bidderAccounts.length; i++) {
const result = spawnSync('laconic', ['registry', 'account', 'get', '--address', bidderAccounts[i].address]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected account
const expectedAccount = getAccountObj({ address: bidderAccounts[i].address, balance: expectedBalances[i] });
expect(outputObj.length).toEqual(1);
expect(outputObj[0]).toMatchObject(expectedAccount);
}
});
});
describe('Gas and fees config', () => {
const bondAmount = 1000;
test('gas set, fees set to Xalnt', async () => {
// gasPrice not set
const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondAmount.toString()]);
const outputObj = checkResultAndRetrieveOutput(result);
expect(outputObj.bondId).toBeDefined();
// gasPrice set (lower than min gas price)
updateGasAndFeesConfig(undefined, undefined, '0.00001alnt');
const result1 = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondAmount.toString()]);
const outputObj1 = checkResultAndRetrieveOutput(result1);
expect(outputObj1.bondId).toBeDefined();
});
test('gas not set, fees not set, gasPrice set', async () => {
updateGasAndFeesConfig(null, null, '1alnt');
const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondAmount.toString()]);
const outputObj = checkResultAndRetrieveOutput(result);
expect(outputObj.bondId).toBeDefined();
});
test('gas not set, fees set without token suffix, gasPrice set', async () => {
updateGasAndFeesConfig(null, '1.8', '1alnt');
const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondAmount.toString()]);
const outputObj = checkResultAndRetrieveOutput(result);
expect(outputObj.bondId).toBeDefined();
});
test('gas not set, fees not set, gasPrice not set', async () => {
updateGasAndFeesConfig(null, null, null);
const result = spawnSync('laconic', ['registry', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondAmount.toString()]);
expect(result.status).toBe(1);
const output = result.stdout.toString().trim();
const errorOutput = result.stderr.toString().trim();
expect(output).toBe('');
expect(errorOutput).toContain('Gas price must be set in the client options when auto gas is used.');
});
});
});
});

View File

@ -1,22 +1,9 @@
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { SpawnSyncReturns, spawnSync } from 'child_process';
import { Arguments } from 'yargs';
import { StdFee } from '@cosmjs/stargate';
import { getConfig, getGasAndFees } from '../src/util';
export const CHAIN_ID = 'laconic_9000-1';
export const TOKEN_TYPE = 'alnt';
export const CONFIG_FILE = 'config.yml';
export enum AUCTION_STATUS {
COMMIT = 'commit',
REVEAL = 'reveal',
COMPLETED = 'completed'
}
export const TOKEN_TYPE = 'photon';
export const AUCTION_FEES = {
commit: 1000000,
@ -27,10 +14,6 @@ export const AUCTION_COMMIT_DURATION = 60; // 60s
export const AUCTION_REVEAL_DURATION = 60; // 60s
export function checkResultAndRetrieveOutput (result: SpawnSyncReturns<Buffer>): any {
if (result.status !== 0) {
console.log('stderr', result.stderr.toString().trim());
}
expect(result.status).toBe(0);
const errorOutput = result.stderr.toString().trim();
@ -109,8 +92,7 @@ export function getAuctionObj (params: { owner: string, status?: string }): any
type: TOKEN_TYPE,
quantity: AUCTION_FEES.minimumBid
},
winnerAddresses: [],
winnerBids: []
winnerAddress: ''
};
}
@ -136,38 +118,3 @@ export function getBidObj (params: { bidder: string, status?: string }): any {
export async function delay (ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function getFeesConfig (): number {
const { services: { registry: registryConfig } } = getConfig(CONFIG_FILE);
const fee = getGasAndFees({} as Arguments, registryConfig);
return Number((fee as StdFee).amount[0].amount);
}
export function updateGasAndFeesConfig (gas?: string | null, fees?: string | null, gasPrice?: string | null): void {
const config = getConfig(path.resolve(CONFIG_FILE));
if (gas) {
config.services.registry.gas = gas;
} else if (gas === null) {
delete config.services.registry.gas;
}
if (fees) {
config.services.registry.fees = fees;
} else if (fees === null) {
delete config.services.registry.fees;
}
if (gasPrice) {
config.services.registry.gasPrice = gasPrice;
} else if (gasPrice === null) {
delete config.services.registry.gasPrice;
}
try {
fs.writeFileSync(CONFIG_FILE, yaml.dump(config), 'utf8');
} catch (e) {
console.error('Error writing config file:', e);
throw e;
}
}

View File

@ -1,11 +1,5 @@
#!/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)
@ -28,10 +22,13 @@ services:
bondId:
chainId: $cosmos_chain_id
gas: 200000
fees: 200000alnt
fees: 200000photon
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

195
yarn.lock
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.11":
version "0.2.11"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.11/registry-sdk-0.2.11.tgz#019b792c68f440f2cfca5af2f49e1205bb33ba72"
integrity sha512-IipqJzaBQEXMNH6yWFG2E/o0U6IAXw35PBMHx6QIboVu/sMNLIsWy1P8MmR8C8xYsmHOhgXLsC4hYSeFMXrqFw==
"@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==
dependencies:
"@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1"
@ -365,16 +365,6 @@
"@cosmjs/math" "0.28.4"
"@cosmjs/utils" "0.28.4"
"@cosmjs/amino@^0.32.2":
version "0.32.4"
resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.32.4.tgz#3908946c0394e6d431694c8992c5147079a1c860"
integrity sha512-zKYOt6hPy8obIFtLie/xtygCkH9ZROiQ12UHfKsOkWaZfPQUvVbtgmu6R4Kn1tFLI/SRkw7eqhaogmW/3NYu/Q==
dependencies:
"@cosmjs/crypto" "^0.32.4"
"@cosmjs/encoding" "^0.32.4"
"@cosmjs/math" "^0.32.4"
"@cosmjs/utils" "^0.32.4"
"@cosmjs/amino@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.32.3.tgz#b81d4a2b8d61568431a1afcd871e1344a19d97ff"
@ -427,19 +417,6 @@
elliptic "^6.5.4"
libsodium-wrappers-sumo "^0.7.11"
"@cosmjs/crypto@^0.32.4":
version "0.32.4"
resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.32.4.tgz#5d29633b661eaf092ddb3e7ea6299cfd6f4507a2"
integrity sha512-zicjGU051LF1V9v7bp8p7ovq+VyC91xlaHdsFOTo2oVry3KQikp8L/81RkXmUIT8FxMwdx1T7DmFwVQikcSDIw==
dependencies:
"@cosmjs/encoding" "^0.32.4"
"@cosmjs/math" "^0.32.4"
"@cosmjs/utils" "^0.32.4"
"@noble/hashes" "^1"
bn.js "^5.2.0"
elliptic "^6.5.4"
libsodium-wrappers-sumo "^0.7.11"
"@cosmjs/encoding@0.27.1":
version "0.27.1"
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.27.1.tgz#3cd5bc0af743485eb2578cdb08cfa84c86d610e1"
@ -458,15 +435,6 @@
bech32 "^1.1.4"
readonly-date "^1.0.0"
"@cosmjs/encoding@^0.32.2", "@cosmjs/encoding@^0.32.4":
version "0.32.4"
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.32.4.tgz#646e0e809f7f4f1414d8fa991fb0ffe6c633aede"
integrity sha512-tjvaEy6ZGxJchiizzTn7HVRiyTg1i4CObRRaTRPknm5EalE13SV+TCHq38gIDfyUeden4fCuaBVEdBR5+ti7Hw==
dependencies:
base64-js "^1.3.0"
bech32 "^1.1.4"
readonly-date "^1.0.0"
"@cosmjs/encoding@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.32.3.tgz#e245ff511fe4a0df7ba427b5187aab69e3468e5b"
@ -511,13 +479,6 @@
dependencies:
bn.js "^5.2.0"
"@cosmjs/math@^0.32.2", "@cosmjs/math@^0.32.4":
version "0.32.4"
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.32.4.tgz#87ac9eadc06696e30a30bdb562a495974bfd0a1a"
integrity sha512-++dqq2TJkoB8zsPVYCvrt88oJWsy1vMOuSOKcdlnXuOA/ASheTJuYy4+oZlTQ3Fr8eALDLGGPhJI02W2HyAQaw==
dependencies:
bn.js "^5.2.0"
"@cosmjs/math@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.32.3.tgz#16e4256f4da507b9352327da12ae64056a2ba6c9"
@ -525,7 +486,7 @@
dependencies:
bn.js "^5.2.0"
"@cosmjs/proto-signing@^0.32.2":
"@cosmjs/proto-signing@^0.32.2", "@cosmjs/proto-signing@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.32.3.tgz#91ae149b747d18666a6ccc924165b306431f7c0d"
integrity sha512-kSZ0ZUY0DwcRT0NcIn2HkadH4NKlwjfZgbLj1ABwh/4l0RgeT84QCscZCu63tJYq3K6auwqTiZSZERwlO4/nbg==
@ -548,28 +509,21 @@
xstream "^11.14.0"
"@cosmjs/stargate@^0.32.2":
version "0.32.2"
resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.32.2.tgz#73718c5c6a3ae138682ee9987333d911eca22a13"
integrity sha512-AsJa29fT7Jd4xt9Ai+HMqhyj7UQu7fyYKdXj/8+/9PD74xe6lZSYhQPcitUmMLJ1ckKPgXSk5Dd2LbsQT0IhZg==
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.32.3.tgz#5a92b222ada960ebecea72cc9f366370763f4b66"
integrity sha512-OQWzO9YWKerUinPIxrO1MARbe84XkeXJAW0lyMIjXIEikajuXZ+PwftiKA5yA+8OyditVmHVLtPud6Pjna2s5w==
dependencies:
"@confio/ics23" "^0.6.8"
"@cosmjs/amino" "^0.32.2"
"@cosmjs/encoding" "^0.32.2"
"@cosmjs/math" "^0.32.2"
"@cosmjs/proto-signing" "^0.32.2"
"@cosmjs/stream" "^0.32.2"
"@cosmjs/tendermint-rpc" "^0.32.2"
"@cosmjs/utils" "^0.32.2"
"@cosmjs/amino" "^0.32.3"
"@cosmjs/encoding" "^0.32.3"
"@cosmjs/math" "^0.32.3"
"@cosmjs/proto-signing" "^0.32.3"
"@cosmjs/stream" "^0.32.3"
"@cosmjs/tendermint-rpc" "^0.32.3"
"@cosmjs/utils" "^0.32.3"
cosmjs-types "^0.9.0"
xstream "^11.14.0"
"@cosmjs/stream@^0.32.2":
version "0.32.4"
resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.32.4.tgz#83e1f2285807467c56d9ea0e1113f79d9fa63802"
integrity sha512-Gih++NYHEiP+oyD4jNEUxU9antoC0pFSg+33Hpp0JlHwH0wXhtD3OOKnzSfDB7OIoEbrzLJUpEjOgpCp5Z+W3A==
dependencies:
xstream "^11.14.0"
"@cosmjs/stream@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/stream/-/stream-0.32.3.tgz#7522579aaf18025d322c2f33d6fb7573220395d6"
@ -577,7 +531,7 @@
dependencies:
xstream "^11.14.0"
"@cosmjs/tendermint-rpc@^0.32.2":
"@cosmjs/tendermint-rpc@^0.32.2", "@cosmjs/tendermint-rpc@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.32.3.tgz#f0406b9f0233e588fb924dca8c614972f9038aff"
integrity sha512-xeprW+VR9xKGstqZg0H/KBZoUp8/FfFyS9ljIUTLM/UINjP2MhiwncANPS2KScfJVepGufUKk0/phHUeIBSEkw==
@ -603,11 +557,6 @@
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.28.4.tgz#ecbc72458cdaffa6eeef572bc691502b3151330f"
integrity sha512-lb3TU6833arPoPZF8HTeG9V418CpurvqH5Aa/ls0I0wYdPDEMO6622+PQNQhQ8Vw8Az2MXoSyc8jsqrgawT84Q==
"@cosmjs/utils@^0.32.2", "@cosmjs/utils@^0.32.4":
version "0.32.4"
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.32.4.tgz#a9a717c9fd7b1984d9cefdd0ef6c6f254060c671"
integrity sha512-D1Yc+Zy8oL/hkUkFUL/bwxvuDBzRGpc4cF7/SkdhxX4iHpSLgdOuTt1mhCh9+kl6NQREy9t7SYZ6xeW5gFe60w==
"@cosmjs/utils@^0.32.3":
version "0.32.3"
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.32.3.tgz#5dcaee6dd7cc846cdc073e9a7a7f63242f5f7e31"
@ -1327,6 +1276,101 @@
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"
@ -2008,6 +2052,11 @@ 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"
@ -2422,6 +2471,11 @@ 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"
@ -4385,7 +4439,7 @@ object.values@^1.1.7:
define-properties "^1.2.0"
es-abstract "^1.22.1"
once@^1.3.0:
once@^1.3.0, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
@ -5216,6 +5270,11 @@ 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"