ethaccessor

package
v0.0.0-...-491e088 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USAGE_CLIENT_BLOCK = "usage_client_block_"
	BLOCKS             = "blocks_"
)
View Source
const (
	EVENT_RING_MINED           = "RingMined"
	EVENT_ORDER_CANCELLED      = "OrderCancelled"
	EVENT_CUTOFF_ALL           = "AllOrdersCancelled"
	EVENT_CUTOFF_PAIR          = "OrdersCancelled"
	EVENT_TOKEN_REGISTERED     = "TokenRegistered"
	EVENT_TOKEN_UNREGISTERED   = "TokenUnregistered"
	EVENT_ADDRESS_AUTHORIZED   = "AddressAuthorized"
	EVENT_ADDRESS_DEAUTHORIZED = "AddressDeauthorized"
	EVENT_TRANSFER             = "Transfer"
	EVENT_APPROVAL             = "Approval"
	EVENT_WETH_DEPOSIT         = "Deposit"
	EVENT_WETH_WITHDRAWAL      = "Withdrawal"
)
View Source
const (
	METHOD_UNKNOWN         = ""
	METHOD_SUBMIT_RING     = "submitRing"
	METHOD_CANCEL_ORDER    = "cancelOrder"
	METHOD_CUTOFF_ALL      = "cancelAllOrders"
	METHOD_CUTOFF_PAIR     = "cancelAllOrdersByTradingPair"
	METHOD_WETH_DEPOSIT    = "deposit"
	METHOD_WETH_WITHDRAWAL = "withdraw"
	METHOD_APPROVE         = "approve"
	METHOD_TRANSFER        = "transfer"
)

Variables

This section is empty.

Functions

func BatchCall

func BatchCall(routeParam string, reqs []BatchReq) error

func BatchErc20BalanceAndAllowance

func BatchErc20BalanceAndAllowance(routeParam string, reqs []*BatchErc20Req) error

func BatchTransactionRecipients

func BatchTransactionRecipients(reqs []*BatchTransactionRecipientReq, blockNumber string) error

func BatchTransactions

func BatchTransactions(reqs []*BatchTransactionReq, blockNumber string) error

func BlockNumber

func BlockNumber(result interface{}) error

func Call

func Call(result interface{}, ethCall *CallArg, blockNumber string) error

func ContractCallMethod

func ContractCallMethod(a *abi.ABI, contractAddress common.Address) func(result interface{}, methodName, blockParameter string, args ...interface{}) error

func ContractSendTransactionMethod

func ContractSendTransactionMethod(routeParam string, a *abi.ABI, contractAddress common.Address) func(sender common.Address, methodName string, gas, gasPrice, value *big.Int, args ...interface{}) (string, error)

func DelegateAbi

func DelegateAbi() *abi.ABI

func DelegateAddresses

func DelegateAddresses() map[common.Address]bool

func Erc20Abi

func Erc20Abi() *abi.ABI

func Erc20Allowance

func Erc20Allowance(tokenAddress, ownerAddress, spender common.Address, blockParameter string) (*big.Int, error)

func Erc20Balance

func Erc20Balance(tokenAddress, ownerAddress common.Address, blockParameter string) (*big.Int, error)

func EstimateGas

func EstimateGas(callData []byte, to common.Address, blockNumber string) (gas, gasPrice *big.Int, err error)

func EstimateGasPrice

func EstimateGasPrice(minGasPrice, maxGasPrice *big.Int) *big.Int

func GenerateSubmitRingMethodInputsData

func GenerateSubmitRingMethodInputsData(ring *types.Ring, feeReceipt common.Address, protocolAbi *abi.ABI) ([]byte, error)

func GetBalance

func GetBalance(result interface{}, address common.Address, blockNumber string) error

func GetBlockByHash

func GetBlockByHash(result types.CheckNull, blockHash string, withObject bool) error

func GetBlockByNumber

func GetBlockByNumber(result interface{}, blockNumber *big.Int, withObject bool) error

func GetBlockTransactionCountByHash

