Skip to content

Commit

Permalink
Add additional arguments to the constructor
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
michalsmiarowski committed Nov 9, 2023
1 parent c73d926 commit bfc9182
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion typescript/src/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./backoff"
export * from "./hex"
export * from "./ledger"
export * from "./ledger"
2 changes: 1 addition & 1 deletion typescript/src/lib/utils/ledger/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./ledger"
export * from "./wallet-api"
export * from "./wallet-api"
12 changes: 9 additions & 3 deletions typescript/src/lib/utils/ledger/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit bfc9182

Please sign in to comment.