@reef-knot/core-react 4.1.1 → 4.2.1
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/eip6963.d.ts +2 -0
- package/dist/eip6963.d.ts.map +1 -0
- package/dist/eip6963.js +5 -0
- package/dist/hooks/useAutoConnect.d.ts.map +1 -1
- package/dist/hooks/useAutoConnect.js +7 -1
- package/dist/hooks/useEagerConnect.d.ts +1 -2
- package/dist/hooks/useEagerConnect.d.ts.map +1 -1
- package/dist/hooks/useEagerConnect.js +10 -45
- package/dist/walletData/index.d.ts.map +1 -1
- package/dist/walletData/index.js +4 -1
- package/package.json +13 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip6963.d.ts","sourceRoot":"","sources":["../src/eip6963.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,sBAAgB,CAAC"}
|
package/dist/eip6963.js
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc,uBAAwB,OAAO,
|
|
1
|
+
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc,uBAAwB,OAAO,SAmDzD,CAAC"}
|
|
@@ -38,7 +38,13 @@ const useAutoConnect = autoConnectEnabled => {
|
|
|
38
38
|
const savedReconnectWalletId = yield storage === null || storage === void 0 ? void 0 : storage.getItem(LS_KEY_RECONNECT_WALLET_ID);
|
|
39
39
|
const walletData = walletDataList.find(data => data.walletId === savedReconnectWalletId);
|
|
40
40
|
if (walletData) {
|
|
41
|
-
|
|
41
|
+
let createConnectorFn = walletData.createConnectorFn;
|
|
42
|
+
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) {
|
|
43
|
+
createConnectorFn = walletData.walletconnectExtras.connectionViaURI.createConnectorFn;
|
|
44
|
+
}
|
|
45
|
+
// Wait for all EIP-6963 wallets to load their code and fire "eip6963:announceProvider" event
|
|
46
|
+
// Without the delay, this code can be called from a browser's cache faster than wallet extension code
|
|
47
|
+
yield new Promise(resolve => setTimeout(resolve, 100));
|
|
42
48
|
yield reconnectAsync({
|
|
43
49
|
connectors: [createConnectorFn]
|
|
44
50
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { WalletAdapterData } from '@reef-knot/types';
|
|
2
|
-
import type { Chain } from 'wagmi/chains';
|
|
3
2
|
import type { Config, ConnectReturnType } from '@wagmi/core';
|
|
4
3
|
import type { ReefKnotModalContextValue } from '../context';
|
|
5
4
|
type ConnectResult = ConnectReturnType;
|
|
6
|
-
export declare const connectEagerly: (config: Config, adapters: WalletAdapterData[], openModalAsync: ReefKnotModalContextValue['openModalAsync']
|
|
5
|
+
export declare const connectEagerly: (config: Config, adapters: WalletAdapterData[], openModalAsync: ReefKnotModalContextValue['openModalAsync']) => Promise<ConnectResult | null>;
|
|
7
6
|
export declare const useEagerConnect: () => {
|
|
8
7
|
eagerConnect: () => Promise<ConnectResult | null>;
|
|
9
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEagerConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useEagerConnect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEagerConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useEagerConnect.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,KAAK,aAAa,GAAG,iBAAiB,CAAC;AAEvC,eAAO,MAAM,cAAc,WACjB,MAAM,YACJ,iBAAiB,EAAE,kBACb,yBAAyB,CAAC,gBAAgB,CAAC,KAC1D,QAAQ,aAAa,GAAG,IAAI,CA4C9B,CAAC;AAEF,eAAO,MAAM,eAAe;;CAc3B,CAAC"}
|
|
@@ -3,53 +3,20 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import { useConfig } from 'wagmi';
|
|
4
4
|
import { useReefKnotContext } from './useReefKnotContext.js';
|
|
5
5
|
import { useReefKnotModal } from './useReefKnotModal.js';
|
|
6
|
-
import { connect
|
|
7
|
-
import { getUnsupportedChainError } from '../helpers/getUnsupportedChainError.js';
|
|
6
|
+
import { connect } from 'wagmi/actions';
|
|
8
7
|
import { checkTermsAccepted } from '../helpers/checkTermsAccepted.js';
|
|
9
8
|
|
|
10
|
-
const
|
|
9
|
+
const connectEagerly = (config, adapters, openModalAsync) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
10
|
var _a;
|
|
12
|
-
const connectResult = yield connect(config, {
|
|
13
|
-
connector
|
|
14
|
-
});
|
|
15
|
-
if (connectResult && supportedChains.findIndex(({
|
|
16
|
-
id
|
|
17
|
-
}) => id === connectResult.chainId) === -1) {
|
|
18
|
-
// No errors during connection, but the chain is unsupported.
|
|
19
|
-
// This case is considered as error for now, and we explicitly call disconnect() here.
|
|
20
|
-
// This logic comes from previously used web3-react connection logic, which wasn't reworked yet after web3-react removal.
|
|
21
|
-
// web3-react logic was: if a chain is unsupported – break the connection, throw an error
|
|
22
|
-
// wagmi logic is: if a chain is unsupported – connect anyway, without errors.
|
|
23
|
-
// So, here we are trying to mimic the legacy logic, because we are not ready to rework it yet.
|
|
24
|
-
const connectError = getUnsupportedChainError(supportedChains);
|
|
25
|
-
yield disconnect(config);
|
|
26
|
-
// A user may change a chain in a wallet app, prepare for that event.
|
|
27
|
-
// There is a strong recommendation in the MetaMask documentation
|
|
28
|
-
// to reload the page upon chain changes, unless there is a good reason not to.
|
|
29
|
-
// This looks like a good general approach.
|
|
30
|
-
if (config.state.current) {
|
|
31
|
-
const activeConnector = (_a = config.state.connections.get(config.state.current)) === null || _a === void 0 ? void 0 : _a.connector;
|
|
32
|
-
if (activeConnector) {
|
|
33
|
-
const provider = yield activeConnector.getProvider();
|
|
34
|
-
provider.once('chainChanged', () => {
|
|
35
|
-
var _a;
|
|
36
|
-
return (_a = globalThis.window) === null || _a === void 0 ? void 0 : _a.location.reload();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
throw connectError;
|
|
41
|
-
}
|
|
42
|
-
return connectResult;
|
|
43
|
-
});
|
|
44
|
-
const connectEagerly = (config, adapters, openModalAsync, supportedChains) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
var _b;
|
|
46
11
|
const isTermsAccepted = checkTermsAccepted();
|
|
47
12
|
for (const adapter of adapters) {
|
|
48
|
-
if (yield (
|
|
13
|
+
if (yield (_a = adapter.detector) === null || _a === void 0 ? void 0 : _a.call(adapter)) {
|
|
49
14
|
// wallet is detected
|
|
50
15
|
let connectionResult = null;
|
|
51
16
|
const tryConnection = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
const result = yield
|
|
17
|
+
const result = yield connect(config, {
|
|
18
|
+
connector: adapter.createConnectorFn
|
|
19
|
+
});
|
|
53
20
|
connectionResult = result;
|
|
54
21
|
return result;
|
|
55
22
|
});
|
|
@@ -68,7 +35,7 @@ const connectEagerly = (config, adapters, openModalAsync, supportedChains) => __
|
|
|
68
35
|
try {
|
|
69
36
|
yield tryConnection();
|
|
70
37
|
} catch (e) {
|
|
71
|
-
// when failed open terms modal,allow user to see error and retry
|
|
38
|
+
// when failed, open the terms modal, allow user to see the error and retry the connection
|
|
72
39
|
yield openModalAsync({
|
|
73
40
|
type: 'eager',
|
|
74
41
|
props: {
|
|
@@ -78,7 +45,6 @@ const connectEagerly = (config, adapters, openModalAsync, supportedChains) => __
|
|
|
78
45
|
});
|
|
79
46
|
}
|
|
80
47
|
}
|
|
81
|
-
// TS doesn't know we assigned in tryConnection
|
|
82
48
|
return connectionResult;
|
|
83
49
|
}
|
|
84
50
|
}
|
|
@@ -90,15 +56,14 @@ const useEagerConnect = () => {
|
|
|
90
56
|
openModalAsync
|
|
91
57
|
} = useReefKnotModal();
|
|
92
58
|
const {
|
|
93
|
-
walletDataList
|
|
94
|
-
chains
|
|
59
|
+
walletDataList
|
|
95
60
|
} = useReefKnotContext();
|
|
96
61
|
const eagerConnect = useCallback(() => {
|
|
97
62
|
const autoConnectOnlyAdapters = walletDataList.filter(({
|
|
98
63
|
autoConnectOnly
|
|
99
64
|
}) => autoConnectOnly);
|
|
100
|
-
return connectEagerly(config, autoConnectOnlyAdapters, openModalAsync
|
|
101
|
-
}, [openModalAsync, walletDataList,
|
|
65
|
+
return connectEagerly(config, autoConnectOnlyAdapters, openModalAsync);
|
|
66
|
+
}, [openModalAsync, walletDataList, config]);
|
|
102
67
|
return {
|
|
103
68
|
eagerConnect
|
|
104
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletData/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletData/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC/C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,YAAY,EAAE,KAAK,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,kBAAkB,oFAM5B,sBAAsB;;CAoBxB,CAAC"}
|
package/dist/walletData/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { providersStore } from '../eip6963.js';
|
|
2
|
+
|
|
1
3
|
const getWalletsDataList = ({
|
|
2
4
|
walletsList,
|
|
3
5
|
rpc,
|
|
@@ -13,7 +15,8 @@ const getWalletsDataList = ({
|
|
|
13
15
|
rpc,
|
|
14
16
|
defaultChain,
|
|
15
17
|
walletconnectProjectId,
|
|
16
|
-
safeAllowedDomains
|
|
18
|
+
safeAllowedDomains,
|
|
19
|
+
providersStore
|
|
17
20
|
}));
|
|
18
21
|
return {
|
|
19
22
|
walletsDataList
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/core-react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -37,22 +37,23 @@
|
|
|
37
37
|
"lint": "eslint --ext ts,tsx,js,mjs ."
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@reef-knot/ledger-connector": "^4.0
|
|
41
|
-
"@reef-knot/wallets-list": "^2.0
|
|
42
|
-
"@reef-knot/types": "^2.0
|
|
43
|
-
"@reef-knot/ui-react": "^2.1.
|
|
44
|
-
"@reef-knot/wallets-helpers": "^2.0
|
|
40
|
+
"@reef-knot/ledger-connector": "^4.1.0",
|
|
41
|
+
"@reef-knot/wallets-list": "^2.1.0",
|
|
42
|
+
"@reef-knot/types": "^2.1.0",
|
|
43
|
+
"@reef-knot/ui-react": "^2.1.3",
|
|
44
|
+
"@reef-knot/wallets-helpers": "^2.1.0",
|
|
45
45
|
"eslint-config-custom": "*",
|
|
46
46
|
"react": "18.2.0",
|
|
47
47
|
"viem": "2.13.3",
|
|
48
|
-
"wagmi": "2.11.2"
|
|
48
|
+
"wagmi": "2.11.2",
|
|
49
|
+
"mipd": "0.0.7"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@reef-knot/ledger-connector": "^4.
|
|
52
|
-
"@reef-knot/wallets-list": "^2.
|
|
53
|
-
"@reef-knot/types": "^2.0.
|
|
54
|
-
"@reef-knot/ui-react": "^2.
|
|
55
|
-
"@reef-knot/wallets-helpers": "^2.0.
|
|
52
|
+
"@reef-knot/ledger-connector": "^4.1.0",
|
|
53
|
+
"@reef-knot/wallets-list": "^2.1.0",
|
|
54
|
+
"@reef-knot/types": "^2.0.1",
|
|
55
|
+
"@reef-knot/ui-react": "^2.1.3",
|
|
56
|
+
"@reef-knot/wallets-helpers": "^2.0.2",
|
|
56
57
|
"react": ">=18",
|
|
57
58
|
"viem": "2.13.3",
|
|
58
59
|
"wagmi": "2.11.2",
|