Skip to content

Commit

Permalink
🐛 FIX: Currently switch account when user connects to another wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
riverrun46 committed Sep 25, 2023
1 parent 4b3ae89 commit db3e36c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pages/accounts/components/Item.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { Ref, computed, inject, ref } from 'vue'
import { ClipboardDocumentCheckIcon, ClipboardDocumentListIcon, PencilSquareIcon } from '@heroicons/vue/24/solid'
import { useRouter } from 'vue-router'
import { API_NET, API_TARGET, Wallet } from 'meta-contract'
import { useQueryClient } from '@tanstack/vue-query'
import accountManager, { type Account, currentAccount } from '@/lib/account'
import { network } from '@/lib/network'
import accountManager, { type Account, getPrivateKey } from '@/lib/account'
import { getNetwork, network } from '@/lib/network'
import { shortestAddress } from '@/lib/formatters'
import EditName from './EditName.vue'
import { useQueryClient } from '@tanstack/vue-query'
import { FEEB } from '@/data/config'
const router = useRouter()
Expand Down Expand Up @@ -55,12 +57,18 @@ const randomColor = (key: string) => {
}
const queryClient = useQueryClient()
const wallet = inject<Ref<Wallet>>('wallet')!
const connect = async () => {
await accountManager.connect(props.account.id)
// invalidate all queries
await queryClient.invalidateQueries()
// update injected wallet
const network = await getNetwork()
const wif = await getPrivateKey()
wallet.value = new Wallet(wif, network as API_NET, FEEB, API_TARGET.MVC)
router.push('/wallet')
}
Expand Down

0 comments on commit db3e36c

Please sign in to comment.