common

package
v0.180.30 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Moved here because transactions package depends on accounts package which depends on appdatabase where this functionality is needed

Index

Constants

View Source
const (
	UnknownChainID     uint64 = 0
	EthereumMainnet    uint64 = 1
	EthereumGoerli     uint64 = 5
	EthereumSepolia    uint64 = 11155111
	OptimismMainnet    uint64 = 10
	OptimismGoerli     uint64 = 420
	OptimismSepolia    uint64 = 11155420
	ArbitrumMainnet    uint64 = 42161
	ArbitrumGoerli     uint64 = 421613
	ArbitrumSepolia    uint64 = 421614
	BinanceChainID     uint64 = 56 // obsolete?
	BinanceTestChainID uint64 = 97 // obsolete?
)
View Source
const (
	// Transaction types
	EthTransfer     Type = "eth"
	Erc20Transfer   Type = "erc20"
	Erc721Transfer  Type = "erc721"
	Erc1155Transfer Type = "erc1155"
	UniswapV2Swap   Type = "uniswapV2Swap"
	UniswapV3Swap   Type = "uniswapV3Swap"
	HopBridgeFrom   Type = "HopBridgeFrom"
	HopBridgeTo     Type = "HopBridgeTo"

	// Event types
	WETHDepositEventType                      EventType = "wethDepositEvent"
	WETHWithdrawalEventType                   EventType = "wethWithdrawalEvent"
	Erc20TransferEventType                    EventType = "erc20Event"
	Erc721TransferEventType                   EventType = "erc721Event"
	Erc1155TransferSingleEventType            EventType = "erc1155SingleEvent"
	Erc1155TransferBatchEventType             EventType = "erc1155BatchEvent"
	UniswapV2SwapEventType                    EventType = "uniswapV2SwapEvent"
	UniswapV3SwapEventType                    EventType = "uniswapV3SwapEvent"
	HopBridgeTransferSentToL2EventType        EventType = "hopBridgeTransferSentToL2Event"
	HopBridgeTransferFromL1CompletedEventType EventType = "hopBridgeTransferFromL1CompletedEvent"
	HopBridgeWithdrawalBondedEventType        EventType = "hopBridgeWithdrawalBondedEvent"
	HopBridgeTransferSentEventType            EventType = "hopBridgeTransferSentEvent"
	UnknownEventType                          EventType = "unknownEvent"

	// Transfer (index_topic_1 address from, index_topic_2 address to, uint256 value)
	// Transfer (index_topic_1 address from, index_topic_2 address to, index_topic_3 uint256 tokenId)
	Erc20_721TransferEventSignature     = "Transfer(address,address,uint256)"
	Erc1155TransferSingleEventSignature = "TransferSingle(address,address,address,uint256,uint256)"    // operator, from, to, id, value
	Erc1155TransferBatchEventSignature  = "TransferBatch(address,address,address,uint256[],uint256[])" // operator, from, to, ids, values

	// TransferFromL1Completed (index_topic_1 address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline, index_topic_2 address relayer, uint256 relayerFee)
	HopBridgeTransferFromL1CompletedEventSignature = "TransferFromL1Completed(address,uint256,uint256,uint256,address,uint256)"
)
View Source
const (
	NoMultiTransactionID = MultiTransactionIDType(0)
)

Variables

View Source
var (
	// MaxUint256 is the maximum value that can be represented by a uint256.
	MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), common.Big1)
)

Functions

func GetEventSignatureHash added in v0.157.2

func GetEventSignatureHash(signature string) common.Hash

func GetLogSubTxID added in v0.171.21

func GetLogSubTxID(log types.Log) common.Hash

func IsTokenTransfer added in v0.157.2

func IsTokenTransfer(logs []*types.Log) bool

func NewAndSet added in v0.166.6

func NewAndSet[T any](v T) *T

func ParseErc1155TransferLog added in v0.171.21

func ParseErc1155TransferLog(ethlog *types.Log, evType EventType) (operator, from, to common.Address, ids, amounts []*big.Int, err error)

