mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 15:55:18 +00:00
Remove used legacy querier types (#1835)
These were left out by accident when the legacy queriers are removed from the modules in this commit 3ba4078ec1
This commit is contained in:
parent
2bc0c62570
commit
11d3ba3466
@ -1,95 +0,0 @@
|
|||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
errorsmod "cosmossdk.io/errors"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/auction/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
defaultPage = 1
|
|
||||||
defaultLimit = 100
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryAuctionByID returns an auction from state if present or falls back to searching old blocks
|
|
||||||
func QueryAuctionByID(cliCtx client.Context, cdc *codec.Codec, queryRoute string, auctionID uint64) (types.Auction, int64, error) {
|
|
||||||
bz, err := cliCtx.LegacyAmino.MarshalJSON(types.NewQueryAuctionParams(auctionID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryGetAuction), bz)
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
var auction types.Auction
|
|
||||||
cliCtx.LegacyAmino.MustUnmarshalJSON(res, &auction)
|
|
||||||
|
|
||||||
return auction, height, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil && !strings.Contains(err.Error(), "auction not found") {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res, height, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryNextAuctionID), nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var nextAuctionID uint64
|
|
||||||
cliCtx.LegacyAmino.MustUnmarshalJSON(res, &nextAuctionID)
|
|
||||||
|
|
||||||
if auctionID >= nextAuctionID {
|
|
||||||
return nil, 0, errorsmod.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
|
|
||||||
}
|
|
||||||
|
|
||||||
events := []string{
|
|
||||||
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, "place_bid"),
|
|
||||||
fmt.Sprintf("%s.%s='%s'", types.EventTypeAuctionBid, types.AttributeKeyAuctionID, []byte(fmt.Sprintf("%d", auctionID))),
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the auction is closed, query for previous bid transactions
|
|
||||||
// note, will only fetch a maximum of 100 bids, so if an auction had more than that this
|
|
||||||
// query may fail to retreive the final state of the auction
|
|
||||||
searchResult, err := authtx.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit, "")
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
maxHeight := int64(0)
|
|
||||||
found := false
|
|
||||||
|
|
||||||
for _, info := range searchResult.Txs {
|
|
||||||
for _, msg := range info.GetTx().GetMsgs() {
|
|
||||||
_, ok := msg.(*types.MsgPlaceBid)
|
|
||||||
if ok {
|
|
||||||
found = true
|
|
||||||
if info.Height > maxHeight {
|
|
||||||
maxHeight = info.Height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
return nil, 0, errorsmod.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
|
|
||||||
}
|
|
||||||
|
|
||||||
queryCLIContext := cliCtx.WithHeight(maxHeight)
|
|
||||||
res, height, err = queryCLIContext.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryGetAuction), bz)
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode and print results
|
|
||||||
var auction types.Auction
|
|
||||||
cliCtx.LegacyAmino.MustUnmarshalJSON(res, &auction)
|
|
||||||
return auction, height, nil
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// QueryGetAuction is the query path for querying one auction
|
|
||||||
QueryGetAuction = "auction"
|
|
||||||
// QueryGetAuctions is the query path for querying all auctions
|
|
||||||
QueryGetAuctions = "auctions"
|
|
||||||
// QueryGetParams is the query path for querying the global auction params
|
|
||||||
QueryGetParams = "params"
|
|
||||||
// QueryNextAuctionID is the query path for querying the id of the next auction
|
|
||||||
QueryNextAuctionID = "next-auction-id"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryAuctionParams params for query /auction/auction
|
|
||||||
type QueryAuctionParams struct {
|
|
||||||
AuctionID uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAuctionParams returns a new QueryAuctionParams
|
|
||||||
func NewQueryAuctionParams(id uint64) QueryAuctionParams {
|
|
||||||
return QueryAuctionParams{
|
|
||||||
AuctionID: id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryAllAuctionParams is the params for an auctions query
|
|
||||||
type QueryAllAuctionParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Type string `json:"type" yaml:"type"`
|
|
||||||
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
Phase string `json:"phase" yaml:"phase"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAllAuctionParams creates a new QueryAllAuctionParams
|
|
||||||
func NewQueryAllAuctionParams(page, limit int, aucType, aucDenom, aucPhase string, aucOwner sdk.AccAddress) QueryAllAuctionParams {
|
|
||||||
return QueryAllAuctionParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Type: aucType,
|
|
||||||
Owner: aucOwner,
|
|
||||||
Denom: aucDenom,
|
|
||||||
Phase: aucPhase,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AuctionWithPhase augmented type for collateral auctions which includes auction phase for querying
|
|
||||||
type AuctionWithPhase struct {
|
|
||||||
Auction Auction `json:"auction" yaml:"auction"`
|
|
||||||
|
|
||||||
Type string `json:"type" yaml:"type"`
|
|
||||||
Phase string `json:"phase" yaml:"phase"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAuctionWithPhase returns new AuctionWithPhase
|
|
||||||
func NewAuctionWithPhase(a Auction) AuctionWithPhase {
|
|
||||||
return AuctionWithPhase{
|
|
||||||
Auction: a,
|
|
||||||
Type: a.GetType(),
|
|
||||||
Phase: a.GetPhase(),
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
tmbytes "github.com/cometbft/cometbft/libs/bytes"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// QueryGetAssetSupply command for getting info about an asset's supply
|
|
||||||
QueryGetAssetSupply = "supply"
|
|
||||||
// QueryGetAssetSupplies command for getting a list of asset supplies
|
|
||||||
QueryGetAssetSupplies = "supplies"
|
|
||||||
// QueryGetAtomicSwap command for getting info about an atomic swap
|
|
||||||
QueryGetAtomicSwap = "swap"
|
|
||||||
// QueryGetAtomicSwaps command for getting a list of atomic swaps
|
|
||||||
QueryGetAtomicSwaps = "swaps"
|
|
||||||
// QueryGetParams command for getting module params
|
|
||||||
QueryGetParams = "parameters"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Legacy querier requests
|
|
||||||
|
|
||||||
// QueryAssetSupply contains the params for query 'custom/bep3/supply'
|
|
||||||
type QueryAssetSupply struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAssetSupply creates a new QueryAssetSupply
|
|
||||||
func NewQueryAssetSupply(denom string) QueryAssetSupply {
|
|
||||||
return QueryAssetSupply{
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryAssetSupplies contains the params for an AssetSupplies query
|
|
||||||
type QueryAssetSupplies struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAssetSupplies creates a new QueryAssetSupplies
|
|
||||||
func NewQueryAssetSupplies(page int, limit int) QueryAssetSupplies {
|
|
||||||
return QueryAssetSupplies{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryAtomicSwapByID contains the params for query 'custom/bep3/swap'
|
|
||||||
type QueryAtomicSwapByID struct {
|
|
||||||
SwapID tmbytes.HexBytes `json:"swap_id" yaml:"swap_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAtomicSwapByID creates a new QueryAtomicSwapByID
|
|
||||||
func NewQueryAtomicSwapByID(swapBytes tmbytes.HexBytes) QueryAtomicSwapByID {
|
|
||||||
return QueryAtomicSwapByID{
|
|
||||||
SwapID: swapBytes,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryAtomicSwaps contains the params for an AtomicSwaps query
|
|
||||||
type QueryAtomicSwaps struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Involve sdk.AccAddress `json:"involve" yaml:"involve"`
|
|
||||||
Expiration uint64 `json:"expiration" yaml:"expiration"`
|
|
||||||
Status SwapStatus `json:"status" yaml:"status"`
|
|
||||||
Direction SwapDirection `json:"direction" yaml:"direction"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAtomicSwaps creates a new instance of QueryAtomicSwaps
|
|
||||||
func NewQueryAtomicSwaps(page, limit int, involve sdk.AccAddress, expiration uint64,
|
|
||||||
status SwapStatus, direction SwapDirection,
|
|
||||||
) QueryAtomicSwaps {
|
|
||||||
return QueryAtomicSwaps{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Involve: involve,
|
|
||||||
Expiration: expiration,
|
|
||||||
Status: status,
|
|
||||||
Direction: direction,
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,36 +4,6 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Querier routes for the cdp module
|
|
||||||
const (
|
|
||||||
QueryGetCdp = "cdp"
|
|
||||||
QueryGetCdps = "cdps"
|
|
||||||
QueryGetCdpDeposits = "deposits"
|
|
||||||
QueryGetCdpsByCollateralization = "ratio" // legacy query, maintained for REST API
|
|
||||||
QueryGetCdpsByCollateralType = "collateralType" // legacy query, maintained for REST API
|
|
||||||
QueryGetParams = "params"
|
|
||||||
QueryGetAccounts = "accounts"
|
|
||||||
QueryGetTotalPrincipal = "totalPrincipal"
|
|
||||||
QueryGetTotalCollateral = "totalCollateral"
|
|
||||||
RestOwner = "owner"
|
|
||||||
RestCollateralType = "collateral-type"
|
|
||||||
RestRatio = "ratio"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryCdpParams params for query /cdp/cdp
|
|
||||||
type QueryCdpParams struct {
|
|
||||||
CollateralType string // get CDPs with this collateral type
|
|
||||||
Owner sdk.AccAddress // get CDPs belonging to this owner
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryCdpParams returns QueryCdpParams
|
|
||||||
func NewQueryCdpParams(owner sdk.AccAddress, collateralType string) QueryCdpParams {
|
|
||||||
return QueryCdpParams{
|
|
||||||
Owner: owner,
|
|
||||||
CollateralType: collateralType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryCdpsParams is the params for a filtered CDP query
|
// QueryCdpsParams is the params for a filtered CDP query
|
||||||
type QueryCdpsParams struct {
|
type QueryCdpsParams struct {
|
||||||
Page int `json:"page" yaml:"page"`
|
Page int `json:"page" yaml:"page"`
|
||||||
@ -55,67 +25,3 @@ func NewQueryCdpsParams(page, limit int, collateralType string, owner sdk.AccAdd
|
|||||||
Ratio: ratio,
|
Ratio: ratio,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryCdpDeposits params for query /cdp/deposits
|
|
||||||
type QueryCdpDeposits struct {
|
|
||||||
CollateralType string // get CDPs with this collateral type
|
|
||||||
Owner sdk.AccAddress // get CDPs belonging to this owner
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryCdpDeposits returns QueryCdpDeposits
|
|
||||||
func NewQueryCdpDeposits(owner sdk.AccAddress, collateralType string) QueryCdpDeposits {
|
|
||||||
return QueryCdpDeposits{
|
|
||||||
Owner: owner,
|
|
||||||
CollateralType: collateralType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryCdpsByCollateralTypeParams params for query /cdp/cdps/{denom}
|
|
||||||
type QueryCdpsByCollateralTypeParams struct {
|
|
||||||
CollateralType string // get CDPs with this collateral type
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryCdpsByCollateralTypeParams returns QueryCdpsByCollateralTypeParams
|
|
||||||
func NewQueryCdpsByCollateralTypeParams(collateralType string) QueryCdpsByCollateralTypeParams {
|
|
||||||
return QueryCdpsByCollateralTypeParams{
|
|
||||||
CollateralType: collateralType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryCdpsByRatioParams params for query /cdp/cdps/ratio
|
|
||||||
type QueryCdpsByRatioParams struct {
|
|
||||||
CollateralType string
|
|
||||||
Ratio sdk.Dec // get CDPs below this collateral:debt ratio
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryCdpsByRatioParams returns QueryCdpsByRatioParams
|
|
||||||
func NewQueryCdpsByRatioParams(collateralType string, ratio sdk.Dec) QueryCdpsByRatioParams {
|
|
||||||
return QueryCdpsByRatioParams{
|
|
||||||
CollateralType: collateralType,
|
|
||||||
Ratio: ratio,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryGetTotalPrincipalParams params for query /cdp/totalPrincipal
|
|
||||||
type QueryGetTotalPrincipalParams struct {
|
|
||||||
CollateralType string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryGetTotalPrincipalParams returns QueryGetTotalPrincipalParams
|
|
||||||
func NewQueryGetTotalPrincipalParams(collateralType string) QueryGetTotalPrincipalParams {
|
|
||||||
return QueryGetTotalPrincipalParams{
|
|
||||||
CollateralType: collateralType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryGetTotalCollateralParams params for query /cdp/totalCollateral
|
|
||||||
type QueryGetTotalCollateralParams struct {
|
|
||||||
CollateralType string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryGetTotalCollateralParams returns QueryGetTotalCollateralParams
|
|
||||||
func NewQueryGetTotalCollateralParams(collateralType string) QueryGetTotalCollateralParams {
|
|
||||||
return QueryGetTotalCollateralParams{
|
|
||||||
CollateralType: collateralType,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
errorsmod "cosmossdk.io/errors"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||||
|
|
||||||
@ -62,99 +57,3 @@ func QueryProposer(cliCtx client.Context, proposalID uint64) (Proposer, error) {
|
|||||||
|
|
||||||
return Proposer{}, fmt.Errorf("failed to find the proposer for proposalID %d", proposalID)
|
return Proposer{}, fmt.Errorf("failed to find the proposer for proposalID %d", proposalID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryProposalByID returns a proposal from state if present or fallbacks to searching old blocks
|
|
||||||
func QueryProposalByID(cliCtx client.Context, cdc *codec.LegacyAmino, queryRoute string, proposalID uint64) (*types.Proposal, int64, error) {
|
|
||||||
bz, err := cdc.MarshalJSON(types.NewQueryProposalParams(proposalID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryProposal), bz)
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
var proposal types.Proposal
|
|
||||||
cdc.MustUnmarshalJSON(res, &proposal)
|
|
||||||
|
|
||||||
return &proposal, height, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: !errors.Is(err, types.ErrUnknownProposal) does not work here
|
|
||||||
if err != nil && !strings.Contains(err.Error(), "proposal not found") {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res, height, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryNextProposalID), nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var nextProposalID uint64
|
|
||||||
cdc.MustUnmarshalJSON(res, &nextProposalID)
|
|
||||||
|
|
||||||
if proposalID >= nextProposalID {
|
|
||||||
return nil, 0, errorsmod.Wrapf(types.ErrUnknownProposal, "%d", proposalID)
|
|
||||||
}
|
|
||||||
|
|
||||||
events := []string{
|
|
||||||
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgSubmitProposal),
|
|
||||||
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalSubmit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", proposalID))),
|
|
||||||
}
|
|
||||||
|
|
||||||
searchResult, err := authtx.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit, "")
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, info := range searchResult.Txs {
|
|
||||||
for _, msg := range info.GetTx().GetMsgs() {
|
|
||||||
if subMsg, ok := msg.(*types.MsgSubmitProposal); ok {
|
|
||||||
deadline, err := calculateDeadline(cliCtx, cdc, queryRoute, subMsg.CommitteeID, info.Height)
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
proposal, err := types.NewProposal(subMsg.GetPubProposal(), proposalID, subMsg.CommitteeID, deadline)
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
return &proposal, height, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, 0, errorsmod.Wrapf(types.ErrUnknownProposal, "%d", proposalID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculateDeadline returns the proposal deadline for a committee and block height
|
|
||||||
func calculateDeadline(cliCtx client.Context, cdc *codec.LegacyAmino, queryRoute string, committeeID uint64, blockHeight int64) (time.Time, error) {
|
|
||||||
var deadline time.Time
|
|
||||||
|
|
||||||
bz, err := cdc.MarshalJSON(types.NewQueryCommitteeParams(committeeID))
|
|
||||||
if err != nil {
|
|
||||||
return deadline, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryCommittee), bz)
|
|
||||||
if err != nil {
|
|
||||||
return deadline, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var committee types.Committee
|
|
||||||
err = cdc.UnmarshalJSON(res, &committee)
|
|
||||||
if err != nil {
|
|
||||||
return deadline, err
|
|
||||||
}
|
|
||||||
|
|
||||||
node, err := cliCtx.GetNode()
|
|
||||||
if err != nil {
|
|
||||||
return deadline, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resultBlock, err := node.Block(context.Background(), &blockHeight)
|
|
||||||
if err != nil {
|
|
||||||
return deadline, err
|
|
||||||
}
|
|
||||||
|
|
||||||
deadline = resultBlock.Block.Header.Time.Add(committee.GetProposalDuration())
|
|
||||||
return deadline, nil
|
|
||||||
}
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Query endpoints supported by the Querier
|
|
||||||
const (
|
|
||||||
QueryCommittees = "committees"
|
|
||||||
QueryCommittee = "committee"
|
|
||||||
QueryProposals = "proposals"
|
|
||||||
QueryProposal = "proposal"
|
|
||||||
QueryNextProposalID = "next-proposal-id"
|
|
||||||
QueryVotes = "votes"
|
|
||||||
QueryVote = "vote"
|
|
||||||
QueryTally = "tally"
|
|
||||||
QueryRawParams = "raw_params"
|
|
||||||
)
|
|
||||||
|
|
||||||
type QueryCommitteeParams struct {
|
|
||||||
CommitteeID uint64 `json:"committee_id" yaml:"committee_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewQueryCommitteeParams(committeeID uint64) QueryCommitteeParams {
|
|
||||||
return QueryCommitteeParams{
|
|
||||||
CommitteeID: committeeID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryProposalParams struct {
|
|
||||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewQueryProposalParams(proposalID uint64) QueryProposalParams {
|
|
||||||
return QueryProposalParams{
|
|
||||||
ProposalID: proposalID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryVoteParams struct {
|
|
||||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
|
|
||||||
Voter sdk.AccAddress `json:"voter" yaml:"voter"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams {
|
|
||||||
return QueryVoteParams{
|
|
||||||
ProposalID: proposalID,
|
|
||||||
Voter: voter,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryRawParamsParams struct {
|
|
||||||
Subspace string
|
|
||||||
Key string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewQueryRawParamsParams(subspace, key string) QueryRawParamsParams {
|
|
||||||
return QueryRawParamsParams{
|
|
||||||
Subspace: subspace,
|
|
||||||
Key: key,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,200 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
|
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Querier routes for the hard module
|
|
||||||
const (
|
|
||||||
QueryGetParams = "params"
|
|
||||||
QueryGetModuleAccounts = "accounts"
|
|
||||||
QueryGetDeposits = "deposits"
|
|
||||||
QueryGetUnsyncedDeposits = "unsynced-deposits"
|
|
||||||
QueryGetTotalDeposited = "total-deposited"
|
|
||||||
QueryGetBorrows = "borrows"
|
|
||||||
QueryGetUnsyncedBorrows = "unsynced-borrows"
|
|
||||||
QueryGetTotalBorrowed = "total-borrowed"
|
|
||||||
QueryGetInterestRate = "interest-rate"
|
|
||||||
QueryGetReserves = "reserves"
|
|
||||||
QueryGetInterestFactors = "interest-factors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryDepositsParams is the params for a filtered deposit query
|
|
||||||
type QueryDepositsParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryDepositsParams creates a new QueryDepositsParams
|
|
||||||
func NewQueryDepositsParams(page, limit int, denom string, owner sdk.AccAddress) QueryDepositsParams {
|
|
||||||
return QueryDepositsParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Denom: denom,
|
|
||||||
Owner: owner,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryUnsyncedDepositsParams is the params for a filtered unsynced deposit query.
|
|
||||||
type QueryUnsyncedDepositsParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryUnsyncedDepositsParams creates a new QueryUnsyncedDepositsParams
|
|
||||||
func NewQueryUnsyncedDepositsParams(page, limit int, denom string, owner sdk.AccAddress) QueryUnsyncedDepositsParams {
|
|
||||||
return QueryUnsyncedDepositsParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Denom: denom,
|
|
||||||
Owner: owner,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryAccountParams is the params for a filtered module account query
|
|
||||||
type QueryAccountParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Name string `json:"name" yaml:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryAccountParams returns QueryAccountParams
|
|
||||||
func NewQueryAccountParams(page, limit int, name string) QueryAccountParams {
|
|
||||||
return QueryAccountParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Name: name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ModAccountWithCoins includes the module account with its coins
|
|
||||||
type ModAccountWithCoins struct {
|
|
||||||
Account authtypes.ModuleAccountI `json:"account" yaml:"account"`
|
|
||||||
Coins sdk.Coins `json:"coins" yaml:"coins"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryBorrowsParams is the params for a filtered borrows query
|
|
||||||
type QueryBorrowsParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryBorrowsParams creates a new QueryBorrowsParams
|
|
||||||
func NewQueryBorrowsParams(page, limit int, owner sdk.AccAddress, denom string) QueryBorrowsParams {
|
|
||||||
return QueryBorrowsParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Owner: owner,
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryUnsyncedBorrowsParams is the params for a filtered unsynced borrows query
|
|
||||||
type QueryUnsyncedBorrowsParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryUnsyncedBorrowsParams creates a new QueryUnsyncedBorrowsParams
|
|
||||||
func NewQueryUnsyncedBorrowsParams(page, limit int, owner sdk.AccAddress, denom string) QueryUnsyncedBorrowsParams {
|
|
||||||
return QueryUnsyncedBorrowsParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Owner: owner,
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryTotalBorrowedParams is the params for a filtered total borrowed coins query
|
|
||||||
type QueryTotalBorrowedParams struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryTotalBorrowedParams creates a new QueryTotalBorrowedParams
|
|
||||||
func NewQueryTotalBorrowedParams(denom string) QueryTotalBorrowedParams {
|
|
||||||
return QueryTotalBorrowedParams{
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryTotalDepositedParams is the params for a filtered total deposited coins query
|
|
||||||
type QueryTotalDepositedParams struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryTotalDepositedParams creates a new QueryTotalDepositedParams
|
|
||||||
func NewQueryTotalDepositedParams(denom string) QueryTotalDepositedParams {
|
|
||||||
return QueryTotalDepositedParams{
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryInterestRateParams is the params for a filtered interest rate query
|
|
||||||
type QueryInterestRateParams struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryInterestRateParams creates a new QueryInterestRateParams
|
|
||||||
func NewQueryInterestRateParams(denom string) QueryInterestRateParams {
|
|
||||||
return QueryInterestRateParams{
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMoneyMarketInterestRate returns a new instance of MoneyMarketInterestRate
|
|
||||||
func NewMoneyMarketInterestRate(denom string, supplyInterestRate, borrowInterestRate sdk.Dec) MoneyMarketInterestRate {
|
|
||||||
return MoneyMarketInterestRate{
|
|
||||||
Denom: denom,
|
|
||||||
SupplyInterestRate: supplyInterestRate.String(),
|
|
||||||
BorrowInterestRate: borrowInterestRate.String(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MoneyMarketInterestRates is a slice of MoneyMarketInterestRate
|
|
||||||
type MoneyMarketInterestRates []MoneyMarketInterestRate
|
|
||||||
|
|
||||||
// QueryReservesParams is the params for a filtered reserves query
|
|
||||||
type QueryReservesParams struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryReservesParams creates a new QueryReservesParams
|
|
||||||
func NewQueryReservesParams(denom string) QueryReservesParams {
|
|
||||||
return QueryReservesParams{
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryInterestFactorsParams is the params for a filtered interest factors query
|
|
||||||
type QueryInterestFactorsParams struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryInterestFactorsParams creates a new QueryInterestFactorsParams
|
|
||||||
func NewQueryInterestFactorsParams(denom string) QueryInterestFactorsParams {
|
|
||||||
return QueryInterestFactorsParams{
|
|
||||||
Denom: denom,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewInterestFactor returns a new instance of InterestFactor
|
|
||||||
func NewInterestFactor(denom string, supplyInterestFactor, borrowInterestFactor sdk.Dec) InterestFactor {
|
|
||||||
return InterestFactor{
|
|
||||||
Denom: denom,
|
|
||||||
SupplyInterestFactor: supplyInterestFactor.String(),
|
|
||||||
BorrowInterestFactor: borrowInterestFactor.String(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// InterestFactors is a slice of InterestFactor
|
|
||||||
type InterestFactors []InterestFactor
|
|
7
x/hard/types/query.go
Normal file
7
x/hard/types/query.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
// MoneyMarketInterestRates is a slice of MoneyMarketInterestRate
|
||||||
|
type MoneyMarketInterestRates []MoneyMarketInterestRate
|
||||||
|
|
||||||
|
// InterestFactors is a slice of InterestFactor
|
||||||
|
type InterestFactors []InterestFactor
|
@ -1,12 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
// Querier routes for the issuance module
|
|
||||||
const (
|
|
||||||
QueryGetParams = "parameters"
|
|
||||||
QueryGetAsset = "asset"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryAssetParams params for querying an asset by denom
|
|
||||||
type QueryAssetParams struct {
|
|
||||||
Denom string `json:"denom" yaml:"denom"`
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
// Querier routes for the kavadist module
|
|
||||||
const (
|
|
||||||
QueryGetParams = "params"
|
|
||||||
QueryGetBalance = "balance"
|
|
||||||
)
|
|
@ -1,32 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
// price Takes an [assetcode] and returns CurrentPrice for that asset
|
|
||||||
// pricefeed Takes an [assetcode] and returns the raw []PostedPrice for that asset
|
|
||||||
// assets Returns []Assets in the pricefeed system
|
|
||||||
|
|
||||||
const (
|
|
||||||
// QueryGetParams command for params query
|
|
||||||
QueryGetParams = "parameters"
|
|
||||||
// QueryMarkets command for assets query
|
|
||||||
QueryMarkets = "markets"
|
|
||||||
// QueryOracles command for oracles query
|
|
||||||
QueryOracles = "oracles"
|
|
||||||
// QueryRawPrices command for raw price queries
|
|
||||||
QueryRawPrices = "rawprices"
|
|
||||||
// QueryPrice command for price queries
|
|
||||||
QueryPrice = "price"
|
|
||||||
// QueryPrices command for quering all prices
|
|
||||||
QueryPrices = "prices"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryWithMarketIDParams fields for querying information from a specific market
|
|
||||||
type QueryWithMarketIDParams struct {
|
|
||||||
MarketID string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryWithMarketIDParams creates a new instance of QueryWithMarketIDParams
|
|
||||||
func NewQueryWithMarketIDParams(marketID string) QueryWithMarketIDParams {
|
|
||||||
return QueryWithMarketIDParams{
|
|
||||||
MarketID: marketID,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdkmath "cosmossdk.io/math"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Querier routes for the swap module
|
|
||||||
const (
|
|
||||||
QueryGetParams = "params"
|
|
||||||
QueryGetDeposits = "deposits"
|
|
||||||
QueryGetPool = "pool"
|
|
||||||
QueryGetPools = "pools"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryDepositsParams is the params for a filtered deposits query
|
|
||||||
type QueryDepositsParams struct {
|
|
||||||
Page int `json:"page" yaml:"page"`
|
|
||||||
Limit int `json:"limit" yaml:"limit"`
|
|
||||||
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
|
|
||||||
Pool string `json:"pool" yaml:"pool"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryDepositsParams creates a new QueryDepositsParams
|
|
||||||
func NewQueryDepositsParams(page, limit int, owner sdk.AccAddress, pool string) QueryDepositsParams {
|
|
||||||
return QueryDepositsParams{
|
|
||||||
Page: page,
|
|
||||||
Limit: limit,
|
|
||||||
Owner: owner,
|
|
||||||
Pool: pool,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DepositsQueryResult contains the result of a deposits query
|
|
||||||
type DepositsQueryResult struct {
|
|
||||||
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
|
|
||||||
PoolID string `json:"pool_id" yaml:"pool_id"`
|
|
||||||
SharesOwned sdkmath.Int `json:"shares_owned" yaml:"shares_owned"`
|
|
||||||
SharesValue sdk.Coins `json:"shares_value" yaml:"shares_value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewDepositsQueryResult creates a new DepositsQueryResult
|
|
||||||
func NewDepositsQueryResult(shareRecord ShareRecord, sharesValue sdk.Coins) DepositsQueryResult {
|
|
||||||
return DepositsQueryResult{
|
|
||||||
Depositor: shareRecord.Depositor,
|
|
||||||
PoolID: shareRecord.PoolID,
|
|
||||||
SharesOwned: shareRecord.SharesOwned,
|
|
||||||
SharesValue: sharesValue,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DepositsQueryResults is a slice of DepositsQueryResult
|
|
||||||
type DepositsQueryResults []DepositsQueryResult
|
|
||||||
|
|
||||||
// QueryPoolParams is the params for a pool query
|
|
||||||
type QueryPoolParams struct {
|
|
||||||
Pool string `json:"pool" yaml:"pool"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewQueryPoolParams creates a new QueryPoolParams
|
|
||||||
func NewQueryPoolParams(pool string) QueryPoolParams {
|
|
||||||
return QueryPoolParams{
|
|
||||||
Pool: pool,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PoolStatsQueryResult contains the result of a pool query
|
|
||||||
type PoolStatsQueryResult struct {
|
|
||||||
Name string `json:"name" yaml:"name"`
|
|
||||||
Coins sdk.Coins `json:"coins" yaml:"coins"`
|
|
||||||
TotalShares sdkmath.Int `json:"total_shares" yaml:"total_shares"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPoolStatsQueryResult creates a new PoolStatsQueryResult
|
|
||||||
func NewPoolStatsQueryResult(name string, coins sdk.Coins, totalShares sdkmath.Int) PoolStatsQueryResult {
|
|
||||||
return PoolStatsQueryResult{
|
|
||||||
Name: name,
|
|
||||||
Coins: coins,
|
|
||||||
TotalShares: totalShares,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PoolStatsQueryResults is a slice of PoolStatsQueryResult
|
|
||||||
type PoolStatsQueryResults []PoolStatsQueryResult
|
|
Loading…
Reference in New Issue
Block a user