cfxbridge

package
v1.1.6-testnet Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ETH space only accept latest_state as block number. Other epoch tags, e.g. latest_checkpoint,
	// latest_confirmed and latest_mined are not supported.
	ErrEpochUnsupported = errors.New("epoch not supported")

	// ETH space only have pivot blocks as a list, and do not require to query non-pivot blocks.
	// To compatible with CFX space RPC, bridge service will check the assumption against pivot block.
	ErrInvalidBlockAssumption = errors.New("invalid block assumption")
)
View Source
var (
	HexBig0 = types.NewBigInt(0)
)

Functions

func ConvertAddress

func ConvertAddress(value common.Address, ethNetworkId uint32) types.Address

func ConvertAddressNullable

func ConvertAddressNullable(value *common.Address, ethNetworkId uint32) *types.Address

func ConvertAddresses

func ConvertAddresses(addresses []common.Address, ethNetworkId uint32) []types.Address

func ConvertBlock

func ConvertBlock(block *ethTypes.Block, ethNetworkId uint32) *types.Block

func ConvertBlockHeader

func ConvertBlockHeader(block *ethTypes.Block, ethNetworkId uint32) *types.BlockHeader

func ConvertBlockSummary

func ConvertBlockSummary(block *ethTypes.Block, ethNetworkId uint32) *types.BlockSummary

func ConvertHash

func ConvertHash(value common.Hash) types.Hash

func ConvertHashNullable

func ConvertHashNullable(value *common.Hash) *types.Hash

func ConvertLog

func ConvertLog(log *ethTypes.Log, ethNetworkId uint32) *types.Log

func ConvertLogFilter

func ConvertLogFilter(fq *ethTypes.FilterQuery, ethNetworkId uint32) *types.LogFilter

func ConvertReceipt

func ConvertReceipt(receipt *ethTypes.Receipt, ethNetworkId uint32) *types.TransactionReceipt

func ConvertTrace

func ConvertTrace(ethTrace *web3goTypes.LocalizedTrace, ethNetworkId uint32) (*types.LocalizedTrace, *types.LocalizedTrace)

func ConvertTx

func ConvertTx(tx *ethTypes.TransactionDetail, ethNetworkId uint32) *types.Transaction

func ConvertTxStatus

func ConvertTxStatus(value *uint64) hexutil.Uint64

func ConvertTxStatusNullable

func ConvertTxStatusNullable(value *uint64) (status *hexutil.Uint64)

func NormalizeBig

func NormalizeBig(value *big.Int, err error) (*hexutil.Big, error)

Types

type BlockTraceBuilder

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

func (*BlockTraceBuilder) Append

func (btb *BlockTraceBuilder) Append(trace, traceResult *types.LocalizedTrace, subTraces uint) error

func (*BlockTraceBuilder) Build

type CfxAPI

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

func NewCfxAPI

func NewCfxAPI(ethClient *web3go.Client, ethNetId uint32, cfxClient *sdk.Client) *CfxAPI

func (*CfxAPI) Call

func (api *CfxAPI) Call(ctx context.Context, request EthCallRequest, bn *EthBlockNumber) (hexutil.Bytes, error)

func (*CfxAPI) ClientVersion

func (api *CfxAPI) ClientVersion(ctx context.Context) (string, error)

func (*CfxAPI) EpochNumber

func (api *CfxAPI) EpochNumber(ctx context.Context, epoch *types.Epoch) (*hexutil.Big, error)

func (*CfxAPI) EstimateGasAndCollateral

func (api *CfxAPI) EstimateGasAndCollateral(ctx context.Context, request EthCallRequest, bn *EthBlockNumber) (types.Estimate, error)

func (*CfxAPI) GasPrice

