Skip to content

Commit 15192c5

Browse files
authored
Merge pull request #549 from HausDAO/develop
deploy .club
2 parents 18fff8b + 11cd0b8 commit 15192c5

File tree

28 files changed

+1507
-565
lines changed

28 files changed

+1507
-565
lines changed

.github/workflows/ci_develop.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- uses: actions/setup-node@v3
2727
with:
28-
node-version: 16.x
28+
node-version: 18.x
2929

3030
- name: Create env file
3131
run: |

.github/workflows/ci_main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
- uses: actions/setup-node@v3
2828
with:
29-
node-version: 16.x
29+
node-version: 18.x
3030

3131
- name: Create env file
3232
run: |

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.16.0
1+
18.19.0

apps/admin/src/polyfills.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@
55
*/
66
import 'core-js/stable';
77
import 'regenerator-runtime/runtime';
8+
9+
// Ensure Buffer is globally available early (before any dynamic imports needing it)
10+
try {
11+
// eslint-disable-next-line @typescript-eslint/no-var-requires
12+
const { Buffer } = require('buffer');
13+
if (typeof window !== 'undefined' && !(window as any).Buffer) {
14+
(window as any).Buffer = Buffer;
15+
}
16+
} catch (err) {
17+
// eslint-disable-next-line no-console
18+
console.warn('[Polyfills] Buffer polyfill failed', err);
19+
}
Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import {
2-
EthereumClient,
3-
w3mConnectors,
4-
w3mProvider,
5-
} from '@web3modal/ethereum';
61
import { configureChains, createConfig, WagmiConfig } from 'wagmi';
72
import { SafeConnector } from '@wagmi/connectors/safe';
3+
import { InjectedConnector } from 'wagmi/connectors/injected';
4+
import { MetaMaskConnector } from 'wagmi/connectors/metaMask';
5+
import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet';
6+
// WalletConnect v2 included whenever a NX_WALLET_CONNECT_ID is provided (no extra enable flag)
7+
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
88
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
9-
import { Web3Modal } from '@web3modal/react';
109

1110
import {
1211
HAUS_NETWORK_DATA,
@@ -15,13 +14,26 @@ import {
1514
} from '@daohaus/keychain-utils';
1615

1716
import { ConnectProvider, ConnectProviderProps } from './ConnectContext';
17+
import { logChains } from './utils/debug';
1818

19-
if (!process.env['NX_WALLET_CONNECT_ID']) {
20-
throw new Error('You need to provide NX_WALLET_CONNECT_ID env variable');
19+
// Ensure Buffer global for libraries (e.g., walletconnect QR, qrcode) that expect Node Buffer
20+
// Some build setups (webpack 5) do not auto-polyfill core modules.
21+
// Safe to run always; no-op if already defined.
22+
try {
23+
// eslint-disable-next-line @typescript-eslint/no-var-requires
24+
const { Buffer } = require('buffer');
25+
if (typeof window !== 'undefined' && !(window as unknown as { Buffer?: unknown }).Buffer) {
26+
(window as unknown as { Buffer?: unknown }).Buffer = Buffer;
27+
}
28+
} catch (err) {
29+
// Buffer polyfill failed – non-fatal.
2130
}
22-
export const projectId = process.env['NX_WALLET_CONNECT_ID'];
31+
32+
// Legacy Web3Modal artifacts removed; no external modal client.
2333

2434
const chains = Object.values(VIEM_CHAINS);
35+
// Debug log of chain list
36+
logChains(chains as unknown as { id: number; name?: string }[]);
2537
const { publicClient } = configureChains(
2638
chains,
2739
[
@@ -33,25 +45,54 @@ const { publicClient } = configureChains(
3345
};
3446
},
3547
}),
36-
w3mProvider({ projectId }),
3748
],
3849
{ retryCount: 10 }
3950
);
51+
const includeSafe = process.env['NX_CONNECT_DISABLE_SAFE'] !== 'true';
52+
const walletConnectProjectId = process.env['NX_WALLET_CONNECT_ID'];
53+
54+
const baseConnectors = [
55+
// Injected first: rename so it doesn't clash label-wise with MetaMask when present
56+
new InjectedConnector({
57+
chains,
58+
options: { shimDisconnect: true, name: 'Browser Wallet' },
59+
}),
60+
new MetaMaskConnector({ chains, options: { shimDisconnect: true } }),
61+
new CoinbaseWalletConnector({
62+
chains,
63+
options: { appName: 'DAOhaus Admin' },
64+
}),
65+
...(includeSafe
66+
? [
67+
new SafeConnector({
68+
chains,
69+
options: {
70+
allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/],
71+
debug: false,
72+
},
73+
}),
74+
]
75+
: []),
76+
...(walletConnectProjectId
77+
? [
78+
new WalletConnectConnector({
79+
chains,
80+
options: {
81+
projectId: walletConnectProjectId,
82+
showQrModal: true, // uses WC's standalone QR (not Web3Modal UI)
83+
},
84+
}),
85+
]
86+
: []),
87+
];
88+
4089
export const wagmiConfig = createConfig({
4190
autoConnect: true,
42-
connectors: [
43-
...w3mConnectors({ projectId, chains }),
44-
new SafeConnector({
45-
chains,
46-
options: {
47-
allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/],
48-
debug: false,
49-
},
50-
}),
51-
],
91+
connectors: baseConnectors,
5292
publicClient,
5393
});
54-
export const ethereumClient = new EthereumClient(wagmiConfig, chains);
94+
// Placeholder for backward compatibility; no external client now
95+
export const ethereumClient = undefined as unknown as Record<string, never>;
5596

