Documentation ¶
Index ¶
- Constants
- Variables
- func GetBody(body interface{}) (buf io.ReadWriter, err error)
- func GetValidParameter(first, second string) string
- type Amount
- type AnyAction
- type Block
- type BlockAPI
- type CoinStatus
- type Collectible
- type CollectiblePage
- type CollectiblePageV3
- type CollectibleTransfer
- type CollectibleV3
- type Collection
- type CollectionPage
- type CollectionPageV3
- type CollectionV3
- type CollectionsAPI
- type CollectionsAPIs
- type ContractCall
- type Currency
- type Delegation
- type DelegationMetaDataPending
- type DelegationResponse
- type DelegationStatus
- type DelegationType
- type DelegationsBatchPage
- type DelegationsPage
- type Direction
- type DocsResponse
- type KeyTitle
- type KeyType
- type MultiCurrencyTransfer
- type NamingServiceAPI
- type NativeTokenTransfer
- type Observer
- type Platform
- type Platforms
- type Request
- func (r *Request) Execute(method string, url string, body io.Reader, result interface{}, ...) error
- func (r *Request) Get(result interface{}, path string, query url.Values) error
- func (r *Request) GetBase(path string) string
- func (r *Request) GetWithCache(result interface{}, path string, query url.Values, cache time.Duration) error
- func (r *Request) GetWithCacheAndContext(result interface{}, path string, query url.Values, cache time.Duration, ...) error
- func (r *Request) GetWithContext(result interface{}, path string, query url.Values, ctx context.Context) error
- func (r *Request) Post(result interface{}, path string, body interface{}) error
- func (r *Request) PostWithCache(result interface{}, path string, body interface{}, cache time.Duration) error
- func (r *Request) PostWithCacheAndContext(result interface{}, path string, body interface{}, cache time.Duration, ...) error
- func (r *Request) PostWithContext(result interface{}, path string, body interface{}, ctx context.Context) error
- func (r *Request) RpcBatchCall(requests RpcRequests) ([]RpcResponse, error)
- func (r *Request) RpcBatchCallWithContext(requests RpcRequests, ctx context.Context) ([]RpcResponse, error)
- func (r *Request) RpcCall(result interface{}, method string, params interface{}) error
- func (r *Request) RpcCallWithContext(result interface{}, method string, params interface{}, ctx context.Context) error
- func (r *Request) SetTimeout(seconds time.Duration)
- type Resolved
- type ResultsResponse
- type RpcError
- type RpcRequest
- type RpcRequests
- type RpcResponse
- type StakeAPI
- type StakeValidator
- type StakeValidatorInfo
- type StakeValidators
- type StakingBatchPage
- type StakingDetails
- type StakingResponse
- type StakingReward
- type Status
- type Subscription
- type SubscriptionEvent
- type SubscriptionOperation
- type Subscriptions
- type Token
- type TokenPage
- type TokenSwap
- type TokenTransfer
- type TokenTxAPI
- type TokenType
- type TokensAPI
- type TransactionType
- type Transfer
- type Tx
- func (t *Tx) GetAddresses() []string
- func (t *Tx) GetTransactionDirection(address string) Direction
- func (t *Tx) GetUtxoAddresses() (addresses []string)
- func (t *Tx) InferUtxoValue(address string, coinIndex uint)
- func (t *Tx) MarshalJSON() ([]byte, error)
- func (t *Tx) UnmarshalJSON(data []byte) error
- type TxAPI
- type TxOutput
- type TxPage
- type TxUtxoAPI
- type Txs
- type Validator
- type ValidatorMap
- type ValidatorPage
Constants ¶
const ( DelegationStatusActive DelegationStatus = "active" DelegationStatusPending DelegationStatus = "pending" DelegationTypeAuto DelegationType = "auto" DelegationTypeDelegate DelegationType = "delegate" DefaultAnnualReward = 0 )
const ( StatusCompleted Status = "completed" StatusPending Status = "pending" StatusError Status = "error" DirectionOutgoing Direction = "outgoing" DirectionIncoming Direction = "incoming" DirectionSelf Direction = "yourself" TokenTypeERC20 TokenType = "ERC20" TokenTypeBEP2 TokenType = "BEP2" TokenTypeBEP8 TokenType = "BEP8" TokenTypeTRC10 TokenType = "TRC10" TokenTypeETC20 TokenType = "ETC20" TokenTypePOA20 TokenType = "POA20" TokenTypeTRC20 TokenType = "TRC20" TokenTypeCLO20 TokenType = "CLO20" TokenTypeGO20 TokenType = "G020" TokenTypeWAN20 TokenType = "WAN20" TokenTypeTT20 TokenType = "TT20" TxTransfer TransactionType = "transfer" TxNativeTokenTransfer TransactionType = "native_token_transfer" TxTokenTransfer TransactionType = "token_transfer" TxCollectibleTransfer TransactionType = "collectible_transfer" TxTokenSwap TransactionType = "token_swap" TxContractCall TransactionType = "contract_call" TxAnyAction TransactionType = "any_action" TxMultiCurrencyTransfer TransactionType = "multi_currency_transfer" KeyPlaceOrder KeyType = "place_order" KeyCancelOrder KeyType = "cancel_order" KeyIssueToken KeyType = "issue_token" KeyBurnToken KeyType = "burn_token" KeyMintToken KeyType = "mint_token" KeyApproveToken KeyType = "approve_token" KeyStakeDelegate KeyType = "stake_delegate" KeyStakeClaimRewards KeyType = "stake_claim_rewards" KeyTitlePlaceOrder KeyTitle = "Place Order" KeyTitleCancelOrder KeyTitle = "Cancel Order" AnyActionDelegation KeyTitle = "Delegation" AnyActionUndelegation KeyTitle = "Undelegation" AnyActionClaimRewards KeyTitle = "Claim Rewards" // TxPerPage says how many transactions to return per page TxPerPage = 25 )
const (
JsonRpcVersion = "2.0"
)
Variables ¶
var ( // ErrSourceConn signals that the connection to the source API failed ErrSourceConn = errors.New("connection to servers failed") // ErrInvalidAddr signals that the requested address is invalid ErrInvalidAddr = errors.New("invalid address") // ErrNotFound signals that the resource has not been found ErrNotFound = errors.New("not found") // ErrInvalidKey signals that the requested key is invalid ErrInvalidKey = errors.New("invalid key") )
var DefaultClient = &http.Client{ Timeout: time.Second * 15, }
Functions ¶
func GetBody ¶
func GetBody(body interface{}) (buf io.ReadWriter, err error)
func GetValidParameter ¶
Types ¶
type Amount ¶
type Amount string
Amount is a positive decimal integer string. It is written in the smallest possible unit (e.g. Wei, Satoshis)
func InferValue ¶ added in v1.1.0
func (*Amount) MarshalJSON ¶
MarshalJSON returns a JSON string representing the amount
func (*Amount) UnmarshalJSON ¶
UnmarshalJSON reads an amount from a JSON string or number. Comma separators get dropped with address.DecimalToSatoshis.
type AnyAction ¶
type AnyAction struct { Coin uint `json:"coin"` Title KeyTitle `json:"title"` Key KeyType `json:"key"` TokenID string `json:"token_id"` Name string `json:"name"` Symbol string `json:"symbol"` Decimals uint `json:"decimals"` Value Amount `json:"value"` }
AnyAction describes all other types
type BlockAPI ¶
type BlockAPI interface { Platform CurrentBlockNumber() (int64, error) GetBlockByNumber(num int64) (*Block, error) }
BlockAPI provides block information and lookups
type CoinStatus ¶
type Collectible ¶
type Collectible struct { ID string `json:"id"` CollectionID string `json:"collection_id"` TokenID string `json:"token_id"` ContractAddress string `json:"contract_address"` Category string `json:"category"` ImageUrl string `json:"image_url"` ExternalLink string `json:"external_link"` ProviderLink string `json:"provider_link"` Type string `json:"type"` Description string `json:"description"` Coin uint `json:"coin"` Name string `json:"name"` Version string `json:"nft_version"` }
type CollectiblePage ¶
type CollectiblePage []Collectible
func (CollectiblePage) MarshalJSON ¶
func (r CollectiblePage) MarshalJSON() ([]byte, error)
MarshalJSON returns a wrapped list of collectibles in JSON
type CollectiblePageV3 ¶ added in v1.1.0
type CollectiblePageV3 []CollectibleV3
func (CollectiblePageV3) MarshalJSON ¶ added in v1.1.0
func (r CollectiblePageV3) MarshalJSON() ([]byte, error)
MarshalJSON returns a wrapped list of collectibles in JSON
type CollectibleTransfer ¶
type CollectibleTransfer struct { Name string `json:"name"` Contract string `json:"contract"` ImageURL string `json:"image_url"` }
CollectibleTransfer describes the transfer of a "collectible", unique token.
type CollectibleV3 ¶ added in v1.1.0
type CollectibleV3 struct { ID string `json:"id"` CollectionID string `json:"collection_id"` TokenID string `json:"token_id"` CategoryContract string `json:"category_contract"` ContractAddress string `json:"contract_address"` Category string `json:"category"` ImageUrl string `json:"image_url"` ExternalLink string `json:"external_link"` ProviderLink string `json:"provider_link"` Type string `json:"type"` Description string `json:"description"` Coin uint `json:"coin"` Name string `json:"name"` Version string `json:"nft_version"` }
type Collection ¶
type CollectionPage ¶
type CollectionPage []Collection
func (CollectionPage) MarshalJSON ¶
func (r CollectionPage) MarshalJSON() ([]byte, error)
MarshalJSON returns a wrapped list of collections in JSON
type CollectionPageV3 ¶ added in v1.1.0
type CollectionPageV3 []CollectionV3
func (CollectionPageV3) MarshalJSON ¶ added in v1.1.0
func (r CollectionPageV3) MarshalJSON() ([]byte, error)
MarshalJSON returns a wrapped list of collections in JSON
type CollectionV3 ¶ added in v1.1.0
type CollectionV3 struct { Id string `json:"id"` Name string `json:"name"` Symbol string `json:"symbol"` Slug string `json:"slug"` ImageUrl string `json:"image_url"` Description string `json:"description"` ExternalLink string `json:"external_link"` Total int `json:"total"` CategoryAddress string `json:"category_address"` Address string `json:"address"` Coin uint `json:"coin"` // Delete in the future version, as it's now part of Collectible Version string `json:"nft_version"` Type string `json:"type"` }
type CollectionsAPI ¶ added in v1.1.0
type CollectionsAPI interface { Platform GetCollections(owner string) (CollectionPage, error) GetCollectibles(owner, collectibleID string) (CollectiblePage, error) GetCollectionsV3(owner string) (CollectionPageV3, error) GetCollectiblesV3(owner, collectibleID string) (CollectiblePageV3, error) }
type CollectionsAPIs ¶ added in v1.1.0
type CollectionsAPIs map[uint]CollectionsAPI
type ContractCall ¶
ContractCall describes a
type Delegation ¶
type Delegation struct { Delegator StakeValidator `json:"delegator"` Value string `json:"value"` Status DelegationStatus `json:"status"` Metadata interface{} `json:"metadata,omitempty"` }
type DelegationMetaDataPending ¶
type DelegationMetaDataPending struct {
AvailableDate uint `json:"available_date"`
}
type DelegationResponse ¶
type DelegationResponse struct { Delegations DelegationsPage `json:"delegations"` Balance string `json:"balance"` Address string `json:"address"` StakingResponse }
type DelegationStatus ¶
type DelegationStatus string
type DelegationType ¶
type DelegationType string
type DelegationsBatchPage ¶
type DelegationsBatchPage []DelegationResponse
type DelegationsPage ¶
type DelegationsPage []Delegation
type DocsResponse ¶
type DocsResponse struct {
Docs interface{} `json:"docs"`
}
type MultiCurrencyTransfer ¶
type MultiCurrencyTransfer struct { Currencies []Currency `json:"currencies"` Fees []Currency `json:"fees"` }
MultiCurrencyTransfer describes the transfer of multiple currency native to the platform
type NamingServiceAPI ¶
type NativeTokenTransfer ¶
type NativeTokenTransfer struct { Name string `json:"name"` Symbol string `json:"symbol"` TokenID string `json:"token_id"` Decimals uint `json:"decimals"` Value Amount `json:"value"` From string `json:"from"` To string `json:"to"` }
NativeTokenTransfer describes the transfer of native tokens. Example: Stellar Tokens, TRC10
type Platforms ¶ added in v1.1.0
func (Platforms) GetPlatformList ¶ added in v1.1.0
type Request ¶
type Request struct { BaseUrl string Headers map[string]string HttpClient *http.Client ErrorHandler func(res *http.Response, uri string) error }
func InitClient ¶
func InitJSONClient ¶ added in v1.1.0
func (*Request) GetWithCache ¶
func (*Request) GetWithCacheAndContext ¶ added in v1.1.4
func (*Request) GetWithContext ¶ added in v1.1.4
func (*Request) PostWithCache ¶
func (*Request) PostWithCacheAndContext ¶ added in v1.1.4
func (*Request) PostWithContext ¶ added in v1.1.4
func (*Request) RpcBatchCall ¶ added in v1.1.0
func (r *Request) RpcBatchCall(requests RpcRequests) ([]RpcResponse, error)
func (*Request) RpcBatchCallWithContext ¶ added in v1.1.4
func (r *Request) RpcBatchCallWithContext(requests RpcRequests, ctx context.Context) ([]RpcResponse, error)
func (*Request) RpcCallWithContext ¶ added in v1.1.4
func (*Request) SetTimeout ¶
type ResultsResponse ¶
type ResultsResponse struct { Total int `json:"total"` Results interface{} `json:"docs"` }
type RpcRequest ¶
type RpcRequests ¶ added in v1.1.0
type RpcRequests []*RpcRequest
type RpcResponse ¶
type RpcResponse struct { JsonRpc string `json:"jsonrpc"` Error *RpcError `json:"error,omitempty"` Result interface{} `json:"result,omitempty"` Id int64 `json:"id,omitempty"` }
func (*RpcResponse) GetObject ¶
func (r *RpcResponse) GetObject(toType interface{}) error
type StakeAPI ¶
type StakeAPI interface { Platform UndelegatedBalance(address string) (string, error) GetDetails() StakingDetails GetValidators() (ValidatorPage, error) GetDelegations(address string) (DelegationsPage, error) GetActiveValidators() (StakeValidators, error) }
StakingAPI provides staking information
type StakeValidator ¶
type StakeValidator struct { ID string `json:"id"` Status bool `json:"status"` Info StakeValidatorInfo `json:"info,omitempty"` Details StakingDetails `json:"details,omitempty"` }
type StakeValidatorInfo ¶
type StakeValidators ¶ added in v1.1.0
type StakeValidators []StakeValidator
func (StakeValidators) ToMap ¶ added in v1.1.0
func (sv StakeValidators) ToMap() ValidatorMap
type StakingBatchPage ¶
type StakingBatchPage []StakingResponse
type StakingDetails ¶
type StakingDetails struct { Reward StakingReward `json:"reward"` LockTime int `json:"locktime"` MinimumAmount Amount `json:"minimum_amount"` Type DelegationType `json:"type"` }
type StakingResponse ¶
type StakingResponse struct { Coin *coin.ExternalCoin `json:"coin"` Details StakingDetails `json:"details"` }
type StakingReward ¶
type StakingReward struct {
Annual float64 `json:"annual"`
}
type Subscription ¶
type SubscriptionEvent ¶ added in v1.1.0
type SubscriptionEvent struct { Subscriptions Subscriptions `json:"subscriptions"` Operation SubscriptionOperation `json:"operation"` }
func (*SubscriptionEvent) ParseSubscriptions ¶ added in v1.1.0
func (e *SubscriptionEvent) ParseSubscriptions(s Subscriptions) []Subscription
type SubscriptionOperation ¶ added in v1.1.0
type SubscriptionOperation string
type Subscriptions ¶ added in v1.1.0
type Token ¶
type Token struct { Name string `json:"name"` Symbol string `json:"symbol"` Decimals uint `json:"decimals"` TokenID string `json:"token_id"` Coin uint `json:"coin"` Type TokenType `json:"type"` }
Token describes the non-native tokens. Examples: ERC-20, TRC-20, BEP-2
type TokenSwap ¶
type TokenSwap struct { Input TokenTransfer `json:"input"` Output TokenTransfer `json:"output"` }
TokenSwap describes the exchange of two different tokens
type TokenTransfer ¶
type TokenTransfer struct { Name string `json:"name"` Symbol string `json:"symbol"` TokenID string `json:"token_id"` Decimals uint `json:"decimals"` Value Amount `json:"value"` From string `json:"from"` To string `json:"to"` }
TokenTransfer describes the transfer of non-native tokens. Examples: ERC-20, TRC20
type TokenTxAPI ¶
TokenTxAPI provides token transaction lookups
type TransactionType ¶
type TransactionType string
type Transfer ¶
type Transfer struct { Value Amount `json:"value"` Symbol string `json:"symbol"` Decimals uint `json:"decimals"` }
Transfer describes the transfer of currency native to the platform
type Tx ¶
type Tx struct { // Unique identifier ID string `json:"id"` // SLIP-44 coin index of the platform Coin uint `json:"coin"` // Address of the transaction sender From string `json:"from"` // Address of the transaction recipient To string `json:"to"` // Transaction fee (native currency) Fee Amount `json:"fee"` // Unix timestamp of the block the transaction was included in Date int64 `json:"date"` // Height of the block the transaction was included in Block uint64 `json:"block"` // Status of the transaction e.g: "completed", "pending", "error" Status Status `json:"status"` // Empty if the transaction "completed" or "pending", else error explaining why the transaction failed (optional) Error string `json:"error,omitempty"` // Transaction nonce or sequence Sequence uint64 `json:"sequence"` // Type of metadata Type TransactionType `json:"type"` // Input addresses Inputs []TxOutput `json:"inputs,omitempty"` // Output addresses Outputs []TxOutput `json:"outputs,omitempty"` // Transaction Direction Direction Direction `json:"direction,omitempty"` // Meta data object Memo string `json:"memo"` Meta interface{} `json:"metadata"` }
Tx describes an on-chain transaction generically
func (*Tx) GetAddresses ¶
func (*Tx) GetTransactionDirection ¶ added in v1.1.0
func (*Tx) GetUtxoAddresses ¶
func (*Tx) InferUtxoValue ¶ added in v1.1.0
func (*Tx) MarshalJSON ¶
MarshalJSON creates a JSON object from a transaction. Sets the Type field to the currect value based on the Meta type.
func (*Tx) UnmarshalJSON ¶
UnmarshalJSON creates a transaction along with metadata from a JSON object. Fails if the meta object can't be read.
type TxPage ¶
type TxPage []Tx
TxPage is a page of transactions
func (*TxPage) MarshalJSON ¶
MarshalJSON returns a wrapped list of transactions in JSON
type TxUtxoAPI ¶ added in v1.1.0
TxUtxoAPI provides transaction lookup based on address and XPUB (Bitcoin-style)
type Txs ¶ added in v1.1.0
type Txs []Tx
func (Txs) FilterUniqueID ¶ added in v1.1.0
func (Txs) SortByDate ¶ added in v1.1.0
type Validator ¶
type Validator struct { ID string `json:"id"` Status bool `json:"status"` Details StakingDetails `json:"details"` }
type ValidatorMap ¶
type ValidatorMap map[string]StakeValidator
type ValidatorPage ¶
type ValidatorPage []Validator