@reef-knot/wallets-helpers 1.1.1 → 1.1.3

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.
@@ -0,0 +1,26 @@
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
+
16
+ function __awaiter(thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ }
25
+
26
+ export { __awaiter };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './factories';
1
+ export * from './walletconnect';
2
2
  export * from './utils';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { getWalletConnectConnector, prepareWalletConnectRPC } from './factories/walletConnectConnector.js';
2
- export { walletConnectMobileLinks } from './factories/walletConnectMobileLinks.js';
1
+ export { getWalletConnectConnector } from './walletconnect/getWalletConnectConnector.js';
2
+ export { getWalletConnectUri } from './walletconnect/getWalletConnectUri.js';
3
3
  export { isValidHttpUrl } from './utils/isValidHttpUrl.js';
4
4
  export { device, isAndroid, isIOS, isMobile, isMobileOrTablet, isTablet, os } from './utils/user-agents.js';
@@ -0,0 +1,8 @@
1
+ import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
2
+ import { Chain } from 'wagmi/chains';
3
+ export declare const getWalletConnectConnector: ({ projectId, qrcode, chains, }: {
4
+ projectId?: string | undefined;
5
+ qrcode?: boolean | undefined;
6
+ chains: Chain[];
7
+ }) => WalletConnectConnector;
8
+ //# sourceMappingURL=getWalletConnectConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWalletConnectConnector.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectConnector.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;4BAmChB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
2
+
3
+ let walletconnectConnector;
4
+ let walletconnectConnectorNoQR;
5
+ const getWalletConnectConnector = ({
6
+ projectId = '',
7
+ qrcode = true,
8
+ chains
9
+ }) => {
10
+ if (!projectId) {
11
+ throw new Error('No WalletConnect Project ID found, it is required by WalletConnect v2: https://docs.walletconnect.com/2.0/cloud/relay#project-id');
12
+ }
13
+ const params = {
14
+ chains,
15
+ options: {
16
+ projectId,
17
+ showQrModal: qrcode,
18
+ qrModalOptions: {
19
+ themeVariables: {
20
+ '--w3m-z-index': '1000',
21
+ // walletconnect suddenly renamed w3m to wcm in @walletconnect/modal v2.5
22
+ // It is a breaking change in a minor version update. So now I have to support both options here
23
+ '--wcm-z-index': '1000'
24
+ }
25
+ }
26
+ }
27
+ };
28
+ if (!qrcode) {
29
+ if (!walletconnectConnectorNoQR) {
30
+ walletconnectConnectorNoQR = new WalletConnectConnector(params);
31
+ }
32
+ return walletconnectConnectorNoQR;
33
+ }
34
+ if (!walletconnectConnector) {
35
+ walletconnectConnector = new WalletConnectConnector(params);
36
+ }
37
+ return walletconnectConnector;
38
+ };
39
+
40
+ export { getWalletConnectConnector };
@@ -0,0 +1,3 @@
1
+ import type { Connector } from 'wagmi/connectors';
2
+ export declare const getWalletConnectUri: (connector: Connector) => Promise<string>;
3
+ //# sourceMappingURL=getWalletConnectUri.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWalletConnectUri.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectUri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,eAAO,MAAM,mBAAmB,cAAqB,SAAS,oBAK7D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { __awaiter } from '../_virtual/_tslib.js';
2
+
3
+ const getWalletConnectUri = connector => __awaiter(void 0, void 0, void 0, function* () {
4
+ const provider = yield connector.getProvider();
5
+ return new Promise(resolve => {
6
+ provider.once('display_uri', resolve);
7
+ });
8
+ });
9
+
10
+ export { getWalletConnectUri };
@@ -0,0 +1,3 @@
1
+ export * from './getWalletConnectConnector';
2
+ export * from './getWalletConnectUri';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletconnect/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
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.3",
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.17",
40
+ "wagmi": "^0.12.18",
41
41
  "ua-parser-js": "1.0.33"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=17",
45
- "wagmi": "^0.12.17",
45
+ "wagmi": "^0.12.18",
46
46
  "ua-parser-js": "1.0.33"
47
47
  }
48
48
  }
@@ -1,3 +0,0 @@
1
- export * from './walletConnectConnector';
2
- export * from './walletConnectMobileLinks';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC"}
@@ -1,13 +0,0 @@
1
- import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
2
- import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
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;
7
- projectId?: string | undefined;
8
- noMobileLinks?: boolean | undefined;
9
- qrcode?: boolean | undefined;
10
- v2?: boolean | undefined;
11
- chains: Chain[];
12
- }) => WalletConnectConnector | WalletConnectLegacyConnector;
13
- //# sourceMappingURL=walletConnectConnector.d.ts.map
@@ -1 +0,0 @@
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,61 +0,0 @@
1
- import { WalletConnectLegacyConnector } from 'wagmi/connectors/walletConnectLegacy';
2
- 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
-
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
- };
14
- const getWalletConnectConnector = ({
15
- rpc,
16
- projectId = '',
17
- noMobileLinks = false,
18
- qrcode = true,
19
- v2: _v2 = false,
20
- chains
21
- }) => {
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({
49
- chains,
50
- options: {
51
- rpc: prepareWalletConnectRPC(rpc),
52
- qrcode,
53
- qrcodeModalOptions: {
54
- mobileLinks: noMobileLinks ? [] : walletConnectMobileLinks,
55
- desktopLinks: []
56
- }
57
- }
58
- });
59
- };
60
-
61
- export { getWalletConnectConnector, prepareWalletConnectRPC };
@@ -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 };