api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const LatestBlockHeight = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressResponse

type AddressResponse struct {
	Jsonrpc string         `json:"jsonrpc"`
	ID      string         `json:"id,omitempty"`
	Result  *AddressResult `json:"result,omitempty"`
	Error   *Error         `json:"error,omitempty"`
}

type AddressResult

type AddressResult struct {
	Balance          []Balance `json:"balances"`
	TransactionCount string    `json:"transaction_count"`
}

type AddressesResponse added in v0.2.5

type AddressesResponse struct {
	Jsonrpc string             `json:"jsonrpc"`
	ID      string             `json:"id,omitempty"`
	Result  []*AddressesResult `json:"result,omitempty"`
	Error   *Error             `json:"error,omitempty"`
}

type AddressesResult added in v0.2.5

type AddressesResult struct {
	Address          string    `json:"address"`
	Balance          []Balance `json:"balance"`
	TransactionCount string    `json:"transaction_count"`
}

type Api

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

func NewApi

func NewApi(hostUrl string) *Api

Create MinterAPI instance.

func NewApiWithClient added in v0.2.4

func NewApiWithClient(hostUrl string, client *resty.Client) *Api

Create MinterAPI instance with custom client

func (*Api) Address

func (a *Api) Address(address string) (*AddressResult, error)

Returns coins list, balance and transaction count (for nonce) of an address.

func (*Api) AddressAtHeight added in v1.0.0

func (a *Api) AddressAtHeight(address string, height int) (*AddressResult, error)

Returns coins list, balance and transaction count (for nonce) of an address.

func (*Api) Addresses added in v0.2.5

func (a *Api) Addresses(addresses []string, height int) ([]*AddressesResult, error)

func (*Api) Balance

func (a *Api) Balance(address string) ([]Balance, error)

Returns balance of an address.

func (*Api) BalanceAtHeight added in v1.0.0

func (a *Api) BalanceAtHeight(address string, height int) ([]Balance, error)

Returns balance of an address.

func (*Api) Block

func (a *Api) Block(height int) (*BlockResult, error)

Returns block data at given height.

func (*Api) Candidate

func (a *Api) Candidate(pubKey string) (*CandidateResult, error)

Returns candidate’s info by provided public_key. It will respond with 404 code if candidate is not found.

func (*Api) CandidateAtHeight added in v1.0.0

func (a *Api) CandidateAtHeight(pubKey string, height int) (*CandidateResult, error)

Returns candidate’s info by provided public_key. It will respond with 404 code if candidate is not found.

func (*Api) Candidates

func (a *Api) Candidates(includeStakes bool) ([]*CandidateResult, error)

Returns list of candidates.

func (*Api) CandidatesAtHeight added in v1.0.0

func (a *Api) CandidatesAtHeight(height int, includeStakes bool) ([]*CandidateResult, error)

Returns list of candidates.

func (*Api) CoinInfo

func (a *Api) CoinInfo(symbol string) (*CoinInfoResult, error)

Returns information about coin. Note: this method does not return information about base coins (MNT and BIP).

func (*Api) CoinInfoAtHeight added in v1.0.0

func (a *Api) CoinInfoAtHeight(symbol string, height int) (*CoinInfoResult, error)

Returns information about coin. Note: this method does not return information about base coins (MNT and BIP).

func (*Api) EstimateCoinBuy

func (a *Api) EstimateCoinBuy(coinToSell string, valueToBuy string, coinToBuy string) (*EstimateCoinBuyResult, error)

Return estimate of buy coin transaction.

func (*Api) EstimateCoinBuyAtHeight added in v1.0.0

func (a *Api) EstimateCoinBuyAtHeight(coinToSell string, valueToBuy string, coinToBuy string, height int) (*EstimateCoinBuyResult, error)

Return estimate of buy coin transaction.

func (*Api) EstimateCoinSell

func (a *Api) EstimateCoinSell(coinToSell string, valueToSell string, coinToBuy string) (*EstimateCoinSellResult, error)

Return estimate of sell coin transaction.

