client

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotExisted = fmt.Errorf("account not existed")

	ErrBuildTx     = fmt.Errorf("failed to build transaction")
	ErrSignTx      = fmt.Errorf("failed to sign transaction")
	ErrBroadcastTx = fmt.Errorf("failed to broadcast transaction")

	ErrInsufficientBalance = fmt.Errorf("insufficient balance")

	ErrInvalidAccAddress = fmt.Errorf("invalid AccAddress")
	ErrInvalidValAddress = fmt.Errorf("invalid ValAddress")

	ErrInvalidParameters = fmt.Errorf("invalid parameters")
)

Functions

func ParseCosmosMsgReceiver added in v0.0.2

func ParseCosmosMsgReceiver(msg sdk.Msg) (string, error)

ParseCosmosMsgReceiver returns the recipients of the given Cosmos message.

func ParseCosmosMsgSender added in v0.0.2

func ParseCosmosMsgSender(msg sdk.Msg) (string, error)

ParseCosmosMsgSender returns the sender of the given Cosmos message.

func ParseCosmosMsgValue added in v0.0.2

func ParseCosmosMsgValue(msg sdk.Msg) (sdk.Int, error)

ParseCosmosMsgValue returns the value of the given Cosmos message.

Types

type AccountBalance

type AccountBalance struct {
	Total    sdk.Int `json:"Total"`
	Locked   sdk.Int `json:"Locked"`
	Unlocked sdk.Int `json:"Unlocked"`
}

type AccountInfoI

type AccountInfoI interface {
	GetAddress() sdk.AccAddress

	GetPubKey() types.PubKey // can return nil.

	GetAccountNumber() uint64

	GetSequence() uint64

	String() string
}

type AccountRetrieverI

type AccountRetrieverI interface {
	Balance(address string) (*AccountBalance, error)
	AccountExists(address string) error
	AccountInfo(addr string) (AccountInfoI, error)
	TotalAccounts() (uint64, error)
}

AccountRetrieverI specifies required methods for checking the sender account.

type AuthClient

type AuthClient struct {
	authTypes.QueryClient
}

func NewAuthClient

func NewAuthClient(conn grpc.ClientConn) *AuthClient

NewAuthClient creates a new client for interacting with the `auth` module.

type AuthzClient

type AuthzClient struct {
	authz.QueryClient
}

func NewAuthzClient

func NewAuthzClient(conn grpc.ClientConn) *AuthzClient

NewAuthzClient creates a new client for interacting with the `authz` module.

type BankClient

type BankClient struct {
	bankTypes.QueryClient
}

func NewBankClient

func NewBankClient(conn grpc.ClientConn) *BankClient

NewBankClient creates a new client for interacting with the `bank` module.

type BaseClient

type BaseClient struct {
	client.Context
	// contains filtered or unexported fields
}

type CosmosClient

type CosmosClient struct {
	*BaseClient
	// contains filtered or unexported fields
}

func NewCosmosClient

func NewCosmosClient(cfg CosmosClientConfig) (*CosmosClient, error)

NewCosmosClient creates a new cosmos client.

func (*CosmosClient) AccountExists

func (c *CosmosClient) AccountExists(addr string) error

AccountExists checks if an account exists given its address.

func (*CosmosClient) AccountInfo

func (c *CosmosClient) AccountInfo(addr string) (AccountInfoI, error)

AccountInfo returns a authTypes.AccountI for the given address.

func (*CosmosClient) AllDelegationRewards

func (c *CosmosClient) AllDelegationRewards(delAddr string) (map[string]sdk.Int, error)

AllDelegationRewards returns the delegating reward of a delegator for all validators.

func (*CosmosClient) AllValidators

func (c *CosmosClient) AllValidators(status stakingTypes.BondStatus) ([]stakingTypes.Validator, error)

AllValidators returns all validators matching with the given status.

func (*CosmosClient) AnnualProvisions added in v0.0.4

func (c *CosmosClient) AnnualProvisions() (sdk.Dec, error)

AnnualProvisions returns the current minting annual provisions.

func (*CosmosClient) Balance

func (c *CosmosClient) Balance(strAddr string) (*AccountBalance, error)

Balance retrieves the balances of an account.

func (*CosmosClient) BlockProvision added in v0.0.4

func (c *CosmosClient) BlockProvision() (sdk.Int, error)

