@bit-buccaneers/wallet-abstraction 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.js CHANGED
@@ -24,7 +24,8 @@ var createEvmConfig = (chains) => {
24
24
  config = createConfig({
25
25
  chains: configuredChains,
26
26
  connectors,
27
- transports
27
+ transports,
28
+ multiInjectedProviderDiscovery: false
28
29
  });
29
30
  return config;
30
31
  };
@@ -615,6 +616,7 @@ var createWcEvmConnector = (config2) => {
615
616
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
616
617
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
617
618
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
619
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
618
620
  return {
619
621
  ...walletConfig2,
620
622
  type: "evm",
@@ -646,6 +648,9 @@ var createWcEvmConnector = (config2) => {
646
648
  throw new Error("No EVM account in session");
647
649
  }
648
650
  const address = account.split(":")[2];
651
+ if (isMobile() && signDeeplink) {
652
+ openDeeplink(signDeeplink);
653
+ }
649
654
  const result = await requestWalletConnect(
650
655
  "personal_sign",
651
656
  [message, address],
@@ -660,6 +665,7 @@ var createWcSolanaConnector = (config2) => {
660
665
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
661
666
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
662
667
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
668
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
663
669
  return {
664
670
  ...walletConfig2,
665
671
  type: "solana",
@@ -686,6 +692,9 @@ var createWcSolanaConnector = (config2) => {
686
692
  }
687
693
  const pubkey = account.split(":")[2];
688
694
  const messageBytes = new TextEncoder().encode(message);
695
+ if (isMobile() && signDeeplink) {
696
+ openDeeplink(signDeeplink);
697
+ }
689
698
  const result = await requestWalletConnect(
690
699
  "solana_signMessage",
691
700
  { message: bs582.encode(messageBytes), pubkey },
@@ -1297,6 +1306,9 @@ var checkEvmWalletInstalled = (connectorId) => {
1297
1306
  return true;
1298
1307
  }
1299
1308
  };
1309
+ var cleanupWalletLocalStorage = () => {
1310
+ Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
1311
+ };
1300
1312
  var getEvmConnectors = () => {
1301
1313
  const wagmiConnectors = getConnectors(getEvmConfig());
1302
1314
  const connectors = wagmiConnectors.map((c) => ({
@@ -1314,6 +1326,7 @@ var getEvmConnectors = () => {
1314
1326
  return connectedResult(result.accounts[0], { chainId: result.chainId });
1315
1327
  } catch (err) {
1316
1328
  if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
1329
+ cleanupWalletLocalStorage();
1317
1330
  await disconnect(getEvmConfig(), { connector: c });
1318
1331
  await sleep(100);
1319
1332
  const result = await connect(getEvmConfig(), { connector: c });
@@ -1324,6 +1337,7 @@ var getEvmConnectors = () => {
1324
1337
  }
1325
1338
  },
1326
1339
  disconnect: async () => {
1340
+ cleanupWalletLocalStorage();
1327
1341
  await disconnect(getEvmConfig(), { connector: c });
1328
1342
  },
1329
1343
  signMessage: async (message) => {
@@ -1331,6 +1345,13 @@ var getEvmConnectors = () => {
1331
1345
  }
1332
1346
  }
1333
1347
  }));
1348
+ if (!isMobile()) {
1349
+ const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
1350
+ const metamaskConnector = connectors[metamaskIndex];
1351
+ if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
1352
+ connectors[metamaskIndex] = createMetaMaskEvmConnector();
1353
+ }
1354
+ }
1334
1355
  addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
1335
1356
  return connectors;
1336
1357
  };
package/dist/dev.jsx CHANGED
@@ -15,7 +15,8 @@ var createEvmConfig = (chains) => {
15
15
  config = createConfig({
16
16
  chains: configuredChains,
17
17
  connectors,
18
- transports
18
+ transports,
19
+ multiInjectedProviderDiscovery: false
19
20
  });
20
21
  return config;
21
22
  };
@@ -622,6 +623,7 @@ var createWcEvmConnector = (config2) => {
622
623
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
623
624
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
624
625
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
626
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
625
627
  return {
626
628
  ...walletConfig2,
627
629
  type: "evm",
@@ -653,6 +655,9 @@ var createWcEvmConnector = (config2) => {
653
655
  throw new Error("No EVM account in session");
654
656
  }
655
657
  const address = account.split(":")[2];
658
+ if (isMobile() && signDeeplink) {
659
+ openDeeplink(signDeeplink);
660
+ }
656
661
  const result = await requestWalletConnect(
657
662
  "personal_sign",
658
663
  [message, address],
@@ -667,6 +672,7 @@ var createWcSolanaConnector = (config2) => {
667
672
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
668
673
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
669
674
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
675
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
670
676
  return {
671
677
  ...walletConfig2,
672
678
  type: "solana",
@@ -693,6 +699,9 @@ var createWcSolanaConnector = (config2) => {
693
699
  }
694
700
  const pubkey = account.split(":")[2];
695
701
  const messageBytes = new TextEncoder().encode(message);
702
+ if (isMobile() && signDeeplink) {
703
+ openDeeplink(signDeeplink);
704
+ }
696
705
  const result = await requestWalletConnect(
697
706
  "solana_signMessage",
698
707
  { message: bs583.encode(messageBytes), pubkey },
@@ -1321,6 +1330,9 @@ var checkEvmWalletInstalled = (connectorId) => {
1321
1330
  return true;
1322
1331
  }
1323
1332
  };
1333
+ var cleanupWalletLocalStorage = () => {
1334
+ Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
1335
+ };
1324
1336
  var getEvmConnectors = () => {
1325
1337
  const wagmiConnectors = getConnectors(getEvmConfig());
1326
1338
  const connectors = wagmiConnectors.map((c) => ({
@@ -1338,6 +1350,7 @@ var getEvmConnectors = () => {
1338
1350
  return connectedResult(result.accounts[0], { chainId: result.chainId });
1339
1351
  } catch (err) {
1340
1352
  if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
1353
+ cleanupWalletLocalStorage();
1341
1354
  await disconnect(getEvmConfig(), { connector: c });
1342
1355
  await sleep(100);
1343
1356
  const result = await connect(getEvmConfig(), { connector: c });
@@ -1348,6 +1361,7 @@ var getEvmConnectors = () => {
1348
1361
  }
1349
1362
  },
1350
1363
  disconnect: async () => {
1364
+ cleanupWalletLocalStorage();
1351
1365
  await disconnect(getEvmConfig(), { connector: c });
1352
1366
  },
1353
1367
  signMessage: async (message) => {
@@ -1355,6 +1369,13 @@ var getEvmConnectors = () => {
1355
1369
  }
1356
1370
  }
1357
1371
  }));
1372
+ if (!isMobile()) {
1373
+ const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
1374
+ const metamaskConnector = connectors[metamaskIndex];
1375
+ if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
1376
+ connectors[metamaskIndex] = createMetaMaskEvmConnector();
1377
+ }
1378
+ }
1358
1379
  addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
1359
1380
  return connectors;
1360
1381
  };
package/dist/index.js CHANGED
@@ -24,7 +24,8 @@ var createEvmConfig = (chains) => {
24
24
  config = createConfig({
25
25
  chains: configuredChains,
26
26
  connectors,
27
- transports
27
+ transports,
28
+ multiInjectedProviderDiscovery: false
28
29
  });
29
30
  return config;
30
31
  };
@@ -615,6 +616,7 @@ var createWcEvmConnector = (config2) => {
615
616
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
616
617
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
617
618
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
619
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
618
620
  return {
619
621
  ...walletConfig2,
620
622
  type: "evm",
@@ -646,6 +648,9 @@ var createWcEvmConnector = (config2) => {
646
648
  throw new Error("No EVM account in session");
647
649
  }
648
650
  const address = account.split(":")[2];
651
+ if (isMobile() && signDeeplink) {
652
+ openDeeplink(signDeeplink);
653
+ }
649
654
  const result = await requestWalletConnect(
650
655
  "personal_sign",
651
656
  [message, address],
@@ -660,6 +665,7 @@ var createWcSolanaConnector = (config2) => {
660
665
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
661
666
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
662
667
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
668
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
663
669
  return {
664
670
  ...walletConfig2,
665
671
  type: "solana",
@@ -686,6 +692,9 @@ var createWcSolanaConnector = (config2) => {
686
692
  }
687
693
  const pubkey = account.split(":")[2];
688
694
  const messageBytes = new TextEncoder().encode(message);
695
+ if (isMobile() && signDeeplink) {
696
+ openDeeplink(signDeeplink);
697
+ }
689
698
  const result = await requestWalletConnect(
690
699
  "solana_signMessage",
691
700
  { message: bs582.encode(messageBytes), pubkey },
@@ -1297,6 +1306,9 @@ var checkEvmWalletInstalled = (connectorId) => {
1297
1306
  return true;
1298
1307
  }
1299
1308
  };
1309
+ var cleanupWalletLocalStorage = () => {
1310
+ Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
1311
+ };
1300
1312
  var getEvmConnectors = () => {
1301
1313
  const wagmiConnectors = getConnectors(getEvmConfig());
1302
1314
  const connectors = wagmiConnectors.map((c) => ({
@@ -1314,6 +1326,7 @@ var getEvmConnectors = () => {
1314
1326
  return connectedResult(result.accounts[0], { chainId: result.chainId });
1315
1327
  } catch (err) {
1316
1328
  if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
1329
+ cleanupWalletLocalStorage();
1317
1330
  await disconnect(getEvmConfig(), { connector: c });
1318
1331
  await sleep(100);
1319
1332
  const result = await connect(getEvmConfig(), { connector: c });
@@ -1324,6 +1337,7 @@ var getEvmConnectors = () => {
1324
1337
  }
1325
1338
  },
1326
1339
  disconnect: async () => {
1340
+ cleanupWalletLocalStorage();
1327
1341
  await disconnect(getEvmConfig(), { connector: c });
1328
1342
  },
1329
1343
  signMessage: async (message) => {
@@ -1331,6 +1345,13 @@ var getEvmConnectors = () => {
1331
1345
  }
1332
1346
  }
1333
1347
  }));
1348
+ if (!isMobile()) {
1349
+ const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
1350
+ const metamaskConnector = connectors[metamaskIndex];
1351
+ if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
1352
+ connectors[metamaskIndex] = createMetaMaskEvmConnector();
1353
+ }
1354
+ }
1334
1355
  addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
1335
1356
  return connectors;
1336
1357
  };
package/dist/index.jsx CHANGED
@@ -15,7 +15,8 @@ var createEvmConfig = (chains) => {
15
15
  config = createConfig({
16
16
  chains: configuredChains,
17
17
  connectors,
18
- transports
18
+ transports,
19
+ multiInjectedProviderDiscovery: false
19
20
  });
20
21
  return config;
21
22
  };
@@ -622,6 +623,7 @@ var createWcEvmConnector = (config2) => {
622
623
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
623
624
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
624
625
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
626
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
625
627
  return {
626
628
  ...walletConfig2,
627
629
  type: "evm",
@@ -653,6 +655,9 @@ var createWcEvmConnector = (config2) => {
653
655
  throw new Error("No EVM account in session");
654
656
  }
655
657
  const address = account.split(":")[2];
658
+ if (isMobile() && signDeeplink) {
659
+ openDeeplink(signDeeplink);
660
+ }
656
661
  const result = await requestWalletConnect(
657
662
  "personal_sign",
658
663
  [message, address],
@@ -667,6 +672,7 @@ var createWcSolanaConnector = (config2) => {
667
672
  const walletConfig2 = WALLETS.find((w) => w.id === config2.walletId);
668
673
  const getDeeplink = config2.getDeeplink ?? createDeeplink(config2.wcDeeplink);
669
674
  const isInWallet = () => isInWalletBrowser(config2.injectedKey);
675
+ const signDeeplink = config2.signDeeplink ?? config2.wcDeeplink;
670
676
  return {
671
677
  ...walletConfig2,
672
678
  type: "solana",
@@ -693,6 +699,9 @@ var createWcSolanaConnector = (config2) => {
693
699
  }
694
700
  const pubkey = account.split(":")[2];
695
701
  const messageBytes = new TextEncoder().encode(message);
702
+ if (isMobile() && signDeeplink) {
703
+ openDeeplink(signDeeplink);
704
+ }
696
705
  const result = await requestWalletConnect(
697
706
  "solana_signMessage",
698
707
  { message: bs583.encode(messageBytes), pubkey },
@@ -1321,6 +1330,9 @@ var checkEvmWalletInstalled = (connectorId) => {
1321
1330
  return true;
1322
1331
  }
1323
1332
  };
1333
+ var cleanupWalletLocalStorage = () => {
1334
+ Object.keys(window.localStorage).filter((key) => key.startsWith("wagmi.")).forEach((key) => window.localStorage.removeItem(key));
1335
+ };
1324
1336
  var getEvmConnectors = () => {
1325
1337
  const wagmiConnectors = getConnectors(getEvmConfig());
1326
1338
  const connectors = wagmiConnectors.map((c) => ({
@@ -1338,6 +1350,7 @@ var getEvmConnectors = () => {
1338
1350
  return connectedResult(result.accounts[0], { chainId: result.chainId });
1339
1351
  } catch (err) {
1340
1352
  if (err instanceof Error && err.name === "ConnectorAlreadyConnectedError") {
1353
+ cleanupWalletLocalStorage();
1341
1354
  await disconnect(getEvmConfig(), { connector: c });
1342
1355
  await sleep(100);
1343
1356
  const result = await connect(getEvmConfig(), { connector: c });
@@ -1348,6 +1361,7 @@ var getEvmConnectors = () => {
1348
1361
  }
1349
1362
  },
1350
1363
  disconnect: async () => {
1364
+ cleanupWalletLocalStorage();
1351
1365
  await disconnect(getEvmConfig(), { connector: c });
1352
1366
  },
1353
1367
  signMessage: async (message) => {
@@ -1355,6 +1369,13 @@ var getEvmConnectors = () => {
1355
1369
  }
1356
1370
  }
1357
1371
  }));
1372
+ if (!isMobile()) {
1373
+ const metamaskIndex = connectors.findIndex((c) => c.id === "metamask");
1374
+ const metamaskConnector = connectors[metamaskIndex];
1375
+ if (metamaskIndex !== -1 && metamaskConnector && !metamaskConnector.installed) {
1376
+ connectors[metamaskIndex] = createMetaMaskEvmConnector();
1377
+ }
1378
+ }
1358
1379
  addFallbackConnectors(connectors, EVM_FALLBACK_CONNECTORS);
1359
1380
  return connectors;
1360
1381
  };
@@ -7,6 +7,8 @@ export interface WcWalletConfig {
7
7
  injectedKey: string;
8
8
  /** Custom deeplink builder for wallets that need special formatting */
9
9
  getDeeplink?: (uri: string) => string;
10
+ /** Deeplink to open wallet app for signing (without WC URI) */
11
+ signDeeplink?: string;
10
12
  }
11
13
  export declare const createWcEvmConnector: (config: WcWalletConfig) => EvmWalletConnector;
12
14
  export declare const createWcSolanaConnector: (config: WcWalletConfig) => SolanaWalletConnector;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-buccaneers/wallet-abstraction",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Solid.js web3 wallet abstraction for EVM and Solana",
5
5
  "license": "MIT",
6
6
  "author": "Bit Buccaneers",