Skip to content

Commit

Permalink
add getProvider api
Browse files Browse the repository at this point in the history
  • Loading branch information
Gergo Nagy committed Apr 13, 2022
1 parent 2f5c054 commit 4207b3a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/window-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ if (!window.walletRouter) {
hasProvider(checkIdentity: (provider: WalletProvider) => boolean) {
return this.providers.some(checkIdentity)
},
getProvider(checkIdentity: (provider: WalletProvider) => boolean) {
const providerIndex = this.providers.findIndex(checkIdentity)
return this.providers[providerIndex]
},
setCurrentProvider(checkIdentity: (provider: WalletProvider) => boolean) {
if (!this.hasProvider(checkIdentity)) {
throw new Error(
"The given identity did not match to any of the recognized providers!"
)
}
const providerIdex = this.providers.findIndex(checkIdentity)
this.previousProvider = this.currentProvider
this.currentProvider = this.providers[providerIdex]
this.currentProvider = this.getProvider(checkIdentity)
},
addProvider(newProvider: WalletProvider) {
if (!this.providers.includes(newProvider)) {
Expand Down

0 comments on commit 4207b3a

Please sign in to comment.