func GetBlockTransactionCountByHash(result interface{}, blockHash string, blockParameter string) error

func GetBlockTransactionCountByNumber

func GetBlockTransactionCountByNumber(result interface{}, blockNumber string) error

func GetCancelled

func GetCancelled(contractAddress common.Address, orderhash common.Hash, blockNumber string) (*big.Int, error)

func GetCancelledOrFilled

func GetCancelledOrFilled(contractAddress common.Address, orderhash common.Hash, blockNumber string) (*big.Int, error)

func GetCutoff

func GetCutoff(contractAddress, owner common.Address, blockNumber string) (*big.Int, error)

todo(fuk): 需要测试,如果没有,合约是否返回为0

func GetCutoffPair

func GetCutoffPair(contractAddress, owner, token1, token2 common.Address, blockNumber string) (*big.Int, error)

todo(fuk): 需要测试,如果没有,合约是否返回为0

func GetFullBlock

func GetFullBlock(blockNumber *big.Int, withObject bool) (interface{}, error)

func GetSpenderAddress

func GetSpenderAddress(protocolAddress common.Address) (spender common.Address, err error)

func GetTransactionByHash

func GetTransactionByHash(result types.CheckNull, txHash string, blockParameter string) error

func GetTransactionCount

func GetTransactionCount(result interface{}, address common.Address, blockNumber string) error

func GetTransactionReceipt

func GetTransactionReceipt(result interface{}, txHash string, blockParameter string) error

func IncludeGasPriceEvaluator

func IncludeGasPriceEvaluator()

func Initialize

func Initialize(accessorOptions config.AccessorOptions, commonOptions config.CommonOptions, wethAddress common.Address) error

func IsRelateProtocol

func IsRelateProtocol(protocol, delegate common.Address) bool

func IsSpenderAddress

func IsSpenderAddress(spender common.Address) bool

func NewAbi

func NewAbi(abiStr string) (*abi.ABI, error)

func ProtocolAddresses

func ProtocolAddresses() map[common.Address]*ProtocolAddress

func ProtocolImplAbi

func ProtocolImplAbi() *abi.ABI

func SendRawTransaction

func SendRawTransaction(result interface{}, tx string) error

func SignAndSendTransaction

func SignAndSendTransaction(sender common.Address, to common.Address, gas, gasPrice, value *big.Int, callData []byte, needPreExe bool) (string, error)

func SupportedDelegateAddress

func SupportedDelegateAddress(delegate common.Address) bool

func TokenRegistryAbi

func TokenRegistryAbi() *abi.ABI

func TxIsSubmitRing

func TxIsSubmitRing(methodName string) bool

func WethAbi

func WethAbi() *abi.ABI

Types

type AddressAuthorizedEvent

type AddressAuthorizedEvent struct {
	ContractAddress common.Address `fieldName:"addr" fieldId:"0"`
	Number          int            `fieldName:"number" fieldId:"1"`
}

func (*AddressAuthorizedEvent) ConvertDown

type AddressDeAuthorizedEvent

type AddressDeAuthorizedEvent struct {
	ContractAddress common.Address `fieldName:"addr" fieldId:"0"`
	Number          int            `fieldName:"number" fieldId:"1"`
}

func (*AddressDeAuthorizedEvent) ConvertDown

type AddressNonce

type AddressNonce struct {
	Address common.Address
	Nonce   *big.Int
	// contains filtered or unexported fields
}

type ApprovalEvent

type ApprovalEvent struct {
	Owner   common.Address `fieldName:"owner" fieldId:"0"`
	Spender common.Address `fieldName:"spender" fieldId:"1"`
	Value   *big.Int       `fieldName:"value" fieldId:"2"`
}

func (*ApprovalEvent) ConvertDown

func (e *ApprovalEvent) ConvertDown() *types.ApprovalEvent

type ApproveMethod

type ApproveMethod struct {
	Spender common.Address `fieldName:"spender" fieldId:"0"`
	Value   *big.Int       `fieldName:"value" fieldId:"1"`
}

