11/* @license Copyright 2024 w3ux authors & contributors
22SPDX-License-Identifier: GPL-3.0-only */
33
4- import { web3Enable } from '@polkagate/extension-dapp'
54import extensions from '@w3ux/extension-assets'
65import { createSafeContext } from '@w3ux/hooks'
76import type { ExtensionStatus } from '@w3ux/types'
8- import { setStateWithRef , withTimeout } from '@w3ux/utils'
7+ import { setStateWithRef } from '@w3ux/utils'
98import type { ReactNode } from 'react'
109import { useEffect , useRef , useState } from 'react'
1110import type { ExtensionsContextInterface } from './types'
1211
1312export const [ ExtensionsContext , useExtensions ] =
1413 createSafeContext < ExtensionsContextInterface > ( )
1514
16- export const ExtensionsProvider = ( {
17- children,
18- options,
19- } : {
20- children : ReactNode
21- options ?: {
22- chainSafeSnapEnabled ?: boolean
23- polkagateSnapEnabled ?: boolean
24- }
25- } ) => {
15+ export const ExtensionsProvider = ( { children } : { children : ReactNode } ) => {
2616 // Store whether initial `injectedWeb3` checking is underway.
2717 //
2818 // Injecting `injectedWeb3` is an asynchronous process, so we need to check for its existence for
@@ -40,11 +30,6 @@ export const ExtensionsProvider = ({
4030 > ( { } )
4131 const extensionsStatusRef = useRef ( extensionsStatus )
4232
43- // Store whether Metamask Snaps are enabled.
44- const [ polkaGateSnapEnabled ] = useState < boolean > (
45- options ?. polkagateSnapEnabled || false
46- )
47-
4833 // Listen for window.injectedWeb3 with an interval.
4934 let injectedWeb3Interval : ReturnType < typeof setInterval >
5035 const injectCounter = useRef < number > ( 0 )
@@ -54,18 +39,12 @@ export const ExtensionsProvider = ({
5439 // Clear interval and move on to checking for Metamask Polkadot Snap.
5540 const handleClearInterval = async ( hasInjectedWeb3 : boolean ) => {
5641 clearInterval ( injectedWeb3Interval )
57-
58- // Check if Metamask PolkaGate Snap is available.
59- if ( polkaGateSnapEnabled ) {
60- await withTimeout ( 500 , web3Enable ( 'snap_only' ) )
61-
62- if ( hasInjectedWeb3 ) {
63- setStateWithRef (
64- getExtensionsStatus ( ) ,
65- setExtensionsStatus ,
66- extensionsStatusRef
67- )
68- }
42+ if ( hasInjectedWeb3 ) {
43+ setStateWithRef (
44+ getExtensionsStatus ( ) ,
45+ setExtensionsStatus ,
46+ extensionsStatusRef
47+ )
6948 }
7049 setStateWithRef ( false , setCheckingInjectedWeb3 , checkingInjectedWeb3Ref )
7150 }
@@ -134,9 +113,8 @@ export const ExtensionsProvider = ({
134113 }
135114 }
136115
137- // Check for `injectedWeb3` and Metamask Snap on mount. To trigger interval on soft page
138- // refreshes, no empty dependency array is provided to this `useEffect`. Checks for `injectedWeb3`
139- // for a total of 3 seconds before giving up.
116+ // To trigger interval on soft page refreshes, no empty dependency array is provided to this
117+ // `useEffect`. Checks for `injectedWeb3` for a total of 3 seconds before giving up.
140118 //
141119 // Interval duration.
142120 const checkEveryMs = 300
0 commit comments