Revert "refactor(react-dapp-v2): replaces legacy qrcodeModal with web3modalV2"
This reverts commit 2083b4ae41
.
This commit is contained in:
parent
2083b4ae41
commit
3d03e9c6bc
@ -16,12 +16,10 @@
|
|||||||
"@polkadot/util-crypto": "^10.1.2",
|
"@polkadot/util-crypto": "^10.1.2",
|
||||||
"@solana/web3.js": "^1.36.0",
|
"@solana/web3.js": "^1.36.0",
|
||||||
"@walletconnect/encoding": "^1.0.1",
|
"@walletconnect/encoding": "^1.0.1",
|
||||||
|
"@walletconnect/qrcode-modal": "^1.7.8",
|
||||||
"@walletconnect/sign-client": "2.1.0",
|
"@walletconnect/sign-client": "2.1.0",
|
||||||
"@walletconnect/types": "2.1.0",
|
"@walletconnect/types": "2.1.0",
|
||||||
"@walletconnect/utils": "2.1.0",
|
"@walletconnect/utils": "2.1.0",
|
||||||
"@web3modal/core": "^2.0.0-beta.3",
|
|
||||||
"@web3modal/ethereum": "^2.0.0-beta.3",
|
|
||||||
"@web3modal/ui": "^2.0.0-beta.3",
|
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"blockies-ts": "^1.0.0",
|
"blockies-ts": "^1.0.0",
|
||||||
"bs58": "^5.0.0",
|
"bs58": "^5.0.0",
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
if (!process.env.NEXT_PUBLIC_PROJECT_ID)
|
|
||||||
throw new Error("`NEXT_PUBLIC_PROJECT_ID` env variable is missing.");
|
|
||||||
|
|
||||||
export const DEFAULT_MAIN_CHAINS = [
|
export const DEFAULT_MAIN_CHAINS = [
|
||||||
// mainnets
|
// mainnets
|
||||||
"eip155:1",
|
"eip155:1",
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import Client from "@walletconnect/sign-client";
|
import Client from "@walletconnect/sign-client";
|
||||||
import { PairingTypes, SessionTypes } from "@walletconnect/types";
|
import { PairingTypes, SessionTypes } from "@walletconnect/types";
|
||||||
import { ConfigCtrl as ModalConfigCtrl, ModalCtrl } from "@web3modal/core";
|
import QRCodeModal from "@walletconnect/qrcode-modal";
|
||||||
import type { W3mModal } from "@web3modal/ui";
|
|
||||||
import "@web3modal/ui";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createContext,
|
createContext,
|
||||||
ReactNode,
|
ReactNode,
|
||||||
@ -52,14 +49,6 @@ interface IContext {
|
|||||||
*/
|
*/
|
||||||
export const ClientContext = createContext<IContext>({} as IContext);
|
export const ClientContext = createContext<IContext>({} as IContext);
|
||||||
|
|
||||||
/**
|
|
||||||
* Web3Modal Config
|
|
||||||
*/
|
|
||||||
ModalConfigCtrl.setConfig({
|
|
||||||
projectId: DEFAULT_PROJECT_ID,
|
|
||||||
theme: "light" as const,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider
|
* Provider
|
||||||
*/
|
*/
|
||||||
@ -153,11 +142,9 @@ export function ClientContextProvider({
|
|||||||
|
|
||||||
// Open QRCode modal if a URI was returned (i.e. we're not connecting an existing pairing).
|
// Open QRCode modal if a URI was returned (i.e. we're not connecting an existing pairing).
|
||||||
if (uri) {
|
if (uri) {
|
||||||
// Create a flat array of all requested chains across namespaces.
|
QRCodeModal.open(uri, () => {
|
||||||
const standaloneChains = Object.values(requiredNamespaces)
|
console.log("EVENT", "QR Code Modal closed");
|
||||||
.map((namespace) => namespace.chains)
|
});
|
||||||
.flat();
|
|
||||||
ModalCtrl.open({ uri, standaloneChains });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const session = await approval();
|
const session = await approval();
|
||||||
@ -170,7 +157,7 @@ export function ClientContextProvider({
|
|||||||
// ignore rejection
|
// ignore rejection
|
||||||
} finally {
|
} finally {
|
||||||
// close modal in case it was open
|
// close modal in case it was open
|
||||||
ModalCtrl.close();
|
QRCodeModal.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[chains, client, onSessionConnected]
|
[chains, client, onSessionConnected]
|
||||||
@ -319,23 +306,11 @@ export function ClientContextProvider({
|
|||||||
...value,
|
...value,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<>
|
{children}
|
||||||
{children}
|
|
||||||
<w3m-modal></w3m-modal>
|
|
||||||
</>
|
|
||||||
</ClientContext.Provider>
|
</ClientContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let Typescript know about the custom w3m-modal dom / webcomponent element
|
|
||||||
declare global {
|
|
||||||
namespace JSX {
|
|
||||||
interface IntrinsicElements {
|
|
||||||
"w3m-modal": Partial<W3mModal>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useWalletConnectClient() {
|
export function useWalletConnectClient() {
|
||||||
const context = useContext(ClientContext);
|
const context = useContext(ClientContext);
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user