@@ -27,11 +27,11 @@ class SendTransaction implements ShouldQueue
2727{
2828 use InteractsWithQueue, Queueable, SerializesModels;
2929
30- public function __construct (public string $ address , public string $ data , public array $ opts , public int $ chainId , public array $ txCfg ) {}
30+ public function __construct (public string $ address , public string $ data , public array $ opts , public int $ chainId , public array $ txCfg, public mixed $ payload = null ) {}
3131
3232 public function handle (RpcClient $ rpc , Signer $ signer , NonceManager $ nonces , FeePolicy $ fees ): void
3333 {
34- event (new TxQueued ($ this ->address , $ this ->data ));
34+ event (new TxQueued ($ this ->address , $ this ->data , $ this -> payload ));
3535
3636 $ from = $ signer ->getAddress ();
3737
@@ -67,7 +67,7 @@ public function handle(RpcClient $rpc, Signer $signer, NonceManager $nonces, Fee
6767
6868 $ pk = method_exists ($ signer , 'privateKey ' ) ? $ signer ->privateKey () : null ;
6969 if (! $ pk ) {
70- event (new TxFailed ($ this ->address , $ this ->data , 'Signer has no privateKey method ' ));
70+ event (new TxFailed ($ this ->address , $ this ->data , 'Signer has no privateKey method ' , $ this -> payload ));
7171
7272 return ;
7373 }
@@ -78,10 +78,10 @@ public function handle(RpcClient $rpc, Signer $signer, NonceManager $nonces, Fee
7878 $ rawHex = str_starts_with ($ raw , '0x ' ) ? $ raw : '0x ' .$ raw ; // ensure 0x prefix
7979 $ txHash = $ rpc ->call ('eth_sendRawTransaction ' , [$ rawHex ]);
8080 $ nonces ->markUsed ($ from , $ nonce );
81- event (new TxBroadcasted ($ txHash , $ fields ));
81+ event (new TxBroadcasted ($ txHash , $ fields, $ this -> payload ));
8282
8383 } catch (\Throwable $ e ) {
84- event (new TxFailed ($ this ->address , $ this ->data , 'rpc_send_error: ' .$ e ->getMessage ()));
84+ event (new TxFailed ($ this ->address , $ this ->data , 'rpc_send_error: ' .$ e ->getMessage (), $ this -> payload ));
8585
8686 return ;
8787 }
@@ -94,7 +94,7 @@ public function handle(RpcClient $rpc, Signer $signer, NonceManager $nonces, Fee
9494 while (time () < $ deadline ) {
9595 $ rec = $ rpc ->call ('eth_getTransactionReceipt ' , [$ txHash ]);
9696 if (! empty ($ rec )) {
97- event (new TxMined ($ txHash , $ rec ));
97+ event (new TxMined ($ txHash , $ rec, $ this -> payload ));
9898
9999 return ;
100100 }
@@ -109,15 +109,15 @@ public function handle(RpcClient $rpc, Signer $signer, NonceManager $nonces, Fee
109109 $ fields ['maxFeePerGas ' ] = $ max ;
110110
111111 // Emit replacement attempt (before rebroadcast)
112- event (new TxReplaced ($ oldTxHash , $ fields , $ i + 1 ));
112+ event (new TxReplaced ($ oldTxHash , $ fields , $ i + 1 , $ this -> payload ));
113113
114114 try {
115115 $ raw = new EIP1559Transaction ($ fields )->sign ($ pk );
116116 $ rawHex = str_starts_with ($ raw , '0x ' ) ? $ raw : '0x ' .$ raw ; // ensure 0x prefix
117117 $ txHash = $ rpc ->call ('eth_sendRawTransaction ' , [$ rawHex ]);
118- event (new TxBroadcasted ($ txHash , $ fields ));
118+ event (new TxBroadcasted ($ txHash , $ fields, $ this -> payload ));
119119 } catch (\Throwable $ e ) {
120- event (new TxFailed ($ this ->address , $ this ->data , 'rpc_send_error_replacement_ ' .$ i .': ' .$ e ->getMessage ()));
120+ event (new TxFailed ($ this ->address , $ this ->data , 'rpc_send_error_replacement_ ' .$ i .': ' .$ e ->getMessage (), $ this -> payload ));
121121
122122 return ;
123123 }
@@ -126,7 +126,7 @@ public function handle(RpcClient $rpc, Signer $signer, NonceManager $nonces, Fee
126126 while (time () < $ deadline ) {
127127 $ rec = $ rpc ->call ('eth_getTransactionReceipt ' , [$ txHash ]);
128128 if (! empty ($ rec )) {
129- event (new TxMined ($ txHash , $ rec ));
129+ event (new TxMined ($ txHash , $ rec, $ this -> payload ));
130130
131131 return ;
132132 }
@@ -137,7 +137,8 @@ public function handle(RpcClient $rpc, Signer $signer, NonceManager $nonces, Fee
137137 event (new TxFailed (
138138 $ this ->address ,
139139 $ this ->data ,
140- sprintf ('no_receipt_after_%d_replacements (last maxFee=%d priority=%d) ' , $ maxRep , $ fields ['maxFeePerGas ' ], $ fields ['maxPriorityFeePerGas ' ])
140+ sprintf ('no_receipt_after_%d_replacements (last maxFee=%d priority=%d) ' , $ maxRep , $ fields ['maxFeePerGas ' ], $ fields ['maxPriorityFeePerGas ' ]),
141+ $ this ->payload
141142 ));
142143 }
143144}
0 commit comments