@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.
Files changed (40) hide show
  1. package/dist/{DepositModalReown-GXY65HZP.mjs → DepositModalReown-2S76TEXU.mjs} +9 -6
  2. package/dist/{DepositModalReown-HVIEA6YA.cjs → DepositModalReown-4NV6JM2U.cjs} +12 -9
  3. package/dist/{QRCode-SMMYPUQC.cjs → QRCode-KG47KTGX.cjs} +1 -1
  4. package/dist/{QRCode-YMQTKSSK.mjs → QRCode-YJ3EGWQS.mjs} +1 -1
  5. package/dist/{WithdrawModalReown-O6V6KRH6.mjs → WithdrawModalReown-QEQPCSWT.mjs} +4 -4
  6. package/dist/{WithdrawModalReown-4M3PBY2T.cjs → WithdrawModalReown-Z5JVENP6.cjs} +7 -7
  7. package/dist/{chunk-Y3RA3YGA.cjs → chunk-2TWQGPPB.cjs} +1323 -590
  8. package/dist/chunk-7JIDIX27.cjs +554 -0
  9. package/dist/{chunk-FKPTIHU7.mjs → chunk-7MZNQ4C2.mjs} +76 -351
  10. package/dist/{chunk-YQFH2WSW.cjs → chunk-FGVSNARE.cjs} +55 -25
  11. package/dist/{chunk-7SYZG47X.cjs → chunk-HUPEN2T5.cjs} +2820 -1509
  12. package/dist/{chunk-U5QIFNG4.mjs → chunk-N5NOJ4ZV.mjs} +2746 -1435
  13. package/dist/{chunk-5YXAQB6A.mjs → chunk-QXIJLRKC.mjs} +56 -26
  14. package/dist/chunk-SZIYS42B.mjs +554 -0
  15. package/dist/{chunk-UIHAYD7J.mjs → chunk-WVE3JN3C.mjs} +1308 -575
  16. package/dist/{chunk-Z2SIC2TH.cjs → chunk-YI63OMXN.cjs} +157 -432
  17. package/dist/constants-DqVn968d.d.cts +52 -0
  18. package/dist/constants-DqVn968d.d.ts +52 -0
  19. package/dist/constants.cjs +8 -2
  20. package/dist/constants.d.cts +17 -48
  21. package/dist/constants.d.ts +17 -48
  22. package/dist/constants.mjs +7 -1
  23. package/dist/deposit.cjs +4 -4
  24. package/dist/deposit.d.cts +2 -2
  25. package/dist/deposit.d.ts +2 -2
  26. package/dist/deposit.mjs +3 -3
  27. package/dist/index.cjs +16 -7
  28. package/dist/index.d.cts +2 -2
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.mjs +16 -7
  31. package/dist/styles.css +656 -207
  32. package/dist/{types-DRou84ZM.d.cts → types-D6wrO4Ow.d.cts} +33 -8
  33. package/dist/{types-DRou84ZM.d.ts → types-D6wrO4Ow.d.ts} +33 -8
  34. package/dist/withdraw.cjs +4 -4
  35. package/dist/withdraw.d.cts +2 -2
  36. package/dist/withdraw.d.ts +2 -2
  37. package/dist/withdraw.mjs +3 -3
  38. package/package.json +5 -5
  39. package/dist/chunk-EEHUOFIW.mjs +0 -524
  40. package/dist/chunk-XCAF6B3D.cjs +0 -524
@@ -1,4 +1,12 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core/reown.tsx
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunk2TWQGPPBcjs = require('./chunk-2TWQGPPB.cjs');
4
+
5
+
6
+
7
+ var _chunk7JIDIX27cjs = require('./chunk-7JIDIX27.cjs');
8
+
9
+ // src/core/reown.tsx
2
10
  var _react = require('react');
3
11
  var _reactquery = require('@tanstack/react-query');
4
12
  var _appkitadapterwagmi = require('@reown/appkit-adapter-wagmi');
@@ -11,7 +19,12 @@ var _wagmi = require('wagmi');
11
19
 
12
20
 
13
21
 
22
+
14
23
  var _react3 = require('@reown/appkit/react');
