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

Bugfixes for crypto payments #259

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion components/checkout/pay/CryptoPaymentForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ stopWatcher = watchEffect(() => {
redirect();
});

function dismissNotification() {
set(state, 'idle');
set(error, '');
}

watch(canvas, async (canvas) => {
if (!canvas)
return;
Expand Down Expand Up @@ -252,7 +257,7 @@ watch(canvas, async (canvas) => {
:timeout="10000"
closeable
:visible="failure"
@dismiss="state = 'idle'"
@dismiss="dismissNotification()"
>
<template #title>
{{ status?.title }}
Expand Down
18 changes: 6 additions & 12 deletions composables/crypto-payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function useWeb3Payment(data: Ref<CryptoPayment>, state: Ref<StepType | I

appKit.subscribeAccount((account) => {
set(state, 'idle');
set(errorMessage, '');
set(connected, account.isConnected);

if (account.isConnected) {
Expand Down Expand Up @@ -199,15 +200,14 @@ export function useWeb3Payment(data: Ref<CryptoPayment>, state: Ref<StepType | I
signer: await browserProvider.getSigner(),
});
}
catch (error_: any) {
logger.error(error_);
catch (error: any) {
logger.error(error);
set(state, 'idle');

if ('reason' in error_ && error_.reason)
set(errorMessage, error_.reason);

if ('shortMessage' in error)
set(errorMessage, error.shortMessage);
else
set(errorMessage, error_.message);
set(errorMessage, error.message);
}
};

Expand All @@ -225,12 +225,6 @@ export function useWeb3Payment(data: Ref<CryptoPayment>, state: Ref<StepType | I
appKit.switchNetwork(network);
}

watch(state, (state) => {
if (state === 'idle') {
set(errorMessage, '');
}
});

onUnmounted(async () => {
await appKit.disconnect();
});
Expand Down
15 changes: 9 additions & 6 deletions layouts/account.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { get } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import Default from '~/layouts/default.vue';
import { useMainStore } from '~/store';
import { commonAttrs, noIndex } from '~/utils/metadata';
import Default from '~/layouts/default.vue';

const { t } = useI18n();

const store = useMainStore();
const { account } = storeToRefs(store);
const { account } = storeToRefs(useMainStore());

const name = computed(() => {
const name = computed<string>(() => {
const accountVal = get(account);
if (!accountVal)
return '';

const { firstName, lastName } = accountVal.address;
const { firstName, lastName, movedOffline } = accountVal.address;

if (movedOffline) {
return accountVal.username;
}

return `${firstName} ${lastName}`;
});
Expand Down
Loading