Documentation
¶
Index ¶
- Variables
- func EncodeToken(token TokenItem) ([]byte, error)
- func EncodeTokens(tokens TokenItems) ([]byte, error)
- type Asset
- type AssetService
- type AssetStore
- type Factory
- type Fee
- type Order
- type OrderState
- type OrderStore
- type Session
- type Snapshot
- type System
- type TokenItem
- type TokenItems
- type TokenRequest
- type TokenRequests
- type TokenType
- type Transaction
- type TransactionState
- type TransactionStore
- type Transfer
- type TransferPriority
- type User
- type UserService
- type WalletService
- type WalletStore
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrAssetNotExist = errors.New("asset not exist")
)
View Source
var (
ErrInvalidTrace = errors.New("invalid trace")
)
Functions ¶
func EncodeToken ¶
func EncodeTokens ¶
func EncodeTokens(tokens TokenItems) ([]byte, error)
Types ¶
type Asset ¶ added in v0.1.8
type Asset struct {
ID uint64 `sql:"PRIMARY_KEY;" json:"id"`
AssetID string `sql:"size:36;" json:"asset_id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Version int64 `sql:"not null" json:"version,omitempty"`
Verified bool `json:"verified"`
Name string `sql:"size:64" json:"name,omitempty"`
Symbol string `sql:"size:32" json:"symbol,omitempty"`
Logo string `sql:"size:256" json:"logo,omitempty"`
DisplaySymbol string `sql:"size:32;default:null;" json:"display_symbol,omitempty"`
ChainID string `sql:"size:36" json:"chain_id,omitempty"`
Price decimal.Decimal `sql:"type:decimal(32,8);default:0" json:"price,omitempty"`
PriceUpdatedAt *time.Time `sql:"default:null" json:"price_updated_at,omitempty"`
}
type AssetService ¶ added in v0.1.8
AssetService provides access to assets information in the remote system like mixin network.
type AssetStore ¶ added in v0.1.8
type AssetStore interface {
Save(ctx context.Context, asset *Asset) error
Find(ctx context.Context, assetIDs ...string) ([]*Asset, error)
ListAll(ctx context.Context) ([]*Asset, error)
}
AssetStore defines operations for working with assets on db.
type Factory ¶
type Factory interface {
Platform() string
GasAsset() string
CreateTransaction(ctx context.Context, tokens TokenItems, trace string) (*Transaction, error)
SendTransaction(ctx context.Context, tx *Transaction) error
ReadTransaction(ctx context.Context, hash string) (*Transaction, error)
}
type Order ¶
type Order struct {
ID uint64 `sql:"PRIMARY_KEY;" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version,omitempty"`
TraceID string `sql:"size:36;" json:"trace_id,omitempty"`
State OrderState `json:"state"`
UserID string `sql:"size:36;" json:"user_id,omitempty"`
FeeAsset string `sql:"size:36;" json:"fee_asset,omitempty"`
FeeAmount decimal.Decimal `sql:"type:decimal(64,8)" json:"fee_amount,omitempty"`
GasUsage decimal.Decimal `sql:"type:decimal(64,8)" json:"gas_usage,omitempty"`
Platform string `sql:"size:255;" json:"platform,omitempty"`
TokenRequests TokenItems `sql:"type:longtext;" json:"token_requests,omitempty"`
Tokens TokenItems `sql:"type:longtext;" json:"tokens,omitempty"`
Transaction string `sql:"size:128;" json:"transaction,omitempty"`
}
type OrderState ¶
type OrderState int
const ( OrderStateNew OrderState = iota OrderStatePaid OrderStateProcessing OrderStateFailed OrderStateDone )
type OrderStore ¶
type Snapshot ¶
type Snapshot struct {
CreatedAt time.Time `json:"created_at,omitempty"`
SnapshotID string `json:"snapshot_id,omitempty"`
UserID string `json:"user_id,omitempty"`
OpponentID string `json:"opponent_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
AssetID string `json:"asset_id,omitempty"`
Source string `json:"source,omitempty"`
Amount decimal.Decimal `json:"amount,omitempty"`
Memo string `json:"memo,omitempty"`
TransactionHash string `json:"transaction_hash,omitempty"`
}
type System ¶
type System struct {
Version string
ClientID string
ClientSecret string
Fees map[string]*Fee
WhiteList map[string]bool
}
System stores system information.
type TokenItem ¶ added in v0.1.8
type TokenItem struct {
AssetID string `json:"asset_id,omitempty"`
AssetKey string `json:"asset_key,omitempty"`
Name string `json:"name,omitempty"`
Symbol string `json:"symbol,omitempty"`
TotalSupply uint64 `json:"total_supply,omitempty"`
}
func DecodeToken ¶
func (TokenItem) MarshalBinary ¶ added in v0.1.8
func (*TokenItem) UnmarshalBinary ¶ added in v0.1.8
type TokenItems ¶ added in v0.1.8
type TokenItems []*TokenItem
func DecodeTokens ¶
func DecodeTokens(data []byte) TokenItems
func (TokenItems) MarshalBinary ¶ added in v0.1.8
func (t TokenItems) MarshalBinary() ([]byte, error)
func (*TokenItems) Scan ¶ added in v0.1.8
func (s *TokenItems) Scan(value interface{}) error
Scan implements the sql.Scanner interface for database deserialization.
func (*TokenItems) UnmarshalBinary ¶ added in v0.1.8
func (t *TokenItems) UnmarshalBinary(data []byte) error
type TokenRequest ¶ added in v0.1.8
type TokenRequests ¶ added in v0.1.8
type TokenRequests []*TokenRequest
func (*TokenRequests) Scan ¶ added in v0.1.8
func (s *TokenRequests) Scan(value interface{}) error
Scan implements the sql.Scanner interface for database deserialization.
type Transaction ¶
type Transaction struct {
ID uint64 `sql:"PRIMARY_KEY;" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version"`
TraceID string `sql:"size:36;" json:"trace_id,omitempty"`
Hash string `sql:"size:127;" json:"hash,omitempty"`
Raw string `sql:"type:longtext;" json:"raw,omitempty"`
State TransactionState `json:"state,omitempty"`
Tokens TokenItems `sql:"type:longtext;" json:"tokens,omitempty"`
Gas decimal.Decimal `sql:"type:decimal(64,8)" json:"gas,omitempty"`
}
type TransactionState ¶
type TransactionState int
const ( TransactionStateNew TransactionState = iota TransactionStatePending TransactionStateFailed TransactionStateSuccess )
type TransactionStore ¶
type TransactionStore interface {
Create(ctx context.Context, tx *Transaction) error
Update(ctx context.Context, tx *Transaction) error
Find(ctx context.Context, hash string) (*Transaction, error)
FindTrace(ctx context.Context, traceID string) ([]*Transaction, error)
}
type Transfer ¶
type Transfer struct {
ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"`
Priority TransferPriority `json:"priority"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
TraceID string `sql:"type:char(36)" json:"trace_id,omitempty"`
AssetID string `sql:"type:char(36)" json:"asset_id,omitempty"`
Amount decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"`
Memo string `sql:"size:200" json:"memo,omitempty"`
Threshold uint8 `json:"threshold,omitempty"`
Opponents pq.StringArray `sql:"type:varchar(1024)" json:"opponents,omitempty"`
}
type TransferPriority ¶
type TransferPriority int
const ( TransferPriorityHigh TransferPriority = iota TransferPriorityNormal TransferPriorityLow )
type UserService ¶
type WalletService ¶
Click to show internal directories.
Click to hide internal directories.