@reef-knot/core-react 1.8.1 → 2.0.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.
- package/dist/_virtual/_tslib.js +31 -0
- package/dist/components/AutoConnect.d.ts +10 -0
- package/dist/components/AutoConnect.d.ts.map +1 -0
- package/dist/components/AutoConnect.js +14 -0
- package/dist/context/acceptTermsModal.d.ts +9 -8
- package/dist/context/acceptTermsModal.d.ts.map +1 -1
- package/dist/context/reefKnot.d.ts +1 -0
- package/dist/context/reefKnot.d.ts.map +1 -1
- package/dist/context/reefKnot.js +7 -1
- package/dist/helpers/checkTermsAccepted.d.ts +2 -0
- package/dist/helpers/checkTermsAccepted.d.ts.map +1 -0
- package/dist/helpers/checkTermsAccepted.js +11 -0
- package/dist/helpers/getUnsupportedChainError.d.ts +3 -0
- package/dist/helpers/getUnsupportedChainError.d.ts.map +1 -0
- package/dist/helpers/getUnsupportedChainError.js +13 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useAutoConnect.d.ts +4 -0
- package/dist/hooks/useAutoConnect.d.ts.map +1 -0
- package/dist/hooks/useAutoConnect.js +115 -0
- package/dist/index.js +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
16
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
27
|
+
var e = new Error(message);
|
|
28
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { __awaiter };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Chain } from 'wagmi';
|
|
3
|
+
import type { WalletAdapterData } from '@reef-knot/types';
|
|
4
|
+
export declare const AutoConnect: ({ children, autoConnect, walletDataList, chains, }: {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
autoConnect: boolean;
|
|
7
|
+
walletDataList: WalletAdapterData[];
|
|
8
|
+
chains: Chain[];
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=AutoConnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoConnect.d.ts","sourceRoot":"","sources":["../../src/components/AutoConnect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,eAAO,MAAM,WAAW;cAMZ,MAAM,SAAS;iBACZ,OAAO;oBACJ,iBAAiB,EAAE;YAC3B,KAAK,EAAE;uBAKhB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useAutoConnect } from '../hooks/useAutoConnect.js';
|
|
3
|
+
|
|
4
|
+
const AutoConnect = ({
|
|
5
|
+
children,
|
|
6
|
+
autoConnect,
|
|
7
|
+
walletDataList,
|
|
8
|
+
chains
|
|
9
|
+
}) => {
|
|
10
|
+
useAutoConnect(autoConnect, walletDataList, chains);
|
|
11
|
+
return React.createElement(React.Fragment, null, children);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { AutoConnect };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
export type AcceptTermsModal = {
|
|
3
|
+
isVisible: boolean;
|
|
4
|
+
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
5
|
+
onContinue: () => void;
|
|
6
|
+
setOnContinue: React.Dispatch<React.SetStateAction<() => void>>;
|
|
7
|
+
error?: Error;
|
|
8
|
+
setError: React.Dispatch<React.SetStateAction<Error | undefined>>;
|
|
9
|
+
};
|
|
2
10
|
export type AcceptTermsModalContextValue = {
|
|
3
|
-
acceptTermsModal:
|
|
4
|
-
isVisible: boolean;
|
|
5
|
-
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
|
-
onContinue: () => void;
|
|
7
|
-
setOnContinue: React.Dispatch<React.SetStateAction<() => void>>;
|
|
8
|
-
error?: Error;
|
|
9
|
-
setError: React.Dispatch<React.SetStateAction<Error | undefined>>;
|
|
10
|
-
};
|
|
11
|
+
acceptTermsModal: AcceptTermsModal;
|
|
11
12
|
};
|
|
12
13
|
export declare const AcceptTermsModalContext: React.Context<AcceptTermsModalContextValue>;
|
|
13
14
|
export declare const AcceptTermsModalContextProvider: ({ children, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptTermsModal.d.ts","sourceRoot":"","sources":["../../src/context/acceptTermsModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"acceptTermsModal.d.ts","sourceRoot":"","sources":["../../src/context/acceptTermsModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAChE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;CACnE,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAKF,eAAO,MAAM,uBAAuB,6CAKF,CAAC;AAEnC,eAAO,MAAM,+BAA+B;cAGhC,MAAM,SAAS;uBA+B1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reefKnot.d.ts","sourceRoot":"","sources":["../../src/context/reefKnot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,EAAE,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"reefKnot.d.ts","sourceRoot":"","sources":["../../src/context/reefKnot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,EAAE,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAMrC,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,YAAY,EAAE,KAAK,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,cAAc,EAAE,iBAAiB,EAAE,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,eAAe,qCAA4C,CAAC;AAEzE,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAuC7C,CAAC"}
|
package/dist/context/reefKnot.js
CHANGED
|
@@ -2,6 +2,7 @@ import React, { createContext, useMemo } from 'react';
|
|
|
2
2
|
import { WCWarnBannerContextProvider } from '@reef-knot/ui-react';
|
|
3
3
|
import { getWalletDataList } from '../walletData/index.js';
|
|
4
4
|
import { AcceptTermsModalContextProvider } from './acceptTermsModal.js';
|
|
5
|
+
import { AutoConnect } from '../components/AutoConnect.js';
|
|
5
6
|
|
|
6
7
|
const ReefKnotContext = createContext({});
|
|
7
8
|
const ReefKnot = ({
|
|
@@ -9,6 +10,7 @@ const ReefKnot = ({
|
|
|
9
10
|
walletconnectProjectId,
|
|
10
11
|
chains,
|
|
11
12
|
defaultChain,
|
|
13
|
+
autoConnect = true,
|
|
12
14
|
children
|
|
13
15
|
}) => {
|
|
14
16
|
const walletDataList = getWalletDataList({
|
|
@@ -24,7 +26,11 @@ const ReefKnot = ({
|
|
|
24
26
|
}), [rpc, walletDataList, chains]);
|
|
25
27
|
return React.createElement(ReefKnotContext.Provider, {
|
|
26
28
|
value: contextValue
|
|
27
|
-
}, React.createElement(AcceptTermsModalContextProvider, null, React.createElement(WCWarnBannerContextProvider, null,
|
|
29
|
+
}, React.createElement(AcceptTermsModalContextProvider, null, React.createElement(WCWarnBannerContextProvider, null, React.createElement(AutoConnect, {
|
|
30
|
+
autoConnect: autoConnect,
|
|
31
|
+
walletDataList: walletDataList,
|
|
32
|
+
chains: chains
|
|
33
|
+
}, children))));
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
export { ReefKnot, ReefKnotContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTermsAccepted.d.ts","sourceRoot":"","sources":["../../src/helpers/checkTermsAccepted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,eAK9B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LS_KEY_TERMS_ACCEPTANCE } from '../constants/localStorage.js';
|
|
2
|
+
|
|
3
|
+
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;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { checkTermsAccepted };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUnsupportedChainError.d.ts","sourceRoot":"","sources":["../../src/helpers/getUnsupportedChainError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,eAAO,MAAM,wBAAwB,oBAAqB,KAAK,EAAE,UAahE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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.map(({
|
|
5
|
+
name
|
|
6
|
+
}) => name).filter(chainName => chainName !== 'unknown');
|
|
7
|
+
const lastChain = chains.pop();
|
|
8
|
+
return [chains.join(', '), lastChain].filter(chain => chain).join(' or ');
|
|
9
|
+
})();
|
|
10
|
+
return new Error(`Unsupported chain. Please switch to ${supportedChainsNames} in your wallet.`);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { getUnsupportedChainError };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,EAAE,MAAM,OAAO,CAAC;AAIrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA+FrD,eAAO,MAAM,cAAc,uBACL,OAAO,kBACX,iBAAiB,EAAE,UAC3B,KAAK,EAAE,SA0ChB,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
import { useClient, useAccount } from 'wagmi';
|
|
3
|
+
import { connect, disconnect } from 'wagmi/actions';
|
|
4
|
+
import { useRef, useContext, useEffect } from 'react';
|
|
5
|
+
import { AcceptTermsModalContext } from '../context/acceptTermsModal.js';
|
|
6
|
+
import { getUnsupportedChainError } from '../helpers/getUnsupportedChainError.js';
|
|
7
|
+
import { checkTermsAccepted } from '../helpers/checkTermsAccepted.js';
|
|
8
|
+
|
|
9
|
+
const connectAndHandleErrors = (connector, supportedChains, acceptTermsModal) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
|
+
let connectResult = null;
|
|
12
|
+
let connectError;
|
|
13
|
+
try {
|
|
14
|
+
connectResult = yield connect({
|
|
15
|
+
connector
|
|
16
|
+
});
|
|
17
|
+
} catch (e) {
|
|
18
|
+
connectResult = null; // ensure that connectResult is empty in case of an error
|
|
19
|
+
connectError = e;
|
|
20
|
+
}
|
|
21
|
+
if (connectResult === null || connectResult === void 0 ? void 0 : connectResult.chain.unsupported) {
|
|
22
|
+
// No errors during connection, but the chain is unsupported.
|
|
23
|
+
// This case is considered as error for now, and we explicitly call disconnect() here.
|
|
24
|
+
// This logic comes from previously used web3-react connection logic, which wasn't reworked yet after web3-react removal.
|
|
25
|
+
// web3-react logic was: if a chain is unsupported – break the connection, throw an error
|
|
26
|
+
// wagmi logic is: if a chain is unsupported – connect anyway, without errors, set `chain.unsupported` flag to true.
|
|
27
|
+
// So, here we are trying to mimic the legacy logic, because we are not ready to rework it yet.
|
|
28
|
+
connectResult = null;
|
|
29
|
+
connectError = getUnsupportedChainError(supportedChains);
|
|
30
|
+
yield disconnect();
|
|
31
|
+
// A user may change a chain in a wallet app, prepare for that event.
|
|
32
|
+
// There is a strong recommendation in the MetaMask documentation
|
|
33
|
+
// to reload the page upon chain changes, unless there is a good reason not to.
|
|
34
|
+
// This looks like a good general approach.
|
|
35
|
+
const provider = yield connector.getProvider();
|
|
36
|
+
provider.once('chainChanged', () => {
|
|
37
|
+
var _a;
|
|
38
|
+
return (_a = globalThis.window) === null || _a === void 0 ? void 0 : _a.location.reload();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (connectError) {
|
|
42
|
+
(_a = acceptTermsModal.setError) === null || _a === void 0 ? void 0 : _a.call(acceptTermsModal, connectError);
|
|
43
|
+
(_b = acceptTermsModal.setVisible) === null || _b === void 0 ? void 0 : _b.call(acceptTermsModal, true);
|
|
44
|
+
} else {
|
|
45
|
+
(_c = acceptTermsModal.setVisible) === null || _c === void 0 ? void 0 : _c.call(acceptTermsModal, false);
|
|
46
|
+
(_d = acceptTermsModal.setError) === null || _d === void 0 ? void 0 : _d.call(acceptTermsModal, undefined);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
connectResult,
|
|
50
|
+
connectError
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const connectEagerly = (adapters, acceptTermsModal, supportedChains) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
var _e, _f, _g;
|
|
55
|
+
const isTermsAccepted = checkTermsAccepted();
|
|
56
|
+
let connectResult = null;
|
|
57
|
+
let connectError;
|
|
58
|
+
const continueConnection = connector => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
({
|
|
60
|
+
connectResult,
|
|
61
|
+
connectError
|
|
62
|
+
} = yield connectAndHandleErrors(connector, supportedChains, acceptTermsModal));
|
|
63
|
+
});
|
|
64
|
+
for (const adapter of adapters) {
|
|
65
|
+
if ((_e = adapter.detector) === null || _e === void 0 ? void 0 : _e.call(adapter)) {
|
|
66
|
+
// wallet is detected
|
|
67
|
+
if (!isTermsAccepted) {
|
|
68
|
+
// Terms of service were not accepted previously.
|
|
69
|
+
// So, for legal reasons, we must ask a user to accept the terms before connecting.
|
|
70
|
+
const onContinue = () => void continueConnection(adapter.connector);
|
|
71
|
+
(_f = acceptTermsModal.setOnContinue) === null || _f === void 0 ? void 0 : _f.call(acceptTermsModal, () => onContinue);
|
|
72
|
+
(_g = acceptTermsModal.setVisible) === null || _g === void 0 ? void 0 : _g.call(acceptTermsModal, true);
|
|
73
|
+
} else {
|
|
74
|
+
yield continueConnection(adapter.connector);
|
|
75
|
+
}
|
|
76
|
+
break; // no need to iterate over all other adapters if at least one was detected
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
connectResult,
|
|
81
|
+
connectError
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
const useAutoConnect = (autoConnectEnabled, walletDataList, chains) => {
|
|
85
|
+
const isAutoConnectCalled = useRef(false);
|
|
86
|
+
const client = useClient();
|
|
87
|
+
const {
|
|
88
|
+
isConnected
|
|
89
|
+
} = useAccount();
|
|
90
|
+
const {
|
|
91
|
+
acceptTermsModal
|
|
92
|
+
} = useContext(AcceptTermsModalContext);
|
|
93
|
+
const autoConnectOnlyAdapters = walletDataList.filter(adapter => adapter.autoConnectOnly);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
// Don't auto-connect if already connected or if the auto-connect feature is disabled or if already tried to auto-connect.
|
|
96
|
+
if (isConnected || !autoConnectEnabled || isAutoConnectCalled.current) return;
|
|
97
|
+
void (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
// The current logic is to try auto-connect only once, even if an error happened and connection was not successful.
|
|
99
|
+
isAutoConnectCalled.current = true;
|
|
100
|
+
// Try to eagerly connect wallets that are meant to be used only with auto-connection.
|
|
101
|
+
// For example, wallets with dApp browsers, or using iframes to open dApps.
|
|
102
|
+
const {
|
|
103
|
+
connectResult,
|
|
104
|
+
connectError
|
|
105
|
+
} = yield connectEagerly(autoConnectOnlyAdapters, acceptTermsModal, chains);
|
|
106
|
+
// If still not connected and there were no errors and the terms of service are accepted,
|
|
107
|
+
// call the default wagmi autoConnect method, which attempts to connect to the last used connector.
|
|
108
|
+
if (!connectResult && !connectError && checkTermsAccepted()) {
|
|
109
|
+
yield client.autoConnect();
|
|
110
|
+
}
|
|
111
|
+
}))();
|
|
112
|
+
}, [autoConnectOnlyAdapters, autoConnectEnabled, client, isConnected, walletDataList, acceptTermsModal, chains]);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export { useAutoConnect };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { getConnectors, getWalletDataList } from './walletData/index.js';
|
|
2
2
|
export { useReefKnotContext } from './hooks/useReefKnotContext.js';
|
|
3
|
+
export { useAutoConnect } from './hooks/useAutoConnect.js';
|
|
3
4
|
export { ReefKnot, ReefKnotContext } from './context/reefKnot.js';
|
|
4
5
|
export { AcceptTermsModalContext, AcceptTermsModalContextProvider } from './context/acceptTermsModal.js';
|
|
5
6
|
export { LS_KEY_TERMS_ACCEPTANCE } from './constants/localStorage.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/core-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -36,10 +36,14 @@
|
|
|
36
36
|
"dev": "dev=on rollup -c -w",
|
|
37
37
|
"lint": "eslint --ext ts,tsx,js,mjs ."
|
|
38
38
|
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"ua-parser-js": "1.0.33"
|
|
41
|
+
},
|
|
39
42
|
"devDependencies": {
|
|
40
|
-
"@reef-knot/wallets-list": "^1.
|
|
41
|
-
"@reef-knot/types": "^1.
|
|
43
|
+
"@reef-knot/wallets-list": "^1.12.0",
|
|
44
|
+
"@reef-knot/types": "^1.5.0",
|
|
42
45
|
"@reef-knot/ui-react": "^1.0.8",
|
|
46
|
+
"@types/ua-parser-js": "^0.7.36",
|
|
43
47
|
"eslint-config-custom": "*",
|
|
44
48
|
"react": "18.2.0",
|
|
45
49
|
"wagmi": "^0.12.19"
|