@reef-knot/web3-react 1.4.0 → 1.4.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,eAAO,MAAM,cAAc,eAAgB,sBAAsB,SAKhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAAgB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,eAAO,MAAM,cAAc,eAAgB,sBAAsB,SAKhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAAgB,sBAAsB,SAkEnE,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,IAwBvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAO,IAgB3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,IAexC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
2
|
import { useRef, useContext, useEffect } from 'react';
|
|
3
|
-
import { AcceptTermsModalContext } from '@reef-knot/core-react';
|
|
3
|
+
import { AcceptTermsModalContext, LS_KEY_TERMS_ACCEPTANCE } from '@reef-knot/core-react';
|
|
4
4
|
import { useWeb3 } from './useWeb3.js';
|
|
5
5
|
import { useConnectorStorage } from './useConnectorStorage.js';
|
|
6
6
|
import { useConnectorInfo } from './useConnectorInfo.js';
|
|
@@ -35,7 +35,7 @@ var useEagerConnector = connectors => {
|
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
if (isConnectedViaWagmi || tried.current || active) return;
|
|
37
37
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
var _a, _b;
|
|
38
|
+
var _a, _b, _c;
|
|
39
39
|
tried.current = true;
|
|
40
40
|
var isLedgerApp = ledgerlive === null || ledgerlive === void 0 ? void 0 : ledgerlive.isLedgerApp(); // Ledger Live iframe
|
|
41
41
|
var isSafeApp = yield gnosis === null || gnosis === void 0 ? void 0 : gnosis.isSafeApp(); // Gnosis iframe
|
|
@@ -53,15 +53,24 @@ var useEagerConnector = connectors => {
|
|
|
53
53
|
return null;
|
|
54
54
|
})();
|
|
55
55
|
if (!connector) return;
|
|
56
|
-
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
var connectWallet = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
var _d;
|
|
58
|
+
yield activate(connector, undefined, true);
|
|
59
|
+
// Hide the modal if a user approved the connection in a wallet's UI.
|
|
60
|
+
// If a user rejects the connection, then an error is thrown
|
|
61
|
+
// and the following code is not being reached, the modal stays visible.
|
|
62
|
+
(_d = acceptTermsModal.setVisible) === null || _d === void 0 ? void 0 : _d.call(acceptTermsModal, false);
|
|
63
|
+
});
|
|
64
|
+
var termsAccepted = false;
|
|
65
|
+
if (typeof window !== 'undefined') {
|
|
66
|
+
termsAccepted = ((_a = window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(LS_KEY_TERMS_ACCEPTANCE)) === 'true';
|
|
67
|
+
}
|
|
68
|
+
if (shouldAutoConnectApp && !termsAccepted) {
|
|
69
|
+
(_b = acceptTermsModal.setOnContinue) === null || _b === void 0 ? void 0 : _b.call(acceptTermsModal, () => connectWallet);
|
|
70
|
+
(_c = acceptTermsModal.setVisible) === null || _c === void 0 ? void 0 : _c.call(acceptTermsModal, true);
|
|
62
71
|
return;
|
|
63
72
|
}
|
|
64
|
-
yield
|
|
73
|
+
yield connectWallet();
|
|
65
74
|
}))();
|
|
66
75
|
}, [activate, active, isConnectedViaWagmi, ledgerlive, gnosis, savedConnector, connectors, injected, acceptTermsModal]);
|
|
67
76
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/web3-react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@babel/preset-react": "7.18.6",
|
|
47
47
|
"@babel/preset-typescript": "7.18.6",
|
|
48
48
|
"@ethersproject/providers": "^5.7.2",
|
|
49
|
-
"@reef-knot/core-react": "^1.5.
|
|
49
|
+
"@reef-knot/core-react": "^1.5.1",
|
|
50
50
|
"@reef-knot/ledger-connector": "^1.0.0",
|
|
51
51
|
"@testing-library/react": "^12.1.5",
|
|
52
52
|
"@testing-library/react-hooks": "^7.0.2",
|