This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
block.go
92 lines (81 loc) · 2.59 KB
/
block.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package common
import (
"math/big"
"time"
ethCommon "github.com/ethereum/go-ethereum/common"
)
// Block represents of an Ethereum block
type Block struct {
Num int64 `meddler:"eth_block_num"`
Timestamp time.Time `meddler:"timestamp,utctime"`
Hash ethCommon.Hash `meddler:"hash"`
ParentHash ethCommon.Hash `meddler:"-" json:"-"`
}
// RollupData contains information returned by the Rollup smart contract
type RollupData struct {
// L1UserTxs that were submitted in the block
L1UserTxs []L1Tx
Batches []BatchData
AddedTokens []Token
Withdrawals []WithdrawInfo
UpdateBucketWithdraw []BucketUpdate
TokenExchanges []TokenExchange
Vars *RollupVariables
}
// NewRollupData creates an empty RollupData with the slices initialized.
func NewRollupData() RollupData {
return RollupData{
L1UserTxs: make([]L1Tx, 0),
Batches: make([]BatchData, 0),
AddedTokens: make([]Token, 0),
Withdrawals: make([]WithdrawInfo, 0),
Vars: nil,
}
}
// AuctionData contains information returned by the Action smart contract
type AuctionData struct {
Bids []Bid
Coordinators []Coordinator
Vars *AuctionVariables
}
// NewAuctionData creates an empty AuctionData with the slices initialized.
func NewAuctionData() AuctionData {
return AuctionData{
Bids: make([]Bid, 0),
Coordinators: make([]Coordinator, 0),
Vars: nil,
}
}
// WDelayerTransfer represents a transfer (either deposit or withdrawal) in the
// WDelayer smart contract
type WDelayerTransfer struct {
Owner ethCommon.Address
Token ethCommon.Address
Amount *big.Int
// TxHash ethCommon.Hash // hash of the transaction in which the wdelayer transfer happened
}
// WDelayerData contains information returned by the WDelayer smart contract
type WDelayerData struct {
Vars *WDelayerVariables
Deposits []WDelayerTransfer
// We use an array because there can be multiple deposits in a single eth transaction
DepositsByTxHash map[ethCommon.Hash][]*WDelayerTransfer
Withdrawals []WDelayerTransfer
EscapeHatchWithdrawals []WDelayerEscapeHatchWithdrawal
}
// NewWDelayerData creates an empty WDelayerData.
func NewWDelayerData() WDelayerData {
return WDelayerData{
Vars: nil,
Deposits: make([]WDelayerTransfer, 0),
DepositsByTxHash: make(map[ethCommon.Hash][]*WDelayerTransfer),
Withdrawals: make([]WDelayerTransfer, 0),
}
}
// BlockData contains the information of a Block
type BlockData struct {
Block Block
Rollup RollupData
Auction AuctionData
WDelayer WDelayerData
}