Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dedicated OneKey keyring class #175

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/keyring-eth-trezor/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ module.exports = merge(baseConfig, {
coverageThreshold: {
global: {
branches: 48.27,
functions: 91.22,
lines: 89.94,
statements: 90.15,
functions: 91.37,
lines: 90.2,
statements: 90.4,
},
},
});
1 change: 1 addition & 0 deletions packages/keyring-eth-trezor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './trezor-keyring';
export * from './onekey-keyring';
export type * from './trezor-bridge';
export * from './trezor-connect-bridge';
42 changes: 42 additions & 0 deletions packages/keyring-eth-trezor/src/onekey-keyring.test.ts
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('OneKeyKeyring', 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);
});
});
});
9 changes: 9 additions & 0 deletions packages/keyring-eth-trezor/src/onekey-keyring.ts
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 {
ccharly marked this conversation as resolved.
Show resolved Hide resolved
static type: string = oneKeyKeyringType;

readonly type: string = oneKeyKeyringType;
}
Loading