func (*Api) EstimateCoinSellAll added in v0.2.5

func (a *Api) EstimateCoinSellAll(coinToSell string, coinToBuy string, valueToSell string, gasPrice int) (*EstimateCoinSellAllResult, error)

func (*Api) EstimateCoinSellAllAtHeight added in v1.0.0

func (a *Api) EstimateCoinSellAllAtHeight(coinToSell string, coinToBuy string, valueToSell string, gasPrice int, height int) (*EstimateCoinSellAllResult, error)

func (*Api) EstimateCoinSellAtHeight added in v1.0.0

func (a *Api) EstimateCoinSellAtHeight(coinToSell string, valueToSell string, coinToBuy string, height int) (*EstimateCoinSellResult, error)

Return estimate of sell coin transaction.

func (*Api) EstimateTxCommission

func (a *Api) EstimateTxCommission(transaction interface{ Encode() (string, error) }) (*EstimateTxCommissionResult, error)

Return estimate of transaction.

func (*Api) Events

func (a *Api) Events() (*EventsResult, error)

Returns events at given height.

func (*Api) EventsAtHeight added in v1.0.0

func (a *Api) EventsAtHeight(height int) (*EventsResult, error)

Returns events at given height.

func (*Api) MaxGas

func (a *Api) MaxGas() (string, error)

Returns current max gas.

func (*Api) MinGasPrice

func (a *Api) MinGasPrice() (string, error)

Returns current min gas price.

func (*Api) MissedBlocks

func (a *Api) MissedBlocks(pubKey string) (*MissedBlocksResult, error)

Returns missed blocks by validator public key.

func (*Api) MissedBlocksAtHeight added in v1.0.0

func (a *Api) MissedBlocksAtHeight(pubKey string, height int) (*MissedBlocksResult, error)

Returns missed blocks by validator public key.

func (*Api) Nonce

func (a *Api) Nonce(address string) (uint64, error)

Returns next transaction number (nonce) of an address.

func (*Api) SendRawTransaction added in v1.0.0

func (a *Api) SendRawTransaction(tx string) (*SendTransactionResult, error)

Returns the result of raw tx. To ensure that transaction was successfully committed to the blockchain, you need to find the transaction by the hash and ensure that the status code equals to 0.

func (*Api) SendTransaction

func (a *Api) SendTransaction(transaction interface{ Encode() (string, error) }) (*SendTransactionResult, error)

Returns the result of sending signed tx.

func (*Api) Status

func (a *Api) Status() (*StatusResult, error)

Returns node status info.

func (*Api) Transaction

func (a *Api) Transaction(hash string) (*TransactionResult, error)

Returns transaction info.

func (*Api) Transactions

func (a *Api) Transactions(query string, page int, perPage int) ([]*TransactionResult, error)

Return transactions by query.

func (*Api) UnconfirmedTxs

func (a *Api) UnconfirmedTxs(limit int) (*UnconfirmedTxsResult, error)

Returns unconfirmed transactions.

func (*Api) Validators

func (a *Api) Validators() ([]*ValidatorResult, error)

Returns list of active validators.

func (*Api) ValidatorsAtHeight added in v1.0.0

func (a *Api) ValidatorsAtHeight(height int) ([]*ValidatorResult, error)

Returns list of active validators.

func (*Api) ValidatorsPage added in v1.0.3

func (a *Api) ValidatorsPage(height, page, perPage int) ([]*ValidatorResult, error)

Returns list of active validators with custom paging.

type Balance added in v1.1.7

type Balance struct {
	ID     string `json:"coin_id"`
	Symbol string `json:"symbol"`
	Value  string `json:"value"`
}

type BlockResponse

type BlockResponse struct {
	Jsonrpc string       `json:"jsonrpc"`
	ID      string       `json:"id,omitempty"`
	Result  *BlockResult `json:"result,omitempty"`
	Error   *Error       `json:"error,omitempty"`
}

type BlockResult

