@reef-knot/wallets-helpers 1.0.1 → 1.1.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.
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
|
|
2
2
|
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
3
|
+
import { Chain } from 'wagmi/chains';
|
|
4
|
+
export declare const prepareWalletConnectRPC: (rpc?: Record<number, string>) => Record<number, string>;
|
|
5
|
+
export declare const getWalletConnectConnector: ({ rpc, projectId, noMobileLinks, qrcode, v2: _v2, chains, }: {
|
|
6
|
+
rpc?: Record<number, string> | undefined;
|
|
6
7
|
projectId?: string | undefined;
|
|
7
8
|
noMobileLinks?: boolean | undefined;
|
|
8
9
|
qrcode?: boolean | undefined;
|
|
9
10
|
v2?: boolean | undefined;
|
|
11
|
+
chains: Chain[];
|
|
10
12
|
}) => WalletConnectConnector | WalletConnectLegacyConnector;
|
|
11
13
|
//# sourceMappingURL=walletConnectConnector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletConnectConnector.d.ts","sourceRoot":"","sources":["../../src/factories/walletConnectConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"walletConnectConnector.d.ts","sourceRoot":"","sources":["../../src/factories/walletConnectConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,eAAO,MAAM,uBAAuB,SAAS,OAAO,MAAM,EAAE,MAAM,CAAC,2BAUlE,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;YAa5B,KAAK,EAAE;2DAqChB,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { isValidHttpUrl } from '../utils/isValidHttpUrl.js';
|
|
|
4
4
|
import '../utils/user-agents.js';
|
|
5
5
|
import { walletConnectMobileLinks } from './walletConnectMobileLinks.js';
|
|
6
6
|
|
|
7
|
-
const prepareWalletConnectRPC = rpc => {
|
|
7
|
+
const prepareWalletConnectRPC = (rpc = {}) => {
|
|
8
8
|
const BASE_URL = typeof window === 'undefined' ? '' : window.location.origin;
|
|
9
9
|
// adds BASE_URL to `rpc` object's string values
|
|
10
10
|
return Object.entries(rpc).reduce((result, [key, value]) => Object.assign(Object.assign({}, result), {
|
|
@@ -16,19 +16,25 @@ const getWalletConnectConnector = ({
|
|
|
16
16
|
projectId = '',
|
|
17
17
|
noMobileLinks = false,
|
|
18
18
|
qrcode = true,
|
|
19
|
-
v2: _v2 = false
|
|
19
|
+
v2: _v2 = false,
|
|
20
|
+
chains
|
|
20
21
|
}) => {
|
|
22
|
+
let v2EnabledByLS = false;
|
|
23
|
+
if (typeof window !== 'undefined') {
|
|
24
|
+
v2EnabledByLS = window.localStorage.getItem('reefknot_wcv2_enable') === 'true';
|
|
25
|
+
}
|
|
21
26
|
// WalletConnect v2 will automatically replace legacy v1 after this date:
|
|
22
|
-
const v2TransitionDate = new Date('2023-06-
|
|
23
|
-
const v2 = _v2 || new Date() > v2TransitionDate;
|
|
27
|
+
const v2TransitionDate = new Date('2023-06-24T00:00:00Z');
|
|
28
|
+
const v2 = _v2 || v2EnabledByLS || new Date() > v2TransitionDate;
|
|
24
29
|
if (v2) {
|
|
25
30
|
return new WalletConnectConnector({
|
|
31
|
+
chains,
|
|
26
32
|
options: {
|
|
27
33
|
projectId,
|
|
28
34
|
showQrModal: qrcode,
|
|
29
35
|
qrModalOptions: {
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
// @walletconnect library currently requires the "chainImages" option, looks like their mistake
|
|
37
|
+
chainImages: undefined,
|
|
32
38
|
themeVariables: {
|
|
33
39
|
'--w3m-z-index': '1000'
|
|
34
40
|
}
|
|
@@ -37,6 +43,7 @@ const getWalletConnectConnector = ({
|
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
45
|
return new WalletConnectLegacyConnector({
|
|
46
|
+
chains,
|
|
40
47
|
options: {
|
|
41
48
|
rpc: prepareWalletConnectRPC(rpc),
|
|
42
49
|
qrcode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/wallets-helpers",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"lint": "eslint"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"wagmi": "0.12.
|
|
40
|
+
"wagmi": "^0.12.16",
|
|
41
41
|
"ua-parser-js": "1.0.33"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=17",
|
|
45
|
-
"wagmi": "0.12.
|
|
45
|
+
"wagmi": "^0.12.16",
|
|
46
46
|
"ua-parser-js": "1.0.33"
|
|
47
47
|
}
|
|
48
48
|
}
|