24
+ var _networks = require('@reown/appkit/networks');
25
+
26
+
27
+ // src/core/reown-networks.ts
15
28
 
16
29
 
17
30
 
@@ -20,17 +33,33 @@ var _react3 = require('@reown/appkit/react');
20
33
 
21
34
 
22
35
 
23
- var _networks = require('@reown/appkit/networks');
24
36
 
37
+
38
+ var APPKIT_NETWORK_BY_ID = {
39
+ [_networks.mainnet.id]: _networks.mainnet,
40
+ [_networks.optimism.id]: _networks.optimism,
41
+ [_networks.polygon.id]: _networks.polygon,
42
+ [_networks.arbitrum.id]: _networks.arbitrum,
43
+ [_networks.base.id]: _networks.base,
44
+ [_networks.bsc.id]: _networks.bsc,
45
+ [_networks.soneium.id]: _networks.soneium,
46
+ [_networks.plasma.id]: _networks.plasma
47
+ };
48
+ var EVM_NETWORKS = _chunk7JIDIX27cjs.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
  var _jsxruntime = require('react/jsx-runtime');
26
- var EVM_NETWORKS = [
27
- _networks.mainnet,
28
- _networks.base,
29
- _networks.arbitrum,
30
- _networks.optimism,
31
- _networks.polygon,
32
- _networks.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__ */ _jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children }) });
80
109
  }
81
- async function disconnectWallet() {
82
- if (!_react3.modal) {
83
- console.warn(
84
- "[rhinestone] disconnectWallet called before the modal provider mounted; no-op."
85
- );
86
- return;
87
- }
88
- await _react3.modal.disconnect();
89
- }
90
110
  function useReownWallet() {
91
111
  const { open } = _react3.useAppKit.call(void 0, );
92
112
  const { address, isConnected, caipAddress } = _react3.useAppKitAccount.call(void 0, );
@@ -94,6 +114,7 @@ function useReownWallet() {
94
114
  const { walletInfo } = _react3.useWalletInfo.call(void 0, );
95
115
  const { data: walletClient } = _wagmi.useWalletClient.call(void 0, );
96
116
  const publicClient = _wagmi.usePublicClient.call(void 0, );
117
+ const { switchNetwork } = _react3.useAppKitNetwork.call(void 0, );
97
118
  const { switchChainAsync } = _wagmi.useSwitchChain.call(void 0, );
98
119
  const isSolana = _nullishCoalesce(_optionalChain([caipAddress, 'optionalAccess', _3 => _3.startsWith, 'call', _4 => _4("solana:")]), () => ( false));
99
120
  const solanaAddress = isSolana ? _optionalChain([caipAddress, 'optionalAccess', _5 => _5.split, 'call', _6 => _6(":"), 'access', _7 => _7.slice, 'call', _8 => _8(2), 'access', _9 => _9.join, 'call', _10 => _10(":")]) : void 0;
@@ -116,11 +137,21 @@ function useReownWallet() {
116
137
  void _optionalChain([_react3.modal, 'optionalAccess', _12 => _12.disconnect, 'call', _13 => _13()]);
117
138
  },
118
139
  switchChain: async (chainId) => {
119
- if (_optionalChain([walletClient, 'optionalAccess', _14 => _14.switchChain])) {
120
- await walletClient.switchChain({ id: chainId });
121
- return;
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 (_chunk2TWQGPPBcjs.isUnsupportedChainSwitchError.call(void 0, err)) {
149
+ throw new Error(
150
+ `Switch to ${_chunk7JIDIX27cjs.getChainName.call(void 0, chainId)} in your wallet to continue`
151
+ );
152
+ }
153
+ throw err;
122
154
  }
123
- await switchChainAsync({ chainId });
124
155
  }
125
156
  };
126
157
  }
@@ -128,5 +159,4 @@ function useReownWallet() {
128
159
 
129
160
 
130
161
 
131
-
132
- exports.ReownWalletProvider = ReownWalletProvider; exports.disconnectWallet = disconnectWallet; exports.useReownWallet = useReownWallet;
162
+ exports.ReownWalletProvider = ReownWalletProvider; exports.useReownWallet = useReownWallet;