BlockProvision returns the current block reward amount.

func (*CosmosClient) BlockTxsByHeight added in v0.0.2

func (c *CosmosClient) BlockTxsByHeight(ctx context.Context, blk *big.Int) ([]*sdk.TxResponse, error)

BlockTxsByHeight retrieves the receipts of all transaction in a block given its height.

func (*CosmosClient) BuildAndSendTx

func (c *CosmosClient) BuildAndSendTx(txParams msg_params.TxParams, msgs ...types.Msg) (*types.TxResponse, error)

BuildAndSendTx creates and sends a transaction with given parameters.

func (*CosmosClient) CirculatingSupply added in v0.0.4

func (c *CosmosClient) CirculatingSupply() (sdk.Int, error)

CirculatingSupply returns the current circulating supply.

func (*CosmosClient) Delegation added in v0.0.6

func (c *CosmosClient) Delegation(delAddr, valAddr string) (DelegationDetail, error)

func (*CosmosClient) DelegationDetail

func (c *CosmosClient) DelegationDetail(addr string) (map[string]DelegationDetail, error)

DelegationDetail returns the staking amounts of the given address.

func (*CosmosClient) DelegationRewards

func (c *CosmosClient) DelegationRewards(delAddr, valAddr string) (sdk.Int, error)

DelegationRewards returns the delegating reward of a delegator w.r.t to a validator address.

func (*CosmosClient) EncodeTx

func (c *CosmosClient) EncodeTx(txBuilder client.TxBuilder) ([]byte, error)

EncodeTx generates the raw transaction given a client.TxBuilder.

func (*CosmosClient) EstimateGas

func (c *CosmosClient) EstimateGas(tx Tx, msgs ...sdk.Msg) (uint64, error)

EstimateGas simulates the execution of a transaction and returns the simulation response obtained by the query and the adjusted gas amount.

func (*CosmosClient) GetAvailableVestingBalance added in v0.0.3

func (c *CosmosClient) GetAvailableVestingBalance(strAddr string) (sdk.Int, error)

GetAvailableVestingBalance returns the spendable amount of a vesting address.

func (*CosmosClient) GetBlockByHeight added in v0.0.5

func (c *CosmosClient) GetBlockByHeight(height int64) (*coretypes.ResultBlock, error)

func (*CosmosClient) GetBondedRatio added in v0.0.4

func (c *CosmosClient) GetBondedRatio() (sdk.Dec, error)

GetBondedRatio returns the current staking ratio.

func (*CosmosClient) GetCommunityPoolBalance added in v0.0.4

func (c *CosmosClient) GetCommunityPoolBalance() (sdk.Int, error)

GetCommunityPoolBalance returns the balance of the community pool

func (*CosmosClient) GetFoundationBalance added in v0.0.4

func (c *CosmosClient) GetFoundationBalance() (*AccountBalance, error)

GetFoundationBalance returns the balance of the foundation address.

func (*CosmosClient) GetModuleAccount added in v0.0.4

func (c *CosmosClient) GetModuleAccount(name string) (AccountInfoI, error)

GetModuleAccount returns the account of the given module.

func (*CosmosClient) GetNextVestingPeriod added in v0.0.4

func (c *CosmosClient) GetNextVestingPeriod(strAddr string) (time.Time, sdk.Int, error)

GetNextVestingPeriod returns the next vesting information of the given address.

func (*CosmosClient) GetValidatorDetail

func (c *CosmosClient) GetValidatorDetail(valAddress string) (*stakingTypes.Validator, error)

GetValidatorDetail returns the detail of a validator given its address.

func (*CosmosClient) GetVestingAccount added in v0.0.3

func (c *CosmosClient) GetVestingAccount(strAddr string) (*vestingTypes.ClawbackVestingAccount, error)

GetVestingAccount returns the vesting of the given address.

func (*CosmosClient) GetVestingBalance added in v0.0.3

func (c *CosmosClient) GetVestingBalance(strAddr string) (*VestingBalances, error)

GetVestingBalance returns the detail balance of a vesting account.

func (*CosmosClient) GranteeGrants

func (c *CosmosClient) GranteeGrants(granteeStr string) ([]*GrantAuthorization, error)

GranteeGrants returns a list of `Authorization` granted to the grantee.

