Skip to content

Commit

Permalink
Fix for differentiate onchain and offchain vouch for removal
Browse files Browse the repository at this point in the history
Prefetch cross chain transfer
  • Loading branch information
martillansky committed Feb 22, 2024
1 parent 3658036 commit daf1bf2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/app/[pohid]/CrossChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default withClientConnected<CrossChainProps>(function CrossChain({
const web3Loaded = useWeb3Loaded();
const chainId = useChainId();

const [prepareTransfer] = useCCPoHWrite(
const [prepareTransfer, doTransfer] = useCCPoHWrite(
"transferHumanity",
useMemo(
() => ({
Expand Down Expand Up @@ -107,7 +107,7 @@ export default withClientConnected<CrossChainProps>(function CrossChain({
<Modal
formal
header="Transfer"
trigger={<button className="text-sky-500">Transfer</button>}
trigger={<button className="text-sky-500" onClick={doTransfer}>Transfer</button>}
>
<div className="p-4">
<span className="txt m-2">
Expand Down
4 changes: 2 additions & 2 deletions src/app/[pohid]/[chain]/[request]/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
(
(onChainVouches.some(voucherAddress => {
if (voucherAddress === address?.toLocaleLowerCase()) {
setIsVouchGranted({...isVouchGranted, isVouchOnchain: true});
setIsVouchGranted(prevState => ({...prevState, isVouchOnchain: true}));
return true;
}
return false;
Expand All @@ -173,7 +173,7 @@ export default withClientConnected<ActionBarProps>(function ActionBar({
}

if (didIVouchFor())
setIsVouchGranted({...isVouchGranted, didIVouchFor: true});
setIsVouchGranted(prevState => ({...prevState, didIVouchFor: true}));
}, [address, action, requester, revocation, chain, userChainId]);

useEffectOnce(() => {
Expand Down
18 changes: 2 additions & 16 deletions src/app/[pohid]/[chain]/[request]/RemoveVouch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,9 @@ export default function RemoveVouch({ pohId, requester, isOnchain }: RemoveVouch
},
});
};
/* const removeOffchainVouch = async () => {
try {
await axios.delete(`/api/vouch/${chain.name}/remove`, {
data: {
pohId: pohId,
voucher: voucher
}
});
toast.success("Vouch removed successfully");
} catch (err) {
console.error(err);
toast.error("Some error occurred");
}
};
*/

const removeVouch = () => {
if (isOnchain)
if (isOnchain)
removeOnchainVouch()
else
removeOffchainVouch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export async function GET(

if (!chain) throw new Error("unsupported chain");

console.log(params);

const { data, error } = await datalake
.from("poh-vouchdb")
.select("*")
Expand Down
1 change: 0 additions & 1 deletion src/utils/case.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const camelToTitle = (strIn: string, revocation?: boolean, expired?: boolean) => {
console.log(strIn)
let str: string = strIn;
switch (strIn) {
case "vouching":
Expand Down

0 comments on commit daf1bf2

Please sign in to comment.