@reef-knot/core-react 6.2.4 → 7.0.0-alpha.2

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.
@@ -1,10 +1,10 @@
1
- import { useAutoConnect } from '../hooks/useAutoConnect.js';
1
+ import { useAutoConnect } from "../hooks/useAutoConnect.js";
2
2
 
3
- const AutoConnect = ({
4
- autoConnect
5
- }) => {
6
- useAutoConnect(autoConnect);
7
- return null;
3
+ //#region src/components/AutoConnect.tsx
4
+ const AutoConnect = ({ autoConnect }) => {
5
+ useAutoConnect(autoConnect);
6
+ return null;
8
7
  };
9
8
 
10
- export { AutoConnect };
9
+ //#endregion
10
+ export { AutoConnect };
@@ -1,10 +1,6 @@
1
- // This key can be changed to enforce all users to accept the Terms again,
2
- // for example if the Terms were significantly updated
3
- const LS_KEY_TERMS_ACCEPTANCE = 'reef-knot_accept-terms_n2';
4
- // Storage key for restoring connector after page refresh
5
- // `/packages/core-react/src/hooks/useAutoConnect.ts`
6
- // It keeps association with the reef-knot `WalletAdapterData['walletId']` metadata
7
- // from the `ReefKnotContextValue['walletDataList']` instead of wagmi's `config.connectors` for better reliability
8
- const LS_KEY_RECONNECT_WALLET_ID = 'reef-knot_reconnect-wallet-id';
1
+ //#region src/constants/localStorage.ts
2
+ const LS_KEY_TERMS_ACCEPTANCE = "reef-knot_accept-terms_n2";
3
+ const LS_KEY_RECONNECT_WALLET_ID = "reef-knot_reconnect-wallet-id";
9
4
 
10
- export { LS_KEY_RECONNECT_WALLET_ID, LS_KEY_TERMS_ACCEPTANCE };
5
+ //#endregion
6
+ export { LS_KEY_RECONNECT_WALLET_ID, LS_KEY_TERMS_ACCEPTANCE };
@@ -1,8 +1,10 @@
1
- import { createContext } from 'react';
1
+ import { createContext } from "react";
2
2
 
3
+ //#region src/context/reefKnotContext.ts
3
4
  /**
4
- * Context definition is in separated file to avoid circular dependencies
5
- */
5
+ * Context definition is in separated file to avoid circular dependencies
6
+ */
6
7
  const ReefKnotContext = createContext({});
7
8
 
8
- export { ReefKnotContext };
9
+ //#endregion
10
+ export { ReefKnotContext };
@@ -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,69 +1,65 @@
1
- import { __rest, __awaiter } from '../_virtual/_tslib.js';
2
- import React, { createContext, useState, useMemo } from 'react';
3
- import { useLocalStorage } from '../helpers/useLocalStorage.js';
4
- import { LS_KEY_TERMS_ACCEPTANCE } from '../constants/localStorage.js';
1
+ import { useLocalStorage } from "../helpers/useLocalStorage.js";
2
+ import { LS_KEY_TERMS_ACCEPTANCE } from "../constants/localStorage.js";
3
+ import { createContext, useMemo, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
5
 
6
+ //#region src/context/reefKnotModalContext.tsx
6
7
  const NOOP = () => {};
7
8
  const ReefKnotModalContext = createContext(null);
8
- ReefKnotModalContext.displayName = 'ReefKnotModalContext';
9
- const ReefKnotModalContextProvider = ({
10
- children
11
- }) => {
12
- const [termsChecked, setTermsChecked] = useLocalStorage(LS_KEY_TERMS_ACCEPTANCE, false);
13
- const [modalStack, updateModalStack] = useState([]);
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), {
21
- onClose
22
- })]);
23
- },
24
- openModalAsync: _a => __awaiter(void 0, [_a], void 0, function* ({
25
- type,
26
- props
27
- }) {
28
- return new Promise(resolve => {
29
- updateModalStack(old => [
30
- // for some reason TS cannot match type and props here
31
- ...old, {
32
- type,
33
- props: props,
34
- onClose: resolve
35
- }]);
36
- });
37
- }),
38
- closeModal: result => {
39
- updateModalStack(old => {
40
- const modal = old.pop();
41
- modal === null || modal === void 0 ? void 0 : modal.onClose(result);
42
- return [...old];
43
- });
44
- },
45
- forceCloseAllModals: () => {
46
- updateModalStack(old => {
47
- let modal = old.pop();
48
- while (modal) {
49
- modal === null || modal === void 0 ? void 0 : modal.onClose({
50
- success: false
51
- });
52
- modal = old.pop();
53
- }
54
- return [];
55
- });
56
- }
57
- }), []);
58
- const contextValue = useMemo(() => Object.assign({
59
- modalStack,
60
- currentModal: modalStack[modalStack.length - 1],
61
- termsChecked,
62
- setTermsChecked
63
- }, stableCallbacks), [stableCallbacks, termsChecked, modalStack, setTermsChecked]);
64
- return React.createElement(ReefKnotModalContext.Provider, {
65
- value: contextValue
66
- }, children);
9
+ ReefKnotModalContext.displayName = "ReefKnotModalContext";
10
+ const ReefKnotModalContextProvider = ({ children }) => {
11
+ const [termsChecked, setTermsChecked] = useLocalStorage(LS_KEY_TERMS_ACCEPTANCE, false);
12
+ const [modalStack, updateModalStack] = useState([]);
13
+ const stableCallbacks = useMemo(() => ({
14
+ openModal: ({ onClose = NOOP, ...props }) => {
15
+ updateModalStack((old) => [...old, {
16
+ ...props,
17
+ onClose
18
+ }]);
19
+ },
20
+ openModalAsync: async ({ type, props }) => {
21
+ return new Promise((resolve) => {
22
+ updateModalStack((old) => [...old, {
23
+ type,
24
+ props,
25
+ onClose: resolve
26
+ }]);
27
+ });
28
+ },
29
+ closeModal: (result) => {
30
+ updateModalStack((old) => {
31
+ old.pop()?.onClose(result);
32
+ return [...old];
33
+ });
34
+ },
35
+ forceCloseAllModals: () => {
36
+ updateModalStack((old) => {
37
+ let modal = old.pop();
38
+ while (modal) {
39
+ modal?.onClose({ success: false });
40
+ modal = old.pop();
41
+ }
42
+ return [];
43
+ });
44
+ }
45
+ }), []);
46
+ const contextValue = useMemo(() => ({
47
+ modalStack,
48
+ currentModal: modalStack[modalStack.length - 1],
49
+ termsChecked,
50
+ setTermsChecked,
51
+ ...stableCallbacks
52
+ }), [
53
+ stableCallbacks,
54
+ termsChecked,
55
+ modalStack,
56
+ setTermsChecked
57
+ ]);
58
+ return /* @__PURE__ */ jsx(ReefKnotModalContext.Provider, {
59
+ value: contextValue,
60
+ children
61
+ });
67
62
  };
