generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dedicated OneKey keyring class
- Loading branch information
Showing
3 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import HDKey from 'hdkey'; | ||
import * as sinon from 'sinon'; | ||
|
||
import { OneKeyKeyring } from './onekey-keyring'; | ||
import { TrezorBridge } from './trezor-bridge'; | ||
import { TrezorKeyring } from './trezor-keyring'; | ||
|
||
const fakeXPubKey = | ||
'xpub6FnCn6nSzZAw5Tw7cgR9bi15UV96gLZhjDstkXXxvCLsUXBGXPdSnLFbdpq8p9HmGsApME5hQTZ3emM2rnY5agb9rXpVGyy3bdW6EEgAtqt'; | ||
const fakeHdKey = HDKey.fromExtendedKey(fakeXPubKey); | ||
|
||
describe('TrezorKeyring', function () { | ||
let keyring: OneKeyKeyring; | ||
let bridge: TrezorBridge; | ||
|
||
beforeEach(async function () { | ||
bridge = {} as TrezorBridge; | ||
keyring = new OneKeyKeyring({ bridge }); | ||
keyring.hdk = fakeHdKey; | ||
}); | ||
|
||
afterEach(function () { | ||
sinon.restore(); | ||
}); | ||
|
||
it('extends TrezorKeyring', () => { | ||
expect(keyring).toBeInstanceOf(TrezorKeyring); | ||
}); | ||
|
||
describe('Keyring.type', function () { | ||
it('is a class property that returns the type string.', function () { | ||
const { type } = TrezorKeyring; | ||
expect(typeof type).toBe('string'); | ||
}); | ||
|
||
it('returns the correct value', function () { | ||
const { type } = keyring; | ||
const correct = OneKeyKeyring.type; | ||
expect(type).toBe(correct); | ||
}); | ||
}); | ||
}); |
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,9 @@ | ||
import { TrezorKeyring } from './trezor-keyring'; | ||
|
||
const oneKeyKeyringType = 'OneKey Hardware'; | ||
|
||
export class OneKeyKeyring extends TrezorKeyring { | ||
static type: string = oneKeyKeyringType; | ||
|
||
readonly type: string = oneKeyKeyringType; | ||
} |