@@ -61,7 +61,6 @@ func (b *BuilderClient) SetWaitTimeout(timeout time.Duration) {
61
61
// that supports eth_sendBundle.
62
62
func (b * BuilderClient ) SendUserOperation () modules.BatchHandlerFunc {
63
63
return func (ctx * modules.BatchHandlerCtx ) error {
64
- // Estimate gas for handleOps() and drop all userOps that cause unexpected reverts.
65
64
opts := transaction.Opts {
66
65
EOA : b .eoa ,
67
66
Eth : b .eth ,
@@ -76,18 +75,27 @@ func (b *BuilderClient) SendUserOperation() modules.BatchHandlerFunc {
76
75
NoSend : true ,
77
76
WaitTimeout : b .waitTimeout ,
78
77
}
78
+ // Estimate gas for handleOps() and drop all userOps that cause unexpected reverts.
79
+ estRev := []string {}
79
80
for len (ctx .Batch ) > 0 {
80
81
est , revert , err := transaction .EstimateHandleOpsGas (& opts )
81
82
82
83
if err != nil {
83
84
return err
84
85
} else if revert != nil {
85
86
ctx .MarkOpIndexForRemoval (revert .OpIndex )
87
+ estRev = append (estRev , revert .Reason )
86
88
} else {
87
89
opts .GasLimit = est
88
90
break
89
91
}
90
92
}
93
+ ctx .Data ["estimate_revert_reasons" ] = estRev
94
+
95
+ // No need to continue if the batch size is 0. Otherwise we would just be sending empty batches.
96
+ if len (ctx .Batch ) == 0 {
97
+ return nil
98
+ }
91
99
92
100
// Calculate the max base fee up to a future block number.
93
101
bn , err := b .eth .BlockNumber (context .Background ())
@@ -135,7 +143,11 @@ func (b *BuilderClient) SendUserOperation() modules.BatchHandlerFunc {
135
143
}
136
144
137
145
// Wait for transaction to be included on-chain.
138
- _ , err = transaction .Wait (txn , opts .Eth , opts .WaitTimeout )
139
- return err
146
+ if _ , err := transaction .Wait (txn , opts .Eth , opts .WaitTimeout ); err != nil {
147
+ return err
148
+ }
149
+ ctx .Data ["txn_hash" ] = txn .Hash ().String ()
150
+
151
+ return nil
140
152
}
141
153
}
0 commit comments