@reef-knot/web3-react 1.12.0 → 1.13.0

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.
@@ -4,6 +4,7 @@ import { SafeAppConnector } from '@gnosis.pm/safe-apps-web3-react';
4
4
  import { CHAINS } from '@lido-sdk/constants';
5
5
  import { LedgerHQFrameConnector } from '@reef-knot/ledger-connector';
6
6
  export interface ConnectorsContextProps {
7
+ children?: React.ReactNode;
7
8
  defaultChainId: CHAINS;
8
9
  rpc: Record<number, string>;
9
10
  appName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/context/connectors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAIrE,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,EAAE,sBAAsB,CAAC;IACnC,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,iBAAiB,uCAA8C,CAAC;;AAmC7E,wBAAoE"}
1
+ {"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/context/connectors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAIrE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,EAAE,sBAAsB,CAAC;IACnC,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,iBAAiB,uCAA8C,CAAC;;AAmC7E,wBAAoE"}
@@ -3,6 +3,7 @@ import { CHAINS } from '@lido-sdk/constants';
3
3
  import { SWRConfiguration } from 'swr';
4
4
  import { ConnectorsContextProps } from './connectors';
5
5
  export interface ProviderWeb3Props extends ConnectorsContextProps {
6
+ children?: React.ReactNode;
6
7
  defaultChainId: CHAINS;
7
8
  supportedChainIds: CHAINS[];
8
9
  swrConfig?: SWRConfiguration;
@@ -10,6 +11,6 @@ export interface ProviderWeb3Props extends ConnectorsContextProps {
10
11
  walletconnectProjectId?: string;
11
12
  onError?: (error: unknown) => void;
12
13
  }
13
- declare const _default: React.MemoExoticComponent<React.FC<ProviderWeb3Props>>;
14
+ declare const _default: React.MemoExoticComponent<(props: ProviderWeb3Props) => React.JSX.Element>;
14
15
  export default _default;
15
16
  //# sourceMappingURL=web3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web3.d.ts","sourceRoot":"","sources":["../../src/context/web3.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAO7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAGvC,OAA2B,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;;AA4HD,wBAAyD"}
1
+ {"version":3,"file":"web3.d.ts","sourceRoot":"","sources":["../../src/context/web3.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAOzD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAGvC,OAA2B,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;;AA6HD,wBAAkC"}
@@ -17,7 +17,6 @@ import '@web3-react/injected-connector';
17
17
  import '@web3-react/walletlink-connector';
18
18
  import '@reef-knot/ledger-connector';
19
19
  import '../helpers/ua.js';
20
- import 'tiny-warning';
21
20
  import ProviderConnectors from './connectors.js';
22
21
 
23
22
  function getLibrary(provider) {
@@ -75,14 +74,18 @@ var ProviderSDK = props => {
75
74
  invariant(rpc[CHAINS.Mainnet], 'RPC url for mainnet is not provided');
76
75
  var providerRpc = getStaticRpcBatchProvider(chainId, rpc[chainId], 0, pollingInterval);
77
76
  var providerMainnetRpc = getStaticRpcBatchProvider(CHAINS.Mainnet, rpc[CHAINS.Mainnet], 0, pollingInterval);
78
- return /*#__PURE__*/React.createElement(ProviderSDK$1, Object.assign({
79
- chainId: chainId,
80
- supportedChainIds: supportedChainIds,
81
- providerWeb3: providerWeb3,
82
- providerRpc: providerRpc,
83
- providerMainnetRpc: providerMainnetRpc,
84
- account: account !== null && account !== void 0 ? account : undefined
85
- }, rest), children);
77
+ return (
78
+ /*#__PURE__*/
79
+ // @ts-expect-error Property children does not exist on type IntrinsicAttributes & SDKContextProps
80
+ React.createElement(ProviderSDK$1, Object.assign({
81
+ chainId: chainId,
82
+ supportedChainIds: supportedChainIds,
83
+ providerWeb3: providerWeb3,
84
+ providerRpc: providerRpc,
85
+ providerMainnetRpc: providerMainnetRpc,
86
+ account: account !== null && account !== void 0 ? account : undefined
87
+ }, rest), children)
88
+ );
86
89
  };
87
90
  var ProviderWeb3 = props => {
88
91
  var {
@@ -107,7 +110,7 @@ var ProviderWeb3 = props => {
107
110
  holesky
108
111
  }));
109
112
  var supportedWagmiChains = wagmiChainsArray.filter(chain => supportedChainIds.includes(chain.id));
110
- var defaultWagmiChain = wagmiChainsArray.find(chain => chain.id === defaultChainId);
113
+ var defaultWagmiChain = wagmiChainsArray.find(chain => chain.id === defaultChainId) || wagmiChainsArray[0];
111
114
  return /*#__PURE__*/React.createElement(Web3ReactProvider, {
112
115
  getLibrary: getLibrary
113
116
  }, /*#__PURE__*/React.createElement(ProviderSDK, Object.assign({
@@ -1,6 +1,5 @@
1
1
  export * from './useAutoConnect';
2
2
  export * from './useConnectorInfo';
3
- export * from './useConnectorMetamask';
4
3
  export * from './useConnectors';
5
4
  export * from './useConnectorStorage';
6
5
  export * from './useDisconnect';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ export { default as ProviderWeb3 } from './context/web3.js';
5
5
  export { ConnectorsContext, default as ProviderConnectors } from './context/connectors.js';
6
6
  export { useAutoConnect, useDeleteConnectorFromLS, useEagerConnector, useSaveConnectorToLS, useWatchConnectorInLS } from './hooks/useAutoConnect.js';
7
7
  export { useConnectorInfo } from './hooks/useConnectorInfo.js';
8
- export { useConnectorMetamask } from './hooks/useConnectorMetamask.js';
9
8
  export { useConnectors } from './hooks/useConnectors.js';
10
9
  export { useConnectorStorage } from './hooks/useConnectorStorage.js';
11
10
  export { useDisconnect, useForceDisconnect } from './hooks/useDisconnect.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/web3-react",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -49,7 +49,7 @@
49
49
  "@lido-sdk/constants": "^3.2.0",
50
50
  "@lido-sdk/providers": "^1.4.13",
51
51
  "@lido-sdk/react": "^2.0.2",
52
- "@reef-knot/core-react": "^1.8.0",
52
+ "@reef-knot/core-react": "^1.8.1",
53
53
  "@reef-knot/ledger-connector": "^2.0.0",
54
54
  "@testing-library/react": "^12.1.5",
55
55
  "@testing-library/react-hooks": "^7.0.2",
@@ -1,9 +0,0 @@
1
- import { InjectedConnector } from '@web3-react/injected-connector';
2
- import { ConnectorHookArgs } from './types';
3
- type ConnectorHookResult = {
4
- connect: () => Promise<void>;
5
- connector: InjectedConnector;
6
- };
7
- export declare const useConnectorMetamask: (args?: ConnectorHookArgs) => ConnectorHookResult;
8
- export {};
9
- //# sourceMappingURL=useConnectorMetamask.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useConnectorMetamask.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnectorMetamask.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAUnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAIF,eAAO,MAAM,oBAAoB,UACxB,iBAAiB,KACvB,mBA0CF,CAAC"}
@@ -1,65 +0,0 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
- import invariant from 'tiny-invariant';
3
- import warning from 'tiny-warning';
4
- import { useCallback } from 'react';
5
- import { useConnectors } from './useConnectors.js';
6
- import { useWeb3 } from './useWeb3.js';
7
- import { isBraveWalletProvider, hasInjected } from '../helpers/providerDetectors.js';
8
- import { checkIfBraveBrowser } from '../helpers/ua.js';
9
- import { openWindow } from '../helpers/openWindow.js';
10
- import { useForceDisconnect } from './useDisconnect.js';
11
-
12
- var WALLET_URL = 'https://metamask.app.link/dapp/';
13
- var useConnectorMetamask = args => {
14
- var {
15
- injected
16
- } = useConnectors();
17
- var {
18
- activate
19
- } = useWeb3();
20
- var {
21
- disconnect
22
- } = useForceDisconnect();
23
- var onConnect = args === null || args === void 0 ? void 0 : args.onConnect;
24
- var openInWallet = useCallback(() => {
25
- try {
26
- var {
27
- host,
28
- pathname,
29
- search
30
- } = window.location;
31
- var pageUrlWithoutProtocol = encodeURI(host + pathname + search);
32
- openWindow("".concat(WALLET_URL).concat(pageUrlWithoutProtocol));
33
- } catch (error) {
34
- warning(false, 'Failed to open the link');
35
- }
36
- }, []);
37
- var connect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
38
- invariant(injected, 'Connector is required');
39
- // Brave Wallet mimics MetaMask.
40
- // If a user has the Brave Browser without the MetaMask extension we want
41
- // to redirect the user to the MetaMask website.
42
- // If MetaMask is installed, the isBraveWallet property will be false.
43
- if ((yield checkIfBraveBrowser()) && isBraveWalletProvider()) {
44
- openInWallet();
45
- return;
46
- }
47
- // Do not check for isMetamaskProvider here,
48
- // it will break an ability to connect with other EIP-1193 wallets,
49
- // which do not have their branded connection button
50
- // and recommend to click on MetaMask button in such case.
51
- if (hasInjected()) {
52
- yield disconnect();
53
- yield activate(injected);
54
- onConnect === null || onConnect === void 0 ? void 0 : onConnect();
55
- } else {
56
- openInWallet();
57
- }
58
- }), [injected, openInWallet, disconnect, activate, onConnect]);
59
- return {
60
- connect,
61
- connector: injected
62
- };
63
- };
64
-
65
- export { useConnectorMetamask };