From 9c33262dd1cc6fc3db41c7e3710c4fe9ba74deed Mon Sep 17 00:00:00 2001 From: Lochie Axon Date: Fri, 10 Jan 2025 20:18:57 +1100 Subject: [PATCH] chore: dhedge.org to safe's allowedDomains (#2310) --- src/ui-config/wagmiConfig.ts | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ui-config/wagmiConfig.ts b/src/ui-config/wagmiConfig.ts index 6f5e6e5e4c..dfcc2f6cf2 100644 --- a/src/ui-config/wagmiConfig.ts +++ b/src/ui-config/wagmiConfig.ts @@ -1,3 +1,4 @@ +import { Emitter } from '@wagmi/core/internal'; import { getDefaultConfig } from 'connectkit'; import { ENABLE_TESTNET, @@ -8,7 +9,7 @@ import { networkConfigs, } from 'src/utils/marketsAndNetworksConfig'; import { type Chain } from 'viem'; -import { createConfig, CreateConfigParameters, http, injected } from 'wagmi'; +import { createConfig, CreateConfigParameters, http } from 'wagmi'; import { arbitrum, arbitrumSepolia, @@ -28,6 +29,7 @@ import { sepolia, zksync, } from 'wagmi/chains'; +import { injected, safe } from 'wagmi/connectors'; const testnetChains: CreateConfigParameters['chains'] = [ sepolia, @@ -95,13 +97,28 @@ const getTransport = (chainId: number) => { const buildTransports = (chains: CreateConfigParameters['chains']) => Object.fromEntries(chains.map((chain) => [chain.id, http(getTransport(chain.id))])); -const prodConfig = createConfig( - getDefaultConfig({ - chains: ENABLE_TESTNET ? testnetChains : prodChains, - transports: ENABLE_TESTNET ? undefined : buildTransports(prodChains), - ...defaultConfig, - }) -); +const prodCkConfig = getDefaultConfig({ + chains: ENABLE_TESTNET ? testnetChains : prodChains, + transports: ENABLE_TESTNET ? undefined : buildTransports(prodChains), + ...defaultConfig, +}); +const prodConfig = createConfig({ + ...prodCkConfig, + connectors: prodCkConfig.connectors?.map((connector) => { + // initialize the connector with the emitter so we can access the id + const c = connector({ + chains: prodCkConfig.chains, + emitter: new Emitter(''), + }); + if (c.id === 'safe') { + return safe({ + allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/, /dhedge.org$/], + }); + } else { + return connector; + } + }), +}); const isCypressEnabled = process.env.NEXT_PUBLIC_IS_CYPRESS_ENABLED === 'true';