type BlockResult struct {
	Hash         string              `json:"hash"`
	Height       string              `json:"height"`
	Time         time.Time           `json:"time"`
	NumTxs       string              `json:"num_txs"`
	TotalTxs     string              `json:"total_txs"`
	Transactions []TransactionResult `json:"transactions"`
	BlockReward  string              `json:"block_reward"`
	Size         string              `json:"size"`
	Proposer     string              `json:"proposer"`
	Validators   []struct {
		PubKey string `json:"pub_key"`
		Signed bool   `json:"signed"`
	} `json:"validators"`
}

type BuyCoinData

type BuyCoinData struct {
	CoinToBuy          Coin   `json:"coin_to_buy"`
	ValueToBuy         string `json:"value_to_buy"`
	CoinToSell         Coin   `json:"coin_to_sell"`
	MaximumValueToSell string `json:"maximum_value_to_sell"`
}

type CandidateResponse

type CandidateResponse struct {
	Jsonrpc string           `json:"jsonrpc"`
	ID      string           `json:"id,omitempty"`
	Result  *CandidateResult `json:"result,omitempty"`
	Error   *Error           `json:"error,omitempty"`
}

type CandidateResult

type CandidateResult struct {
	RewardAddress string `json:"reward_address"`
	OwnerAddress  string `json:"owner_address"`
	TotalStake    string `json:"total_stake"`
	PubKey        string `json:"pub_key"`
	Commission    string `json:"commission"`
	Stakes        []struct {
		Owner    string `json:"owner"`
		Coin     Coin   `json:"coin"`
		Value    string `json:"value"`
		BipValue string `json:"bip_value"`
	} `json:"stakes"`
	Status int `json:"status"`
}

type CandidatesResponse

type CandidatesResponse struct {
	Jsonrpc string             `json:"jsonrpc"`
	ID      string             `json:"id,omitempty"`
	Result  []*CandidateResult `json:"result,omitempty"`
	Error   *Error             `json:"error,omitempty"`
}

type Coin added in v1.1.7

type Coin struct {
	ID     string `json:"id"`
	Symbol string `json:"symbol"`
}

type CoinInfoResponse

type CoinInfoResponse struct {
	Jsonrpc string          `json:"jsonrpc"`
	ID      string          `json:"id,omitempty"`
	Result  *CoinInfoResult `json:"result,omitempty"`
	Error   *Error          `json:"error,omitempty"`
}

type CoinInfoResult

type CoinInfoResult struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	Symbol         string `json:"symbol"`
	Volume         string `json:"volume"`
	Crr            int    `json:"crr"`
	ReserveBalance string `json:"reserve_balance"`
	MaxSupply      string `json:"max_supply"`
	OwnerAddress   string `json:"owner_address,omitempty"`
}

type CreateCoinData

type CreateCoinData struct {
	Name                 string `json:"name"`
	Symbol               string `json:"symbol"`
	InitialAmount        string `json:"initial_amount"`
	InitialReserve       string `json:"initial_reserve"`
	ConstantReserveRatio string `json:"constant_reserve_ratio"`
	MaxSupply            string `json:"max_supply"`
}

type CreateMultisigData

type CreateMultisigData struct {
	Threshold uint       `json:"threshold"`
	Weights   []uint     `json:"weights"`
	Addresses [][20]byte `json:"addresses"`
}

type DeclareCandidacyData

type DeclareCandidacyData struct {
	Address    string `json:"address"`
	PubKey     string `json:"pub_key"`
	Commission string `json:"commission"`
	Coin       Coin   `json:"coin"`
	Stake      string `json:"stake"`
}

type DelegateData

type DelegateData struct {
	PubKey string `json:"pub_key"`
	Coin   Coin   `json:"coin"`
	Value  string `json:"value"`
}

type EditCandidateData

type EditCandidateData struct {
	PubKey        string `json:"pub_key"`
	RewardAddress string `json:"reward_address"`
	OwnerAddress  string `json:"owner_address"`
}

type Error

type Error struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message"`
	Data    string `json:"data"`
}

func (*Error) Error

func (e *Error) Error() string

type EstimateCoinBuyResponse

