Skip to content

Commit f88fa39

Browse files
committed
refactor: simplify serialize()
1 parent 261268a commit f88fa39

2 files changed

Lines changed: 7 additions & 30 deletions

File tree

packages/keyring-eth-qr/jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ module.exports = merge(baseConfig, {
1515
displayName,
1616

1717
// An array of regexp pattern strings used to skip coverage collection
18-
coveragePathIgnorePatterns: ['./src/tests'],
18+
coveragePathIgnorePatterns: [],
1919

2020
// An object that configures minimum threshold enforcement for coverage results
2121
coverageThreshold: {
2222
global: {
23-
branches: 91.8,
23+
branches: 91.66,
2424
functions: 100,
25-
lines: 95.04,
26-
statements: 95.14,
25+
lines: 94.97,
26+
statements: 95.07,
2727
},
2828
},
2929
});

packages/keyring-eth-qr/src/qr-keyring.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,33 +131,10 @@ export class QrKeyring implements Keyring {
131131
return getDefaultSerializedQrKeyringState();
132132
}
133133

134-
const accounts = this.#accounts.slice();
135-
136-
if (deviceDetails.keyringMode === DeviceMode.HD) {
137-
// These properties are only relevant for HD Keys
138-
return {
139-
initialized: true,
140-
name: deviceDetails.name,
141-
keyringMode: DeviceMode.HD,
142-
keyringAccount: deviceDetails.keyringAccount,
143-
xfp: deviceDetails.xfp,
144-
xpub: deviceDetails.xpub,
145-
hdPath: deviceDetails.hdPath,
146-
childrenPath: deviceDetails.childrenPath,
147-
accounts,
148-
indexes: deviceDetails.indexes,
149-
};
150-
}
151-
// These properties are only relevant for Account Keys
152134
return {
135+
...deviceDetails,
153136
initialized: true,
154-
name: deviceDetails.name,
155-
keyringMode: DeviceMode.ACCOUNT,
156-
keyringAccount: deviceDetails.keyringAccount,
157-
xfp: deviceDetails.xfp,
158-
paths: deviceDetails.paths,
159-
accounts,
160-
indexes: deviceDetails.indexes,
137+
accounts: this.#accounts.slice(),
161138
};
162139
}
163140

@@ -219,7 +196,7 @@ export class QrKeyring implements Keyring {
219196
* @returns The accounts in the QrKeyring
220197
*/
221198
async getAccounts(): Promise<Hex[]> {
222-
return Array.from(this.#accounts.values());
199+
return this.#accounts.slice();
223200
}
224201

225202
/**

0 commit comments

Comments
 (0)