Documentation ¶
Index ¶
- Variables
- func NewGUID() string
- type Airdrop
- type BlockLocator
- type Database
- func (d *Database) AddIndexedL1Block(block *IndexedL1Block) error
- func (d *Database) AddIndexedL2Block(block *IndexedL2Block) error
- func (d *Database) AddL1Token(address string, token *Token) error
- func (d *Database) AddL2Token(address string, token *Token) error
- func (d *Database) AddStateBatch(batches []StateBatch) error
- func (d *Database) Close() error
- func (d *Database) Config() string
- func (d *Database) GetAirdrop(address common.Address) (*Airdrop, error)
- func (d *Database) GetDepositsByAddress(address common.Address, page PaginationParam) (*PaginatedDeposits, error)
- func (d *Database) GetHighestL1Block() (*BlockLocator, error)
- func (d *Database) GetHighestL2Block() (*BlockLocator, error)
- func (d *Database) GetIndexedL1BlockByHash(hash common.Hash) (*IndexedL1Block, error)
- func (d *Database) GetL1TokenByAddress(address string) (*Token, error)
- func (d *Database) GetL2TokenByAddress(address string) (*Token, error)
- func (d *Database) GetWithdrawalBatch(hash common.Hash) (*StateBatchJSON, error)
- func (d *Database) GetWithdrawalsByAddress(address common.Address, page PaginationParam, state FinalizationState) (*PaginatedWithdrawals, error)
- type Deposit
- type DepositJSON
- type FinalizationState
- type FinalizedWithdrawal
- type IndexedL1Block
- type IndexedL2Block
- type PaginatedDeposits
- type PaginatedWithdrawals
- type PaginationParam
- type ProvenWithdrawal
- type StateBatch
- type StateBatchJSON
- type Token
- type Withdrawal
- type WithdrawalJSON
Constants ¶
This section is empty.
Variables ¶
var ETHL1Address common.Address
var ETHL1Token = &Token{ Address: ETHL1Address.String(), Name: "Ethereum", Symbol: "ETH", Decimals: 18, }
ETHL1Token is a placeholder token for differentiating ETH transactions from ERC20 transactions on L1.
var ETHL2Token = &Token{ Address: predeploys.LegacyERC20ETH, Name: "Ethereum", Symbol: "ETH", Decimals: 18, }
ETHL2Token is a placeholder token for differentiating ETH transactions from ERC20 transactions on L2.
Functions ¶
Types ¶
type Airdrop ¶
type Airdrop struct { Address string `json:"address"` VoterAmount string `json:"voterAmount"` MultisigSignerAmount string `json:"multisigSignerAmount"` GitcoinAmount string `json:"gitcoinAmount"` ActiveBridgedAmount string `json:"activeBridgedAmount"` OpUserAmount string `json:"opUserAmount"` OpRepeatUserAmount string `json:"opRepeatUserAmount"` BonusAmount string `json:"bonusAmount"` TotalAmount string `json:"totalAmount"` }
type BlockLocator ¶
BlockLocator contains the block number and hash. It can uniquely identify an Ethereum block
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database contains the database instance and the connection string.
func NewDatabase ¶
NewDatabase returns the database for the given connection string.
func (*Database) AddIndexedL1Block ¶
func (d *Database) AddIndexedL1Block(block *IndexedL1Block) error
AddIndexedL1Block inserts the indexed block i.e. the L1 block containing all scanned Deposits into the known deposits database. NOTE: the block hash MUST be unique
func (*Database) AddIndexedL2Block ¶
func (d *Database) AddIndexedL2Block(block *IndexedL2Block) error
AddIndexedL2Block inserts the indexed block i.e. the L2 block containing all scanned Withdrawals into the known withdrawals database. NOTE: the block hash MUST be unique
func (*Database) AddL1Token ¶
AddL1Token inserts the Token details for the given address into the known L1 tokens database. NOTE: a Token MUST have a unique address
func (*Database) AddL2Token ¶
AddL2Token inserts the Token details for the given address into the known L2 tokens database. NOTE: a Token MUST have a unique address
func (*Database) AddStateBatch ¶
func (d *Database) AddStateBatch(batches []StateBatch) error
AddStateBatch inserts the state batches into the known state batches database.
func (*Database) Close ¶
Close closes the database. NOTE: "It is rarely necessary to close a DB." See: https://pkg.go.dev/database/sql#Open
func (*Database) GetAirdrop ¶
func (*Database) GetDepositsByAddress ¶
func (d *Database) GetDepositsByAddress(address common.Address, page PaginationParam) (*PaginatedDeposits, error)
GetDepositsByAddress returns the list of Deposits indexed for the given address paginated by the given params.
func (*Database) GetHighestL1Block ¶
func (d *Database) GetHighestL1Block() (*BlockLocator, error)
GetHighestL1Block returns the highest known L1 block.
func (*Database) GetHighestL2Block ¶
func (d *Database) GetHighestL2Block() (*BlockLocator, error)
GetHighestL2Block returns the highest known L2 block.
func (*Database) GetIndexedL1BlockByHash ¶
func (d *Database) GetIndexedL1BlockByHash(hash common.Hash) (*IndexedL1Block, error)
GetIndexedL1BlockByHash returns the L1 block by it's hash.
func (*Database) GetL1TokenByAddress ¶
GetL1TokenByAddress returns the ERC20 Token corresponding to the given address on L1.
func (*Database) GetL2TokenByAddress ¶
GetL2TokenByAddress returns the ERC20 Token corresponding to the given address on L2.
func (*Database) GetWithdrawalBatch ¶
func (d *Database) GetWithdrawalBatch(hash common.Hash) (*StateBatchJSON, error)
GetWithdrawalBatch returns the StateBatch corresponding to the given withdrawal transaction hash.
func (*Database) GetWithdrawalsByAddress ¶
func (d *Database) GetWithdrawalsByAddress(address common.Address, page PaginationParam, state FinalizationState) (*PaginatedWithdrawals, error)
GetWithdrawalsByAddress returns the list of Withdrawals indexed for the given address paginated by the given params.
type Deposit ¶
type Deposit struct { GUID string TxHash common.Hash L1Token common.Address L2Token common.Address FromAddress common.Address ToAddress common.Address Amount *big.Int Data []byte LogIndex uint }
Deposit contains transaction data for deposits made via the L1 to L2 bridge.
type DepositJSON ¶
type DepositJSON struct { GUID string `json:"guid"` FromAddress string `json:"from"` ToAddress string `json:"to"` L1Token *Token `json:"l1Token"` L2Token string `json:"l2Token"` Amount string `json:"amount"` Data []byte `json:"data"` LogIndex uint64 `json:"logIndex"` BlockNumber uint64 `json:"blockNumber"` BlockTimestamp string `json:"blockTimestamp"` TxHash string `json:"transactionHash"` }
DepositJSON contains Deposit data suitable for JSON serialization.
type FinalizationState ¶
type FinalizationState int
const ( FinalizationStateAny FinalizationState = iota FinalizationStateFinalized FinalizationStateUnfinalized )
func ParseFinalizationState ¶
func ParseFinalizationState(in string) FinalizationState
func (FinalizationState) SQL ¶
func (f FinalizationState) SQL() string
type FinalizedWithdrawal ¶
type IndexedL1Block ¶
type IndexedL1Block struct { Hash common.Hash ParentHash common.Hash Number uint64 Timestamp uint64 Deposits []Deposit ProvenWithdrawals []ProvenWithdrawal FinalizedWithdrawals []FinalizedWithdrawal }
IndexedL1Block contains the L1 block including the deposits in it.
func (IndexedL1Block) String ¶
func (b IndexedL1Block) String() string
String returns the block hash for the indexed l1 block.
type IndexedL2Block ¶
type IndexedL2Block struct { Hash common.Hash ParentHash common.Hash Number uint64 Timestamp uint64 Withdrawals []Withdrawal }
IndexedL2Block contains the L2 block including the withdrawals in it.
func (IndexedL2Block) String ¶
func (b IndexedL2Block) String() string
String returns the block hash for the indexed l2 block.
type PaginatedDeposits ¶
type PaginatedDeposits struct { Param *PaginationParam `json:"pagination"` Deposits []DepositJSON `json:"items"` }
type PaginatedWithdrawals ¶
type PaginatedWithdrawals struct { Param *PaginationParam `json:"pagination"` Withdrawals []WithdrawalJSON `json:"items"` }
type PaginationParam ¶
type PaginationParam struct { Limit uint64 `json:"limit"` Offset uint64 `json:"offset"` Total uint64 `json:"total"` }
PaginationParam holds the pagination fields passed through by the REST middleware and queried by the database to page through deposits and withdrawals.
type ProvenWithdrawal ¶
type StateBatch ¶
type StateBatch struct { Index *big.Int Root common.Hash Size *big.Int PrevTotal *big.Int ExtraData []byte BlockHash common.Hash }
StateBatch is the state batch containing merkle root of the withdrawals periodically written to L1.
type StateBatchJSON ¶
type StateBatchJSON struct { Index uint64 `json:"index"` Root string `json:"root"` Size uint64 `json:"size"` PrevTotal uint64 `json:"prevTotal"` ExtraData []byte `json:"extraData"` BlockHash string `json:"blockHash"` BlockNumber uint64 `json:"blockNumber"` BlockTimestamp uint64 `json:"blockTimestamp"` }
StateBatchJSON contains StateBatch data suitable for JSON serialization.
type Token ¶
type Token struct { Address string `json:"address"` Name string `json:"name"` Symbol string `json:"symbol"` Decimals uint8 `json:"decimals"` }
Token contains the token details of the ERC20 contract at the given address. NOTE: The Token address will almost definitely be different on L1 and L2, so we need to track it on both chains when handling transactions.
type Withdrawal ¶
type Withdrawal struct { GUID string TxHash common.Hash L1Token common.Address L2Token common.Address FromAddress common.Address ToAddress common.Address Amount *big.Int Data []byte LogIndex uint BedrockHash *common.Hash }
Withdrawal contains transaction data for withdrawals made via the L2 to L1 bridge.
func (Withdrawal) String ¶
func (w Withdrawal) String() string
String returns the tx hash for the withdrawal.
type WithdrawalJSON ¶
type WithdrawalJSON struct { GUID string `json:"guid"` FromAddress string `json:"from"` ToAddress string `json:"to"` L1Token string `json:"l1Token"` L2Token *Token `json:"l2Token"` Amount string `json:"amount"` Data []byte `json:"data"` LogIndex uint64 `json:"logIndex"` BlockNumber uint64 `json:"blockNumber"` BlockTimestamp string `json:"blockTimestamp"` TxHash string `json:"transactionHash"` Batch *StateBatchJSON `json:"batch"` BedrockWithdrawalHash *string `json:"bedrockWithdrawalHash"` BedrockProvenTxHash *string `json:"bedrockProvenTxHash"` BedrockProvenLogIndex *int `json:"bedrockProvenLogIndex"` BedrockFinalizedTxHash *string `json:"bedrockFinalizedTxHash"` BedrockFinalizedLogIndex *int `json:"bedrockFinalizedLogIndex"` BedrockFinalizedSuccess *bool `json:"bedrockFinalizedSuccess"` }
WithdrawalJSON contains Withdrawal data suitable for JSON serialization.