type EstimateCoinBuyResponse struct {
	Jsonrpc string                 `json:"jsonrpc"`
	ID      string                 `json:"id,omitempty"`
	Result  *EstimateCoinBuyResult `json:"result,omitempty"`
	Error   *Error                 `json:"error,omitempty"`
}

type EstimateCoinBuyResult

type EstimateCoinBuyResult struct {
	WillPay    string `json:"will_pay"`
	Commission string `json:"commission"`
}

type EstimateCoinSellAllResponse added in v0.2.5

type EstimateCoinSellAllResponse struct {
	Jsonrpc string                     `json:"jsonrpc"`
	ID      string                     `json:"id,omitempty"`
	Result  *EstimateCoinSellAllResult `json:"result,omitempty"`
	Error   *Error                     `json:"error,omitempty"`
}

type EstimateCoinSellAllResult added in v0.2.5

type EstimateCoinSellAllResult struct {
	WillGet string `json:"will_get"`
}

type EstimateCoinSellResponse

type EstimateCoinSellResponse struct {
	Jsonrpc string                  `json:"jsonrpc"`
	ID      string                  `json:"id,omitempty"`
	Result  *EstimateCoinSellResult `json:"result,omitempty"`
	Error   *Error                  `json:"error,omitempty"`
}

type EstimateCoinSellResult

type EstimateCoinSellResult struct {
	WillGet    string `json:"will_get"`
	Commission string `json:"commission"`
}

type EstimateTxCommissionResponse

type EstimateTxCommissionResponse struct {
	Jsonrpc string                      `json:"jsonrpc"`
	ID      string                      `json:"id,omitempty"`
	Result  *EstimateTxCommissionResult `json:"result,omitempty"`
	Error   *Error                      `json:"error,omitempty"`
}

type EstimateTxCommissionResult

type EstimateTxCommissionResult struct {
	Commission string `json:"commission"`
}

type Event added in v0.1.2

type Event struct {
	Type  string            `json:"type"`
	Value map[string]string `json:"value"`
}

func (*Event) ValueStruct added in v0.1.2

func (e *Event) ValueStruct() (interface{}, error)

Converting event map data to the structure interface regarding event type

type EventsResponse

type EventsResponse struct {
	Jsonrpc string        `json:"jsonrpc"`
	ID      string        `json:"id,omitempty"`
	Result  *EventsResult `json:"result,omitempty"`
	Error   *Error        `json:"error,omitempty"`
}

type EventsResult

type EventsResult struct {
	Events []Event `json:"events"`
}

type MaxGasResponse

type MaxGasResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	ID      string `json:"id,omitempty"`
	Result  string `json:"result,omitempty"`
	Error   *Error `json:"error,omitempty"`
}

type MinGasPriceResponse

type MinGasPriceResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	ID      string `json:"id,omitempty"`
	Result  string `json:"result,omitempty"`
	Error   *Error `json:"error,omitempty"`
}

type MissedBlocksResponse

type MissedBlocksResponse struct {
	Jsonrpc string              `json:"jsonrpc"`
	ID      string              `json:"id,omitempty"`
	Result  *MissedBlocksResult `json:"result,omitempty"`
	Error   *Error              `json:"error,omitempty"`
}

type MissedBlocksResult

type MissedBlocksResult struct {
	MissedBlocks      string `json:"missed_blocks"`
	MissedBlocksCount string `json:"missed_blocks_count"`
}

type MultisendData

type MultisendData struct {
	List []MultisendDataItem
}

type MultisendDataItem

type MultisendDataItem SendData

type RedeemCheckData

type RedeemCheckData struct {
	RawCheck string `json:"raw_check"`
	Proof    string `json:"proof"`
}

type ResponseError added in v0.2.16

type ResponseError struct {
	*resty.Response
}

func NewResponseError added in v0.2.16

func NewResponseError(response *resty.Response) *ResponseError

func (*ResponseError) Error added in v0.2.16

func (res *ResponseError) Error() string

type RewardEventValue added in v0.1.2