68
63
 
69
- export { ReefKnotModalContext, ReefKnotModalContextProvider };
64
+ //#endregion
65
+ 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,25 +1,23 @@
1
- import React, { useState, useMemo } from 'react';
2
- import { ReefKnotModalContextProvider } from './reefKnotModalContext.js';
3
- import { ReefKnotContext } from './reefKnotContext.js';
4
- import { AutoConnect } from '../components/AutoConnect.js';
1
+ import { ReefKnotContext } from "./reefKnotContext.js";
2
+ import { ReefKnotModalContextProvider } from "./reefKnotModalContext.js";
3
+ import { AutoConnect } from "../components/AutoConnect.js";
4
+ import { useMemo, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
5
6
 
6
- const ReefKnotProvider = ({
7
- config,
8
- children
9
- }) => {
10
- const [loadingWalletId, setLoadingWalletId] = useState(null);
11
- const {
12
- autoConnect
13
- } = config;
14
- const contextValue = useMemo(() => Object.assign(Object.assign({}, config), {
15
- loadingWalletId,
16
- setLoadingWalletId
17
- }), [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));
7
+ //#region src/context/reefKnotProvider.tsx
8
+ const ReefKnotProvider = ({ config, children }) => {
9
+ const [loadingWalletId, setLoadingWalletId] = useState(null);
10
+ const { autoConnect } = config;
11
+ const contextValue = useMemo(() => ({
12
+ ...config,
13
+ loadingWalletId,
14
+ setLoadingWalletId
15
+ }), [config, loadingWalletId]);
16
+ return /* @__PURE__ */ jsx(ReefKnotContext.Provider, {
17
+ value: contextValue,
18
+ children: /* @__PURE__ */ jsxs(ReefKnotModalContextProvider, { children: [autoConnect && /* @__PURE__ */ jsx(AutoConnect, { autoConnect: true }), children] })
19
+ });
23
20
  };
24
21
 
25
- export { ReefKnotProvider };
22
+ //#endregion
23
+ export { ReefKnotProvider };
package/dist/eip6963.js CHANGED
@@ -1,5 +1,7 @@
1
- import { createStore } from 'mipd';
1
+ import { createStore } from "mipd";
2
2
 
3
+ //#region src/eip6963.ts
3
4
  const providersStore = createStore();
4
5
 
5
- export { providersStore };
6
+ //#endregion
7
+ export { providersStore };
@@ -1,11 +1,10 @@
1
- import { LS_KEY_TERMS_ACCEPTANCE } from '../constants/localStorage.js';
1
+ import { LS_KEY_TERMS_ACCEPTANCE } from "../constants/localStorage.js";
2
2
 
3
+ //#region src/helpers/checkTermsAccepted.ts
3
4
  const checkTermsAccepted = () => {
4
- var _a;
5
- if (typeof window !== 'undefined') {
6
- return ((_a = window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(LS_KEY_TERMS_ACCEPTANCE)) === 'true';
7
- }
8
- return false;
5
+ if (typeof window !== "undefined") return window.localStorage?.getItem(LS_KEY_TERMS_ACCEPTANCE) === "true";
6
+ return false;
9
7
  };
10
8
 
11
- export { checkTermsAccepted };
9
+ //#endregion
10
+ export { checkTermsAccepted };
@@ -1,83 +1,51 @@
1
- import { __rest } from '../_virtual/_tslib.js';
2
- import { http } from 'viem';
3
- import { createConfig } from 'wagmi';
4
- import { getWalletsDataList } from './getWalletsDataList.js';
1
+ import { getWalletsDataList } from "./getWalletsDataList.js";
2
+ import { createConfig } from "wagmi";
3
+ import { http } from "viem";
5
4
 
6
- const getDefaultTransports = (chains, rpc) => chains.reduce((result, chain) => Object.assign(Object.assign({}, result), {
7
- [chain.id]: http(rpc[chain.id], {
8
- batch: true
9
- })
5
+ //#region src/helpers/getDefaultConfig.ts
6
+ const getDefaultTransports = (chains, rpc) => chains.reduce((result, chain) => ({
7
+ ...result,
8
+ [chain.id]: http(rpc[chain.id], { batch: true })
10
9
  }), {});
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"]);
40
- const {
41
- walletsDataList
42
- } = getWalletsDataList({
43
- rpc,
44
- defaultChain,
45
- walletsList,
46
- walletconnectProjectId,
47
- safeAllowedDomains
48
- });
49
- const reefKnotConfig = {
50
- autoConnect,
51
- walletDataList: walletsDataList,
52
- onAutoConnect,
53
- onReconnect
54
- };
55
- const wagmiConfig = createConfig(Object.assign({
56
- chains,
57
- transports: transports || getDefaultTransports(chains, rpc),
58
- multiInjectedProviderDiscovery: false
59
- }, wagmiArgs));
60
- // TODO: We could use `getDefaultWalletsModalConfig` here, but it cause package dependency cycle rn
61
- const walletsModalConfig = {
62
- buttonComponentsByConnectorId,
63
- walletsShown,
64
- walletsPinned,
65
- walletsDisplayInitialCount,
66
- linkTerms,
67
- linkPrivacyNotice,
68
- linkDontHaveWallet,
69
- onClickTermsAccept,
70
- onClickWalletsLess,
71
- onClickWalletsMore,
72
- onConnectStart,
73
- onConnectSuccess
74
- };
75
- return {
76
- wagmiConfig,
77
- reefKnotConfig,
78
- walletsDataList,
79
- walletsModalConfig
80
- };
10
+ const getDefaultConfig = ({ rpc, defaultChain, walletconnectProjectId, walletsList, safeAllowedDomains, chains, transports, autoConnect, onAutoConnect, onReconnect, buttonComponentsByConnectorId, walletsShown, walletsPinned, walletsDisplayInitialCount, linkTerms, linkPrivacyNotice, linkDontHaveWallet, onClickTermsAccept, onClickWalletsLess, onClickWalletsMore, onConnectStart, onConnectSuccess, ...wagmiArgs }) => {
11
+ const { walletsDataList } = getWalletsDataList({
12
+ rpc,
13
+ defaultChain,
14
+ walletsList,
15
+ walletconnectProjectId,
16
+ safeAllowedDomains
17
+ });
18
+ const reefKnotConfig = {
19
+ autoConnect,
20
+ walletDataList: walletsDataList,
21
+ onAutoConnect,
22
+ onReconnect
23
+ };
24
+ return {
25
+ wagmiConfig: createConfig({
26
+ chains,
27
+ transports: transports || getDefaultTransports(chains, rpc),
28
+ multiInjectedProviderDiscovery: false,
29
+ ...wagmiArgs
30
+ }),
31
+ reefKnotConfig,
32
+ walletsDataList,
33
+ walletsModalConfig: {
34
+ buttonComponentsByConnectorId,
35
+ walletsShown,
36
+ walletsPinned,
37
+ walletsDisplayInitialCount,
38
+ linkTerms,
39
+ linkPrivacyNotice,
40
+ linkDontHaveWallet,
41
+ onClickTermsAccept,
42
+ onClickWalletsLess,
43
+ onClickWalletsMore,
44
+ onConnectStart,
45
+ onConnectSuccess
46
+ }
47
+ };
81
48
  };
82
49
 
83
- export { getDefaultConfig };
50
+ //#endregion
51
+ export { getDefaultConfig };
@@ -1,18 +1,12 @@
1
- const getUnsupportedChainError = supportedChains => {
2
- // Get names of supported chains to suggest them in case of "unsupported network" error
3
- const supportedChainsNames = (() => {
4
- const chains = supportedChains
5
- // On Lido widgets the Polygon Mumbai network was added as a temporary workaround for the wagmi and walletconnect bug,
6
- // when some wallets are failing to connect if there are only one supported network, so we need at least 2 of them.
7
- // But we don't want to mention it in the error as a suggested supported network, because it is not really true, so temporary filtering it out.
8
- // TODO: the issue is fixed in wagmi v1+, remove the filter after updating wagmi to v1+
9
- .filter(chain => chain.id !== 80001).map(({
10
- name
11
- }) => name).filter(chainName => chainName !== 'unknown');
12
- const lastChain = chains.pop();
13
- return [chains.join(', '), lastChain].filter(chain => chain).join(' or ');
14
- })();
15
- return new Error(`Unsupported chain. Please switch to ${supportedChainsNames} in your wallet.`);
1
+ //#region src/helpers/getUnsupportedChainError.ts
2
+ const getUnsupportedChainError = (supportedChains) => {
3
+ const supportedChainsNames = (() => {
4
+ const chains = supportedChains.filter((chain) => chain.id !== 80001).map(({ name }) => name).filter((chainName) => chainName !== "unknown");
5
+ const lastChain = chains.pop();
6
+ return [chains.join(", "), lastChain].filter((chain) => chain).join(" or ");
7
+ })();
8
+ return /* @__PURE__ */ new Error(`Unsupported chain. Please switch to ${supportedChainsNames} in your wallet.`);
16
9
  };
17
10
 
18
- export { getUnsupportedChainError };
11
+ //#endregion
12
+ export { getUnsupportedChainError };
@@ -1,26 +1,17 @@
1
- import { providersStore } from '../eip6963.js';
1
+ import { providersStore } from "../eip6963.js";
2
2
 
3
- const getWalletsDataList = ({
4
- walletsList,
5
- rpc,
6
- defaultChain,
7
- walletconnectProjectId,
8
- safeAllowedDomains
9
- }) => {
10
- const walletAdapters = Object.values(walletsList);
11
- if (!rpc[defaultChain.id]) {
12
- throw 'RPC for default chain must be provided';
13
- }
14
- const walletsDataList = walletAdapters.map(walletAdapter => walletAdapter({
15
- rpc,
16
- defaultChain,
17
- walletconnectProjectId,
18
- safeAllowedDomains,
19
- providersStore
20
- }));
21
- return {
22
- walletsDataList
23
- };
3
+ //#region src/helpers/getWalletsDataList.ts
4
+ const getWalletsDataList = ({ walletsList, rpc, defaultChain, walletconnectProjectId, safeAllowedDomains }) => {
5
+ const walletAdapters = Object.values(walletsList);
6
+ if (!rpc[defaultChain.id]) throw "RPC for default chain must be provided";
7
+ return { walletsDataList: walletAdapters.map((walletAdapter) => walletAdapter({
8
+ rpc,
9
+ defaultChain,
10
+ walletconnectProjectId,
11
+ safeAllowedDomains,
12
+ providersStore
13
+ })) };
24
14
  };
25
15
 
26
- export { getWalletsDataList };
16
+ //#endregion
17
+ export { getWalletsDataList };
@@ -0,0 +1,6 @@
1
+ import { useLocalStorage } from "./useLocalStorage.js";
2
+ import { checkTermsAccepted } from "./checkTermsAccepted.js";
3
+ import { hasInjected, isDappBrowserProvider } from "./providerDetectors.js";
4
+ import { getUnsupportedChainError } from "./getUnsupportedChainError.js";
5
+ import { getWalletsDataList } from "./getWalletsDataList.js";
6
+ import { getDefaultConfig } from "./getDefaultConfig.js";
@@ -1,12 +1,11 @@
1
- import { isMobileOrTablet } from '@reef-knot/wallets-helpers';
2
- import 'viem/window';
1
+ import { isMobileOrTablet } from "@reef-knot/wallets-helpers";
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
+ //#region src/helpers/providerDetectors.ts
5
+ const hasInjected = () => !!globalThis.window?.ethereum;
8
6
  const isDappBrowserProvider = () => {
9
- return isMobileOrTablet && hasInjected();
7
+ return isMobileOrTablet && hasInjected();
10
8
  };
11
9
 
12
- export { hasInjected, isDappBrowserProvider };
10
+ //#endregion
11
+ export { hasInjected, isDappBrowserProvider };
@@ -1,29 +1,19 @@
1
- import { useState } from 'react';
1
+ import { useState } from "react";
2
2
 
3
+ //#region src/helpers/useLocalStorage.ts
3
4
  function useLocalStorage(key, initialValue) {
4
- // State to store our value
5
- // Pass initial state function to useState so logic is only executed once
6
- const [storedValue, setStoredValue] = useState(() => {
7
- var _a;
8
- let item;
9
- if (typeof window !== 'undefined') {
10
- item = (_a = window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(key);
11
- }
12
- // Parse stored json or if none return initialValue
13
- return item ? JSON.parse(item) : initialValue;
14
- });
15
- // Return a wrapped version of useState's setter function that persists the new value to localStorage.
16
- const setValue = value => {
17
- // Allow value to be a function, so we have same API as useState
18
- const valueToStore = value instanceof Function ? value(storedValue) : value;
19
- // Save state
20
- setStoredValue(valueToStore);
21
- // Save to local storage
22
- if (typeof window !== 'undefined') {
23
- window.localStorage.setItem(key, JSON.stringify(valueToStore));
24
- }
25
- };
26
- return [storedValue, setValue];
5
+ const [storedValue, setStoredValue] = useState(() => {
6
+ let item;
7
+ if (typeof window !== "undefined") item = window.localStorage?.getItem(key);
8
+ return item ? JSON.parse(item) : initialValue;
9
+ });
10
+ const setValue = (value) => {
11
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
12
+ setStoredValue(valueToStore);
13
+ if (typeof window !== "undefined") window.localStorage.setItem(key, JSON.stringify(valueToStore));
14
+ };
15
+ return [storedValue, setValue];
27
16
  }
28
17
 
29
- export { useLocalStorage };
18
+ //#endregion
19
+ export { useLocalStorage };
@@ -1,12 +1,11 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
-
3
- // Utility to wrap a function and call a callback after the function call
1
+ //#region src/helpers/withCallback.ts
4
2
  function withCallback(fn, callback) {
5
- return (...args) => __awaiter(this, void 0, void 0, function* () {
6
- const result = yield fn(...args);
7
- if (callback) callback();
8
- return result;
9
- });
3
+ return async (...args) => {
4
+ const result = await fn(...args);
5
+ if (callback) callback();
6
+ return result;
7
+ };
10
8
  }
11
9
 
12
- export { withCallback };
10
+ //#endregion
11
+ export { withCallback };
@@ -0,0 +1,8 @@
1
+ import { useReefKnotContext } from "./useReefKnotContext.js";
2
+ import { useReefKnotModal } from "./useReefKnotModal.js";
3
+ import { connectEagerly, useEagerConnect } from "./useEagerConnect.js";
4
+ import { useAutoConnect } from "./useAutoConnect.js";
5
+ import { useAutoConnectCheck } from "./useAutoConnectCheck.js";
6
+ import { useDisconnect, useForceDisconnect } from "./useDisconnect.js";
7
+ import { useConnectorInfo } from "./useConnectorInfo.js";
8
+ import { useConnect } from "./useConnect.js";