5697
export const Connect = ({
5798
children,
@@ -70,7 +111,6 @@ export const Connect = ({
70111
>
71112
{children}
72113
</ConnectProvider>
73-
<Web3Modal projectId={projectId} ethereumClient={ethereumClient} />
74114
</WagmiConfig>
75115
);
76116
};

libs/connect-context/src/ConnectContext.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
useMemo,
88
useState,
99
} from 'react';
10-
import { useWeb3Modal } from '@web3modal/react';
1110
import {
1211
useAccount,
1312
useDisconnect,
@@ -23,12 +22,12 @@ import {
2322
isValidNetwork,
2423
NetworkConfigs,
2524
ValidNetwork,
26-
VIEM_CHAINS,
2725
} from '@daohaus/keychain-utils';
2826

2927
import { defaultConnectValues } from './utils/defaults';
3028
import { ConnectLifecycleFns, UserProfile } from './utils/types';
3129
import { loadProfile } from './utils';
30+
import InternalConnectModal from './components/InternalConnectModal';
3231

3332
export type UserConnectType = {
3433
networks: NetworkConfigs;
@@ -58,14 +57,16 @@ export type ConnectProviderProps = {
5857
daoChainId?: string;
5958
};
6059

60+
// Always use internal connect modal (Web3Modal removed)
61+
const useInternal = true;
62+
6163
export const ConnectProvider = ({
6264
children,
6365
networks = HAUS_NETWORK_DATA,
6466
lifeCycleFns,
6567
daoChainId,
6668
daoId,
6769
}: ConnectProviderProps) => {
68-
const { open, setDefaultChain } = useWeb3Modal();
6970
const { address, isConnecting } = useAccount();
7071
const { disconnect } = useDisconnect();
7172
const { chain } = useNetwork();
@@ -93,13 +94,11 @@ export const ConnectProvider = ({
9394
[chainId, networks]
9495
);
9596

96-
const connectWallet = useCallback(async () => {
97-
if (daoChainId && VIEM_CHAINS[daoChainId as ValidNetwork]) {
98-
setDefaultChain(VIEM_CHAINS[daoChainId as ValidNetwork]);
99-
}
97+
const [internalOpen, setInternalOpen] = useState(false);
10098

101-
open();
102-
}, [open, setDefaultChain, daoChainId]);
99+
const connectWallet = useCallback(async () => {
100+
setInternalOpen(true);
101+
}, []);
103102

104103
const handleSwitchNetwork = async (_chainId: string | number) => {
105104
switchNetwork?.(Number(_chainId));
@@ -135,6 +134,19 @@ export const ConnectProvider = ({
135134
// eslint-disable-next-line react-hooks/exhaustive-deps
136135
}, [address, chainId]);
137136

137+
// Auto switch to daoChainId if provided and connected and mismatch
138+
useEffect(() => {
139+
if (
140+
daoChainId &&
141+
isConnected &&
142+
chain &&
143+
Number(daoChainId) !== chain.id &&
144+
switchNetwork
145+
) {
146+
switchNetwork(Number(daoChainId));
147+
}
148+
}, [daoChainId, isConnected, chain, switchNetwork]);
149+
138150
return (
139151
<ConnectContext.Provider
140152
value={{
@@ -155,6 +167,13 @@ export const ConnectProvider = ({
155167
}}
156168
>
157169
{children}
170+
{useInternal && (
171+
<InternalConnectModal
172+
open={internalOpen}
173+
onClose={() => setInternalOpen(false)}
174+
defaultChainId={daoChainId ? Number(daoChainId) : undefined}
175+
/>
176+
)}
158177
</ConnectContext.Provider>
159178
);
160179
};
Lines changed: 26 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Module declarations for icon asset imports local to connect-context
2+
// Ensures TypeScript understands imported SVG/PNG modules in this lib.
3+
declare module '*.svg' {
4+
const content: string;
5+
export default content;
6+
}
7+
8+
declare module '*.png' {
9+
const content: string;
10+
export default content;
11+
}

0 commit comments

Comments
 (0)