@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 +9 -5
- package/dist/utils/eip6963.js +11 -13
- package/dist/utils/index.js +3 -0
- package/dist/utils/isValidHttpUrl.js +11 -9
- package/dist/utils/userAgents.js +9 -7
- package/dist/walletconnect/getWalletConnectConnector.js +13 -20
- package/dist/walletconnect/getWalletConnectUri.js +8 -7
- package/dist/walletconnect/index.js +2 -0
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 };
|
package/dist/utils/eip6963.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
//#region src/utils/eip6963.ts
|
|
1
2
|
const getTargetEIP6963 = (providersStore, rdns) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getTargetEIP6963, isProviderExistsEIP6963 };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isValidHttpUrl };
|
package/dist/utils/userAgents.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { UAParser } from
|
|
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 ===
|
|
6
|
-
const isAndroid = os.name ===
|
|
6
|
+
const isIOS = os.name === "iOS";
|
|
7
|
+
const isAndroid = os.name === "Android";
|
|
7
8
|
const device = parser.getDevice();
|
|
8
|
-
const isIPad = device.model ===
|
|
9
|
-
const isMobile = device.type ===
|
|
10
|
-
const isTablet = device.type ===
|
|
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
|
-
|
|
14
|
+
//#endregion
|
|
15
|
+
export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os };
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import { walletConnect } from
|
|
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
|
-
|
|
6
|
-
|
|
6
|
+
if (!cache[key]) cache[key] = getter();
|
|
7
|
+
return cache[key];
|
|
7
8
|
};
|
|
8
9
|
getWalletConnectConnector.type = walletConnect.type;
|
|
9
|
-
function getWalletConnectConnector({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getWalletConnectConnector };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getWalletConnectUri };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/wallets-helpers",
|
|
3
|
-
"version": "
|
|
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": "
|
|
36
|
-
"dev": "
|
|
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
|
},
|