Documentation ¶
Index ¶
- Constants
- Variables
- func BuildSimTx(info *keyring.Record, txf tx.Factory, msgs ...sdk.Msg) ([]byte, error)
- func CreateMnemonic() (string, error)
- func DefaultPageRequest() *query.PageRequest
- func GetHeightFromMetadata(md metadata.MD) (int64, error)
- func GetProveFromMetadata(md metadata.MD) (bool, error)
- func LensKeyringAlgoOptions() keyring.Option
- func NewRPCClient(addr string, timeout time.Duration) (*rpchttp.HTTP, error)
- func SetHeightOnContext(ctx context.Context, height int64) context.Context
- func SetProveOnContext(ctx context.Context, prove bool) context.Context
- type ChainClient
- func (cc *ChainClient) AccountFromKeyOrAddress(keyOrAddress string) (out sdk.AccAddress, err error)
- func (cc *ChainClient) AddKey(name string, coinType uint32) (output *KeyOutput, err error)
- func (cc *ChainClient) BroadcastTx(ctx context.Context, tx []byte) (*sdk.TxResponse, error)
- func (cc *ChainClient) CalculateGas(ctx context.Context, txf tx.Factory, msgs ...sdk.Msg) (txtypes.SimulateResponse, uint64, error)
- func (cc *ChainClient) CreateKeystore(path string) error
- func (cc *ChainClient) DecodeBech32AccAddr(addr string) (sdk.AccAddress, error)
- func (cc *ChainClient) DecodeBech32AccPub(addr string) (sdk.AccAddress, error)
- func (cc *ChainClient) DecodeBech32ConsAddr(addr string) (sdk.AccAddress, error)
- func (cc *ChainClient) DecodeBech32ConsPub(addr string) (sdk.AccAddress, error)
- func (cc *ChainClient) DecodeBech32ValAddr(addr string) (sdk.ValAddress, error)
- func (cc *ChainClient) DecodeBech32ValPub(addr string) (sdk.AccAddress, error)
- func (cc *ChainClient) DeleteKey(name string) error
- func (cc *ChainClient) EncodeBech32AccAddr(addr sdk.AccAddress) (string, error)
- func (cc *ChainClient) EncodeBech32AccPub(addr sdk.AccAddress) (string, error)
- func (cc *ChainClient) EncodeBech32ConsAddr(addr sdk.AccAddress) (string, error)
- func (cc *ChainClient) EncodeBech32ConsPub(addr sdk.AccAddress) (string, error)
- func (cc *ChainClient) EncodeBech32ValAddr(addr sdk.ValAddress) (string, error)
- func (cc *ChainClient) EncodeBech32ValPub(addr sdk.AccAddress) (string, error)
- func (cc *ChainClient) EnsureExists(clientCtx client.Context, addr sdk.AccAddress) error
- func (cc *ChainClient) ExportPrivKeyArmor(keyName string) (armor string, err error)
- func (cc *ChainClient) GetAccount(clientCtx client.Context, addr sdk.AccAddress) (client.Account, error)
- func (cc *ChainClient) GetAccountNumberSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, uint64, error)
- func (cc *ChainClient) GetAccountWithHeight(clientCtx client.Context, addr sdk.AccAddress) (client.Account, int64, error)
- func (cc *ChainClient) GetKeyAddress() (sdk.AccAddress, error)
- func (cc *ChainClient) HandleAndPrintMsgSend(res *sdk.TxResponse, err error) error
- func (cc *ChainClient) Init() error
- func (cc *ChainClient) Invoke(ctx context.Context, method string, req, reply interface{}, ...) (err error)
- func (cc *ChainClient) KeyAddOrRestore(keyName string, coinType uint32, mnemonic ...string) (*KeyOutput, error)
- func (cc *ChainClient) KeyExists(name string) bool
- func (cc *ChainClient) KeystoreCreated(path string) bool
- func (cc *ChainClient) ListAddresses() (map[string]string, error)
- func (cc *ChainClient) MarshalProto(res proto.Message) ([]byte, error)
- func (cc *ChainClient) MustEncodeAccAddr(addr sdk.AccAddress) string
- func (cc *ChainClient) MustEncodeValAddr(addr sdk.ValAddress) string
- func (cc *ChainClient) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error)
- func (cc *ChainClient) PrepareFactory(txf tx.Factory) (tx.Factory, error)
- func (cc *ChainClient) PrintObject(res interface{}) error
- func (cc *ChainClient) PrintTxResponse(res *sdk.TxResponse) error
- func (cc *ChainClient) QueryABCI(ctx context.Context, req abci.RequestQuery) (abci.ResponseQuery, error)
- func (cc *ChainClient) QueryAccount(ctx context.Context, address sdk.AccAddress) (authtypes.AccountI, error)
- func (cc *ChainClient) QueryBalanceWithDenomTraces(ctx context.Context, address sdk.AccAddress, pageReq *query.PageRequest) (sdk.Coins, error)
- func (cc *ChainClient) QueryDelegatorValidators(ctx context.Context, address sdk.AccAddress) ([]string, error)
- func (cc *ChainClient) QueryDenomsMetadata(ctx context.Context, pageReq *query.PageRequest) (*bankTypes.QueryDenomsMetadataResponse, error)
- func (cc *ChainClient) QueryDistributionCommission(ctx context.Context, address sdk.ValAddress) (sdk.DecCoins, error)
- func (cc *ChainClient) QueryDistributionCommunityPool(ctx context.Context) (sdk.DecCoins, error)
- func (cc *ChainClient) QueryDistributionParams(ctx context.Context) (*distTypes.Params, error)
- func (cc *ChainClient) QueryDistributionRewards(ctx context.Context, delegatorAddress sdk.AccAddress, ...) (sdk.DecCoins, error)
- func (cc *ChainClient) QueryDistributionSlashes(ctx context.Context, validatorAddress sdk.ValAddress, ...) (*distTypes.QueryValidatorSlashesResponse, error)
- func (cc *ChainClient) QueryDistributionValidatorRewards(ctx context.Context, validatorAddress sdk.ValAddress) (sdk.DecCoins, error)
- func (cc *ChainClient) QueryTotalSupply(ctx context.Context, pageReq *query.PageRequest) (*bankTypes.QueryTotalSupplyResponse, error)
- func (cc *ChainClient) QueryTx(ctx context.Context, hashHex string, prove bool) (*ctypes.ResultTx, error)
- func (cc *ChainClient) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*ctypes.ResultTx, error)
- func (cc *ChainClient) RestoreKey(name, mnemonic string, coinType uint32) (address string, err error)
- func (cc *ChainClient) RunGRPCQuery(ctx context.Context, method string, req interface{}, md metadata.MD) (abci.ResponseQuery, metadata.MD, error)
- func (cc *ChainClient) SendMsg(ctx context.Context, msg sdk.Msg, memo string) (*sdk.TxResponse, error)
- func (cc *ChainClient) SendMsgs(ctx context.Context, msgs []sdk.Msg, memo string) (*sdk.TxResponse, error)
- func (cc *ChainClient) SetSDKContext() func()
- func (cc *ChainClient) ShowAddress(name string) (address string, err error)
- func (cc *ChainClient) TxFactory() tx.Factory
- func (cc *ChainClient) TxServiceBroadcast(ctx context.Context, req *tx.BroadcastTxRequest) (*tx.BroadcastTxResponse, error)
- type ChainClientConfig
- type Codec
- type KeyOutput
Constants ¶
const (
ErrTimeoutAfterWaitingForTxBroadcast _err = "timed out after waiting for tx to get included in the block"
)
Variables ¶
var ( // Variables used for retries RtyAttNum = uint(5) RtyAtt = retry.Attempts(RtyAttNum) RtyDel = retry.Delay(time.Millisecond * 400) RtyErr = retry.LastErrorOnly(true) )
var ( // SupportedAlgorithms defines the list of signing algorithms used on Evmos: // - secp256k1 (Cosmos) // - eth_secp256k1 (Ethereum) SupportedAlgorithms = keyring.SigningAlgoList{hd.Secp256k1, ethhd.EthSecp256k1} // SupportedAlgorithmsLedger defines the list of signing algorithms used on Evmos for the Ledger device: // - secp256k1 (Cosmos) // - eth_secp256k1 (Ethereum) SupportedAlgorithmsLedger = keyring.SigningAlgoList{hd.Secp256k1, ethhd.EthSecp256k1} )
var ( ModuleBasics = []module.AppModuleBasic{ auth.AppModuleBasic{}, authz.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, gov.NewAppModuleBasic( []client.ProposalHandler{ paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, }, ), crisis.AppModuleBasic{}, distribution.AppModuleBasic{}, feegrant.AppModuleBasic{}, mint.AppModuleBasic{}, params.AppModuleBasic{}, slashing.AppModuleBasic{}, staking.AppModuleBasic{}, upgrade.AppModuleBasic{}, transfer.AppModuleBasic{}, ibc.AppModuleBasic{}, } )
Functions ¶
func BuildSimTx ¶
BuildSimTx creates an unsigned tx with an empty single signature and returns the encoded transaction or an error if the unsigned transaction cannot be built.
func DefaultPageRequest ¶
func DefaultPageRequest() *query.PageRequest
func LensKeyringAlgoOptions ¶ added in v0.5.0
Option defines a function keys options for the ethereum Secp256k1 curve. It supports secp256k1 and eth_secp256k1 keys for accounts.
func SetHeightOnContext ¶
Types ¶
type ChainClient ¶
type ChainClient struct { Config *ChainClientConfig Keybase keyring.Keyring KeyringOptions []keyring.Option RPCClient rpcclient.Client LightProvider provtypes.Provider Input io.Reader Output io.Writer Codec Codec // contains filtered or unexported fields }
func NewChainClient ¶
func (*ChainClient) AccountFromKeyOrAddress ¶ added in v0.1.3
func (cc *ChainClient) AccountFromKeyOrAddress(keyOrAddress string) (out sdk.AccAddress, err error)
AccountFromKeyOrAddress returns an account from either a key or an address if empty string is passed in this returns the default key's address
func (*ChainClient) AddKey ¶
func (cc *ChainClient) AddKey(name string, coinType uint32) (output *KeyOutput, err error)
func (*ChainClient) BroadcastTx ¶
func (cc *ChainClient) BroadcastTx(ctx context.Context, tx []byte) (*sdk.TxResponse, error)
func (*ChainClient) CalculateGas ¶
func (*ChainClient) CreateKeystore ¶
func (cc *ChainClient) CreateKeystore(path string) error
func (*ChainClient) DecodeBech32AccAddr ¶
func (cc *ChainClient) DecodeBech32AccAddr(addr string) (sdk.AccAddress, error)
func (*ChainClient) DecodeBech32AccPub ¶
func (cc *ChainClient) DecodeBech32AccPub(addr string) (sdk.AccAddress, error)
func (*ChainClient) DecodeBech32ConsAddr ¶
func (cc *ChainClient) DecodeBech32ConsAddr(addr string) (sdk.AccAddress, error)
func (*ChainClient) DecodeBech32ConsPub ¶
func (cc *ChainClient) DecodeBech32ConsPub(addr string) (sdk.AccAddress, error)
func (*ChainClient) DecodeBech32ValAddr ¶
func (cc *ChainClient) DecodeBech32ValAddr(addr string) (sdk.ValAddress, error)
func (*ChainClient) DecodeBech32ValPub ¶
func (cc *ChainClient) DecodeBech32ValPub(addr string) (sdk.AccAddress, error)
func (*ChainClient) DeleteKey ¶
func (cc *ChainClient) DeleteKey(name string) error
func (*ChainClient) EncodeBech32AccAddr ¶
func (cc *ChainClient) EncodeBech32AccAddr(addr sdk.AccAddress) (string, error)
func (*ChainClient) EncodeBech32AccPub ¶
func (cc *ChainClient) EncodeBech32AccPub(addr sdk.AccAddress) (string, error)
func (*ChainClient) EncodeBech32ConsAddr ¶
func (cc *ChainClient) EncodeBech32ConsAddr(addr sdk.AccAddress) (string, error)
func (*ChainClient) EncodeBech32ConsPub ¶
func (cc *ChainClient) EncodeBech32ConsPub(addr sdk.AccAddress) (string, error)
func (*ChainClient) EncodeBech32ValAddr ¶
func (cc *ChainClient) EncodeBech32ValAddr(addr sdk.ValAddress) (string, error)
func (*ChainClient) EncodeBech32ValPub ¶
func (cc *ChainClient) EncodeBech32ValPub(addr sdk.AccAddress) (string, error)
func (*ChainClient) EnsureExists ¶
func (cc *ChainClient) EnsureExists(clientCtx client.Context, addr sdk.AccAddress) error
EnsureExists returns an error if no account exists for the given address else nil.
func (*ChainClient) ExportPrivKeyArmor ¶
func (cc *ChainClient) ExportPrivKeyArmor(keyName string) (armor string, err error)
func (*ChainClient) GetAccount ¶
func (cc *ChainClient) GetAccount(clientCtx client.Context, addr sdk.AccAddress) (client.Account, error)
GetAccount queries for an account given an address and a block height. An error is returned if the query or decoding fails.
func (*ChainClient) GetAccountNumberSequence ¶
func (cc *ChainClient) GetAccountNumberSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, uint64, error)
GetAccountNumberSequence returns sequence and account number for the given address. It returns an error if the account couldn't be retrieved from the state.
func (*ChainClient) GetAccountWithHeight ¶
func (cc *ChainClient) GetAccountWithHeight(clientCtx client.Context, addr sdk.AccAddress) (client.Account, int64, error)
GetAccountWithHeight queries for an account given an address. Returns the height of the query with the account. An error is returned if the query or decoding fails.
func (*ChainClient) GetKeyAddress ¶
func (cc *ChainClient) GetKeyAddress() (sdk.AccAddress, error)
func (*ChainClient) HandleAndPrintMsgSend ¶ added in v0.1.3
func (cc *ChainClient) HandleAndPrintMsgSend(res *sdk.TxResponse, err error) error
func (*ChainClient) Init ¶ added in v0.1.3
func (cc *ChainClient) Init() error
func (*ChainClient) Invoke ¶
func (cc *ChainClient) Invoke(ctx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error)
Invoke implements the grpc ClientConn.Invoke method
func (*ChainClient) KeyAddOrRestore ¶
func (*ChainClient) KeyExists ¶
func (cc *ChainClient) KeyExists(name string) bool
func (*ChainClient) KeystoreCreated ¶
func (cc *ChainClient) KeystoreCreated(path string) bool
func (*ChainClient) ListAddresses ¶
func (cc *ChainClient) ListAddresses() (map[string]string, error)
func (*ChainClient) MarshalProto ¶
func (cc *ChainClient) MarshalProto(res proto.Message) ([]byte, error)
func (*ChainClient) MustEncodeAccAddr ¶ added in v0.1.3
func (cc *ChainClient) MustEncodeAccAddr(addr sdk.AccAddress) string
func (*ChainClient) MustEncodeValAddr ¶ added in v0.1.3
func (cc *ChainClient) MustEncodeValAddr(addr sdk.ValAddress) string
func (*ChainClient) NewStream ¶
func (cc *ChainClient) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error)
NewStream implements the grpc ClientConn.NewStream method
func (*ChainClient) PrepareFactory ¶
func (*ChainClient) PrintObject ¶
func (cc *ChainClient) PrintObject(res interface{}) error
func (*ChainClient) PrintTxResponse ¶
func (cc *ChainClient) PrintTxResponse(res *sdk.TxResponse) error
TODO: actually do something different here have a couple of levels of verbosity
func (*ChainClient) QueryABCI ¶
func (cc *ChainClient) QueryABCI(ctx context.Context, req abci.RequestQuery) (abci.ResponseQuery, error)
func (*ChainClient) QueryAccount ¶
func (cc *ChainClient) QueryAccount(ctx context.Context, address sdk.AccAddress) (authtypes.AccountI, error)
func (*ChainClient) QueryBalanceWithDenomTraces ¶ added in v0.1.3
func (cc *ChainClient) QueryBalanceWithDenomTraces(ctx context.Context, address sdk.AccAddress, pageReq *query.PageRequest) (sdk.Coins, error)
QueryBalanceWithDenomTraces is a helper function for query balance
func (*ChainClient) QueryDelegatorValidators ¶
func (cc *ChainClient) QueryDelegatorValidators(ctx context.Context, address sdk.AccAddress) ([]string, error)
func (*ChainClient) QueryDenomsMetadata ¶ added in v0.1.3
func (cc *ChainClient) QueryDenomsMetadata(ctx context.Context, pageReq *query.PageRequest) (*bankTypes.QueryDenomsMetadataResponse, error)
func (*ChainClient) QueryDistributionCommission ¶
func (cc *ChainClient) QueryDistributionCommission(ctx context.Context, address sdk.ValAddress) (sdk.DecCoins, error)
func (*ChainClient) QueryDistributionCommunityPool ¶
func (*ChainClient) QueryDistributionParams ¶
func (*ChainClient) QueryDistributionRewards ¶
func (cc *ChainClient) QueryDistributionRewards(ctx context.Context, delegatorAddress sdk.AccAddress, validatorAddress sdk.ValAddress) (sdk.DecCoins, error)
func (*ChainClient) QueryDistributionSlashes ¶
func (cc *ChainClient) QueryDistributionSlashes(ctx context.Context, validatorAddress sdk.ValAddress, startHeight, endHeight uint64, pageReq *query.PageRequest) (*distTypes.QueryValidatorSlashesResponse, error)
QueryDistributionSlashes returns all slashes of a validator, optionally pass the start and end height
func (*ChainClient) QueryDistributionValidatorRewards ¶
func (cc *ChainClient) QueryDistributionValidatorRewards(ctx context.Context, validatorAddress sdk.ValAddress) (sdk.DecCoins, error)
QueryDistributionValidatorRewards returns all the validator distribution rewards from a given height
func (*ChainClient) QueryTotalSupply ¶ added in v0.1.3
func (cc *ChainClient) QueryTotalSupply(ctx context.Context, pageReq *query.PageRequest) (*bankTypes.QueryTotalSupplyResponse, error)
QueryTotalSupply returns the total supply of coins on a chain
func (*ChainClient) QueryTx ¶ added in v0.1.3
func (cc *ChainClient) QueryTx(ctx context.Context, hashHex string, prove bool) (*ctypes.ResultTx, error)
QueryTx takes a hex encoded tx hash and decodes it before attempting to query the tx via the RPCClient.
func (*ChainClient) QueryTxs ¶ added in v0.1.3
func (cc *ChainClient) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*ctypes.ResultTx, error)
QueryTxs returns an array of transactions related to the specified event search criteria.
func (*ChainClient) RestoreKey ¶
func (cc *ChainClient) RestoreKey(name, mnemonic string, coinType uint32) (address string, err error)
func (*ChainClient) RunGRPCQuery ¶
func (cc *ChainClient) RunGRPCQuery(ctx context.Context, method string, req interface{}, md metadata.MD) (abci.ResponseQuery, metadata.MD, error)
RunGRPCQuery runs a gRPC query from the clientCtx, given all necessary arguments for the gRPC method, and returns the ABCI response. It is used to factorize code between client (Invoke) and server (RegisterGRPCServer) gRPC handlers.
func (*ChainClient) SendMsg ¶
func (cc *ChainClient) SendMsg(ctx context.Context, msg sdk.Msg, memo string) (*sdk.TxResponse, error)
func (*ChainClient) SendMsgs ¶
func (cc *ChainClient) SendMsgs(ctx context.Context, msgs []sdk.Msg, memo string) (*sdk.TxResponse, error)
SendMsgs wraps the msgs in a StdTx, signs and sends it. An error is returned if there was an issue sending the transaction. A successfully sent, but failed transaction will not return an error. If a transaction is successfully sent, the result of the execution of that transaction will be logged. A boolean indicating if a transaction was successfully sent and executed successfully is returned.
func (*ChainClient) SetSDKContext ¶
func (cc *ChainClient) SetSDKContext() func()
SetSDKConfig sets the SDK config to the proper bech32 prefixes Don't use this unless you know what you're doing. if lens is successful, this can be eliminated TODO: :dagger: :knife: :chainsaw: remove this function
func (*ChainClient) ShowAddress ¶
func (cc *ChainClient) ShowAddress(name string) (address string, err error)
func (*ChainClient) TxFactory ¶
func (cc *ChainClient) TxFactory() tx.Factory
func (*ChainClient) TxServiceBroadcast ¶
func (cc *ChainClient) TxServiceBroadcast(ctx context.Context, req *tx.BroadcastTxRequest) (*tx.BroadcastTxResponse, error)
TxServiceBroadcast is a helper function to broadcast a Tx with the correct gRPC types from the tx service. Calls `clientCtx.BroadcastTx` under the hood.
type ChainClientConfig ¶
type ChainClientConfig struct { Key string `json:"key" yaml:"key"` ChainID string `json:"chain-id" yaml:"chain-id"` RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"` GRPCAddr string `json:"grpc-addr" yaml:"grpc-addr"` AccountPrefix string `json:"account-prefix" yaml:"account-prefix"` KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"` GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"` GasPrices string `json:"gas-prices" yaml:"gas-prices"` MinGasAmount uint64 `json:"min-gas-amount" yaml:"min-gas-amount"` KeyDirectory string `json:"key-directory" yaml:"key-directory"` Debug bool `json:"debug" yaml:"debug"` Timeout string `json:"timeout" yaml:"timeout"` BlockTimeout string `json:"block-timeout" yaml:"block-timeout"` OutputFormat string `json:"output-format" yaml:"output-format"` SignModeStr string `json:"sign-mode" yaml:"sign-mode"` ExtraCodecs []string `json:"extra-codecs" yaml:"extra-codecs"` Modules []module.AppModuleBasic `json:"-" yaml:"-"` }
func GetCosmosHubConfig ¶
func GetCosmosHubConfig(keyHome string, debug bool) *ChainClientConfig
func GetOsmosisConfig ¶
func GetOsmosisConfig(keyHome string, debug bool) *ChainClientConfig
func (*ChainClientConfig) SignMode ¶
func (ccc *ChainClientConfig) SignMode() signing.SignMode
func (*ChainClientConfig) Validate ¶
func (ccc *ChainClientConfig) Validate() error
type Codec ¶
type Codec struct { InterfaceRegistry types.InterfaceRegistry Marshaler codec.Codec TxConfig client.TxConfig Amino *codec.LegacyAmino }
func MakeCodecConfig ¶
func MakeCodecConfig() Codec