Documentation
¶
Overview ¶
Package http_client is the interface for uses API v2 methods.
Example ¶
package main import ( "context" "fmt" "github.com/MinterTeam/minter-go-sdk/v2/api/http_client" "github.com/MinterTeam/minter-go-sdk/v2/api/http_client/models" "github.com/MinterTeam/minter-go-sdk/v2/transaction" "github.com/MinterTeam/minter-go-sdk/v2/wallet" "io" "math/big" "strings" ) func main() { client, _ := http_client.NewConcise("http://localhost:8843/v2") coinID, _ := client.CoinID("SYMBOL") w, _ := wallet.Create("1 2 3 4 5 6 7 8 9 10 11 12", "") data := transaction.NewSendData().SetCoin(coinID).SetValue(big.NewInt(1)).MustSetTo(w.Address) transactionsBuilder := transaction.NewBuilder(transaction.TestNetChainID) tx, _ := transactionsBuilder.NewTransaction(data) sign, _ := tx.SetNonce(1).SetGasPrice(1).Sign(w.PrivateKey) encode, _ := sign.Encode() hash, _ := sign.Hash() subscribeClient, _ := client.Subscribe(context.Background(), fmt.Sprintf("tx.hash = '%s'", strings.ToUpper(hash[2:]))) defer subscribeClient.CloseSend() res, _ := client.SendTransaction(encode) if res.Code != 0 { panic(res.Log) } _, err := subscribeClient.Recv() if err == io.EOF { return } if err == context.Canceled || err == context.DeadlineExceeded { return } if err != nil { panic(err) } response, _ := client.Transaction(hash) sendData := new(models.SendData) _ = response.Data.UnmarshalTo(sendData) }
Output:
Index ¶
- func ErrorBody(err error) (int, *models.ErrorBody, error)
- type Client
- type Concise
- func (c *Concise) Address(address string, optionalHeight ...uint64) (*models.AddressResponse, error)
- func (c *Concise) AddressExtended(address string, delegated bool, optionalHeight ...uint64) (*models.AddressResponse, error)
- func (c *Concise) Addresses(addresses []string, optionalHeight ...uint64) (*models.AddressesResponse, error)
- func (c *Concise) AddressesExtended(addresses []string, delegated bool, optionalHeight ...uint64) (*models.AddressesResponse, error)
- func (c *Concise) Block(height uint64) (*models.BlockResponse, error)
- func (c *Concise) Candidate(publicKey string, optionalHeight ...uint64) (*models.CandidateResponse, error)
- func (c *Concise) CandidateExtended(publicKey string, notShowStakes bool, optionalHeight ...uint64) (*models.CandidateResponse, error)
- func (c *Concise) Candidates(includeStakes bool, status string, optionalHeight ...uint64) (*models.CandidatesResponse, error)
- func (c *Concise) CandidatesExtended(includeStakes, notShowStakes bool, status string, optionalHeight ...uint64) (*models.CandidatesResponse, error)
- func (c *Concise) CoinID(symbol string, optionalHeight ...uint64) (uint64, error)
- func (c *Concise) CoinInfo(symbol string, optionalHeight ...uint64) (*models.CoinInfoResponse, error)
- func (c *Concise) CoinInfoByID(id uint64, optionalHeight ...uint64) (*models.CoinInfoResponse, error)
- func (c *Concise) EstimateCoinIDBuy(coinToSell, coinToBuy uint64, valueToBuy string, optionalHeight ...uint64) (*models.EstimateCoinBuyResponse, error)
- func (c *Concise) EstimateCoinIDSell(coinToBuy, coinToSell uint64, valueToSell string, optionalHeight ...uint64) (*models.EstimateCoinSellResponse, error)
- func (c *Concise) EstimateCoinIDSellAll(coinToBuy, coinToSell, gasPrice uint64, valueToSell string, ...) (*models.EstimateCoinSellAllResponse, error)
- func (c *Concise) EstimateCoinSymbolBuy(coinToSell, coinToBuy, valueToBuy string, optionalHeight ...uint64) (*models.EstimateCoinBuyResponse, error)
- func (c *Concise) EstimateCoinSymbolSell(coinToBuy, coinToSell, valueToSell string, optionalHeight ...uint64) (*models.EstimateCoinSellResponse, error)
- func (c *Concise) EstimateCoinSymbolSellAll(coinToBuy, coinToSell string, gasPrice uint64, valueToSell string, ...) (*models.EstimateCoinSellAllResponse, error)
- func (c *Concise) EstimateTxCommission(tx string, optionalHeight ...uint64) (*models.EstimateTxCommissionResponse, error)
- func (c *Concise) Events(height uint64, search ...string) (*models.EventsResponse, error)
- func (c *Concise) Frozen(address string, optionalCoinID ...uint64) (*models.FrozenResponse, error)
- func (c *Concise) Genesis() (*models.GenesisResponse, error)
- func (c *Concise) Halts(height uint64) (*models.HaltsResponse, error)
- func (c *Concise) MaxGasPrice(optionalHeight ...uint64) (*models.MaxGasPriceResponse, error)
- func (c *Concise) MinGasPrice() (*models.MinGasPriceResponse, error)
- func (c *Concise) MissedBlocks(publicKey string, optionalHeight ...uint64) (*models.MissedBlocksResponse, error)
- func (c *Concise) NetInfo() (*models.NetInfoResponse, error)
- func (c *Concise) Nonce(address string, optionalHeight ...uint64) (uint64, error)
- func (c *Concise) SendTransaction(tx string) (*models.SendTransactionResponse, error)
- func (c *Concise) Status() (*models.StatusResponse, error)
- func (c *Concise) Subscribe(ctx context.Context, query string) (*SubscriberClient, error)
- func (c *Concise) Transaction(hash string) (*models.TransactionResponse, error)
- func (c *Concise) Transactions(query string, page, perPage int32) (*models.TransactionsResponse, error)
- func (c *Concise) UnconfirmedTxs(limit int32) (*models.UnconfirmedTxsResponse, error)
- func (c *Concise) Validators(optionalHeight ...uint64) (*models.ValidatorsResponse, error)
- func (c *Concise) WaitList(publicKey, address string, optionalHeight ...uint64) (*models.WaitListResponse, error)
- func (c *Concise) WithContextFunc(contextFunc func(context.Context) func() context.Context) *Concise
- func (c *Concise) WithDebug(debug bool) *Concise
- func (c *Concise) WithHeaders(headers map[string][]string) *Concise
- func (c *Concise) WithLogger(logger logger.Logger) *Concise
- func (c *Concise) WithTimeout(timeout time.Duration) *Concise
- type SubscriberClient
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
api_service.ClientService
}
Client is go-swagger HTTP client
type Concise ¶ added in v2.0.1
type Concise struct { api_service.ClientService // contains filtered or unexported fields }
Concise http concise HTTP client, with wrapper over go-swagger Client methods
func NewConcise ¶ added in v2.0.1
NewConcise returns concise HTTP client, with wrapper over go-swagger methods
func (*Concise) Address ¶ added in v2.0.1
func (c *Concise) Address(address string, optionalHeight ...uint64) (*models.AddressResponse, error)
Address returns coins list, balance and transaction count of an address.
func (*Concise) AddressExtended ¶ added in v2.1.0
func (c *Concise) AddressExtended(address string, delegated bool, optionalHeight ...uint64) (*models.AddressResponse, error)
AddressExtended returns coins list with bipValue, balance, delegated and transaction count of an address.
func (*Concise) Addresses ¶ added in v2.0.1
func (c *Concise) Addresses(addresses []string, optionalHeight ...uint64) (*models.AddressesResponse, error)
Addresses returns list of addresses.
func (*Concise) AddressesExtended ¶ added in v2.1.0
func (c *Concise) AddressesExtended(addresses []string, delegated bool, optionalHeight ...uint64) (*models.AddressesResponse, error)
AddressesExtended returns list of addresses with bipValue and delegated.
func (*Concise) Block ¶ added in v2.0.1
func (c *Concise) Block(height uint64) (*models.BlockResponse, error)
Block returns block data at given height.
func (*Concise) Candidate ¶ added in v2.0.1
func (c *Concise) Candidate(publicKey string, optionalHeight ...uint64) (*models.CandidateResponse, error)
Candidate returns candidate’s res by provided public_key.
func (*Concise) CandidateExtended ¶ added in v2.1.0
func (c *Concise) CandidateExtended(publicKey string, notShowStakes bool, optionalHeight ...uint64) (*models.CandidateResponse, error)
CandidateExtended returns candidate’s res by provided public_key.
func (*Concise) Candidates ¶ added in v2.0.1
func (c *Concise) Candidates(includeStakes bool, status string, optionalHeight ...uint64) (*models.CandidatesResponse, error)
Candidates returns list of candidates.
func (*Concise) CandidatesExtended ¶ added in v2.1.0
func (c *Concise) CandidatesExtended(includeStakes, notShowStakes bool, status string, optionalHeight ...uint64) (*models.CandidatesResponse, error)
CandidatesExtended returns list of candidates.
func (*Concise) CoinInfo ¶ added in v2.0.1
func (c *Concise) CoinInfo(symbol string, optionalHeight ...uint64) (*models.CoinInfoResponse, error)
CoinInfo returns information about coin symbol.
func (*Concise) CoinInfoByID ¶ added in v2.0.1
func (c *Concise) CoinInfoByID(id uint64, optionalHeight ...uint64) (*models.CoinInfoResponse, error)
CoinInfoByID returns information about coin ID.
func (*Concise) EstimateCoinIDBuy ¶ added in v2.0.1
func (c *Concise) EstimateCoinIDBuy(coinToSell, coinToBuy uint64, valueToBuy string, optionalHeight ...uint64) (*models.EstimateCoinBuyResponse, error)
EstimateCoinIDBuy return estimate of buy coin transaction.
func (*Concise) EstimateCoinIDSell ¶ added in v2.0.1
func (c *Concise) EstimateCoinIDSell(coinToBuy, coinToSell uint64, valueToSell string, optionalHeight ...uint64) (*models.EstimateCoinSellResponse, error)
EstimateCoinIDSell return estimate of sell coin transaction.
func (*Concise) EstimateCoinIDSellAll ¶ added in v2.0.1
func (c *Concise) EstimateCoinIDSellAll(coinToBuy, coinToSell, gasPrice uint64, valueToSell string, optionalHeight ...uint64) (*models.EstimateCoinSellAllResponse, error)
EstimateCoinIDSellAll return estimate of sell all coin transaction.
func (*Concise) EstimateCoinSymbolBuy ¶ added in v2.0.1
func (c *Concise) EstimateCoinSymbolBuy(coinToSell, coinToBuy, valueToBuy string, optionalHeight ...uint64) (*models.EstimateCoinBuyResponse, error)
EstimateCoinSymbolBuy return estimate of buy coin transaction.
func (*Concise) EstimateCoinSymbolSell ¶ added in v2.0.1
func (c *Concise) EstimateCoinSymbolSell(coinToBuy, coinToSell, valueToSell string, optionalHeight ...uint64) (*models.EstimateCoinSellResponse, error)
EstimateCoinSymbolSell return estimate of sell coin transaction.
func (*Concise) EstimateCoinSymbolSellAll ¶ added in v2.0.1
func (c *Concise) EstimateCoinSymbolSellAll(coinToBuy, coinToSell string, gasPrice uint64, valueToSell string, optionalHeight ...uint64) (*models.EstimateCoinSellAllResponse, error)
EstimateCoinSymbolSellAll return estimate of sell all coin transaction.
func (*Concise) EstimateTxCommission ¶ added in v2.0.1
func (c *Concise) EstimateTxCommission(tx string, optionalHeight ...uint64) (*models.EstimateTxCommissionResponse, error)
EstimateTxCommission return estimate of encoding transaction.
func (*Concise) Genesis ¶ added in v2.0.1
func (c *Concise) Genesis() (*models.GenesisResponse, error)
Genesis returns genesis file.
func (*Concise) Halts ¶ added in v2.0.1
func (c *Concise) Halts(height uint64) (*models.HaltsResponse, error)
Halts returns the candidate votes for stopping the network at block.
func (*Concise) MaxGasPrice ¶ added in v2.0.1
func (c *Concise) MaxGasPrice(optionalHeight ...uint64) (*models.MaxGasPriceResponse, error)
MaxGasPrice returns current max gas.
func (*Concise) MinGasPrice ¶ added in v2.0.1
func (c *Concise) MinGasPrice() (*models.MinGasPriceResponse, error)
MinGasPrice returns current min gas price.
func (*Concise) MissedBlocks ¶ added in v2.0.1
func (c *Concise) MissedBlocks(publicKey string, optionalHeight ...uint64) (*models.MissedBlocksResponse, error)
MissedBlocks returns missed blocks by validator public key.
func (*Concise) NetInfo ¶ added in v2.0.1
func (c *Concise) NetInfo() (*models.NetInfoResponse, error)
NetInfo returns network res
func (*Concise) Nonce ¶ added in v2.0.1
Nonce returns next transaction number (nonce) of an address.
func (*Concise) SendTransaction ¶ added in v2.0.1
func (c *Concise) SendTransaction(tx string) (*models.SendTransactionResponse, error)
SendTransaction returns the result of sending signed 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 (*Concise) Status ¶ added in v2.0.1
func (c *Concise) Status() (*models.StatusResponse, error)
Status returns node status including pubkey, latest block.
func (*Concise) Transaction ¶ added in v2.0.1
func (c *Concise) Transaction(hash string) (*models.TransactionResponse, error)
Transaction returns transaction res.
func (*Concise) Transactions ¶ added in v2.0.1
func (c *Concise) Transactions(query string, page, perPage int32) (*models.TransactionsResponse, error)
Transactions returns transactions by query.
func (*Concise) UnconfirmedTxs ¶ added in v2.0.1
func (c *Concise) UnconfirmedTxs(limit int32) (*models.UnconfirmedTxsResponse, error)
UnconfirmedTxs returns unconfirmed transactions.
func (*Concise) Validators ¶ added in v2.0.1
func (c *Concise) Validators(optionalHeight ...uint64) (*models.ValidatorsResponse, error)
Validators returns list of active validators.
func (*Concise) WaitList ¶ added in v2.0.1
func (c *Concise) WaitList(publicKey, address string, optionalHeight ...uint64) (*models.WaitListResponse, error)
WaitList returns the list of address stakes in waitlist.
func (*Concise) WithContextFunc ¶ added in v2.0.2
func (c *Concise) WithContextFunc(contextFunc func(context.Context) func() context.Context) *Concise
WithContextFunc returns new Concise client with new context Example:
timeout := func(c context.Context) func() context.Context { return func() context.Context { ctx, _ := context.WithTimeout(c, 10*time.Second) return ctx } }
func (*Concise) WithHeaders ¶ added in v2.1.0
WithHeaders returns copy of Concise with custom headers.
func (*Concise) WithLogger ¶ added in v2.1.0
WithLogger returns copy of Concise with custom logger.
type SubscriberClient ¶
type SubscriberClient struct {
// contains filtered or unexported fields
}
SubscriberClient is subscriber
func (*SubscriberClient) CloseSend ¶
func (s *SubscriberClient) CloseSend() error
CloseSend closes the send direction of the stream.
func (*SubscriberClient) Recv ¶
func (s *SubscriberClient) Recv() (*api_service.SubscribeOKBody, error)
Recv returns message SubscribeOKBody.