Skip to content

Commit

Permalink
🐛 FIX: Migrate to v2 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
riverrun46 committed Oct 2, 2023
1 parent 0c325ed commit e89bda8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "metalet",
"private": true,
"version": "2.0.2",
"version": "2.0.3",
"type": "module",
"scripts": {
"dev": "vite --config vite.dev.config.ts",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Metalet",
"description": "An MVC Crypto Wallet Extension",
"version": "2.0.2",
"version": "2.0.3",
"manifest_version": 3,
"action": {
"default_popup": "index.html",
Expand Down
2 changes: 1 addition & 1 deletion src/data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const FEEB = 1
export const NOTIFICATION_WIDTH = 360
export const NOTIFICATION_HEIGHT = 620

export const VERSION = '2.0.2'
export const VERSION = '2.0.3'
5 changes: 3 additions & 2 deletions src/lib/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ export async function getCurrentAccount(): Promise<Account | null> {
return null
}

currentAccount.value = await getAccount(currentAccountId)
const account = await getAccount(currentAccountId)
currentAccount.value = account

return currentAccount.value
return account
}

export async function removeCurrentAccount(): Promise<boolean> {
Expand Down
7 changes: 4 additions & 3 deletions src/pages/migrate/Index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import MetaletLogoImg from '@/assets/images/metalet-logo.png?url'
import accountManager from '@/lib/account'
import accountManager, { getAccounts } from '@/lib/account'
import type { Account } from '@/lib/account'
import { mvc } from 'meta-contract'
import { setNetwork } from '@/lib/network'
Expand All @@ -18,8 +18,9 @@ const importWallet = async () => {
const mneStr = oldRecord.currentAccount.mnemonicStr
// 比照查看有无该助记词的账号
const accounts: Account[] = await accountManager.all().then((res) => Object.values(res))
const hasAccount = accounts.some((account) => account.mnemonic === mneStr)
const accounts = await getAccounts()
const accountsArr = Array.from(accounts.values())
const hasAccount = accountsArr.some((account) => account.mnemonic === mneStr)
if (!hasAccount) {
// 迁移过程
Expand Down
7 changes: 4 additions & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as VueRouter from 'vue-router'
import Wallet from './pages/wallet/Index.vue'
import { getStorage } from './lib/storage'
import accountManager, { getCurrentAccount } from './lib/account'
import accountManager, { Account, getAccounts, getCurrentAccount } from './lib/account'

const routes = [
{ path: '/', redirect: '/wallet' },
Expand Down Expand Up @@ -254,8 +254,9 @@ router.beforeEach(async (to, from) => {
const mneStr = oldRecord.currentAccount.mnemonicStr

// 比照查看有无该助记词的账号
const accounts: any[] = await accountManager.all().then((res) => Object.values(res))
const hasAccount = accounts.some((account) => account.mnemonic === mneStr)
const accounts = await getAccounts()
const accountsArr = Array.from(accounts.values())
const hasAccount = accountsArr.some((account) => account.mnemonic === mneStr)

if (!hasAccount && to.path !== '/migrate') {
return '/migrate'
Expand Down

0 comments on commit e89bda8

Please sign in to comment.