@reef-knot/core-react 1.1.1 → 1.3.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.
@@ -0,0 +1,12 @@
1
+ import React, { FC } from 'react';
2
+ import { WalletAdapterData } from '@reef-knot/types';
3
+ export interface ReefKnotContextProps {
4
+ rpc: Record<number, string>;
5
+ }
6
+ export type ReefKnotContextValue = {
7
+ rpc: Record<number, string>;
8
+ walletDataList: WalletAdapterData[];
9
+ };
10
+ export declare const ReefKnotContext: React.Context<ReefKnotContextValue>;
11
+ export declare const ReefKnot: FC<ReefKnotContextProps>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,EAAE,EAAW,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,cAAc,EAAE,iBAAiB,EAAE,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,eAAe,qCAA4C,CAAC;AAEzE,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAkB7C,CAAC"}
@@ -0,0 +1,22 @@
1
+ import React, { createContext, useMemo } from 'react';
2
+ import { WalletsListEthereum } from '@reef-knot/wallets-list';
3
+
4
+ const ReefKnotContext = createContext({});
5
+ const ReefKnot = props => {
6
+ const {
7
+ rpc
8
+ } = props;
9
+ const walletAdapters = Object.values(WalletsListEthereum);
10
+ const walletDataList = walletAdapters.map(walletAdapter => walletAdapter({
11
+ rpc
12
+ }));
13
+ const contextValue = useMemo(() => ({
14
+ rpc,
15
+ walletDataList
16
+ }), [rpc, walletDataList]);
17
+ return React.createElement(ReefKnotContext.Provider, {
18
+ value: contextValue
19
+ }, props.children);
20
+ };
21
+
22
+ export { ReefKnot, ReefKnotContext };
@@ -0,0 +1,2 @@
1
+ export * from './useReefKnotContext';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ReefKnotContextValue } from '../context';
2
+ export declare const useReefKnotContext: () => ReefKnotContextValue;
3
+ //# sourceMappingURL=useReefKnotContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReefKnotContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useReefKnotContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEnE,eAAO,MAAM,kBAAkB,QAAO,oBAErC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import { ReefKnotContext } from '../context/index.js';
3
+
4
+ const useReefKnotContext = () => {
5
+ return useContext(ReefKnotContext);
6
+ };
7
+
8
+ export { useReefKnotContext };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './walletData';
2
- export * from './utils';
2
+ export * from './context';
3
+ export * from './hooks';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { getConnectors, walletAdapters, walletDataList } from './walletData/index.js';
2
- export { isValidHttpUrl } from './utils/isValidHttpUrl.js';
3
- export { createConnectorsWalletConnect } from './walletData/connectorsWalletConnect.js';
1
+ export { getConnectors } from './walletData/getConnectors.js';
2
+ export { ReefKnot, ReefKnotContext } from './context/index.js';
3
+ export { useReefKnotContext } from './hooks/useReefKnotContext.js';
@@ -0,0 +1,4 @@
1
+ export declare const getConnectors: ({ rpc }: {
2
+ rpc: Record<number, string>;
3
+ }) => import("@wagmi/connectors/dist/base-84a689bb").C<any, any, any>[];
4
+ //# sourceMappingURL=getConnectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConnectors.d.ts","sourceRoot":"","sources":["../../src/walletData/getConnectors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;SAAoB,OAAO,MAAM,EAAE,MAAM,CAAC;uEAWnE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { WalletsListEthereum } from '@reef-knot/wallets-list';
2
+
3
+ const getConnectors = ({
4
+ rpc
5
+ }) => {
6
+ const walletAdapters = Object.values(WalletsListEthereum);
7
+ const walletDataList = walletAdapters.map(walletAdapter => walletAdapter({
8
+ rpc
9
+ }));
10
+ const connectors = [...walletDataList].map(walletData => walletData.connector);
11
+ return connectors;
12
+ };
13
+
14
+ export { getConnectors };
@@ -1,8 +1,2 @@
1
- import { Connector } from 'wagmi';
2
- export * from './connectorsWalletConnect';
3
- export declare const walletAdapters: import("@reef-knot/types").WalletAdapterType[];
4
- export declare const walletDataList: import("@reef-knot/types").WalletAdapterData[];
5
- export declare const getConnectors: ({ rpc }: {
6
- rpc: Record<number, string>;
7
- }) => Connector<any, any, any>[];
1
+ export * from './getConnectors';
8
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletData/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,cAAc,2BAA2B,CAAC;AAE1C,eAAO,MAAM,cAAc,gDAAqC,CAAC;AACjE,eAAO,MAAM,cAAc,gDAE1B,CAAC;AAEF,eAAO,MAAM,aAAa;SAAoB,OAAO,MAAM,EAAE,MAAM,CAAC;gCAOnE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletData/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/core-react",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -38,12 +38,14 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "react": "17.0.2",
41
- "wagmi": "^0.11.7",
42
- "@reef-knot/wallets-list": "^1.1.0"
41
+ "wagmi": "^0.12.12",
42
+ "@reef-knot/wallets-list": "^1.3.0",
43
+ "@reef-knot/types": "^1.1.0"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "react": ">=17",
46
- "wagmi": "^0.11.7",
47
- "@reef-knot/wallets-list": "^1.1.0"
47
+ "wagmi": "^0.12.12",
48
+ "@reef-knot/wallets-list": "^2.0.0",
49
+ "@reef-knot/types": "^1.1.0"
48
50
  }
49
51
  }
