@reef-knot/wallets-helpers 2.3.0-alpha.2 → 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 };
@@ -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,9 +1,10 @@
1
- const getWalletConnectUri = async connector => {
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
- const provider = await connector.getProvider();
4
- return new Promise(resolve => {
5
- provider.once('display_uri', resolve);
6
- });
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
7
  };
8
8
 
9
- 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-alpha.2",
3
+ "version": "3.0.0-alpha.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -32,15 +32,17 @@
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
47
  "wagmi": ">=3.3"
46
48
  },