@reef-knot/core-react 1.3.0 → 1.4.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.
@@ -1,7 +1,11 @@
1
1
  import React, { FC } from 'react';
2
2
  import { WalletAdapterData } from '@reef-knot/types';
3
+ import { Chain } from 'wagmi/chains';
3
4
  export interface ReefKnotContextProps {
4
5
  rpc: Record<number, string>;
6
+ walletconnectProjectId?: string;
7
+ chains: Chain[];
8
+ defaultChain?: Chain;
5
9
  }
6
10
  export type ReefKnotContextValue = {
7
11
  rpc: Record<number, string>;
@@ -1 +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"}
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;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAGrC,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;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,CAwB7C,CAAC"}
@@ -1,22 +1,27 @@
1
1
  import React, { createContext, useMemo } from 'react';
2
- import { WalletsListEthereum } from '@reef-knot/wallets-list';
2
+ import { getWalletDataList } from '../walletData/index.js';
3
3
 
4
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
- }));
5
+ const ReefKnot = ({
6
+ rpc,
7
+ walletconnectProjectId,
8
+ chains,
9
+ defaultChain,
10
+ children
11
+ }) => {
12
+ const walletDataList = getWalletDataList({
13
+ rpc,
14
+ walletconnectProjectId,
15
+ chains,
16
+ defaultChain
17
+ });
13
18
  const contextValue = useMemo(() => ({
14
19
  rpc,
15
20
  walletDataList
16
21
  }), [rpc, walletDataList]);
17
22
  return React.createElement(ReefKnotContext.Provider, {
18
23
  value: contextValue
19
- }, props.children);
24
+ }, children);
20
25
  };
21
26
 
22
27
  export { ReefKnot, ReefKnotContext };
@@ -1 +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"}
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,oBACT,CAAC"}
@@ -1,8 +1,6 @@
1
1
  import { useContext } from 'react';
2
2
  import { ReefKnotContext } from '../context/index.js';
3
3
 
4
- const useReefKnotContext = () => {
5
- return useContext(ReefKnotContext);
6
- };
4
+ const useReefKnotContext = () => useContext(ReefKnotContext);
7
5
 
8
6
  export { useReefKnotContext };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { getConnectors } from './walletData/getConnectors.js';
1
+ export { getConnectors, getWalletDataList } from './walletData/index.js';
2
2
  export { ReefKnot, ReefKnotContext } from './context/index.js';
3
3
  export { useReefKnotContext } from './hooks/useReefKnotContext.js';
@@ -1,2 +1,11 @@
1
- export * from './getConnectors';
1
+ import { WalletAdapterData } from '@reef-knot/types';
2
+ import type { Chain } from 'wagmi/chains';
3
+ export interface GetConnectorsArgs {
4
+ rpc?: Record<number, string>;
5
+ walletconnectProjectId?: string;
6
+ chains: Chain[];
7
+ defaultChain?: Chain;
8
+ }
9
+ export declare const getWalletDataList: ({ rpc, walletconnectProjectId, chains, defaultChain, }: GetConnectorsArgs) => WalletAdapterData[];
10
+ export declare const getConnectors: (args: GetConnectorsArgs) => import("@wagmi/connectors/dist/base-84a689bb").C<any, any, any>[];
2
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletData/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletData/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;AAED,eAAO,MAAM,iBAAiB,2DAK3B,iBAAiB,wBAenB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,iBAAiB,sEAEpD,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { WalletsListEthereum } from '@reef-knot/wallets-list';
2
+
3
+ let walletDataList;
4
+ const getWalletDataList = ({
5
+ rpc,
6
+ walletconnectProjectId,
7
+ chains,
8
+ defaultChain
9
+ }) => {
10
+ const walletAdapters = Object.values(WalletsListEthereum);
11
+ if (!walletDataList) {
12
+ // Sorting supported chains, so the default chain is always first in the array
13
+ // Have to do this because WalletConnect v2 via wagmi always tries to connect
14
+ // to the first chain in the chains array
15
+ const sortedChains = defaultChain ? chains.sort(chain => chain.id === defaultChain.id ? -1 : 1) : chains;
16
+ walletDataList = walletAdapters.map(walletAdapter => walletAdapter({
17
+ rpc,
18
+ walletconnectProjectId,
19
+ chains: sortedChains
20
+ }));
21
+ }
22
+ return walletDataList;
23
+ };
24
+ const getConnectors = args => {
25
+ return getWalletDataList(args).map(({
26
+ connector
27
+ }) => connector);
28
+ };
29
+
30
+ export { getConnectors, getWalletDataList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/core-react",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -38,14 +38,14 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "react": "17.0.2",
41
- "wagmi": "^0.12.12",
42
- "@reef-knot/wallets-list": "^1.3.0",
43
- "@reef-knot/types": "^1.1.0"
41
+ "wagmi": "^0.12.16",
42
+ "@reef-knot/wallets-list": "^1.4.0",
43
+ "@reef-knot/types": "^1.2.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": ">=17",
47
- "wagmi": "^0.12.12",
48
- "@reef-knot/wallets-list": "^2.0.0",
49
- "@reef-knot/types": "^1.1.0"
47
+ "wagmi": "^0.12.16",
48
+ "@reef-knot/wallets-list": "^1.4.0",
49
+ "@reef-knot/types": "^1.2.0"
50
50
  }
51
51
  }
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,14 +0,0 @@
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 };