Skip to content

Commit

Permalink
filter after intent timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
richardliang committed May 7, 2024
1 parent 72f8069 commit fd1a1e7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion client/src/components/Notary/NotarizationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
} from '@helpers/types';
import { commonStrings, platformStrings } from "@helpers/strings";
import useExtensionNotarizations from '@hooks/useExtensionNotarizations';
import useOnramperIntents from '@hooks/revolut/useOnRamperIntents';


import chromeSvg from '../../assets/images/browsers/chrome.svg';
import braveSvg from '../../assets/images/browsers/brave.svg';
Expand Down Expand Up @@ -73,6 +75,8 @@ export const NotarizationTable: React.FC<NotarizationTableProps> = ({
transferProofs
} = useExtensionNotarizations();

const { currentIntent } = useOnramperIntents();

/*
* State
*/
Expand Down Expand Up @@ -398,7 +402,19 @@ export const NotarizationTable: React.FC<NotarizationTableProps> = ({

case NotaryVerificationCircuit.TRANSFER:
if (transferProofs && transferProofs.length > 0) {
const transferProofRows = transferProofs.map((request: ExtensionNotaryProofRequest) => {
// First filter transfer proofs for payment timestamps after intent if intent exists
let filteredTransferProofs = transferProofs;
if (currentIntent) {
filteredTransferProofs = transferProofs.filter((request: ExtensionNotaryProofRequest) => {
const [ , , , , paymentTimestamp] = request.metadata;

const paymentTimestampAdjusted = BigInt(paymentTimestamp) / 1000n;
const intentTimestamp = BigInt(currentIntent.intent.timestamp);

return paymentTimestampAdjusted >= intentTimestamp;
});
}
const transferProofRows = filteredTransferProofs.map((request: ExtensionNotaryProofRequest) => {
const [timestamp, amount, currency] = request.metadata;

const formattedAmount = (Math.abs(amount) / 100).toFixed(2);
Expand Down

0 comments on commit fd1a1e7

Please sign in to comment.