@reef-knot/wallets-helpers 1.1.1 → 1.1.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.
@@ -1,3 +1,2 @@
1
1
  export * from './walletConnectConnector';
2
- export * from './walletConnectMobileLinks';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
@@ -1,13 +1,8 @@
1
- import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
2
1
  import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
3
2
  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;
3
+ export declare const getWalletConnectConnector: ({ projectId, qrcode, chains, }: {
7
4
  projectId?: string | undefined;
8
- noMobileLinks?: boolean | undefined;
9
5
  qrcode?: boolean | undefined;
10
- v2?: boolean | undefined;
11
6
  chains: Chain[];
12
- }) => WalletConnectConnector | WalletConnectLegacyConnector;
7
+ }) => WalletConnectConnector;
13
8
  //# 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;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;2DAwChB,CAAC"}
1
+ {"version":3,"file":"walletConnectConnector.d.ts","sourceRoot":"","sources":["../../src/factories/walletConnectConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAKrC,eAAO,MAAM,yBAAyB;;;YAO5B,KAAK,EAAE;4BA6BhB,CAAC"}
@@ -1,61 +1,37 @@
1
- import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
2
1
  import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
3
- import { isValidHttpUrl } from '../utils/isValidHttpUrl.js';
4
- import '../utils/user-agents.js';
5
- import { walletConnectMobileLinks } from './walletConnectMobileLinks.js';
6
2
 
7
- const prepareWalletConnectRPC = (rpc = {}) => {
8
- const BASE_URL = typeof window === 'undefined' ? '' : window.location.origin;
9
- // adds BASE_URL to `rpc` object's string values
10
- return Object.entries(rpc).reduce((result, [key, value]) => Object.assign(Object.assign({}, result), {
11
- [key]: isValidHttpUrl(value) ? value : BASE_URL + value
12
- }), {});
13
- };
3
+ let walletconnectConnector;
4
+ let walletconnectConnectorNoQR;
14
5
  const getWalletConnectConnector = ({
15
- rpc,
16
6
  projectId = '',
17
- noMobileLinks = false,
18
7
  qrcode = true,
19
- v2: _v2 = false,
20
8
  chains
21
9
  }) => {
22
- let v2EnabledByLS = false;
23
- if (typeof window !== 'undefined') {
24
- v2EnabledByLS = window.localStorage.getItem('reefknot_wcv2_enable') === 'true';
25
- }
26
- // WalletConnect v2 will automatically replace legacy v1 after this date:
27
- const v2TransitionDate = new Date('2023-06-24T00:00:00Z');
28
- const v2 = _v2 || v2EnabledByLS || new Date() > v2TransitionDate;
29
- if (v2) {
30
- return new WalletConnectConnector({
31
- chains,
32
- options: {
33
- projectId,
34
- showQrModal: qrcode,
35
- qrModalOptions: {
36
- // @walletconnect library currently requires the "chainImages" option, looks like their mistake
37
- chainImages: undefined,
38
- themeVariables: {
39
- '--w3m-z-index': '1000',
40
- // @ts-expect-error walletconnect suddenly renamed w3m to wcm in @walletconnect/modal v2.5
41
- // It is a breaking change in a minor version update. So now I have to support both options here
42
- '--wcm-z-index': '1000'
43
- }
44
- }
45
- }
46
- });
47
- }
48
- return new WalletConnectLegacyConnector({
10
+ const params = {
49
11
  chains,
50
12
  options: {
51
- rpc: prepareWalletConnectRPC(rpc),
52
- qrcode,
53
- qrcodeModalOptions: {
54
- mobileLinks: noMobileLinks ? [] : walletConnectMobileLinks,
55
- desktopLinks: []
13
+ projectId,
14
+ showQrModal: qrcode,
15
+ qrModalOptions: {
16
+ themeVariables: {
17
+ '--w3m-z-index': '1000',
18
+ // walletconnect suddenly renamed w3m to wcm in @walletconnect/modal v2.5
19
+ // It is a breaking change in a minor version update. So now I have to support both options here
20
+ '--wcm-z-index': '1000'
21
+ }
56
22
  }
57
23
  }
58
- });
24
+ };
25
+ if (!qrcode) {
26
+ if (!walletconnectConnectorNoQR) {
27
+ walletconnectConnectorNoQR = new WalletConnectConnector(params);
28
+ }
29
+ return walletconnectConnectorNoQR;
30
+ }
31
+ if (!walletconnectConnector) {
32
+ walletconnectConnector = new WalletConnectConnector(params);
33
+ }
34
+ return walletconnectConnector;
59
35
  };
60
36
 
61
- export { getWalletConnectConnector, prepareWalletConnectRPC };
37
+ export { getWalletConnectConnector };
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { getWalletConnectConnector, prepareWalletConnectRPC } from './factories/walletConnectConnector.js';
2
- export { walletConnectMobileLinks } from './factories/walletConnectMobileLinks.js';
1
+ export { getWalletConnectConnector } from './factories/walletConnectConnector.js';
3
2
  export { isValidHttpUrl } from './utils/isValidHttpUrl.js';
4
3
  export { device, isAndroid, isIOS, isMobile, isMobileOrTablet, isTablet, os } from './utils/user-agents.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reef-knot/wallets-helpers",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -1,2 +0,0 @@
1
- export declare const walletConnectMobileLinks: string[];
2
- //# sourceMappingURL=walletConnectMobileLinks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"walletConnectMobileLinks.d.ts","sourceRoot":"","sources":["../../src/factories/walletConnectMobileLinks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,UA4CpC,CAAC"}
@@ -1,3 +0,0 @@
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 };