* Refactor CliContext as Context
* Fix lint issues
* Fix goimports
* Fix gov tests
* Resolved ci-lint issues
* Add changelog
* Rename cliCtx to clientCtx
* Fix mocks and routes
* Add changelog
* Update changelog
* Apply suggestions from code review
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
* merge client/rpc/ro{ot,utes}.go
* Update docs
* client/rpc: remove redundant client/rpc.RegisterRPCRoutes
* regenerate mocks
* Update ADRs
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
)
|
|
|
|
func queryTotalSupply(clientCtx client.Context, cdc *codec.Codec) error {
|
|
params := types.NewQueryTotalSupplyParams(1, 0) // no pagination
|
|
bz, err := cdc.MarshalJSON(params)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
res, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalSupply), bz)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var totalSupply sdk.Coins
|
|
err = cdc.UnmarshalJSON(res, &totalSupply)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintOutput(totalSupply)
|
|
}
|
|
|
|
func querySupplyOf(clientCtx client.Context, cdc *codec.Codec, denom string) error {
|
|
params := types.NewQuerySupplyOfParams(denom)
|
|
bz, err := cdc.MarshalJSON(params)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
res, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QuerySupplyOf), bz)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var supply sdk.Int
|
|
err = cdc.UnmarshalJSON(res, &supply)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintOutput(supply)
|
|
}
|