From d81347f014ce0c193df0db45028b115ef648e6e3 Mon Sep 17 00:00:00 2001 From: John Shaw Date: Tue, 16 Apr 2024 07:59:50 +0200 Subject: [PATCH 1/2] chore: fixed selectedProof not selecting new proof on upload --- package-lock.json | 14 +++++++------- web/components/FileUpload/index.tsx | 2 +- web/components/ProofDetails/index.tsx | 2 +- web/components/ProofSelect/index.tsx | 13 +++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 51edec9..fa81b68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "redux-thunk": "^2.4.2", "stream": "^0.0.2", "tailwindcss": "^3.3.3", - "tlsn-js": "^0.1.0-alpha.4.3" + "tlsn-js": "^0.1.0-alpha.5.2" }, "devDependencies": { "@babel/core": "^7.20.12", @@ -19481,9 +19481,9 @@ "dev": true }, "node_modules/tlsn-js": { - "version": "0.1.0-alpha.4.3", - "resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.4.3.tgz", - "integrity": "sha512-3E9i9aQE42gW3a6zsmjfqomDgG1baqj6D1z5dp40Q8b6oETpSpAKDN021tfs9woLyI0xRWxO1tBcd7gnVtK7zw==", + "version": "0.1.0-alpha.5.2", + "resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.5.2.tgz", + "integrity": "sha512-5QEAzjOPLrw7TN5nRYphUbVBihZ2ufIQ+BcKnTw+0MejqZHo9pUcjHGkrkt9EfhdkC2zsWWKbDZXlAPxwaPtOQ==", "dependencies": { "comlink": "^4.4.1" }, @@ -34888,9 +34888,9 @@ "dev": true }, "tlsn-js": { - "version": "0.1.0-alpha.4.3", - "resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.4.3.tgz", - "integrity": "sha512-3E9i9aQE42gW3a6zsmjfqomDgG1baqj6D1z5dp40Q8b6oETpSpAKDN021tfs9woLyI0xRWxO1tBcd7gnVtK7zw==", + "version": "0.1.0-alpha.5.2", + "resolved": "https://registry.npmjs.org/tlsn-js/-/tlsn-js-0.1.0-alpha.5.2.tgz", + "integrity": "sha512-5QEAzjOPLrw7TN5nRYphUbVBihZ2ufIQ+BcKnTw+0MejqZHo9pUcjHGkrkt9EfhdkC2zsWWKbDZXlAPxwaPtOQ==", "requires": { "comlink": "^4.4.1" } diff --git a/web/components/FileUpload/index.tsx b/web/components/FileUpload/index.tsx index ae37ae7..13cf8fc 100644 --- a/web/components/FileUpload/index.tsx +++ b/web/components/FileUpload/index.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useCallback, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { uploadFile } from '../../store/proofupload'; +import { uploadFile, selectProof } from '../../store/proofupload'; import { readFileAsync } from '../../utils'; import NotaryKey from '../NotaryKey'; import ProofDetails from '../ProofDetails'; diff --git a/web/components/ProofDetails/index.tsx b/web/components/ProofDetails/index.tsx index e95f11f..390b526 100644 --- a/web/components/ProofDetails/index.tsx +++ b/web/components/ProofDetails/index.tsx @@ -64,7 +64,7 @@ const ProofDetails: React.FC = ({proof, cid, file}): ReactEle const proofToDisplay = selectedProof?.proof || proof; const inputValue = process.env.NODE_ENV === "development" ? `http://localhost:3000/${selectedProof?.ipfsCID ? selectedProof?.ipfsCID : cid}` - : `www.tlsnexplorer.com/${selectedProof?.ipfsCID ? selectedProof?.ipfsCID : cid}`; + : `https://explorer-tlsn.pse.dev/${selectedProof?.ipfsCID ? selectedProof?.ipfsCID : cid}`; // TODO - Format proof details for redacted data diff --git a/web/components/ProofSelect/index.tsx b/web/components/ProofSelect/index.tsx index 0cc06fe..b20de2a 100644 --- a/web/components/ProofSelect/index.tsx +++ b/web/components/ProofSelect/index.tsx @@ -1,18 +1,19 @@ -import React, { ReactElement } from 'react'; +import React, { ReactElement, useCallback } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { selectProof } from '../../store/proofupload'; +import { selectProof, useSelectedProof } from '../../store/proofupload'; export default function ProofSelect(): ReactElement { const dispatch = useDispatch(); - + const selectedProof = useSelectedProof(); const proofs = useSelector((state: any) => state.proofUpload.proofs); - const handleChange = async (e: React.ChangeEvent) => { + + const handleChange = useCallback(async (e: React.ChangeEvent) => { const selectedIndex = e.target.selectedIndex; const proof = proofs[selectedIndex - 1]; dispatch(selectProof(proof)); - } + }, []); return (
@@ -20,7 +21,7 @@ export default function ProofSelect(): ReactElement {