@@ -1,2 +0,0 @@
1
- export * from './isValidHttpUrl';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const isValidHttpUrl: (string: string) => boolean;
2
- //# sourceMappingURL=isValidHttpUrl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isValidHttpUrl.d.ts","sourceRoot":"","sources":["../../src/utils/isValidHttpUrl.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,WAAY,MAAM,YAQ5C,CAAC"}
@@ -1,11 +0,0 @@
1
- const isValidHttpUrl = string => {
2
- let url;
3
- try {
4
- url = new URL(string);
5
- } catch (_) {
6
- return false;
7
- }
8
- return url.protocol === 'http:' || url.protocol === 'https:';
9
- };
10
-
11
- export { isValidHttpUrl };
@@ -1,8 +0,0 @@
1
- import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
2
- export type RKConnectorWalletConnect = WalletConnectConnector & {
3
- _reefknot_id: string;
4
- };
5
- export declare const createConnectorsWalletConnect: ({ rpc, }: {
6
- rpc: Record<number, string>;
7
- }) => WalletConnectConnector[];
8
- //# sourceMappingURL=connectorsWalletConnect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connectorsWalletConnect.d.ts","sourceRoot":"","sources":["../../src/walletData/connectorsWalletConnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAOxE,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,GAAG;IAC9D,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,6BAA6B;SAGnC,OAAO,MAAM,EAAE,MAAM,CAAC;8BAoD5B,CAAC"}
@@ -1,48 +0,0 @@
1
- import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
2
- import { isValidHttpUrl } from '../utils/isValidHttpUrl.js';
3
- import { walletConnectMobileLinks } from './walletConnectMobileLinks.js';
4
-
5
- const createConnectorsWalletConnect = ({
6
- rpc
7
- }) => {
8
- const BASE_URL = typeof window === 'undefined' ? '' : window.location.origin;
9
- // adds BASE_URL to `rpc` object's string values
10
- const walletConnectRPC = Object.entries(rpc).reduce((result, [key, value]) => Object.assign(Object.assign({}, result), {
11
- [key]: isValidHttpUrl(value) ? value : BASE_URL + value
12
- }), {});
13
- const connectors = {
14
- WalletConnect: new WalletConnectConnector({
15
- options: {
16
- rpc: walletConnectRPC,
17
- qrcodeModalOptions: {
18
- mobileLinks: walletConnectMobileLinks,
19
- desktopLinks: []
20
- }
21
- }
22
- }),
23
- WalletConnectNoLinks: new WalletConnectConnector({
24
- options: {
25
- rpc: walletConnectRPC,
26
- qrcodeModalOptions: {
27
- mobileLinks: [],
28
- desktopLinks: []
29
- }
30
- }
31
- }),
32
- WalletConnectURI: new WalletConnectConnector({
33
- options: {
34
- rpc: walletConnectRPC,
35
- qrcode: false
36
- }
37
- })
38
- };
39
- // Temporary solution:
40
- // give connectors different ids, so we can choose between them later
41
- // TODO: rework with custom connector classes extending original connector
42
- connectors.WalletConnect._reefknot_id = 'WalletConnect';
43
- connectors.WalletConnectNoLinks._reefknot_id = 'WalletConnectNoLinks';
44
- connectors.WalletConnectURI._reefknot_id = 'WalletConnectURI';
45
- return Object.values(connectors);
46
- };
47
-
48
- export { createConnectorsWalletConnect };
@@ -1,16 +0,0 @@
1
- import { WalletsListEthereum } from '@reef-knot/wallets-list';
2
- import { createConnectorsWalletConnect } from './connectorsWalletConnect.js';
3
-
4
- const walletAdapters = Object.values(WalletsListEthereum);
5
- const walletDataList = walletAdapters.map(walletAdapter => walletAdapter());
6
- const getConnectors = ({
7
- rpc
8
- }) => {
9
- const connectors = [...walletDataList].map(walletData => walletData.connector);
10
- const connectorsWC = createConnectorsWalletConnect({
11
- rpc
12
- });
13
- return [...connectorsWC, ...connectors];
14
- };
15
-
16
- export { createConnectorsWalletConnect, getConnectors, walletAdapters, walletDataList };
@@ -1,2 +0,0 @@
1
- export declare const walletConnectMobileLinks: string[];
2
- //# sourceMappingURL=walletConnectMobileLinks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"walletConnectMobileLinks.d.ts","sourceRoot":"","sources":["../../src/walletData/walletConnectMobileLinks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,UA4CpC,CAAC"}
@@ -1,3 +0,0 @@
1
- const walletConnectMobileLinks = ['MetaMask', 'Trust Wallet', 'Zerion', 'imToken', 'Robinhood Wallet', 'Rainbow', 'Ledger Live', 'Uniswap Wallet', '1inch Wallet', 'Safe', 'Ambire Wallet', 'Unstoppable Domains', 'Argent', 'Omni', 'MathWallet', 'TokenPocket', 'iToken Wallet', 'Atomic', 'Coin98', 'CoolWallet', 'Unstoppable Wallet', 'Infinity Wallet', 'Crypto.com | DeFi Wallet', 'Guarda Wallet', 'Trustee Wallet', 'Rabby', 'Tangem', 'Coinbase Wallet', 'Frame', 'Blockchain.com', 'Exodus', 'ZenGo', 'XDEFI Wallet', 'Frontier', 'OKX Wallet', 'Brave Wallet', 'Binance DeFi Wallet', 'Fireblocks', 'Phantom', 'MEW wallet', 'GameStop Wallet', 'Opera Crypto Browser', 'Taho'];
2
-
3
- export { walletConnectMobileLinks };