Skip to content

Commit

Permalink
[Blockchain Watcher](FIX) Fix algorand mapper (#1710)
Browse files Browse the repository at this point in the history
* Fix algorand mapper

* Replace catch variable

---------

Co-authored-by: julian merlo <julianmerlo@julians-MacBook-Air.local>
  • Loading branch information
julianmerlo95 and julian merlo authored Sep 19, 2024
1 parent aa82517 commit 58166f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,20 @@ export const algorandRedeemedTransactionFoundMapper = (
};

const mappedVaaInformation = (payload: string): VaaInformation | undefined => {
const payloadToHex = Buffer.from(payload, "base64").toString("hex");
const buffer = Buffer.from(payloadToHex, "hex");
const vaa = parseVaa(buffer);
try {
const payloadToHex = Buffer.from(payload, "base64").toString("hex");
const buffer = Buffer.from(payloadToHex, "hex");
const vaa = parseVaa(buffer);

return {
emitterChain: vaa.emitterChain,
emitterAddress: vaa.emitterAddress.toString("hex").toUpperCase(),
sequence: Number(vaa.sequence),
};
return {
emitterChain: vaa.emitterChain,
emitterAddress: vaa.emitterAddress.toString("hex").toUpperCase(),
sequence: Number(vaa.sequence),
};
} catch (e) {
// If we cant parse the VAA we ignore
return undefined;
}
};

type VaaInformation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ export class SnsEvent {
}

static fromLogFoundEvent<T>(logFoundEvent: LogFoundEvent<T>): SnsEvent {
const prefix = `chain-event-${uuidv4()}-${logFoundEvent.txHash}`;
// SNS message attributes have a limit of 127 characters
const trackId = prefix.length > 127 ? prefix.substring(0, 127) : prefix;

return new SnsEvent(
`chain-event-${uuidv4()}-${logFoundEvent.txHash}`,
trackId,
"blockchain-watcher",
logFoundEvent.name,
new Date().toISOString(),
Expand Down

0 comments on commit 58166f7

Please sign in to comment.