@dynamic-labs/wagmi-connector 0.18.6 → 0.18.8

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,23 @@
1
1
 
2
+ ### [0.18.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.7...v0.18.8) (2023-08-24)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * allow overriding contracts on wagmi chains ([#3107](https://github.com/dynamic-labs/DynamicAuth/issues/3107)) ([d078532](https://github.com/dynamic-labs/DynamicAuth/commit/d078532432415fc26402b9a5405059078be811eb))
8
+ * 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)
9
+
10
+ ### [0.18.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.6...v0.18.7) (2023-08-23)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * fix jumping when entering OTP code on IOS ([#3036](https://github.com/dynamic-labs/DynamicAuth/issues/3036)) ([#3093](https://github.com/dynamic-labs/DynamicAuth/issues/3093)) ([39952ee](https://github.com/dynamic-labs/DynamicAuth/commit/39952eef29fa2613862119649d84525d67d1697c))
16
+ * log user out when magic session expires ([#3087](https://github.com/dynamic-labs/DynamicAuth/issues/3087)) ([278af99](https://github.com/dynamic-labs/DynamicAuth/commit/278af998dab6396a98309062ccc14f16ba636dd3)), closes [#3085](https://github.com/dynamic-labs/DynamicAuth/issues/3085)
17
+ * improvements to network switching in bridge flow ([#3081](https://github.com/dynamic-labs/DynamicAuth/issues/3081)) ([9db6fff](https://github.com/dynamic-labs/DynamicAuth/commit/9db6fff847df24412c308c36eb36aae76df08510))
18
+ * fix could not replace transaction error ([#3049](https://github.com/dynamic-labs/DynamicAuth/issues/3049)) ([#3090](https://github.com/dynamic-labs/DynamicAuth/issues/3090)) ([4665306](https://github.com/dynamic-labs/DynamicAuth/commit/46653069020ad1cb59f503b958810c642afc42eb))
19
+ * update embedded wallet notice design ([#3082](https://github.com/dynamic-labs/DynamicAuth/issues/3082)) ([#3084](https://github.com/dynamic-labs/DynamicAuth/issues/3084)) ([3b56c17](https://github.com/dynamic-labs/DynamicAuth/commit/3b56c17ce9bc0307c185ed0795df35dcb9830030))
20
+
2
21
  ### [0.18.6](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.5...v0.18.6) (2023-08-21)
3
22
 
4
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/wagmi-connector",
3
- "version": "0.18.6",
3
+ "version": "0.18.8",
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.6",
15
- "@dynamic-labs/types": "0.18.6",
14
+ "@dynamic-labs/sdk-react-core": "0.18.8",
15
+ "@dynamic-labs/types": "0.18.8",
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 {};