@reef-knot/wallets-helpers 2.3.0 → 3.0.0-alpha.2
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.d.ts +5 -2
- package/dist/walletconnect/getWalletConnectConnector.d.ts.map +1 -1
- package/dist/walletconnect/getWalletConnectConnector.js +13 -20
- package/dist/walletconnect/getWalletConnectUri.js +9 -10
- package/dist/walletconnect/index.js +2 -0
- package/package.json +9 -7
- package/dist/_virtual/_tslib.js +0 -33
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 };
|
|
@@ -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
|
|
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;;
|
|
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
|
|
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,11 +1,10 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
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 };
|
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.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"homepage": "https://github.com/lidofinance/reef-knot",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/lidofinance/reef-knot.git",
|
|
24
|
+
"url": "git+https://github.com/lidofinance/reef-knot.git",
|
|
25
25
|
"directory": "packages/wallets-helpers"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
@@ -32,21 +32,23 @@
|
|
|
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
|
-
"wagmi": ">=
|
|
47
|
+
"wagmi": ">=3.3"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
50
|
"@tanstack/react-query": "^5.29.0",
|
|
49
51
|
"react": ">=18",
|
|
50
|
-
"wagmi": ">=
|
|
52
|
+
"wagmi": ">=3.3"
|
|
51
53
|
}
|
|
52
54
|
}
|
package/dist/_virtual/_tslib.js
DELETED
|
@@ -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 };
|