@rhinestone/deposit-modal 0.0.0-dev-20260608080045

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.
Files changed (40) hide show
  1. package/README.md +134 -0
  2. package/dist/DepositModalReown-6SUEC5IU.mjs +60 -0
  3. package/dist/DepositModalReown-DNW4GH6L.cjs +60 -0
  4. package/dist/QRCode-5DXFNKI2.cjs +58 -0
  5. package/dist/QRCode-WUC652SH.mjs +58 -0
  6. package/dist/WithdrawModalReown-7UAGSOSU.mjs +37 -0
  7. package/dist/WithdrawModalReown-OUWBSKSM.cjs +37 -0
  8. package/dist/caip-CsslyHGL.d.cts +62 -0
  9. package/dist/caip-CsslyHGL.d.ts +62 -0
  10. package/dist/chunk-2SMS542Q.cjs +1654 -0
  11. package/dist/chunk-33H6O5UU.cjs +162 -0
  12. package/dist/chunk-6YRDD462.mjs +614 -0
  13. package/dist/chunk-GPSBM66J.mjs +162 -0
  14. package/dist/chunk-KAWJABTW.mjs +3765 -0
  15. package/dist/chunk-KJ2RR2D4.mjs +7619 -0
  16. package/dist/chunk-MILJQWPT.cjs +614 -0
  17. package/dist/chunk-RABZINV3.cjs +3765 -0
  18. package/dist/chunk-TKQYTBU6.mjs +1654 -0
  19. package/dist/chunk-VVJAIMKB.cjs +7619 -0
  20. package/dist/constants.cjs +70 -0
  21. package/dist/constants.d.cts +21 -0
  22. package/dist/constants.d.ts +21 -0
  23. package/dist/constants.mjs +70 -0
  24. package/dist/deposit.cjs +8 -0
  25. package/dist/deposit.d.cts +11 -0
  26. package/dist/deposit.d.ts +11 -0
  27. package/dist/deposit.mjs +8 -0
  28. package/dist/index.cjs +86 -0
  29. package/dist/index.d.cts +11 -0
  30. package/dist/index.d.ts +11 -0
  31. package/dist/index.mjs +86 -0
  32. package/dist/styles.css +5143 -0
  33. package/dist/styles.d.ts +3 -0
  34. package/dist/types-BMcGO5k_.d.cts +432 -0
  35. package/dist/types-BMcGO5k_.d.ts +432 -0
  36. package/dist/withdraw.cjs +8 -0
  37. package/dist/withdraw.d.cts +11 -0
  38. package/dist/withdraw.d.ts +11 -0
  39. package/dist/withdraw.mjs +8 -0
  40. package/package.json +190 -0