func (*ApproveMethod) ConvertDown

func (e *ApproveMethod) ConvertDown() *types.ApprovalEvent

type BatchBalanceReq

type BatchBalanceReq struct {
	Owner          common.Address
	Token          common.Address
	BlockParameter string
	Balance        types.Big
	BalanceErr     error
}

type BatchBalanceReqs

type BatchBalanceReqs []*BatchBalanceReq

func (BatchBalanceReqs) FromBatchElem

func (reqs BatchBalanceReqs) FromBatchElem(elems []rpc.BatchElem)

func (BatchBalanceReqs) ToBatchElem

func (reqs BatchBalanceReqs) ToBatchElem() []rpc.BatchElem

type BatchErc20AllowanceReq

type BatchErc20AllowanceReq struct {
	Owner          common.Address
	Token          common.Address
	BlockParameter string
	Spender        common.Address
	Allowance      types.Big
	AllowanceErr   error
}

type BatchErc20AllowanceReqs

type BatchErc20AllowanceReqs []*BatchErc20AllowanceReq

func (BatchErc20AllowanceReqs) FromBatchElem

func (reqs BatchErc20AllowanceReqs) FromBatchElem(elems []rpc.BatchElem)

func (BatchErc20AllowanceReqs) ToBatchElem

func (reqs BatchErc20AllowanceReqs) ToBatchElem() []rpc.BatchElem

type BatchErc20Req

type BatchErc20Req struct {
	Owner          common.Address
	Token          common.Address
	Symbol         string
	Spender        common.Address
	BlockParameter string
	Balance        types.Big
	Allowance      types.Big
	BalanceErr     error
	AllowanceErr   error
}

type BatchReq

type BatchReq interface {
	ToBatchElem() []rpc.BatchElem
	FromBatchElem(batchElems []rpc.BatchElem)
}

type BatchTransactionRecipientReq

type BatchTransactionRecipientReq struct {
	TxHash    string
	TxContent TransactionReceipt
	Err       error
}

type BatchTransactionReq

type BatchTransactionReq struct {
	TxHash    string
	TxContent Transaction
	Err       error
}

type Block

type Block struct {
	Number           types.Big   `json:"number"`
	Hash             common.Hash `json:"hash"`
	ParentHash       common.Hash `json:"parentHash"`
	Nonce            string      `json:"nonce"`
	Sha3Uncles       string      `json:"sha3Uncles"`
	LogsBloom        string      `json:"logsBloom"`
	TransactionsRoot string      `json:"transactionsRoot"`
	ReceiptsRoot     string      `json:"stateRoot"`
	Miner            string      `json:"miner"`
	Difficulty       types.Big   `json:"difficulty"`
	TotalDifficulty  types.Big   `json:"totalDifficulty"`
	ExtraData        string      `json:"extraData"`
	Size             types.Big   `json:"size"`
	GasLimit         types.Big   `json:"gasLimit"`
	GasUsed          types.Big   `json:"gasUsed"`
	Timestamp        types.Big   `json:"timestamp"`
	Uncles           []string    `json:"uncles"`
}

func (Block) IsNull

func (block Block) IsNull() bool

type BlockIterator

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

func NewBlockIterator

func NewBlockIterator(startNumber, endNumber *big.Int, withTxData bool, confirms uint64) *BlockIterator

func (*BlockIterator) Next

func (iterator *BlockIterator) Next() (interface{}, error)

func (*BlockIterator) Prev

func (iterator *BlockIterator) Prev() (interface{}, error)

type BlockWithTxAndReceipt

type BlockWithTxAndReceipt struct {
	Block
	Transactions []Transaction        `json:"transactions"`
	Receipts     []TransactionReceipt `json:"receipts"`
}

type BlockWithTxHash

type BlockWithTxHash struct {
	Block
	Transactions []string
}

type BlockWithTxObject

type BlockWithTxObject struct {
	Block
	Transactions []Transaction
}

type CallArg

