Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add compatibility with SAFE #346

Merged
merged 8 commits into from
Sep 30, 2023
11 changes: 10 additions & 1 deletion packages/nextjs/hooks/scaffold-eth/useAutoConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { getTargetNetwork } from "~~/utils/scaffold-eth";
const SCAFFOLD_WALLET_STROAGE_KEY = "scaffoldEth2.wallet";
const WAGMI_WALLET_STORAGE_KEY = "wagmi.wallet";

// ID of the SAFE connector instance
const SAFE_ID = "safe";

/**
* This function will get the initial wallet connector (if any), the app will connect to
* @param previousWalletId
Expand All @@ -19,8 +22,14 @@ const getInitialConnector = (
previousWalletId: string,
connectors: Connector[],
): { connector: Connector | undefined; chainId?: number } | undefined => {
const targetNetwork = getTargetNetwork();
// Look for the SAFE connector instance and connect to it instantly if loaded in SAFE frame
const safeConnectorInstance = connectors.find(connector => connector.id === SAFE_ID && connector.ready);

if (safeConnectorInstance) {
return { connector: safeConnectorInstance };
}
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved

const targetNetwork = getTargetNetwork();
const allowBurner = scaffoldConfig.onlyLocalBurnerWallet ? targetNetwork.id === hardhat.id : true;

if (!previousWalletId) {
Expand Down
5 changes: 5 additions & 0 deletions packages/nextjs/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Scaffold-ETH 2 DApp",
"description": "A DApp built with Scaffold-ETH",
"iconPath": "logo.svg"
}
2 changes: 2 additions & 0 deletions packages/nextjs/services/web3/wagmiConnectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ledgerWallet,
metaMaskWallet,
rainbowWallet,
safeWallet,
walletConnectWallet,
} from "@rainbow-me/rainbowkit/wallets";
import { configureChains } from "wagmi";
Expand Down Expand Up @@ -55,6 +56,7 @@ const wallets = [
...(configuredNetwork.id === chains.hardhat.id || !onlyLocalBurnerWallet
? [burnerWalletConfig({ chains: [appChains.chains[0]] })]
: []),
safeWallet({ ...walletsOptions, debug: false, allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/] }),
];

/**
Expand Down