@@ -7,7 +7,7 @@ pub enum TransactionSendError {
77 NoProofSubmitters ,
88 NoFeePerProof ,
99 InsufficientFeeForAggregator ,
10- SubmissionInsufficientBalance ,
10+ SubmissionInsufficientBalance ( Address ) ,
1111 BatchAlreadySubmitted ,
1212 InsufficientFunds ,
1313 OnlyBatcherAllowed ,
@@ -30,8 +30,16 @@ impl From<Bytes> for TransactionSendError {
3030 "0x3102f10c" => TransactionSendError :: BatchAlreadySubmitted , // can happen, don't flush
3131 "0x5c54305e" => TransactionSendError :: InsufficientFunds , // shouldn't happen, don't flush
3232 "0x152bc288" => TransactionSendError :: OnlyBatcherAllowed , // won't happen, don't flush
33- "0x4f779ceb" => TransactionSendError :: SubmissionInsufficientBalance , // shouldn't happen,
34- // flush can help if something went wrong
33+ "0x4f779ceb" => {
34+ // SubmissionInsufficientBalance(address sender, uint256 balance, uint256 required)
35+ // Try to decode the address parameter (first parameter after selector)
36+ let address = byte_string
37+ . get ( 34 ..74 ) // Skip "0x" + selector (8 chars) + padding (24 chars)
38+ . and_then ( |hex_str| hex:: decode ( hex_str) . ok ( ) )
39+ . map ( |bytes| Address :: from_slice ( & bytes) )
40+ . unwrap_or ( Address :: zero ( ) ) ;
41+ TransactionSendError :: SubmissionInsufficientBalance ( address)
42+ }
3543 _ => {
3644 // flush because unkown error
3745 TransactionSendError :: Generic ( format ! ( "Unknown bytestring error: {}" , byte_string) )
@@ -155,8 +163,12 @@ impl fmt::Display for TransactionSendError {
155163 TransactionSendError :: InsufficientFeeForAggregator => {
156164 write ! ( f, "Insufficient fee for aggregator" )
157165 }
158- TransactionSendError :: SubmissionInsufficientBalance => {
159- write ! ( f, "Submission insufficient balance" )
166+ TransactionSendError :: SubmissionInsufficientBalance ( address) => {
167+ write ! (
168+ f,
169+ "Submission insufficient balance for address: {:?}" ,
170+ address
171+ )
160172 }
161173 TransactionSendError :: BatchAlreadySubmitted => {
162174 write ! ( f, "Batch already submitted" )
0 commit comments