resources

package
v0.0.0-...-bd92ab4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainTypeEVM          = ChainType(types.NetworkType_EVM)
	ChainTypeSolana       = ChainType(types.NetworkType_Solana)
	ChainTypeNearProtocol = ChainType(types.NetworkType_Near)
	ChainTypeOther        = ChainType(types.NetworkType_Other)
)

Variables

This section is empty.

Functions

func SupportedChainKinds

func SupportedChainKinds() []interface{}

func SupportedChainKindsText

func SupportedChainKindsText() []string

func SupportedChainTypes

func SupportedChainTypes() []interface{}

func SupportedChainTypesText

func SupportedChainTypesText() []string

Types

type Balance

type Balance struct {
	Key
	Attributes    BalanceAttributes    `json:"attributes"`
	Relationships BalanceRelationships `json:"relationships"`
}

type BalanceAttributes

type BalanceAttributes struct {
	Amount string `json:"amount"`
}

type BalanceListResponse

type BalanceListResponse struct {
	Data     []Balance       `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*BalanceListResponse) GetMeta

func (r *BalanceListResponse) GetMeta(out interface{}) error

func (*BalanceListResponse) PutMeta

func (r *BalanceListResponse) PutMeta(v interface{}) (err error)

type BalanceRelationships

type BalanceRelationships struct {
	Chain Relation `json:"chain"`
	Owner Relation `json:"owner"`
	Token Relation `json:"token"`
}

type BalanceResponse

type BalanceResponse struct {
	Data     Balance         `json:"data"`
	Included Included        `json:"included"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*BalanceResponse) GetMeta

func (r *BalanceResponse) GetMeta(out interface{}) error

func (*BalanceResponse) PutMeta

func (r *BalanceResponse) PutMeta(v interface{}) (err error)

type Chain

type Chain struct {
	Key
	Attributes ChainAttributes `json:"attributes"`
}

type ChainAttributes

type ChainAttributes struct {
	ExplorerUrl string `json:"explorer_url"`
	Icon        string `json:"icon"`
	// The kind of the chain
	Kind                ChainKind       `json:"kind"`
	Name                string          `json:"name"`
	NativeToken         NativeTokenInfo `json:"native_token"`
	Rpc                 string          `json:"rpc"`
	SwapContractAddress string          `json:"swap_contract_address"`
	SwapContractVersion string          `json:"swap_contract_version"`
	// The type of the chain
	Type ChainType `json:"type"`
}

type ChainKind

type ChainKind int32
const (
	ChainKindTestnet ChainKind = iota
	ChainKindMainnet
)

func (ChainKind) Int

func (t ChainKind) Int() int

func (ChainKind) MarshalJSON

func (t ChainKind) MarshalJSON() ([]byte, error)

func (ChainKind) String

func (t ChainKind) String() string

func (*ChainKind) UnmarshalJSON

func (t *ChainKind) UnmarshalJSON(b []byte) error

func (*ChainKind) UnmarshalText

func (t *ChainKind) UnmarshalText(b []byte) error

type ChainListResponse

type ChainListResponse struct {
	Data     []Chain         `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*ChainListResponse) GetMeta

func (r *ChainListResponse) GetMeta(out interface{}) error

func (*ChainListResponse) PutMeta

func (r *ChainListResponse) PutMeta(v interface{}) (err error)

type ChainResponse

type ChainResponse struct {
	Data     Chain           `json:"data"`
	Included Included        `json:"included"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*ChainResponse) GetMeta

func (r *ChainResponse) GetMeta(out interface{}) error

func (*ChainResponse) PutMeta

func (r *ChainResponse) PutMeta(v interface{}) (err error)

type ChainType

type ChainType types.NetworkType

func (ChainType) Int

func (t ChainType) Int() int

func (ChainType) MarshalJSON

func (t ChainType) MarshalJSON() ([]byte, error)

func (ChainType) String

func (t ChainType) String() string

func (*ChainType) UnmarshalJSON

func (t *ChainType) UnmarshalJSON(b []byte) error

func (*ChainType) UnmarshalText

func (t *ChainType) UnmarshalText(b []byte) error

type Details

type Details json.RawMessage

func (Details) MarshalJSON

func (d Details) MarshalJSON() ([]byte, error)

MarshalJSON - casts Details to []byte

func (*Details) Scan

func (r *Details) Scan(src interface{}) error

Scan - implements db driver method for auto unmarshal

