-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Injected Universal Provider (#3177)
Co-authored-by: tomiir <[email protected]>
- Loading branch information
1 parent
0f55885
commit 3cf3bc5
Showing
20 changed files
with
1,366 additions
and
1,160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
'@reown/appkit-scaffold-ui': patch | ||
'@reown/appkit': patch | ||
'@reown/appkit-core': patch | ||
'@reown/appkit-adapter-ethers': patch | ||
'@reown/appkit-adapter-ethers5': patch | ||
'@reown/appkit-adapter-solana': patch | ||
'@reown/appkit-adapter-wagmi': patch | ||
'@reown/appkit-utils': patch | ||
'@reown/appkit-cdn': patch | ||
'@reown/appkit-cli': patch | ||
'@reown/appkit-common': patch | ||
'@reown/appkit-experimental': patch | ||
'@reown/appkit-polyfills': patch | ||
'@reown/appkit-siwe': patch | ||
'@reown/appkit-siwx': patch | ||
'@reown/appkit-ui': patch | ||
'@reown/appkit-wallet': patch | ||
'@reown/appkit-wallet-button': patch | ||
--- | ||
|
||
Adds walletConnectProvider flag to inject a UniversalProvider instance to be used by AppKit' |
57 changes: 57 additions & 0 deletions
57
apps/laboratory/src/pages/library/custom-universal-provider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { AppKit, createAppKit } from '@reown/appkit/react' | ||
import { ThemeStore } from '../../utils/StoreUtil' | ||
import { ConstantsUtil } from '../../utils/ConstantsUtil' | ||
import { AppKitButtons } from '../../components/AppKitButtons' | ||
import { mainnet } from '@reown/appkit/networks' | ||
import { MultiChainInfo } from '../../components/MultiChainInfo' | ||
import { UpaTests } from '../../components/UPA/UpaTests' | ||
import Provider, { UniversalProvider } from '@walletconnect/universal-provider' | ||
import { useEffect, useState } from 'react' | ||
|
||
const networks = ConstantsUtil.EvmNetworks | ||
|
||
export default function MultiChainWagmiAdapterOnly() { | ||
const [uprovider, setUprovider] = useState<Provider | null>(null) | ||
const [appkit, setAppKit] = useState<AppKit | null>(null) | ||
|
||
async function initializeUniversalProvider() { | ||
const provider = await UniversalProvider.init({ | ||
projectId: ConstantsUtil.ProjectId | ||
}) | ||
|
||
const modal = createAppKit({ | ||
networks, | ||
defaultNetwork: mainnet, | ||
projectId: ConstantsUtil.ProjectId, | ||
metadata: ConstantsUtil.Metadata, | ||
universalProvider: provider | ||
}) | ||
|
||
ThemeStore.setModal(modal) | ||
setAppKit(modal) | ||
|
||
provider.on('display_uri', (connection: string) => { | ||
modal.open({ view: 'ConnectingWalletConnectBasic', uri: connection }) | ||
}) | ||
|
||
setUprovider(provider) | ||
} | ||
|
||
useEffect(() => { | ||
initializeUniversalProvider() | ||
}, []) | ||
|
||
return ( | ||
<> | ||
{uprovider && appkit ? ( | ||
<> | ||
<AppKitButtons /> | ||
<MultiChainInfo /> | ||
<UpaTests /> | ||
</> | ||
) : ( | ||
'' | ||
)} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.