-
Notifications
You must be signed in to change notification settings - Fork 656
/
interfaces.go
40 lines (34 loc) · 1.81 KB
/
interfaces.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
package sequencesender
import (
"context"
"math/big"
"time"
ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types"
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/jackc/pgx/v4"
)
// Consumer interfaces required by the package.
// etherman contains the methods required to interact with ethereum.
type etherman interface {
BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, l2Coinbase common.Address) (to *common.Address, data []byte, err error)
EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, l2Coinbase common.Address) (*types.Transaction, error)
GetLastBatchTimestamp() (uint64, error)
GetLatestBlockTimestamp(ctx context.Context) (uint64, error)
GetLatestBatchNumber() (uint64, error)
}
// stateInterface gathers the methods required to interact with the state.
type stateInterface interface {
GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)
IsBatchClosed(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (bool, error)
GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
GetForcedBatch(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*state.ForcedBatch, error)
GetTimeForLatestBatchVirtualization(ctx context.Context, dbTx pgx.Tx) (time.Time, error)
GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
}
type ethTxManager interface {
Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, dbTx pgx.Tx) error
ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
}