@@ -59,6 +59,8 @@ type TxManager[CID chains.ID, HEAD chains.Head[BHASH], ADDR chains.Hashable, THA
5959 CountTransactionsByState (ctx context.Context , state txmgrtypes.TxState ) (count uint32 , err error )
6060 GetTransactionStatus (ctx context.Context , transactionID string ) (state commontypes.TransactionStatus , err error )
6161 GetTransactionFee (ctx context.Context , transactionID string ) (fee * evmtypes.TransactionFee , err error )
62+ GetTransactionReceipt (ctx context.Context , transactionID string ) (receipt * txmgrtypes.ChainReceipt [THASH , BHASH ], err error )
63+ CalculateFee (feeParts FeeParts ) * big.Int
6264}
6365
6466type TxmV2Wrapper [CID chains.ID , HEAD chains.Head [BHASH ], ADDR chains.Hashable , THASH chains.Hashable , BHASH chains.Hashable , SEQ chains.Sequence , FEE fees.Fee ] interface {
@@ -743,23 +745,52 @@ func (b *Txm[CID, HEAD, ADDR, THASH, BHASH, R, SEQ, FEE]) GetTransactionFee(ctx
743745 return fee , fmt .Errorf ("failed to find receipt with IdempotencyKey %s" , transactionID )
744746 }
745747
748+ txFee := b .CalculateFee (FeeParts {
749+ GasUsed : receipt .GetFeeUsed (),
750+ EffectiveGasPrice : receipt .GetEffectiveGasPrice (),
751+ L1Fee : receipt .GetL1Fee (),
752+ })
753+
754+ fee = & evmtypes.TransactionFee {
755+ TransactionFee : txFee ,
756+ }
757+
758+ return fee , nil
759+ }
760+
761+ func (b * Txm [CID , HEAD , ADDR , THASH , BHASH , R , SEQ , FEE ]) GetTransactionReceipt (ctx context.Context , transactionID string ) (receipt * txmgrtypes.ChainReceipt [THASH , BHASH ], err error ) {
762+ foundReceipt , err := b .txStore .FindReceiptWithIdempotencyKey (ctx , transactionID , b .chainID )
763+ if err != nil {
764+ return nil , fmt .Errorf ("failed to find receipt with IdempotencyKey %s: %w" , transactionID , err )
765+ }
766+
767+ // This check is required since a no-rows error returns nil err
768+ if foundReceipt == nil {
769+ return nil , fmt .Errorf ("failed to find receipt with IdempotencyKey %s" , transactionID )
770+ }
771+ return & foundReceipt , nil
772+ }
773+
774+ type FeeParts struct {
775+ GasUsed uint64
776+ EffectiveGasPrice * big.Int
777+ L1Fee * big.Int
778+ }
779+
780+ func (b * Txm [CID , HEAD , ADDR , THASH , BHASH , R , SEQ , FEE ]) CalculateFee (feeParts FeeParts ) * big.Int {
746781 totalFee := new (big.Int )
747782
748- gasUsed := new (big.Int ).SetUint64 (receipt . GetFeeUsed () )
749- price := receipt . GetEffectiveGasPrice ()
783+ gasUsed := new (big.Int ).SetUint64 (feeParts . GasUsed )
784+ price := feeParts . EffectiveGasPrice
750785 if price != nil {
751786 totalFee .Mul (gasUsed , price )
752787 }
753- l1Fee := receipt . GetL1Fee ()
788+ l1Fee := feeParts . L1Fee
754789 if l1Fee != nil {
755790 totalFee .Add (totalFee , l1Fee )
756791 }
757792
758- fee = & evmtypes.TransactionFee {
759- TransactionFee : totalFee ,
760- }
761-
762- return fee , nil
793+ return totalFee
763794}
764795
765796// Deprecated: use txmgrtest.ErrTxManager
@@ -847,6 +878,14 @@ func (n *NullTxManager[CID, HEAD, ADDR, THASH, BHASH, SEQ, FEE]) GetTransactionF
847878 return
848879}
849880
881+ func (n * NullTxManager [CID , HEAD , ADDR , THASH , BHASH , SEQ , FEE ]) CalculateFee (feeParts FeeParts ) * big.Int {
882+ return nil
883+ }
884+
885+ func (n * NullTxManager [CID , HEAD , ADDR , THASH , BHASH , SEQ , FEE ]) GetTransactionReceipt (ctx context.Context , transactionID string ) (receipt * txmgrtypes.ChainReceipt [THASH , BHASH ], err error ) {
886+ return
887+ }
888+
850889func (b * Txm [CID , HEAD , ADDR , THASH , BHASH , R , SEQ , FEE ]) pruneQueueAndCreateTxn (
851890 ctx context.Context ,
852891 txRequest txmgrtypes.TxRequest [ADDR , THASH ],
0 commit comments