Documentation
¶
Overview ¶
Package api contains helper methods for handling events, subscriptions, and more.
Index ¶
- Constants
- func ConvertBase64ToTx(tx string) (transaction.Signed, error)
- func QueryBlockHeight(height uint64) string
- func QueryCoinID(coinID uint64) string
- func QueryCoinSymbol(symbol string) string
- func QueryCommissionCoin(coinID uint64) string
- func QueryCommissionConversion(isPool bool) string
- func QueryEvent(event SubscribeEventType) string
- func QueryFail() string
- func QueryFrom(address string) string
- func QueryHash(hash string) string
- func QueryPublicKey(publicKey string) string
- func QueryTag(tag, param string) string
- func QueryTo(address string) string
- func QueryTxHeight(height uint64) string
- func QueryType(t byte) string
- func SubscribeNewTxFindTag(message, tag string) (string, error)
- func SubscribeNewTxToTx(message string) (transaction.Signed, error)
- type Event
- type EventType
- type JailEvent
- type OrderExpiredEvent
- type RemoveCandidateEvent
- type RewardEvent
- type SlashEvent
- type StakeEvent
- type StakeKickEvent
- type StakeMoveEvent
- type SubscribeEventType
- type SubscribeNewBlockResult
- type SubscribeNewTxResult
- type UnbondEvent
- type UnlockEvent
- type UpdateCommissionsEvent
- type UpdateNetworkEvent
- type UpdatedBlockRewardEvent
- type ValidatorEvent
Examples ¶
Constants ¶
const ( // DAOAddress is DAO's address for charging a 10% commission on all rewards DAOAddress = "Mx7f0fc21d932f38ca9444f61703174569066cfa50" // DevelopersAddress is developers' address for charging a 10% commission on all rewards DevelopersAddress = "Mx688568d9d70c57e71d0b9de6480afb0d317f885c" )
const ( // RoleValidator is validator role RoleValidator = "Validator" // RoleDelegator is delegator role RoleDelegator = "Delegator" // RoleDAO is DAO role RoleDAO = "DAO" // RoleDevelopers is developers role RoleDevelopers = "Developers" )
Variables ¶
This section is empty.
Functions ¶
func ConvertBase64ToTx ¶ added in v2.4.0
func ConvertBase64ToTx(tx string) (transaction.Signed, error)
func QueryBlockHeight ¶ added in v2.4.0
func QueryCoinID ¶ added in v2.4.0
func QueryCoinSymbol ¶ added in v2.4.0
func QueryCommissionCoin ¶ added in v2.4.0
func QueryCommissionConversion ¶ added in v2.4.0
func QueryEvent ¶ added in v2.4.0
func QueryEvent(event SubscribeEventType) string
func QueryPublicKey ¶ added in v2.4.0
func QueryTxHeight ¶ added in v2.4.0
func SubscribeNewTxFindTag ¶ added in v2.2.0
func SubscribeNewTxToTx ¶ added in v2.4.0
func SubscribeNewTxToTx(message string) (transaction.Signed, error)
Types ¶
type Event ¶
type Event interface {
Type() EventType
}
Event interface
func ConvertToEvent ¶
ConvertToEvent returns interface of Event
Example ¶
package main
import (
"fmt"
"github.com/MinterTeam/minter-go-sdk/v2/api"
)
func main() {
eventValueJSON := `{
"address": "Mx7f0fc21d932f38ca9444f61703174569066cfa50",
"amount": "3962700000000000000000",
"role": "Delegator",
"for_coin": "1",
"validator_pub_key": "Mpd83e627510eea6aefa46d9914b0715dabf4a561ced78d34267b31d41d5f700b5"
}`
event, _ := api.ConvertToEvent("minter/RewardEvent", []byte(eventValueJSON))
if event.Type() != api.TypeRewardEvent {
return
}
fmt.Printf("%#v", event.(*api.RewardEvent))
}
Output: &api.RewardEvent{Role:"Delegator", Address:"Mx7f0fc21d932f38ca9444f61703174569066cfa50", Amount:"3962700000000000000000", ValidatorPubKey:"Mpd83e627510eea6aefa46d9914b0715dabf4a561ced78d34267b31d41d5f700b5", ForCoin:"1"}
type EventType ¶ added in v2.1.0
type EventType string
EventType is string name of events
const ( TypeRewardEvent EventType = "minter/RewardEvent" TypeSlashEvent EventType = "minter/SlashEvent" TypeJailEvent EventType = "minter/JailEvent" TypeUnbondEvent EventType = "minter/UnbondEvent" TypeStakeKickEvent EventType = "minter/StakeKickEvent" TypeOrderExpiredEvent EventType = "minter/OrderExpiredEvent" TypeUpdateNetworkEvent EventType = "minter/UpdateNetworkEvent" TypeUpdateCommissionsEvent EventType = "minter/UpdateCommissionsEvent" TypeRemoveCandidateEvent EventType = "minter/RemoveCandidateEvent" TypeStakeMoveEvent EventType = "minter/StakeMoveEvent" TypeUpdatedBlockRewardEvent EventType = "minter/UpdatedBlockRewardEvent" TypeUnlockEvent EventType = "minter/UnlockEvent" )
Event type names
type JailEvent ¶ added in v2.2.0
type JailEvent struct {
ValidatorPubKey string `json:"validator_pub_key"`
JailedUntil string `json:"jailed_until"`
}
func (*JailEvent) GetPublicKey ¶ added in v2.4.0
func (*JailEvent) GetValidatorPublicKey ¶ added in v2.2.0
GetValidatorPublicKey return validator public key Deprecated: Use GetPublicKey
type OrderExpiredEvent ¶ added in v2.4.0
type OrderExpiredEvent struct {
ID string `json:"id"`
Address string `json:"address"`
Coin string `json:"coin"`
Amount string `json:"amount"`
}
func (*OrderExpiredEvent) GetAddress ¶ added in v2.4.0
func (e *OrderExpiredEvent) GetAddress() string
GetAddress return owner address
func (*OrderExpiredEvent) Type ¶ added in v2.4.0
func (e *OrderExpiredEvent) Type() EventType
type RemoveCandidateEvent ¶ added in v2.4.0
type RemoveCandidateEvent struct {
CandidatePubKey string `json:"candidate_pub_key"`
}
func (*RemoveCandidateEvent) GetPublicKey ¶ added in v2.4.0
func (e *RemoveCandidateEvent) GetPublicKey() string
func (*RemoveCandidateEvent) Type ¶ added in v2.4.0
func (e *RemoveCandidateEvent) Type() EventType
type RewardEvent ¶
type RewardEvent struct {
Role string `json:"role"`
Address string `json:"address"`
Amount string `json:"amount"`
ValidatorPubKey string `json:"validator_pub_key"`
ForCoin string `json:"for_coin"`
}
RewardEvent is the payment of rewards
func (*RewardEvent) GetAddress ¶
func (e *RewardEvent) GetAddress() string
GetAddress return owner address
func (*RewardEvent) GetPublicKey ¶ added in v2.4.0
func (e *RewardEvent) GetPublicKey() string
GetPublicKey return validator public key
func (*RewardEvent) GetValidatorPublicKey ¶
func (e *RewardEvent) GetValidatorPublicKey() string
GetValidatorPublicKey return validator public key Deprecated: Use GetPublicKey
func (*RewardEvent) Type ¶ added in v2.2.0
func (e *RewardEvent) Type() EventType
type SlashEvent ¶
type SlashEvent struct {
Address string `json:"address"`
Amount string `json:"amount"`
Coin string `json:"coin"`
ValidatorPubKey string `json:"validator_pub_key"`
}
SlashEvent is the payment of the validator's penalty by this stake
func (*SlashEvent) GetAddress ¶
func (e *SlashEvent) GetAddress() string
GetAddress return owner address
func (*SlashEvent) GetPublicKey ¶ added in v2.4.0
func (e *SlashEvent) GetPublicKey() string
GetPublicKey return validator public key
func (*SlashEvent) GetValidatorPublicKey ¶
func (e *SlashEvent) GetValidatorPublicKey() string
GetValidatorPublicKey return validator public key Deprecated: Use GetPublicKey
func (*SlashEvent) Type ¶ added in v2.2.0
func (e *SlashEvent) Type() EventType
type StakeEvent ¶ added in v2.2.0
type StakeEvent interface {
// GetAddress return owner address
GetAddress() string
ValidatorEvent
}
StakeEvent interface
type StakeKickEvent ¶
type StakeKickEvent struct {
Address string `json:"address"`
Amount string `json:"amount"`
Coin string `json:"coin"`
ValidatorPubKey string `json:"validator_pub_key"`
}
StakeKickEvent is the knocking out a stake to the waiting list
func (*StakeKickEvent) GetAddress ¶
func (e *StakeKickEvent) GetAddress() string
GetAddress return owner address
func (*StakeKickEvent) GetPublicKey ¶ added in v2.4.0
func (e *StakeKickEvent) GetPublicKey() string
GetPublicKey return validator public key
func (*StakeKickEvent) GetValidatorPublicKey ¶
func (e *StakeKickEvent) GetValidatorPublicKey() string
GetValidatorPublicKey return validator public key Deprecated: Use GetPublicKey
func (*StakeKickEvent) Type ¶ added in v2.2.0
func (e *StakeKickEvent) Type() EventType
type StakeMoveEvent ¶ added in v2.2.0
type StakeMoveEvent struct {
Address string `json:"address"`
Amount string `json:"amount"`
Coin string `json:"coin"`
CandidatePubKey string `json:"candidate_pub_key"`
ToCandidatePubKey string `json:"to_candidate_pub_key"`
}
func (*StakeMoveEvent) GetPublicKey ¶ added in v2.5.0
func (e *StakeMoveEvent) GetPublicKey() string
func (*StakeMoveEvent) Type ¶ added in v2.2.0
func (e *StakeMoveEvent) Type() EventType
type SubscribeEventType ¶ added in v2.4.0
type SubscribeEventType string
const ( EventNewBlock SubscribeEventType = "NewBlock" EventNewBlockHeader SubscribeEventType = "NewBlockHeader" EventNewEvidence SubscribeEventType = "NewEvidence" EventTx SubscribeEventType = "Tx" EventValidatorSetUpdates SubscribeEventType = "ValidatorSetUpdates" )
Reserved event types. Block level events for mass consumption by users. These events are triggered from the state package, after a block has been committed. These are also used by the tx indexer for async indexing.
type SubscribeNewBlockResult ¶ added in v2.2.0
type SubscribeNewBlockResult struct {
Query string `json:"query"`
Data struct {
Block struct {
Data struct {
Txs []string `json:"txs"`
} `json:"data"`
Evidence struct {
Evidence []interface{} `json:"evidence"`
} `json:"evidence"`
Header struct {
AppHash string `json:"app_hash"`
ChainID string `json:"chain_id"`
ConsensusHash string `json:"consensus_hash"`
DataHash string `json:"data_hash"`
EvidenceHash string `json:"evidence_hash"`
Height uint64 `json:"height"`
LastBlockID struct {
Hash string `json:"hash"`
Parts struct {
Hash string `json:"hash"`
Total uint64 `json:"total"`
} `json:"parts"`
} `json:"last_block_id"`
LastCommitHash string `json:"last_commit_hash"`
LastResultsHash string `json:"last_results_hash"`
NextValidatorsHash string `json:"next_validators_hash"`
ProposerAddress string `json:"proposer_address"`
Time time.Time `json:"time"`
ValidatorsHash string `json:"validators_hash"`
Version struct {
Block uint64 `json:"block"`
} `json:"version"`
} `json:"header"`
LastCommit struct {
BlockID struct {
Hash string `json:"hash"`
Parts struct {
Hash string `json:"hash"`
Total uint64 `json:"total"`
} `json:"parts"`
} `json:"block_id"`
Height uint64 `json:"height"`
Round uint64 `json:"round"`
Signatures []struct {
BlockIDFlag uint64 `json:"block_id_flag"`
Signature string `json:"signature"`
Timestamp time.Time `json:"timestamp"`
ValidatorAddress string `json:"validator_address"`
} `json:"signatures"`
} `json:"last_commit"`
} `json:"block"`
ResultBeginBlock struct {
} `json:"result_begin_block"`
ResultEndBlock struct {
ConsensusParamUpdates struct {
Block struct {
MaxBytes uint64 `json:"max_bytes"`
MaxGas uint64 `json:"max_gas"`
} `json:"block"`
} `json:"consensus_param_updates"`
ValidatorUpdates interface{} `json:"validator_updates"`
} `json:"result_end_block"`
} `json:"data"`
Events []struct {
Key string `json:"key"`
Events []string `json:"events"`
} `json:"events"`
}
func SubscribeNewBlockParse ¶ added in v2.2.0
func SubscribeNewBlockParse(message string) (*SubscribeNewBlockResult, error)
type SubscribeNewTxResult ¶ added in v2.2.0
type SubscribeNewTxResult struct {
Query string `json:"query"`
Data struct {
Height uint64 `json:"height"`
Result struct {
Events []struct {
Attributes []struct {
Index bool `json:"index"`
Key string `json:"key"`
Value string `json:"value"`
} `json:"attributes"`
Type string `json:"type"`
} `json:"events"`
GasUsed uint64 `json:"gas_used"`
GasWanted uint64 `json:"gas_wanted"`
} `json:"result"`
Tx string `json:"tx"`
} `json:"data"`
Events []struct {
Key string `json:"key"`
Events []string `json:"events"`
} `json:"events"`
}
func SubscribeNewTxParse ¶ added in v2.2.0
func SubscribeNewTxParse(message string) (*SubscribeNewTxResult, error)
type UnbondEvent ¶
type UnbondEvent struct {
Address string `json:"address"`
Amount string `json:"amount"`
Coin string `json:"coin"`
ValidatorPubKey string `json:"validator_pub_key"`
}
UnbondEvent is the unbinding a stake from a validator
func (*UnbondEvent) GetAddress ¶
func (e *UnbondEvent) GetAddress() string
GetAddress return owner address
func (*UnbondEvent) GetPublicKey ¶ added in v2.4.0
func (e *UnbondEvent) GetPublicKey() string
GetPublicKey return validator public key
func (*UnbondEvent) GetValidatorPublicKey ¶
func (e *UnbondEvent) GetValidatorPublicKey() string
GetValidatorPublicKey return validator public key Deprecated: Use GetPublicKey
func (*UnbondEvent) Type ¶ added in v2.2.0
func (e *UnbondEvent) Type() EventType
type UnlockEvent ¶ added in v2.5.0
type UnlockEvent struct {
Address string `json:"address"`
Amount string `json:"amount"`
Coin string `json:"coin"`
}
UnlockEvent is ...
func (*UnlockEvent) GetAddress ¶ added in v2.5.0
func (e *UnlockEvent) GetAddress() string
GetAddress return owner address
func (*UnlockEvent) Type ¶ added in v2.5.0
func (e *UnlockEvent) Type() EventType
type UpdateCommissionsEvent ¶ added in v2.2.0
type UpdateCommissionsEvent struct {
Coin string `json:"coin"`
PayloadByte string `json:"payload_byte"`
Send string `json:"send"`
BuyBancor string `json:"buy_bancor"`
SellBancor string `json:"sell_bancor"`
SellAllBancor string `json:"sell_all_bancor"`
BuyPoolBase string `json:"buy_pool_base"`
BuyPoolDelta string `json:"buy_pool_delta"`
SellPoolBase string `json:"sell_pool_base"`
SellPoolDelta string `json:"sell_pool_delta"`
SellAllPoolBase string `json:"sell_all_pool_base"`
SellAllPoolDelta string `json:"sell_all_pool_delta"`
CreateTicker3 string `json:"create_ticker3"`
CreateTicker4 string `json:"create_ticker4"`
CreateTicker5 string `json:"create_ticker5"`
CreateTicker6 string `json:"create_ticker6"`
CreateTicker7_10 string `json:"create_ticker7_10"`
CreateCoin string `json:"create_coin"`
CreateToken string `json:"create_token"`
RecreateCoin string `json:"recreate_coin"`
RecreateToken string `json:"recreate_token"`
DeclareCandidacy string `json:"declare_candidacy"`
Delegate string `json:"delegate"`
Unbond string `json:"unbond"`
RedeemCheck string `json:"redeem_check"`
SetCandidateOn string `json:"set_candidate_on"`
SetCandidateOff string `json:"set_candidate_off"`
CreateMultisig string `json:"create_multisig"`
MultisendBase string `json:"multisend_base"`
MultisendDelta string `json:"multisend_delta"`
EditCandidate string `json:"edit_candidate"`
SetHaltBlock string `json:"set_halt_block"`
EditTickerOwner string `json:"edit_ticker_owner"`
EditMultisig string `json:"edit_multisig"`
PriceVote string `json:"price_vote"`
EditCandidatePublicKey string `json:"edit_candidate_public_key"`
CreateSwapPool string `json:"create_swap_pool"`
AddLiquidity string `json:"add_liquidity"`
RemoveLiquidity string `json:"remove_liquidity"`
EditCandidateCommission string `json:"edit_candidate_commission"`
MintToken string `json:"mint_token"`
BurnToken string `json:"burn_token"`
VoteCommission string `json:"vote_commission"`
VoteUpdate string `json:"vote_update"`
FailedTx string `json:"failed_tx,omitempty"`
AddLimitOrder string `json:"add_limit_order,omitempty"`
RemoveLimitOrder string `json:"remove_limit_order,omitempty"`
MoveStake string `json:"move_stake,omitempty"`
LockStake string `json:"lock_stake,omitempty"`
Lock string `json:"lock,omitempty"`
}
func (*UpdateCommissionsEvent) Type ¶ added in v2.2.0
func (e *UpdateCommissionsEvent) Type() EventType
type UpdateNetworkEvent ¶ added in v2.2.0
type UpdateNetworkEvent struct {
Version string `json:"version"`
}
func (*UpdateNetworkEvent) Type ¶ added in v2.2.0
func (e *UpdateNetworkEvent) Type() EventType
type UpdatedBlockRewardEvent ¶ added in v2.5.0
type UpdatedBlockRewardEvent struct {
Value string `json:"value"`
ValueLockedStakeRewards string `json:"value_locked_stake_rewards"`
}
func (*UpdatedBlockRewardEvent) Type ¶ added in v2.5.0
func (e *UpdatedBlockRewardEvent) Type() EventType
type ValidatorEvent ¶ added in v2.2.0
type ValidatorEvent interface {
// GetPublicKey return validator public key
GetPublicKey() string
}
ValidatorEvent interface
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grpc_client package implements the gRPC methods usage interface.
|
Package grpc_client package implements the gRPC methods usage interface. |
|
Package http_client package implements the API v2 methods usage interface.
|
Package http_client package implements the API v2 methods usage interface. |