@reef-knot/core-react 6.2.0-alpha.4 → 6.2.0-alpha.5

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.
@@ -38,6 +38,6 @@ export type ReefKnotModalContextValue = {
38
38
  setTermsChecked: (isChecked: boolean) => void;
39
39
  };
40
40
  export declare const ReefKnotModalContext: React.Context<ReefKnotModalContextValue | null>;
41
- export declare const ReefKnotModalContextProvider: ({ children, }: React.PropsWithChildren) => React.JSX.Element;
41
+ export declare const ReefKnotModalContextProvider: ({ children, }: React.PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
42
42
  export {};
43
43
  //# sourceMappingURL=reefKnotModalContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reefKnotModalContext.d.ts","sourceRoot":"","sources":["../../src/context/reefKnotModalContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAC;AAM3E,KAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,KAAK,UAAU,GACX;IACE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,YAAY,CAAC,EAAE,KAAK,CAAC;KACtB,CAAC;CACH,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEN,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC,GAAG,UAAU,CAAC;AAEf,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC,GAAG,UAAU,CAAC;AAEf,KAAK,oBAAoB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;AAE7D,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7C,cAAc,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACvE,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,YAAY,EAAE,eAAe,GAAG,SAAS,CAAC;IAC1C,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C,CAAC;AAIF,eAAO,MAAM,oBAAoB,iDACsB,CAAC;AAGxD,eAAO,MAAM,4BAA4B,kBAEtC,KAAK,CAAC,iBAAiB,sBA0DzB,CAAC"}
1
+ {"version":3,"file":"reefKnotModalContext.d.ts","sourceRoot":"","sources":["../../src/context/reefKnotModalContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAC;AAM3E,KAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,KAAK,UAAU,GACX;IACE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,YAAY,CAAC,EAAE,KAAK,CAAC;KACtB,CAAC;CACH,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEN,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC,GAAG,UAAU,CAAC;AAEf,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC,GAAG,UAAU,CAAC;AAEf,KAAK,oBAAoB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;AAE7D,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7C,cAAc,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACvE,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,YAAY,EAAE,eAAe,GAAG,SAAS,CAAC;IAC1C,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C,CAAC;AAIF,eAAO,MAAM,oBAAoB,iDACsB,CAAC;AAGxD,eAAO,MAAM,4BAA4B,kBAEtC,KAAK,CAAC,iBAAiB,4CA0DzB,CAAC"}
@@ -1,5 +1,5 @@
1
- import { __rest, __awaiter } from '../_virtual/_tslib.js';
2
- import React, { createContext, useState, useMemo } from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { createContext, useState, useMemo } from 'react';
3
3
  import { useLocalStorage } from '../helpers/useLocalStorage.js';
4
4
  import { LS_KEY_TERMS_ACCEPTANCE } from '../constants/localStorage.js';
5
5
 
@@ -12,19 +12,19 @@ const ReefKnotModalContextProvider = ({
12
12
  const [termsChecked, setTermsChecked] = useLocalStorage(LS_KEY_TERMS_ACCEPTANCE, false);
13
13
  const [modalStack, updateModalStack] = useState([]);
14
14
  const stableCallbacks = useMemo(() => ({
15
- openModal: _a => {
16
- var {
17
- onClose = NOOP
18
- } = _a,
19
- props = __rest(_a, ["onClose"]);
20
- updateModalStack(old => [...old, Object.assign(Object.assign({}, props), {
15
+ openModal: ({
16
+ onClose = NOOP,
17
+ ...props
18
+ }) => {
19
+ updateModalStack(old => [...old, {
20
+ ...props,
21
21
  onClose
22
- })]);
22
+ }]);
23
23
  },
24
- openModalAsync: _a => __awaiter(void 0, [_a], void 0, function* ({
24
+ openModalAsync: async ({
25
25
  type,
26
26
  props
27
- }) {
27
+ }) => {
28
28
  return new Promise(resolve => {
29
29
  updateModalStack(old => [
30
30
  // for some reason TS cannot match type and props here
@@ -34,11 +34,11 @@ const ReefKnotModalContextProvider = ({
34
34
  onClose: resolve
35
35
  }]);
36
36
  });
37
- }),
37
+ },
38
38
  closeModal: result => {
39
39
  updateModalStack(old => {
40
40
  const modal = old.pop();
41
- modal === null || modal === void 0 ? void 0 : modal.onClose(result);
41
+ modal?.onClose(result);
42
42
  return [...old];
43
43
  });
44
44
  },
@@ -46,7 +46,7 @@ const ReefKnotModalContextProvider = ({
46
46
  updateModalStack(old => {
47
47
  let modal = old.pop();
48
48
  while (modal) {
49
- modal === null || modal === void 0 ? void 0 : modal.onClose({
49
+ modal?.onClose({
50
50
  success: false
51
51
  });
52
52
  modal = old.pop();
@@ -55,15 +55,17 @@ const ReefKnotModalContextProvider = ({
55
55
  });
56
56
  }
57
57
  }), []);
58
- const contextValue = useMemo(() => Object.assign({
58
+ const contextValue = useMemo(() => ({
59
59
  modalStack,
60
60
  currentModal: modalStack[modalStack.length - 1],
61
61
  termsChecked,
62
- setTermsChecked
63
- }, stableCallbacks), [stableCallbacks, termsChecked, modalStack, setTermsChecked]);
64
- return React.createElement(ReefKnotModalContext.Provider, {
65
- value: contextValue
66
- }, children);
62
+ setTermsChecked,
63
+ ...stableCallbacks
64
+ }), [stableCallbacks, termsChecked, modalStack, setTermsChecked]);
65
+ return jsx(ReefKnotModalContext.Provider, {
66
+ value: contextValue,
67
+ children: children
68
+ });
67
69
  };
68
70
 
69
71
  export { ReefKnotModalContext, ReefKnotModalContextProvider };
@@ -1,8 +1,8 @@
1
- import React, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { ReefKnotProviderConfig } from './reefKnotContext';
3
3
  export interface ReefKnotProviderProps {
4
4
  config: ReefKnotProviderConfig;
5
5
  children?: ReactNode;
6
6
  }
7
- export declare const ReefKnotProvider: ({ config, children, }: ReefKnotProviderProps) => React.JSX.Element;
7
+ export declare const ReefKnotProvider: ({ config, children, }: ReefKnotProviderProps) => import("react/jsx-runtime").JSX.Element;
8
8
  //# sourceMappingURL=reefKnotProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reefKnotProvider.d.ts","sourceRoot":"","sources":["../../src/context/reefKnotProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAmB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,0BAG1B,qBAAqB,sBAqBvB,CAAC"}
1
+ {"version":3,"file":"reefKnotProvider.d.ts","sourceRoot":"","sources":["../../src/context/reefKnotProvider.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAmB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,0BAG1B,qBAAqB,4CAqBvB,CAAC"}
@@ -1,4 +1,5 @@
1
- import React, { useState, useMemo } from 'react';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useState, useMemo } from 'react';
2
3
  import { ReefKnotModalContextProvider } from './reefKnotModalContext.js';
3
4
  import { ReefKnotContext } from './reefKnotContext.js';
4
5
  import { AutoConnect } from '../components/AutoConnect.js';
@@ -11,15 +12,19 @@ const ReefKnotProvider = ({
11
12
  const {
12
13
  autoConnect
13
14
  } = config;
14
- const contextValue = useMemo(() => Object.assign(Object.assign({}, config), {
15
+ const contextValue = useMemo(() => ({
16
+ ...config,
15
17
  loadingWalletId,
16
18
  setLoadingWalletId
17
19
  }), [config, loadingWalletId]);
18
- return React.createElement(ReefKnotContext.Provider, {
19
- value: contextValue
20
- }, React.createElement(ReefKnotModalContextProvider, null, autoConnect && React.createElement(AutoConnect, {
21
- autoConnect: true
22
- }), children));
20
+ return jsx(ReefKnotContext.Provider, {
21
+ value: contextValue,
22
+ children: jsxs(ReefKnotModalContextProvider, {
23
+ children: [autoConnect && jsx(AutoConnect, {
24
+ autoConnect: true
25
+ }), children]
26
+ })
27
+ });
23
28
  };
24
29
 
25
30
  export { ReefKnotProvider };
@@ -1,9 +1,8 @@
1
1
  import { LS_KEY_TERMS_ACCEPTANCE } from '../constants/localStorage.js';
2
2
 
3
3
  const checkTermsAccepted = () => {
4
- var _a;
5
4
  if (typeof window !== 'undefined') {
6
- return ((_a = window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(LS_KEY_TERMS_ACCEPTANCE)) === 'true';
5
+ return window.localStorage?.getItem(LS_KEY_TERMS_ACCEPTANCE) === 'true';
7
6
  }
8
7
  return false;
9
8
  };
@@ -1,42 +1,41 @@
1
- import { __rest } from '../_virtual/_tslib.js';
2
1
  import { http } from 'viem';
3
2
  import { createConfig } from 'wagmi';
4
3
  import { getWalletsDataList } from './getWalletsDataList.js';
5
4
 
6
- const getDefaultTransports = (chains, rpc) => chains.reduce((result, chain) => Object.assign(Object.assign({}, result), {
5
+ const getDefaultTransports = (chains, rpc) => chains.reduce((result, chain) => ({
6
+ ...result,
7
7
  [chain.id]: http(rpc[chain.id], {
8
8
  batch: true
9
9
  })
10
10
  }), {});
11
- const getDefaultConfig = _a => {
12
- var {
13
- // Reef-Knot config args
14
- rpc,
15
- defaultChain,
16
- walletconnectProjectId,
17
- walletsList,
18
- safeAllowedDomains,
19
- chains,
20
- transports,
21
- autoConnect,
22
- onAutoConnect,
23
- onReconnect,
24
- // Wallets config args
25
- buttonComponentsByConnectorId,
26
- walletsShown,
27
- walletsPinned,
28
- walletsDisplayInitialCount,
29
- linkTerms,
30
- linkPrivacyNotice,
31
- linkDontHaveWallet,
32
- onClickTermsAccept,
33
- onClickWalletsLess,
34
- onClickWalletsMore,
35
- onConnectStart,
36
- onConnectSuccess
37
- } = _a,
38
- // Wagmi config args
39
- wagmiArgs = __rest(_a, ["rpc", "defaultChain", "walletconnectProjectId", "walletsList", "safeAllowedDomains", "chains", "transports", "autoConnect", "onAutoConnect", "onReconnect", "buttonComponentsByConnectorId", "walletsShown", "walletsPinned", "walletsDisplayInitialCount", "linkTerms", "linkPrivacyNotice", "linkDontHaveWallet", "onClickTermsAccept", "onClickWalletsLess", "onClickWalletsMore", "onConnectStart", "onConnectSuccess"]);
11
+ const getDefaultConfig = ({
12
+ // Reef-Knot config args
13
+ rpc,
14
+ defaultChain,
15
+ walletconnectProjectId,
16
+ walletsList,
17
+ safeAllowedDomains,
18
+ chains,
19
+ transports,
20
+ autoConnect,
21
+ onAutoConnect,
22
+ onReconnect,
23
+ // Wallets config args
24
+ buttonComponentsByConnectorId,
25
+ walletsShown,
26
+ walletsPinned,
27
+ walletsDisplayInitialCount,
28
+ linkTerms,
29
+ linkPrivacyNotice,
30
+ linkDontHaveWallet,
31
+ onClickTermsAccept,
32
+ onClickWalletsLess,
33
+ onClickWalletsMore,
34
+ onConnectStart,
35
+ onConnectSuccess,
36
+ // Wagmi config args
37
+ ...wagmiArgs
38
+ }) => {
40
39
  const {
41
40
  walletsDataList
42
41
  } = getWalletsDataList({
@@ -52,11 +51,12 @@ const getDefaultConfig = _a => {
52
51
  onAutoConnect,
53
52
  onReconnect
54
53
  };
55
- const wagmiConfig = createConfig(Object.assign({
54
+ const wagmiConfig = createConfig({
56
55
  chains,
57
56
  transports: transports || getDefaultTransports(chains, rpc),
58
- multiInjectedProviderDiscovery: false
59
- }, wagmiArgs));
57
+ multiInjectedProviderDiscovery: false,
58
+ ...wagmiArgs
59
+ });
60
60
  // TODO: We could use `getDefaultWalletsModalConfig` here, but it cause package dependency cycle rn
61
61
  const walletsModalConfig = {
62
62
  buttonComponentsByConnectorId,
@@ -1,10 +1,7 @@
1
1
  import { isMobileOrTablet } from '@reef-knot/wallets-helpers';
2
2
  import 'viem/window';
3
3
 
4
- const hasInjected = () => {
5
- var _a;
6
- return !!((_a = globalThis.window) === null || _a === void 0 ? void 0 : _a.ethereum);
7
- };
4
+ const hasInjected = () => !!globalThis.window?.ethereum;
8
5
  const isDappBrowserProvider = () => {
9
6
  return isMobileOrTablet && hasInjected();
10
7
  };
@@ -4,10 +4,9 @@ function useLocalStorage(key, initialValue) {
4
4
  // State to store our value
5
5
  // Pass initial state function to useState so logic is only executed once
6
6
  const [storedValue, setStoredValue] = useState(() => {
7
- var _a;
8
7
  let item;
9
8
  if (typeof window !== 'undefined') {
10
- item = (_a = window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(key);
9
+ item = window.localStorage?.getItem(key);
11
10
  }
12
11
  // Parse stored json or if none return initialValue
13
12
  return item ? JSON.parse(item) : initialValue;
@@ -1,12 +1,10 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
-
3
1
  // Utility to wrap a function and call a callback after the function call
4
2
  function withCallback(fn, callback) {
5
- return (...args) => __awaiter(this, void 0, void 0, function* () {
6
- const result = yield fn(...args);
3
+ return async (...args) => {
4
+ const result = await fn(...args);
7
5
  if (callback) callback();
8
6
  return result;
9
- });
7
+ };
10
8
  }
11
9
 
12
10
  export { withCallback };
@@ -1,6 +1,5 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
1
  import { useEffect } from 'react';
3
- import { useConfig, useReconnect, useAccount } from 'wagmi';
2
+ import { useConfig, useReconnect, useConnection } from 'wagmi';
4
3
  import { useEagerConnect } from './useEagerConnect.js';
5
4
  import { checkTermsAccepted } from '../helpers/checkTermsAccepted.js';
6
5
  import { useReefKnotContext } from './useReefKnotContext.js';
@@ -12,11 +11,11 @@ const useAutoConnect = autoConnectEnabled => {
12
11
  storage
13
12
  } = useConfig();
14
13
  const {
15
- reconnectAsync
14
+ mutateAsync: reconnectAsync
16
15
  } = useReconnect();
17
16
  const {
18
17
  isConnected
19
- } = useAccount();
18
+ } = useConnection();
20
19
  const {
21
20
  eagerConnect
22
21
  } = useEagerConnect();
@@ -25,35 +24,34 @@ const useAutoConnect = autoConnectEnabled => {
25
24
  onReconnect
26
25
  } = useReefKnotContext();
27
26
  useEffect(() => {
28
- const tryReconnect = () => __awaiter(void 0, void 0, void 0, function* () {
29
- var _a, _b;
27
+ const tryReconnect = async () => {
30
28
  // Don't auto-connect if already connected or if the auto-connect feature is disabled
31
29
  if (isConnected || !autoConnectEnabled) return;
32
30
  // Try to eagerly connect wallets that are meant to be used only with auto-connection.
33
31
  // For example, wallets with dApp browsers, or using iframes to open dApps.
34
- const connectResult = yield eagerConnect();
32
+ const connectResult = await eagerConnect();
35
33
  // If still not connected and there were no errors and the terms of service are accepted,
36
34
  // call the default wagmi autoConnect method, which attempts to connect to the last used connector.
37
35
  if (!connectResult && checkTermsAccepted() && (
38
36
  // We do not want to reconnect if the `recentConnectorId` item was deleted during disconnect
39
- yield storage === null || storage === void 0 ? void 0 : storage.getItem('recentConnectorId'))) {
40
- const savedReconnectWalletId = yield storage === null || storage === void 0 ? void 0 : storage.getItem(LS_KEY_RECONNECT_WALLET_ID);
37
+ await storage?.getItem('recentConnectorId'))) {
38
+ const savedReconnectWalletId = await storage?.getItem(LS_KEY_RECONNECT_WALLET_ID);
41
39
  const walletData = walletDataList.find(data => data.walletId === savedReconnectWalletId);
42
40
  if (walletData) {
43
41
  let createConnectorFn = walletData.createConnectorFn;
44
- if ((_b = (_a = walletData === null || walletData === void 0 ? void 0 : walletData.walletconnectExtras) === null || _a === void 0 ? void 0 : _a.connectionViaURI) === null || _b === void 0 ? void 0 : _b.condition) {
42
+ if (walletData?.walletconnectExtras?.connectionViaURI?.condition) {
45
43
  createConnectorFn = walletData.walletconnectExtras.connectionViaURI.createConnectorFn;
46
44
  }
47
45
  // Wait for all EIP-6963 wallets to load their code and fire "eip6963:announceProvider" event
48
46
  // Without the delay, this code can be called from a browser's cache faster than wallet extension code
49
- yield new Promise(resolve => setTimeout(resolve, 100));
47
+ await new Promise(resolve => setTimeout(resolve, 100));
50
48
  const reconnectWithCallback = withCallback(reconnectAsync, onReconnect);
51
- yield reconnectWithCallback({
49
+ await reconnectWithCallback({
52
50
  connectors: [createConnectorFn]
53
51
  });
54
52
  }
55
53
  }
56
- });
54
+ };
57
55
  void tryReconnect();
58
56
  // No hook deps: do not retry the auto-connect attemption.
59
57
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1,4 +1,3 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
1
  import { useCallback } from 'react';
3
2
  import { useReefKnotContext } from './useReefKnotContext.js';
4
3
 
@@ -6,15 +5,14 @@ const useAutoConnectCheck = () => {
6
5
  const {
7
6
  walletDataList
8
7
  } = useReefKnotContext();
9
- const checkIfShouldAutoConnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
10
- var _a;
8
+ const checkIfShouldAutoConnect = useCallback(async () => {
11
9
  for (const adapter of walletDataList) {
12
10
  if (!adapter.autoConnectOnly) continue;
13
11
  // Try to detect at least one wallet, marked as for auto connection only
14
- if (yield (_a = adapter.detector) === null || _a === void 0 ? void 0 : _a.call(adapter)) return true;
12
+ if (await adapter.detector?.()) return true;
15
13
  }
16
14
  return false;
17
- }), [walletDataList]);
15
+ }, [walletDataList]);
18
16
  return {
19
17
  checkIfShouldAutoConnect
20
18
  };
@@ -1,4 +1,3 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
1
  import { useCallback } from 'react';
3
2
  import { useAutoConnectCheck } from './useAutoConnectCheck.js';
4
3
  import { useEagerConnect } from './useEagerConnect.js';
@@ -14,9 +13,9 @@ const useConnect = () => {
14
13
  const {
15
14
  eagerConnect
16
15
  } = useEagerConnect();
17
- const connect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18
- if (yield checkIfShouldAutoConnect()) {
19
- const result = yield eagerConnect();
16
+ const connect = useCallback(async () => {
17
+ if (await checkIfShouldAutoConnect()) {
18
+ const result = await eagerConnect();
20
19
  return {
21
20
  success: !!result
22
21
  };
@@ -25,7 +24,7 @@ const useConnect = () => {
25
24
  type: 'wallet'
26
25
  });
27
26
  }
28
- }), [checkIfShouldAutoConnect, eagerConnect, openModalAsync]);
27
+ }, [checkIfShouldAutoConnect, eagerConnect, openModalAsync]);
29
28
  return {
30
29
  connect
31
30
  };
@@ -1,21 +1,21 @@
1
- import { useAccount } from 'wagmi';
1
+ import { useConnection } from 'wagmi';
2
2
  import { idLedgerHid, idLedgerLive } from '@reef-knot/ledger-connector';
3
3
  import { hasInjected, isDappBrowserProvider } from '../helpers/providerDetectors.js';
4
4
 
5
5
  const useConnectorInfo = () => {
6
6
  const {
7
7
  connector
8
- } = useAccount();
8
+ } = useConnection();
9
9
  // These checks are working only for connected wallets! There is no connector if a wallet is not connected yet.
10
- const isLedger = Boolean((connector === null || connector === void 0 ? void 0 : connector.id) === idLedgerHid);
11
- const isLedgerLive = Boolean((connector === null || connector === void 0 ? void 0 : connector.id) === idLedgerLive);
12
- const isGnosis = Boolean((connector === null || connector === void 0 ? void 0 : connector.id) === 'safe');
10
+ const isLedger = Boolean(connector?.id === idLedgerHid);
11
+ const isLedgerLive = Boolean(connector?.id === idLedgerLive);
12
+ const isGnosis = Boolean(connector?.id === 'safe');
13
13
  const isInjected = hasInjected();
14
14
  const isDappBrowser = isDappBrowserProvider();
15
15
  // Do not set connector's name if the app is opened in a mobile wallet dapp browser,
16
16
  // because we use a generic injected connector for this case and proper detection is hard.
17
17
  // Also, it will be easy for a user to understand which wallet app is being used for connection.
18
- const connectorName = isDappBrowser ? undefined : connector === null || connector === void 0 ? void 0 : connector.name;
18
+ const connectorName = isDappBrowser ? undefined : connector?.name;
19
19
  return {
20
20
  connectorName,
21
21
  isGnosis,
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useMemo } from 'react';
2
- import { useAccount, useConfig, useDisconnect as useDisconnect$1 } from 'wagmi';
2
+ import { useConnection, useConfig, useDisconnect as useDisconnect$1 } from 'wagmi';
3
3
  import { useReefKnotContext } from './useReefKnotContext.js';
4
4
  import { useReefKnotModal } from './useReefKnotModal.js';
5
5
  import { LS_KEY_RECONNECT_WALLET_ID } from '../constants/localStorage.js';
@@ -9,12 +9,12 @@ const useDisconnectCleaningStorage = () => {
9
9
  storage
10
10
  } = useConfig();
11
11
  const {
12
- disconnect
12
+ mutate: disconnect
13
13
  } = useDisconnect$1();
14
14
  return useCallback((...args) => {
15
15
  disconnect(...args);
16
- void (storage === null || storage === void 0 ? void 0 : storage.removeItem('recentConnectorId'));
17
- void (storage === null || storage === void 0 ? void 0 : storage.removeItem(LS_KEY_RECONNECT_WALLET_ID));
16
+ void storage?.removeItem('recentConnectorId');
17
+ void storage?.removeItem(LS_KEY_RECONNECT_WALLET_ID);
18
18
  }, [disconnect, storage]);
19
19
  };
20
20
  const useForceDisconnect = () => {
@@ -34,7 +34,7 @@ const useDisconnect = () => {
34
34
  const {
35
35
  isConnected,
36
36
  connector
37
- } = useAccount();
37
+ } = useConnection();
38
38
  const disconnect = useDisconnectCleaningStorage();
39
39
  const {
40
40
  walletDataList
@@ -42,8 +42,8 @@ const useDisconnect = () => {
42
42
  const isDisconnectMakesSense = useMemo(() => {
43
43
  // It doesn't make sense to offer a user the ability to disconnect if the user is not connected yet,
44
44
  // or if the user was connected automatically
45
- const connectorData = walletDataList.find(c => c.walletId === (connector === null || connector === void 0 ? void 0 : connector.id));
46
- return isConnected && !(connectorData === null || connectorData === void 0 ? void 0 : connectorData.autoConnectOnly);
45
+ const connectorData = walletDataList.find(c => c.walletId === connector?.id);
46
+ return isConnected && !connectorData?.autoConnectOnly;
47
47
  }, [isConnected, connector, walletDataList]);
48
48
  return {
49
49
  disconnect: isDisconnectMakesSense ? disconnect : undefined,
@@ -1,4 +1,3 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
1
  import { useCallback } from 'react';
3
2
  import { useConfig } from 'wagmi';
4
3
  import { useReefKnotContext } from './useReefKnotContext.js';
@@ -6,25 +5,24 @@ import { useReefKnotModal } from './useReefKnotModal.js';
6
5
  import { connect } from 'wagmi/actions';
7
6
  import { checkTermsAccepted } from '../helpers/checkTermsAccepted.js';
8
7
 
9
- const connectEagerly = (config, adapters, openModalAsync) => __awaiter(void 0, void 0, void 0, function* () {
10
- var _a;
8
+ const connectEagerly = async (config, adapters, openModalAsync) => {
11
9
  const isTermsAccepted = checkTermsAccepted();
12
10
  for (const adapter of adapters) {
13
- if (yield (_a = adapter.detector) === null || _a === void 0 ? void 0 : _a.call(adapter)) {
11
+ if (await adapter.detector?.()) {
14
12
  // wallet is detected
15
13
  let connectionResult = null;
16
- const tryConnection = () => __awaiter(void 0, void 0, void 0, function* () {
17
- const result = yield connect(config, {
14
+ const tryConnection = async () => {
15
+ const result = await connect(config, {
18
16
  connector: adapter.createConnectorFn
19
17
  });
20
18
  connectionResult = result;
21
19
  return result;
22
- });
20
+ };
23
21
  // if terms are not accepted, show modal and wait for user to try to connect from it
24
22
  if (!isTermsAccepted) {
25
23
  // Terms of service were not accepted previously.
26
24
  // So, for legal reasons, we must ask a user to accept the terms before connecting.
27
- yield openModalAsync({
25
+ await openModalAsync({
28
26
  type: 'eager',
29
27
  props: {
30
28
  tryConnection
@@ -33,10 +31,10 @@ const connectEagerly = (config, adapters, openModalAsync) => __awaiter(void 0, v
33
31
  } else {
34
32
  // happy path - try connection
35
33
  try {
36
- yield tryConnection();
34
+ await tryConnection();
37
35
  } catch (e) {
38
36
  // when failed, open the terms modal, allow user to see the error and retry the connection
39
- yield openModalAsync({
37
+ await openModalAsync({
40
38
  type: 'eager',
41
39
  props: {
42
40
  tryConnection,
@@ -49,7 +47,7 @@ const connectEagerly = (config, adapters, openModalAsync) => __awaiter(void 0, v
49
47
  }
50
48
  }
51
49
  return null;
52
- });
50
+ };
53
51
  const useEagerConnect = () => {
54
52
  const config = useConfig();
55
53
  const {
@@ -59,16 +57,16 @@ const useEagerConnect = () => {
59
57
  walletDataList,
60
58
  onAutoConnect
61
59
  } = useReefKnotContext();
62
- const eagerConnect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
60
+ const eagerConnect = useCallback(async () => {
63
61
  const autoConnectOnlyAdapters = walletDataList.filter(({
64
62
  autoConnectOnly
65
63
  }) => autoConnectOnly);
66
- const connectionResult = yield connectEagerly(config, autoConnectOnlyAdapters, openModalAsync);
64
+ const connectionResult = await connectEagerly(config, autoConnectOnlyAdapters, openModalAsync);
67
65
  if (connectionResult && onAutoConnect) {
68
66
  onAutoConnect();
69
67
  }
70
68
  return connectionResult;
71
- }), [openModalAsync, walletDataList, config, onAutoConnect]);
69
+ }, [openModalAsync, walletDataList, config, onAutoConnect]);
72
70
  return {
73
71
  eagerConnect
74
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/core-react",
3
- "version": "6.2.0-alpha.4",
3
+ "version": "6.2.0-alpha.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -37,26 +37,26 @@
37
37
  "lint": "eslint --ext ts,tsx,js,mjs ."
38
38
  },
39
39
  "devDependencies": {
40
- "@reef-knot/ledger-connector": "4.4.0-alpha.3",
41
- "@reef-knot/types": "4.2.0-alpha.1",
42
- "@reef-knot/ui-react": "2.3.0-alpha.1",
43
- "@reef-knot/wallets-helpers": "2.3.0-alpha.1",
44
- "@reef-knot/wallets-list": "4.2.0-alpha.4",
40
+ "@reef-knot/ledger-connector": "4.4.0-alpha.4",
41
+ "@reef-knot/types": "4.2.0-alpha.2",
42
+ "@reef-knot/ui-react": "2.3.0-alpha.2",
43
+ "@reef-knot/wallets-helpers": "2.3.0-alpha.2",
44
+ "@reef-knot/wallets-list": "4.2.0-alpha.5",
45
45
  "eslint-config-custom": "*",
46
46
  "mipd": "0.0.7",
47
47
  "react": "18.2.0",
48
- "viem": ">=2.23",
49
- "wagmi": ">=2.14"
48
+ "viem": ">=2.44",
49
+ "wagmi": ">=3.3"
50
50
  },
51
51
  "peerDependencies": {
52
- "@reef-knot/ledger-connector": "4.4.0-alpha.3",
53
- "@reef-knot/types": "4.2.0-alpha.1",
54
- "@reef-knot/ui-react": "2.3.0-alpha.1",
55
- "@reef-knot/wallets-helpers": "2.3.0-alpha.1",
56
- "@reef-knot/wallets-list": "4.2.0-alpha.4",
52
+ "@reef-knot/ledger-connector": "4.4.0-alpha.4",
53
+ "@reef-knot/types": "4.2.0-alpha.2",
54
+ "@reef-knot/ui-react": "2.3.0-alpha.2",
55
+ "@reef-knot/wallets-helpers": "2.3.0-alpha.2",
56
+ "@reef-knot/wallets-list": "4.2.0-alpha.5",
57
57
  "@tanstack/react-query": "^5.29.0",
58
58
  "react": ">=18",
59
- "viem": ">=2.23",
60
- "wagmi": ">=2.14"
59
+ "viem": ">=2.44",
60
+ "wagmi": ">=3.3"
61
61
  }
62
62
  }
@@ -1,45 +0,0 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- /* global Reflect, Promise, SuppressedError, Symbol */
16
-
17
-
18
- function __rest(s, e) {
19
- var t = {};
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
21
- t[p] = s[p];
22
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
23
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
24
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
25
- t[p[i]] = s[p[i]];
26
- }
27
- return t;
28
- }
29
-
30
- function __awaiter(thisArg, _arguments, P, generator) {
31
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
32
- return new (P || (P = Promise))(function (resolve, reject) {
33
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
34
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
35
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36
- step((generator = generator.apply(thisArg, _arguments || [])).next());
37
- });
38
- }
39
-
40
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
41
- var e = new Error(message);
42
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
43
- };
44
-
45
- export { __awaiter, __rest };