@dynamic-labs/wagmi-connector 0.18.7 → 0.18.9

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/CHANGELOG.md CHANGED
@@ -1,4 +1,25 @@
1
1
 
2
+ ### [0.18.9](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.8...v0.18.9) (2023-08-25)
3
+
4
+
5
+ ### Features
6
+
7
+ * register connection of second wallet in bridge ([5c49b72](https://github.com/dynamic-labs/DynamicAuth/commit/5c49b7266a0b89f73a91116b4161185fd2fa8c15)), closes [#3113](https://github.com/dynamic-labs/DynamicAuth/issues/3113)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * fix github social linking icon on dark mode ([#3129](https://github.com/dynamic-labs/DynamicAuth/issues/3129)) ([2ecad53](https://github.com/dynamic-labs/DynamicAuth/commit/2ecad53312baca43b200e17d1df60a61adf31222)), closes [#3126](https://github.com/dynamic-labs/DynamicAuth/issues/3126)
13
+ * fix issue with detecting oauth window closed before finishing linking ([#3127](https://github.com/dynamic-labs/DynamicAuth/issues/3127)) ([8c774cc](https://github.com/dynamic-labs/DynamicAuth/commit/8c774cc7a67784892af5e91244de42f9fd092acc)), closes [#3124](https://github.com/dynamic-labs/DynamicAuth/issues/3124)
14
+
15
+ ### [0.18.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.7...v0.18.8) (2023-08-24)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * allow overriding contracts on wagmi chains ([#3107](https://github.com/dynamic-labs/DynamicAuth/issues/3107)) ([d078532](https://github.com/dynamic-labs/DynamicAuth/commit/d078532432415fc26402b9a5405059078be811eb))
21
+ * send wagmi settings only once when DynamicWagmiConnector loads (v18) ([#3108](https://github.com/dynamic-labs/DynamicAuth/issues/3108)) ([d25de8f](https://github.com/dynamic-labs/DynamicAuth/commit/d25de8f8a4ee7be6e89cb74881ea390ef72e578f)), closes [#3103](https://github.com/dynamic-labs/DynamicAuth/issues/3103)
22
+
2
23
  ### [0.18.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.6...v0.18.7) (2023-08-23)
3
24
 
4
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/wagmi-connector",
3
- "version": "0.18.7",
3
+ "version": "0.18.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -11,8 +11,8 @@
11
11
  "react": "^17.0.2 || ^18.0.0",
12
12
  "ethers": "5.7.2",
13
13
  "wagmi": "~0.12.13",
14
- "@dynamic-labs/sdk-react-core": "0.18.7",
15
- "@dynamic-labs/types": "0.18.7",
14
+ "@dynamic-labs/sdk-react-core": "0.18.9",
15
+ "@dynamic-labs/types": "0.18.9",
16
16
  "eventemitter3": "5.0.1"
17
17
  },
18
18
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import { configureChains, mainnet, createClient, WagmiConfig } from 'wagmi';
3
3
  import { publicProvider } from 'wagmi/providers/public';
4
4
  import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
@@ -21,9 +21,13 @@ const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, child
21
21
  var _a;
22
22
  const { networkConfigurations, handleLogOut, connectedWallets, linkedWallets, authMode, sendWagmiSettings, } = useDynamicContext();
23
23
  const wallets = authMode === 'connect-only' ? connectedWallets : linkedWallets;
24
- sendWagmiSettings({
25
- dynamicWagmiSettings: customerSuppliedEvmNetworks,
26
- });
24
+ useEffect(() => {
25
+ // only send wagmi settings once, when the first time DynamicWagmiConnector renders
26
+ sendWagmiSettings({
27
+ dynamicWagmiSettings: customerSuppliedEvmNetworks,
28
+ });
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ }, []);
27
31
  const evmNetworks = ((_a = customerSuppliedEvmNetworks !== null && customerSuppliedEvmNetworks !== void 0 ? customerSuppliedEvmNetworks : networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) !== null && _a !== void 0 ? _a : []).map((network) => {
28
32
  network.chainId = parseInt(network.chainId.toString());
29
33
  return network;
@@ -1,3 +1,4 @@
1
1
  import { Chain } from 'wagmi';
2
2
  import { WagmiEvmNetworks } from '../types';
3
3
  export declare const mapDynamicChainToWagmi: (dynamicChain: WagmiEvmNetworks) => Chain;
4
+ export declare const overrideWagmiChainWithDynamicSettings: (wagmiChain: Chain, dynamicChain: WagmiEvmNetworks) => Chain;
@@ -2,7 +2,7 @@ import * as allChains from 'wagmi/chains';
2
2
  import { resolveRpcUrlFromEvmNetworks } from '../utils/resolveRpcUrlFromEvmNetworks/resolveRpcUrlFromEvmNetworks.js';
3
3
 
4
4
  // eslint-disable-next-line import/no-namespace
5
- const findRpcProvider = (rpcUrls, privateCustomerRpcUrls, name) => {
5
+ const updateRpcProvider = (rpcUrls, privateCustomerRpcUrls, name) => {
6
6
  const findRpcUrl = privateCustomerRpcUrls === null || privateCustomerRpcUrls === void 0 ? void 0 : privateCustomerRpcUrls.find((rpcUrl) => {
7
7
  if (typeof rpcUrl === 'string') {
8
8
  return rpcUrl.includes(name);
@@ -22,7 +22,14 @@ const findRpcProvider = (rpcUrls, privateCustomerRpcUrls, name) => {
22
22
  }
23
23
  };
24
24
  const mapDynamicChainToWagmi = (dynamicChain) => {
25
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
25
+ var _a;
26
+ /**
27
+ * Find the chain in Wagmi that matches the chainId of the dynamic chain.
28
+ */
29
+ const wagmiChain = ((_a = Object.values(allChains).find((chain) => chain.id === dynamicChain.chainId)) !== null && _a !== void 0 ? _a : {});
30
+ return overrideWagmiChainWithDynamicSettings(wagmiChain, dynamicChain);
31
+ };
32
+ const generateRpcUrls = (dynamicChain) => {
26
33
  const rpcUrlResolved = resolveRpcUrlFromEvmNetworks(dynamicChain);
27
34
  const rpcUrls = {
28
35
  default: {
@@ -33,12 +40,12 @@ const mapDynamicChainToWagmi = (dynamicChain) => {
33
40
  },
34
41
  };
35
42
  const rpcUrlProviders = ['alchemy', 'infura'];
36
- rpcUrlProviders.forEach((name) => findRpcProvider(rpcUrls, dynamicChain.privateCustomerRpcUrls, name));
37
- /**
38
- * Find the chain in Wagmi that matches the chainId of the dynamic chain.
39
- */
40
- const wagmiChain = ((_a = Object.values(allChains).find((chain) => chain.id === dynamicChain.chainId)) !== null && _a !== void 0 ? _a : {});
41
- return Object.assign(Object.assign({}, wagmiChain), { blockExplorers: Object.assign(Object.assign({}, wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.blockExplorers), { default: Object.assign(Object.assign({}, (_b = wagmiChain.blockExplorers) === null || _b === void 0 ? void 0 : _b.default), { name: '', url: (_d = (_c = dynamicChain.blockExplorerUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '' }) }), id: (_e = dynamicChain.chainId) !== null && _e !== void 0 ? _e : wagmiChain.id, name: (_g = (_f = dynamicChain.vanityName) !== null && _f !== void 0 ? _f : dynamicChain.name) !== null && _g !== void 0 ? _g : wagmiChain.name, nativeCurrency: (_h = dynamicChain.nativeCurrency) !== null && _h !== void 0 ? _h : wagmiChain.nativeCurrency, network: (_j = dynamicChain.name) !== null && _j !== void 0 ? _j : wagmiChain.network, rpcUrls: rpcUrls !== null && rpcUrls !== void 0 ? rpcUrls : wagmiChain.rpcUrls });
43
+ rpcUrlProviders.forEach((name) => updateRpcProvider(rpcUrls, dynamicChain.privateCustomerRpcUrls, name));
44
+ return rpcUrls;
45
+ };
46
+ const overrideWagmiChainWithDynamicSettings = (wagmiChain, dynamicChain) => {
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
48
+ return (Object.assign(Object.assign({}, wagmiChain), { blockExplorers: Object.assign(Object.assign({}, wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.blockExplorers), { default: Object.assign(Object.assign({}, (_a = wagmiChain.blockExplorers) === null || _a === void 0 ? void 0 : _a.default), { name: '', url: (_c = (_b = dynamicChain.blockExplorerUrls) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '' }) }), contracts: (_d = dynamicChain.contracts) !== null && _d !== void 0 ? _d : wagmiChain.contracts, id: (_e = dynamicChain.chainId) !== null && _e !== void 0 ? _e : wagmiChain.id, name: (_g = (_f = dynamicChain.vanityName) !== null && _f !== void 0 ? _f : dynamicChain.name) !== null && _g !== void 0 ? _g : wagmiChain.name, nativeCurrency: (_h = dynamicChain.nativeCurrency) !== null && _h !== void 0 ? _h : wagmiChain.nativeCurrency, network: (_j = dynamicChain.name) !== null && _j !== void 0 ? _j : wagmiChain.network, rpcUrls: generateRpcUrls(dynamicChain) }));
42
49
  };
43
50
 
44
- export { mapDynamicChainToWagmi };
51
+ export { mapDynamicChainToWagmi, overrideWagmiChainWithDynamicSettings };
@@ -21,5 +21,8 @@ type CustomProviderOptions = {
21
21
  };
22
22
  export type WagmiEvmNetworks = Omit<PartialBy<EvmNetwork, 'iconUrls' | 'networkId' | 'vanityName'>, 'privateCustomerRpcUrls'> & {
23
23
  privateCustomerRpcUrls: (string | CustomProviderOptions)[];
24
+ contracts?: {
25
+ [key: string]: any;
26
+ };
24
27
  };
25
28
  export {};