Skip to content

Commit

Permalink
Merge pull request #96 from Proof-Of-Humanity/testnets
Browse files Browse the repository at this point in the history
Testnets
  • Loading branch information
martillansky authored Oct 16, 2024
2 parents 7a1f616 + e92be06 commit 528a1a4
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/app/[pohid]/[chain]/[request]/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useEffectOnce } from "@legendapp/state/react";
import { colorForStatus } from "config/misc";
import usePoHWrite from "contracts/hooks/usePoHWrite";
import { ContractData } from "data/contract";
import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { toast } from "react-toastify";
import { Address, Hash, formatEther, hexToSignature } from "viem";
import { useAccount, useChainId } from "wagmi";
Expand Down Expand Up @@ -94,8 +94,9 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
// )
// );

const errorRef = useRef(false);
const offChainRef = useRef(false);
const [action, setAction] = useState(ActionType.NONE);

const [didIVouchFor, setDidIVouchFor] = useState(false);
const [isVouchOnchain, setIsVouchOnchain] = useState(false);

Expand All @@ -111,7 +112,16 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
return false;
}) ||
offChainVouches.some(
(voucher) => voucher.voucher.toLocaleLowerCase() === address?.toLocaleLowerCase()
(voucher) => {
if (voucher.voucher.toLocaleLowerCase() === address?.toLocaleLowerCase()) {
if (!offChainRef.current && userChainId === chain.id) {
toast.error("Off chain vouches cannot be removed");
offChainRef.current = true;
}
return true;
}
return false;
}
))
);
};
Expand Down Expand Up @@ -185,7 +195,8 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
toast.success("Request advanced to resolving state");
},
onFail() {
toast.error("No vouch is valid. Advance is not possible");
!errorRef.current && toast.error("No vouch is valid. Advance is not possible");
errorRef.current = true;
setAction(ActionType.VOUCH);
},
}),
Expand Down

0 comments on commit 528a1a4

Please sign in to comment.