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

chore: dhedge.org to safe's allowedDomains #2310

Merged
merged 1 commit into from
Jan 10, 2025
Merged
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
33 changes: 25 additions & 8 deletions src/ui-config/wagmiConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Emitter } from '@wagmi/core/internal';
import { getDefaultConfig } from 'connectkit';
import {
ENABLE_TESTNET,
Expand All @@ -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,
Expand All @@ -28,6 +29,7 @@ import {
sepolia,
zksync,
} from 'wagmi/chains';
import { injected, safe } from 'wagmi/connectors';

const testnetChains: CreateConfigParameters['chains'] = [
sepolia,
Expand Down Expand Up @@ -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';

Expand Down
Loading