type RewardEventValue struct {
	Role            string `json:"role"`
	Address         string `json:"address"`
	Amount          string `json:"amount"`
	ValidatorPubKey string `json:"validator_pub_key"`
}

type SellAllCoinData

type SellAllCoinData struct {
	CoinToSell        Coin   `json:"coin_to_sell"`
	CoinToBuy         Coin   `json:"coin_to_buy"`
	MinimumValueToBuy string `json:"minimum_value_to_buy"`
}

type SellCoinData

type SellCoinData struct {
	CoinToSell        Coin   `json:"coin_to_sell"`
	ValueToSell       string `json:"value_to_sell"`
	CoinToBuy         Coin   `json:"coin_to_buy"`
	MinimumValueToBuy string `json:"minimum_value_to_buy"`
}

type SendData

type SendData struct {
	Coin  Coin   `json:"coin"`
	To    string `json:"to"`
	Value string `json:"value"`
}

type SendTransactionResponse

type SendTransactionResponse struct {
	Jsonrpc string                 `json:"jsonrpc"`
	ID      string                 `json:"id,omitempty"`
	Result  *SendTransactionResult `json:"result,omitempty"`
	Error   *TxError               `json:"error,omitempty"`
}

type SendTransactionResult

type SendTransactionResult struct {
	Code int    `json:"code"`
	Data string `json:"data"`
	Log  string `json:"log"`
	Hash string `json:"hash"`
}

type SetCandidateOffData

type SetCandidateOffData struct {
	PubKey string `json:"pub_key"`
}

type SetCandidateOnData

type SetCandidateOnData struct {
	PubKey string `json:"pub_key"`
}

type SlashEventValue added in v0.1.2

type SlashEventValue struct {
	Address         string `json:"address"`
	Amount          string `json:"amount"`
	Coin            string `json:"coin"`
	ValidatorPubKey string `json:"validator_pub_key"`
}

type StatusResponse

type StatusResponse struct {
	Jsonrpc string        `json:"jsonrpc"`
	ID      string        `json:"id,omitempty"`
	Result  *StatusResult `json:"result,omitempty"`
	Error   *Error        `json:"error,omitempty"`
}

type StatusResult

type StatusResult struct {
	Version           string    `json:"version"`
	LatestBlockHash   string    `json:"latest_block_hash"`
	LatestAppHash     string    `json:"latest_app_hash"`
	LatestBlockHeight string    `json:"latest_block_height"`
	LatestBlockTime   time.Time `json:"latest_block_time"`
	StateHistory      string    `json:"state_history"`
	TmStatus          struct {
		NodeInfo struct {
			ProtocolVersion struct {
				P2P   string `json:"p2p"`
				Block string `json:"block"`
				App   string `json:"app"`
			} `json:"protocol_version"`
			ID         string `json:"id,omitempty"`
			ListenAddr string `json:"listen_addr"`
			Network    string `json:"network"`
			Version    string `json:"version"`
			Channels   string `json:"channels"`
			Moniker    string `json:"moniker"`
			Other      struct {
				TxIndex    string `json:"tx_index"`
				RPCAddress string `json:"rpc_address"`
			} `json:"other"`
		} `json:"node_info"`
		SyncInfo struct {
			LatestBlockHash   string    `json:"latest_block_hash"`
			LatestAppHash     string    `json:"latest_app_hash"`
			LatestBlockHeight string    `json:"latest_block_height"`
			LatestBlockTime   time.Time `json:"latest_block_time"`
			CatchingUp        bool      `json:"catching_up"`
		} `json:"sync_info"`
		ValidatorInfo struct {
			Address string `json:"address"`
			PubKey  struct {
				Type  string `json:"type"`
				Value string `json:"value"`
			} `json:"pub_key"`
			VotingPower string `json:"voting_power"`
		} `json:"validator_info"`
	} `json:"tm_status"`
}

type TransactionResponse

type TransactionResponse struct {
	Jsonrpc string             `json:"jsonrpc"`
	ID      string             `json:"id,omitempty"`
	Result  *TransactionResult `json:"result,omitempty"`
	Error   *Error             `json:"error,omitempty"`
}

