@reef-knot/web3-react 1.10.0 → 1.12.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/context/connectors.d.ts +1 -5
- package/dist/context/connectors.d.ts.map +1 -1
- package/dist/context/connectors.js +3 -30
- package/dist/context/web3.js +1 -1
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useAutoConnect.d.ts.map +1 -1
- package/dist/hooks/useAutoConnect.js +2 -8
- package/dist/hooks/useConnectorInfo.d.ts +0 -1
- package/dist/hooks/useConnectorInfo.d.ts.map +1 -1
- package/dist/hooks/useConnectorInfo.js +1 -4
- package/dist/index.js +0 -2
- package/package.json +7 -7
- package/dist/hooks/useConnectorCoinbase.d.ts +0 -9
- package/dist/hooks/useConnectorCoinbase.d.ts.map +0 -1
- package/dist/hooks/useConnectorCoinbase.js +0 -29
- package/dist/hooks/useConnectorLedger.d.ts +0 -9
- package/dist/hooks/useConnectorLedger.d.ts.map +0 -1
- package/dist/hooks/useConnectorLedger.js +0 -36
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InjectedConnector } from '@web3-react/injected-connector';
|
|
3
|
-
import { WalletLinkConnector } from '@web3-react/walletlink-connector';
|
|
4
3
|
import { SafeAppConnector } from '@gnosis.pm/safe-apps-web3-react';
|
|
5
4
|
import { CHAINS } from '@lido-sdk/constants';
|
|
6
|
-
import {
|
|
5
|
+
import { LedgerHQFrameConnector } from '@reef-knot/ledger-connector';
|
|
7
6
|
export interface ConnectorsContextProps {
|
|
8
7
|
defaultChainId: CHAINS;
|
|
9
8
|
rpc: Record<number, string>;
|
|
@@ -12,10 +11,7 @@ export interface ConnectorsContextProps {
|
|
|
12
11
|
}
|
|
13
12
|
export type ConnectorsContextValue = {
|
|
14
13
|
injected: InjectedConnector;
|
|
15
|
-
walletlink: WalletLinkConnector;
|
|
16
|
-
coinbase: WalletLinkConnector;
|
|
17
14
|
ledgerlive: LedgerHQFrameConnector;
|
|
18
|
-
ledger: LedgerHQConnector;
|
|
19
15
|
gnosis?: SafeAppConnector;
|
|
20
16
|
};
|
|
21
17
|
export type Connector = keyof ConnectorsContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/context/connectors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/context/connectors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAIrE,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,EAAE,sBAAsB,CAAC;IACnC,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,iBAAiB,uCAA8C,CAAC;;AAmC7E,wBAAoE"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import React, { memo, createContext, useMemo } from 'react';
|
|
2
2
|
import { InjectedConnector } from '@web3-react/injected-connector';
|
|
3
|
-
import { WalletLinkConnector } from '@web3-react/walletlink-connector';
|
|
4
3
|
import { SafeAppConnector } from '@gnosis.pm/safe-apps-web3-react';
|
|
5
|
-
import { CHAINS } from '@lido-sdk/constants';
|
|
6
4
|
import { useSDK } from '@lido-sdk/react';
|
|
7
|
-
import { LedgerHQFrameConnector
|
|
5
|
+
import { LedgerHQFrameConnector } from '@reef-knot/ledger-connector';
|
|
8
6
|
import { useAutoConnect } from '../hooks/useAutoConnect.js';
|
|
9
7
|
import { CONNECTOR_NAMES } from '../constants/connectors.js';
|
|
10
8
|
|
|
11
9
|
var ConnectorsContext = /*#__PURE__*/createContext({});
|
|
12
10
|
var ProviderConnectors = props => {
|
|
13
|
-
var BASE_URL = typeof window === 'undefined' ? '' : window.location.origin;
|
|
14
|
-
var DEFAULT_LOGO = "".concat(BASE_URL, "/apple-touch-icon.png");
|
|
15
|
-
var DEFAULT_NAME = 'Lido';
|
|
16
11
|
var {
|
|
17
|
-
|
|
18
|
-
children,
|
|
19
|
-
defaultChainId,
|
|
20
|
-
appName = DEFAULT_NAME,
|
|
21
|
-
appLogoUrl = DEFAULT_LOGO
|
|
12
|
+
children
|
|
22
13
|
} = props;
|
|
23
14
|
var {
|
|
24
15
|
supportedChainIds
|
|
@@ -38,26 +29,8 @@ var ProviderConnectors = props => {
|
|
|
38
29
|
})(),
|
|
39
30
|
[CONNECTOR_NAMES.LEDGER_HQ_LIVE]: new LedgerHQFrameConnector({
|
|
40
31
|
supportedChainIds
|
|
41
|
-
}),
|
|
42
|
-
[CONNECTOR_NAMES.LEDGER]: new LedgerHQConnector({
|
|
43
|
-
chainId: defaultChainId,
|
|
44
|
-
url: rpc[defaultChainId]
|
|
45
|
-
}),
|
|
46
|
-
[CONNECTOR_NAMES.COINBASE]: new WalletLinkConnector({
|
|
47
|
-
// only mainnet
|
|
48
|
-
url: rpc[CHAINS.Mainnet],
|
|
49
|
-
supportedChainIds,
|
|
50
|
-
appName,
|
|
51
|
-
appLogoUrl
|
|
52
|
-
}),
|
|
53
|
-
[CONNECTOR_NAMES.WALLET_LINK]: new WalletLinkConnector({
|
|
54
|
-
// only mainnet
|
|
55
|
-
url: rpc[CHAINS.Mainnet],
|
|
56
|
-
supportedChainIds,
|
|
57
|
-
appName,
|
|
58
|
-
appLogoUrl
|
|
59
32
|
})
|
|
60
|
-
}), [
|
|
33
|
+
}), [supportedChainIds]);
|
|
61
34
|
useAutoConnect(connectors);
|
|
62
35
|
return /*#__PURE__*/React.createElement(ConnectorsContext.Provider, {
|
|
63
36
|
value: connectors
|
package/dist/context/web3.js
CHANGED
|
@@ -17,8 +17,8 @@ import '@web3-react/injected-connector';
|
|
|
17
17
|
import '@web3-react/walletlink-connector';
|
|
18
18
|
import '@reef-knot/ledger-connector';
|
|
19
19
|
import '../helpers/ua.js';
|
|
20
|
-
import ProviderConnectors from './connectors.js';
|
|
21
20
|
import 'tiny-warning';
|
|
21
|
+
import ProviderConnectors from './connectors.js';
|
|
22
22
|
|
|
23
23
|
function getLibrary(provider) {
|
|
24
24
|
var library = new Web3Provider(provider);
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from './useAutoConnect';
|
|
2
|
-
export * from './useConnectorCoinbase';
|
|
3
2
|
export * from './useConnectorInfo';
|
|
4
|
-
export * from './useConnectorLedger';
|
|
5
3
|
export * from './useConnectorMetamask';
|
|
6
4
|
export * from './useConnectors';
|
|
7
5
|
export * from './useConnectorStorage';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAUpD,eAAO,MAAM,cAAc,eAAgB,sBAAsB,SAKhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAAgB,sBAAsB,SAuEnE,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,
|
|
1
|
+
{"version":3,"file":"useAutoConnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoConnect.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAUpD,eAAO,MAAM,cAAc,eAAgB,sBAAsB,SAKhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAAgB,sBAAsB,SAuEnE,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,IAQvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAO,IAgB3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,IAexC,CAAC"}
|
|
@@ -92,17 +92,11 @@ var useSaveConnectorToLS = () => {
|
|
|
92
92
|
var {
|
|
93
93
|
isInjected,
|
|
94
94
|
isDappBrowser,
|
|
95
|
-
isCoinbase,
|
|
96
|
-
isLedger,
|
|
97
95
|
isConnectedViaWagmi
|
|
98
96
|
} = useConnectorInfo();
|
|
99
97
|
useEffect(() => {
|
|
100
|
-
if (!isConnectedViaWagmi)
|
|
101
|
-
|
|
102
|
-
if (isCoinbase) return saveConnector('coinbase');
|
|
103
|
-
if (isLedger) return saveConnector('ledger');
|
|
104
|
-
}
|
|
105
|
-
}, [isLedger, isCoinbase, isInjected, isDappBrowser, saveConnector, isConnectedViaWagmi]);
|
|
98
|
+
if (!isConnectedViaWagmi && isInjected && !isDappBrowser) return saveConnector('injected');
|
|
99
|
+
}, [isInjected, isDappBrowser, saveConnector, isConnectedViaWagmi]);
|
|
106
100
|
};
|
|
107
101
|
var useDeleteConnectorFromLS = () => {
|
|
108
102
|
var [, saveConnector] = useConnectorStorage();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectorInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnectorInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useConnectorInfo.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnectorInfo.ts"],"names":[],"mappings":"AAiBA,KAAK,aAAa,GAAG;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,aAkFnC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { useAccount } from 'wagmi';
|
|
|
2
2
|
import { SafeAppConnector } from '@gnosis.pm/safe-apps-web3-react';
|
|
3
3
|
import { InjectedConnector } from '@web3-react/injected-connector';
|
|
4
4
|
import { WalletLinkConnector } from '@web3-react/walletlink-connector';
|
|
5
|
-
import { LedgerHQFrameConnector
|
|
5
|
+
import { LedgerHQFrameConnector } from '@reef-knot/ledger-connector';
|
|
6
6
|
import { useWeb3 } from './useWeb3.js';
|
|
7
7
|
import { PROVIDER_NAMES } from '../constants/connectors.js';
|
|
8
8
|
import { isCoinbaseProvider, isDappBrowserProvider, isMetamaskProvider, isImTokenProvider, isTrustProvider, isXdefiProvider, isZerionProvider } from '../helpers/providerDetectors.js';
|
|
@@ -23,7 +23,6 @@ var useConnectorInfo = () => {
|
|
|
23
23
|
// === WEB3-REACT connectors BEGIN
|
|
24
24
|
var isGnosis = active && connector instanceof SafeAppConnector;
|
|
25
25
|
var isLedgerLive = active && connector instanceof LedgerHQFrameConnector;
|
|
26
|
-
var isLedger = connector instanceof LedgerHQConnector;
|
|
27
26
|
// WalletLink is used by Coinbase, but it can be used by other wallets too.
|
|
28
27
|
var isWalletLink = active && connector instanceof WalletLinkConnector;
|
|
29
28
|
// This detection doesn't work for the connection via QR code scanning.
|
|
@@ -49,7 +48,6 @@ var useConnectorInfo = () => {
|
|
|
49
48
|
// So it is easy for a user to understand which wallet app is being used for connection.
|
|
50
49
|
if (isDappBrowser) return undefined;
|
|
51
50
|
if (isGnosis) return PROVIDER_NAMES.GNOSIS;
|
|
52
|
-
if (isLedger) return PROVIDER_NAMES.LEDGER;
|
|
53
51
|
if (isLedgerLive) return PROVIDER_NAMES.LEDGER_HQ_LIVE;
|
|
54
52
|
if (isImToken) return PROVIDER_NAMES.IM_TOKEN;
|
|
55
53
|
if (isTrust) return PROVIDER_NAMES.TRUST;
|
|
@@ -72,7 +70,6 @@ var useConnectorInfo = () => {
|
|
|
72
70
|
providerName,
|
|
73
71
|
isConnectedViaWagmi,
|
|
74
72
|
isGnosis,
|
|
75
|
-
isLedger,
|
|
76
73
|
isLedgerLive,
|
|
77
74
|
isWalletLink,
|
|
78
75
|
isCoinbase,
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,7 @@ export { CONNECTOR_NAMES, PROVIDER_NAMES } from './constants/connectors.js';
|
|
|
4
4
|
export { default as ProviderWeb3 } from './context/web3.js';
|
|
5
5
|
export { ConnectorsContext, default as ProviderConnectors } from './context/connectors.js';
|
|
6
6
|
export { useAutoConnect, useDeleteConnectorFromLS, useEagerConnector, useSaveConnectorToLS, useWatchConnectorInLS } from './hooks/useAutoConnect.js';
|
|
7
|
-
export { useConnectorCoinbase } from './hooks/useConnectorCoinbase.js';
|
|
8
7
|
export { useConnectorInfo } from './hooks/useConnectorInfo.js';
|
|
9
|
-
export { useConnectorLedger } from './hooks/useConnectorLedger.js';
|
|
10
8
|
export { useConnectorMetamask } from './hooks/useConnectorMetamask.js';
|
|
11
9
|
export { useConnectors } from './hooks/useConnectors.js';
|
|
12
10
|
export { useConnectorStorage } from './hooks/useConnectorStorage.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/web3-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"@lido-sdk/constants": "^3.2.0",
|
|
50
50
|
"@lido-sdk/providers": "^1.4.13",
|
|
51
51
|
"@lido-sdk/react": "^2.0.2",
|
|
52
|
-
"@reef-knot/core-react": "^1.
|
|
53
|
-
"@reef-knot/ledger-connector": "^
|
|
52
|
+
"@reef-knot/core-react": "^1.8.0",
|
|
53
|
+
"@reef-knot/ledger-connector": "^2.0.0",
|
|
54
54
|
"@testing-library/react": "^12.1.5",
|
|
55
55
|
"@testing-library/react-hooks": "^7.0.2",
|
|
56
56
|
"@types/jest": "^29.4.0",
|
|
57
|
-
"@types/react": "
|
|
57
|
+
"@types/react": "18.2.45",
|
|
58
58
|
"@types/ua-parser-js": "^0.7.36",
|
|
59
59
|
"babel-jest": "^29.3.1",
|
|
60
60
|
"babel-loader": "8.2.2",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"eslint-config-custom": "*",
|
|
63
63
|
"jest": "^29.4.3",
|
|
64
64
|
"jest-environment-jsdom": "^29.4.3",
|
|
65
|
-
"react": "
|
|
65
|
+
"react": "18.2.0",
|
|
66
66
|
"ua-parser-js": "1.0.33"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@lido-sdk/providers": "^1.4.13",
|
|
83
83
|
"@lido-sdk/react": "^2.0.2",
|
|
84
84
|
"@reef-knot/core-react": "^1.4.3",
|
|
85
|
-
"@reef-knot/ledger-connector": "^
|
|
86
|
-
"react": ">=
|
|
85
|
+
"@reef-knot/ledger-connector": "^2.0.0",
|
|
86
|
+
"react": ">=18",
|
|
87
87
|
"ua-parser-js": "^1.0.33",
|
|
88
88
|
"wagmi": "^0.12.19"
|
|
89
89
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { WalletLinkConnector } from '@web3-react/walletlink-connector';
|
|
2
|
-
import { ConnectorHookArgs } from './types';
|
|
3
|
-
type Connector = {
|
|
4
|
-
connect: () => Promise<void>;
|
|
5
|
-
connector: WalletLinkConnector;
|
|
6
|
-
};
|
|
7
|
-
export declare const useConnectorCoinbase: (args?: ConnectorHookArgs) => Connector;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=useConnectorCoinbase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectorCoinbase.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnectorCoinbase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS,EAAE,mBAAmB,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAAW,iBAAiB,KAAG,SAa/D,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
|
-
import { useConnectors } from './useConnectors.js';
|
|
4
|
-
import { useForceDisconnect } from './useDisconnect.js';
|
|
5
|
-
import { useWeb3 } from './useWeb3.js';
|
|
6
|
-
|
|
7
|
-
var useConnectorCoinbase = args => {
|
|
8
|
-
var {
|
|
9
|
-
coinbase
|
|
10
|
-
} = useConnectors();
|
|
11
|
-
var {
|
|
12
|
-
activate
|
|
13
|
-
} = useWeb3();
|
|
14
|
-
var {
|
|
15
|
-
disconnect
|
|
16
|
-
} = useForceDisconnect();
|
|
17
|
-
var onConnect = args === null || args === void 0 ? void 0 : args.onConnect;
|
|
18
|
-
var connect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
yield disconnect();
|
|
20
|
-
yield activate(coinbase);
|
|
21
|
-
onConnect === null || onConnect === void 0 ? void 0 : onConnect();
|
|
22
|
-
}), [disconnect, activate, coinbase, onConnect]);
|
|
23
|
-
return {
|
|
24
|
-
connect,
|
|
25
|
-
connector: coinbase
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export { useConnectorCoinbase };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { LedgerHQConnector } from '@reef-knot/ledger-connector';
|
|
2
|
-
import { ConnectorHookArgs } from './types';
|
|
3
|
-
type ConnectorHookResult = {
|
|
4
|
-
connect: () => Promise<void>;
|
|
5
|
-
connector: LedgerHQConnector;
|
|
6
|
-
};
|
|
7
|
-
export declare const useConnectorLedger: (args?: ConnectorHookArgs) => ConnectorHookResult;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=useConnectorLedger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectorLedger.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnectorLedger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,UACtB,iBAAiB,KACvB,mBAyBF,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
|
-
import { useConnectors } from './useConnectors.js';
|
|
4
|
-
import { useForceDisconnect } from './useDisconnect.js';
|
|
5
|
-
import { useWeb3 } from './useWeb3.js';
|
|
6
|
-
|
|
7
|
-
var useConnectorLedger = args => {
|
|
8
|
-
var {
|
|
9
|
-
ledger
|
|
10
|
-
} = useConnectors();
|
|
11
|
-
var {
|
|
12
|
-
activate
|
|
13
|
-
} = useWeb3();
|
|
14
|
-
var {
|
|
15
|
-
disconnect
|
|
16
|
-
} = useForceDisconnect();
|
|
17
|
-
var onConnect = args === null || args === void 0 ? void 0 : args.onConnect;
|
|
18
|
-
var connect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
disconnect();
|
|
20
|
-
// Workaround for an issue when connection does not happen because of
|
|
21
|
-
// Warning: Suppressed stale connector activation [object Object]
|
|
22
|
-
// Reproducible on a stake widget, but not in the reef-knot demo app.
|
|
23
|
-
// This is web3-react related issue, see https://github.com/Uniswap/web3-react/issues/78
|
|
24
|
-
// In our case may happen because `disconnect()` on the upper line is not awaited.
|
|
25
|
-
// Leaving it like this, because web3-react will be removed soon and the code will be rewritten.
|
|
26
|
-
yield new Promise(resolve => setTimeout(resolve, 500));
|
|
27
|
-
yield activate(ledger, () => {}, true);
|
|
28
|
-
onConnect === null || onConnect === void 0 ? void 0 : onConnect();
|
|
29
|
-
}), [activate, disconnect, ledger, onConnect]);
|
|
30
|
-
return {
|
|
31
|
-
connect,
|
|
32
|
-
connector: ledger
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { useConnectorLedger };
|