Skip to content

Commit

Permalink
Adapt DAppConnector for tests
Browse files Browse the repository at this point in the history
Signed-off-by: Fran Fernandez <fran@kabila.app>
  • Loading branch information
franfernandez20 committed Mar 9, 2024
1 parent 639fddc commit d167d28
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/dapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class DAppConnector {
})
DAppSigner.initialize(this.walletConnectClient)

const existingSessions = this.walletConnectClient.session.getAll()
const existingSessions = this.checkPersistedState()

if (existingSessions) this.signers = existingSessions.flatMap(this.createSigners)

Expand All @@ -142,6 +142,13 @@ export class DAppConnector {
}
}

public checkPersistedState() {
if (!this.walletConnectClient) {
throw new Error('WalletConnect is not initialized')
}
return this.walletConnectClient.session.getAll()
}

public getSigner(accountId: AccountId): DAppSigner {
const signer = this.signers.find((signer) => signer.getAccountId().equals(accountId))
if (!signer) throw new Error('Signer is not found for this accountId')
Expand Down

0 comments on commit d167d28

Please sign in to comment.