func (Details) String

func (d Details) String() string

func (*Details) UnmarshalJSON

func (d *Details) UnmarshalJSON(data []byte) error

UnmarshalJSON - casts data to Details

func (Details) Value

func (r Details) Value() (driver.Value, error)

Value - implements db driver method for auto marshal

type Flag

type Flag struct {
	Name  string `json:"name"`
	Value int32  `json:"value"`
}

type Flagger

type Flagger interface {
	IsFlag() bool
}

type Flags

type Flags struct {
	Mask   int32  `json:"mask"`
	Values []Flag `json:"flags"`
}

func FlagsFromMask

func FlagsFromMask(mask int32, allFlags map[int32]string) Flags

type Included

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

Included - an array of Resource objects that are related to the primary data and/or each other (“included resources”).

func (*Included) Add

func (c *Included) Add(includes ...Resource)

Add - adds new include into collection. If one already present - skips it

func (Included) MarshalJSON

func (c Included) MarshalJSON() ([]byte, error)

MarshalJSON - marshals include collection as array of json objects

func (*Included) MustBalance

func (c *Included) MustBalance(key Key) *Balance

MustBalance - returns Balance from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustChain

func (c *Included) MustChain(key Key) *Chain

MustChain - returns Chain from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustToken

func (c *Included) MustToken(key Key) *Token

MustToken - returns Token from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) UnmarshalJSON

func (c *Included) UnmarshalJSON(data []byte) error

UmarshalJSON - unmarshal array of json objects into include collection

type Key

type Key struct {
	ID   string       `json:"id"`
	Type ResourceType `json:"type"`
}

func NewKeyInt64

func NewKeyInt64(id int64, resourceType ResourceType) Key

func (Key) AsRelation

func (r Key) AsRelation() *Relation

func (*Key) GetKey

func (r *Key) GetKey() Key

func (Key) GetKeyP

func (r Key) GetKeyP() *Key
type Links struct {
	First string `json:"first,omitempty"`
	Last  string `json:"last,omitempty"`
	Next  string `json:"next,omitempty"`
	Prev  string `json:"prev,omitempty"`
	Self  string `json:"self,omitempty"`
}

type NativeTokenInfo

type NativeTokenInfo struct {
	// The number of decimals the token uses - e.g. 18, means to divide the token amount by 1000000000000000000 to get its user representation.
	Decimals int64 `json:"decimals"`
	// The name of the token.
	Name string `json:"name"`
	// The symbol of the token.
	Symbol string `json:"symbol"`
}

type Relation

type Relation struct {
	Data  *Key   `json:"data,omitempty"`
	Links *Links `json:"links,omitempty"`
}

type RelationCollection

type RelationCollection struct {
	Data  []Key  `json:"data"`
	Links *Links `json:"links,omitempty"`
}

func (RelationCollection) MarshalJSON

func (r RelationCollection) MarshalJSON() ([]byte, error)

type Resource

type Resource interface {
	//GetKey - returns key of the Resource
	GetKey() Key
}

type ResourceType

type ResourceType string
const (
	ACCOUNTS ResourceType = "accounts"
	BALANCES ResourceType = "balances"
	CHAINS   ResourceType = "chains"
	TOKENS   ResourceType = "tokens"
)

List of ResourceType

type Token

type Token struct {
	Key
	Attributes TokenAttributes `json:"attributes"`
}

type TokenAttributes

type TokenAttributes struct {
	Decimals int64  `json:"decimals"`
	LogoUri  string `json:"logo_uri"`
	Name     string `json:"name"`
	Native   *bool  `json:"native,omitempty"`
	Symbol   string `json:"symbol"`
}

type TokenListResponse

type TokenListResponse struct {
	Data     []Token         `json:"data"`
	Included Included        `json:"included"`
	Links    *Links          `json:"links"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*TokenListResponse) GetMeta

func (r *TokenListResponse) GetMeta(out interface{}) error

func (*TokenListResponse) PutMeta

func (r *TokenListResponse) PutMeta(v interface{}) (err error)

type TokenResponse

type TokenResponse struct {
	Data     Token           `json:"data"`
	Included Included        `json:"included"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (*TokenResponse) GetMeta

func (r *TokenResponse) GetMeta(out interface{}) error

func (*TokenResponse) PutMeta

func (r *TokenResponse) PutMeta(v interface{}) (err error)

Jump to

Keyboard shortcuts

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