Skip to content

Commit

Permalink
feat: send txn without waiting for tx manager
Browse files Browse the repository at this point in the history
  • Loading branch information
renlulu committed Aug 10, 2024
1 parent bdeff56 commit 12cba1f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions chainio/txmgr/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ func (m *SimpleTxManager) WithGasLimitMultiplier(multiplier float64) *SimpleTxMa
// and resign the transaction after adding the nonce and gas limit.
// To check out the whole flow on how this works, check out the README.md in this folder
func (m *SimpleTxManager) Send(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) {

txID, err := m.SendWithoutWaiting(ctx, tx)
if err != nil {
return nil, errors.Join(errors.New("send: failed to estimate gas and nonce"), err)
}

receipt, err := m.waitForReceipt(ctx, *txID)
if err != nil {
log.Info("Transaction receipt not found", "err", err)
return nil, err
}

return receipt, nil
}

func (m *SimpleTxManager) SendWithoutWaiting(ctx context.Context, tx *types.Transaction) (*wallet.TxID, error) {
// Estimate gas and nonce
// can't print tx hash in logs because the tx changes below when we complete and sign it
// so the txHash is meaningless at this point
Expand All @@ -89,14 +105,7 @@ func (m *SimpleTxManager) Send(ctx context.Context, tx *types.Transaction) (*typ
if err != nil {
return nil, errors.Join(errors.New("send: failed to estimate gas and nonce"), err)
}

receipt, err := m.waitForReceipt(ctx, txID)
if err != nil {
log.Info("Transaction receipt not found", "err", err)
return nil, err
}

return receipt, nil
return &txID, nil
}

func NoopSigner(addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
Expand Down

0 comments on commit 12cba1f

Please sign in to comment.