@reef-knot/web3-react 6.2.4 → 7.0.0-alpha.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.
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/helpers/index.js +11 -1
- package/dist/helpers/interceptLedgerError.js +12 -12
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useSupportedChains.js +17 -21
- package/dist/hooks/useWeb3.js +27 -52
- package/dist/index.js +6 -4
- package/package.json +14 -12
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll };
|
package/dist/helpers/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { LedgerErrorsDict, interceptLedgerError } from "./interceptLedgerError.js";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/index.ts
|
|
5
|
+
var helpers_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
LedgerErrorsDict: () => LedgerErrorsDict,
|
|
7
|
+
interceptLedgerError: () => interceptLedgerError
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { helpers_exports };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region src/helpers/interceptLedgerError.ts
|
|
2
|
+
const LedgerErrorsDict = {
|
|
3
|
+
TransportOpenUserCancelled: "The connection attempt has been rejected.",
|
|
4
|
+
TransportStatusError: "Make sure the device is connected and the Ethereum app is open on the device.",
|
|
5
|
+
InvalidStateError: "Make sure the device is connected and the Ethereum app is open on the device.",
|
|
6
|
+
LockedDeviceError: "The device is locked. Please, unlock it and try again.",
|
|
7
|
+
TransportError: void 0
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return error;
|
|
9
|
+
const interceptLedgerError = (error) => {
|
|
10
|
+
if (Object.hasOwn(LedgerErrorsDict, error.name)) return new Error(LedgerErrorsDict[error.name]);
|
|
11
|
+
return error;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
//#endregion
|
|
15
|
+
export { LedgerErrorsDict, interceptLedgerError };
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { useMemo } from
|
|
2
|
-
import { getNetwork } from
|
|
3
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { getNetwork } from "@ethersproject/providers";
|
|
3
|
+
import { useConfig, useConnection } from "wagmi";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, [chains]);
|
|
18
|
-
return {
|
|
19
|
-
isUnsupported,
|
|
20
|
-
supportedChains
|
|
21
|
-
};
|
|
5
|
+
//#region src/hooks/useSupportedChains.ts
|
|
6
|
+
const useSupportedChains = () => {
|
|
7
|
+
const { chainId } = useConnection();
|
|
8
|
+
const { chains } = useConfig();
|
|
9
|
+
return {
|
|
10
|
+
isUnsupported: useMemo(() => {
|
|
11
|
+
return !chainId || !chains?.find((c) => c.id === chainId);
|
|
12
|
+
}, [chainId, chains]),
|
|
13
|
+
supportedChains: useMemo(() => {
|
|
14
|
+
return chains.map((c) => getNetwork(c.id));
|
|
15
|
+
}, [chains])
|
|
16
|
+
};
|
|
22
17
|
};
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
//#endregion
|
|
20
|
+
export { useSupportedChains };
|
package/dist/hooks/useWeb3.js
CHANGED
|
@@ -1,56 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useSupportedChains } from "./useSupportedChains.js";
|
|
2
|
+
import { useConnect, useConnection } from "wagmi";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
// Because of migration to wagmi library, this method now returns values from wagmi and is left here for backwards compatibility.
|
|
4
|
+
//#region src/hooks/useWeb3.ts
|
|
6
5
|
function useWeb3(_key) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var chainId = isUnsupported ? undefined : wagmiAccount === null || wagmiAccount === void 0 ? void 0 : wagmiAccount.chainId;
|
|
30
|
-
var active = isUnsupported ? false : wagmiAccount === null || wagmiAccount === void 0 ? void 0 : wagmiAccount.isConnected;
|
|
31
|
-
// wagmi error can be null, but historically we need `Error | undefined` here
|
|
32
|
-
var error = wagmiError || undefined;
|
|
33
|
-
return {
|
|
34
|
-
chainId,
|
|
35
|
-
account,
|
|
36
|
-
active,
|
|
37
|
-
error,
|
|
38
|
-
// Web3Provider from ethers.js, we pass it to Web3ReactProvider via getLibrary()
|
|
39
|
-
library: undefined,
|
|
40
|
-
// AbstractConnector from @web3-react, used by @reef-knot/web3-react only for
|
|
41
|
-
// useDisconnect, useConnectorInfo and useSupportedChains
|
|
42
|
-
connector: undefined,
|
|
43
|
-
activate: () => {
|
|
44
|
-
console.error('"activate" method is deprecated and does nothing.');
|
|
45
|
-
return Promise.resolve();
|
|
46
|
-
},
|
|
47
|
-
setError: () => {
|
|
48
|
-
console.error('"setError" method is deprecated and does nothing.');
|
|
49
|
-
},
|
|
50
|
-
deactivate: () => {
|
|
51
|
-
console.error('"deactivate" method is deprecated and does nothing.');
|
|
52
|
-
}
|
|
53
|
-
};
|
|
6
|
+
const wagmiAccount = useConnection();
|
|
7
|
+
const { error: wagmiError } = useConnect();
|
|
8
|
+
const account = wagmiAccount?.address;
|
|
9
|
+
const { isUnsupported } = useSupportedChains();
|
|
10
|
+
return {
|
|
11
|
+
chainId: isUnsupported ? void 0 : wagmiAccount?.chainId,
|
|
12
|
+
account,
|
|
13
|
+
active: isUnsupported ? false : wagmiAccount?.isConnected,
|
|
14
|
+
error: wagmiError || void 0,
|
|
15
|
+
library: void 0,
|
|
16
|
+
connector: void 0,
|
|
17
|
+
activate: () => {
|
|
18
|
+
console.error("\"activate\" method is deprecated and does nothing.");
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
},
|
|
21
|
+
setError: () => {
|
|
22
|
+
console.error("\"setError\" method is deprecated and does nothing.");
|
|
23
|
+
},
|
|
24
|
+
deactivate: () => {
|
|
25
|
+
console.error("\"deactivate\" method is deprecated and does nothing.");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
54
28
|
}
|
|
55
29
|
|
|
56
|
-
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useWeb3 };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { useSupportedChains } from "./hooks/useSupportedChains.js";
|
|
2
|
+
import { useWeb3 } from "./hooks/useWeb3.js";
|
|
3
|
+
import "./hooks/index.js";
|
|
4
|
+
import { helpers_exports } from "./helpers/index.js";
|
|
5
|
+
|
|
6
|
+
export { helpers_exports as helpers, useSupportedChains, useWeb3 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/web3-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"homepage": "https://github.com/lidofinance/reef-knot",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/lidofinance/reef-knot.git",
|
|
24
|
+
"url": "git+https://github.com/lidofinance/reef-knot.git",
|
|
25
25
|
"directory": "packages/web3-react"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"dev": "
|
|
37
|
-
"lint": "eslint --ext ts,tsx,js,mjs ."
|
|
35
|
+
"build": "yarn run -T tsdown",
|
|
36
|
+
"dev": "yarn run -T tsdown --watch",
|
|
37
|
+
"lint": "eslint --ext ts,tsx,js,mjs .",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@babel/cli": "7.19.3",
|
|
@@ -46,14 +47,15 @@
|
|
|
46
47
|
"@babel/preset-react": "7.18.6",
|
|
47
48
|
"@babel/preset-typescript": "7.18.6",
|
|
48
49
|
"@ethersproject/providers": "^5.7.2",
|
|
49
|
-
"@reef-knot/core-react": "
|
|
50
|
-
"@reef-knot/ledger-connector": "
|
|
51
|
-
"@reef-knot/wallets-helpers": "
|
|
50
|
+
"@reef-knot/core-react": "7.0.0-alpha.2",
|
|
51
|
+
"@reef-knot/ledger-connector": "5.0.0-alpha.1",
|
|
52
|
+
"@reef-knot/wallets-helpers": "3.0.0-alpha.2",
|
|
52
53
|
"@testing-library/react": "^12.1.5",
|
|
53
54
|
"@testing-library/react-hooks": "^7.0.2",
|
|
54
55
|
"@types/react": "18.2.45",
|
|
55
56
|
"babel-loader": "8.2.2",
|
|
56
57
|
"babel-plugin-styled-components": "1.13.2",
|
|
58
|
+
"build-config": "*",
|
|
57
59
|
"eslint-config-custom": "*",
|
|
58
60
|
"react": "18.2.0"
|
|
59
61
|
},
|
|
@@ -62,11 +64,11 @@
|
|
|
62
64
|
},
|
|
63
65
|
"peerDependencies": {
|
|
64
66
|
"@ethersproject/providers": "5",
|
|
65
|
-
"@reef-knot/core-react": "
|
|
66
|
-
"@reef-knot/ledger-connector": "
|
|
67
|
-
"@reef-knot/wallets-helpers": "
|
|
67
|
+
"@reef-knot/core-react": "7.0.0-alpha.2",
|
|
68
|
+
"@reef-knot/ledger-connector": "5.0.0-alpha.1",
|
|
69
|
+
"@reef-knot/wallets-helpers": "3.0.0-alpha.2",
|
|
68
70
|
"@tanstack/react-query": "^5.29.0",
|
|
69
71
|
"react": ">=18",
|
|
70
|
-
"wagmi": ">=
|
|
72
|
+
"wagmi": ">=3.3"
|
|
71
73
|
}
|
|
72
74
|
}
|