Skip to content

Commit

Permalink
Merge pull request #1580 from bancorprotocol/update-wagmi-2.12.32
Browse files Browse the repository at this point in the history
Update wagmi to 2.12.32
  • Loading branch information
tiagofilipenunes authored Nov 19, 2024
2 parents 63ff8e6 + 0af6fab commit 2c2588a
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 210 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"lint-staged": "^14.0.1",
"lodash": "^4.17.21",
"lz-string": "^1.5.0",
"mipd": "^0.0.7",
"msw": "^2.3.1",
"postcss": "^8.4.31",
"prettier": "^2.7.1",
Expand All @@ -87,7 +86,7 @@
"vite-plugin-svgr": "^2.4.0",
"vite-tsconfig-paths": "^4.2.1",
"vitest": "^1.6.0",
"wagmi": "2.12.12",
"wagmi": "2.12.32",
"web-vitals": "^2.1.0"
},
"scripts": {
Expand Down
31 changes: 6 additions & 25 deletions src/libs/wagmi/connectors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import tailwindWalletLogo from 'assets/logos/tailwindWallet.svg';
import compassWalletLogo from 'assets/logos/compassWallet.svg';
import seifWalletLogo from 'assets/logos/seifWallet.svg';
import { createStore } from 'mipd';
import { Connector, CreateConnectorFn, createConnector } from 'wagmi';
import {
metaMask,
Expand Down Expand Up @@ -34,10 +33,10 @@ const createPlaceholderConnector = ({
}) => {
return createConnector(() => {
return {
id: id,
name: name,
id,
name,
type: id + PLACEHOLDER_TAG,
icon: icon,
icon,
async setup() {},
async connect() {
throw Error('Wallet not installed');
Expand Down Expand Up @@ -82,7 +81,6 @@ const getDefaultConnector = (connectorType: SelectableConnectionName) => {
});
case 'MetaMask':
return metaMask({
extensionOnly: false,
preferDesktop: true,
dappMetadata: {
name: config.appName,
Expand Down Expand Up @@ -130,28 +128,11 @@ export const providerRdnsToName = (
): string | undefined => providerMapRdnsToName[connectionName];

const getConfigConnectors = (): CreateConnectorFn[] => {
const store = createStore();

const initializedProvidersRdns = store
.getProviders()
.map((provider) => provider.info.rdns.toLowerCase());

// Safe wallet always runs through an iFrame, the same check as the safe connector's getProvider is performed here.
// The allowedDomains param in the safe connector is another way to check we're in a safe wallet
if (!isIframe()) initializedProvidersRdns.push('safe');

const initializedProvidersNames = initializedProvidersRdns
.map(providerRdnsToName)
.filter((c) => c)
.map((c) => c!.toLowerCase());

// Only initialize connectors that are not injected
const missingConnectors = selectedConnectors.filter(
(name) => !initializedProvidersNames.includes(name.toLowerCase())
);

store.destroy();
return missingConnectors.map(getDefaultConnector);
const configConnectors = new Set(selectedConnectors);
if (!isIframe()) configConnectors.delete('Safe');
return Array.from(configConnectors).map(getDefaultConnector);
};

export const configConnectors = getConfigConnectors();
Loading

0 comments on commit 2c2588a

Please sign in to comment.