github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/sequencesender/interfaces.go (about) 1 package sequencesender 2 3 import ( 4 "context" 5 "math/big" 6 "time" 7 8 theEtherman "github.com/0xPolygon/supernets2-node/etherman" 9 ethmanTypes "github.com/0xPolygon/supernets2-node/etherman/types" 10 "github.com/0xPolygon/supernets2-node/ethtxmanager" 11 "github.com/0xPolygon/supernets2-node/state" 12 "github.com/ethereum/go-ethereum/common" 13 "github.com/ethereum/go-ethereum/core/types" 14 "github.com/jackc/pgx/v4" 15 ) 16 17 // Consumer interfaces required by the package. 18 19 // etherman contains the methods required to interact with ethereum. 20 type etherman interface { 21 BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, committeeSignaturesAndAddrs []byte) (to *common.Address, data []byte, err error) 22 EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, committeeSignaturesAndAddrs []byte) (*types.Transaction, error) 23 GetLastBatchTimestamp() (uint64, error) 24 GetLatestBlockTimestamp(ctx context.Context) (uint64, error) 25 GetLatestBatchNumber() (uint64, error) 26 GetCurrentDataCommittee() (*theEtherman.DataCommittee, error) 27 } 28 29 // stateInterface gathers the methods required to interact with the state. 30 type stateInterface interface { 31 GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error) 32 IsBatchClosed(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (bool, error) 33 GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) 34 GetForcedBatch(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*state.ForcedBatch, error) 35 GetTimeForLatestBatchVirtualization(ctx context.Context, dbTx pgx.Tx) (time.Time, error) 36 GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) 37 } 38 39 type ethTxManager interface { 40 Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, dbTx pgx.Tx) error 41 ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx) 42 }