type CallArg struct {
	From     common.Address `json:"from"`
	To       common.Address `json:"to"`
	Gas      types.Big      `json:"gas"`
	GasPrice types.Big      `json:"gasPrice"`
	Value    types.Big      `json:"value"`
	Data     string         `json:"data"`
	Nonce    types.Big      `json:"nonce"`
}

type CancelOrderMethod

type CancelOrderMethod struct {
	AddressList    [5]common.Address `fieldName:"addresses" fieldId:"0"`   //  owner, tokenS, tokenB, authAddr
	OrderValues    [6]*big.Int       `fieldName:"orderValues" fieldId:"1"` //  amountS, amountB, validSince (second), validUntil (second), lrcFee, and cancelAmount
	BuyNoMoreThanB bool              `fieldName:"buyNoMoreThanAmountB" fieldId:"2"`
	MarginSplit    uint8             `fieldName:"marginSplitPercentage" fieldId:"3"`
	V              uint8             `fieldName:"v" fieldId:"4"`
	R              [32]byte          `fieldName:"r" fieldId:"5"`
	S              [32]byte          `fieldName:"s" fieldId:"6"`
}

func (*CancelOrderMethod) ConvertDown

func (m *CancelOrderMethod) ConvertDown() (*types.Order, *big.Int, error)

todo(fuk): modify internal cancelOrderMethod and implement related functions

type CutoffEvent

type CutoffEvent struct {
	Owner  common.Address `fieldName:"_address" fieldId:"0"`
	Cutoff *big.Int       `fieldName:"_cutoff" fieldId:"1"`
}

func (*CutoffEvent) ConvertDown

func (e *CutoffEvent) ConvertDown() *types.CutoffEvent

type CutoffMethod

type CutoffMethod struct {
	Cutoff *big.Int `fieldName:"cutoff" fieldId:"0"`
}

func (*CutoffMethod) ConvertDown

func (method *CutoffMethod) ConvertDown() *types.CutoffEvent

type CutoffPairEvent

type CutoffPairEvent struct {
	Owner  common.Address `fieldName:"_address" fieldId:"0"`
	Token1 common.Address `fieldName:"_token1" fieldId:"1"`
	Token2 common.Address `fieldName:"_token2" fieldId:"2"`
	Cutoff *big.Int       `fieldName:"_cutoff" fieldId:"3"`
}

func (*CutoffPairEvent) ConvertDown

func (e *CutoffPairEvent) ConvertDown() *types.CutoffPairEvent

type CutoffPairMethod

type CutoffPairMethod struct {
	Token1 common.Address `fieldName:"token1" fieldId:"0"`
	Token2 common.Address `fieldName:"token2" fieldId:"1"`
	Cutoff *big.Int       `fieldName:"cutoff" fieldId:"2"`
}

func (*CutoffPairMethod) ConvertDown

func (method *CutoffPairMethod) ConvertDown() *types.CutoffPairEvent

type FilterQuery

type FilterQuery struct {
	FromBlock string           `json:"fromBlock"`
	ToBlock   string           `json:"toBlock"`
	Address   []common.Address `json:"address"`
	Topics    [][]common.Hash  `json:"topics"`
}

type GasPriceEvaluator

type GasPriceEvaluator struct {
	Blocks []*BlockWithTxAndReceipt
	// contains filtered or unexported fields
}

func (*GasPriceEvaluator) GasPrice

func (e *GasPriceEvaluator) GasPrice(minGasPrice, maxGasPrice *big.Int) *big.Int

type Log

type Log struct {
	LogIndex         types.Big `json:"logIndex"`
	BlockNumber      types.Big `json:"blockNumber"`
	BlockHash        string    `json:"blockHash"`
	TransactionHash  string    `json:"transactionHash"`
	TransactionIndex types.Big `json:"transactionIndex"`
	Address          string    `json:"address"`
	Data             string    `json:"data"`
	Topics           []string  `json:"topics"`
	Removed          bool      `json:"removed"`
}

func (*Log) EventId

func (evtlog *Log) EventId() common.Hash

