2026-03-09 07:43:12 +00:00
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { rpcClient } from '@/api/rpc-client'
|
|
|
|
|
|
|
|
|
|
export const useWeb5BadgeStore = defineStore('web5Badge', () => {
|
|
|
|
|
const pendingRequestCount = ref(0)
|
|
|
|
|
|
|
|
|
|
async function refresh() {
|
|
|
|
|
try {
|
|
|
|
|
const res = await rpcClient.call<{ requests: Array<{ id: string }> }>({ method: 'network.list-requests' })
|
|
|
|
|
pendingRequestCount.value = res.requests?.length ?? 0
|
2026-03-11 00:58:55 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
if (import.meta.env.DEV) console.warn('Badge refresh failed — best-effort', e)
|
2026-03-09 07:43:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { pendingRequestCount, refresh }
|
|
|
|
|
})
|