service

package
v0.0.0-...-bac2478 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const (
	InfuraApiUrl         string = "https://mainnet.infura.io/v3/"
	EthereumUsdtAddress  string = "0xdAC17F958D2ee523a2206206994597C13D831ec7"
	EthereumEmptyAddress string = "0x0000000000000000000000000000000000000000"

	EthereumUsdtAbi string = `` /* 342-byte string literal not displayed */

)

Variables

View Source
var EthereumUsdtMethodTransfer []byte = []byte{0xa9, 0x5, 0x9c, 0xbb}
View Source
var TronTriggerSmartyContract string = "type.googleapis.com/protocol.TriggerSmartContract"
View Source
var TronUsdtAddress string = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"

Functions

func FindTronTransaction

func FindTronTransaction(block *api.BlockExtention, txId string) (*api.TransactionExtention, error)

func GetAllPlatform

func GetAllPlatform() []model.Platform

func GetHttpProxyDialOption

func GetHttpProxyDialOption() (*grpc.DialOption, error)

func GetInfuraApiUrlFromEnvironmentVariable

func GetInfuraApiUrlFromEnvironmentVariable() (string, error)

func GetInfuraApiUrlV2

func GetInfuraApiUrlV2(key string) string

func IsNotFound

func IsNotFound(err error) bool

func NewError

func NewError(code Code, rpcError error) error

func NewEthereumError

func NewEthereumError(err error) error

func NewTronClient

func NewTronClient() (*client.GrpcClient, error)

func ParseEthereumTransactionFromAddress

func ParseEthereumTransactionFromAddress(t *types.Transaction) string

func ToTronAddress

func ToTronAddress(addr common.Address) address.Address

Converts an Ethereum address to a Tron address.

Types

type BlockChainService

type BlockChainService interface {
	GetLatestBlock() (*model.Block, error)

	GetBlock(height *big.Int) (*model.Block, error)
}

type BlockListener

type BlockListener interface {
	BeforeQuerying(height *big.Int)

	AfterRawQuerying(block interface{}, err error)

	AfterQuerying(block *model.Block, err error)
}

type Code

type Code uint32
const (
	OK Code = iota
	NotFound
	RpcError
	Other
)

type DataSendingBlockListener

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

func NewDataSendingBlockListener

func NewDataSendingBlockListener(channel chan interface{}) *DataSendingBlockListener

func (*DataSendingBlockListener) AfterQuerying

func (l *DataSendingBlockListener) AfterQuerying(blok *model.Block, err error)

func (*DataSendingBlockListener) AfterRawQuerying

func (l *DataSendingBlockListener) AfterRawQuerying(block interface{}, err error)

func (*DataSendingBlockListener) BeforeQuerying

func (l *DataSendingBlockListener) BeforeQuerying(height *big.Int)

type EthereumBlockChainService

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

func NewEthereumBlockChainService

func NewEthereumBlockChainService(url string, listeners []BlockListener) (*EthereumBlockChainService, error)

func (*EthereumBlockChainService) GetBlock

func (s *EthereumBlockChainService) GetBlock(height *big.Int) (*model.Block, error)

func (*EthereumBlockChainService) GetLatestBlock

func (s *EthereumBlockChainService) GetLatestBlock() (*model.Block, error)

type EthereumClient

type EthereumClient struct {
	Client    *ethclient.Client
	Assembler *EthereumServiceAssembler
	Channel   chan interface{}
}

func NewEthereumClient

func NewEthereumClient(url string, channel chan interface{}) (*EthereumClient, error)

func (*EthereumClient) GetBlock

func (s *EthereumClient) GetBlock(number *big.Int) (*types.Block, error)

func (*EthereumClient) GetNowBlock

func (s *EthereumClient) GetNowBlock() (*types.Header, error)

func (*EthereumClient) GetTransactions

func (s *EthereumClient) GetTransactions(number *big.Int) ([]*model.Transaction, error)

type EthereumContractUsdtTransfer

type EthereumContractUsdtTransfer struct {
	To    *common.Address
	Value *big.Int
}

type EthereumServiceAssembler

type EthereumServiceAssembler struct {
	ParsedABI     abi.ABI
	TansferMethod *abi.Method
}

func NewEthereumServiceAssembler

func NewEthereumServiceAssembler() (*EthereumServiceAssembler, error)

func (*EthereumServiceAssembler) BlockToTransactions

func (a *EthereumServiceAssembler) BlockToTransactions(block *types.Block) []*model.Transaction

func (*EthereumServiceAssembler) ToBlock