type LogParameter

type LogParameter struct {
	Topics []string
}

type MutilClient

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

func NewMutilClient

func NewMutilClient(urls []string) *MutilClient

将最近的块放入redis中,获取时,从redis中按照块号获取可用的client与本地保存做交集,然后随机选取client,请求节点

func (*MutilClient) BatchCall

func (mc *MutilClient) BatchCall(routeParam string, b []rpc.BatchElem) (node string, err error)

func (*MutilClient) BlockNumber

func (mc *MutilClient) BlockNumber(result interface{}) error

func (*MutilClient) Call

func (mc *MutilClient) Call(routeParam string, result interface{}, method string, args ...interface{}) (node string, err error)

type OrderCancelledEvent

type OrderCancelledEvent struct {
	OrderHash       common.Hash `fieldName:"_orderHash" fieldId:"0"`
	AmountCancelled *big.Int    `fieldName:"_amountCancelled" fieldId:"1"` // amountCancelled为多次取消累加总量,根据orderhash以及amountCancelled可以确定其唯一性
}

func (*OrderCancelledEvent) ConvertDown

func (e *OrderCancelledEvent) ConvertDown() *types.OrderCancelledEvent

type ProtocolAddress

type ProtocolAddress struct {
	Version         string
	ContractAddress common.Address

	LrcTokenAddress common.Address

	TokenRegistryAddress common.Address

	DelegateAddress common.Address
}

type RingMinedEvent

type RingMinedEvent struct {
	RingIndex     *big.Int       `fieldName:"_ringIndex" fieldId:"0"`
	RingHash      common.Hash    `fieldName:"_ringhash" fieldId:"1"`
	Miner         common.Address `fieldName:"_miner" fieldId:"2"`
	FeeRecipient  common.Address `fieldName:"_feeRecipient" fieldId:"3"`
	OrderInfoList [][32]uint8    `fieldName:"_orderInfoList" fieldId:"4"`
}

func (*RingMinedEvent) ConvertDown

type RpcClient

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

type SubmitRingMethodInputs

type SubmitRingMethodInputs struct {
	AddressList        [][4]common.Address `fieldName:"addressList" fieldId:"0"`   // owner,tokenS, wallet, authAddress
	UintArgsList       [][6]*big.Int       `fieldName:"uintArgsList" fieldId:"1"`  // amountS, amountB, validSince (second),validUntil (second), lrcFee, rateAmountS.
	Uint8ArgsList      [][1]uint8          `fieldName:"uint8ArgsList" fieldId:"2"` // marginSplitPercentageList
	BuyNoMoreThanBList []bool              `fieldName:"buyNoMoreThanAmountBList" fieldId:"3"`
	VList              []uint8             `fieldName:"vList" fieldId:"4"`
	RList              [][32]byte          `fieldName:"rList" fieldId:"5"`
	SList              [][32]byte          `fieldName:"sList" fieldId:"6"`
	FeeRecipient       common.Address      `fieldName:"feeRecipient" fieldId:"7"`
	FeeSelections      uint16              `fieldName:"feeSelections" fieldId:"8"`
	Protocol           common.Address
	FeeReceipt         common.Address
}

func (*SubmitRingMethodInputs) ConvertDown

should add protocol, miner, feeRecipient

type SyncingResult

type SyncingResult struct {
	StartingBlock types.Big
	CurrentBlock  types.Big
	HighestBlock  types.Big
}

type TokenRegisteredEvent

type TokenRegisteredEvent struct {
	Token  common.Address `fieldName:"addr" fieldId:"0"`
	Symbol string         `fieldName:"symbol" fieldId:"1"`
}

func (*TokenRegisteredEvent) ConvertDown

func (e *TokenRegisteredEvent) ConvertDown() *types.TokenRegisterEvent

type TokenUnRegisteredEvent

type TokenUnRegisteredEvent struct {
	Token  common.Address `fieldName:"addr" fieldId:"0"`
	Symbol string         `fieldName:"symbol" fieldId:"1"`
}

