Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add integration with cancel recovery #53

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion packages/auth-server/composables/useRecoveryGuardian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const useRecoveryGuardian = () => {
});

const { inProgress: confirmGuardianInProgress, error: confirmGuardianError, execute: confirmGuardian } = useAsync(async (account: Address) => {
const client = await getWalletClient({ chainId: defaultChain.id });
const client = getWalletClient({ chainId: defaultChain.id });
const [address] = await client.getAddresses();
const tx = await client.writeContract({
account: address,
Expand All @@ -91,6 +91,25 @@ export const useRecoveryGuardian = () => {
return tx;
});

const { inProgress: getPendingRecoveryDataInProgress, error: getPendingRecoveryDataError, execute: getPendingRecoveryData, result: getPendingRecoveryDataResult } = useAsync(async (account: Address) => {
const client = getPublicClient({ chainId: defaultChain.id });
return await client.readContract({
address: contractsByChain[defaultChain.id].recovery,
abi: GuardianRecoveryModuleAbi,
functionName: "pendingRecoveryData",
args: [account],
});
});

const { inProgress: discardRecoveryInProgress, error: discardRecoveryError, execute: discardRecovery } = useAsync(async () => {
const client = getClient({ chainId: defaultChain.id });
return await client.writeContract({
aon marked this conversation as resolved.
Show resolved Hide resolved
address: contractsByChain[defaultChain.id].recovery,
abi: GuardianRecoveryModuleAbi,
functionName: "discardRecovery",
});
});

return {
confirmGuardianInProgress,
confirmGuardianError,
Expand All @@ -108,5 +127,12 @@ export const useRecoveryGuardian = () => {
getGuardiansError,
getGuardiansData,
getGuardians,
getPendingRecoveryDataInProgress,
getPendingRecoveryDataError,
getPendingRecoveryData,
getPendingRecoveryDataResult,
discardRecoveryInProgress,
discardRecoveryError,
discardRecovery,
};
};
21 changes: 15 additions & 6 deletions packages/auth-server/pages/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,28 @@
<script setup lang="ts">
import { ExclamationTriangleIcon } from "@heroicons/vue/24/solid";

definePageMeta({
middleware: ["logged-in"],
layout: "dashboard",
});
const { address } = useAccountStore();
const { getPendingRecoveryData, discardRecovery } = useRecoveryGuardian();

const pendingRecovery = ref(false);

const cancelRecovery = () => {
// TODO: Implement recovery cancellation
watchEffect(async () => {
if (!address) return;
const recoveryProcessInitiated = await getPendingRecoveryData(address);
pendingRecovery.value = recoveryProcessInitiated?.[0] !== "0x" && recoveryProcessInitiated?.[1] !== 0n;
});

const cancelRecovery = async () => {
await discardRecovery();
pendingRecovery.value = false;
};

const dismissWarning = () => {
pendingRecovery.value = false;
};

definePageMeta({
middleware: ["logged-in"],
layout: "dashboard",
});
</script>
Loading
Loading