Skip to content

Commit

Permalink
refactor: update coinbase catch logic
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk committed Jun 12, 2024
1 parent c683e4d commit 3b64225
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/ethers/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export interface Web3ModalClientOptions extends Omit<LibraryOptions, 'defaultCha
tokens?: Record<number, Token>
}

type CoinbaseProviderError = {
code: number
message: string
data: string | undefined
}

export type Web3ModalOptions = Omit<Web3ModalClientOptions, '_sdkVersion'>

declare global {
Expand Down Expand Up @@ -281,6 +287,7 @@ export class Web3Modal extends Web3ModalScaffold {
this.setCoinbaseProvider(ethersConfig)
} catch (error) {
EthersStoreUtil.setError(error)
throw new Error((error as CoinbaseProviderError).message)
}
} else if (id === ConstantsUtil.AUTH_CONNECTOR_ID) {
this.setAuthProvider()
Expand Down
7 changes: 7 additions & 0 deletions packages/ethers5/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export interface Web3ModalClientOptions extends Omit<LibraryOptions, 'defaultCha
tokens?: Record<number, Token>
}

type CoinbaseProviderError = {
code: number
message: string
data: string | undefined
}

export type Web3ModalOptions = Omit<Web3ModalClientOptions, '_sdkVersion'>

declare global {
Expand Down Expand Up @@ -256,6 +262,7 @@ export class Web3Modal extends Web3ModalScaffold {
await CoinbaseProvider.request({ method: 'eth_requestAccounts' })
} catch (error) {
EthersStoreUtil.setError(error)
throw new Error((error as CoinbaseProviderError).message)
}
}
},
Expand Down

0 comments on commit 3b64225

Please sign in to comment.