@@ -0,0 +1,162 @@
1
+ import {
2
+ isUnsupportedChainSwitchError
3
+ } from "./chunk-KAWJABTW.mjs";
4
+ import {
5
+ SUPPORTED_CHAINS,
6
+ getChainName
7
+ } from "./chunk-6YRDD462.mjs";
8
+
9
+ // src/core/reown.tsx
10
+ import { useState } from "react";
11
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
12
+ import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
13
+ import { SolanaAdapter } from "@reown/appkit-adapter-solana";
14
+ import { WagmiProvider } from "wagmi";
15
+ import {
16
+ createAppKit,
17
+ useAppKit,
18
+ useAppKitAccount,
19
+ useAppKitNetwork,
20
+ useAppKitState,
21
+ useWalletInfo,
22
+ modal
23
+ } from "@reown/appkit/react";
24
+ import { solana } from "@reown/appkit/networks";
25
+ import { useWalletClient, usePublicClient, useSwitchChain } from "wagmi";
26
+
27
+ // src/core/reown-networks.ts
28
+ import {
29
+ mainnet,
30
+ optimism,
31
+ polygon,
32
+ arbitrum,
33
+ base,
34
+ bsc,
35
+ soneium,
36
+ plasma
37
+ } from "@reown/appkit/networks";
38
+ var APPKIT_NETWORK_BY_ID = {
39
+ [mainnet.id]: mainnet,
40
+ [optimism.id]: optimism,
41
+ [polygon.id]: polygon,
42
+ [arbitrum.id]: arbitrum,
43
+ [base.id]: base,
44
+ [bsc.id]: bsc,
45
+ [soneium.id]: soneium,
46
+ [plasma.id]: plasma
47
+ };
48
+ var EVM_NETWORKS = SUPPORTED_CHAINS.map((chain) => {
49
+ const network = APPKIT_NETWORK_BY_ID[chain.id];
50
+ if (!network) {
51
+ throw new Error(
52
+ `[rhinestone] No AppKit network registered for supported chain ${chain.id} (${chain.name}). Add it to APPKIT_NETWORK_BY_ID in reown-networks.ts.`
53
+ );
54
+ }
55
+ return network;
56
+ });
57
+ function getAppKitNetwork(chainId) {
58
+ return APPKIT_NETWORK_BY_ID[chainId];
59
+ }
60
+
61
+ // src/core/reown.tsx
62
+ import { jsx } from "react/jsx-runtime";
63
+ var cachedAdapter = null;
64
+ var cachedAdapterKey = null;
65
+ function mapTheme(theme) {
66
+ const themeMode = theme?.mode === "light" ? "light" : "dark";
67
+ const themeVariables = {};
68
+ if (theme?.ctaColor) {
69
+ themeVariables["--apkt-accent"] = theme.ctaColor;
70
+ }
71
+ return { themeMode, themeVariables };
72
+ }
73
+ function getOrCreateAdapter(projectId, enableSolana, theme) {
74
+ const adapterKey = `${projectId}:${enableSolana ? "solana" : "evm"}`;
75
+ if (cachedAdapter && cachedAdapterKey === adapterKey) return cachedAdapter;
76
+ cachedAdapter = new WagmiAdapter({
77
+ networks: EVM_NETWORKS,
78
+ projectId
79
+ });
80
+ cachedAdapterKey = adapterKey;
81
+ const { themeMode, themeVariables } = mapTheme(theme);
82
+ const adapters = enableSolana ? [cachedAdapter, new SolanaAdapter()] : [cachedAdapter];
83
+ const networks = enableSolana ? [...EVM_NETWORKS, solana] : EVM_NETWORKS;
84
+ createAppKit({
85
+ adapters,
86
+ networks,
87
+ projectId,
88
+ themeMode,
89
+ themeVariables,
90
+ features: {
91
+ connectMethodsOrder: ["wallet"],
92
+ email: false,
93
+ socials: false
94
+ },
95
+ allowUnsupportedChain: true
96
+ });
97
+ return cachedAdapter;
98
+ }
99
+ function ReownWalletProvider({
100
+ projectId,
101
+ theme,
102
+ enableSolana = true,
103
+ children
104
+ }) {
105
+ const [queryClient] = useState(() => new QueryClient());
106
+ const adapter = getOrCreateAdapter(projectId, enableSolana, theme);
107
+ const config = adapter.wagmiConfig;
108
+ return /* @__PURE__ */ jsx(WagmiProvider, { config, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) });
109
+ }
110
+ function useReownWallet() {
111
+ const { open } = useAppKit();
112
+ const { address, isConnected, caipAddress } = useAppKitAccount();
113
+ const { initialized, loading } = useAppKitState();
114
+ const { walletInfo } = useWalletInfo();
115
+ const { data: walletClient } = useWalletClient();
116
+ const publicClient = usePublicClient();
117
+ const { switchNetwork } = useAppKitNetwork();
118
+ const { switchChainAsync } = useSwitchChain();
119
+ const isSolana = caipAddress?.startsWith("solana:") ?? false;
120
+ const solanaAddress = isSolana ? caipAddress?.split(":").slice(2).join(":") : void 0;
121
+ return {
122
+ walletClient: isSolana ? void 0 : walletClient ?? void 0,
123
+ publicClient: isSolana ? void 0 : publicClient ?? void 0,
124
+ address: isSolana ? void 0 : address,
125
+ caipAddress,
126
+ isConnected,
127
+ isReady: initialized && !loading,
128
+ icon: walletInfo?.icon,
129
+ isSolana,
130
+ solanaAddress,
131
+ solanaProvider: void 0,
132
+ // Populated by DepositModalReown via useAppKitProvider
133
+ openConnect: () => {
134
+ void open({ view: "Connect" });
135
+ },
136
+ disconnect: () => {
137
+ void modal?.disconnect();
138
+ },
139
+ switchChain: async (chainId) => {
140
+ const target = getAppKitNetwork(chainId);
141
+ try {
142
+ if (target) {
143
+ await switchNetwork(target);
144
+ } else {
145
+ await switchChainAsync({ chainId });
146
+ }
147
+ } catch (err) {
148
+ if (isUnsupportedChainSwitchError(err)) {
149
+ throw new Error(
150
+ `Switch to ${getChainName(chainId)} in your wallet to continue`
151
+ );
152
+ }
153
+ throw err;
154
+ }
155
+ }
156
+ };
157
+ }
158
+
159
+ export {
160
+ ReownWalletProvider,
161
+ useReownWallet
162
+ };