Skip to content

Commit

Permalink
Fix/wallet connect (#18)
Browse files Browse the repository at this point in the history
* feat: add check MM version

* feat: add user reject msg

* fix: time out message

* add description to changelog

* fix: remove check version MM
  • Loading branch information
WhiteNik16 authored Jan 18, 2024
1 parent 95b211f commit 9e2a9ab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
#### Added
- Maintenance page
- Check MetaMask version

#### Fixed
- Remove the option to connect any other wallets except Metamask

## [2.6.1] - 2024-01-09
#### Added
Expand Down
12 changes: 11 additions & 1 deletion src/contexts/Web3ProviderContext/Web3ProviderContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { useLocalStorage } from 'react-use'

import { config } from '@/config'
import { ErrorHandler } from '@/helpers'
import { bus, BUS_EVENTS, ErrorHandler } from '@/helpers'
import { useProvider } from '@/hooks'

interface Web3ProviderContextValue {
Expand Down Expand Up @@ -115,6 +115,16 @@ const Web3ProviderContextProvider: FC<Props> = ({ children }) => {

await providerDetector.init()

const isOkx = !!window?.okxwallet
const isMetamask = providerDetector.providers.metamask && !isOkx

if (!isMetamask) {
return bus.emit(
BUS_EVENTS.warning,
`Unsupported cryptocurrency wallet. Please try again with MetaMask`,
)
}

Provider.setChainsDetails(
Object.entries(config.SUPPORTED_CHAINS_DETAILS).reduce(
(acc, [, chainDetails]) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ErrorHandler {
break
}
case errors.ProviderUserRejectedRequest:
errorMessage = ''
errorMessage = i18n.t('errors.user-reject')
break
case errors.ProviderInternalError:
if (error.message.toLowerCase().includes('timed out')) {
Expand Down
3 changes: 2 additions & 1 deletion src/localization/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
},
"errors": {
"default": "Something went wrong",
"slow-connection": "Time out: Zero-Knowledge proof generation took too long. That can use a lot of power, for the best results:\n\n- Close any tabs you have open\n- Connect the device to power"
"slow-connection": "Time out: Getting Verifaible Credential took too long. That can use a lot of power, for the best results:\n\n- Close any tabs you have open\n- Connect the device to power",
"user-reject": "You canceled the signature request, please try again"
},
"notifications": {
"default-title-success": "Success",
Expand Down
8 changes: 8 additions & 0 deletions src/types/common.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { RawProvider } from '@distributedlab/w3p'

import type { ICON_NAMES } from '@/enums'

declare global {
interface Window {
okxwallet: RawProvider
}
}

export type NotificationObjectPayload = {
title?: string
message: string
Expand Down

0 comments on commit 9e2a9ab

Please sign in to comment.