Skip to content

Commit bfd8c41

Browse files
committed
chore: refactors and cleanups x402 hooks
1 parent ee7f4f8 commit bfd8c41

File tree

8 files changed

+128
-445
lines changed

8 files changed

+128
-445
lines changed

demo/vue-app-new/package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/vue-app-new/src/components/X402Tester.vue

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ const parseConsoleBody = (text: string) => {
3030
}
3131
};
3232
33-
watch(chainId, (id) => {
34-
isOnBaseSepolia.value = id?.toLowerCase() === BASE_SEPOLIA_CHAIN_ID.toLowerCase();
35-
}, { immediate: true });
33+
watch(
34+
chainId,
35+
(id) => {
36+
isOnBaseSepolia.value = id?.toLowerCase() === BASE_SEPOLIA_CHAIN_ID.toLowerCase();
37+
},
38+
{ immediate: true }
39+
);
3640
3741
const onSwitchToBaseSepolia = async () => {
3842
fetchLoading.value = true;
@@ -73,18 +77,13 @@ const onFetchWithPayment = async () => {
7377

7478
<!-- Status badges -->
7579
<div class="flex flex-wrap gap-2 mb-3 text-xs">
76-
<span
77-
class="px-2 py-1 rounded-full font-medium"
78-
:class="isConnected ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-600'"
79-
>
80+
<span class="px-2 py-1 rounded-full font-medium" :class="isConnected ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-600'">
8081
{{ isConnected ? "Connected" : "Not connected" }}
8182
</span>
8283
<span v-if="chainNamespace" class="px-2 py-1 rounded-full bg-blue-100 text-blue-700 font-medium">
8384
{{ chainNamespace }}
8485
</span>
85-
<span v-if="chainId" class="px-2 py-1 rounded-full bg-gray-100 text-gray-600 font-medium font-mono">
86-
chain {{ chainId }}
87-
</span>
86+
<span v-if="chainId" class="px-2 py-1 rounded-full bg-gray-100 text-gray-600 font-medium font-mono">chain {{ chainId }}</span>
8887
<span
8988
v-if="chainNamespace === CHAIN_NAMESPACES.EIP155"
9089
class="px-2 py-1 rounded-full font-medium"
@@ -96,14 +95,7 @@ const onFetchWithPayment = async () => {
9695

9796
<!-- Switch chain -->
9897
<div v-if="isConnected && chainNamespace === CHAIN_NAMESPACES.EIP155" class="mb-3">
99-
<Button
100-
block
101-
size="xs"
102-
pill
103-
:loading="fetchLoading"
104-
:disabled="isOnBaseSepolia"
105-
@click="onSwitchToBaseSepolia"
106-
>
98+
<Button block size="xs" pill :loading="fetchLoading" :disabled="isOnBaseSepolia" @click="onSwitchToBaseSepolia">
10799
{{ isOnBaseSepolia ? "Already on Base Sepolia" : "Switch to Base Sepolia" }}
108100
</Button>
109101
</div>
@@ -120,16 +112,6 @@ const onFetchWithPayment = async () => {
120112
</div>
121113

122114
<!-- Fetch button -->
123-
<Button
124-
block
125-
size="xs"
126-
pill
127-
:loading="fetchLoading"
128-
:disabled="!isConnected"
129-
class="mb-3"
130-
@click="onFetchWithPayment"
131-
>
132-
Fetch with Payment
133-
</Button>
115+
<Button block size="xs" pill :loading="fetchLoading" :disabled="!isConnected" class="mb-3" @click="onFetchWithPayment">Fetch with Payment</Button>
134116
</Card>
135117
</template>

0 commit comments

Comments
 (0)