Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fe/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
CRE_HELPER_SERVER_URL=http://localhost:3000
CRE_HELPER_API_KEY=replace-me
VITE_WALLETCONNECT_PROJECT_ID=replace-me
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .env.example, setting VITE_WALLETCONNECT_PROJECT_ID=replace-me will override the in-code fallback ("demo") and likely break WalletConnect for anyone who copies this file verbatim. Consider leaving it blank/commented out or setting it to demo with a note that a real project id is required for production.

Suggested change
VITE_WALLETCONNECT_PROJECT_ID=replace-me
# WalletConnect project id. "demo" is suitable for local development only;
# replace this with a real project id for production.
VITE_WALLETCONNECT_PROJECT_ID=demo

Copilot uses AI. Check for mistakes.

# Optional comma-separated overrides for RPC priority.
VITE_SEPOLIA_RPC_URLS=https://sepolia.drpc.org,https://ethereum-sepolia-rpc.publicnode.com
VITE_BASE_SEPOLIA_RPC_URLS=https://sepolia.base.org,https://base-sepolia-rpc.publicnode.com
VITE_ARBITRUM_SEPOLIA_RPC_URLS=https://sepolia-rollup.arbitrum.io/rpc,https://arbitrum-sepolia-rpc.publicnode.com
46 changes: 42 additions & 4 deletions fe/app/config/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
import { getDefaultConfig } from "@rainbow-me/rainbowkit";
import { cookieStorage, createStorage, http } from "wagmi";
import { cookieStorage, createStorage, fallback, http } from "wagmi";
import { arbitrumSepolia, baseSepolia, sepolia } from "wagmi/chains";

const RPC_TIMEOUT_MS = 2_500;

const splitRpcUrls = (value: string | undefined) =>
value
?.split(",")
.map((url) => url.trim())
.filter(Boolean) ?? [];
Comment on lines +10 to +11
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splitRpcUrls will throw when the env var is undefined. value?.split(",") returns undefined when value is missing, but .map(...) then runs on that undefined. Use optional chaining for the whole chain (e.g. value?.split(",")?.map(... )?.filter(...) ?? []) or parenthesize the split result before mapping.

Suggested change
.map((url) => url.trim())
.filter(Boolean) ?? [];
?.map((url) => url.trim())
?.filter(Boolean) ?? [];

Copilot uses AI. Check for mistakes.

const uniqueRpcUrls = (urls: string[]) => [...new Set(urls)];

const createFallbackTransport = (urls: string[]) =>
fallback(
uniqueRpcUrls(urls).map((url) => http(url, { timeout: RPC_TIMEOUT_MS })),
{ retryCount: 0 },
);

const sepoliaRpcUrls = [
...splitRpcUrls(import.meta.env.VITE_SEPOLIA_RPC_URLS),
"https://sepolia.drpc.org",
"https://ethereum-sepolia-rpc.publicnode.com",
"https://sepolia.gateway.tenderly.co",
...sepolia.rpcUrls.default.http,
];

const baseSepoliaRpcUrls = [
...splitRpcUrls(import.meta.env.VITE_BASE_SEPOLIA_RPC_URLS),
...baseSepolia.rpcUrls.default.http,
"https://base-sepolia-rpc.publicnode.com",
"https://base-sepolia.drpc.org",
];

const arbitrumSepoliaRpcUrls = [
...splitRpcUrls(import.meta.env.VITE_ARBITRUM_SEPOLIA_RPC_URLS),
...arbitrumSepolia.rpcUrls.default.http,
"https://arbitrum-sepolia-rpc.publicnode.com",
"https://arbitrum-sepolia.drpc.org",
];

export const config = getDefaultConfig({
appName: "CRE Examples",
projectId: import.meta.env.VITE_WALLETCONNECT_PROJECT_ID ?? "demo",
chains: [sepolia, baseSepolia, arbitrumSepolia],
ssr: true,
storage: createStorage({ storage: cookieStorage }),
transports: {
[sepolia.id]: http(sepolia.rpcUrls.default.http[0]),
[baseSepolia.id]: http(baseSepolia.rpcUrls.default.http[0]),
[arbitrumSepolia.id]: http(arbitrumSepolia.rpcUrls.default.http[0]),
[sepolia.id]: createFallbackTransport(sepoliaRpcUrls),
[baseSepolia.id]: createFallbackTransport(baseSepoliaRpcUrls),
[arbitrumSepolia.id]: createFallbackTransport(arbitrumSepoliaRpcUrls),
},
});

Expand Down
Loading