Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning false when no wallet is found #119

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/rainbowkit-wallets/src/lib/localStorageWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { PublicClient, mainnet, WalletClient } from 'wagmi'
export default class localStorageWallet {
static storageItemName = 'localstorage-wallet-seed'

public static async getWallet(provider: PublicClient): Promise<WalletClient> {
public static async getWallet(provider: PublicClient): Promise<WalletClient | false> {
try {
const value: string = localStorage.getItem(this.storageItemName) as string
if (!value) throw new Error('no wallet found')
if (!value) return false

return this.createWallet(value, provider)
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions packages/rainbowkit-wallets/src/wagmi/inputsConnector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inputsWallet } from '../lib/inputsWallet'
import { localStorageConnector } from './localStorageConnector'
import { PublicClient } from 'wagmi'
import { PublicClient, WalletClient } from 'wagmi'

const IS_SERVER = typeof window === 'undefined'

Expand All @@ -17,6 +17,6 @@ export class inputsConnector extends localStorageConnector {
wallet = await w.create(provider)
}

this.wallet = wallet
this.wallet = wallet as WalletClient
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class localStorageConnector extends Connector {
let wallet = await localStorageWallet.getWallet(provider)
if (!wallet) return false

this.wallet = wallet
this.wallet = wallet as WalletClient

const account = await this.getAccount()
return !!account
Expand All @@ -104,7 +104,7 @@ export class localStorageConnector extends Connector {
let wallet = await localStorageWallet.getWallet(provider)
if (!wallet) throw new ConnectorNotFoundError()

this.wallet = wallet
this.wallet = wallet as WalletClient
return this.wallet
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rainbowkit-wallets/src/wagmi/oAuthConnector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chain, PublicClient } from 'wagmi'
import { Chain, PublicClient, WalletClient } from 'wagmi'
import { oAuthWallet } from '../lib/oAuthWallet'
import { localStorageConnector } from './localStorageConnector'

Expand Down Expand Up @@ -35,6 +35,6 @@ export class oAuthConnector extends localStorageConnector {
wallet = await w.create(provider)
}

this.wallet = wallet
this.wallet = wallet as WalletClient
}
}