diff --git a/__tests__/migration/customTokenMigration.test.ts b/__tests__/migration/customTokenMigration.test.ts index eb17b17b5f6..b110ecbb4d2 100644 --- a/__tests__/migration/customTokenMigration.test.ts +++ b/__tests__/migration/customTokenMigration.test.ts @@ -25,7 +25,7 @@ test('should migrate data', () => { { id: '0x9a78649501bbbac285ea4187299471b7ad4abd35', chain: 'eth' }, ]) .then((result) => { - expect(result.preference.addedToken).toEqual({ + expect(result!.preference.addedToken).toEqual({ '0x5853ed4f26a3fcea565b3fbc698bb19cdf6deb85': [ 'bsc:0x9a78649501bbaac285ea4187299471b7ad4abd35', 'cro:0x9a78649501bbaac285ea4187299471b7ad4abd36', @@ -44,6 +44,6 @@ const data1 = { }; test('do nothing if empty', () => { return customTokenMigration.migrator(data1).then((result) => { - expect(result.preference.addedToken).toEqual({}); + expect(result!.preference.addedToken).toEqual({}); }); }); diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index 79e46ab6a35..b93d5604378 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -921,11 +921,6 @@ export class WalletController extends BaseController { return this._setCurrentAccountFromKeyring(keyringInstance); }; - getWatchAddressPreference = (address: string) => - preferenceService.getWatchAddressPreference(address); - - setWatchAddressPreference = preferenceService.setWatchAddressPreference; - addTxExplainCache = (params: { address: string; chainId: number; diff --git a/src/background/service/preference.ts b/src/background/service/preference.ts index d0fce1e824a..ca958c7747e 100644 --- a/src/background/service/preference.ts +++ b/src/background/service/preference.ts @@ -108,6 +108,21 @@ class PreferenceService { if (!this.store.addedToken) { this.store.addedToken = {}; } + if (!this.store.externalLinkAck) { + this.store.externalLinkAck = false; + } + if (!this.store.hiddenAddresses) { + this.store.hiddenAddresses = []; + } + if (!this.store.balanceMap) { + this.store.balanceMap = {}; + } + if (!this.store.useLedgerLive) { + this.store.useLedgerLive = false; + } + if (!this.store.walletSavedList) { + this.store.walletSavedList = []; + } }; getLastTimeSendToken = (address: string) => { @@ -151,27 +166,6 @@ class PreferenceService { return cloneDeep(this.store.hiddenAddresses); }; - getWatchAddressPreference = (address: string) => { - const key = address.toLowerCase(); - if ( - !this.store.watchAddressPreference || - !this.store.watchAddressPreference[key] - ) - return null; - - return this.store.watchAddressPreference[key]; - }; - - setWatchAddressPreference = (address: string, id: number) => { - if (!this.store.watchAddressPreference) { - this.store.watchAddressPreference = {}; - } - this.store.watchAddressPreference = { - ...this.store.watchAddressPreference, - [address.toLowerCase()]: id, - }; - }; - hideAddress = (type: string, address: string, brandName: string) => { this.store.hiddenAddresses = [ ...this.store.hiddenAddresses, diff --git a/src/migrations/customTokenMigration.ts b/src/migrations/customTokenMigration.ts index 9c73ec68905..145fcbb5a3e 100644 --- a/src/migrations/customTokenMigration.ts +++ b/src/migrations/customTokenMigration.ts @@ -9,6 +9,8 @@ export default { _mockData?: any ) { try { + if (data.preference === undefined) return undefined; + const addedTokens: Record = {}; for (const addr in data.preference.addedToken) { addedTokens[addr] = data.preference.addedToken[addr]; @@ -20,7 +22,6 @@ export default { token.length === 42 && token.startsWith('0x') ); - console.log(); const resultTokens: { id: string; chain: string }[] = process.env.NODE_ENV === 'test' ? _mockData