common

package
v0.171.5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MPL-2.0 Imports: 8 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
	ArbitrumMainnet uint64 = 42161
	ArbitrumGoerli  uint64 = 421613
	ArbitrumSepolia uint64 = 421614
)
View Source
const (
	// Transaction types
	EthTransfer    Type = "eth"
	Erc20Transfer  Type = "erc20"
	Erc721Transfer Type = "erc721"
	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"
	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)"

	// 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)"
)

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 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 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 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 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) String added in v0.167.5

func (c ChainID) String() string

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 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 ExtractTokenIdentity added in v0.157.2

func ExtractTokenIdentity(dbEntryType Type, log *types.Log, tx *types.Transaction) (correctType Type, tokenAddress *common.Address, txTokenID *big.Int, txValue *big.Int, txFrom *common.Address, txTo *common.Address)

Jump to

Keyboard shortcuts

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