diff --git a/src/v2/components/Web3ConnectionManager/WalletSelectorModal/components/ConnectorButton.tsx b/src/v2/components/Web3ConnectionManager/WalletSelectorModal/components/ConnectorButton.tsx
index 78e004b47c..cea2495f09 100644
--- a/src/v2/components/Web3ConnectionManager/WalletSelectorModal/components/ConnectorButton.tsx
+++ b/src/v2/components/Web3ConnectionManager/WalletSelectorModal/components/ConnectorButton.tsx
@@ -52,6 +52,7 @@ const ConnectorButton = ({ connector, pendingConnector, connect, error }: Props)
!error
}
loadingText={`${connectorName} - connecting...`}
+ data-testid={`${connector.id}-connector-button`}
>
{connectorIcon ? (
diff --git a/src/v2/hooks/useAutoReconnect.ts b/src/v2/hooks/useAutoReconnect.ts
index d0b51116ce..491831e950 100644
--- a/src/v2/hooks/useAutoReconnect.ts
+++ b/src/v2/hooks/useAutoReconnect.ts
@@ -13,11 +13,14 @@ const useAutoReconnect = () => {
let connected = false
+ let canConnectToSafe = false
const safeConnector = connectors.find((connector) => connector.id === "safe")
- const canConnectToSafe = await safeConnector
- .getProvider()
- .then((provider) => !!provider)
- .catch(() => false)
+ if (safeConnector) {
+ canConnectToSafe = await safeConnector
+ .getProvider()
+ .then((provider) => !!provider)
+ .catch(() => false)
+ }
const recentConnectorId = await config.storage.getItem("recentConnectorId")
if (!recentConnectorId && !canConnectToSafe) return
diff --git a/src/wagmiConfig/index.ts b/src/wagmiConfig/index.ts
index a822c09535..e37f75f992 100644
--- a/src/wagmiConfig/index.ts
+++ b/src/wagmiConfig/index.ts
@@ -179,7 +179,11 @@ export const wagmiConfig = createConfig({
[blast.id]: http(),
[blastSepolia.id]: http(),
[oasisSapphire.id]: http(),
- [sepolia.id]: http("https://ethereum-sepolia-rpc.publicnode.com"),
+ [sepolia.id]: http(
+ process.env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC
+ ? "http://localhost:8545"
+ : "https://ethereum-sepolia-rpc.publicnode.com"
+ ),
[astarZkEVM.id]: http(),
[coreDao.id]: http(),
[liskSepolia.id]: http(),
@@ -191,40 +195,48 @@ export const wagmiConfig = createConfig({
[mint.id]: http(),
},
ssr: true,
- connectors: process.env.NEXT_PUBLIC_MOCK_CONNECTOR
- ? [
- mock({
- accounts: [mnemonicToAccount(process.env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC)],
- }),
- ]
- : [
- injected(),
- coinbaseWallet({
- appName: "Guild.xyz",
- appLogoUrl: "https://guild.xyz/guild-icon.png",
- version: "4",
- }),
- walletConnect({
- projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
- showQrModal: true,
- qrModalOptions: {
- explorerRecommendedWalletIds: [
- "971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709", // OKX
- "107bb20463699c4e614d3a2fb7b961e66f48774cb8f6d6c1aee789853280972c", // Bitcoin.com
- "541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf", // Ronin
- "4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust
+ connectors:
+ typeof navigator !== "undefined" &&
+ navigator.userAgent.includes("GUILD_E2E") &&
+ process.env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC
+ ? [
+ mock({
+ accounts: [
+ mnemonicToAccount(process.env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC),
],
- themeVariables: {
- "--wcm-z-index": "10001",
- "--w3m-z-index": "10001",
- } as any, // casting it, so `--wcm-z-index` is accepted
- },
- }),
- safe({
- allowedDomains: [/gnosis-safe\.io$/, /app\.safe\.global$/],
- debug: false,
- }),
- ],
+ features: {
+ reconnect: true,
+ },
+ }),
+ ]
+ : [
+ injected(),
+ coinbaseWallet({
+ appName: "Guild.xyz",
+ appLogoUrl: "https://guild.xyz/guild-icon.png",
+ version: "4",
+ }),
+ walletConnect({
+ projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
+ showQrModal: true,
+ qrModalOptions: {
+ explorerRecommendedWalletIds: [
+ "971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709", // OKX
+ "107bb20463699c4e614d3a2fb7b961e66f48774cb8f6d6c1aee789853280972c", // Bitcoin.com
+ "541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf", // Ronin
+ "4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust
+ ],
+ themeVariables: {
+ "--wcm-z-index": "10001",
+ "--w3m-z-index": "10001",
+ } as any, // casting it, so `--wcm-z-index` is accepted
+ },
+ }),
+ safe({
+ allowedDomains: [/gnosis-safe\.io$/, /app\.safe\.global$/],
+ debug: false,
+ }),
+ ],
})
export const COINBASE_INJECTED_WALLET_ID = "com.coinbase.wallet"
diff --git a/src/wagmiConfig/mockConnector.ts b/src/wagmiConfig/mockConnector.ts
index 171d5b0f97..c6f2080473 100644
--- a/src/wagmiConfig/mockConnector.ts
+++ b/src/wagmiConfig/mockConnector.ts
@@ -64,19 +64,21 @@ export function mock(
let currentChainId = await this.getChainId()
if (chainId && currentChainId !== chainId) {
- const chain = await this.switchChain({ chainId })
- currentChainId = chain.id
+ const chain = await this.switchChain?.({ chainId })
+
+ if (chain) currentChainId = chain.id
}
connected = true
+ await config.storage?.setItem("mock.connected", true)
return { accounts, chainId: currentChainId }
},
async disconnect() {
+ await config.storage?.removeItem("mock.connected")
connected = false
},
async getAccounts() {
- if (!connected) throw new Error("Connector is not connected")
const provider = await this.getProvider()
const accounts = await provider.request({ method: "eth_accounts" })
return accounts.map((x) => getAddress(x))
@@ -88,7 +90,10 @@ export function mock(
},
async isAuthorized() {
if (!features.reconnect) return false
- if (!connected) return false
+
+ const connectedLocal = await config.storage?.getItem("mock.connected")
+ if (!connectedLocal) return false
+
const accounts = await this.getAccounts()
return !!accounts.length
},
@@ -180,10 +185,10 @@ export function mock(
return custom({ request })({ retryCount: 0 })
},
- async getClient({ chainId }) {
+ async getClient({ chainId } = {}) {
const client = createWalletClient({
transport: http(
- config.chains.find((c) => c.id === chainId).rpcUrls.default.http[0]
+ config.chains.find((c) => c.id === chainId)?.rpcUrls.default.http[0]
),
account: parameters.accounts[0],
}) as Client
diff --git a/tsconfig.json b/tsconfig.json
index d247ed23f5..9a5bd0c77f 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -32,11 +32,11 @@
"./src/**/*.ts",
"./src/**/*.tsx",
"api/**/*.ts",
- "cypress.config.ts",
- "cypress/**/*.ts",
".next/types/**/*.ts",
"tailwind.config.ts",
- "scripts/detectCircularDependencies.ts"
+ "scripts/detectCircularDependencies.ts",
+ "playwright.config.ts",
+ "playwright/**/*.ts"
],
"exclude": ["node_modules", ".next", "out"]
}