@reef-knot/wallets-helpers 3.1.0 → 3.2.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/README.md +11 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +1 -3
- package/dist/utils/eip6963.d.ts +11 -9
- package/dist/utils/eip6963.d.ts.map +1 -1
- package/dist/utils/eip6963.js +7 -7
- package/dist/utils/eip6963.js.map +1 -0
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +1 -0
- package/dist/utils/isValidHttpUrl.d.ts +2 -0
- package/dist/utils/isValidHttpUrl.d.ts.map +1 -1
- package/dist/utils/isValidHttpUrl.js +4 -3
- package/dist/utils/isValidHttpUrl.js.map +1 -0
- package/dist/utils/userAgents.d.ts +2 -0
- package/dist/utils/userAgents.d.ts.map +1 -1
- package/dist/utils/userAgents.js +3 -3
- package/dist/utils/userAgents.js.map +1 -0
- package/dist/walletAdapter.d.ts +36 -0
- package/dist/walletAdapter.d.ts.map +1 -0
- package/dist/walletconnect/getWalletConnectConnector.d.ts +28 -26
- package/dist/walletconnect/getWalletConnectConnector.d.ts.map +1 -1
- package/dist/walletconnect/getWalletConnectConnector.js +20 -14
- package/dist/walletconnect/getWalletConnectConnector.js.map +1 -0
- package/dist/walletconnect/index.js +1 -2
- package/package.json +7 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/walletconnect/getWalletConnectUri.d.ts +0 -3
- package/dist/walletconnect/getWalletConnectUri.d.ts.map +0 -1
- package/dist/walletconnect/getWalletConnectUri.js +0 -10
- package/dist/walletconnect/index.d.ts +0 -3
- package/dist/walletconnect/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
# Wallets Helpers
|
|
2
2
|
|
|
3
|
+
Shared runtime helpers and TypeScript contracts for Reef Knot wallet adapters.
|
|
3
4
|
|
|
5
|
+
```ts
|
|
6
|
+
import type {
|
|
7
|
+
WalletAdapterArgs,
|
|
8
|
+
WalletAdapterData,
|
|
9
|
+
WalletAdapterIcons,
|
|
10
|
+
WalletAdapterType,
|
|
11
|
+
} from '@reef-knot/wallets-helpers';
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This package is independent of the Reef Knot UI and the default wallet catalog.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getWalletConnectConnector } from "./walletconnect/getWalletConnectConnector.js";
|
|
2
|
+
import { isValidHttpUrl } from "./utils/isValidHttpUrl.js";
|
|
3
|
+
import { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from "./utils/userAgents.js";
|
|
4
|
+
import { getTargetEIP6963, isProviderExistsEIP6963 } from "./utils/eip6963.js";
|
|
5
|
+
import "./utils/index.js";
|
|
6
|
+
import { WalletAdapterArgs, WalletAdapterData, WalletAdapterIcons, WalletAdapterType } from "./walletAdapter.js";
|
|
7
|
+
export { WalletAdapterArgs, WalletAdapterData, WalletAdapterIcons, WalletAdapterType, device, getTargetEIP6963, getWalletConnectConnector, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isProviderExistsEIP6963, isTablet, isValidHttpUrl, os };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { getWalletConnectConnector } from "./walletconnect/getWalletConnectConnector.js";
|
|
2
|
-
import { getWalletConnectUri } from "./walletconnect/getWalletConnectUri.js";
|
|
3
2
|
import "./walletconnect/index.js";
|
|
4
3
|
import { isValidHttpUrl } from "./utils/isValidHttpUrl.js";
|
|
5
4
|
import { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from "./utils/userAgents.js";
|
|
6
5
|
import { getTargetEIP6963, isProviderExistsEIP6963 } from "./utils/eip6963.js";
|
|
7
6
|
import "./utils/index.js";
|
|
8
|
-
|
|
9
|
-
export { device, getTargetEIP6963, getWalletConnectConnector, getWalletConnectUri, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isProviderExistsEIP6963, isTablet, isValidHttpUrl, os };
|
|
7
|
+
export { device, getTargetEIP6963, getWalletConnectConnector, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isProviderExistsEIP6963, isTablet, isValidHttpUrl, os };
|
package/dist/utils/eip6963.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Rdns, Store } from "mipd";
|
|
2
|
+
//#region src/utils/eip6963.d.ts
|
|
2
3
|
export declare const getTargetEIP6963: (providersStore: Store, rdns: Rdns) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
4
|
+
id: "com.coinbase" | "com.enkrypt" | "io.metamask" | "io.zerion" | (string & {});
|
|
5
|
+
name: string;
|
|
6
|
+
provider: () => {
|
|
7
|
+
request: import("viem").EIP1193RequestFn<import("viem").EIP1474Methods>;
|
|
8
|
+
on: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
9
|
+
removeListener: <event extends keyof import("viem").EIP1193EventMap>(event: event, listener: import("viem").EIP1193EventMap[event]) => void;
|
|
10
|
+
} | undefined;
|
|
11
|
+
};
|
|
11
12
|
export declare const isProviderExistsEIP6963: (providersStore: Store, rdns: Rdns) => boolean;
|
|
13
|
+
//#endregion
|
|
12
14
|
//# sourceMappingURL=eip6963.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip6963.d.ts","
|
|
1
|
+
{"version":3,"file":"eip6963.d.ts","names":[],"sources":["../../src/utils/eip6963.ts"],"mappings":";;qBAEa,mBAAgB,gBAAoB,OAAK,MAAQ;EAK1D;EACA;EAEA;;;;;;qBAIS,0BAAuB,gBAAoB,OAAK,MAAQ"}
|
package/dist/utils/eip6963.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//#region src/utils/eip6963.ts
|
|
2
2
|
const getTargetEIP6963 = (providersStore, rdns) => {
|
|
3
|
-
const
|
|
4
|
-
if (!providerDetail) return void 0;
|
|
3
|
+
const findProviderDetail = () => providersStore.findProvider({ rdns });
|
|
5
4
|
return {
|
|
6
|
-
id:
|
|
7
|
-
name:
|
|
8
|
-
provider:
|
|
5
|
+
id: rdns,
|
|
6
|
+
name: findProviderDetail()?.info.name ?? rdns,
|
|
7
|
+
provider: () => findProviderDetail()?.provider
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
10
|
const isProviderExistsEIP6963 = (providersStore, rdns) => Boolean(providersStore.findProvider({ rdns }));
|
|
12
|
-
|
|
13
11
|
//#endregion
|
|
14
|
-
export { getTargetEIP6963, isProviderExistsEIP6963 };
|
|
12
|
+
export { getTargetEIP6963, isProviderExistsEIP6963 };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=eip6963.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip6963.js","names":[],"sources":["../../src/utils/eip6963.ts"],"sourcesContent":["import type { Store, Rdns } from 'mipd';\n\nexport const getTargetEIP6963 = (providersStore: Store, rdns: Rdns) => {\n const findProviderDetail = () => providersStore.findProvider({ rdns });\n // Never return undefined: wagmi then falls back to `window.ethereum`,\n // which can belong to another wallet.\n return {\n id: rdns,\n name: findProviderDetail()?.info.name ?? rdns,\n // Look up again on each call. The wallet can announce after this target is created.\n provider: () => findProviderDetail()?.provider,\n };\n};\n\nexport const isProviderExistsEIP6963 = (providersStore: Store, rdns: Rdns) =>\n Boolean(providersStore.findProvider({ rdns }));\n"],"mappings":";AAEA,MAAa,oBAAoB,gBAAuB,SAAe;CACrE,MAAM,2BAA2B,eAAe,aAAa,EAAE,KAAK,CAAC;CAGrE,OAAO;EACL,IAAI;EACJ,MAAM,mBAAmB,CAAC,EAAE,KAAK,QAAQ;EAEzC,gBAAgB,mBAAmB,CAAC,EAAE;CACxC;AACF;AAEA,MAAa,2BAA2B,gBAAuB,SAC7D,QAAQ,eAAe,aAAa,EAAE,KAAK,CAAC,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { isValidHttpUrl } from "./isValidHttpUrl.js";
|
|
2
|
+
import { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from "./userAgents.js";
|
|
3
|
+
import { getTargetEIP6963, isProviderExistsEIP6963 } from "./eip6963.js";
|
|
4
|
+
export { device, getTargetEIP6963, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isProviderExistsEIP6963, isTablet, isValidHttpUrl, os };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { isValidHttpUrl } from "./isValidHttpUrl.js";
|
|
2
2
|
import { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os } from "./userAgents.js";
|
|
3
3
|
import { getTargetEIP6963, isProviderExistsEIP6963 } from "./eip6963.js";
|
|
4
|
+
export { device, getTargetEIP6963, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isProviderExistsEIP6963, isTablet, isValidHttpUrl, os };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidHttpUrl.d.ts","
|
|
1
|
+
{"version":3,"file":"isValidHttpUrl.d.ts","names":[],"sources":["../../src/utils/isValidHttpUrl.ts"],"mappings":";qBAAa,iBAAc"}
|
|
@@ -3,11 +3,12 @@ const isValidHttpUrl = (string) => {
|
|
|
3
3
|
let url;
|
|
4
4
|
try {
|
|
5
5
|
url = new URL(string);
|
|
6
|
-
} catch
|
|
6
|
+
} catch {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
10
10
|
};
|
|
11
|
-
|
|
12
11
|
//#endregion
|
|
13
|
-
export { isValidHttpUrl };
|
|
12
|
+
export { isValidHttpUrl };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=isValidHttpUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidHttpUrl.js","names":[],"sources":["../../src/utils/isValidHttpUrl.ts"],"sourcesContent":["export const isValidHttpUrl = (string: string) => {\n let url;\n try {\n url = new URL(string);\n } catch {\n return false;\n }\n return url.protocol === 'http:' || url.protocol === 'https:';\n};\n"],"mappings":";AAAA,MAAa,kBAAkB,WAAmB;CAChD,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,MAAM;CACtB,QAAQ;EACN,OAAO;CACT;CACA,OAAO,IAAI,aAAa,WAAW,IAAI,aAAa;AACtD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/utils/userAgents.d.ts
|
|
1
2
|
export declare const os: import("ua-parser-js").IOS;
|
|
2
3
|
export declare const isIOS: boolean;
|
|
3
4
|
export declare const isAndroid: boolean;
|
|
@@ -6,4 +7,5 @@ export declare const isIPad: boolean;
|
|
|
6
7
|
export declare const isMobile: boolean;
|
|
7
8
|
export declare const isTablet: boolean;
|
|
8
9
|
export declare const isMobileOrTablet: boolean;
|
|
10
|
+
//#endregion
|
|
9
11
|
//# sourceMappingURL=userAgents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAgents.d.ts","
|
|
1
|
+
{"version":3,"file":"userAgents.d.ts","names":[],"sources":["../../src/utils/userAgents.ts"],"mappings":";qBAIa,2BAAE;qBACF;qBACA;qBAEA,+BAAM;qBACN;qBACA;qBACA;qBACA"}
|
package/dist/utils/userAgents.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UAParser } from "ua-parser-js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/userAgents.ts
|
|
4
3
|
const parser = new UAParser();
|
|
5
4
|
const os = parser.getOS();
|
|
@@ -10,6 +9,7 @@ const isIPad = device.model === "iPad";
|
|
|
10
9
|
const isMobile = device.type === "mobile";
|
|
11
10
|
const isTablet = device.type === "tablet";
|
|
12
11
|
const isMobileOrTablet = isMobile || isTablet;
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
|
-
export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os };
|
|
13
|
+
export { device, isAndroid, isIOS, isIPad, isMobile, isMobileOrTablet, isTablet, os };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=userAgents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userAgents.js","names":[],"sources":["../../src/utils/userAgents.ts"],"sourcesContent":["import { UAParser } from 'ua-parser-js';\n\nconst parser = new UAParser();\n\nexport const os = parser.getOS();\nexport const isIOS = os.name === 'iOS';\nexport const isAndroid = os.name === 'Android';\n\nexport const device = parser.getDevice();\nexport const isIPad = device.model === 'iPad';\nexport const isMobile = device.type === 'mobile';\nexport const isTablet = device.type === 'tablet';\nexport const isMobileOrTablet = isMobile || isTablet;\n"],"mappings":";;AAEA,MAAM,SAAS,IAAI,SAAS;AAE5B,MAAa,KAAK,OAAO,MAAM;AAC/B,MAAa,QAAQ,GAAG,SAAS;AACjC,MAAa,YAAY,GAAG,SAAS;AAErC,MAAa,SAAS,OAAO,UAAU;AACvC,MAAa,SAAS,OAAO,UAAU;AACvC,MAAa,WAAW,OAAO,SAAS;AACxC,MAAa,WAAW,OAAO,SAAS;AACxC,MAAa,mBAAmB,YAAY"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Store } from "mipd";
|
|
2
|
+
import { ElementType } from "react";
|
|
3
|
+
import { Chain } from "wagmi/chains";
|
|
4
|
+
import { CreateConnectorFn } from "wagmi";
|
|
5
|
+
//#region src/walletAdapter.d.ts
|
|
6
|
+
export type WalletAdapterIcons = {
|
|
7
|
+
light: ElementType;
|
|
8
|
+
dark: ElementType;
|
|
9
|
+
};
|
|
10
|
+
export type WalletAdapterData = {
|
|
11
|
+
walletId: string;
|
|
12
|
+
walletName: string;
|
|
13
|
+
type: string;
|
|
14
|
+
rdns?: string;
|
|
15
|
+
icon?: ElementType | WalletAdapterIcons;
|
|
16
|
+
detector?: () => boolean | Promise<boolean>;
|
|
17
|
+
autoConnectOnly?: boolean;
|
|
18
|
+
downloadURLs?: {
|
|
19
|
+
default: string;
|
|
20
|
+
android?: string;
|
|
21
|
+
ios?: string;
|
|
22
|
+
};
|
|
23
|
+
deeplink?: string;
|
|
24
|
+
createConnectorFn: CreateConnectorFn;
|
|
25
|
+
};
|
|
26
|
+
export interface WalletAdapterArgs {
|
|
27
|
+
rpc: Record<number, string>;
|
|
28
|
+
defaultChain: Chain;
|
|
29
|
+
walletconnectProjectId?: string;
|
|
30
|
+
safeAllowedDomains?: RegExp[];
|
|
31
|
+
ledgerForceClearSign?: boolean;
|
|
32
|
+
providersStore: Store;
|
|
33
|
+
}
|
|
34
|
+
export type WalletAdapterType = (args: WalletAdapterArgs) => WalletAdapterData;
|
|
35
|
+
//#endregion
|
|
36
|
+
//# sourceMappingURL=walletAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletAdapter.d.ts","names":["ProvidersStore"],"sources":["../src/walletAdapter.ts"],"mappings":";;;;;YAKY;EACV,OAAO;EACP,MAAM;;YAGI;EACV;EACA;EAIA;EAKA;EAIA,OAAO,cAAc;EAGrB,2BAA2B;EAK3B;EAIA;IACE;IACA;IACA;;EAGF;EAEA,mBAAmB;;iBAGJ;EACf,KAAK;EACL,cAAc;EACd;EACA,qBAAqB;EACrB;EACA,gBAAgBA;;YAEN,qBAAqB,MAAM,sBAAsB"}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/walletconnect/getWalletConnectConnector.d.ts
|
|
2
|
+
export declare function getWalletConnectConnector({ projectId, qrcode }: {
|
|
3
|
+
projectId?: string;
|
|
4
|
+
qrcode?: boolean;
|
|
4
5
|
}): import("wagmi").CreateConnectorFn<import("@walletconnect/ethereum-provider").default, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
connect<withCapabilities extends boolean = false>(parameters?: {
|
|
7
|
+
chainId?: number | undefined;
|
|
8
|
+
isReconnecting?: boolean | undefined;
|
|
9
|
+
pairingTopic?: string | undefined;
|
|
10
|
+
withCapabilities?: withCapabilities | boolean | undefined;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
accounts: withCapabilities extends true ? readonly {
|
|
13
|
+
address: import("abitype").Address;
|
|
14
|
+
}[] : readonly import("abitype").Address[];
|
|
15
|
+
chainId: number;
|
|
16
|
+
}>;
|
|
17
|
+
getNamespaceChainsIds(): number[];
|
|
18
|
+
getRequestedChainsIds(): Promise<number[]>;
|
|
19
|
+
isChainsStale(): Promise<boolean>;
|
|
20
|
+
onConnect(connectInfo: import("viem").ProviderConnectInfo): void;
|
|
21
|
+
onDisplayUri(uri: string): void;
|
|
22
|
+
onSessionDelete(data: {
|
|
23
|
+
topic: string;
|
|
24
|
+
}): void;
|
|
25
|
+
setRequestedChainsIds(chains: number[]): void;
|
|
26
|
+
requestedChainsStorageKey: `${string}.requestedChains`;
|
|
26
27
|
}, {
|
|
27
|
-
|
|
28
|
+
[x: `${string}.requestedChains`]: number[];
|
|
28
29
|
}>;
|
|
29
30
|
export declare namespace getWalletConnectConnector {
|
|
30
|
-
|
|
31
|
+
var type: "walletConnect";
|
|
31
32
|
}
|
|
33
|
+
//#endregion
|
|
32
34
|
//# sourceMappingURL=getWalletConnectConnector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWalletConnectConnector.d.ts","
|
|
1
|
+
{"version":3,"file":"getWalletConnectConnector.d.ts","names":[],"sources":["../../src/walletconnect/getWalletConnectConnector.ts"],"mappings":";wBAqBgB,4BACd,WACA;EAEA;EACA;oBACD,6DAAA;;;;;;;;;;;;;;;;;;;;;;;;;yBANe;MAAA"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { walletConnect } from "wagmi/connectors";
|
|
2
|
-
|
|
3
2
|
//#region src/walletconnect/getWalletConnectConnector.ts
|
|
4
|
-
const cache =
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
3
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4
|
+
const createConnector = (projectId, qrcode) => walletConnect({
|
|
5
|
+
projectId,
|
|
6
|
+
showQrModal: qrcode,
|
|
7
|
+
qrModalOptions: { themeVariables: { "--wcm-z-index": "1000" } }
|
|
8
|
+
});
|
|
9
9
|
getWalletConnectConnector.type = walletConnect.type;
|
|
10
10
|
function getWalletConnectConnector({ projectId = "", qrcode = true }) {
|
|
11
|
-
if (!projectId)
|
|
12
|
-
|
|
13
|
-
projectId,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
if (!projectId) {
|
|
12
|
+
console.warn("No WalletConnect Project ID found, it is required by WalletConnect v2: https://docs.walletconnect.com/2.0/cloud/relay#project-id");
|
|
13
|
+
return createConnector(projectId, qrcode);
|
|
14
|
+
}
|
|
15
|
+
const key = `${projectId}:${qrcode ? "qrcode" : "no-qrcode"}`;
|
|
16
|
+
let connector = cache.get(key);
|
|
17
|
+
if (!connector) {
|
|
18
|
+
connector = createConnector(projectId, qrcode);
|
|
19
|
+
cache.set(key, connector);
|
|
20
|
+
}
|
|
21
|
+
return connector;
|
|
17
22
|
}
|
|
18
|
-
|
|
19
23
|
//#endregion
|
|
20
|
-
export { getWalletConnectConnector };
|
|
24
|
+
export { getWalletConnectConnector };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=getWalletConnectConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWalletConnectConnector.js","names":[],"sources":["../../src/walletconnect/getWalletConnectConnector.ts"],"sourcesContent":["import { walletConnect } from 'wagmi/connectors';\n\ntype WCConnector = ReturnType<typeof walletConnect>;\n\n// Reusing factories avoids repeated WalletConnect Core initialization.\n// The key must include every factory input, otherwise a later config would get\n// a factory bound to the first projectId seen in this runtime.\nconst cache = new Map<string, WCConnector>();\n\nconst createConnector = (projectId: string, qrcode: boolean) =>\n walletConnect({\n projectId,\n showQrModal: qrcode,\n qrModalOptions: {\n themeVariables: {\n '--wcm-z-index': '1000',\n },\n },\n });\n\ngetWalletConnectConnector.type = walletConnect.type;\nexport function getWalletConnectConnector({\n projectId = '',\n qrcode = true,\n}: {\n projectId?: string;\n qrcode?: boolean;\n}) {\n if (!projectId) {\n console.warn(\n 'No WalletConnect Project ID found, it is required by WalletConnect v2: https://docs.walletconnect.com/2.0/cloud/relay#project-id',\n );\n // Not cached, so a later config with a valid projectId is not shadowed\n return createConnector(projectId, qrcode);\n }\n\n const key = `${projectId}:${qrcode ? 'qrcode' : 'no-qrcode'}`;\n let connector = cache.get(key);\n if (!connector) {\n connector = createConnector(projectId, qrcode);\n cache.set(key, connector);\n }\n return connector;\n}\n"],"mappings":";;AAOA,MAAM,wBAAQ,IAAI,IAAyB;AAE3C,MAAM,mBAAmB,WAAmB,WAC1C,cAAc;CACZ;CACA,aAAa;CACb,gBAAgB,EACd,gBAAgB,EACd,iBAAiB,OACnB,EACF;AACF,CAAC;AAEH,0BAA0B,OAAO,cAAc;AAC/C,SAAgB,0BAA0B,EACxC,YAAY,IACZ,SAAS,QAIR;CACD,IAAI,CAAC,WAAW;EACd,QAAQ,KACN,kIACF;EAEA,OAAO,gBAAgB,WAAW,MAAM;CAC1C;CAEA,MAAM,MAAM,GAAG,UAAU,GAAG,SAAS,WAAW;CAChD,IAAI,YAAY,MAAM,IAAI,GAAG;CAC7B,IAAI,CAAC,WAAW;EACd,YAAY,gBAAgB,WAAW,MAAM;EAC7C,MAAM,IAAI,KAAK,SAAS;CAC1B;CACA,OAAO;AACT"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getWalletConnectUri } from "./getWalletConnectUri.js";
|
|
1
|
+
export { getWalletConnectConnector } from "./getWalletConnectConnector.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/wallets-helpers",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-alpha.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,16 +34,19 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "yarn run -T tsdown",
|
|
36
36
|
"dev": "yarn run -T tsdown --watch",
|
|
37
|
-
"lint": "
|
|
38
|
-
"
|
|
37
|
+
"lint": "yarn run -T eslint .",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"typecheck": "yarn run -T tsc --noEmit"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@types/ua-parser-js": "0.7.39",
|
|
43
|
+
"mipd": "0.0.7",
|
|
42
44
|
"ua-parser-js": "1.0.37"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
47
|
"build-config": "*",
|
|
46
|
-
"
|
|
48
|
+
"react": "18.2.0",
|
|
49
|
+
"vitest": "^4.1.11",
|
|
47
50
|
"wagmi": ">=3.6"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getWalletConnectUri.d.ts","sourceRoot":"","sources":["../../src/walletconnect/getWalletConnectUri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,eAAO,MAAM,mBAAmB,cAAqB,SAAS,oBAM7D,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
};
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { getWalletConnectUri };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/walletconnect/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
|