func ParseErc20TransferLog added in v0.157.2

func ParseErc20TransferLog(ethlog *types.Log) (from, to common.Address, amount *big.Int)

func ParseErc721TransferLog added in v0.157.2

func ParseErc721TransferLog(ethlog *types.Log) (from, to common.Address, tokenID *big.Int)

func ParseHopBridgeTransferFromL1CompletedLog added in v0.161.4

func ParseHopBridgeTransferFromL1CompletedLog(ethlog *types.Log) (recipient common.Address, relayer common.Address, amount *big.Int, err error)

func ParseHopBridgeTransferSentLog added in v0.161.4

func ParseHopBridgeTransferSentLog(ethlog *types.Log) (transferID *big.Int, chainID uint64, recipient common.Address, amount *big.Int, transferNonce *big.Int, bonderFee *big.Int, index *big.Int, amountOutMin *big.Int, deadline *big.Int, err error)

func ParseHopBridgeTransferSentToL2Log added in v0.161.4

func ParseHopBridgeTransferSentToL2Log(ethlog *types.Log) (chainID uint64, recipient common.Address, relayer common.Address, amount *big.Int, err error)

func ParseHopWithdrawalBondedLog added in v0.161.4

func ParseHopWithdrawalBondedLog(ethlog *types.Log) (transferID *big.Int, amount *big.Int, err error)

func ParseTransferLog added in v0.171.21

func ParseTransferLog(ethlog types.Log) (from, to common.Address, txIDs []common.Hash, tokenIDs, values []*big.Int, err error)

func ParseUniswapV2Log added in v0.157.2

func ParseUniswapV2Log(ethlog *types.Log) (pairAddress common.Address, from common.Address, to common.Address, amount0In *big.Int, amount1In *big.Int, amount0Out *big.Int, amount1Out *big.Int, err error)

func ParseUniswapV3Log added in v0.157.2

func ParseUniswapV3Log(ethlog *types.Log) (poolAddress common.Address, sender common.Address, recipient common.Address, amount0 *big.Int, amount1 *big.Int, err error)

func ParseWETHDepositLog added in v0.159.5

func ParseWETHDepositLog(ethlog *types.Log) (src common.Address, amount *big.Int)

func ParseWETHWithdrawLog added in v0.159.5

func ParseWETHWithdrawLog(ethlog *types.Log) (dst common.Address, amount *big.Int)

func ShouldCancel added in v0.171.21

func ShouldCancel(ctx context.Context) bool

ShouldCancel returns true if the context has been cancelled and task should be aborted

func TxDataContainsAddress added in v0.161.4

func TxDataContainsAddress(txType uint8, txData []byte, address common.Address) bool

Types

type ChainID

type ChainID uint64

func AllChainIDs added in v0.167.5

func AllChainIDs() []ChainID

func (ChainID) IsMainnet added in v0.171.21

func (c ChainID) IsMainnet() bool

func (ChainID) String added in v0.167.5

func (c ChainID) String() string

type ContractType added in v0.174.0

type ContractType byte
const (
	ContractTypeUnknown ContractType = iota
	ContractTypeERC20
	ContractTypeERC721
	ContractTypeERC1155
)

type EventType added in v0.157.2

type EventType string

Log Event type

func GetEventType added in v0.157.2

func GetEventType(log *types.Log) EventType

Detect event type for a cetain item from the Events Log

func GetFirstEvent added in v0.157.2

func GetFirstEvent(logs []*types.Log) (EventType, *types.Log)

type MultiTransactionIDType added in v0.176.10

type MultiTransactionIDType int64

type Type added in v0.157.2

type Type string

Type type of transaction

func EventTypeToSubtransactionType added in v0.157.2

func EventTypeToSubtransactionType(eventType EventType) Type

func ExtractTokenTransferData added in v0.171.21

func ExtractTokenTransferData(dbEntryType Type, log *types.Log, tx *types.Transaction) (correctType Type, tokenAddress *common.Address, txFrom *common.Address, txTo *common.Address)

Jump to

Keyboard shortcuts

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