From 5f895b3fa342215d2c2be1cb585da5402fd0a7f7 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 15:19:30 -0600 Subject: [PATCH 1/9] fix: web3 auth network --- lib/state/util/web3auth-config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/state/util/web3auth-config.ts b/lib/state/util/web3auth-config.ts index ed5c06771..c12fd58c2 100644 --- a/lib/state/util/web3auth-config.ts +++ b/lib/state/util/web3auth-config.ts @@ -61,7 +61,10 @@ export const web3authNoModal = ? new Web3AuthNoModal({ clientId, chainConfig, - web3AuthNetwork: "sapphire_devnet", + web3AuthNetwork: + process.env.NODE_ENV === "production" + ? "sapphire_mainnet" + : "sapphire_devnet", }) : null; From d0e464dec942f8d2ff6e8f495fce639bd183f4a8 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 15:20:13 -0600 Subject: [PATCH 2/9] chore: add err check --- lib/hooks/useWeb3Wallet.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index dfe346bf5..d031eb90e 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -65,7 +65,8 @@ const useWeb3Wallet = () => { if (web3authProvider) { await getKeypair(web3authProvider); } - } catch { + } catch (e) { + console.log(e); notificationStore.pushNotification( `Error connecting: please try again later.`, { From 295c47d2d1d424666d6e84ae908e72f34221a693 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 15:34:39 -0600 Subject: [PATCH 3/9] fix: env check --- lib/state/util/web3auth-config.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/state/util/web3auth-config.ts b/lib/state/util/web3auth-config.ts index c12fd58c2..243520f32 100644 --- a/lib/state/util/web3auth-config.ts +++ b/lib/state/util/web3auth-config.ts @@ -5,6 +5,7 @@ import { atom } from "jotai"; import { OpenloginAdapter } from "@web3auth/openlogin-adapter"; import { CommonPrivateKeyProvider } from "@web3auth/base-provider"; import { TypeOfLogin } from "@web3auth/openlogin-adapter"; +import { environment } from "lib/constants/index"; interface LoginConfig { [key: string]: { @@ -62,9 +63,7 @@ export const web3authNoModal = clientId, chainConfig, web3AuthNetwork: - process.env.NODE_ENV === "production" - ? "sapphire_mainnet" - : "sapphire_devnet", + environment === "production" ? "sapphire_mainnet" : "sapphire_devnet", }) : null; From 7ce36aab703cd6fd54ed46ddaf952e51a16f5931 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 16:00:12 -0600 Subject: [PATCH 4/9] fix: switch waitready util --- lib/hooks/useWeb3Wallet.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index d031eb90e..046c26a0e 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -1,6 +1,6 @@ import { WALLET_ADAPTERS, IProvider } from "@web3auth/base"; import { Keyring } from "@polkadot/keyring"; -import { cryptoWaitReady } from "@polkadot/util-crypto"; +import { waitReady } from "@polkadot/wasm-crypto"; import { useWallet } from "lib/state/wallet"; import { web3authAtom } from "lib/state/util/web3auth-config"; import { useAtom } from "jotai"; @@ -142,7 +142,8 @@ const useWeb3Wallet = () => { if (!provider) { return; } - await cryptoWaitReady(); + const resp = await waitReady(); + console.log(resp); const privateKey = await provider.request({ method: "private_key", }); From 12aa119e3550ffc41d2d680ef1a96e32af865da7 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 16:19:08 -0600 Subject: [PATCH 5/9] test: add checks --- lib/hooks/useWeb3Wallet.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index 046c26a0e..d70b9dc0f 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -62,6 +62,7 @@ const useWeb3Wallet = () => { WALLET_ADAPTERS.OPENLOGIN, loginOptions, ); + console.log(web3authProvider); if (web3authProvider) { await getKeypair(web3authProvider); } @@ -149,6 +150,7 @@ const useWeb3Wallet = () => { }); const keyring = new Keyring({ ss58Format: 73, type: "sr25519" }); const keyPair = keyring.addFromUri("0x" + privateKey); + console.log(keyring, keyPair); if (keyPair) { selectWallet("web3auth", keyPair); } From cc655574618abb94fd91f49cc410f4b7543c8c71 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 16:36:29 -0600 Subject: [PATCH 6/9] fix: update package --- lib/hooks/useWeb3Wallet.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index d70b9dc0f..e32437c06 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -1,6 +1,6 @@ import { WALLET_ADAPTERS, IProvider } from "@web3auth/base"; import { Keyring } from "@polkadot/keyring"; -import { waitReady } from "@polkadot/wasm-crypto"; +import { cryptoWaitReady } from "@polkadot/util-crypto"; import { useWallet } from "lib/state/wallet"; import { web3authAtom } from "lib/state/util/web3auth-config"; import { useAtom } from "jotai"; @@ -143,12 +143,15 @@ const useWeb3Wallet = () => { if (!provider) { return; } - const resp = await waitReady(); + const resp = await cryptoWaitReady(); console.log(resp); const privateKey = await provider.request({ method: "private_key", }); + console.log(privateKey); + console.log(Keyring); const keyring = new Keyring({ ss58Format: 73, type: "sr25519" }); + console.log(keyring); const keyPair = keyring.addFromUri("0x" + privateKey); console.log(keyring, keyPair); if (keyPair) { From 19b4163c9a65025228cf3cbd83a92aed4a92aa79 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 16:42:51 -0600 Subject: [PATCH 7/9] fix: change deps --- lib/hooks/useWeb3Wallet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index e32437c06..91e1c4e24 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -1,5 +1,5 @@ import { WALLET_ADAPTERS, IProvider } from "@web3auth/base"; -import { Keyring } from "@polkadot/keyring"; +import { Keyring } from "@polkadot/api"; import { cryptoWaitReady } from "@polkadot/util-crypto"; import { useWallet } from "lib/state/wallet"; import { web3authAtom } from "lib/state/util/web3auth-config"; From 93dd3bac50fa8fb73b5d92a9d1665e4a6980dba9 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 16:50:55 -0600 Subject: [PATCH 8/9] fix: change keyring import --- lib/hooks/useWeb3Wallet.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index 91e1c4e24..fb415813b 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -62,12 +62,10 @@ const useWeb3Wallet = () => { WALLET_ADAPTERS.OPENLOGIN, loginOptions, ); - console.log(web3authProvider); if (web3authProvider) { await getKeypair(web3authProvider); } } catch (e) { - console.log(e); notificationStore.pushNotification( `Error connecting: please try again later.`, { From e7a2b925dfe99f71a5e35d751b8a2317598edc87 Mon Sep 17 00:00:00 2001 From: robhyrk Date: Thu, 22 Feb 2024 16:52:21 -0600 Subject: [PATCH 9/9] fix:remove console logs --- lib/hooks/useWeb3Wallet.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/hooks/useWeb3Wallet.ts b/lib/hooks/useWeb3Wallet.ts index fb415813b..a568888e3 100644 --- a/lib/hooks/useWeb3Wallet.ts +++ b/lib/hooks/useWeb3Wallet.ts @@ -141,17 +141,12 @@ const useWeb3Wallet = () => { if (!provider) { return; } - const resp = await cryptoWaitReady(); - console.log(resp); + await cryptoWaitReady(); const privateKey = await provider.request({ method: "private_key", }); - console.log(privateKey); - console.log(Keyring); const keyring = new Keyring({ ss58Format: 73, type: "sr25519" }); - console.log(keyring); const keyPair = keyring.addFromUri("0x" + privateKey); - console.log(keyring, keyPair); if (keyPair) { selectWallet("web3auth", keyPair); }