Skip to content

Commit

Permalink
Add user rejected alert
Browse files Browse the repository at this point in the history
  • Loading branch information
xavikh committed Mar 15, 2024
1 parent 3ef3c7e commit d5e877f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
30 changes: 20 additions & 10 deletions hooks/usePermit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ export function usePermit() {
});
const [nonceResult, nameResult, versionResult] = erc20data || [];

const { signTypedDataAsync: permitSign, status: permitSignStatus } = useSignTypedData();
const { signTypedDataAsync: permitSign, status: permitSignStatus, error: permitSignError } = useSignTypedData();

useEffect(() => {
switch (permitSignStatus) {
case "idle":
case "pending":
return;
case "error":
addAlert("Could not sign the permit", { type: "error", timeout: 1500 });
if (permitSignError?.message?.startsWith("User rejected the request")) {
addAlert("Transaction rejected by the user", {
timeout: 4 * 1000,
});
} else {
addAlert("Could not sign the permit", { type: "error", timeout: 1500 });
}
return;
case "success":
addAlert("Permit signed", { type: "success", timeout: 1500 });
Expand Down Expand Up @@ -81,15 +87,19 @@ export function usePermit() {
deadline,
};

let sig = await permitSign({
account: account_address,
types,
domain,
primaryType: 'Permit',
message,
});
try {
let sig = await permitSign({
account: account_address,
types,
domain,
primaryType: 'Permit',
message,
});

return hexToSignature(sig);
return hexToSignature(sig);
} catch (e) {
return;
}
};

return {
Expand Down
1 change: 0 additions & 1 deletion plugins/lockToVote/hooks/useProposalVeto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function useProposalVeto(proposalId: string) {
timeout: 4 * 1000,
});
} else {
console.error(vetoingError);
addAlert("Could not create the veto", { type: "error" });
}
return;
Expand Down

0 comments on commit d5e877f

Please sign in to comment.