type TransactionResult

type TransactionResult struct {
	Hash        string          `json:"hash"`
	RawTx       string          `json:"raw_tx"`
	Height      string          `json:"height"`
	Index       int             `json:"index,omitempty"`
	From        string          `json:"from"`
	Nonce       string          `json:"nonce"`
	Gas         string          `json:"gas"`
	GasPrice    int             `json:"gas_price"`
	GasCoin     Coin            `json:"gas_coin"`
	Type        int             `json:"type"`
	Data        transactionData `json:"data"`
	Payload     []byte          `json:"payload"`
	ServiceData []byte          `json:"service_data"`
	Tags        struct {
		TxCoinToBuy       string `json:"tx.coin_to_buy,omitempty"`
		TxCoinToSell      string `json:"tx.coin_to_sell,omitempty"`
		TxReturn          string `json:"tx.return,omitempty"`
		TxType            string `json:"tx.type,omitempty"`
		TxFrom            string `json:"tx.from,omitempty"`
		TxTo              string `json:"tx.to,omitempty"`
		TxCoinID          string `json:"tx.coin_id,omitempty"`
		TxCoinSymbol      string `json:"tx.coin_symbol,omitempty"`
		TxSellAmount      string `json:"tx.sell_amount,omitempty"`
		TxCreatedMultisig string `json:"tx.created_multisig,omitempty"`
	} `json:"tags,omitempty"`
	Code uint32 `json:"code,omitempty"`
	Log  string `json:"log,omitempty"`
}

func (*TransactionResult) DataStruct

func (t *TransactionResult) DataStruct() (tdi, error)

Converting transaction map data to the structure interface regarding transaction type

func (*TransactionResult) ErrorLog added in v0.2.5

func (t *TransactionResult) ErrorLog() error

func (*TransactionResult) IsValid added in v0.2.5

func (t *TransactionResult) IsValid() bool

type TransactionsResponse

type TransactionsResponse struct {
	Jsonrpc string               `json:"jsonrpc"`
	ID      string               `json:"id,omitempty"`
	Result  []*TransactionResult `json:"result,omitempty"`
	Error   *Error               `json:"error,omitempty"`
}

type TxError

type TxError struct {
	Code     int    `json:"code,omitempty"`
	Message  string `json:"message,omitempty"`
	Data     string `json:"data,omitempty"`
	TxResult struct {
		Code int    `json:"code,omitempty"`
		Log  string `json:"log,omitempty"`
	} `json:"tx_result,omitempty"`
}

func (*TxError) Error

func (e *TxError) Error() string

type UnbondData

type UnbondData struct {
	PubKey string `json:"pub_key"`
	Coin   Coin   `json:"coin"`
	Value  string `json:"value"`
}

type UnbondEventValue added in v0.1.2

type UnbondEventValue struct {
	Address         string `json:"address"`
	Amount          string `json:"amount"`
	Coin            string `json:"coin"`
	ValidatorPubKey string `json:"validator_pub_key"`
}

type UnconfirmedTxsResponse

type UnconfirmedTxsResponse struct {
	Jsonrpc string                `json:"jsonrpc"`
	ID      string                `json:"id,omitempty"`
	Result  *UnconfirmedTxsResult `json:"result,omitempty"`
	Error   *Error                `json:"error,omitempty"`
}

type UnconfirmedTxsResult

type UnconfirmedTxsResult struct {
	NTxs       string   `json:"n_txs"`
	Total      string   `json:"total"`
	TotalBytes string   `json:"total_bytes"`
	Txs        []string `json:"txs"`
}

type ValidatorResult

type ValidatorResult struct {
	PubKey      string `json:"pub_key"`
	VotingPower string `json:"voting_power"`
}

type ValidatorsResponse

type ValidatorsResponse struct {
	Jsonrpc string             `json:"jsonrpc"`
	ID      string             `json:"id,omitempty"`
	Result  []*ValidatorResult `json:"result,omitempty"`
	Error   *Error             `json:"error,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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