@reef-knot/wallets-helpers 1.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.
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Lido
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Wallets Helpers
2
+
3
+
@@ -0,0 +1,3 @@
1
+ export * from './walletConnectLegacyConnector';
2
+ export * from './walletConnectMobileLinks';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
2
+ export declare const prepareWalletConnectRPC: (rpc: Record<number, string>) => Record<number, string>;
3
+ export declare const getWalletConnectConnector: ({ rpc, noMobileLinks, qrcode, }: {
4
+ rpc: Record<number, string>;
5
+ noMobileLinks?: boolean | undefined;
6
+ qrcode?: boolean | undefined;
7
+ }) => WalletConnectLegacyConnector;
8
+ //# sourceMappingURL=walletConnectLegacyConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletConnectLegacyConnector.d.ts","sourceRoot":"","sources":["../../src/factories/walletConnectLegacyConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAIpF,eAAO,MAAM,uBAAuB,QAAS,OAAO,MAAM,EAAE,MAAM,CAAC,2BAUlE,CAAC;AAEF,eAAO,MAAM,yBAAyB;SAK/B,OAAO,MAAM,EAAE,MAAM,CAAC;;;kCAc5B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
2
+ import { isValidHttpUrl } from '../utils/isValidHttpUrl.js';
3
+ import '../utils/user-agents.js';
4
+ import { walletConnectMobileLinks } from './walletConnectMobileLinks.js';
5
+
6
+ const prepareWalletConnectRPC = rpc => {
7
+ const BASE_URL = typeof window === 'undefined' ? '' : window.location.origin;
8
+ // adds BASE_URL to `rpc` object's string values
9
+ return Object.entries(rpc).reduce((result, [key, value]) => Object.assign(Object.assign({}, result), {
10
+ [key]: isValidHttpUrl(value) ? value : BASE_URL + value
11
+ }), {});
12
+ };
13
+ const getWalletConnectConnector = ({
14
+ rpc,
15
+ noMobileLinks,
16
+ qrcode
17
+ }) => {
18
+ return new WalletConnectLegacyConnector({
19
+ options: {
20
+ rpc: prepareWalletConnectRPC(rpc),
21
+ qrcode,
22
+ qrcodeModalOptions: {
23
+ mobileLinks: noMobileLinks ? [] : walletConnectMobileLinks,
24
+ desktopLinks: []
25
+ }
26
+ }
27
+ });
28
+ };
29
+
30
+ export { getWalletConnectConnector, prepareWalletConnectRPC };
@@ -0,0 +1,2 @@
1
+ export declare const walletConnectMobileLinks: string[];
2
+ //# sourceMappingURL=walletConnectMobileLinks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletConnectMobileLinks.d.ts","sourceRoot":"","sources":["../../src/factories/walletConnectMobileLinks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,UA4CpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ const walletConnectMobileLinks = ['MetaMask', 'Trust Wallet', 'Zerion', 'imToken', 'Robinhood Wallet', 'Rainbow', 'Ledger Live', 'Uniswap Wallet', '1inch Wallet', 'Safe', 'Ambire Wallet', 'Unstoppable Domains', 'Argent', 'Omni', 'MathWallet', 'TokenPocket', 'iToken Wallet', 'Atomic', 'Coin98', 'CoolWallet', 'Unstoppable Wallet', 'Infinity Wallet', 'Crypto.com | DeFi Wallet', 'Guarda Wallet', 'Trustee Wallet', 'Rabby', 'Tangem', 'Coinbase Wallet', 'Frame', 'Blockchain.com', 'Exodus', 'ZenGo', 'XDEFI Wallet', 'Frontier', 'OKX Wallet', 'Brave Wallet', 'Binance DeFi Wallet', 'Fireblocks', 'Phantom', 'MEW wallet', 'GameStop Wallet', 'Opera Crypto Browser', 'Taho'];
2
+
3
+ export { walletConnectMobileLinks };
@@ -0,0 +1,3 @@
1
+ export * from './factories';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { getWalletConnectConnector, prepareWalletConnectRPC } from './factories/walletConnectLegacyConnector.js';
2
+ export { walletConnectMobileLinks } from './factories/walletConnectMobileLinks.js';
3
+ export { isValidHttpUrl } from './utils/isValidHttpUrl.js';
4
+ export { device, isAndroid, isIOS, isMobile, isMobileOrTablet, isTablet, os } from './utils/user-agents.js';
@@ -0,0 +1,3 @@
1
+ export * from './isValidHttpUrl';
2
+ export * from './user-agents';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const isValidHttpUrl: (string: string) => boolean;
2
+ //# sourceMappingURL=isValidHttpUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidHttpUrl.d.ts","sourceRoot":"","sources":["../../src/utils/isValidHttpUrl.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,WAAY,MAAM,YAQ5C,CAAC"}
@@ -0,0 +1,11 @@
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:';
9
+ };
10
+
11
+ export { isValidHttpUrl };
@@ -0,0 +1,9 @@
1
+ /// <reference types="ua-parser-js" />
2
+ export declare const os: import("ua-parser-js").IOS;
3
+ export declare const isIOS: boolean;
4
+ export declare const isAndroid: boolean;
5
+ export declare const device: import("ua-parser-js").IDevice;
6
+ export declare const isMobile: boolean;
7
+ export declare const isTablet: boolean;
8
+ export declare const isMobileOrTablet: boolean;
9
+ //# sourceMappingURL=user-agents.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,12 @@
1
+ import { UAParser } from 'ua-parser-js';
2
+
3
+ const parser = new UAParser();
4
+ const os = parser.getOS();
5
+ const isIOS = os.name === 'iOS';
6
+ const isAndroid = os.name === 'Android';
7
+ const device = parser.getDevice();
8
+ const isMobile = device.type === 'mobile';
9
+ const isTablet = device.type === 'tablet';
10
+ const isMobileOrTablet = isMobile || isTablet;
11
+
12
+ export { device, isAndroid, isIOS, isMobile, isMobileOrTablet, isTablet, os };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@reef-knot/wallets-helpers",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": "./dist/index.js"
8
+ },
9
+ "typesVersions": {
10
+ "*": {
11
+ ".": [
12
+ "dist/index.d.ts"
13
+ ]
14
+ }
15
+ },
16
+ "type": "module",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "license": "MIT",
21
+ "homepage": "https://github.com/lidofinance/reef-knot",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/lidofinance/reef-knot.git",
25
+ "directory": "packages/wallets-helpers"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/lidofinance/reef-knot/issues"
29
+ },
30
+ "publishConfig": {
31
+ "registry": "https://registry.npmjs.org/",
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "rollup -c",
36
+ "dev": "dev=on rollup -c -w",
37
+ "lint": "eslint"
38
+ },
39
+ "devDependencies": {
40
+ "wagmi": "0.12.12",
41
+ "ua-parser-js": "1.0.33"
42
+ },
43
+ "peerDependencies": {
44
+ "react": ">=17",
45
+ "wagmi": "0.12.12",
46
+ "ua-parser-js": "1.0.33"
47
+ }
48
+ }