@reef-knot/web3-react 1.5.0 → 1.6.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/helpers/index.d.ts +1 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/interceptLedgerError.d.ts +2 -4
- package/dist/helpers/interceptLedgerError.d.ts.map +1 -1
- package/dist/helpers/interceptLedgerError.js +7 -7
- package/dist/hooks/useConnectorError.js +2 -2
- package/dist/hooks/useConnectorLedger.d.ts.map +1 -1
- package/dist/hooks/useConnectorLedger.js +9 -2
- package/package.json +2 -2
package/dist/helpers/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export * from './providerDetectors';
|
|
|
2
2
|
export * from './ua';
|
|
3
3
|
export * from './openWindow';
|
|
4
4
|
export { default as isUrl } from './isUrl';
|
|
5
|
-
export
|
|
5
|
+
export * from './interceptLedgerError';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,MAAM,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,MAAM,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,wBAAwB,CAAC"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export { hasInjected, isBraveWalletProvider, isCoin98Provider, isCoinbaseProvide
|
|
|
2
2
|
export { browser, checkIfBraveBrowser, device, isAndroid, isEdge, isFirefox, isIOS, isMobile, isMobileOrTablet, isTablet, os } from './ua.js';
|
|
3
3
|
export { openWindow } from './openWindow.js';
|
|
4
4
|
export { default as isUrl } from './isUrl.js';
|
|
5
|
-
export {
|
|
5
|
+
export { LedgerErrorsDict, interceptLedgerError } from './interceptLedgerError.js';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
};
|
|
4
|
-
export default function (error?: Error): Error | undefined;
|
|
1
|
+
export declare const LedgerErrorsDict: Record<string, string | undefined>;
|
|
2
|
+
export declare const interceptLedgerError: (error: Error) => Error;
|
|
5
3
|
//# sourceMappingURL=interceptLedgerError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptLedgerError.d.ts","sourceRoot":"","sources":["../../src/helpers/interceptLedgerError.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"interceptLedgerError.d.ts","sourceRoot":"","sources":["../../src/helpers/interceptLedgerError.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAQ/D,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAAW,KAAK,UAMhD,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
1
|
+
var LedgerErrorsDict = {
|
|
2
2
|
TransportOpenUserCancelled: 'The connection attempt has been rejected.',
|
|
3
3
|
TransportStatusError: 'Make sure the device is connected and the Ethereum app is open on the device.',
|
|
4
4
|
InvalidStateError: 'Make sure the device is connected and the Ethereum app is open on the device.',
|
|
5
|
+
LockedDeviceError: 'The device is locked. Please, unlock it and try again.',
|
|
5
6
|
TransportError: undefined
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
return new Error(errorDict[error.name]);
|
|
8
|
+
var interceptLedgerError = error => {
|
|
9
|
+
if (Object.hasOwn(LedgerErrorsDict, error.name)) {
|
|
10
|
+
return new Error(LedgerErrorsDict[error.name]);
|
|
11
11
|
}
|
|
12
12
|
return error;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { LedgerErrorsDict, interceptLedgerError };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useWeb3 } from './useWeb3.js';
|
|
2
2
|
import '../helpers/ua.js';
|
|
3
|
-
import interceptLedgerError from '../helpers/interceptLedgerError.js';
|
|
3
|
+
import { interceptLedgerError } from '../helpers/interceptLedgerError.js';
|
|
4
4
|
import { useConnectorInfo } from './useConnectorInfo.js';
|
|
5
5
|
|
|
6
6
|
var useConnectorError = () => {
|
|
@@ -11,7 +11,7 @@ var useConnectorError = () => {
|
|
|
11
11
|
isLedger
|
|
12
12
|
} = useConnectorInfo();
|
|
13
13
|
if (!error) {
|
|
14
|
-
return
|
|
14
|
+
return;
|
|
15
15
|
}
|
|
16
16
|
if (isLedger) {
|
|
17
17
|
return interceptLedgerError(error);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -16,8 +16,15 @@ var useConnectorLedger = args => {
|
|
|
16
16
|
} = useForceDisconnect();
|
|
17
17
|
var onConnect = args === null || args === void 0 ? void 0 : args.onConnect;
|
|
18
18
|
var connect = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
|
|
20
|
-
|
|
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);
|
|
21
28
|
onConnect === null || onConnect === void 0 ? void 0 : onConnect();
|
|
22
29
|
}), [activate, disconnect, ledger, onConnect]);
|
|
23
30
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/web3-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@lido-sdk/providers": "^1.4.13",
|
|
51
51
|
"@lido-sdk/react": "^2.0.2",
|
|
52
52
|
"@reef-knot/core-react": "^1.5.1",
|
|
53
|
-
"@reef-knot/ledger-connector": "^1.
|
|
53
|
+
"@reef-knot/ledger-connector": "^1.1.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",
|