api

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 3 Imported by: 3

Documentation

Overview

Package api ...

Index

Examples

Constants

View Source
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"
)
View Source
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 SubscribeNewTxFindTag added in v2.2.0

func SubscribeNewTxFindTag(message, tag string) (string, error)

Types

type Event

type Event interface {
	Type() EventType
}

Event interface

func ConvertToEvent

func ConvertToEvent(typeName EventType, value []byte) (Event, error)

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": "DAO",
        "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:"DAO", Address:"Mx7f0fc21d932f38ca9444f61703174569066cfa50", Amount:"3962700000000000000000", ValidatorPubKey:"Mpd83e627510eea6aefa46d9914b0715dabf4a561ced78d34267b31d41d5f700b5"}

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"
	TypeStakeMoveEvent         EventType = "minter/StakeMoveEvent"
	TypeUpdateNetworkEvent     EventType = "minter/UpdateNetworkEvent"
	TypeUpdateCommissionsEvent EventType = "minter/UpdateCommissionsEvent"
)

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) GetValidatorPublicKey added in v2.2.0

func (e *JailEvent) GetValidatorPublicKey() string

func (*JailEvent) Type added in v2.2.0

func (e *JailEvent) 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"`
}

RewardEvent is the payment of rewards

func (*RewardEvent) GetAddress

func (e *RewardEvent) GetAddress() string

GetAddress return owner address

func (*RewardEvent) GetValidatorPublicKey

func (e *RewardEvent) GetValidatorPublicKey() string

GetValidatorPublicKey return validator public key

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) GetValidatorPublicKey

func (e *SlashEvent) GetValidatorPublicKey() string

GetValidatorPublicKey return validator public key

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) GetValidatorPublicKey

func (e *StakeKickEvent) GetValidatorPublicKey() string

GetValidatorPublicKey return validator public key

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"`
	ValidatorPubKey string `json:"validator_pub_key"`
	WaitList        bool   `json:"waitlist"`
}

StakeMoveEvent ...

func (*StakeMoveEvent) GetAddress added in v2.2.0

func (e *StakeMoveEvent) GetAddress() string

GetAddress return owner address

func (*StakeMoveEvent) GetValidatorPublicKey added in v2.2.0

func (e *StakeMoveEvent) GetValidatorPublicKey() string

GetValidatorPublicKey return validator public key

func (*StakeMoveEvent) Type added in v2.2.0

func (e *StakeMoveEvent) Type() EventType

type SubscribeNewBlockResult added in v2.2.0

type SubscribeNewBlockResult struct {
	Query string `json:"query"`
	Data  struct {
		Block struct {
			Data struct {
				Txs []interface{} `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        int    `json:"height"`
				LastBlockID   struct {
					Hash  string `json:"hash"`
					Parts struct {
						Hash  string `json:"hash"`
						Total int    `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 int `json:"block"`
				} `json:"version"`
			} `json:"header"`
			LastCommit struct {
				BlockID struct {
					Hash  string `json:"hash"`
					Parts struct {
						Hash  string `json:"hash"`
						Total int    `json:"total"`
					} `json:"parts"`
				} `json:"block_id"`
				Height     int `json:"height"`
				Round      int `json:"round"`
				Signatures []struct {
					BlockIDFlag      int       `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 int `json:"max_bytes"`
					MaxGas   int `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 int `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   int `json:"gas_used"`
			GasWanted int `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) GetValidatorPublicKey

func (e *UnbondEvent) GetValidatorPublicKey() string

GetValidatorPublicKey return validator public key

func (*UnbondEvent) Type added in v2.2.0

func (e *UnbondEvent) 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"`
	MoveStake               string `json:"move_stake"`
	MintToken               string `json:"mint_token"`
	BurnToken               string `json:"burn_token"`
	VoteCommission          string `json:"vote_commission"`
	VoteUpdate              string `json:"vote_update"`
}

func (*UpdateCommissionsEvent) Type added in v2.2.0

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 ValidatorEvent added in v2.2.0

type ValidatorEvent interface {
	// GetValidatorPublicKey return validator public key
	GetValidatorPublicKey() string
}

ValidatorEvent interface

Directories

Path Synopsis
Package grpc_client is the interface for uses gRPC methods.
Package grpc_client is the interface for uses gRPC methods.
Package http_client is the interface for uses API v2 methods.
Package http_client is the interface for uses API v2 methods.

Jump to

Keyboard shortcuts

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