Skip to content

Commit

Permalink
Adds support for 12 byte ZIDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Elizondo committed Jun 7, 2024
1 parent a8ef0b9 commit 324590a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/parsers/web3/parse_web3_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,25 @@ export function parseTransaction(rawTx: EVMTransaction): Transaction {
transaction.affiliateAddress = '0x'.concat(rawTx.input.slice(bytesPos + 32, bytesPos + 72));
const quoteId = rawTx.input.slice(bytesPos + 104, bytesPos + 136);
if (
quoteId.slice(0, 14) === '00000000000000' &&
!isCoinbaseShortZidTransaction(transaction.blockNumber, transaction.affiliateAddress)
quoteId.slice(0, 16) === '0000000000000000' &&
isCoinbaseShortZidTransaction(transaction.blockNumber, transaction.affiliateAddress)
) {
// Coinbase short-zid incident (2024-04-30 - 2024-05-04)
// (8 bytes data, 8 bytes padding)
transaction.quoteTimestamp = null;
transaction.quoteId = '0x' + quoteId;
} else if (quoteId.slice(0, 14) === '00000000000000') {
// Pre ZID QR ID
// Excludes short-zid incident (2024-04-30 - 2024-05-04)
const parsedQuoteTimestamp = parseInt(rawTx.input.slice(bytesPos + 128, bytesPos + 136), 16);
transaction.quoteTimestamp = isNaN(parsedQuoteTimestamp) ? null : parsedQuoteTimestamp;
transaction.quoteId = rawTx.input.slice(bytesPos + 118, bytesPos + 128);
} else if (quoteId.slice(0, 8) === '00000000') {
// 12-byte ZID (~2024-06-07)
// (12 bytes data, ignore first 4 bytes of padding)
transaction.quoteTimestamp = null;
transaction.quoteId = '0x' + quoteId.slice(8);
} else {
// ZID
// 16-byte ZID - Original
transaction.quoteTimestamp = null;
transaction.quoteId = '0x' + quoteId;
}
Expand Down

0 comments on commit 324590a

Please sign in to comment.