@reef-knot/wallets-helpers 1.1.6 → 2.0.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.
@@ -1,8 +1,28 @@
1
- import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
2
- import { Chain } from 'wagmi/chains';
3
- export declare const getWalletConnectConnector: ({ projectId, qrcode, chains, }: {
4
- projectId?: string | undefined;
5
- qrcode?: boolean | undefined;
6
- chains: Chain[];
7
- }) => WalletConnectConnector;
1
+ export declare function getWalletConnectConnector({ projectId, qrcode, }: {
2
+ projectId?: string;
3
+ qrcode?: boolean;
4
+ }): import("wagmi").CreateConnectorFn<import("@walletconnect/ethereum-provider").default, {
5
+ connect(parameters?: {
6
+ chainId?: number | undefined;
7
+ pairingTopic?: string | undefined;
8
+ } | undefined): Promise<{
9
+ accounts: readonly `0x${string}`[];
10
+ chainId: number;
11
+ }>;
12
+ getNamespaceChainsIds(): number[];
13
+ getRequestedChainsIds(): Promise<number[]>;
14
+ isChainsStale(): Promise<boolean>;
15
+ onConnect(connectInfo: import("viem").ProviderConnectInfo): void;
16
+ onDisplayUri(uri: string): void;
17
+ onSessionDelete(data: {
18
+ topic: string;
19
+ }): void;
20
+ setRequestedChainsIds(chains: number[]): void;
21
+ requestedChainsStorageKey: `${string}.requestedChains`;
22
+ }, {
23
+ [x: `${string}.requestedChains`]: number[];
24
+ }>;
25
+ export declare namespace getWalletConnectConnector {
26
+ var type: "walletConnect";
27
+ }
8
28
  //# sourceMappingURL=getWalletConnectConnector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWalletConnectConnector.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAKrC,eAAO,MAAM,yBAAyB;;;YAO5B,KAAK,EAAE;4BAmChB,CAAC"}
1
+ {"version":3,"file":"getWalletConnectConnector.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectConnector.ts"],"names":[],"mappings":"AAYA,wBAAgB,yBAAyB,CAAC,EACxC,SAAc,EACd,MAAa,GACd,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;;;;;;;;;;;;;;;;;;;;GAkBA;yBAxBe,yBAAyB"}
@@ -1,40 +1,27 @@
1
- import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
1
+ import { walletConnect } from 'wagmi/connectors';
2
2
 
3
- let walletconnectConnector;
4
- let walletconnectConnectorNoQR;
5
- const getWalletConnectConnector = ({
3
+ const cache = {};
4
+ const memoize = (key, getter) => {
5
+ if (!cache[key]) cache[key] = getter();
6
+ return cache[key];
7
+ };
8
+ getWalletConnectConnector.type = walletConnect.type;
9
+ function getWalletConnectConnector({
6
10
  projectId = '',
7
- qrcode = true,
8
- chains
9
- }) => {
11
+ qrcode = true
12
+ }) {
10
13
  if (!projectId) {
11
14
  console.warn('No WalletConnect Project ID found, it is required by WalletConnect v2: https://docs.walletconnect.com/2.0/cloud/relay#project-id');
12
15
  }
13
- const params = {
14
- chains,
15
- options: {
16
- projectId,
17
- showQrModal: qrcode,
18
- qrModalOptions: {
19
- themeVariables: {
20
- '--w3m-z-index': '1000',
21
- // walletconnect suddenly renamed w3m to wcm in @walletconnect/modal v2.5
22
- // It is a breaking change in a minor version update. So now I have to support both options here
23
- '--wcm-z-index': '1000'
24
- }
16
+ return memoize(qrcode ? 'qrcode' : 'no-qrcode', () => walletConnect({
17
+ projectId,
18
+ showQrModal: qrcode,
19
+ qrModalOptions: {
20
+ themeVariables: {
21
+ '--wcm-z-index': '1000'
25
22
  }
26
23
  }
27
- };
28
- if (!qrcode) {
29
- if (!walletconnectConnectorNoQR) {
30
- walletconnectConnectorNoQR = new WalletConnectConnector(params);
31
- }
32
- return walletconnectConnectorNoQR;
33
- }
34
- if (!walletconnectConnector) {
35
- walletconnectConnector = new WalletConnectConnector(params);
36
- }
37
- return walletconnectConnector;
38
- };
24
+ }));
25
+ }
39
26
 
40
27
  export { getWalletConnectConnector };
@@ -1,3 +1,3 @@
1
- import type { Connector } from 'wagmi/connectors';
1
+ import type { Connector } from 'wagmi';
2
2
  export declare const getWalletConnectUri: (connector: Connector) => Promise<string>;
3
3
  //# sourceMappingURL=getWalletConnectUri.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWalletConnectUri.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectUri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,eAAO,MAAM,mBAAmB,cAAqB,SAAS,oBAK7D,CAAC"}
1
+ {"version":3,"file":"getWalletConnectUri.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectUri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,eAAO,MAAM,mBAAmB,cAAqB,SAAS,oBAM7D,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
2
 
3
3
  const getWalletConnectUri = connector => __awaiter(void 0, void 0, void 0, function* () {
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
5
  const provider = yield connector.getProvider();
5
6
  return new Promise(resolve => {
6
7
  provider.once('display_uri', resolve);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/wallets-helpers",
3
- "version": "1.1.6",
3
+ "version": "2.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -39,13 +39,14 @@
39
39
  "devDependencies": {
40
40
  "@types/ua-parser-js": "0.7.39",
41
41
  "eslint-config-custom": "*",
42
- "wagmi": "^0.12.19",
42
+ "wagmi": "2.11.2",
43
43
  "ua-parser-js": "1.0.37"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@types/ua-parser-js": "0.7.39",
47
47
  "react": ">=18",
48
- "wagmi": "^0.12.19",
49
- "ua-parser-js": "1.0.37"
48
+ "wagmi": "2.11.2",
49
+ "ua-parser-js": "1.0.37",
50
+ "@tanstack/react-query": "^5.29.0"
50
51
  }
51
52
  }