Documentation ¶
Index ¶
- Variables
- func NewCliFlags() []cli.Flag
- type CachedClient
- type Client
- func (c *Client) FromWei(address common.Address, amount *big.Int) (float64, error)
- func (c *Client) GetActiveTokens() ([]Token, error)
- func (c *Client) GetInternalTokens() ([]Token, error)
- func (c *Client) ToWei(address common.Address, amount float64) (*big.Int, error)
- func (c *Client) Tokens() ([]Token, error)
- type Interface
- type MockClient
- func (mc *MockClient) FromWei(_ common.Address, _ *big.Int) (float64, error)
- func (mc *MockClient) GetActiveTokens() ([]Token, error)
- func (mc *MockClient) GetInternalTokens() ([]Token, error)
- func (mc *MockClient) ToWei(_ common.Address, _ float64) (*big.Int, error)
- func (mc *MockClient) Tokens() ([]Token, error)
- type Token
Constants ¶
This section is empty.
Variables ¶
var ETHToken = Token{
ID: "ETH",
Name: "Ethereum",
Address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
Decimals: 18,
}
ETHToken is the configuration of Ethereum, will never be changed.
Functions ¶
func NewCliFlags ¶
NewCliFlags returns cli flags to configure a core client.
Types ¶
type CachedClient ¶
type CachedClient struct { *Client // contains filtered or unexported fields }
CachedClient is the wrapper of Core Client with caching ability.
func NewCachedClient ¶
func NewCachedClient(client *Client) *CachedClient
NewCachedClient creates a new core client instance.
func (*CachedClient) FromWei ¶
FromWei formats the given amount in wei to human friendly number with preconfigured token decimals.
func (*CachedClient) Tokens ¶
func (cc *CachedClient) Tokens() ([]Token, error)
Tokens purges the current cached tokens and fetching from Core server.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the the real implementation of core client interface.
func NewClient ¶
func NewClient(sugar *zap.SugaredLogger, url, signingKey string) (*Client, error)
NewClient creates a new core client instance.
func NewClientFromContext ¶
NewClientFromContext returns new core client from cli flags.
func (*Client) FromWei ¶
FromWei formats the given amount in wei to human friendly number with preconfigured token decimals.
func (*Client) GetActiveTokens ¶
GetActiveTokens return list of active token from external reserve
func (*Client) GetInternalTokens ¶
GetInternalTokens return list of internal token from Kyber reserve
func (*Client) Tokens ¶
Tokens returns all configured tokens. Example response JSON:
{ "data": { "tokens": { "tokens": [ { "id": "ABT", "name": "ArcBlock", "address": "0xb98d4c97425d9908e66e53a6fdf673acca0be986", "decimals": 18, "active": true, "internal": true, "last_activation_change": 1535021910190 }, { "id": "ADX", "name": "AdEx", "address": "0x4470BB87d77b963A013DB939BE332f927f2b992e", "decimals": 4, "active": true, "internal": false, "last_activation_change": 1535021910195 } ] } } }
type Interface ¶
type Interface interface { Tokens() ([]Token, error) FromWei(common.Address, *big.Int) (float64, error) ToWei(common.Address, float64) (*big.Int, error) }
Interface represents a client o interact with KyberNetwork core APIs.
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a simple mock client sending mock token from Core
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient creates a new instance of MockClient, that implements core.Interface, intended to use in tests.
func (*MockClient) FromWei ¶
FromWei formats the given amount in wei to human friendly number with preconfigured token decimals.
func (*MockClient) GetActiveTokens ¶
func (mc *MockClient) GetActiveTokens() ([]Token, error)
GetActiveTokens return list of Active Tokens from core
func (*MockClient) GetInternalTokens ¶
func (mc *MockClient) GetInternalTokens() ([]Token, error)
GetInternalTokens returns list of Internal Token from core
func (*MockClient) Tokens ¶
func (mc *MockClient) Tokens() ([]Token, error)
Tokens returns all tokens of MockClient.
type Token ¶
type Token struct { ID string `json:"id"` Name string `json:"name"` Address string `json:"address"` Decimals int64 `json:"decimals"` }
Token is a ERC20 token allowed to trade in core. Note: all fields below are valid, uncomment when needed.
func LookupToken ¶
LookupToken returns the token with given id from results of Tokens of given core client.