remove 0x prefix and lowercase the hash (#257)

Co-authored-by: gipsh <gipsh@gmail.com>
This commit is contained in:
gipsh 2023-05-10 17:34:24 -03:00 committed by GitHub
parent 7fb3857a97
commit 3867a2eb24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -22,13 +22,24 @@ func workerTxHash(ctx context.Context, repo *storage.Repository, line string) er
return fmt.Errorf("error parsing chain id: %v\n", err)
}
//remove 0x from txhash
if len(tokens[3]) < 3 {
return fmt.Errorf("invalid txhash: %s", tokens[3])
}
// if token starts with 0x remove it
if tokens[3][:2] == "0x" {
tokens[3] = tokens[3][2:]
}
txHash := strings.ToLower(tokens[3])
now := time.Now()
vaaTxHash := storage.VaaIdTxHashUpdate{
ChainID: vaa.ChainID(intChainID),
Emitter: tokens[1],
Sequence: tokens[2],
TxHash: tokens[3],
TxHash: txHash,
UpdatedAt: &now,
}