Normalize txHash destination in tx-tracker component (#1274)

Co-authored-by: ftocal <fert1335@gmail.com>
This commit is contained in:
walker-16 2024-04-08 14:05:48 -03:00 committed by GitHub
parent 11ecb6eb6d
commit 8dc2b5ac5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 1 deletions

View File

@ -4,10 +4,12 @@ import (
"encoding/base32"
"encoding/hex"
"fmt"
"strings"
algorand_types "github.com/algorand/go-algorand-sdk/types"
"github.com/cosmos/btcutil/bech32"
"github.com/mr-tron/base58"
"github.com/wormhole-foundation/wormhole-explorer/common/utils"
sdk "github.com/wormhole-foundation/wormhole/sdk/vaa"
)
@ -167,6 +169,35 @@ func TranslateEmitterAddress(chainID sdk.ChainID, address string) (string, error
}
}
func NormalizeTxHashByChainId(chainID sdk.ChainID, txHash string) string {
switch chainID {
case sdk.ChainIDEthereum,
sdk.ChainIDBase,
sdk.ChainIDBSC,
sdk.ChainIDPolygon,
sdk.ChainIDAvalanche,
sdk.ChainIDOasis,
sdk.ChainIDAurora,
sdk.ChainIDFantom,
sdk.ChainIDKarura,
sdk.ChainIDAcala,
sdk.ChainIDKlaytn,
sdk.ChainIDCelo,
sdk.ChainIDMoonbeam,
sdk.ChainIDArbitrum,
sdk.ChainIDOptimism,
sdk.ChainIDSepolia,
sdk.ChainIDArbitrumSepolia,
sdk.ChainIDBaseSepolia,
sdk.ChainIDOptimismSepolia,
sdk.ChainIDHolesky:
lowerTxHash := strings.ToLower(txHash)
return utils.Remove0x(lowerTxHash)
default:
return txHash
}
}
// EncodeTrxHashByChainID encodes the transaction hash by chain id with different encoding methods.
func EncodeTrxHashByChainID(chainID sdk.ChainID, txHash []byte) (string, error) {
switch chainID {

View File

@ -41,6 +41,7 @@ func ProcessTargetTx(
params *ProcessTargetTxParams,
) error {
txHash := domain.NormalizeTxHashByChainId(params.ChainID, params.TxHash)
now := time.Now()
update := &TargetTxUpdate{
ID: params.VaaId,
@ -48,7 +49,7 @@ func ProcessTargetTx(
Destination: &DestinationTx{
ChainID: params.ChainID,
Status: params.Status,
TxHash: params.TxHash,
TxHash: txHash,
BlockNumber: params.BlockHeight,
Timestamp: params.BlockTimestamp,
From: params.From,