From 8cc00bf663bc44cdaba8c3f91fee1bef06f50e35 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Mon, 1 May 2023 08:42:36 -0500 Subject: [PATCH] demo --- src/routes/Redshift.tsx | 136 +++++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 52 deletions(-) diff --git a/src/routes/Redshift.tsx b/src/routes/Redshift.tsx index e1bbdb8..7f5c00d 100644 --- a/src/routes/Redshift.tsx +++ b/src/routes/Redshift.tsx @@ -51,7 +51,7 @@ const dummyRedshift: RedshiftResult = { fees_paid: BigInt(2500), }; -function RedshiftReport(props: { redshift: RedshiftResult }) { +function RedshiftReport(props: { redshift: RedshiftResult, utxo: UtxoItem }) { const [state, _actions] = useMegaStore(); const getUtXos = async () => { @@ -64,9 +64,6 @@ function RedshiftReport(props: { redshift: RedshiftResult }) { return utxos.find((utxo) => utxo.outpoint === outpoint); } - createEffect(() => { - setRedshifted(true, props.redshift?.output_utxo) - }) const [utxos, { refetch: _refetchUtxos }] = createResource(getUtXos); @@ -77,58 +74,92 @@ function RedshiftReport(props: { redshift: RedshiftResult }) { return foundUtxo }) - const outputUtxo = createMemo(() => { - return findUtxoByOutpoint(props.redshift.output_utxo, utxos()) + + async function checkRedshift(outpoint: string) { + // const rs = redshiftItems[0] as RedshiftResult; + console.log("Checking redshift", outpoint) + const redshift = await state.node_manager?.get_redshift(outpoint); + console.log(redshift) + return redshift[0] + } + + const [redshiftResource, { refetch }] = createResource(props.utxo.outpoint, checkRedshift); + onMount(() => { + const interval = setInterval(() => { + if (redshiftResource()) refetch(); + // if (sentAmount() === 200000) { + // clearInterval(interval) + // props.setShiftStage("success"); + // // setSentAmount((0)) + + // } else { + // setSentAmount((sentAmount() + 50000)) + // } + }, 1000) }) + const outputUtxo = createMemo(() => { + return findUtxoByOutpoint(redshiftResource()?.output_utxo, utxos()) + }) + + createEffect(() => { + setRedshifted(true, redshiftResource()?.output_utxo) + }) + + return ( - + {/* We did it. Here's your new UTXO: - + */} What happened? - - - {/* + + + + + {/* */} - - - - - - - - - - - -
{props.redshift.introduction_channel}
- - View on mempool - -
-
- - -
{props.redshift.output_channel}
- - View on mempool - + + + + + + + + + + + +
{redshiftResource().introduction_channel}
+ + View on mempool + +
+
+ + + +
{redshiftResource().output_channel}
+ + View on mempool + -
-
-
-
+
+ + +
+ +
@@ -195,19 +226,19 @@ function ShiftObserver(props: { setShiftStage: (stage: ShiftStage) => void, utxo const [redshiftResource, { refetch }] = createResource(props.utxo.outpoint, checkRedshift); - onMount(() => { - const interval = setInterval(() => { - if (redshiftResource()) refetch(); - // if (sentAmount() === 200000) { - // clearInterval(interval) - // props.setShiftStage("success"); - // // setSentAmount((0)) + // onMount(() => { + // const interval = setInterval(() => { + // if (redshiftResource()) refetch(); + // // if (sentAmount() === 200000) { + // // clearInterval(interval) + // // props.setShiftStage("success"); + // // // setSentAmount((0)) - // } else { - // setSentAmount((sentAmount() + 50000)) - // } - }, 1000) - }) + // // } else { + // // setSentAmount((sentAmount() + 50000)) + // // } + // }, 1000) + // }) // createEffect(() => { // const interval = setInterval(() => { @@ -294,6 +325,7 @@ export default function Redshift() { createEffect(() => { if (chosenUtxo() && initializedRedshift()) { + // window.location.href = "/" setShiftStage("observe"); } }) @@ -357,9 +389,9 @@ export default function Redshift() { - + - +