@reef-knot/web3-react 6.2.4 → 7.0.0-alpha.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.
@@ -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 };
@@ -1 +1,11 @@
1
- export { LedgerErrorsDict, interceptLedgerError } from './interceptLedgerError.js';
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
- var LedgerErrorsDict = {
2
- TransportOpenUserCancelled: 'The connection attempt has been rejected.',
3
- TransportStatusError: 'Make sure the device is connected and the Ethereum app is open on the device.',
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.',
6
- TransportError: undefined
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
- var interceptLedgerError = error => {
9
- if (Object.hasOwn(LedgerErrorsDict, error.name)) {
10
- return new Error(LedgerErrorsDict[error.name]);
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
- export { LedgerErrorsDict, interceptLedgerError };
14
+ //#endregion
15
+ export { LedgerErrorsDict, interceptLedgerError };
@@ -0,0 +1,2 @@
1
+ import { useSupportedChains } from "./useSupportedChains.js";
2
+ import { useWeb3 } from "./useWeb3.js";
@@ -1,24 +1,20 @@
1
- import { useMemo } from 'react';
2
- import { getNetwork } from '@ethersproject/providers';
3
- import { useAccount, useConfig } from 'wagmi';
1
+ import { useMemo } from "react";
2
+ import { getNetwork } from "@ethersproject/providers";
3
+ import { useConfig, useConnection } from "wagmi";
4
4
 
5
- var useSupportedChains = () => {
6
- var {
7
- chainId
8
- } = useAccount();
9
- var {
10
- chains
11
- } = useConfig();
12
- var isUnsupported = useMemo(() => {
13
- return !chainId || !(chains === null || chains === void 0 ? void 0 : chains.find(c => c.id === chainId));
14
- }, [chainId, chains]);
15
- var supportedChains = useMemo(() => {
16
- return chains.map(c => getNetwork(c.id));
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
- export { useSupportedChains };
19
+ //#endregion
20
+ export { useSupportedChains };
@@ -1,56 +1,31 @@
1
- import { useAccount, useConnect } from 'wagmi';
2
- import { useSupportedChains } from './useSupportedChains.js';
1
+ import { useSupportedChains } from "./useSupportedChains.js";
2
+ import { useConnect, useConnection } from "wagmi";
3
3
 
4
- // This is a legacy hook for getting data and methods from web3-react library.
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
- var wagmiAccount = useAccount();
8
- var {
9
- error: wagmiError
10
- } = useConnect();
11
- var account = wagmiAccount === null || wagmiAccount === void 0 ? void 0 : wagmiAccount.address;
12
- // web3-react and wagmi have different logic around unsupported chains.
13
- // If a chain is not supported:
14
- // web3-react sets:
15
- // `chainId` === undefined
16
- // `error` === UnsupportedChainIdError
17
- // `active` === false
18
- // wagmi sets:
19
- // `chain.id` === actual value from wallet
20
- // `chain.unsupported` === true
21
- // `error` === null
22
- // `isConnected` === true (connects via default chain)
23
- // These differences break our widgets, because the widgets don't expect
24
- // chainId to be unsupported, they expect chainId === undefined in that case.
25
- // Making wagmi's logic to be the same as web3-react here, except setting an error:
26
- var {
27
- isUnsupported
28
- } = useSupportedChains();
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
- export { useWeb3 };
30
+ //#endregion
31
+ export { useWeb3 };
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
- export { useSupportedChains } from './hooks/useSupportedChains.js';
2
- export { useWeb3 } from './hooks/useWeb3.js';
3
- import * as index from './helpers/index.js';
4
- export { index as helpers };
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": "6.2.4",
3
+ "version": "7.0.0-alpha.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -32,9 +32,10 @@
32
32
  "access": "public"
33
33
  },
34
34
  "scripts": {
35
- "build": "rollup -c",
36
- "dev": "dev=on rollup -c -w",
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": "6.2.4",
50
- "@reef-knot/ledger-connector": "4.5.0",
51
- "@reef-knot/wallets-helpers": "2.3.0",
50
+ "@reef-knot/core-react": "6.2.0-alpha.6",
51
+ "@reef-knot/ledger-connector": "4.4.0-alpha.5",
52
+ "@reef-knot/wallets-helpers": "2.3.0-alpha.3",
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": "6.2.4",
66
- "@reef-knot/ledger-connector": "4.5.0",
67
- "@reef-knot/wallets-helpers": "2.3.0",
67
+ "@reef-knot/core-react": "6.2.0-alpha.6",
68
+ "@reef-knot/ledger-connector": "4.4.0-alpha.5",
69
+ "@reef-knot/wallets-helpers": "2.3.0-alpha.3",
68
70
  "@tanstack/react-query": "^5.29.0",
69
71
  "react": ">=18",
70
- "wagmi": ">=2.14"
72
+ "wagmi": ">=3.3"
71
73
  }
72
74
  }