-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add network as criteria of manage token list
- Loading branch information
Showing
32 changed files
with
509 additions
and
89 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/adena-extension/src/common/constants/interval.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const HISTORY_FETCH_INTERVAL_TIME = 3 * 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/adena-extension/src/migrates/migrations/v004/storage-migration-v004.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { decryptAES } from 'adena-module'; | ||
import { StorageMigration004 } from './storage-migration-v004'; | ||
|
||
const mockStorageData = { | ||
NETWORKS: [], | ||
CURRENT_CHAIN_ID: '', | ||
CURRENT_NETWORK_ID: '', | ||
SERIALIZED: 'U2FsdGVkX19eI8kOCI/T9o1Ru0b2wdj5rHxmG4QbLQ0yZH4kDa8/gg6Ac2JslvEm', | ||
ENCRYPTED_STORED_PASSWORD: '', | ||
CURRENT_ACCOUNT_ID: '', | ||
ACCOUNT_NAMES: {}, | ||
ESTABLISH_SITES: {}, | ||
ADDRESS_BOOK: [], | ||
ACCOUNT_TOKEN_METAINFOS: {}, | ||
}; | ||
|
||
describe('serialized wallet migration V003', () => { | ||
it('version', () => { | ||
const migration = new StorageMigration004(); | ||
expect(migration.version).toBe(4); | ||
}); | ||
|
||
it('up success', async () => { | ||
const mockData = { | ||
version: 2, | ||
data: mockStorageData, | ||
}; | ||
const migration = new StorageMigration004(); | ||
const result = await migration.up(mockData); | ||
|
||
expect(result.version).toBe(4); | ||
expect(result.data).not.toBeNull(); | ||
expect(result.data.NETWORKS).toEqual([]); | ||
expect(result.data.CURRENT_CHAIN_ID).toBe(''); | ||
expect(result.data.CURRENT_NETWORK_ID).toBe(''); | ||
expect(result.data.SERIALIZED).toBe( | ||
'U2FsdGVkX19eI8kOCI/T9o1Ru0b2wdj5rHxmG4QbLQ0yZH4kDa8/gg6Ac2JslvEm', | ||
); | ||
expect(result.data.ENCRYPTED_STORED_PASSWORD).toBe(''); | ||
expect(result.data.CURRENT_ACCOUNT_ID).toBe(''); | ||
expect(result.data.ACCOUNT_NAMES).toEqual({}); | ||
expect(result.data.ESTABLISH_SITES).toEqual({}); | ||
expect(result.data.ADDRESS_BOOK).toEqual([]); | ||
}); | ||
|
||
it('up password success', async () => { | ||
const mockData = { | ||
version: 1, | ||
data: mockStorageData, | ||
}; | ||
const password = '123'; | ||
const migration = new StorageMigration004(); | ||
const result = await migration.up(mockData, password); | ||
|
||
expect(result.version).toBe(4); | ||
expect(result.data).not.toBeNull(); | ||
expect(result.data.NETWORKS).toEqual([]); | ||
expect(result.data.CURRENT_CHAIN_ID).toBe(''); | ||
expect(result.data.CURRENT_NETWORK_ID).toBe(''); | ||
expect(result.data.SERIALIZED).not.toBe(''); | ||
expect(result.data.ENCRYPTED_STORED_PASSWORD).toBe(''); | ||
expect(result.data.CURRENT_ACCOUNT_ID).toBe(''); | ||
expect(result.data.ACCOUNT_NAMES).toEqual({}); | ||
expect(result.data.ESTABLISH_SITES).toEqual({}); | ||
expect(result.data.ADDRESS_BOOK).toEqual([]); | ||
|
||
const serialized = result.data.SERIALIZED; | ||
const decrypted = await decryptAES(serialized, password); | ||
const wallet = JSON.parse(decrypted); | ||
|
||
expect(wallet.accounts).toHaveLength(0); | ||
expect(wallet.keyrings).toHaveLength(0); | ||
}); | ||
|
||
it('up failed throw error', async () => { | ||
const mockData: any = { | ||
version: 1, | ||
data: { ...mockStorageData, SERIALIZED: null }, | ||
}; | ||
const migration = new StorageMigration004(); | ||
|
||
await expect(migration.up(mockData)).rejects.toThrow( | ||
'Stroage Data doesn not match version V003', | ||
); | ||
}); | ||
}); |
Oops, something went wrong.