-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(web-extension)!: make KeyAgentFactory methods async
Bip32Ed25519 was refactored to synchronous methods by hoisting sodium await to top level in #1558, which makes it difficult to use SigningCoordinator without top level await
- Loading branch information
1 parent
fdf1e41
commit 069b2b5
Showing
5 changed files
with
21 additions
and
13 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
20 changes: 15 additions & 5 deletions
20
packages/web-extension/src/walletManager/SigningCoordinator/KeyAgentFactory.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 |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import { InMemoryKeyAgent, InMemoryKeyAgentProps, KeyAgentDependencies } from '@cardano-sdk/key-management'; | ||
import { Bip32Ed25519 } from '@cardano-sdk/crypto'; | ||
import { InMemoryKeyAgent, InMemoryKeyAgentProps } from '@cardano-sdk/key-management'; | ||
import { LedgerKeyAgent, LedgerKeyAgentProps } from '@cardano-sdk/hardware-ledger'; | ||
import { Logger } from 'ts-log'; | ||
import { TrezorKeyAgent, TrezorKeyAgentProps } from '@cardano-sdk/hardware-trezor'; | ||
|
||
export const createKeyAgentFactory = (dependencies: KeyAgentDependencies) => ({ | ||
InMemory: (props: InMemoryKeyAgentProps) => new InMemoryKeyAgent(props, dependencies), | ||
Ledger: (props: LedgerKeyAgentProps) => new LedgerKeyAgent(props, dependencies), | ||
Trezor: (props: TrezorKeyAgentProps) => new TrezorKeyAgent(props, dependencies) | ||
export type KeyAgentFactoryDependencies = { | ||
logger: Logger; | ||
getBip32Ed25519: () => Promise<Bip32Ed25519>; | ||
}; | ||
|
||
export const createKeyAgentFactory = ({ logger, getBip32Ed25519 }: KeyAgentFactoryDependencies) => ({ | ||
InMemory: async (props: InMemoryKeyAgentProps) => | ||
new InMemoryKeyAgent(props, { bip32Ed25519: await getBip32Ed25519(), logger }), | ||
Ledger: async (props: LedgerKeyAgentProps) => | ||
new LedgerKeyAgent(props, { bip32Ed25519: await getBip32Ed25519(), logger }), | ||
Trezor: async (props: TrezorKeyAgentProps) => | ||
new TrezorKeyAgent(props, { bip32Ed25519: await getBip32Ed25519(), logger }) | ||
}); | ||
|
||
export type KeyAgentFactory = ReturnType<typeof createKeyAgentFactory>; |
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