sdk

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2019 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block interface {
	Number() uint64
	Timestamp() uint64
	GetTransactions() []Transaction

	Hash() string
	ParentHash() string
}

type BlockChain

type BlockChain interface {
	GetTokenBalance(tokenAddress, address string) decimal.Decimal
	GetTokenAllowance(tokenAddress, proxyAddress, address string) decimal.Decimal
	GetHotFeeDiscount(address string) decimal.Decimal

	GetBlockNumber() (uint64, error)
	GetBlockByNumber(blockNumber uint64) (Block, error)

	GetTransaction(ID string) (Transaction, error)
	GetTransactionReceipt(ID string) (TransactionReceipt, error)
	GetTransactionAndReceipt(ID string) (Transaction, TransactionReceipt, error)

	IsValidSignature(address string, message string, signature string) (bool, error)

	SendTransaction(to string, amount *big.Int, data []byte, privateKey *ecdsa.PrivateKey) (transactionHash string, err error)
	SendRawTransaction(tx interface{}) (string, error)

	// from orderbook protocol
	GetOrderbook(pairName, orderID string) []byte
	ProcessOrderbook(payload map[string]string) []byte
	CancelOrderbook(payload map[string]string) bool
	BestAskList(pairName string) []byte
	BestBidList(pairName string) []byte
}

type IReceiptLog

type IReceiptLog interface {
	GetRemoved() bool
	GetLogIndex() int
	GetTransactionIndex() int
	GetTransactionHash() string
	GetBlockNum() int
	GetBlockHash() string
	GetAddress() string
	GetData() string
	GetTopics() []string
}

type MockBlockchain

type MockBlockchain struct {
	BlockChain
	mock.Mock
}

func (*MockBlockchain) GetBlockByNumber

func (m *MockBlockchain) GetBlockByNumber(blockNumber uint64) (Block, error)

func (*MockBlockchain) GetBlockNumber

func (m *MockBlockchain) GetBlockNumber() (uint64, error)

func (*MockBlockchain) GetHotFeeDiscount

func (m *MockBlockchain) GetHotFeeDiscount(address string) decimal.Decimal

func (*MockBlockchain) GetTokenAllowance

func (m *MockBlockchain) GetTokenAllowance(tokenAddress, proxyAddress, address string) decimal.Decimal

func (*MockBlockchain) GetTokenBalance

func (m *MockBlockchain) GetTokenBalance(tokenAddress string, address string) decimal.Decimal

func (*MockBlockchain) GetTransaction

func (m *MockBlockchain) GetTransaction(ID string) (Transaction, error)

func (*MockBlockchain) GetTransactionAndReceipt

func (m *MockBlockchain) GetTransactionAndReceipt(ID string) (Transaction, TransactionReceipt, error)

func (*MockBlockchain) GetTransactionReceipt

func (m *MockBlockchain) GetTransactionReceipt(ID string) (TransactionReceipt, error)

func (*MockBlockchain) IsValidSignature

func (m *MockBlockchain) IsValidSignature(address string, message string, signature string) (bool, error)

func (*MockBlockchain) SendRawTransaction

func (m *MockBlockchain) SendRawTransaction(tx interface{}) (string, error)

func (*MockBlockchain) SendTransaction

func (m *MockBlockchain) SendTransaction(to string, amount *big.Int, data []byte, privateKey *ecdsa.PrivateKey) (transactionHash string, err error)

type MockNova

type MockNova struct {
	NovaProtocol
	BlockChain
}

func NewMockNova

func NewMockNova() *MockNova

type MockNovaProtocol

type MockNovaProtocol struct {
	NovaProtocol
	mock.Mock
}

func (*MockNovaProtocol) GenerateOrderData

func (m *MockNovaProtocol) GenerateOrderData(version, expiredAtSeconds, salt int64, asMakerFeeRate, asTakerFeeRate, makerRebateRate decimal.Decimal, isSell, isMarket, isMakerOnly bool) string

func (*MockNovaProtocol) GetMatchOrderCallData

func (m *MockNovaProtocol) GetMatchOrderCallData(takerOrder *Order, makerOrders []*Order, baseTokenFilledAmounts []*big.Int) []byte

func (*MockNovaProtocol) GetOrderHash

func (m *MockNovaProtocol) GetOrderHash(order *Order) []byte

type Nova

type Nova interface {
	NovaProtocol
	BlockChain
}

type NovaProtocol

type NovaProtocol interface {
	GenerateOrderData(version, expiredAtSeconds, salt int64, asMakerFeeRate, asTakerFeeRate, makerRebateRate decimal.Decimal, isSell, isMarket, isMakerOnly bool) string
	GetOrderHash(*Order) []byte
	GetMatchOrderCallData(*Order, []*Order, []*big.Int) []byte
	IsValidOrderSignature(address string, orderID string, signature string) bool
}

type Order

type Order struct {
	Trader           string
	BaseTokenAmount  *big.Int
	QuoteTokenAmount *big.Int
	GasTokenAmount   *big.Int
	Data             string
	Signature        string

	Relayer           string
	BaseTokenAddress  string
	QuoteTokenAddress string
}

func NewOrderWithData

func NewOrderWithData(
	trader, relayer, baseTokenAddress, quoteTokenAddress string,
	baseTokenAmount, quoteTokenAmount, gasTokenAddress *big.Int,
	data string,
	signature string,
) *Order

type OrderAddressSet

type OrderAddressSet struct {
	BaseToken  string `json:"baseToken"`
	QuoteToken string `json:"quoteToken"`
	Relayer    string `json:"relayer"`
}

type OrderParam

type OrderParam struct {
	Trader           string          `json:"trader"`
	BaseTokenAmount  *big.Int        `json:"base_token_amount"`
	QuoteTokenAmount *big.Int        `json:"quote_token_amount"`
	GasTokenAmount   *big.Int        `json:"gas_token_amount"`
	Data             string          `json:"data"`
	Signature        *OrderSignature `json:"signature"`
}

type OrderSignature

type OrderSignature struct {
	Config [32]byte
	R      [32]byte
	S      [32]byte
}

type Transaction

type Transaction interface {
	GetBlockHash() string
	GetBlockNumber() uint64
	GetFrom() string
	GetGas() int
	GetGasPrice() big.Int
	GetHash() string
	GetTo() string
	GetValue() big.Int
}

type TransactionReceipt

type TransactionReceipt interface {
	GetResult() bool
	GetBlockNumber() uint64

	GetBlockHash() string
	GetTxHash() string
	GetTxIndex() int

	GetLogs() []IReceiptLog
}

Directories

Path Synopsis
rlp encoding standard https://github.com/ethereum/wiki/wiki/RLP
rlp encoding standard https://github.com/ethereum/wiki/wiki/RLP

Jump to

Keyboard shortcuts

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