@reef-knot/wallets-helpers 2.3.0 → 3.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.
package/dist/index.js CHANGED
@@ -1,5 +1,9 @@
1
- export { getWalletConnectConnector } from './walletconnect/getWalletConnectConnector.js';
2
- export { getWalletConnectUri } from './walletconnect/getWalletConnectUri.js';
3
- export { isValidHttpUrl } from './utils/isValidHttpUrl.js';
4
- export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from './utils/userAgents.js';
5
- export { getTargetEIP6963, isProviderExistsEIP6963 } from './utils/eip6963.js';
1
+ import { getWalletConnectConnector } from "./walletconnect/getWalletConnectConnector.js";
2
+ import { getWalletConnectUri } from "./walletconnect/getWalletConnectUri.js";
3
+ import "./walletconnect/index.js";
4
+ import { isValidHttpUrl } from "./utils/isValidHttpUrl.js";
5
+ import { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from "./utils/userAgents.js";
6
+ import { getTargetEIP6963, isProviderExistsEIP6963 } from "./utils/eip6963.js";
7
+ import "./utils/index.js";
8
+
9
+ export { device, getTargetEIP6963, getWalletConnectConnector, getWalletConnectUri, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isProviderExistsEIP6963, isTablet, isValidHttpUrl, os };
@@ -1,16 +1,14 @@
1
+ //#region src/utils/eip6963.ts
1
2
  const getTargetEIP6963 = (providersStore, rdns) => {
2
- const providerDetail = providersStore.findProvider({
3
- rdns
4
- });
5
- if (!providerDetail) return undefined;
6
- return {
7
- id: providerDetail.info.rdns,
8
- name: providerDetail.info.name,
9
- provider: providerDetail.provider
10
- };
3
+ const providerDetail = providersStore.findProvider({ rdns });
4
+ if (!providerDetail) return void 0;
5
+ return {
6
+ id: providerDetail.info.rdns,
7
+ name: providerDetail.info.name,
8
+ provider: providerDetail.provider
9
+ };
11
10
  };
12
- const isProviderExistsEIP6963 = (providersStore, rdns) => Boolean(providersStore.findProvider({
13
- rdns
14
- }));
11
+ const isProviderExistsEIP6963 = (providersStore, rdns) => Boolean(providersStore.findProvider({ rdns }));
15
12
 
16
- export { getTargetEIP6963, isProviderExistsEIP6963 };
13
+ //#endregion
14
+ export { getTargetEIP6963, isProviderExistsEIP6963 };
@@ -0,0 +1,3 @@
1
+ import { isValidHttpUrl } from "./isValidHttpUrl.js";
2
+ import { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from "./userAgents.js";
3
+ import { getTargetEIP6963, isProviderExistsEIP6963 } from "./eip6963.js";
@@ -1,11 +1,13 @@
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:';
1
+ //#region src/utils/isValidHttpUrl.ts
2
+ const isValidHttpUrl = (string) => {
3
+ let url;
4
+ try {
5
+ url = new URL(string);
6
+ } catch (_) {
7
+ return false;
8
+ }
9
+ return url.protocol === "http:" || url.protocol === "https:";
9
10
  };
10
11
 
11
- export { isValidHttpUrl };
12
+ //#endregion
13
+ export { isValidHttpUrl };
@@ -1,13 +1,15 @@
1
- import { UAParser } from 'ua-parser-js';
1
+ import { UAParser } from "ua-parser-js";
2
2
 
3
+ //#region src/utils/userAgents.ts
3
4
  const parser = new UAParser();
4
5
  const os = parser.getOS();
5
- const isIOS = os.name === 'iOS';
6
- const isAndroid = os.name === 'Android';
6
+ const isIOS = os.name === "iOS";
7
+ const isAndroid = os.name === "Android";
7
8
  const device = parser.getDevice();
8
- const isIPad = device.model === 'iPad';
9
- const isMobile = device.type === 'mobile';
10
- const isTablet = device.type === 'tablet';
9
+ const isIPad = device.model === "iPad";
10
+ const isMobile = device.type === "mobile";
11
+ const isTablet = device.type === "tablet";
11
12
  const isMobileOrTablet = isMobile || isTablet;
12
13
 
13
- export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os };
14
+ //#endregion
15
+ export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os };
@@ -2,12 +2,15 @@ export declare function getWalletConnectConnector({ projectId, qrcode, }: {
2
2
  projectId?: string;
3
3
  qrcode?: boolean;
4
4
  }): import("wagmi").CreateConnectorFn<import("@walletconnect/ethereum-provider").default, {
5
- connect(parameters?: {
5
+ connect<withCapabilities extends boolean = false>(parameters?: {
6
6
  chainId?: number | undefined;
7
7
  isReconnecting?: boolean | undefined;
8
8
  pairingTopic?: string | undefined;
9
+ withCapabilities?: withCapabilities | boolean | undefined;
9
10
  }): Promise<{
10
- accounts: readonly import("abitype").Address[];
11
+ accounts: withCapabilities extends true ? readonly {
12
+ address: import("abitype").Address;
13
+ }[] : readonly import("abitype").Address[];
11
14
  chainId: number;
12
15
  }>;
13
16
  getNamespaceChainsIds(): number[];
@@ -1 +1 @@
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;;eAmBw0D,CAAC;sBAA4C,CAAC;oBAA2C,CAAC;;;;;;;;;;;;;;;;;GADl6D;yBAxBe,yBAAyB"}
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;;eAmBk3D,CAAC;sBAA4C,CAAC;oBAA2C,CAAC;wBAA8C,CAAC;;;;;;;;;;;;;;;;;;;GAD3/D;yBAxBe,yBAAyB"}
@@ -1,27 +1,20 @@
1
- import { walletConnect } from 'wagmi/connectors';
1
+ import { walletConnect } from "wagmi/connectors";
2
2
 
3
+ //#region src/walletconnect/getWalletConnectConnector.ts
3
4
  const cache = {};
4
5
  const memoize = (key, getter) => {
5
- if (!cache[key]) cache[key] = getter();
6
- return cache[key];
6
+ if (!cache[key]) cache[key] = getter();
7
+ return cache[key];
7
8
  };
8
9
  getWalletConnectConnector.type = walletConnect.type;
9
- function getWalletConnectConnector({
10
- projectId = '',
11
- qrcode = true
12
- }) {
13
- if (!projectId) {
14
- console.warn('No WalletConnect Project ID found, it is required by WalletConnect v2: https://docs.walletconnect.com/2.0/cloud/relay#project-id');
15
- }
16
- return memoize(qrcode ? 'qrcode' : 'no-qrcode', () => walletConnect({
17
- projectId,
18
- showQrModal: qrcode,
19
- qrModalOptions: {
20
- themeVariables: {
21
- '--wcm-z-index': '1000'
22
- }
23
- }
24
- }));
10
+ function getWalletConnectConnector({ projectId = "", qrcode = true }) {
11
+ if (!projectId) console.warn("No WalletConnect Project ID found, it is required by WalletConnect v2: https://docs.walletconnect.com/2.0/cloud/relay#project-id");
12
+ return memoize(qrcode ? "qrcode" : "no-qrcode", () => walletConnect({
13
+ projectId,
14
+ showQrModal: qrcode,
15
+ qrModalOptions: { themeVariables: { "--wcm-z-index": "1000" } }
16
+ }));
25
17
  }
26
18
 
27
- export { getWalletConnectConnector };
19
+ //#endregion
20
+ export { getWalletConnectConnector };
@@ -1,11 +1,10 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
1
+ //#region src/walletconnect/getWalletConnectUri.ts
2
+ const getWalletConnectUri = async (connector) => {
3
+ const provider = await connector.getProvider();
4
+ return new Promise((resolve) => {
5
+ provider.once("display_uri", resolve);
6
+ });
7
+ };
2
8
 
3
- const getWalletConnectUri = connector => __awaiter(void 0, void 0, void 0, function* () {
4
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- const provider = yield connector.getProvider();
6
- return new Promise(resolve => {
7
- provider.once('display_uri', resolve);
8
- });
9
- });
10
-
11
- export { getWalletConnectUri };
9
+ //#endregion
10
+ export { getWalletConnectUri };
@@ -0,0 +1,2 @@
1
+ import { getWalletConnectConnector } from "./getWalletConnectConnector.js";
2
+ import { getWalletConnectUri } from "./getWalletConnectUri.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/wallets-helpers",
3
- "version": "2.3.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -32,21 +32,23 @@
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
  "dependencies": {
40
41
  "@types/ua-parser-js": "0.7.39",
41
42
  "ua-parser-js": "1.0.37"
42
43
  },
43
44
  "devDependencies": {
45
+ "build-config": "*",
44
46
  "eslint-config-custom": "*",
45
- "wagmi": ">=2.14"
47
+ "wagmi": ">=3.3"
46
48
  },
47
49
  "peerDependencies": {
48
50
  "@tanstack/react-query": "^5.29.0",
49
51
  "react": ">=18",
50
- "wagmi": ">=2.14"
52
+ "wagmi": ">=3.3"
51
53
  }
52
54
  }
@@ -1,33 +0,0 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- /* global Reflect, Promise, SuppressedError, Symbol */
16
-
17
-
18
- function __awaiter(thisArg, _arguments, P, generator) {
19
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
- return new (P || (P = Promise))(function (resolve, reject) {
21
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
- step((generator = generator.apply(thisArg, _arguments || [])).next());
25
- });
26
- }
27
-
28
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
29
- var e = new Error(message);
30
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
- };
32
-
33
- export { __awaiter };