From bfc918298d5e7f94238b1d9dd3d19b23c00278f8 Mon Sep 17 00:00:00 2001 From: michalsmiarowski Date: Thu, 9 Nov 2023 10:50:30 +0100 Subject: [PATCH] Add additional arguments to the constructor Add additional arguments - `windowsMessageTransport` and `walletApiClient` - that user can pass through argument. They are optional so if the user doesn't pass anything it will automatically initialize it using the methods from `src/lib/utils/ledger/utils.ts`. --- typescript/src/lib/utils/index.ts | 2 +- typescript/src/lib/utils/ledger/index.ts | 2 +- typescript/src/lib/utils/ledger/ledger.ts | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/typescript/src/lib/utils/index.ts b/typescript/src/lib/utils/index.ts index 6ff69c332..b51ccf033 100644 --- a/typescript/src/lib/utils/index.ts +++ b/typescript/src/lib/utils/index.ts @@ -1,3 +1,3 @@ export * from "./backoff" export * from "./hex" -export * from "./ledger" \ No newline at end of file +export * from "./ledger" diff --git a/typescript/src/lib/utils/ledger/index.ts b/typescript/src/lib/utils/ledger/index.ts index 9cc70d33a..f743a463e 100644 --- a/typescript/src/lib/utils/ledger/index.ts +++ b/typescript/src/lib/utils/ledger/index.ts @@ -1,2 +1,2 @@ export * from "./ledger" -export * from "./wallet-api" \ No newline at end of file +export * from "./wallet-api" diff --git a/typescript/src/lib/utils/ledger/ledger.ts b/typescript/src/lib/utils/ledger/ledger.ts index 31b8df44a..bcccc8e53 100644 --- a/typescript/src/lib/utils/ledger/ledger.ts +++ b/typescript/src/lib/utils/ledger/ledger.ts @@ -16,11 +16,17 @@ export class LedgerLiveAppEthereumSigner extends Signer { private _windowMessageTransport: WindowMessageTransport private _account: Account | undefined - constructor(provider: ethers.providers.Provider) { + constructor( + provider: ethers.providers.Provider, + windowMessageTransport?: WindowMessageTransport, + walletApiClient?: WalletAPIClient + ) { super() ethers.utils.defineReadOnly(this, "provider", provider || null) - this._windowMessageTransport = getWindowMessageTransport() - this._walletApiClient = getWalletAPIClient(this._windowMessageTransport) + this._windowMessageTransport = + windowMessageTransport || getWindowMessageTransport() + this._walletApiClient = + walletApiClient || getWalletAPIClient(this._windowMessageTransport) } get account() {