Skip to content

Commit 61c3723

Browse files
committed
fix: attach blockHeight to verification
1 parent ac196fd commit 61c3723

4 files changed

Lines changed: 17 additions & 29 deletions

File tree

universalClient/chains/common/event_processor.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -366,27 +366,12 @@ func (ep *EventProcessor) extractOutboundObservation(event *store.Event) (*uexec
366366
txHashHex = txHash
367367
}
368368

369-
// Since the event is confirmed, success is always true
370-
// Parse event data to extract error_msg if available
371-
var errorMsg string = ""
372-
373-
if len(event.EventData) > 0 {
374-
var eventData map[string]interface{}
375-
if err := json.Unmarshal(event.EventData, &eventData); err == nil {
376-
// Check for error_msg field
377-
if errorMsgVal, ok := eventData["error_msg"].(string); ok {
378-
errorMsg = errorMsgVal
379-
}
380-
}
381-
}
382-
383369
observation := &uexecutortypes.OutboundObservation{
384370
Success: true, // Since event is confirmed, success is always true
385371
BlockHeight: event.BlockHeight,
386372
TxHash: txHashHex,
387-
ErrorMsg: errorMsg,
373+
ErrorMsg: "",
388374
}
389375

390376
return observation, nil
391377
}
392-

universalClient/chains/common/types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ type OutboundTxBuilder interface {
4343
BroadcastOutboundSigningRequest(ctx context.Context, req *UnSignedOutboundTxReq, data *uetypes.OutboundCreatedEvent, signature []byte) (string, error)
4444

4545
// VerifyBroadcastedTx checks the status of a broadcasted transaction on the destination chain.
46-
// Returns (found, confirmations, status, error):
46+
// Returns (found, blockHeight, confirmations, status, error):
4747
// - found=false: tx not found or not yet mined
4848
// - found=true: tx exists on-chain
49+
// - blockHeight: the block in which the tx was mined
4950
// - confirmations: number of blocks since the tx was mined (0 = just mined)
5051
// - status: 0 = failed/reverted, 1 = success
51-
VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, confirmations uint64, status uint8, err error)
52+
VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, blockHeight uint64, confirmations uint64, status uint8, err error)
5253
}
5354

5455
// UniversalTx Payload

universalClient/chains/evm/tx_builder.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,23 +491,25 @@ func (tb *TxBuilder) encodeFunctionCall(
491491
}
492492

493493
// VerifyBroadcastedTx checks the status of a broadcasted transaction on the EVM chain.
494-
func (tb *TxBuilder) VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, confirmations uint64, status uint8, err error) {
494+
func (tb *TxBuilder) VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, blockHeight uint64, confirmations uint64, status uint8, err error) {
495495
hash := ethcommon.HexToHash(txHash)
496496
receipt, err := tb.rpcClient.GetTransactionReceipt(ctx, hash)
497497
if err != nil {
498498
// Transaction not found or not yet mined
499-
return false, 0, 0, nil
499+
return false, 0, 0, 0, nil
500500
}
501501

502+
receiptBlock := receipt.BlockNumber.Uint64()
503+
502504
// Calculate confirmations from current block
503505
var confs uint64
504506
latestBlock, err := tb.rpcClient.GetLatestBlock(ctx)
505-
if err == nil && latestBlock >= receipt.BlockNumber.Uint64() {
506-
confs = latestBlock - receipt.BlockNumber.Uint64() + 1
507+
if err == nil && latestBlock >= receiptBlock {
508+
confs = latestBlock - receiptBlock + 1
507509
}
508510

509511
// receipt.Status: 1 = success, 0 = reverted
510-
return true, confs, uint8(receipt.Status), nil
512+
return true, receiptBlock, confs, uint8(receipt.Status), nil
511513
}
512514

513515
// getFunctionSignature returns the full function signature for ABI encoding

universalClient/chains/svm/tx_builder.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,19 +1476,19 @@ func (tb *TxBuilder) buildWithdrawAndExecuteAccounts(
14761476
// - found=true: tx exists on-chain
14771477
// - confirmations: number of slots since the tx was included (0 = just confirmed)
14781478
// - status: 0 = failed, 1 = success
1479-
func (tb *TxBuilder) VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, confirmations uint64, status uint8, err error) {
1479+
func (tb *TxBuilder) VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, blockHeight uint64, confirmations uint64, status uint8, err error) {
14801480
sig, sigErr := solana.SignatureFromBase58(txHash)
14811481
if sigErr != nil {
1482-
return false, 0, 0, nil
1482+
return false, 0, 0, 0, nil
14831483
}
14841484

14851485
tx, txErr := tb.rpcClient.GetTransaction(ctx, sig)
14861486
if txErr != nil {
1487-
return false, 0, 0, nil
1487+
return false, 0, 0, 0, nil
14881488
}
14891489

14901490
if tx == nil {
1491-
return false, 0, 0, nil
1491+
return false, 0, 0, 0, nil
14921492
}
14931493

14941494
// Calculate confirmations from current slot
@@ -1502,10 +1502,10 @@ func (tb *TxBuilder) VerifyBroadcastedTx(ctx context.Context, txHash string) (fo
15021502

15031503
// Check if transaction had an error
15041504
if tx.Meta != nil && tx.Meta.Err != nil {
1505-
return true, confs, 0, nil
1505+
return true, tx.Slot, confs, 0, nil
15061506
}
15071507

1508-
return true, confs, 1, nil
1508+
return true, tx.Slot, confs, 1, nil
15091509
}
15101510

15111511
// buildSetComputeUnitLimitInstruction creates a SetComputeUnitLimit instruction for the Compute Budget program

0 commit comments

Comments
 (0)