func (*CosmosClient) GranterGrants

func (c *CosmosClient) GranterGrants(granterStr string) ([]*GrantAuthorization, error)

GranterGrants returns a list of `Authorization` granted by the granter.

func (*CosmosClient) Grants

func (c *CosmosClient) Grants(granterStr, granteeStr, msgTypeURL string) ([]*Grant, error)

Grants returns a list of `Authorization`, granted to the grantee by the granter. If msgTypeURL is provided, it will only return the grants matching with the msgTypeURL.

func (*CosmosClient) Inflation added in v0.0.4

func (c *CosmosClient) Inflation() (sdk.Dec, error)

Inflation returns the current inflation.

func (*CosmosClient) LatestBlockHeight added in v0.0.2

func (c *CosmosClient) LatestBlockHeight() (*big.Int, error)

LatestBlockHeight returns the latest block height from the current chain.

func (*CosmosClient) ListenToTxs added in v0.0.2

func (c *CosmosClient) ListenToTxs(ctx context.Context, txResult chan interface{}, startBlk *big.Int)

func (*CosmosClient) MintInfo added in v0.0.4

func (c *CosmosClient) MintInfo() (*ProvisionInfo, error)

func (*CosmosClient) MintParams added in v0.0.4

func (c *CosmosClient) MintParams() (*mintTypes.Params, error)

MintParams returns the parameters for the mint module.

func (*CosmosClient) NewTx

func (c *CosmosClient) NewTx(txParams msg_params.TxParams) *Tx

NewTx creates a new Tx from the given parameters.

func (*CosmosClient) Proposal added in v0.0.8

func (c *CosmosClient) Proposal(id uint64) (*govTypes.Proposal, error)

func (*CosmosClient) Proposals added in v0.0.8

func (c *CosmosClient) Proposals() ([]govTypes.Proposal, error)

func (*CosmosClient) SigningInfos added in v0.0.8

func (c *CosmosClient) SigningInfos() ([]slashingTypes.ValidatorSigningInfo, error)

func (*CosmosClient) StakingSupply added in v0.0.4

func (c *CosmosClient) StakingSupply() (sdk.Int, error)

StakingSupply returns the total number of tokens which are bonded.

func (*CosmosClient) StreamBlocks added in v0.0.8

func (c *CosmosClient) StreamBlocks(ctx context.Context, blkChan chan interface{}, startBlk *big.Int)

func (*CosmosClient) TotalAccounts

func (c *CosmosClient) TotalAccounts() (uint64, error)

TotalAccounts returns the number of accounts on the blockchain.

func (*CosmosClient) TotalFeeBurn added in v0.0.8

func (c *CosmosClient) TotalFeeBurn() (sdk.Int, error)

func (*CosmosClient) TotalMintedProvision added in v0.0.4

func (c *CosmosClient) TotalMintedProvision() (sdk.Int, error)

TotalMintedProvision returns the total amount of tokens minted via the `mint` module.

func (*CosmosClient) TotalRewardsOnValidator added in v0.0.8

func (c *CosmosClient) TotalRewardsOnValidator(valAddr string, speedUp ...bool) (sdk.Int, error)

func (*CosmosClient) TxByHash added in v0.0.2

func (c *CosmosClient) TxByHash(hash string) (*sdk.TxResponse, error)

func (*CosmosClient) TxClawBackVesting added in v0.0.4

func (c *CosmosClient) TxClawBackVesting(p msg_params.TxClawBackVestingParams) (*sdk.TxResponse, error)

func (*CosmosClient) TxCreateValidator added in v0.0.6

func (c *CosmosClient) TxCreateValidator(p msg_params.TxCreateValidatorParams) (*sdk.TxResponse, error)

func (*CosmosClient) TxCreateVesting added in v0.0.4

TxCreateVesting creates a new-vesting-account transaction. If sender is not the owner, it performs a TxGrantExec transaction.

func (*CosmosClient) TxDelegate

TxDelegate creates a delegation transaction.

func (*CosmosClient) TxEditValidator added in v0.0.6

func (*CosmosClient) TxGrantAuthorization added in v0.0.3

func (c *CosmosClient) TxGrantAuthorization(p msg_params.TxGrantParams, auths ...authz.Authorization) (*sdk.TxResponse, error)

func (*CosmosClient) TxGrantExec added in v0.0.2

