diff --git a/core/transactor/factory/factory.go b/core/transactor/factory/factory.go index 5797d5a..9e16f99 100644 --- a/core/transactor/factory/factory.go +++ b/core/transactor/factory/factory.go @@ -43,7 +43,7 @@ func New(noncer Noncer, signer kmstypes.TxSigner, mc3Batcher *Multicall3Batcher) // BuildTransactionFromRequests builds a transaction from a list of requests. func (f *Factory) BuildTransactionFromRequests( ctx context.Context, - txReqs []*types.TxRequest, + txReqs ...*types.TxRequest, ) (*coretypes.Transaction, error) { switch len(txReqs) { case 0: @@ -53,7 +53,7 @@ func (f *Factory) BuildTransactionFromRequests( return f.BuildTransaction(ctx, txReqs[0]) default: // len(txReqs) > 1 then build a multicall transaction. - ar := f.mc3Batcher.BatchTxRequests(ctx, txReqs) + ar := f.mc3Batcher.BatchTxRequests(ctx, txReqs...) // Build the transaction to include the calldata. // ar.To should be the Multicall3 contract address diff --git a/core/transactor/factory/multicall.go b/core/transactor/factory/multicall.go index 9769128..bc79f52 100644 --- a/core/transactor/factory/multicall.go +++ b/core/transactor/factory/multicall.go @@ -36,8 +36,7 @@ func NewMulticall3Batcher(address common.Address) *Multicall3Batcher { // BatchTxRequests creates a batched transaction request for the given transaction requests. func (mc *Multicall3Batcher) BatchTxRequests( - _ context.Context, - txReqs []*types.TxRequest, + _ context.Context, txReqs ...*types.TxRequest, ) *types.TxRequest { var ( calls = make([]bindings.Multicall3Call, len(txReqs)) @@ -82,12 +81,12 @@ func (mc *Multicall3Batcher) BatchTxRequests( func (mc *Multicall3Batcher) BatchCallRequests( ctx context.Context, from common.Address, - txReqs []*types.TxRequest, + txReqs ...*types.TxRequest, ) ([]bindings.Multicall3Result, error) { sCtx := sdk.UnwrapContext(ctx) // get the batched tx (call) requests - batchedCall := mc.BatchTxRequests(ctx, txReqs) + batchedCall := mc.BatchTxRequests(ctx, txReqs...) batchedCall.From = from // call the multicall3 contract with the batched call request diff --git a/core/transactor/transactor.go b/core/transactor/transactor.go index 17e99c7..eb61ba8 100644 --- a/core/transactor/transactor.go +++ b/core/transactor/transactor.go @@ -155,7 +155,7 @@ func (t *TxrV2) mainLoop(ctx context.Context) { t.mu.Lock() go func() { defer t.mu.Unlock() - if err := t.sendAndTrack(ctx, msgIDs, batch); err != nil { + if err := t.sendAndTrack(ctx, msgIDs, batch...); err != nil { t.logger.Error("failed to process batch", "err", err) } }() @@ -189,9 +189,9 @@ func (t *TxrV2) retrieveBatch(_ context.Context) ([]string, []*types.TxRequest) // It builds a transaction from the batch and sends it. // It also tracks the transaction for future reference. func (t *TxrV2) sendAndTrack( - ctx context.Context, msgIDs []string, batch []*types.TxRequest, + ctx context.Context, msgIDs []string, batch ...*types.TxRequest, ) error { - tx, err := t.factory.BuildTransactionFromRequests(ctx, batch) + tx, err := t.factory.BuildTransactionFromRequests(ctx, batch...) if err != nil { return err }