func (api *CfxAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

func (*CfxAPI) GetAccount

func (api *CfxAPI) GetAccount(ctx context.Context, address EthAddress, bn *EthBlockNumber) (types.AccountInfo, error)

func (*CfxAPI) GetAccumulateInterestRate

func (api *CfxAPI) GetAccumulateInterestRate(ctx context.Context, bn *EthBlockNumber) (*hexutil.Big, error)

func (*CfxAPI) GetAdmin

func (api *CfxAPI) GetAdmin(ctx context.Context, contract EthAddress, bn *EthBlockNumber) (*string, error)

func (*CfxAPI) GetBalance

func (api *CfxAPI) GetBalance(ctx context.Context, address EthAddress, bn *EthBlockNumber) (*hexutil.Big, error)

func (*CfxAPI) GetBestBlockHash

func (api *CfxAPI) GetBestBlockHash(ctx context.Context) (common.Hash, error)

func (*CfxAPI) GetBlockByBlockNumber

func (api *CfxAPI) GetBlockByBlockNumber(ctx context.Context, blockNumer hexutil.Uint64, includeTxs bool) (interface{}, error)

func (*CfxAPI) GetBlockByEpochNumber

func (api *CfxAPI) GetBlockByEpochNumber(ctx context.Context, bn EthBlockNumber, includeTxs bool) (interface{}, error)

func (*CfxAPI) GetBlockByHash

func (api *CfxAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, includeTxs bool) (interface{}, error)

func (*CfxAPI) GetBlockByHashWithPivotAssumption

func (api *CfxAPI) GetBlockByHashWithPivotAssumption(ctx context.Context, blockHash, pivotHash common.Hash, bn hexutil.Uint64) (*types.Block, error)

func (*CfxAPI) GetBlockRewardInfo

func (api *CfxAPI) GetBlockRewardInfo(ctx context.Context, epoch types.Epoch) ([]types.RewardInfo, error)

func (*CfxAPI) GetBlocksByEpoch

func (api *CfxAPI) GetBlocksByEpoch(ctx context.Context, bn EthBlockNumber) ([]common.Hash, error)

func (*CfxAPI) GetCode

func (api *CfxAPI) GetCode(ctx context.Context, contract EthAddress, bn *EthBlockNumber) (hexutil.Bytes, error)

func (*CfxAPI) GetCollateralForStorage

func (api *CfxAPI) GetCollateralForStorage(ctx context.Context, address EthAddress, bn *EthBlockNumber) (*hexutil.Big, error)

func (*CfxAPI) GetConfirmationRiskByHash

func (api *CfxAPI) GetConfirmationRiskByHash(ctx context.Context, blockHash types.Hash) (*hexutil.Big, error)

func (*CfxAPI) GetDepositList

func (api *CfxAPI) GetDepositList(ctx context.Context, address EthAddress, bn *EthBlockNumber) ([]types.DepositInfo, error)

func (*CfxAPI) GetEpochReceipts

func (api *CfxAPI) GetEpochReceipts(ctx context.Context, bnh EthBlockNumberOrHash) ([][]*types.TransactionReceipt, error)

func (*CfxAPI) GetInterestRate

func (api *CfxAPI) GetInterestRate(ctx context.Context, bn *EthBlockNumber) (*hexutil.Big, error)

func (*CfxAPI) GetLogs

func (api *CfxAPI) GetLogs(ctx context.Context, filter EthLogFilter) ([]types.Log, error)

func (*CfxAPI) GetNextNonce

func (api *CfxAPI) GetNextNonce(ctx context.Context, address EthAddress, bn *EthBlockNumber) (*hexutil.Big, error)

func (*CfxAPI) GetSponsorInfo

func (api *CfxAPI) GetSponsorInfo(ctx context.Context, contract EthAddress, bn *EthBlockNumber) (types.SponsorInfo, error)

func (*CfxAPI) GetStakingBalance

func (api *CfxAPI) GetStakingBalance(ctx context.Context, address EthAddress, bn *EthBlockNumber) (*hexutil.Big, error)

func (*CfxAPI) GetStatus

func (api *CfxAPI) GetStatus(ctx context.Context) (types.Status, error)

func (*CfxAPI) GetStorageAt

func (api *CfxAPI) GetStorageAt(ctx context.Context, address EthAddress, position *hexutil.Big, bn *EthBlockNumber) (common.Hash, error)

func (*CfxAPI) GetStorageRoot

func (api *CfxAPI) GetStorageRoot(ctx context.Context, address EthAddress, bn *EthBlockNumber) (*types.StorageRoot, error)

func (*CfxAPI) GetSupplyInfo

func (api *CfxAPI) GetSupplyInfo(ctx context.Context, epoch *types.Epoch) (types.TokenSupplyInfo, error)

func (*CfxAPI) GetTransactionByHash

func (api *CfxAPI) GetTransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, error)

func (*CfxAPI) GetTransactionReceipt

func (api *CfxAPI) GetTransactionReceipt(ctx context.Context, txHash common.Hash) (*types.TransactionReceipt, error)

func (*CfxAPI) GetVoteList

