From fb3f98293a40fd2a425bb646f942e534d6a402bc Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 09:26:27 -0700 Subject: [PATCH 1/7] added type assertion to client --- core/chains/evm/client/client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/chains/evm/client/client.go b/core/chains/evm/client/client.go index 748e090b2bb..87768e3543f 100644 --- a/core/chains/evm/client/client.go +++ b/core/chains/evm/client/client.go @@ -8,7 +8,7 @@ import ( clienttypes "github.com/smartcontractkit/chainlink/v2/common/chains/client" htrktypes "github.com/smartcontractkit/chainlink/v2/common/headtracker/types" - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" + commontypes "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/assets" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/config" @@ -29,7 +29,7 @@ const queryTimeout = 10 * time.Second // Client is the interface used to interact with an ethereum node. type Client interface { - txmgrtypes.Client[*big.Int, evmtypes.Nonce, common.Address, types.Block, common.Hash, types.Transaction, common.Hash, types.Receipt, types.Log, ethereum.FilterQuery] + commontypes.Client[*big.Int, evmtypes.Nonce, common.Address, types.Block, common.Hash, types.Transaction, common.Hash, types.Receipt, types.Log, ethereum.FilterQuery] Dial(ctx context.Context) error Close() @@ -91,6 +91,7 @@ type client struct { var _ Client = (*client)(nil) var _ htrktypes.Client[*evmtypes.Head, ethereum.Subscription, *big.Int, common.Hash] = (*client)(nil) +var _ commontypes.Client[*big.Int, evmtypes.Nonce, common.Address, types.Block, common.Hash, types.Transaction, common.Hash, types.Receipt, types.Log, ethereum.FilterQuery] = (*client)(nil) // NewClientWithNodes instantiates a client from a list of nodes // Currently only supports one primary From 9f1f7f1513e963e4b9924b407d886b64da3438ff Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 09:27:34 -0700 Subject: [PATCH 2/7] moved chain and client interfaces to common --- common/headtracker/head_listener.go | 5 +- common/headtracker/head_tracker.go | 29 ++++++----- common/headtracker/types/client.go | 5 +- common/headtracker/types/head.go | 3 +- common/txmgr/broadcaster.go | 18 +++---- common/txmgr/confirmer.go | 16 +++--- common/txmgr/reaper.go | 5 +- common/txmgr/resender.go | 12 ++--- common/txmgr/txmgr.go | 16 +++--- common/txmgr/types/client.go | 62 +++--------------------- common/txmgr/types/keystore.go | 4 +- common/txmgr/types/mocks/key_store.go | 2 +- common/txmgr/types/tx.go | 8 +-- common/txmgr/types/tx_attempt_builder.go | 4 +- common/txmgr/types/tx_store.go | 14 +++--- common/{txmgr => }/types/chain.go | 0 common/types/client.go | 56 +++++++++++++++++++++ 17 files changed, 131 insertions(+), 128 deletions(-) rename common/{txmgr => }/types/chain.go (100%) create mode 100644 common/types/client.go diff --git a/common/headtracker/head_listener.go b/common/headtracker/head_listener.go index a2d121911a9..24c221d61ab 100644 --- a/common/headtracker/head_listener.go +++ b/common/headtracker/head_listener.go @@ -10,7 +10,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" htrktypes "github.com/smartcontractkit/chainlink/v2/common/headtracker/types" - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -30,7 +29,7 @@ var ( type HeadListener[ HTH htrktypes.Head[BLOCK_HASH, ID], S types.Subscription, - ID txmgrtypes.ID, + ID types.ID, BLOCK_HASH types.Hashable, ] struct { config htrktypes.Config @@ -46,7 +45,7 @@ type HeadListener[ func NewHeadListener[ HTH htrktypes.Head[BLOCK_HASH, ID], S types.Subscription, - ID txmgrtypes.ID, + ID types.ID, BLOCK_HASH types.Hashable, CLIENT htrktypes.Client[HTH, S, ID, BLOCK_HASH], ]( diff --git a/common/headtracker/head_tracker.go b/common/headtracker/head_tracker.go index d0fec8adef9..4de7d93134e 100644 --- a/common/headtracker/head_tracker.go +++ b/common/headtracker/head_tracker.go @@ -13,8 +13,7 @@ import ( "golang.org/x/exp/maps" htrktypes "github.com/smartcontractkit/chainlink/v2/common/headtracker/types" - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" + "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/utils" @@ -37,13 +36,13 @@ const HeadsBufferSize = 10 type HeadTracker[ HTH htrktypes.Head[BLOCK_HASH, ID], - S commontypes.Subscription, - ID txmgrtypes.ID, - BLOCK_HASH commontypes.Hashable, + S types.Subscription, + ID types.ID, + BLOCK_HASH types.Hashable, ] struct { log logger.Logger - headBroadcaster commontypes.HeadBroadcaster[HTH, BLOCK_HASH] - headSaver commontypes.HeadSaver[HTH, BLOCK_HASH] + headBroadcaster types.HeadBroadcaster[HTH, BLOCK_HASH] + headSaver types.HeadSaver[HTH, BLOCK_HASH] mailMon *utils.MailboxMonitor client htrktypes.Client[HTH, S, ID, BLOCK_HASH] chainID ID @@ -52,7 +51,7 @@ type HeadTracker[ backfillMB *utils.Mailbox[HTH] broadcastMB *utils.Mailbox[HTH] - headListener commontypes.HeadListener[HTH, BLOCK_HASH] + headListener types.HeadListener[HTH, BLOCK_HASH] chStop utils.StopChan wgDone sync.WaitGroup utils.StartStopOnce @@ -62,19 +61,19 @@ type HeadTracker[ // NewHeadTracker instantiates a new HeadTracker using HeadSaver to persist new block numbers. func NewHeadTracker[ HTH htrktypes.Head[BLOCK_HASH, ID], - S commontypes.Subscription, - ID txmgrtypes.ID, - BLOCK_HASH commontypes.Hashable, + S types.Subscription, + ID types.ID, + BLOCK_HASH types.Hashable, ]( lggr logger.Logger, client htrktypes.Client[HTH, S, ID, BLOCK_HASH], config htrktypes.Config, htConfig htrktypes.HeadTrackerConfig, - headBroadcaster commontypes.HeadBroadcaster[HTH, BLOCK_HASH], - headSaver commontypes.HeadSaver[HTH, BLOCK_HASH], + headBroadcaster types.HeadBroadcaster[HTH, BLOCK_HASH], + headSaver types.HeadSaver[HTH, BLOCK_HASH], mailMon *utils.MailboxMonitor, getNilHead func() HTH, -) commontypes.HeadTracker[HTH, BLOCK_HASH] { +) types.HeadTracker[HTH, BLOCK_HASH] { chStop := make(chan struct{}) lggr = lggr.Named("HeadTracker") return &HeadTracker[HTH, S, ID, BLOCK_HASH]{ @@ -305,7 +304,7 @@ func (ht *HeadTracker[HTH, S, ID, BLOCK_HASH]) backfillLoop() { } // backfill fetches all missing heads up until the base height -func (ht *HeadTracker[HTH, S, ID, BLOCK_HASH]) backfill(ctx context.Context, head commontypes.Head[BLOCK_HASH], baseHeight int64) (err error) { +func (ht *HeadTracker[HTH, S, ID, BLOCK_HASH]) backfill(ctx context.Context, head types.Head[BLOCK_HASH], baseHeight int64) (err error) { headBlockNumber := head.BlockNumber() if headBlockNumber <= baseHeight { return nil diff --git a/common/headtracker/types/client.go b/common/headtracker/types/client.go index 3c49dc8cacc..53962954377 100644 --- a/common/headtracker/types/client.go +++ b/common/headtracker/types/client.go @@ -4,11 +4,10 @@ import ( "context" "math/big" - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" + "github.com/smartcontractkit/chainlink/v2/common/types" ) -type Client[H commontypes.Head[BLOCK_HASH], S commontypes.Subscription, ID txmgrtypes.ID, BLOCK_HASH commontypes.Hashable] interface { +type Client[H types.Head[BLOCK_HASH], S types.Subscription, ID types.ID, BLOCK_HASH types.Hashable] interface { HeadByNumber(ctx context.Context, number *big.Int) (head H, err error) // ConfiguredChainID returns the chain ID that the node is configured to connect to ConfiguredChainID() (id ID) diff --git a/common/headtracker/types/head.go b/common/headtracker/types/head.go index 0dc5b43b772..c2d7e262ac7 100644 --- a/common/headtracker/types/head.go +++ b/common/headtracker/types/head.go @@ -1,12 +1,11 @@ package types import ( - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" "github.com/smartcontractkit/chainlink/v2/common/types" ) //go:generate mockery --quiet --name Head --output ./mocks/ --case=underscore -type Head[BLOCK_HASH types.Hashable, CHAIN_ID txmgrtypes.ID] interface { +type Head[BLOCK_HASH types.Hashable, CHAIN_ID types.ID] interface { types.Head[BLOCK_HASH] // ChainID returns the chain ID that the head is for ChainID() CHAIN_ID diff --git a/common/txmgr/broadcaster.go b/common/txmgr/broadcaster.go index 8a028cf0e83..fd60f3452a4 100644 --- a/common/txmgr/broadcaster.go +++ b/common/txmgr/broadcaster.go @@ -57,10 +57,10 @@ type ProcessUnstartedTxs[ADDR types.Hashable] func(ctx context.Context, fromAddr // TransmitCheckerFactory creates a transmit checker based on a spec. type TransmitCheckerFactory[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] interface { // BuildChecker builds a new TransmitChecker based on the given spec. @@ -69,10 +69,10 @@ type TransmitCheckerFactory[ // TransmitChecker determines whether a transaction should be submitted on-chain. type TransmitChecker[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] interface { @@ -97,12 +97,12 @@ type TransmitChecker[ // - transition of eth_txes out of unstarted into either fatal_error or unconfirmed // - existence of a saved eth_tx_attempt type Broadcaster[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, HEAD types.Head[BLOCK_HASH], ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { logger logger.Logger @@ -146,12 +146,12 @@ type Broadcaster[ } func NewBroadcaster[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, HEAD types.Head[BLOCK_HASH], ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ]( txStore txmgrtypes.TransactionStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, SEQ, FEE], @@ -767,7 +767,7 @@ func (eb *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) incr return eb.ks.IncrementNextSequence(address, eb.chainID, currentSequence, qopts...) } -func observeTimeUntilBroadcast[CHAIN_ID txmgrtypes.ID](chainID CHAIN_ID, createdAt, broadcastAt time.Time) { +func observeTimeUntilBroadcast[CHAIN_ID types.ID](chainID CHAIN_ID, createdAt, broadcastAt time.Time) { duration := float64(broadcastAt.Sub(createdAt)) promTimeUntilBroadcast.WithLabelValues(chainID.String()).Observe(duration) } diff --git a/common/txmgr/confirmer.go b/common/txmgr/confirmer.go index 707675bbf59..19f3636a466 100644 --- a/common/txmgr/confirmer.go +++ b/common/txmgr/confirmer.go @@ -104,13 +104,13 @@ var ( // Step 3: See if any transactions have exceeded the gas bumping block threshold and, if so, bump them // Step 4: Check confirmed transactions to make sure they are still in the longest chain (reorg protection) type Confirmer[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ] struct { utils.StartStopOnce @@ -140,13 +140,13 @@ type Confirmer[ } func NewConfirmer[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ]( txStore txmgrtypes.TxStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, R, SEQ, FEE], @@ -953,10 +953,10 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Ens } func hasReceiptInLongestChain[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, ADDR commontypes.Hashable, TX_HASH, BLOCK_HASH commontypes.Hashable, - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ](etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], head commontypes.Head[BLOCK_HASH]) bool { for { @@ -1109,11 +1109,11 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Res // observeUntilTxConfirmed observes the promBlocksUntilTxConfirmed metric for each confirmed // transaction. func observeUntilTxConfirmed[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, ADDR commontypes.Hashable, TX_HASH, BLOCK_HASH commontypes.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ](chainID CHAIN_ID, attempts []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], receipts []R) { for _, attempt := range attempts { diff --git a/common/txmgr/reaper.go b/common/txmgr/reaper.go index a72c9f94388..1d856c014ce 100644 --- a/common/txmgr/reaper.go +++ b/common/txmgr/reaper.go @@ -6,12 +6,13 @@ import ( "time" txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" + "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/utils" ) // Reaper handles periodic database cleanup for Txm -type Reaper[CHAIN_ID txmgrtypes.ID] struct { +type Reaper[CHAIN_ID types.ID] struct { store txmgrtypes.TxHistoryReaper[CHAIN_ID] config txmgrtypes.ReaperChainConfig txConfig txmgrtypes.ReaperTransactionsConfig @@ -24,7 +25,7 @@ type Reaper[CHAIN_ID txmgrtypes.ID] struct { } // NewReaper instantiates a new reaper object -func NewReaper[CHAIN_ID txmgrtypes.ID](lggr logger.Logger, store txmgrtypes.TxHistoryReaper[CHAIN_ID], config txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig, chainID CHAIN_ID) *Reaper[CHAIN_ID] { +func NewReaper[CHAIN_ID types.ID](lggr logger.Logger, store txmgrtypes.TxHistoryReaper[CHAIN_ID], config txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig, chainID CHAIN_ID) *Reaper[CHAIN_ID] { r := &Reaper[CHAIN_ID]{ store, config, diff --git a/common/txmgr/resender.go b/common/txmgr/resender.go index 5f1352727d2..e1a4bec7d1b 100644 --- a/common/txmgr/resender.go +++ b/common/txmgr/resender.go @@ -37,11 +37,11 @@ const ( // can occasionally be problems with this (e.g. abnormally long block times, or // if gas bumping is disabled) type Resender[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { txStore txmgrtypes.TransactionStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, SEQ, FEE] @@ -60,11 +60,11 @@ type Resender[ } func NewResender[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ]( lggr logger.Logger, @@ -198,10 +198,10 @@ func (er *Resender[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) logStuckAttem } func findOldestUnconfirmedAttempt[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH, BLOCK_HASH types.Hashable, - SEQ txmgrtypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ](attempts []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], bool) { var oldestAttempt txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index 2b6b03ef71d..ef68994fbd3 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -31,12 +31,12 @@ type ResumeCallback func(id uuid.UUID, result interface{}, err error) error // //go:generate mockery --quiet --recursive --name TxManager --output ./mocks/ --case=underscore --structname TxManager --filename tx_manager.go type TxManager[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ] interface { commontypes.HeadTrackable[HEAD, BLOCK_HASH] @@ -59,13 +59,13 @@ type reset struct { } type Txm[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ] struct { utils.StartStopOnce @@ -103,13 +103,13 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) RegisterRe // NewTxm creates a new Txm with the given configuration. func NewTxm[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ]( chainId CHAIN_ID, @@ -498,11 +498,11 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) SendNative } type NullTxManager[ - CHAIN_ID txmgrtypes.ID, + CHAIN_ID commontypes.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH, BLOCK_HASH commontypes.Hashable, - SEQ txmgrtypes.Sequence, + SEQ commontypes.Sequence, FEE feetypes.Fee, ] struct { ErrMsg string diff --git a/common/txmgr/types/client.go b/common/txmgr/types/client.go index cd3ec49a1a5..246bc576e01 100644 --- a/common/txmgr/types/client.go +++ b/common/txmgr/types/client.go @@ -12,64 +12,14 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" ) -// A generic client interface for communication with the RPC node -// Every native chain must implement independently -type Client[ - CHAINID ID, - SEQ Sequence, - ADDR types.Hashable, - BLOCK any, - BLOCKHASH types.Hashable, - TX any, - TXHASH types.Hashable, - TXRECEIPT any, - EVENT any, - EVENTOPS any, // event filter query options -] interface { - // ChainID stored for quick access - ConfiguredChainID() CHAINID - // ChainID RPC call - ChainID() (CHAINID, error) - - Accounts[ADDR, SEQ] - Transactions[TX, TXHASH, TXRECEIPT] - Events[EVENT, EVENTOPS] - Blocks[BLOCK, BLOCKHASH] - - CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error -} - -type Accounts[ADDR types.Hashable, SEQ Sequence] interface { - BalanceAt(ctx context.Context, accountAddress ADDR, blockNumber *big.Int) (*big.Int, error) - TokenBalance(ctx context.Context, accountAddress ADDR, tokenAddress ADDR) (*big.Int, error) - SequenceAt(ctx context.Context, accountAddress ADDR, blockNumber *big.Int) (SEQ, error) -} - -type Transactions[TX any, TXHASH types.Hashable, TXRECEIPT any] interface { - SendTransaction(ctx context.Context, tx *TX) error - SimulateTransaction(ctx context.Context, tx *TX) error - TransactionByHash(ctx context.Context, txHash TXHASH) (*TX, error) - TransactionReceipt(ctx context.Context, txHash TXHASH) (*TXRECEIPT, error) -} - -type Blocks[BLOCK any, BLOCKHASH types.Hashable] interface { - BlockByNumber(ctx context.Context, number *big.Int) (*BLOCK, error) - BlockByHash(ctx context.Context, hash BLOCKHASH) (*BLOCK, error) - LatestBlockHeight(context.Context) (*big.Int, error) -} - -type Events[EVENT any, EVENTOPS any] interface { - FilterEvents(ctx context.Context, query EVENTOPS) ([]EVENT, error) -} - // TxmClient is a superset of all the methods needed for the txm type TxmClient[ - CHAIN_ID ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, R ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] interface { ChainClient[CHAIN_ID, ADDR, SEQ] @@ -84,11 +34,11 @@ type TxmClient[ // TransactionClient contains the methods for building, simulating, broadcasting transactions type TransactionClient[ - CHAIN_ID ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, - SEQ Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] interface { ChainClient[CHAIN_ID, ADDR, SEQ] @@ -123,9 +73,9 @@ type TransactionClient[ // ChainClient contains the interfaces for reading chain parameters (chain id, sequences, etc) type ChainClient[ - CHAIN_ID ID, + CHAIN_ID types.ID, ADDR types.Hashable, - SEQ Sequence, + SEQ types.Sequence, ] interface { ConfiguredChainID() CHAIN_ID PendingSequenceAt(ctx context.Context, addr ADDR) (SEQ, error) diff --git a/common/txmgr/types/keystore.go b/common/txmgr/types/keystore.go index 30b5700d39f..4793e6579ad 100644 --- a/common/txmgr/types/keystore.go +++ b/common/txmgr/types/keystore.go @@ -12,9 +12,9 @@ type KeyStore[ // Account Address type. ADDR types.Hashable, // Chain ID type - CHAIN_ID ID, + CHAIN_ID types.ID, // Chain's sequence type. For example, EVM chains use nonce, bitcoin uses UTXO. - SEQ Sequence, + SEQ types.Sequence, ] interface { CheckEnabled(address ADDR, chainID CHAIN_ID) error NextSequence(address ADDR, chainID CHAIN_ID, qopts ...pg.QOpt) (SEQ, error) diff --git a/common/txmgr/types/mocks/key_store.go b/common/txmgr/types/mocks/key_store.go index b60ab969f51..05984ae3306 100644 --- a/common/txmgr/types/mocks/key_store.go +++ b/common/txmgr/types/mocks/key_store.go @@ -141,7 +141,7 @@ type mockConstructorTestingTNewKeyStore interface { } // NewKeyStore creates a new instance of KeyStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewKeyStore[ADDR types.Hashable, CHAIN_ID txmgrtypes.ID, SEQ txmgrtypes.Sequence](t mockConstructorTestingTNewKeyStore) *KeyStore[ADDR, CHAIN_ID, SEQ] { +func NewKeyStore[ADDR types.Hashable, CHAIN_ID types.ID, SEQ types.Sequence](t mockConstructorTestingTNewKeyStore) *KeyStore[ADDR, CHAIN_ID, SEQ] { mock := &KeyStore[ADDR, CHAIN_ID, SEQ]{} mock.Mock.Test(t) diff --git a/common/txmgr/types/tx.go b/common/txmgr/types/tx.go index e8bf72105d2..0f005b397bc 100644 --- a/common/txmgr/types/tx.go +++ b/common/txmgr/types/tx.go @@ -116,10 +116,10 @@ type TxMeta[ADDR types.Hashable, TX_HASH types.Hashable] struct { } type TxAttempt[ - CHAIN_ID ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH, BLOCK_HASH types.Hashable, - SEQ Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { ID int64 @@ -142,10 +142,10 @@ func (a *TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) String() stri } type Tx[ - CHAIN_ID ID, + CHAIN_ID types.ID, ADDR types.Hashable, TX_HASH, BLOCK_HASH types.Hashable, - SEQ Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { ID int64 diff --git a/common/txmgr/types/tx_attempt_builder.go b/common/txmgr/types/tx_attempt_builder.go index 0ef796f50f9..887219c490e 100644 --- a/common/txmgr/types/tx_attempt_builder.go +++ b/common/txmgr/types/tx_attempt_builder.go @@ -15,11 +15,11 @@ import ( // //go:generate mockery --quiet --name TxAttemptBuilder --output ./mocks/ --case=underscore type TxAttemptBuilder[ - CHAIN_ID ID, // CHAIN_ID - chain id type + CHAIN_ID types.ID, // CHAIN_ID - chain id type HEAD types.Head[BLOCK_HASH], // HEAD - chain head type ADDR types.Hashable, // ADDR - chain address type TX_HASH, BLOCK_HASH types.Hashable, // various chain hash types - SEQ Sequence, // SEQ - chain sequence type (nonce, utxo, etc) + SEQ types.Sequence, // SEQ - chain sequence type (nonce, utxo, etc) FEE feetypes.Fee, // FEE - chain fee type ] interface { // interfaces for running the underlying estimator diff --git a/common/txmgr/types/tx_store.go b/common/txmgr/types/tx_store.go index a2a479a40eb..41a989fc769 100644 --- a/common/txmgr/types/tx_store.go +++ b/common/txmgr/types/tx_store.go @@ -19,7 +19,7 @@ type TxStore[ // Represents an account address, in native chain format. ADDR types.Hashable, // Represents a chain id to be used for the chain. - CHAIN_ID ID, + CHAIN_ID types.ID, // Represents a unique Tx Hash for a chain TX_HASH types.Hashable, // Represents a unique Block Hash for a chain @@ -27,7 +27,7 @@ type TxStore[ // Represents a onchain receipt object that a chain's RPC returns R ChainReceipt[TX_HASH, BLOCK_HASH], // Represents the sequence type for a chain. For example, nonce for EVM. - SEQ Sequence, + SEQ types.Sequence, // Represents the chain specific fee type FEE feetypes.Fee, ] interface { @@ -49,10 +49,10 @@ type TxStore[ // TransactionStore contains the persistence layer methods needed to manage Txs and TxAttempts type TransactionStore[ ADDR types.Hashable, - CHAIN_ID ID, + CHAIN_ID types.ID, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, - SEQ Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] interface { CountUnconfirmedTransactions(fromAddress ADDR, chainID CHAIN_ID, qopts ...pg.QOpt) (count uint32, err error) @@ -88,7 +88,7 @@ type TransactionStore[ UpdateTxForRebroadcast(etx Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], etxAttempt TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) error } -type TxHistoryReaper[CHAIN_ID ID] interface { +type TxHistoryReaper[CHAIN_ID types.ID] interface { ReapTxHistory(minBlockNumberToKeep int64, timeThreshold time.Time, chainID CHAIN_ID) error } @@ -98,8 +98,8 @@ type UnstartedTxQueuePruner interface { type SequenceStore[ ADDR types.Hashable, - CHAIN_ID ID, - SEQ Sequence, + CHAIN_ID types.ID, + SEQ types.Sequence, ] interface { UpdateKeyNextSequence(newNextSequence, currentNextSequence SEQ, address ADDR, chainID CHAIN_ID, qopts ...pg.QOpt) error } diff --git a/common/txmgr/types/chain.go b/common/types/chain.go similarity index 100% rename from common/txmgr/types/chain.go rename to common/types/chain.go diff --git a/common/types/client.go b/common/types/client.go new file mode 100644 index 00000000000..a3f89a3155b --- /dev/null +++ b/common/types/client.go @@ -0,0 +1,56 @@ +package types + +import ( + "context" + "math/big" +) + +// A generic client interface for communication with the RPC node +// Every native chain must implement independently +type Client[ + CHAINID ID, + SEQ Sequence, + ADDR Hashable, + BLOCK any, + BLOCKHASH Hashable, + TX any, + TXHASH Hashable, + TXRECEIPT any, + EVENT any, + EVENTOPS any, // event filter query options +] interface { + // ChainID stored for quick access + ConfiguredChainID() CHAINID + // ChainID RPC call + ChainID() (CHAINID, error) + + Accounts[ADDR, SEQ] + Transactions[TX, TXHASH, TXRECEIPT] + Events[EVENT, EVENTOPS] + Blocks[BLOCK, BLOCKHASH] + + CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error +} + +type Accounts[ADDR Hashable, SEQ Sequence] interface { + BalanceAt(ctx context.Context, accountAddress ADDR, blockNumber *big.Int) (*big.Int, error) + TokenBalance(ctx context.Context, accountAddress ADDR, tokenAddress ADDR) (*big.Int, error) + SequenceAt(ctx context.Context, accountAddress ADDR, blockNumber *big.Int) (SEQ, error) +} + +type Transactions[TX any, TXHASH Hashable, TXRECEIPT any] interface { + SendTransaction(ctx context.Context, tx *TX) error + SimulateTransaction(ctx context.Context, tx *TX) error + TransactionByHash(ctx context.Context, txHash TXHASH) (*TX, error) + TransactionReceipt(ctx context.Context, txHash TXHASH) (*TXRECEIPT, error) +} + +type Blocks[BLOCK any, BLOCKHASH Hashable] interface { + BlockByNumber(ctx context.Context, number *big.Int) (*BLOCK, error) + BlockByHash(ctx context.Context, hash BLOCKHASH) (*BLOCK, error) + LatestBlockHeight(context.Context) (*big.Int, error) +} + +type Events[EVENT any, EVENTOPS any] interface { + FilterEvents(ctx context.Context, query EVENTOPS) ([]EVENT, error) +} From 9cbd5b74acf95e306628ab81f845f0683c90cb62 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 09:30:53 -0700 Subject: [PATCH 3/7] updated mocks --- common/headtracker/types/mocks/head.go | 5 +- common/txmgr/mocks/tx_manager.go | 33 ++++--- common/txmgr/types/mocks/key_store.go | 3 +- .../txmgr/types/mocks/tx_attempt_builder.go | 89 +++++++++---------- common/txmgr/types/mocks/tx_store.go | 4 +- 5 files changed, 65 insertions(+), 69 deletions(-) diff --git a/common/headtracker/types/mocks/head.go b/common/headtracker/types/mocks/head.go index 8d63aab7f32..ac83705208b 100644 --- a/common/headtracker/types/mocks/head.go +++ b/common/headtracker/types/mocks/head.go @@ -3,13 +3,12 @@ package mocks import ( - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" types "github.com/smartcontractkit/chainlink/v2/common/types" mock "github.com/stretchr/testify/mock" ) // Head is an autogenerated mock type for the Head type -type Head[BLOCK_HASH types.Hashable, CHAIN_ID txmgrtypes.ID] struct { +type Head[BLOCK_HASH types.Hashable, CHAIN_ID types.ID] struct { mock.Mock } @@ -163,7 +162,7 @@ type mockConstructorTestingTNewHead interface { } // NewHead creates a new instance of Head. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewHead[BLOCK_HASH types.Hashable, CHAIN_ID txmgrtypes.ID](t mockConstructorTestingTNewHead) *Head[BLOCK_HASH, CHAIN_ID] { +func NewHead[BLOCK_HASH types.Hashable, CHAIN_ID types.ID](t mockConstructorTestingTNewHead) *Head[BLOCK_HASH, CHAIN_ID] { mock := &Head[BLOCK_HASH, CHAIN_ID]{} mock.Mock.Test(t) diff --git a/common/txmgr/mocks/tx_manager.go b/common/txmgr/mocks/tx_manager.go index ab3b5a512d8..ae878c18a02 100644 --- a/common/txmgr/mocks/tx_manager.go +++ b/common/txmgr/mocks/tx_manager.go @@ -6,21 +6,20 @@ import ( context "context" big "math/big" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" - feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types" - mock "github.com/stretchr/testify/mock" pg "github.com/smartcontractkit/chainlink/v2/core/services/pg" txmgr "github.com/smartcontractkit/chainlink/v2/common/txmgr" - types "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" + txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" + + types "github.com/smartcontractkit/chainlink/v2/common/types" ) // TxManager is an autogenerated mock type for the TxManager type -type TxManager[CHAIN_ID types.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, SEQ types.Sequence, FEE feetypes.Fee] struct { +type TxManager[CHAIN_ID types.ID, HEAD types.Head[BLOCK_HASH], ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, SEQ types.Sequence, FEE feetypes.Fee] struct { mock.Mock } @@ -39,7 +38,7 @@ func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) Close( } // CreateTransaction provides a mock function with given fields: txRequest, qopts -func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) CreateTransaction(txRequest types.TxRequest[ADDR, TX_HASH], qopts ...pg.QOpt) (types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error) { +func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) CreateTransaction(txRequest txmgrtypes.TxRequest[ADDR, TX_HASH], qopts ...pg.QOpt) (txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error) { _va := make([]interface{}, len(qopts)) for _i := range qopts { _va[_i] = qopts[_i] @@ -49,18 +48,18 @@ func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) Create _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 error - if rf, ok := ret.Get(0).(func(types.TxRequest[ADDR, TX_HASH], ...pg.QOpt) (types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)); ok { + if rf, ok := ret.Get(0).(func(txmgrtypes.TxRequest[ADDR, TX_HASH], ...pg.QOpt) (txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)); ok { return rf(txRequest, qopts...) } - if rf, ok := ret.Get(0).(func(types.TxRequest[ADDR, TX_HASH], ...pg.QOpt) types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(txmgrtypes.TxRequest[ADDR, TX_HASH], ...pg.QOpt) txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(txRequest, qopts...) } else { - r0 = ret.Get(0).(types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } - if rf, ok := ret.Get(1).(func(types.TxRequest[ADDR, TX_HASH], ...pg.QOpt) error); ok { + if rf, ok := ret.Get(1).(func(txmgrtypes.TxRequest[ADDR, TX_HASH], ...pg.QOpt) error); ok { r1 = rf(txRequest, qopts...) } else { r1 = ret.Error(1) @@ -162,18 +161,18 @@ func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) Reset( } // SendNativeToken provides a mock function with given fields: chainID, from, to, value, gasLimit -func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) SendNativeToken(chainID CHAIN_ID, from ADDR, to ADDR, value big.Int, gasLimit uint32) (types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error) { +func (_m *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) SendNativeToken(chainID CHAIN_ID, from ADDR, to ADDR, value big.Int, gasLimit uint32) (txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error) { ret := _m.Called(chainID, from, to, value, gasLimit) - var r0 types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 error - if rf, ok := ret.Get(0).(func(CHAIN_ID, ADDR, ADDR, big.Int, uint32) (types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)); ok { + if rf, ok := ret.Get(0).(func(CHAIN_ID, ADDR, ADDR, big.Int, uint32) (txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)); ok { return rf(chainID, from, to, value, gasLimit) } - if rf, ok := ret.Get(0).(func(CHAIN_ID, ADDR, ADDR, big.Int, uint32) types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(CHAIN_ID, ADDR, ADDR, big.Int, uint32) txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(chainID, from, to, value, gasLimit) } else { - r0 = ret.Get(0).(types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } if rf, ok := ret.Get(1).(func(CHAIN_ID, ADDR, ADDR, big.Int, uint32) error); ok { @@ -210,7 +209,7 @@ type mockConstructorTestingTNewTxManager interface { } // NewTxManager creates a new instance of TxManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewTxManager[CHAIN_ID types.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, SEQ types.Sequence, FEE feetypes.Fee](t mockConstructorTestingTNewTxManager) *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] { +func NewTxManager[CHAIN_ID types.ID, HEAD types.Head[BLOCK_HASH], ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, SEQ types.Sequence, FEE feetypes.Fee](t mockConstructorTestingTNewTxManager) *TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] { mock := &TxManager[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]{} mock.Mock.Test(t) diff --git a/common/txmgr/types/mocks/key_store.go b/common/txmgr/types/mocks/key_store.go index 05984ae3306..90d8040f3e4 100644 --- a/common/txmgr/types/mocks/key_store.go +++ b/common/txmgr/types/mocks/key_store.go @@ -3,7 +3,6 @@ package mocks import ( - txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" pg "github.com/smartcontractkit/chainlink/v2/core/services/pg" mock "github.com/stretchr/testify/mock" @@ -11,7 +10,7 @@ import ( ) // KeyStore is an autogenerated mock type for the KeyStore type -type KeyStore[ADDR types.Hashable, CHAIN_ID txmgrtypes.ID, SEQ txmgrtypes.Sequence] struct { +type KeyStore[ADDR types.Hashable, CHAIN_ID types.ID, SEQ types.Sequence] struct { mock.Mock } diff --git a/common/txmgr/types/mocks/tx_attempt_builder.go b/common/txmgr/types/mocks/tx_attempt_builder.go index 8284431f413..cda71cfae09 100644 --- a/common/txmgr/types/mocks/tx_attempt_builder.go +++ b/common/txmgr/types/mocks/tx_attempt_builder.go @@ -5,19 +5,18 @@ package mocks import ( context "context" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" - feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types" - logger "github.com/smartcontractkit/chainlink/v2/core/logger" mock "github.com/stretchr/testify/mock" - types "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" + txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" + + types "github.com/smartcontractkit/chainlink/v2/common/types" ) // TxAttemptBuilder is an autogenerated mock type for the TxAttemptBuilder type -type TxAttemptBuilder[CHAIN_ID types.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, SEQ types.Sequence, FEE feetypes.Fee] struct { +type TxAttemptBuilder[CHAIN_ID types.ID, HEAD types.Head[BLOCK_HASH], ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, SEQ types.Sequence, FEE feetypes.Fee] struct { mock.Mock } @@ -66,42 +65,42 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } // NewBumpTxAttempt provides a mock function with given fields: ctx, tx, previousAttempt, priorAttempts, lggr -func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewBumpTxAttempt(ctx context.Context, tx types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], previousAttempt types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], priorAttempts []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], lggr logger.Logger) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error) { +func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewBumpTxAttempt(ctx context.Context, tx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], previousAttempt txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], priorAttempts []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], lggr logger.Logger) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error) { ret := _m.Called(ctx, tx, previousAttempt, priorAttempts, lggr) - var r0 types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 FEE var r2 uint32 var r3 bool var r4 error - if rf, ok := ret.Get(0).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error)); ok { return rf(ctx, tx, previousAttempt, priorAttempts, lggr) } - if rf, ok := ret.Get(0).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(ctx, tx, previousAttempt, priorAttempts, lggr) } else { - r0 = ret.Get(0).(types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } - if rf, ok := ret.Get(1).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) FEE); ok { + if rf, ok := ret.Get(1).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) FEE); ok { r1 = rf(ctx, tx, previousAttempt, priorAttempts, lggr) } else { r1 = ret.Get(1).(FEE) } - if rf, ok := ret.Get(2).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) uint32); ok { + if rf, ok := ret.Get(2).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) uint32); ok { r2 = rf(ctx, tx, previousAttempt, priorAttempts, lggr) } else { r2 = ret.Get(2).(uint32) } - if rf, ok := ret.Get(3).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) bool); ok { + if rf, ok := ret.Get(3).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) bool); ok { r3 = rf(ctx, tx, previousAttempt, priorAttempts, lggr) } else { r3 = ret.Get(3).(bool) } - if rf, ok := ret.Get(4).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) error); ok { + if rf, ok := ret.Get(4).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger) error); ok { r4 = rf(ctx, tx, previousAttempt, priorAttempts, lggr) } else { r4 = ret.Error(4) @@ -111,28 +110,28 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } // NewCustomTxAttempt provides a mock function with given fields: tx, fee, gasLimit, txType, lggr -func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewCustomTxAttempt(tx types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], fee FEE, gasLimit uint32, txType int, lggr logger.Logger) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], bool, error) { +func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewCustomTxAttempt(tx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], fee FEE, gasLimit uint32, txType int, lggr logger.Logger) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], bool, error) { ret := _m.Called(tx, fee, gasLimit, txType, lggr) - var r0 types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 bool var r2 error - if rf, ok := ret.Get(0).(func(types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], bool, error)); ok { + if rf, ok := ret.Get(0).(func(txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], bool, error)); ok { return rf(tx, fee, gasLimit, txType, lggr) } - if rf, ok := ret.Get(0).(func(types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(tx, fee, gasLimit, txType, lggr) } else { - r0 = ret.Get(0).(types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } - if rf, ok := ret.Get(1).(func(types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) bool); ok { + if rf, ok := ret.Get(1).(func(txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) bool); ok { r1 = rf(tx, fee, gasLimit, txType, lggr) } else { r1 = ret.Get(1).(bool) } - if rf, ok := ret.Get(2).(func(types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) error); ok { + if rf, ok := ret.Get(2).(func(txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, int, logger.Logger) error); ok { r2 = rf(tx, fee, gasLimit, txType, lggr) } else { r2 = ret.Error(2) @@ -142,18 +141,18 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } // NewEmptyTxAttempt provides a mock function with given fields: seq, feeLimit, fee, fromAddress -func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewEmptyTxAttempt(seq SEQ, feeLimit uint32, fee FEE, fromAddress ADDR) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error) { +func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewEmptyTxAttempt(seq SEQ, feeLimit uint32, fee FEE, fromAddress ADDR) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error) { ret := _m.Called(seq, feeLimit, fee, fromAddress) - var r0 types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 error - if rf, ok := ret.Get(0).(func(SEQ, uint32, FEE, ADDR) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)); ok { + if rf, ok := ret.Get(0).(func(SEQ, uint32, FEE, ADDR) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)); ok { return rf(seq, feeLimit, fee, fromAddress) } - if rf, ok := ret.Get(0).(func(SEQ, uint32, FEE, ADDR) types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(SEQ, uint32, FEE, ADDR) txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(seq, feeLimit, fee, fromAddress) } else { - r0 = ret.Get(0).(types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } if rf, ok := ret.Get(1).(func(SEQ, uint32, FEE, ADDR) error); ok { @@ -166,7 +165,7 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } // NewTxAttempt provides a mock function with given fields: ctx, tx, lggr, opts -func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewTxAttempt(ctx context.Context, tx types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], lggr logger.Logger, opts ...feetypes.Opt) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error) { +func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewTxAttempt(ctx context.Context, tx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], lggr logger.Logger, opts ...feetypes.Opt) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error) { _va := make([]interface{}, len(opts)) for _i := range opts { _va[_i] = opts[_i] @@ -176,39 +175,39 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 FEE var r2 uint32 var r3 bool var r4 error - if rf, ok := ret.Get(0).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error)); ok { return rf(ctx, tx, lggr, opts...) } - if rf, ok := ret.Get(0).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(ctx, tx, lggr, opts...) } else { - r0 = ret.Get(0).(types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } - if rf, ok := ret.Get(1).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) FEE); ok { + if rf, ok := ret.Get(1).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) FEE); ok { r1 = rf(ctx, tx, lggr, opts...) } else { r1 = ret.Get(1).(FEE) } - if rf, ok := ret.Get(2).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) uint32); ok { + if rf, ok := ret.Get(2).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) uint32); ok { r2 = rf(ctx, tx, lggr, opts...) } else { r2 = ret.Get(2).(uint32) } - if rf, ok := ret.Get(3).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) bool); ok { + if rf, ok := ret.Get(3).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) bool); ok { r3 = rf(ctx, tx, lggr, opts...) } else { r3 = ret.Get(3).(bool) } - if rf, ok := ret.Get(4).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) error); ok { + if rf, ok := ret.Get(4).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, ...feetypes.Opt) error); ok { r4 = rf(ctx, tx, lggr, opts...) } else { r4 = ret.Error(4) @@ -218,7 +217,7 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } // NewTxAttemptWithType provides a mock function with given fields: ctx, tx, lggr, txType, opts -func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewTxAttemptWithType(ctx context.Context, tx types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], lggr logger.Logger, txType int, opts ...feetypes.Opt) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error) { +func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) NewTxAttemptWithType(ctx context.Context, tx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], lggr logger.Logger, txType int, opts ...feetypes.Opt) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error) { _va := make([]interface{}, len(opts)) for _i := range opts { _va[_i] = opts[_i] @@ -228,39 +227,39 @@ func (_m *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] + var r0 txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] var r1 FEE var r2 uint32 var r3 bool var r4 error - if rf, ok := ret.Get(0).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) (types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) (txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], FEE, uint32, bool, error)); ok { return rf(ctx, tx, lggr, txType, opts...) } - if rf, ok := ret.Get(0).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { + if rf, ok := ret.Get(0).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]); ok { r0 = rf(ctx, tx, lggr, txType, opts...) } else { - r0 = ret.Get(0).(types.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) + r0 = ret.Get(0).(txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) } - if rf, ok := ret.Get(1).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) FEE); ok { + if rf, ok := ret.Get(1).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) FEE); ok { r1 = rf(ctx, tx, lggr, txType, opts...) } else { r1 = ret.Get(1).(FEE) } - if rf, ok := ret.Get(2).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) uint32); ok { + if rf, ok := ret.Get(2).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) uint32); ok { r2 = rf(ctx, tx, lggr, txType, opts...) } else { r2 = ret.Get(2).(uint32) } - if rf, ok := ret.Get(3).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) bool); ok { + if rf, ok := ret.Get(3).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) bool); ok { r3 = rf(ctx, tx, lggr, txType, opts...) } else { r3 = ret.Get(3).(bool) } - if rf, ok := ret.Get(4).(func(context.Context, types.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) error); ok { + if rf, ok := ret.Get(4).(func(context.Context, txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], logger.Logger, int, ...feetypes.Opt) error); ok { r4 = rf(ctx, tx, lggr, txType, opts...) } else { r4 = ret.Error(4) @@ -308,7 +307,7 @@ type mockConstructorTestingTNewTxAttemptBuilder interface { } // NewTxAttemptBuilder creates a new instance of TxAttemptBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewTxAttemptBuilder[CHAIN_ID types.ID, HEAD commontypes.Head[BLOCK_HASH], ADDR commontypes.Hashable, TX_HASH commontypes.Hashable, BLOCK_HASH commontypes.Hashable, SEQ types.Sequence, FEE feetypes.Fee](t mockConstructorTestingTNewTxAttemptBuilder) *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] { +func NewTxAttemptBuilder[CHAIN_ID types.ID, HEAD types.Head[BLOCK_HASH], ADDR types.Hashable, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, SEQ types.Sequence, FEE feetypes.Fee](t mockConstructorTestingTNewTxAttemptBuilder) *TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE] { mock := &TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]{} mock.Mock.Test(t) diff --git a/common/txmgr/types/mocks/tx_store.go b/common/txmgr/types/mocks/tx_store.go index ee8b405881a..055d7852bfd 100644 --- a/common/txmgr/types/mocks/tx_store.go +++ b/common/txmgr/types/mocks/tx_store.go @@ -20,7 +20,7 @@ import ( ) // TxStore is an autogenerated mock type for the TxStore type -type TxStore[ADDR types.Hashable, CHAIN_ID txmgrtypes.ID, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], SEQ txmgrtypes.Sequence, FEE feetypes.Fee] struct { +type TxStore[ADDR types.Hashable, CHAIN_ID types.ID, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], SEQ types.Sequence, FEE feetypes.Fee] struct { mock.Mock } @@ -856,7 +856,7 @@ type mockConstructorTestingTNewTxStore interface { } // NewTxStore creates a new instance of TxStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewTxStore[ADDR types.Hashable, CHAIN_ID txmgrtypes.ID, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], SEQ txmgrtypes.Sequence, FEE feetypes.Fee](t mockConstructorTestingTNewTxStore) *TxStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, R, SEQ, FEE] { +func NewTxStore[ADDR types.Hashable, CHAIN_ID types.ID, TX_HASH types.Hashable, BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], SEQ types.Sequence, FEE feetypes.Fee](t mockConstructorTestingTNewTxStore) *TxStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, R, SEQ, FEE] { mock := &TxStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, R, SEQ, FEE]{} mock.Mock.Test(t) From 810b1220bec28a92b28cb3bd0edb55ac4ad89554 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 09:41:17 -0700 Subject: [PATCH 4/7] Added concrete interface of methods in evm client --- core/chains/evm/client/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/chains/evm/client/client.go b/core/chains/evm/client/client.go index 87768e3543f..d80b343d977 100644 --- a/core/chains/evm/client/client.go +++ b/core/chains/evm/client/client.go @@ -30,6 +30,10 @@ const queryTimeout = 10 * time.Second // Client is the interface used to interact with an ethereum node. type Client interface { commontypes.Client[*big.Int, evmtypes.Nonce, common.Address, types.Block, common.Hash, types.Transaction, common.Hash, types.Receipt, types.Log, ethereum.FilterQuery] + commontypes.Accounts[common.Address, evmtypes.Nonce] + commontypes.Transactions[types.Transaction, common.Hash, types.Receipt] + commontypes.Blocks[types.Block, common.Hash] + commontypes.Events[types.Log, ethereum.FilterQuery] Dial(ctx context.Context) error Close() From dd4e48caba653f17e02a7838392d5ffb4e9a85ef Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 10:39:41 -0700 Subject: [PATCH 5/7] renamed commontypes to types for headbroadcaster --- common/headtracker/head_broadcaster.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/headtracker/head_broadcaster.go b/common/headtracker/head_broadcaster.go index d31ff4f2008..704c71cf79b 100644 --- a/common/headtracker/head_broadcaster.go +++ b/common/headtracker/head_broadcaster.go @@ -7,24 +7,24 @@ import ( "sync" "time" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" + "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/utils" ) const TrackableCallbackTimeout = 2 * time.Second -type callbackSet[H commontypes.Head[BLOCK_HASH], BLOCK_HASH commontypes.Hashable] map[int]commontypes.HeadTrackable[H, BLOCK_HASH] +type callbackSet[H types.Head[BLOCK_HASH], BLOCK_HASH types.Hashable] map[int]types.HeadTrackable[H, BLOCK_HASH] -func (set callbackSet[H, BLOCK_HASH]) values() []commontypes.HeadTrackable[H, BLOCK_HASH] { - var values []commontypes.HeadTrackable[H, BLOCK_HASH] +func (set callbackSet[H, BLOCK_HASH]) values() []types.HeadTrackable[H, BLOCK_HASH] { + var values []types.HeadTrackable[H, BLOCK_HASH] for _, callback := range set { values = append(values, callback) } return values } -type HeadBroadcaster[H commontypes.Head[BLOCK_HASH], BLOCK_HASH commontypes.Hashable] struct { +type HeadBroadcaster[H types.Head[BLOCK_HASH], BLOCK_HASH types.Hashable] struct { logger logger.Logger callbacks callbackSet[H, BLOCK_HASH] mailbox *utils.Mailbox[H] @@ -38,8 +38,8 @@ type HeadBroadcaster[H commontypes.Head[BLOCK_HASH], BLOCK_HASH commontypes.Hash // NewHeadBroadcaster creates a new HeadBroadcaster func NewHeadBroadcaster[ - H commontypes.Head[BLOCK_HASH], - BLOCK_HASH commontypes.Hashable, + H types.Head[BLOCK_HASH], + BLOCK_HASH types.Hashable, ]( lggr logger.Logger, ) *HeadBroadcaster[H, BLOCK_HASH] { @@ -89,7 +89,7 @@ func (hb *HeadBroadcaster[H, BLOCK_HASH]) BroadcastNewLongestChain(head H) { // Subscribe subscribes to OnNewLongestChain and Connect until HeadBroadcaster is closed, // or unsubscribe callback is called explicitly -func (hb *HeadBroadcaster[H, BLOCK_HASH]) Subscribe(callback commontypes.HeadTrackable[H, BLOCK_HASH]) (currentLongestChain H, unsubscribe func()) { +func (hb *HeadBroadcaster[H, BLOCK_HASH]) Subscribe(callback types.HeadTrackable[H, BLOCK_HASH]) (currentLongestChain H, unsubscribe func()) { hb.mutex.Lock() defer hb.mutex.Unlock() @@ -147,7 +147,7 @@ func (hb *HeadBroadcaster[H, BLOCK_HASH]) executeCallbacks() { defer cancel() for _, callback := range callbacks { - go func(trackable commontypes.HeadTrackable[H, BLOCK_HASH]) { + go func(trackable types.HeadTrackable[H, BLOCK_HASH]) { defer wg.Done() start := time.Now() cctx, cancel := context.WithTimeout(ctx, TrackableCallbackTimeout) From d64e2804e035635d05d3b117d41f8458865d1cd2 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 11:02:34 -0700 Subject: [PATCH 6/7] removed redundent declaration of function in evm client --- core/chains/evm/client/client.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/chains/evm/client/client.go b/core/chains/evm/client/client.go index db9d449542a..a61db041821 100644 --- a/core/chains/evm/client/client.go +++ b/core/chains/evm/client/client.go @@ -30,10 +30,6 @@ const queryTimeout = 10 * time.Second // Client is the interface used to interact with an ethereum node. type Client interface { commontypes.Client[*big.Int, evmtypes.Nonce, common.Address, types.Block, common.Hash, types.Transaction, common.Hash, types.Receipt, types.Log, ethereum.FilterQuery] - commontypes.Accounts[common.Address, evmtypes.Nonce] - commontypes.Transactions[types.Transaction, common.Hash, types.Receipt] - commontypes.Blocks[types.Block, common.Hash] - commontypes.Events[types.Log, ethereum.FilterQuery] Dial(ctx context.Context) error Close() From c0e4ea8693e654f98fa8066f412c8c1f089a3cc7 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 20 Jun 2023 11:06:29 -0700 Subject: [PATCH 7/7] refactored commontypes to types for txmgr --- common/txmgr/confirmer.go | 54 +++++++++++++++++++-------------------- common/txmgr/txmgr.go | 50 ++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/common/txmgr/confirmer.go b/common/txmgr/confirmer.go index 19f3636a466..8a24584d281 100644 --- a/common/txmgr/confirmer.go +++ b/common/txmgr/confirmer.go @@ -17,7 +17,7 @@ import ( clienttypes "github.com/smartcontractkit/chainlink/v2/common/chains/client" feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types" txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" + "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/label" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -104,13 +104,13 @@ var ( // Step 3: See if any transactions have exceeded the gas bumping block threshold and, if so, bump them // Step 4: Check confirmed transactions to make sure they are still in the longest chain (reorg protection) type Confirmer[ - CHAIN_ID commontypes.ID, - HEAD commontypes.Head[BLOCK_HASH], - ADDR commontypes.Hashable, - TX_HASH commontypes.Hashable, - BLOCK_HASH commontypes.Hashable, + CHAIN_ID types.ID, + HEAD types.Head[BLOCK_HASH], + ADDR types.Hashable, + TX_HASH types.Hashable, + BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ commontypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { utils.StartStopOnce @@ -140,13 +140,13 @@ type Confirmer[ } func NewConfirmer[ - CHAIN_ID commontypes.ID, - HEAD commontypes.Head[BLOCK_HASH], - ADDR commontypes.Hashable, - TX_HASH commontypes.Hashable, - BLOCK_HASH commontypes.Hashable, + CHAIN_ID types.ID, + HEAD types.Head[BLOCK_HASH], + ADDR types.Hashable, + TX_HASH types.Hashable, + BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ commontypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ]( txStore txmgrtypes.TxStore[ADDR, CHAIN_ID, TX_HASH, BLOCK_HASH, R, SEQ, FEE], @@ -267,14 +267,14 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) run } // ProcessHead takes all required transactions for the confirmer on a new head -func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) ProcessHead(ctx context.Context, head commontypes.Head[BLOCK_HASH]) error { +func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) ProcessHead(ctx context.Context, head types.Head[BLOCK_HASH]) error { ctx, cancel := context.WithTimeout(ctx, processHeadTimeout) defer cancel() return ec.processHead(ctx, head) } // NOTE: This SHOULD NOT be run concurrently or it could behave badly -func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) processHead(ctx context.Context, head commontypes.Head[BLOCK_HASH]) error { +func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) processHead(ctx context.Context, head types.Head[BLOCK_HASH]) error { mark := time.Now() ec.lggr.Debugw("processHead start", "headNum", head.BlockNumber(), "id", "eth_confirmer") @@ -899,7 +899,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) han // // If any of the confirmed transactions does not have a receipt in the chain, it has been // re-org'd out and will be rebroadcast. -func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) EnsureConfirmedTransactionsInLongestChain(ctx context.Context, head commontypes.Head[BLOCK_HASH]) error { +func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) EnsureConfirmedTransactionsInLongestChain(ctx context.Context, head types.Head[BLOCK_HASH]) error { if head.ChainLength() < ec.chainConfig.FinalityDepth() { logArgs := []interface{}{ "chainLength", head.ChainLength(), "evmFinalityDepth", ec.chainConfig.FinalityDepth(), @@ -953,12 +953,12 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Ens } func hasReceiptInLongestChain[ - CHAIN_ID commontypes.ID, - ADDR commontypes.Hashable, - TX_HASH, BLOCK_HASH commontypes.Hashable, - SEQ commontypes.Sequence, + CHAIN_ID types.ID, + ADDR types.Hashable, + TX_HASH, BLOCK_HASH types.Hashable, + SEQ types.Sequence, FEE feetypes.Fee, -](etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], head commontypes.Head[BLOCK_HASH]) bool { +](etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], head types.Head[BLOCK_HASH]) bool { for { for _, attempt := range etx.TxAttempts { for _, receipt := range attempt.Receipts { @@ -974,7 +974,7 @@ func hasReceiptInLongestChain[ } } -func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) markForRebroadcast(etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], head commontypes.Head[BLOCK_HASH]) error { +func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) markForRebroadcast(etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], head types.Head[BLOCK_HASH]) error { if len(etx.TxAttempts) == 0 { return errors.Errorf("invariant violation: expected eth_tx %v to have at least one attempt", etx.ID) } @@ -1075,7 +1075,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) sen } // ResumePendingTaskRuns issues callbacks to task runs that are pending waiting for receipts -func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) ResumePendingTaskRuns(ctx context.Context, head commontypes.Head[BLOCK_HASH]) error { +func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) ResumePendingTaskRuns(ctx context.Context, head types.Head[BLOCK_HASH]) error { receiptsPlus, err := ec.txStore.FindReceiptsPendingConfirmation(ctx, head.BlockNumber(), ec.chainID) @@ -1109,11 +1109,11 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Res // observeUntilTxConfirmed observes the promBlocksUntilTxConfirmed metric for each confirmed // transaction. func observeUntilTxConfirmed[ - CHAIN_ID commontypes.ID, - ADDR commontypes.Hashable, - TX_HASH, BLOCK_HASH commontypes.Hashable, + CHAIN_ID types.ID, + ADDR types.Hashable, + TX_HASH, BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ commontypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ](chainID CHAIN_ID, attempts []txmgrtypes.TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], receipts []R) { for _, attempt := range attempts { diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index ef68994fbd3..a93100fd696 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -13,7 +13,7 @@ import ( feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types" txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" - commontypes "github.com/smartcontractkit/chainlink/v2/common/types" + "github.com/smartcontractkit/chainlink/v2/common/types" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services" "github.com/smartcontractkit/chainlink/v2/core/services/pg" @@ -31,15 +31,15 @@ type ResumeCallback func(id uuid.UUID, result interface{}, err error) error // //go:generate mockery --quiet --recursive --name TxManager --output ./mocks/ --case=underscore --structname TxManager --filename tx_manager.go type TxManager[ - CHAIN_ID commontypes.ID, - HEAD commontypes.Head[BLOCK_HASH], - ADDR commontypes.Hashable, - TX_HASH commontypes.Hashable, - BLOCK_HASH commontypes.Hashable, - SEQ commontypes.Sequence, + CHAIN_ID types.ID, + HEAD types.Head[BLOCK_HASH], + ADDR types.Hashable, + TX_HASH types.Hashable, + BLOCK_HASH types.Hashable, + SEQ types.Sequence, FEE feetypes.Fee, ] interface { - commontypes.HeadTrackable[HEAD, BLOCK_HASH] + types.HeadTrackable[HEAD, BLOCK_HASH] services.ServiceCtx Trigger(addr ADDR) CreateTransaction(txRequest txmgrtypes.TxRequest[ADDR, TX_HASH], qopts ...pg.QOpt) (etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error) @@ -59,13 +59,13 @@ type reset struct { } type Txm[ - CHAIN_ID commontypes.ID, - HEAD commontypes.Head[BLOCK_HASH], - ADDR commontypes.Hashable, - TX_HASH commontypes.Hashable, - BLOCK_HASH commontypes.Hashable, + CHAIN_ID types.ID, + HEAD types.Head[BLOCK_HASH], + ADDR types.Hashable, + TX_HASH types.Hashable, + BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ commontypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { utils.StartStopOnce @@ -103,13 +103,13 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) RegisterRe // NewTxm creates a new Txm with the given configuration. func NewTxm[ - CHAIN_ID commontypes.ID, - HEAD commontypes.Head[BLOCK_HASH], - ADDR commontypes.Hashable, - TX_HASH commontypes.Hashable, - BLOCK_HASH commontypes.Hashable, + CHAIN_ID types.ID, + HEAD types.Head[BLOCK_HASH], + ADDR types.Hashable, + TX_HASH types.Hashable, + BLOCK_HASH types.Hashable, R txmgrtypes.ChainReceipt[TX_HASH, BLOCK_HASH], - SEQ commontypes.Sequence, + SEQ types.Sequence, FEE feetypes.Fee, ]( chainId CHAIN_ID, @@ -498,11 +498,11 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) SendNative } type NullTxManager[ - CHAIN_ID commontypes.ID, - HEAD commontypes.Head[BLOCK_HASH], - ADDR commontypes.Hashable, - TX_HASH, BLOCK_HASH commontypes.Hashable, - SEQ commontypes.Sequence, + CHAIN_ID types.ID, + HEAD types.Head[BLOCK_HASH], + ADDR types.Hashable, + TX_HASH, BLOCK_HASH types.Hashable, + SEQ types.Sequence, FEE feetypes.Fee, ] struct { ErrMsg string