Skip to content

Commit 1cc91b4

Browse files
authored
fix: safe app connection[skip cypress] (#2426)
1 parent 4b11fd7 commit 1cc91b4

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/ui-config/wagmiConfig.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,41 @@ const prodCkConfig = getDefaultConfig({
7272
transports: ENABLE_TESTNET ? undefined : buildTransports(prodChains),
7373
...defaultConfig,
7474
});
75-
const prodConfig = createConfig({
76-
...prodCkConfig,
77-
connectors: prodCkConfig.connectors?.map((connector) => {
75+
76+
const familyConnectorId = 'familyAccountsProvider';
77+
78+
const connectorConfig = {
79+
chains: prodCkConfig.chains,
80+
emitter: new Emitter(''),
81+
};
82+
83+
const connectors = prodCkConfig.connectors
84+
?.map((connector) => {
7885
// initialize the connector with the emitter so we can access the id
79-
const c = connector({
80-
chains: prodCkConfig.chains,
81-
emitter: new Emitter(''),
82-
});
86+
const c = connector(connectorConfig);
8387
if (c.id === 'safe') {
8488
return safe({
8589
allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/, /dhedge.org$/],
8690
});
8791
} else {
8892
return connector;
8993
}
90-
}),
94+
})
95+
.sort((a, b) => {
96+
// sort connectors so the family connector is last
97+
// fixes slow wallet connections when running in the Safe UI
98+
if (a(connectorConfig).id === familyConnectorId) {
99+
return 1;
100+
}
101+
if (b(connectorConfig).id === familyConnectorId) {
102+
return -1;
103+
}
104+
return 0;
105+
});
106+
107+
const prodConfig = createConfig({
108+
...prodCkConfig,
109+
connectors,
91110
});
92111

93112
const isCypressEnabled = process.env.NEXT_PUBLIC_IS_CYPRESS_ENABLED === 'true';

0 commit comments

Comments
 (0)