func (api *CfxAPI) GetVoteList(ctx context.Context, address EthAddress, bn *EthBlockNumber) ([]types.VoteStakeInfo, error)

func (*CfxAPI) SendRawTransaction

func (api *CfxAPI) SendRawTransaction(ctx context.Context, signedTx hexutil.Bytes) (common.Hash, error)

type EthAddress

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

EthAddress accepts both hex40 and base32 format addresses.

func (*EthAddress) UnmarshalJSON

func (ea *EthAddress) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*EthAddress) ValueOrNil

func (ea *EthAddress) ValueOrNil() *common.Address

type EthBlockNumber

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

EthBlockNumber accepts number and epoch tag latest_state, other values are invalid, e.g. latest_confirmed.

func (*EthBlockNumber) ToArg

func (*EthBlockNumber) UnmarshalJSON

func (ebn *EthBlockNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*EthBlockNumber) Value

func (ebn *EthBlockNumber) Value() ethTypes.BlockNumber

func (*EthBlockNumber) ValueOrNil

func (ebn *EthBlockNumber) ValueOrNil() *ethTypes.BlockNumber

type EthBlockNumberOrHash

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

EthBlockNumberOrHash accepts hex number, hash and epoch tag latest_state, other values are invalid, e.g. latest_confirmed.

func (*EthBlockNumberOrHash) MarshalText

func (ebnh *EthBlockNumberOrHash) MarshalText() ([]byte, error)

func (*EthBlockNumberOrHash) ToArg

func (*EthBlockNumberOrHash) UnmarshalJSON

func (ebnh *EthBlockNumberOrHash) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type EthCallRequest

type EthCallRequest struct {
	From     *EthAddress
	To       *EthAddress
	GasPrice *hexutil.Big
	Gas      *hexutil.Uint64
	Value    *hexutil.Big
	Nonce    *hexutil.Uint64
	Data     *string
}

EthCallRequest is compatible with CFX CallRequest and accepts hex40 format address. Note, StorageLimit field is simply ignored.

func (*EthCallRequest) ToCallMsg

func (req *EthCallRequest) ToCallMsg() ethTypes.CallRequest

type EthLogFilter

type EthLogFilter struct {
	FromEpoch   *EthBlockNumber
	ToEpoch     *EthBlockNumber
	BlockHashes *common.Hash // eth space only accept a single block hash as filter
	Address     []EthAddress
	Topics      [][]common.Hash
}

EthLogFilter is compatible with CFX LogFilter and accepts hex40 format address. Note, some fields are simply ignored, e.g. from/to block, offset/limit.

func (*EthLogFilter) ToFilterQuery

func (filter *EthLogFilter) ToFilterQuery() ethTypes.FilterQuery

func (*EthLogFilter) UnmarshalJSON

func (l *EthLogFilter) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type TraceAPI

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

func NewTraceAPI

func NewTraceAPI(ethClient *web3go.Client, ethNetworkId uint32) *TraceAPI

func (*TraceAPI) Block

func (api *TraceAPI) Block(ctx context.Context, blockHash types.Hash) (*types.LocalizedBlockTrace, error)

func (*TraceAPI) Filter

func (api *TraceAPI) Filter(ctx context.Context, filter types.TraceFilter) ([]types.LocalizedTrace, error)

func (*TraceAPI) Transaction

func (api *TraceAPI) Transaction(ctx context.Context, txHash types.Hash) ([]types.LocalizedTrace, error)

type TraceBuilder

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

TraceBuilder builds traces in stack way and thread unsafe.

func (*TraceBuilder) Append

func (tb *TraceBuilder) Append(trace, traceResult *types.LocalizedTrace, subTraces uint) error

func (*TraceBuilder) Build

func (tb *TraceBuilder) Build() ([]types.LocalizedTrace, error)

type TransactionTraceBuilder

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

func (*TransactionTraceBuilder) Append

func (ttb *TransactionTraceBuilder) Append(trace, traceResult *types.LocalizedTrace, subTraces uint) (bool, error)

func (*TransactionTraceBuilder) Build

type TxpoolAPI

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

func NewTxpoolAPI

func NewTxpoolAPI(ethClient *web3go.Client) *TxpoolAPI

func (*TxpoolAPI) NextNonce

func (api *TxpoolAPI) NextNonce(ctx context.Context, address EthAddress) (val *hexutil.Big, err error)

Jump to

Keyboard shortcuts

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