@@ -60,7 +60,7 @@ type TargetStrategy interface {
6060}
6161
6262var (
63- _ capabilities.TargetCapability = & writeTarget {}
63+ _ capabilities.ExecutableCapability = & writeTarget {}
6464)
6565
6666// chain-agnostic consts
@@ -98,7 +98,8 @@ type writeTarget struct {
9898 nodeAddress string
9999 forwarderAddress string
100100
101- targetStrategy TargetStrategy
101+ targetStrategy TargetStrategy
102+ writeAcceptanceState commontypes.TransactionStatus
102103}
103104type WriteTargetOpts struct {
104105 ID string
@@ -120,7 +121,8 @@ type WriteTargetOpts struct {
120121 NodeAddress string
121122 ForwarderAddress string
122123
123- TargetStrategy TargetStrategy
124+ TargetStrategy TargetStrategy
125+ WriteAcceptanceState commontypes.TransactionStatus
124126}
125127
126128// Capability-specific configuration
@@ -170,6 +172,7 @@ func NewWriteTarget(opts WriteTargetOpts) capabilities.ExecutableCapability {
170172 opts .NodeAddress ,
171173 opts .ForwarderAddress ,
172174 opts .TargetStrategy ,
175+ opts .WriteAcceptanceState ,
173176 }
174177}
175178
@@ -467,18 +470,21 @@ func (c *writeTarget) waitTxReachesTerminalStatus(ctx context.Context, lggr logg
467470 lggr .Debugw ("txm - tx status" , "txID" , txID , "status" , status )
468471
469472 switch status {
470- case commontypes .Finalized :
471- // Notice: report write confirmation is only possible after a tx is accepted without an error
472- // TODO: [Beholder] Emit 'platform.write-target.WriteAccepted' (useful to source tx hash, block number, and tx status/error)
473- lggr .Infow ("accepted" , "txID" , txID , "status" , status )
474- return true , nil
475473 case commontypes .Failed , commontypes .Fatal :
476474 // TODO: [Beholder] Emit 'platform.write-target.WriteError' if accepted with an error (surface specific on-chain error)
477475 lggr .Infow ("transaction failed" , "txID" , txID , "status" , status )
478476 return false , nil
479477 default :
480- lggr .Infow ("not accepted yet" , "txID" , txID , "status" , status )
481- continue
478+ // Notice: On slower chains we can accept a non-finalized state, but on faster chains we should always wait for finalization.
479+ if status >= c .writeAcceptanceState {
480+ // Notice: report write confirmation is only possible after a tx is accepted without an error
481+ // TODO: [Beholder] Emit 'platform.write-target.WriteAccepted' (useful to source tx hash, block number, and tx status/error)
482+ lggr .Infow ("accepted" , "txID" , txID , "status" , status )
483+ return true , nil
484+ } else {
485+ lggr .Infow ("not accepted yet" , "txID" , txID , "status" , status )
486+ continue
487+ }
482488 }
483489 }
484490 }
0 commit comments