Skip to content

Commit ea54cec

Browse files
Expose instances for now
1 parent 598dbe6 commit ea54cec

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

packages/wallet/src/Wallet.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ describe('Wallet', () => {
4646
});
4747
});
4848

49+
it('exposes instances', async () => {
50+
const wallet = await setupWallet();
51+
52+
expect(wallet.getInstance('KeyringController').state).toStrictEqual({
53+
isUnlocked: true,
54+
keyrings: expect.any(Array),
55+
encryptionKey: expect.any(String),
56+
encryptionSalt: expect.any(String),
57+
vault: expect.any(String),
58+
});
59+
});
60+
4961
it('supports passing instance options', async () => {
5062
const wallet = new Wallet({
5163
instanceOptions: {

packages/wallet/src/Wallet.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ export class Wallet {
6161
return this.#controllerMetadata;
6262
}
6363

64+
/**
65+
* Get an instantiated controller or service.
66+
*
67+
* @param name - The name.
68+
* @returns - The instance.
69+
* @deprecated - Please use the messenger instead of direct access.
70+
*/
71+
getInstance(name: keyof DefaultInstances) {
72+
return this.#instances[name];
73+
}
74+
6475
async destroy(): Promise<void> {
6576
if (this.#destroyed) {
6677
return;

0 commit comments

Comments
 (0)