@reef-knot/wallets-helpers 1.1.5 → 2.0.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.
@@ -21,6 +21,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
21
21
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
- }
24
+ }
25
+
26
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
27
+ var e = new Error(message);
28
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
29
+ };
25
30
 
26
31
  export { __awaiter };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { getWalletConnectConnector } from './walletconnect/getWalletConnectConnector.js';
2
2
  export { getWalletConnectUri } from './walletconnect/getWalletConnectUri.js';
3
3
  export { isValidHttpUrl } from './utils/isValidHttpUrl.js';
4
- export { device, isAndroid, isIOS, isMobile, isMobileOrTablet, isTablet, os } from './utils/user-agents.js';
4
+ export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from './utils/user-agents.js';
@@ -3,6 +3,7 @@ export declare const os: import("ua-parser-js").IOS;
3
3
  export declare const isIOS: boolean;
4
4
  export declare const isAndroid: boolean;
5
5
  export declare const device: import("ua-parser-js").IDevice;
6
+ export declare const isIPad: boolean;
6
7
  export declare const isMobile: boolean;
7
8
  export declare const isTablet: boolean;
8
9
  export declare const isMobileOrTablet: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"user-agents.d.ts","sourceRoot":"","sources":["../../src/utils/user-agents.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,EAAE,4BAAiB,CAAC;AACjC,eAAO,MAAM,KAAK,SAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,SAAwB,CAAC;AAE/C,eAAO,MAAM,MAAM,gCAAqB,CAAC;AACzC,eAAO,MAAM,QAAQ,SAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,SAA2B,CAAC;AACjD,eAAO,MAAM,gBAAgB,SAAuB,CAAC"}
1
+ {"version":3,"file":"user-agents.d.ts","sourceRoot":"","sources":["../../src/utils/user-agents.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,EAAE,4BAAiB,CAAC;AACjC,eAAO,MAAM,KAAK,SAAoB,CAAC;AACvC,eAAO,MAAM,SAAS,SAAwB,CAAC;AAE/C,eAAO,MAAM,MAAM,gCAAqB,CAAC;AACzC,eAAO,MAAM,MAAM,SAA0B,CAAC;AAC9C,eAAO,MAAM,QAAQ,SAA2B,CAAC;AACjD,eAAO,MAAM,QAAQ,SAA2B,CAAC;AACjD,eAAO,MAAM,gBAAgB,SAAuB,CAAC"}
@@ -5,8 +5,9 @@ const os = parser.getOS();
5
5
  const isIOS = os.name === 'iOS';
6
6
  const isAndroid = os.name === 'Android';
7
7
  const device = parser.getDevice();
8
+ const isIPad = device.model === 'iPad';
8
9
  const isMobile = device.type === 'mobile';
9
10
  const isTablet = device.type === 'tablet';
10
11
  const isMobileOrTablet = isMobile || isTablet;
11
12
 
12
- export { device, isAndroid, isIOS, isMobile, isMobileOrTablet, isTablet, os };
13
+ export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os };
@@ -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.5",
3
+ "version": "2.0.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -34,15 +34,19 @@
34
34
  "scripts": {
35
35
  "build": "rollup -c",
36
36
  "dev": "dev=on rollup -c -w",
37
- "lint": "eslint"
37
+ "lint": "eslint --ext ts,tsx,js,mjs ."
38
38
  },
39
39
  "devDependencies": {
40
- "wagmi": "^0.12.19",
41
- "ua-parser-js": "1.0.33"
40
+ "@types/ua-parser-js": "0.7.39",
41
+ "eslint-config-custom": "*",
42
+ "wagmi": "2.10.4",
43
+ "ua-parser-js": "1.0.37"
42
44
  },
43
45
  "peerDependencies": {
44
- "react": ">=17",
45
- "wagmi": "^0.12.19",
46
- "ua-parser-js": "1.0.33"
46
+ "@types/ua-parser-js": "0.7.39",
47
+ "react": ">=18",
48
+ "wagmi": "2.10.4",
49
+ "ua-parser-js": "1.0.37",
50
+ "@tanstack/react-query": "^5.29.0"
47
51
  }
48
52
  }