Skip to content

Commit

Permalink
restructure showing error message
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvoskamp committed Feb 22, 2024
1 parent 20a6242 commit ad73d24
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
7 changes: 3 additions & 4 deletions packages/ethers/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {
PublicStateControllerState,
Token
} from '@web3modal/scaffold'
import { ModalController, SnackController } from '@web3modal/core'
import { Web3ModalScaffold } from '@web3modal/scaffold'
import { ConstantsUtil, PresetsUtil, HelpersUtil } from '@web3modal/scaffold-utils'
import EthereumProvider from '@walletconnect/ethereum-provider'
Expand Down Expand Up @@ -765,7 +764,7 @@ export class Web3Modal extends Web3ModalScaffold {
this.emailProvider?.rejectRpcRequest()
super.open()
setTimeout(() => {
SnackController.showError('This RPC method is not supported')
this.showErrorMessage('This RPC method is not supported')
}, 300)
}
})
Expand All @@ -784,8 +783,8 @@ export class Web3Modal extends Web3ModalScaffold {

private watchModal() {
if (this.emailProvider) {
ModalController.subscribeKey('open', val => {
if (!val) {
this.subscribeState(val => {
if (!val.open) {
this.emailProvider?.rejectRpcRequest()
}
})
Expand Down
11 changes: 10 additions & 1 deletion packages/scaffold/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
OptionsController,
PublicStateController,
ThemeController,
SIWEController
SIWEController,
SnackController
} from '@web3modal/core'
import { setColorTheme, setThemeVariables } from '@web3modal/ui'

Expand Down Expand Up @@ -115,6 +116,14 @@ export class Web3ModalScaffold {
return PublicStateController.subscribe(callback)
}

public showErrorMessage(message: string) {
SnackController.showError(message)
}

public showSuccessMessage(message: string) {
SnackController.showSuccess(message)
}

public getEvent() {
return { ...EventsController.state }
}
Expand Down
10 changes: 5 additions & 5 deletions packages/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from './utils/helpers.js'
import { W3mFrameHelpers } from '@web3modal/wallet'
import type { W3mFrameProvider } from '@web3modal/wallet'
import { ConstantsUtil as CoreConstants, ModalController, SnackController } from '@web3modal/core'
import { ConstantsUtil as CoreConstants } from '@web3modal/core'
import type { defaultWagmiConfig as coreConfig } from './utils/defaultWagmiCoreConfig.js'
import type { defaultWagmiConfig as reactConfig } from './utils/defaultWagmiReactConfig.js'

Expand Down Expand Up @@ -399,11 +399,11 @@ export class Web3Modal extends Web3ModalScaffold {
super.open({ view: 'ApproveTransaction' })
}
} else {
provider.rejectRpcRequest()
super.open()
setTimeout(() => {
SnackController.showError('This RPC method is not supported')
this.showErrorMessage('This RPC method is not supported')
}, 300)
provider.rejectRpcRequest()
}
})

Expand All @@ -427,8 +427,8 @@ export class Web3Modal extends Web3ModalScaffold {
connector: Web3ModalClientOptions<CoreConfig>['wagmiConfig']['connectors'][number]
) {
const provider = (await connector.getProvider()) as W3mFrameProvider
ModalController.subscribeKey('open', val => {
if (!val) {
this.subscribeState(val => {
if (!val.open) {
provider.rejectRpcRequest()
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/src/W3mFrameConstants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const W3mFrameConstants = {
SECURE_SITE_SDK: 'https://secure.walletconnect.com/sdk',
SECURE_SITE_SDK: 'http://localhost:3010/sdk',
APP_EVENT_KEY: '@w3m-app/',
FRAME_EVENT_KEY: '@w3m-frame/',
RPC_METHOD_KEY: 'RPC_',
Expand Down

0 comments on commit ad73d24

Please sign in to comment.