11import { disconnect as masterDisconnect } from '@wagmi/core'
2- import { reactive , watchEffect } from 'vue'
2+ import { reactive , readonly , watchEffect } from 'vue'
33
44import { state as optionsState } from './options'
55import type { AccountState , Chain , ConnectedAccount } from './types'
@@ -11,12 +11,18 @@ export const state = reactive<AccountState>({
1111 currentAccount : null
1212} )
1313
14- export const account = reactive < ConnectedAccount > ( {
14+ const accountState = reactive < ConnectedAccount > ( {
1515 connected : false ,
1616 address : undefined ,
17- shortAddress : undefined
17+ shortAddress : undefined ,
18+ wallet : {
19+ id : undefined ,
20+ name : undefined
21+ }
1822} )
1923
24+ export const account = readonly ( accountState )
25+
2026export async function disconnect ( ) {
2127 await masterDisconnect ( )
2228}
@@ -46,12 +52,16 @@ export function shortAddressFilter(value = '') {
4652
4753watchEffect ( ( ) => {
4854 if ( state . currentAccount ) {
49- account . connected = true
50- account . address = state . currentAccount . address
51- account . shortAddress = shortAddressFilter ( state . currentAccount . address )
55+ accountState . connected = true
56+ accountState . address = state . currentAccount . address
57+ accountState . shortAddress = shortAddressFilter ( state . currentAccount . address )
58+ accountState . wallet . id = state . currentAccount . connector ?. id
59+ accountState . wallet . name = state . currentAccount . connector ?. name
5260 } else {
53- account . connected = false
54- account . address = undefined
55- account . shortAddress = undefined
61+ accountState . connected = false
62+ accountState . address = undefined
63+ accountState . shortAddress = undefined
64+ accountState . wallet . id = undefined
65+ accountState . wallet . name = undefined
5666 }
5767} )
0 commit comments