func (c *CosmosClient) TxGrantExec(p msg_params.TxParams, msgs ...sdk.Msg) (*sdk.TxResponse, error)

func (*CosmosClient) TxGrantRevoke

func (c *CosmosClient) TxGrantRevoke(p msg_params.TxParams, granteeStr string, msgTypeURL string) (*sdk.TxResponse, error)

TxGrantRevoke revoke a grant permission granted by to sender to the grantee.

func (*CosmosClient) TxGrantRevokeAll

func (c *CosmosClient) TxGrantRevokeAll(p msg_params.TxParams, granteeStr string) (*sdk.TxResponse, error)

TxGrantRevokeAll revokes all authz permissions granted by the sender to the grantee.

func (*CosmosClient) TxGrantSend

func (c *CosmosClient) TxGrantSend(p msg_params.TxGrantParams, maxSpent *big.Int) (*sdk.TxResponse, error)

func (*CosmosClient) TxGrantWithdrawCommission added in v0.0.5

func (c *CosmosClient) TxGrantWithdrawCommission(p msg_params.TxGrantParams) (*sdk.TxResponse, error)

TxGrantWithdrawCommission creates a staking commission withdrawal grant.

func (*CosmosClient) TxGrantWithdrawReward

func (c *CosmosClient) TxGrantWithdrawReward(p msg_params.TxGrantParams) (*sdk.TxResponse, error)

TxGrantWithdrawReward creates a staking reward withdrawal grant.

func (*CosmosClient) TxGranterRevokeAll

func (c *CosmosClient) TxGranterRevokeAll(p msg_params.TxParams) (*sdk.TxResponse, error)

TxGranterRevokeAll revokes all authz permissions granted by the sender.

func (*CosmosClient) TxSend

TxSend performs a transfer transaction. If sender is not the owner, it performs a TxGrantExec transaction.

func (*CosmosClient) TxStakingGrant

TxStakingGrant creates a staking grant.

func (*CosmosClient) TxSubmitProposal added in v0.0.8

func (c *CosmosClient) TxSubmitProposal(p msg_params.TxParams, content govTypes.Content, initialDeposit ...sdk.Coin) (*sdk.TxResponse, error)

func (*CosmosClient) TxVoteProposal added in v0.0.8

func (c *CosmosClient) TxVoteProposal(p msg_params.TxParams, id uint64, option govTypes.VoteOption) (*sdk.TxResponse, error)

func (*CosmosClient) TxWithdrawCommission added in v0.0.5

func (c *CosmosClient) TxWithdrawCommission(p msg_params.TxWithdrawCommissionParams) (*sdk.TxResponse, error)

TxWithdrawCommission creates a staking commission withdrawal transaction.

func (*CosmosClient) TxWithdrawReward

TxWithdrawReward creates a staking reward withdrawal transaction.

func (*CosmosClient) ValidatorDelegations added in v0.0.6

func (c *CosmosClient) ValidatorDelegations(valAddr string) ([]DelegationDetail, error)

ValidatorDelegations returns the staking amounts of the given address.

func (*CosmosClient) Vote added in v0.0.8

func (c *CosmosClient) Vote(id uint64, voter string) (*govTypes.Vote, error)

func (*CosmosClient) Votes added in v0.0.8

func (c *CosmosClient) Votes(id uint64) ([]govTypes.Vote, error)

type CosmosClientConfig

type CosmosClientConfig struct {
	Endpoint       string `json:"Endpoint"`
	TendermintPort string `json:"TendermintPort"`
	ChainID        string `json:"ChainID"`
}

func DefaultLocalConfig added in v0.0.3

func DefaultLocalConfig() CosmosClientConfig

func DefaultMainnetConfig

func DefaultMainnetConfig() CosmosClientConfig

func DefaultTestnetConfig

func DefaultTestnetConfig() CosmosClientConfig

func (CosmosClientConfig) IsValid

func (cfg CosmosClientConfig) IsValid() (bool, error)

IsValid checks if the current CosmosClientConfig is valid.

type DelegationDetail

type DelegationDetail struct {
	ValidatorName string  `json:"ValidatorName,omitempty"`
	Validator     string  `json:"Validator"`
	Delegator     string  `json:"Delegator"`
	Amount        sdk.Int `json:"Amount"`
	AmountDec     sdk.Dec `json:"AmountDec"`
}

