Skip to content

Commit

Permalink
WIP verify issue after proving
Browse files Browse the repository at this point in the history
  • Loading branch information
MSghais committed Jul 30, 2024
1 parent defd506 commit eb707d0
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions askeladd-dvm-marketplace/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function Home() {
const [proof, setProof] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [isInitialized, setIsInitialized] = useState(false);
const [isFetchJob, setIsFetchJob] = useState(false);
const [timestampJob, setTimestampJob] = useState<number | undefined>();

const { ndk } = useNostrContext()
Expand All @@ -41,10 +42,10 @@ export default function Home() {

useEffect(() => {

if (jobId) {
if (jobId && !isFetchJob) {
waitingForJobResult()
}
}, [jobId])
}, [jobId, isFetchJob])

const submitJob = async () => {
setIsLoading(true);
Expand All @@ -61,8 +62,11 @@ export default function Home() {
];

const content = JSON.stringify({
log_size: logSize.toString(),
claim: claim.toString()
request: {
log_size: logSize.toString(),
claim: claim.toString()
}

})

// Define the timestamp before which you want to fetch events
Expand All @@ -78,17 +82,19 @@ export default function Home() {
/** NDK event
* Generate or import private key after
*/
// let { result, event } = await sendNote({ content, tags, kind: 5600 })
// console.log("event", event)
// if (event?.sig) {
// setJobId(event?.sig);
// }
let { result, event } = await sendNote({ content, tags, kind: 5600 })
console.log("event", event)
if (event?.sig) {
setJobId(event?.sig);
}

};

// Fetch Job result from the Prover
const fetchEventsProof = async () => {

setIsFetchJob(false)

const { events } = await fetchEvents()
if (!events) return;
console.log("events", events);
Expand All @@ -99,6 +105,8 @@ export default function Home() {
* - Timestamp since/until (doesn't work as expected for me)
*/
let lastEvent = events[events?.length - 1]
// let lastEvent= events.find((e) => e?.id == "48b273cee7d08538604f1797c92685a4638d53a8fea56ff9fe48a436ad4a2e73")
if(!lastEvent) return;
setSelectedEvent(lastEvent)
setProof(lastEvent?.content)

Expand Down Expand Up @@ -153,11 +161,13 @@ export default function Home() {
}
}
setIsLoading(false);
setIsFetchJob(true)
}
} catch (e) {
console.log("Verify error", e);
} finally {
setIsLoading(false);
setIsFetchJob(true)

}
};
Expand Down

0 comments on commit eb707d0

Please sign in to comment.