@rhinestone/deposit-modal 0.3.0-alpha.0 → 0.3.0-alpha.10
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/dist/{DepositModalReown-GXY65HZP.mjs → DepositModalReown-2S76TEXU.mjs} +9 -6
- package/dist/{DepositModalReown-HVIEA6YA.cjs → DepositModalReown-4NV6JM2U.cjs} +12 -9
- package/dist/{QRCode-SMMYPUQC.cjs → QRCode-KG47KTGX.cjs} +1 -1
- package/dist/{QRCode-YMQTKSSK.mjs → QRCode-YJ3EGWQS.mjs} +1 -1
- package/dist/{WithdrawModalReown-O6V6KRH6.mjs → WithdrawModalReown-QEQPCSWT.mjs} +4 -4
- package/dist/{WithdrawModalReown-4M3PBY2T.cjs → WithdrawModalReown-Z5JVENP6.cjs} +7 -7
- package/dist/{chunk-Y3RA3YGA.cjs → chunk-2TWQGPPB.cjs} +1323 -590
- package/dist/chunk-7JIDIX27.cjs +554 -0
- package/dist/{chunk-FKPTIHU7.mjs → chunk-7MZNQ4C2.mjs} +76 -351
- package/dist/{chunk-YQFH2WSW.cjs → chunk-FGVSNARE.cjs} +55 -25
- package/dist/{chunk-7SYZG47X.cjs → chunk-HUPEN2T5.cjs} +2820 -1509
- package/dist/{chunk-U5QIFNG4.mjs → chunk-N5NOJ4ZV.mjs} +2746 -1435
- package/dist/{chunk-5YXAQB6A.mjs → chunk-QXIJLRKC.mjs} +56 -26
- package/dist/chunk-SZIYS42B.mjs +554 -0
- package/dist/{chunk-UIHAYD7J.mjs → chunk-WVE3JN3C.mjs} +1308 -575
- package/dist/{chunk-Z2SIC2TH.cjs → chunk-YI63OMXN.cjs} +157 -432
- package/dist/constants-DqVn968d.d.cts +52 -0
- package/dist/constants-DqVn968d.d.ts +52 -0
- package/dist/constants.cjs +8 -2
- package/dist/constants.d.cts +17 -48
- package/dist/constants.d.ts +17 -48
- package/dist/constants.mjs +7 -1
- package/dist/deposit.cjs +4 -4
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +3 -3
- package/dist/index.cjs +16 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +16 -7
- package/dist/styles.css +656 -207
- package/dist/{types-DRou84ZM.d.cts → types-D6wrO4Ow.d.cts} +33 -8
- package/dist/{types-DRou84ZM.d.ts → types-D6wrO4Ow.d.ts} +33 -8
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +3 -3
- package/package.json +5 -5
- package/dist/chunk-EEHUOFIW.mjs +0 -524
- package/dist/chunk-XCAF6B3D.cjs +0 -524
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isUnsupportedChainSwitchError
|
|
3
|
+
} from "./chunk-WVE3JN3C.mjs";
|
|
4
|
+
import {
|
|
5
|
+
SUPPORTED_CHAINS,
|
|
6
|
+
getChainName
|
|
7
|
+
} from "./chunk-SZIYS42B.mjs";
|
|
8
|
+
|
|
1
9
|
// src/core/reown.tsx
|
|
2
10
|
import { useState } from "react";
|
|
3
11
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
@@ -8,29 +16,50 @@ import {
|
|
|
8
16
|
createAppKit,
|
|
9
17
|
useAppKit,
|
|
10
18
|
useAppKitAccount,
|
|
19
|
+
useAppKitNetwork,
|
|
11
20
|
useAppKitState,
|
|
12
21
|
useWalletInfo,
|
|
13
22
|
modal
|
|
14
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
|
|
15
28
|
import {
|
|
16
29
|
mainnet,
|
|
17
|
-
base,
|
|
18
|
-
arbitrum,
|
|
19
30
|
optimism,
|
|
20
31
|
polygon,
|
|
32
|
+
arbitrum,
|
|
33
|
+
base,
|
|
21
34
|
bsc,
|
|
22
|
-
|
|
35
|
+
soneium,
|
|
36
|
+
plasma
|
|
23
37
|
} from "@reown/appkit/networks";
|
|
24
|
-
|
|
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
|
|
25
62
|
import { jsx } from "react/jsx-runtime";
|
|
26
|
-
var EVM_NETWORKS = [
|
|
27
|
-
mainnet,
|
|
28
|
-
base,
|
|
29
|
-
arbitrum,
|
|
30
|
-
optimism,
|
|
31
|
-
polygon,
|
|
32
|
-
bsc
|
|
33
|
-
];
|
|
34
63
|
var cachedAdapter = null;
|
|
35
64
|
var cachedAdapterKey = null;
|
|
36
65
|
function mapTheme(theme) {
|
|
@@ -78,15 +107,6 @@ function ReownWalletProvider({
|
|
|
78
107
|
const config = adapter.wagmiConfig;
|
|
79
108
|
return /* @__PURE__ */ jsx(WagmiProvider, { config, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) });
|
|
80
109
|
}
|
|
81
|
-
async function disconnectWallet() {
|
|
82
|
-
if (!modal) {
|
|
83
|
-
console.warn(
|
|
84
|
-
"[rhinestone] disconnectWallet called before the modal provider mounted; no-op."
|
|
85
|
-
);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
await modal.disconnect();
|
|
89
|
-
}
|
|
90
110
|
function useReownWallet() {
|
|
91
111
|
const { open } = useAppKit();
|
|
92
112
|
const { address, isConnected, caipAddress } = useAppKitAccount();
|
|
@@ -94,6 +114,7 @@ function useReownWallet() {
|
|
|
94
114
|
const { walletInfo } = useWalletInfo();
|
|
95
115
|
const { data: walletClient } = useWalletClient();
|
|
96
116
|
const publicClient = usePublicClient();
|
|
117
|
+
const { switchNetwork } = useAppKitNetwork();
|
|
97
118
|
const { switchChainAsync } = useSwitchChain();
|
|
98
119
|
const isSolana = caipAddress?.startsWith("solana:") ?? false;
|
|
99
120
|
const solanaAddress = isSolana ? caipAddress?.split(":").slice(2).join(":") : void 0;
|
|
@@ -116,17 +137,26 @@ function useReownWallet() {
|
|
|
116
137
|
void modal?.disconnect();
|
|
117
138
|
},
|
|
118
139
|
switchChain: async (chainId) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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;
|
|
122
154
|
}
|
|
123
|
-
await switchChainAsync({ chainId });
|
|
124
155
|
}
|
|
125
156
|
};
|
|
126
157
|
}
|
|
127
158
|
|
|
128
159
|
export {
|
|
129
160
|
ReownWalletProvider,
|
|
130
|
-
disconnectWallet,
|
|
131
161
|
useReownWallet
|
|
132
162
|
};
|