From 743f5ebc3cd3b0ef01f696a9d8f9e563e8aeb07a Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 27 Aug 2024 18:02:01 +0530 Subject: [PATCH] Update bond list CLI for owner filter --- README.md | 36 +++++++++++++----------- src/cmds/registry-cmds/bond-cmds/list.ts | 9 +++++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 92abd82..f77d6f8 100644 --- a/README.md +++ b/README.md @@ -66,21 +66,22 @@ services: ## Gas and Fees - +- Gas and fees in `cosmos-sdk`: + - + - `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`: -- `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`: + ```bash + fees = gas * gasPrice + ``` - ```bash - fees = gas * gasPrice - ``` + - 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) -- Typically, validators / full nodes set `min-gas-prices` to only allow txs providing minimum amount of fees -- There are two ways max fees amount can be given for a tx: - - Either by specifying `fees` and `gas` in the config (in which case fees should be >= gas * min-gas-price) - - Or by specifying a `gasPrice` (in which case gasPrice should be > min-gas-price and fees is calculated by simulating the tx) -- When using the `auto` fees calculation, the gas estimation by tx simulation is typically multiplied by a multiplier + 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`: @@ -104,8 +105,9 @@ services: ``` - `gas` config ignored - - uses `auto` fee calculation using gas estimation with default multiplier value from `registry-sdk` - - tx fails mid-execution if it runs out of given gas + - 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 @@ -117,7 +119,8 @@ services: - `gas` config ignored - uses `auto` fee calculation using gas estimation with `fees` as the multiplier - - tx fails mid-execution if it runs out of given gas, can be retried with a higher gas estimation multiplier (`fees`) + - 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 @@ -128,7 +131,8 @@ services: ``` - `gas` config ignored - - Throws error: + - uses `auto` fee calculation using gas estimation + - throws error: ```bash Gas price must be set in the client options when auto gas is used. diff --git a/src/cmds/registry-cmds/bond-cmds/list.ts b/src/cmds/registry-cmds/bond-cmds/list.ts index 82fb221..d27a482 100644 --- a/src/cmds/registry-cmds/bond-cmds/list.ts +++ b/src/cmds/registry-cmds/bond-cmds/list.ts @@ -23,8 +23,15 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId }); + let result: any; + const { owner } = argv; - const result = await registry.queryBonds({ owner }); + if (owner) { + const [bondsByOwnerResult] = await registry.queryBondsByOwner([String(owner)]); + result = bondsByOwnerResult.bonds; + } else { + result = await registry.queryBonds(); + } queryOutput(result, argv.output); };