func (*TokenUnRegisteredEvent) ConvertDown

type Transaction

type Transaction struct {
	Hash             string    `json:"hash"`
	Nonce            types.Big `json:"nonce"`
	BlockHash        string    `json:"blockHash"`
	BlockNumber      types.Big `json:"blockNumber"`
	TransactionIndex types.Big `json:"transactionIndex"`
	From             string    `json:"from"`
	To               string    `json:"to"`
	Value            types.Big `json:"value"`
	GasPrice         types.Big `json:"gasPrice"`
	Gas              types.Big `json:"gas"`
	Input            string    `json:"input"`
	R                string    `json:"r"`
	S                string    `json:"s"`
	V                string    `json:"v"`
}

func (*Transaction) IsNull

func (tx *Transaction) IsNull() bool

func (*Transaction) IsPending

func (tx *Transaction) IsPending() bool

func (*Transaction) MethodId

func (tx *Transaction) MethodId() string

type TransactionReceipt

type TransactionReceipt struct {
	BlockHash         string     `json:"blockHash"`
	BlockNumber       types.Big  `json:"blockNumber"`
	ContractAddress   string     `json:"contractAddress"`
	CumulativeGasUsed types.Big  `json:"cumulativeGasUsed"`
	From              string     `json:"from"`
	GasUsed           types.Big  `json:"gasUsed"`
	Logs              []Log      `json:"logs"`
	LogsBloom         string     `json:"logsBloom"`
	Root              string     `json:"root"`
	Status            *types.Big `json:"status"`
	To                string     `json:"to"`
	TransactionHash   string     `json:"transactionHash"`
	TransactionIndex  types.Big  `json:"transactionIndex"`
}

func (*TransactionReceipt) AfterByzantiumFork

func (receipt *TransactionReceipt) AfterByzantiumFork() bool

func (*TransactionReceipt) Failed

func (receipt *TransactionReceipt) Failed(tx *Transaction) bool

func (*TransactionReceipt) HasNoLog

func (receipt *TransactionReceipt) HasNoLog() bool

func (*TransactionReceipt) StatusInvalid

func (receipt *TransactionReceipt) StatusInvalid() bool

type TransferEvent

type TransferEvent struct {
	Sender   common.Address `fieldName:"from" fieldId:"0"`
	Receiver common.Address `fieldName:"to" fieldId:"1"`
	Value    *big.Int       `fieldName:"value" fieldId:"2"`
}

func (*TransferEvent) ConvertDown

func (e *TransferEvent) ConvertDown() *types.TransferEvent

type TransferMethod

type TransferMethod struct {
	Receiver common.Address `fieldName:"to" fieldId:"0"`
	Value    *big.Int       `fieldName:"value" fieldId:"1"`
}

function transfer(address to, uint256 value) public returns (bool);

func (*TransferMethod) ConvertDown

func (e *TransferMethod) ConvertDown() *types.TransferEvent

type WethDepositEvent

type WethDepositEvent struct {
	DstAddress common.Address `fieldName:"dst" fieldId:"0"` // 充值到哪个地址
	Value      *big.Int       `fieldName:"wad" fieldId:"1"`
}

event Deposit(address indexed dst, uint wad);

func (*WethDepositEvent) ConvertDown

func (e *WethDepositEvent) ConvertDown() *types.WethDepositEvent

type WethWithdrawalEvent

type WethWithdrawalEvent struct {
	SrcAddress common.Address `fieldName:"src" fieldId:"0"`
	Value      *big.Int       `fieldName:"wad" fieldId:"1"`
}

event Withdrawal(address indexed src, uint wad);

func (*WethWithdrawalEvent) ConvertDown

func (e *WethWithdrawalEvent) ConvertDown() *types.WethWithdrawalEvent

type WethWithdrawalMethod

type WethWithdrawalMethod struct {
	Value *big.Int `fieldName:"wad" fieldId:"0"`
}

func (*WethWithdrawalMethod) ConvertDown

Jump to

Keyboard shortcuts

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