func (a *EthereumServiceAssembler) ToBlock(block *types.Block) *model.Block

func (*EthereumServiceAssembler) ToTransaction

func (*EthereumServiceAssembler) ToUsdtTransferArguments

func (a *EthereumServiceAssembler) ToUsdtTransferArguments(data *[]byte) (*EthereumContractUsdtTransfer, error)

type EthereumTransaction

type EthereumTransaction struct {
	BlockHash   string `json:"block_hash"`
	BlockNumber uint64 `json:"block_number"`

	Type  uint8  `json:"type"`
	Hash  string `json:"hash"`
	Nonce uint64 `json:"nonce"`

	ChainID    *big.Int         `json:"chain_id"`
	AccessList types.AccessList `json:"access_list"`
	Data       string           `json:"data"`
	Gas        uint64           `json:"gas"`
	GasPrice   *big.Int         `json:"gas_price"`
	GasTipCap  *big.Int         `json:"gas_tip_cap"`
	GasFeeCap  *big.Int         `json:"gas_fee_cap"`
	From       string           `json:"from"`
	To         string           `json:"to"`
	Value      *big.Int         `json:"value"`
	Time       time.Time        `json:"time"`
}

func (*EthereumTransaction) FromTransaction

func (t *EthereumTransaction) FromTransaction(block *types.Block, tx *types.Transaction)

type EthereumTransactions

type EthereumTransactions []*EthereumTransaction

func (*EthereumTransactions) FromTransactions

func (t *EthereumTransactions) FromTransactions(block *types.Block, txs types.Transactions) *EthereumTransactions

FromTransactions converts a list of Ethereum transactions to a list of EthereumTransaction

type GetContractAbiResponse

type GetContractAbiResponse struct {
	Entrys []interface{} `json:"entrys"`
}

type GetContractCommand

type GetContractCommand struct {
	Value   string `json:"value"`
	Visible bool   `json:"visible"`
}

type GetContractResponse

type GetContractResponse struct {
	Bytecode string                 `json:"bytecode"`
	Abi      GetContractAbiResponse `json:"abi"`
}

type Status

type Status struct {
	Code  Code
	Cause error
}

func FromError

func FromError(err error) (s *Status, ok bool)

func (*Status) Error

func (s *Status) Error() string

func (*Status) GetCause

func (s *Status) GetCause() error

func (*Status) GetCode

func (s *Status) GetCode() Code

type TronBlockChainAssembler

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

func NewTronBlockChainAssembler

func NewTronBlockChainAssembler() *TronBlockChainAssembler

func (*TronBlockChainAssembler) GetTransferArguments

func (a *TronBlockChainAssembler) GetTransferArguments(
	service *TronBlockChainService,
) (*abi.Arguments, error)

func (*TronBlockChainAssembler) GetTransferContract

func (a *TronBlockChainAssembler) GetTransferContract(
	contract *core.Transaction_Contract) (*core.TransferContract, error)

func (*TronBlockChainAssembler) IsTransferContract

func (a *TronBlockChainAssembler) IsTransferContract(
	contract *core.Transaction_Contract) bool

func (*TronBlockChainAssembler) ToBlock

func (a *TronBlockChainAssembler) ToBlock(
	block *api.BlockExtention,
	service *TronBlockChainService,
) (*model.Block, error)

func (*TronBlockChainAssembler) ToTransaction

func (*TronBlockChainAssembler) ToTransactions

func (a *TronBlockChainAssembler) ToTransactions(args *abi.Arguments, block *api.BlockExtention) []*model.Transaction

func (*TronBlockChainAssembler) TransactionFromContract

func (*TronBlockChainAssembler) TransactionFromTransfer

type TronBlockChainService

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

func NewTronBlockChainService

func NewTronBlockChainService(client *client.GrpcClient, listeners []BlockListener) *TronBlockChainService

func (*TronBlockChainService) GetBlock

func (service *TronBlockChainService) GetBlock(height *big.Int) (*model.Block, error)

func (*TronBlockChainService) GetLatestBlock

func (service *TronBlockChainService) GetLatestBlock() (*model.Block, error)

func (*TronBlockChainService) GetSmartContractABI

func (service *TronBlockChainService) GetSmartContractABI(address string) (*core.SmartContract_ABI, error)

type TronHttpClient

type TronHttpClient struct {
}

func NewTronHttpClient

func NewTronHttpClient() *TronHttpClient

func (*TronHttpClient) GetContract

func (c *TronHttpClient) GetContract(id string) (*GetContractResponse, error)

Jump to

Keyboard shortcuts

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