type DistrClient

type DistrClient struct {
	distrType.QueryClient
}

func NewDistrClient

func NewDistrClient(conn grpc.ClientConn) *DistrClient

NewDistrClient creates a new client for interacting with the `distribution` module.

type FeeburnClient added in v0.0.8

type FeeburnClient struct {
	feeburnTypes.QueryClient
}

func NewFeeburnClient added in v0.0.8

func NewFeeburnClient(conn grpc.ClientConn) *FeeburnClient

NewFeeburnClient creates a new client for interacting with the `feeburn` module.

type GovClient added in v0.0.8

type GovClient struct {
	govTypes.QueryClient
}

func NewGovClient added in v0.0.8

func NewGovClient(conn grpc.ClientConn) *GovClient

NewGovClient creates a new client for interacting with the `gov` module.

type Grant

type Grant struct {
	Authorization authz.Authorization
	Expiration    time.Time
}

type GrantAuthorization

type GrantAuthorization struct {
	Granter       string
	Grantee       string
	Authorization authz.Authorization
	Expiration    time.Time
}

type MintClient added in v0.0.4

type MintClient struct {
	mintTypes.QueryClient
}

func NewMintClient added in v0.0.4

func NewMintClient(conn grpc.ClientConn) *MintClient

NewMintClient creates a new client for interacting with the `mint` module.

type ProvisionInfo added in v0.0.4

type ProvisionInfo struct {
	Params               *mintTypes.Params
	Height               int64
	AnnualProvisions     sdk.Dec
	Inflation            sdk.Dec
	TotalMintedProvision sdk.Int
	BlockProvision       sdk.Int
	CirculatingSupply    sdk.Int
	BondedRatio          sdk.Dec
	StakingSupply        sdk.Int
	FoundationBalance    sdk.Int
	CommunityBalance     sdk.Int
	FeeCollectorBalance  sdk.Int
}

type SlashingClient added in v0.0.8

type SlashingClient struct {
	slashingTypes.QueryClient
}

func NewSlashingClient added in v0.0.8

func NewSlashingClient(conn grpc.ClientConn) *SlashingClient

NewSlashingClient creates a new client for interacting with the `slashing` module.

type StakingClient

type StakingClient struct {
	stakingTypes.QueryClient
	stakingTypes.MsgClient
}

func NewStakingClient

func NewStakingClient(conn grpc.ClientConn) *StakingClient

NewStakingClient creates a new client for interacting with the `staking` module.

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Build

func (t *Tx) Build(msgs ...sdk.Msg) (client.TxBuilder, error)

Build performs WithMsgs and SignTx.

func (*Tx) PrintUnsignedTx

func (t *Tx) PrintUnsignedTx(msg sdk.Msg) (string, error)

PrintUnsignedTx displays the unsigned transaction from the given types.Msg's.

func (*Tx) SignTx

func (t *Tx) SignTx(txBuilder client.TxBuilder) error

SignTx performs the transaction signing.

func (*Tx) WithMsgs

func (t *Tx) WithMsgs(msgs ...sdk.Msg) (client.TxBuilder, error)

WithMsgs creates an unsigned transaction builder from the given types.Msg's.

type VestingBalances added in v0.0.5

type VestingBalances struct {
	// Total is the original vesting amount.
	Total sdk.Coins

	// Locked is the is amount of coins which are locked.
	Locked sdk.Coins

	// Unlocked is the is amount of coins which are unlocked.
	Unlocked sdk.Coins

	// Vested is the is amount of coins which are vested.
	Vested sdk.Coins

	// Unvested is the is amount of coins which are in the vesting period.
	Unvested sdk.Coins
}

VestingBalances reports the balances of a vesting account.

func (*VestingBalances) NonSpendableBalances added in v0.0.7

func (b *VestingBalances) NonSpendableBalances() sdk.Coins

func (*VestingBalances) SpendableBalances added in v0.0.7

func (b *VestingBalances) SpendableBalances() sdk.Coins

type VestingClient added in v0.0.3

type VestingClient struct {
	vestingTypes.QueryClient
}

func NewVestingClient added in v0.0.3

func NewVestingClient(conn grpc.ClientConn) *VestingClient

NewVestingClient creates a new client for interacting with the `vesting` module.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL