api

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: MIT Imports: 8 Imported by: 0

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          map[string]string `json:"balance"`
	TransactionCount string            `json:"transaction_count"`
}

type AddressesResponse

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

type AddressesResult

type AddressesResult struct {
	Address          string            `json:"address"`
	Balance          map[string]string `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

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

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

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

func (*Api) Balance

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

Returns balance of an address.

func (*Api) BalanceAtHeight

func (a *Api) BalanceAtHeight(address string, height int) (map[string]string, 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

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

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

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

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

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

func (*Api) EstimateCoinSellAllAtHeight

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

func (*Api) EstimateCoinSellAtHeight

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 transaction.EncodeInterface) (*EstimateTxCommissionResult, error)

Return estimate of transaction.

func (*Api) Events

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

Returns events at given height.

func (*Api) EventsAtHeight

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

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

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

Returns the result of raw tx.

func (*Api) SendTransaction

func (a *Api) SendTransaction(transaction transaction.SignedTransaction) (*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

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

Returns list of active validators.

func (*Api) ValidatorsPage

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

Returns list of active validators with custom paging.

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          string `json:"coin_to_buy"`
	ValueToBuy         string `json:"value_to_buy"`
	CoinToSell         string `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     string `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 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 {
	Name           string `json:"name"`
	Symbol         string `json:"symbol"`
	Volume         string `json:"volume"`
	Crr            string `json:"crr"`
	ReserveBalance string `json:"reserve_balance"`
}

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       string `json:"coin"`
	Stake      string `json:"stake"`
}

type DelegateData

type DelegateData struct {
	PubKey string `json:"pub_key"`
	Coin   string `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

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

type EstimateCoinSellAllResult

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

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

func (*Event) ValueStruct

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

type ResponseError struct {
	*resty.Response
}

func NewResponseError

func NewResponseError(response *resty.Response) *ResponseError

func (*ResponseError) Error

func (res *ResponseError) Error() string

type RewardEventValue

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        string `json:"coin_to_sell"`
	CoinToBuy         string `json:"coin_to_buy"`
	MinimumValueToBuy string `json:"minimum_value_to_buy"`
}

type SellCoinData

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

type SendData

type SendData struct {
	Coin  string `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

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     string          `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"`
		TxCoin            string `json:"tx.coin,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

func (t *TransactionResult) ErrorLog() error

func (*TransactionResult) IsValid

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   string `json:"coin"`
	Value  string `json:"value"`
}

type UnbondEventValue

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
This package is used to call gRPC methods here https://pkg.go.dev/github.com/MinterTeam/node-grpc-gateway@v1.1.1/api_pb?tab=doc.
This package is used to call gRPC methods here https://pkg.go.dev/github.com/MinterTeam/node-grpc-gateway@v1.1.1/api_pb?tab=doc.

Jump to

Keyboard shortcuts

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