@rhinestone/deposit-modal 0.3.0 → 0.3.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.
Files changed (40) hide show
  1. package/dist/{DepositModalReown-6SUEC5IU.mjs → DepositModalReown-G7UX4IBZ.mjs} +5 -3
  2. package/dist/{DepositModalReown-DNW4GH6L.cjs → DepositModalReown-MECHBE6P.cjs} +8 -6
  3. package/dist/{WithdrawModalReown-7UAGSOSU.mjs → WithdrawModalReown-CUJAFUQM.mjs} +4 -3
  4. package/dist/{WithdrawModalReown-OUWBSKSM.cjs → WithdrawModalReown-WJ6VBZKK.cjs} +7 -6
  5. package/dist/{caip-CrQ2KKU-.d.cts → caip-CsslyHGL.d.cts} +1 -1
  6. package/dist/{caip-CrQ2KKU-.d.ts → caip-CsslyHGL.d.ts} +1 -1
  7. package/dist/{chunk-KAWJABTW.mjs → chunk-3C35DVPE.mjs} +2 -291
  8. package/dist/chunk-AJHFNHG3.cjs +295 -0
  9. package/dist/chunk-BAEB5AFZ.mjs +212 -0
  10. package/dist/{chunk-TKQYTBU6.mjs → chunk-DZQD3DAV.mjs} +7 -5
  11. package/dist/{chunk-2SMS542Q.cjs → chunk-LEL6GMEQ.cjs} +56 -54
  12. package/dist/{chunk-RABZINV3.cjs → chunk-MQIJZNTP.cjs} +3 -292
  13. package/dist/{chunk-KJ2RR2D4.mjs → chunk-QYSCCX4K.mjs} +534 -413
  14. package/dist/chunk-R5CPOBCF.cjs +212 -0
  15. package/dist/{chunk-GPSBM66J.mjs → chunk-R5WDHHVM.mjs} +1 -1
  16. package/dist/{chunk-VVJAIMKB.cjs → chunk-SPUZLWQS.cjs} +783 -662
  17. package/dist/chunk-TQ2AYMWS.mjs +295 -0
  18. package/dist/{chunk-33H6O5UU.cjs → chunk-ULEAK63T.cjs} +2 -2
  19. package/dist/constants.d.cts +1 -1
  20. package/dist/constants.d.ts +1 -1
  21. package/dist/deposit.cjs +5 -3
  22. package/dist/deposit.d.cts +4 -4
  23. package/dist/deposit.d.ts +4 -4
  24. package/dist/deposit.mjs +4 -2
  25. package/dist/index.cjs +6 -4
  26. package/dist/index.d.cts +4 -3
  27. package/dist/index.d.ts +4 -3
  28. package/dist/index.mjs +5 -3
  29. package/dist/polymarket.cjs +64 -0
  30. package/dist/polymarket.d.cts +57 -0
  31. package/dist/polymarket.d.ts +57 -0
  32. package/dist/polymarket.mjs +64 -0
  33. package/dist/styles.css +34 -0
  34. package/dist/{types-BMcGO5k_.d.cts → types-RzfAD14B.d.cts} +9 -0
  35. package/dist/{types-BMcGO5k_.d.ts → types-RzfAD14B.d.ts} +9 -0
  36. package/dist/withdraw.cjs +4 -3
  37. package/dist/withdraw.d.cts +4 -4
  38. package/dist/withdraw.d.ts +4 -4
  39. package/dist/withdraw.mjs +3 -2
  40. package/package.json +15 -2
@@ -0,0 +1,295 @@
1
+ import {
2
+ getChainName
3
+ } from "./chunk-6YRDD462.mjs";
4
+
5
+ // src/core/safe.ts
6
+ import {
7
+ concat,
8
+ encodeFunctionData,
9
+ erc20Abi,
10
+ hashTypedData,
11
+ pad,
12
+ parseEventLogs,
13
+ toHex,
14
+ zeroAddress
15
+ } from "viem";
16
+ var SAFE_ABI = [
17
+ {
18
+ type: "function",
19
+ name: "isOwner",
20
+ stateMutability: "view",
21
+ inputs: [{ name: "owner", type: "address" }],
22
+ outputs: [{ name: "", type: "bool" }]
23
+ },
24
+ {
25
+ type: "function",
26
+ name: "nonce",
27
+ stateMutability: "view",
28
+ inputs: [],
29
+ outputs: [{ type: "uint256" }]
30
+ },
31
+ {
32
+ type: "function",
33
+ name: "execTransaction",
34
+ stateMutability: "payable",
35
+ inputs: [
36
+ { name: "to", type: "address" },
37
+ { name: "value", type: "uint256" },
38
+ { name: "data", type: "bytes" },
39
+ { name: "operation", type: "uint8" },
40
+ { name: "safeTxGas", type: "uint256" },
41
+ { name: "baseGas", type: "uint256" },
42
+ { name: "gasPrice", type: "uint256" },
43
+ { name: "gasToken", type: "address" },
44
+ { name: "refundReceiver", type: "address" },
45
+ { name: "signatures", type: "bytes" }
46
+ ],
47
+ outputs: [{ name: "success", type: "bool" }]
48
+ },
49
+ {
50
+ type: "event",
51
+ name: "ExecutionSuccess",
52
+ inputs: [
53
+ { name: "txHash", type: "bytes32", indexed: true },
54
+ { name: "payment", type: "uint256", indexed: false }
55
+ ],
56
+ anonymous: false
57
+ },
58
+ {
59
+ type: "event",
60
+ name: "ExecutionFailure",
61
+ inputs: [
62
+ { name: "txHash", type: "bytes32", indexed: true },
63
+ { name: "payment", type: "uint256", indexed: false }
64
+ ],
65
+ anonymous: false
66
+ }
67
+ ];
68
+ async function executeSafeEthTransfer(params) {
69
+ const {
70
+ walletClient,
71
+ publicClient,
72
+ safeAddress,
73
+ recipient,
74
+ amount,
75
+ chainId
76
+ } = params;
77
+ const account = walletClient.account;
78
+ const chain = walletClient.chain;
79
+ if (!account || !chain) {
80
+ throw new Error("Wallet not connected");
81
+ }
82
+ if (chain.id !== chainId) {
83
+ throw new Error(`Switch to ${getChainName(chainId)} to sign`);
84
+ }
85
+ const isOwner = await publicClient.readContract({
86
+ address: safeAddress,
87
+ abi: SAFE_ABI,
88
+ functionName: "isOwner",
89
+ args: [account.address]
90
+ });
91
+ if (!isOwner) {
92
+ throw new Error("Connected wallet is not a Safe owner");
93
+ }
94
+ const safeTx = {
95
+ to: recipient,
96
+ value: amount,
97
+ data: "0x",
98
+ operation: 0,
99
+ safeTxGas: 0n,
100
+ baseGas: 0n,
101
+ gasPrice: 0n,
102
+ gasToken: zeroAddress,
103
+ refundReceiver: zeroAddress
104
+ };
105
+ const signature = concat([
106
+ pad(account.address, { size: 32 }),
107
+ pad(toHex(0), { size: 32 }),
108
+ toHex(1, { size: 1 })
109
+ ]);
110
+ const txHash = await walletClient.writeContract({
111
+ account,
112
+ chain,
113
+ address: safeAddress,
114
+ abi: SAFE_ABI,
115
+ functionName: "execTransaction",
116
+ args: [
117
+ safeTx.to,
118
+ safeTx.value,
119
+ safeTx.data,
120
+ safeTx.operation,
121
+ safeTx.safeTxGas,
122
+ safeTx.baseGas,
123
+ safeTx.gasPrice,
124
+ safeTx.gasToken,
125
+ safeTx.refundReceiver,
126
+ signature
127
+ ]
128
+ });
129
+ const receipt = await publicClient.waitForTransactionReceipt({
130
+ hash: txHash
131
+ });
132
+ const safeLogs = receipt.logs.filter(
133
+ (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
134
+ );
135
+ const parsed = parseEventLogs({
136
+ abi: SAFE_ABI,
137
+ logs: safeLogs,
138
+ strict: false
139
+ });
140
+ const failed = parsed.find((log) => log.eventName === "ExecutionFailure");
141
+ if (failed) {
142
+ throw new Error("Safe transaction failed");
143
+ }
144
+ const succeeded = parsed.find((log) => log.eventName === "ExecutionSuccess");
145
+ if (!succeeded) {
146
+ throw new Error("Safe transaction status unavailable");
147
+ }
148
+ return { txHash };
149
+ }
150
+ async function executeSafeErc20Transfer(params) {
151
+ const {
152
+ walletClient,
153
+ publicClient,
154
+ safeAddress,
155
+ tokenAddress,
156
+ recipient,
157
+ amount,
158
+ chainId
159
+ } = params;
160
+ const account = walletClient.account;
161
+ const chain = walletClient.chain;
162
+ if (!account || !chain) {
163
+ throw new Error("Wallet not connected");
164
+ }
165
+ if (chain.id !== chainId) {
166
+ throw new Error(`Switch to ${getChainName(chainId)} to sign`);
167
+ }
168
+ const isOwner = await publicClient.readContract({
169
+ address: safeAddress,
170
+ abi: SAFE_ABI,
171
+ functionName: "isOwner",
172
+ args: [account.address]
173
+ });
174
+ if (!isOwner) {
175
+ throw new Error("Connected wallet is not a Safe owner");
176
+ }
177
+ const data = encodeFunctionData({
178
+ abi: erc20Abi,
179
+ functionName: "transfer",
180
+ args: [recipient, amount]
181
+ });
182
+ const safeTx = {
183
+ to: tokenAddress,
184
+ value: 0n,
185
+ data,
186
+ operation: 0,
187
+ safeTxGas: 0n,
188
+ baseGas: 0n,
189
+ gasPrice: 0n,
190
+ gasToken: zeroAddress,
191
+ refundReceiver: zeroAddress
192
+ };
193
+ const signature = concat([
194
+ pad(account.address, { size: 32 }),
195
+ pad(toHex(0), { size: 32 }),
196
+ toHex(1, { size: 1 })
197
+ ]);
198
+ const txHash = await walletClient.writeContract({
199
+ account,
200
+ chain,
201
+ address: safeAddress,
202
+ abi: SAFE_ABI,
203
+ functionName: "execTransaction",
204
+ args: [
205
+ safeTx.to,
206
+ safeTx.value,
207
+ safeTx.data,
208
+ safeTx.operation,
209
+ safeTx.safeTxGas,
210
+ safeTx.baseGas,
211
+ safeTx.gasPrice,
212
+ safeTx.gasToken,
213
+ safeTx.refundReceiver,
214
+ signature
215
+ ]
216
+ });
217
+ const receipt = await publicClient.waitForTransactionReceipt({
218
+ hash: txHash
219
+ });
220
+ const safeLogs = receipt.logs.filter(
221
+ (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
222
+ );
223
+ const parsed = parseEventLogs({
224
+ abi: SAFE_ABI,
225
+ logs: safeLogs,
226
+ strict: false
227
+ });
228
+ const failed = parsed.find((log) => log.eventName === "ExecutionFailure");
229
+ if (failed) {
230
+ throw new Error("Safe transaction failed");
231
+ }
232
+ const succeeded = parsed.find((log) => log.eventName === "ExecutionSuccess");
233
+ if (!succeeded) {
234
+ throw new Error("Safe transaction status unavailable");
235
+ }
236
+ return { txHash };
237
+ }
238
+ var SAFE_TX_TYPES = {
239
+ SafeTx: [
240
+ { name: "to", type: "address" },
241
+ { name: "value", type: "uint256" },
242
+ { name: "data", type: "bytes" },
243
+ { name: "operation", type: "uint8" },
244
+ { name: "safeTxGas", type: "uint256" },
245
+ { name: "baseGas", type: "uint256" },
246
+ { name: "gasPrice", type: "uint256" },
247
+ { name: "gasToken", type: "address" },
248
+ { name: "refundReceiver", type: "address" },
249
+ { name: "nonce", type: "uint256" }
250
+ ]
251
+ };
252
+ async function buildSafeTransaction(params) {
253
+ const { publicClient, safeAddress, to, value, data, chainId } = params;
254
+ const nonce = await publicClient.readContract({
255
+ address: safeAddress,
256
+ abi: SAFE_ABI,
257
+ functionName: "nonce"
258
+ });
259
+ const message = {
260
+ to,
261
+ value,
262
+ data,
263
+ operation: 0,
264
+ safeTxGas: 0n,
265
+ baseGas: 0n,
266
+ gasPrice: 0n,
267
+ gasToken: zeroAddress,
268
+ refundReceiver: zeroAddress,
269
+ nonce
270
+ };
271
+ const safeTxHash = hashTypedData({
272
+ domain: { chainId, verifyingContract: safeAddress },
273
+ types: SAFE_TX_TYPES,
274
+ primaryType: "SafeTx",
275
+ message
276
+ });
277
+ return {
278
+ chainId,
279
+ safeAddress,
280
+ safeTxHash,
281
+ typedData: {
282
+ domain: { chainId, verifyingContract: safeAddress },
283
+ types: SAFE_TX_TYPES,
284
+ primaryType: "SafeTx",
285
+ message
286
+ }
287
+ };
288
+ }
289
+
290
+ export {
291
+ SAFE_ABI,
292
+ executeSafeEthTransfer,
293
+ executeSafeErc20Transfer,
294
+ buildSafeTransaction
295
+ };
@@ -1,6 +1,6 @@
1
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
2
 
3
- var _chunkRABZINV3cjs = require('./chunk-RABZINV3.cjs');
3
+ var _chunkMQIJZNTPcjs = require('./chunk-MQIJZNTP.cjs');
4
4
 
5
5
 
6
6
 
@@ -145,7 +145,7 @@ function useReownWallet() {
145
145
  await switchChainAsync({ chainId });
146
146
  }
147
147
  } catch (err) {
148
- if (_chunkRABZINV3cjs.isUnsupportedChainSwitchError.call(void 0, err)) {
148
+ if (_chunkMQIJZNTPcjs.isUnsupportedChainSwitchError.call(void 0, err)) {
149
149
  throw new Error(
150
150
  `Switch to ${_chunkMILJQWPTcjs.getChainName.call(void 0, chainId)} in your wallet to continue`
151
151
  );
@@ -1,4 +1,4 @@
1
- export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, z as SupportedTokenOption, d as chainRegistry, f as findChainIdForToken, g as getChainBadge, e as getChainIcon, h as getChainId, i as getChainName, j as getChainObject, k as getExplorerName, l as getExplorerTxUrl, m as getExplorerUrl, n as getSupportedChainIds, o as getSupportedTargetTokens, p as getSupportedTokenSymbolsForChain, q as getTargetTokenSymbolsForChain, r as getTokenAddress, s as getTokenDecimals, t as getTokenDecimalsByAddress, u as getTokenIcon, v as getTokenSymbol, w as getUsdcAddress, x as getUsdcDecimals, y as isSupportedTokenAddressForChain } from './caip-CrQ2KKU-.cjs';
1
+ export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, d as SupportedTokenOption, e as chainRegistry, f as findChainIdForToken, g as getChainBadge, h as getChainIcon, i as getChainId, j as getChainName, k as getChainObject, l as getExplorerName, m as getExplorerTxUrl, n as getExplorerUrl, o as getSupportedChainIds, p as getSupportedTargetTokens, q as getSupportedTokenSymbolsForChain, r as getTargetTokenSymbolsForChain, s as getTokenAddress, t as getTokenDecimals, u as getTokenDecimalsByAddress, v as getTokenIcon, w as getTokenSymbol, x as getUsdcAddress, y as getUsdcDecimals, z as isSupportedTokenAddressForChain } from './caip-CsslyHGL.cjs';
2
2
  import 'viem/chains';
3
3
  import 'viem';
4
4
 
@@ -1,4 +1,4 @@
1
- export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, z as SupportedTokenOption, d as chainRegistry, f as findChainIdForToken, g as getChainBadge, e as getChainIcon, h as getChainId, i as getChainName, j as getChainObject, k as getExplorerName, l as getExplorerTxUrl, m as getExplorerUrl, n as getSupportedChainIds, o as getSupportedTargetTokens, p as getSupportedTokenSymbolsForChain, q as getTargetTokenSymbolsForChain, r as getTokenAddress, s as getTokenDecimals, t as getTokenDecimalsByAddress, u as getTokenIcon, v as getTokenSymbol, w as getUsdcAddress, x as getUsdcDecimals, y as isSupportedTokenAddressForChain } from './caip-CrQ2KKU-.js';
1
+ export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, d as SupportedTokenOption, e as chainRegistry, f as findChainIdForToken, g as getChainBadge, h as getChainIcon, i as getChainId, j as getChainName, k as getChainObject, l as getExplorerName, m as getExplorerTxUrl, n as getExplorerUrl, o as getSupportedChainIds, p as getSupportedTargetTokens, q as getSupportedTokenSymbolsForChain, r as getTargetTokenSymbolsForChain, s as getTokenAddress, t as getTokenDecimals, u as getTokenDecimalsByAddress, v as getTokenIcon, w as getTokenSymbol, x as getUsdcAddress, y as getUsdcDecimals, z as isSupportedTokenAddressForChain } from './caip-CsslyHGL.js';
2
2
  import 'viem/chains';
3
3
  import 'viem';
4
4
 
package/dist/deposit.cjs CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkVVJAIMKBcjs = require('./chunk-VVJAIMKB.cjs');
4
- require('./chunk-RABZINV3.cjs');
3
+ var _chunkSPUZLWQScjs = require('./chunk-SPUZLWQS.cjs');
4
+ require('./chunk-R5CPOBCF.cjs');
5
+ require('./chunk-MQIJZNTP.cjs');
6
+ require('./chunk-AJHFNHG3.cjs');
5
7
  require('./chunk-MILJQWPT.cjs');
6
8
 
7
9
 
8
- exports.DepositModal = _chunkVVJAIMKBcjs.DepositModal;
10
+ exports.DepositModal = _chunkSPUZLWQScjs.DepositModal;
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { f as DepositModalProps } from './types-BMcGO5k_.cjs';
3
- export { A as AssetOption, a as ConnectedEventData, D as DappImportsConfig, c as DepositCompleteEventData, d as DepositFailedEventData, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData } from './types-BMcGO5k_.cjs';
1
+ import * as react from 'react';
2
+ import { f as DepositModalProps } from './types-RzfAD14B.cjs';
3
+ export { A as AssetOption, a as ConnectedEventData, D as DappImportsConfig, c as DepositCompleteEventData, d as DepositFailedEventData, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData } from './types-RzfAD14B.cjs';
4
4
  import 'viem';
5
5
 
6
- declare function DepositModal(props: DepositModalProps): react_jsx_runtime.JSX.Element;
6
+ declare function DepositModal(props: DepositModalProps): react.JSX.Element;
7
7
  declare namespace DepositModal {
8
8
  var displayName: string;
9
9
  }
package/dist/deposit.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { f as DepositModalProps } from './types-BMcGO5k_.js';
3
- export { A as AssetOption, a as ConnectedEventData, D as DappImportsConfig, c as DepositCompleteEventData, d as DepositFailedEventData, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData } from './types-BMcGO5k_.js';
1
+ import * as react from 'react';
2
+ import { f as DepositModalProps } from './types-RzfAD14B.js';
3
+ export { A as AssetOption, a as ConnectedEventData, D as DappImportsConfig, c as DepositCompleteEventData, d as DepositFailedEventData, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData } from './types-RzfAD14B.js';
4
4
  import 'viem';
5
5
 
6
- declare function DepositModal(props: DepositModalProps): react_jsx_runtime.JSX.Element;
6
+ declare function DepositModal(props: DepositModalProps): react.JSX.Element;
7
7
  declare namespace DepositModal {
8
8
  var displayName: string;
9
9
  }
package/dist/deposit.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  DepositModal
3
- } from "./chunk-KJ2RR2D4.mjs";
4
- import "./chunk-KAWJABTW.mjs";
3
+ } from "./chunk-QYSCCX4K.mjs";
4
+ import "./chunk-BAEB5AFZ.mjs";
5
+ import "./chunk-3C35DVPE.mjs";
6
+ import "./chunk-TQ2AYMWS.mjs";
5
7
  import "./chunk-6YRDD462.mjs";
6
8
  export {
7
9
  DepositModal
package/dist/index.cjs CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkVVJAIMKBcjs = require('./chunk-VVJAIMKB.cjs');
3
+ var _chunkSPUZLWQScjs = require('./chunk-SPUZLWQS.cjs');
4
+ require('./chunk-R5CPOBCF.cjs');
4
5
 
5
6
 
6
- var _chunk2SMS542Qcjs = require('./chunk-2SMS542Q.cjs');
7
- require('./chunk-RABZINV3.cjs');
7
+ var _chunkLEL6GMEQcjs = require('./chunk-LEL6GMEQ.cjs');
8
+ require('./chunk-MQIJZNTP.cjs');
9
+ require('./chunk-AJHFNHG3.cjs');
8
10
 
9
11
 
10
12
 
@@ -83,4 +85,4 @@ async function disconnectWallet() {
83
85
 
84
86
 
85
87
 
86
- exports.CHAIN_BY_ID = _chunkMILJQWPTcjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkMILJQWPTcjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkMILJQWPTcjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal = _chunkVVJAIMKBcjs.DepositModal; exports.HYPERCORE_CHAIN_ID = _chunkMILJQWPTcjs.HYPERCORE_CHAIN_ID; exports.HYPERCORE_USDC_ADDRESS = _chunkMILJQWPTcjs.HYPERCORE_USDC_ADDRESS; exports.NATIVE_TOKEN_ADDRESS = _chunkMILJQWPTcjs.NATIVE_TOKEN_ADDRESS; exports.SOURCE_CHAINS = _chunkMILJQWPTcjs.SOURCE_CHAINS; exports.SUPPORTED_CHAINS = _chunkMILJQWPTcjs.SUPPORTED_CHAINS; exports.WithdrawModal = _chunk2SMS542Qcjs.WithdrawModal; exports.chainRegistry = _chunkMILJQWPTcjs.chainRegistry; exports.disconnectWallet = disconnectWallet; exports.findChainIdForToken = _chunkMILJQWPTcjs.findChainIdForToken; exports.getChainBadge = _chunkMILJQWPTcjs.getChainBadge; exports.getChainIcon = _chunkMILJQWPTcjs.getChainIcon; exports.getChainId = _chunkMILJQWPTcjs.getChainId; exports.getChainName = _chunkMILJQWPTcjs.getChainName; exports.getChainObject = _chunkMILJQWPTcjs.getChainObject; exports.getExplorerName = _chunkMILJQWPTcjs.getExplorerName; exports.getExplorerTxUrl = _chunkMILJQWPTcjs.getExplorerTxUrl; exports.getExplorerUrl = _chunkMILJQWPTcjs.getExplorerUrl; exports.getSupportedChainIds = _chunkMILJQWPTcjs.getSupportedChainIds; exports.getSupportedTargetTokens = _chunkMILJQWPTcjs.getSupportedTargetTokens; exports.getSupportedTokenSymbolsForChain = _chunkMILJQWPTcjs.getSupportedTokenSymbolsForChain; exports.getTargetTokenSymbolsForChain = _chunkMILJQWPTcjs.getTargetTokenSymbolsForChain; exports.getTokenAddress = _chunkMILJQWPTcjs.getTokenAddress; exports.getTokenDecimals = _chunkMILJQWPTcjs.getTokenDecimals; exports.getTokenDecimalsByAddress = _chunkMILJQWPTcjs.getTokenDecimalsByAddress; exports.getTokenIcon = _chunkMILJQWPTcjs.getTokenIcon; exports.getTokenSymbol = _chunkMILJQWPTcjs.getTokenSymbol; exports.getUsdcAddress = _chunkMILJQWPTcjs.getUsdcAddress; exports.getUsdcDecimals = _chunkMILJQWPTcjs.getUsdcDecimals; exports.isSupportedTokenAddressForChain = _chunkMILJQWPTcjs.isSupportedTokenAddressForChain;
88
+ exports.CHAIN_BY_ID = _chunkMILJQWPTcjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkMILJQWPTcjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkMILJQWPTcjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal = _chunkSPUZLWQScjs.DepositModal; exports.HYPERCORE_CHAIN_ID = _chunkMILJQWPTcjs.HYPERCORE_CHAIN_ID; exports.HYPERCORE_USDC_ADDRESS = _chunkMILJQWPTcjs.HYPERCORE_USDC_ADDRESS; exports.NATIVE_TOKEN_ADDRESS = _chunkMILJQWPTcjs.NATIVE_TOKEN_ADDRESS; exports.SOURCE_CHAINS = _chunkMILJQWPTcjs.SOURCE_CHAINS; exports.SUPPORTED_CHAINS = _chunkMILJQWPTcjs.SUPPORTED_CHAINS; exports.WithdrawModal = _chunkLEL6GMEQcjs.WithdrawModal; exports.chainRegistry = _chunkMILJQWPTcjs.chainRegistry; exports.disconnectWallet = disconnectWallet; exports.findChainIdForToken = _chunkMILJQWPTcjs.findChainIdForToken; exports.getChainBadge = _chunkMILJQWPTcjs.getChainBadge; exports.getChainIcon = _chunkMILJQWPTcjs.getChainIcon; exports.getChainId = _chunkMILJQWPTcjs.getChainId; exports.getChainName = _chunkMILJQWPTcjs.getChainName; exports.getChainObject = _chunkMILJQWPTcjs.getChainObject; exports.getExplorerName = _chunkMILJQWPTcjs.getExplorerName; exports.getExplorerTxUrl = _chunkMILJQWPTcjs.getExplorerTxUrl; exports.getExplorerUrl = _chunkMILJQWPTcjs.getExplorerUrl; exports.getSupportedChainIds = _chunkMILJQWPTcjs.getSupportedChainIds; exports.getSupportedTargetTokens = _chunkMILJQWPTcjs.getSupportedTargetTokens; exports.getSupportedTokenSymbolsForChain = _chunkMILJQWPTcjs.getSupportedTokenSymbolsForChain; exports.getTargetTokenSymbolsForChain = _chunkMILJQWPTcjs.getTargetTokenSymbolsForChain; exports.getTokenAddress = _chunkMILJQWPTcjs.getTokenAddress; exports.getTokenDecimals = _chunkMILJQWPTcjs.getTokenDecimals; exports.getTokenDecimalsByAddress = _chunkMILJQWPTcjs.getTokenDecimalsByAddress; exports.getTokenIcon = _chunkMILJQWPTcjs.getTokenIcon; exports.getTokenSymbol = _chunkMILJQWPTcjs.getTokenSymbol; exports.getUsdcAddress = _chunkMILJQWPTcjs.getUsdcAddress; exports.getUsdcDecimals = _chunkMILJQWPTcjs.getUsdcDecimals; exports.isSupportedTokenAddressForChain = _chunkMILJQWPTcjs.isSupportedTokenAddressForChain;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { DepositModal } from './deposit.cjs';
2
2
  export { WithdrawModal } from './withdraw.cjs';
3
- export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DappImportsConfig, b as DepositAnalyticsEvent, c as DepositCompleteEventData, d as DepositFailedEventData, e as DepositLifecycleEvent, f as DepositModalProps, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData, M as ModalAnalyticsEvent, O as OrderBookSwapAction, j as OutputTokenRule, P as PostBridgeAction, R as RouteConfig, S as SafeTransactionRequest, W as WithdrawAnalyticsEvent, k as WithdrawCompleteEventData, l as WithdrawFailedEventData, m as WithdrawLifecycleEvent, n as WithdrawModalProps, o as WithdrawSubmittedEventData } from './types-BMcGO5k_.cjs';
4
- export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, d as chainRegistry, f as findChainIdForToken, g as getChainBadge, e as getChainIcon, h as getChainId, i as getChainName, j as getChainObject, k as getExplorerName, l as getExplorerTxUrl, m as getExplorerUrl, n as getSupportedChainIds, o as getSupportedTargetTokens, p as getSupportedTokenSymbolsForChain, q as getTargetTokenSymbolsForChain, r as getTokenAddress, s as getTokenDecimals, t as getTokenDecimalsByAddress, u as getTokenIcon, v as getTokenSymbol, w as getUsdcAddress, x as getUsdcDecimals, y as isSupportedTokenAddressForChain } from './caip-CrQ2KKU-.cjs';
5
- import 'react/jsx-runtime';
3
+ export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DappImportsConfig, b as DepositAnalyticsEvent, c as DepositCompleteEventData, d as DepositFailedEventData, e as DepositLifecycleEvent, f as DepositModalProps, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData, M as ModalAnalyticsEvent, O as OrderBookSwapAction, j as OutputTokenRule, P as PostBridgeAction, R as RouteConfig, S as SafeTransactionRequest, W as WithdrawAnalyticsEvent, k as WithdrawCompleteEventData, l as WithdrawFailedEventData, m as WithdrawLifecycleEvent, n as WithdrawModalProps, o as WithdrawSubmittedEventData } from './types-RzfAD14B.cjs';
4
+ export { PolymarketAccount, PolymarketTokenBalance } from './polymarket.cjs';
5
+ export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, e as chainRegistry, f as findChainIdForToken, g as getChainBadge, h as getChainIcon, i as getChainId, j as getChainName, k as getChainObject, l as getExplorerName, m as getExplorerTxUrl, n as getExplorerUrl, o as getSupportedChainIds, p as getSupportedTargetTokens, q as getSupportedTokenSymbolsForChain, r as getTargetTokenSymbolsForChain, s as getTokenAddress, t as getTokenDecimals, u as getTokenDecimalsByAddress, v as getTokenIcon, w as getTokenSymbol, x as getUsdcAddress, y as getUsdcDecimals, z as isSupportedTokenAddressForChain } from './caip-CsslyHGL.cjs';
6
+ import 'react';
6
7
  import 'viem';
7
8
  import 'viem/chains';
8
9
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { DepositModal } from './deposit.js';
2
2
  export { WithdrawModal } from './withdraw.js';
3
- export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DappImportsConfig, b as DepositAnalyticsEvent, c as DepositCompleteEventData, d as DepositFailedEventData, e as DepositLifecycleEvent, f as DepositModalProps, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData, M as ModalAnalyticsEvent, O as OrderBookSwapAction, j as OutputTokenRule, P as PostBridgeAction, R as RouteConfig, S as SafeTransactionRequest, W as WithdrawAnalyticsEvent, k as WithdrawCompleteEventData, l as WithdrawFailedEventData, m as WithdrawLifecycleEvent, n as WithdrawModalProps, o as WithdrawSubmittedEventData } from './types-BMcGO5k_.js';
4
- export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, d as chainRegistry, f as findChainIdForToken, g as getChainBadge, e as getChainIcon, h as getChainId, i as getChainName, j as getChainObject, k as getExplorerName, l as getExplorerTxUrl, m as getExplorerUrl, n as getSupportedChainIds, o as getSupportedTargetTokens, p as getSupportedTokenSymbolsForChain, q as getTargetTokenSymbolsForChain, r as getTokenAddress, s as getTokenDecimals, t as getTokenDecimalsByAddress, u as getTokenIcon, v as getTokenSymbol, w as getUsdcAddress, x as getUsdcDecimals, y as isSupportedTokenAddressForChain } from './caip-CrQ2KKU-.js';
5
- import 'react/jsx-runtime';
3
+ export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DappImportsConfig, b as DepositAnalyticsEvent, c as DepositCompleteEventData, d as DepositFailedEventData, e as DepositLifecycleEvent, f as DepositModalProps, g as DepositModalTheme, h as DepositModalUIConfig, i as DepositSubmittedEventData, E as ErrorEventData, M as ModalAnalyticsEvent, O as OrderBookSwapAction, j as OutputTokenRule, P as PostBridgeAction, R as RouteConfig, S as SafeTransactionRequest, W as WithdrawAnalyticsEvent, k as WithdrawCompleteEventData, l as WithdrawFailedEventData, m as WithdrawLifecycleEvent, n as WithdrawModalProps, o as WithdrawSubmittedEventData } from './types-RzfAD14B.js';
4
+ export { PolymarketAccount, PolymarketTokenBalance } from './polymarket.js';
5
+ export { C as CHAIN_BY_ID, D as DEFAULT_BACKEND_URL, a as DEFAULT_SIGNER_ADDRESS, H as HYPERCORE_CHAIN_ID, b as HYPERCORE_USDC_ADDRESS, N as NATIVE_TOKEN_ADDRESS, S as SOURCE_CHAINS, c as SUPPORTED_CHAINS, e as chainRegistry, f as findChainIdForToken, g as getChainBadge, h as getChainIcon, i as getChainId, j as getChainName, k as getChainObject, l as getExplorerName, m as getExplorerTxUrl, n as getExplorerUrl, o as getSupportedChainIds, p as getSupportedTargetTokens, q as getSupportedTokenSymbolsForChain, r as getTargetTokenSymbolsForChain, s as getTokenAddress, t as getTokenDecimals, u as getTokenDecimalsByAddress, v as getTokenIcon, w as getTokenSymbol, x as getUsdcAddress, y as getUsdcDecimals, z as isSupportedTokenAddressForChain } from './caip-CsslyHGL.js';
6
+ import 'react';
6
7
  import 'viem';
7
8
  import 'viem/chains';
8
9
 
package/dist/index.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  DepositModal
3
- } from "./chunk-KJ2RR2D4.mjs";
3
+ } from "./chunk-QYSCCX4K.mjs";
4
+ import "./chunk-BAEB5AFZ.mjs";
4
5
  import {
5
6
  WithdrawModal
6
- } from "./chunk-TKQYTBU6.mjs";
7
- import "./chunk-KAWJABTW.mjs";
7
+ } from "./chunk-DZQD3DAV.mjs";
8
+ import "./chunk-3C35DVPE.mjs";
9
+ import "./chunk-TQ2AYMWS.mjs";
8
10
  import {
9
11
  CHAIN_BY_ID,
10
12
  DEFAULT_BACKEND_URL,
@@ -0,0 +1,64 @@
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
+
4
+
5
+ var _chunkR5CPOBCFcjs = require('./chunk-R5CPOBCF.cjs');
6
+ require('./chunk-AJHFNHG3.cjs');
7
+ require('./chunk-MILJQWPT.cjs');
8
+
9
+ // src/core/dapp-imports/polymarket/account.ts
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _viem = require('viem');
17
+ var _chains = require('viem/chains');
18
+ async function getPolymarketAccount(params) {
19
+ const { rpcUrl, signal } = params;
20
+ if (typeof params.eoa !== "string" || !_viem.isAddress.call(void 0, params.eoa)) {
21
+ throw new TypeError(
22
+ `getPolymarketAccount: invalid EOA address: ${String(params.eoa)}`
23
+ );
24
+ }
25
+ const eoa = _viem.getAddress.call(void 0, params.eoa);
26
+ const proxyWallet = await _chunkR5CPOBCFcjs.fetchPolymarketProxyWallet.call(void 0, eoa, signal);
27
+ if (!proxyWallet) return null;
28
+ throwIfAborted(signal);
29
+ let balances = { pusd: 0n, usdce: 0n };
30
+ try {
31
+ balances = await _chunkR5CPOBCFcjs.readPolymarketBalances.call(void 0, {
32
+ publicClient: polygonClient(rpcUrl),
33
+ proxyWallet
34
+ });
35
+ } catch (e) {
36
+ }
37
+ throwIfAborted(signal);
38
+ const pusd = toTokenBalance(balances.pusd);
39
+ const usdce = toTokenBalance(balances.usdce);
40
+ return {
41
+ eoa,
42
+ proxyWallet,
43
+ chainId: _chunkR5CPOBCFcjs.POLYMARKET_POLYGON_CHAIN_ID,
44
+ pusd,
45
+ usdce,
46
+ totalUsd: pusd.usd + usdce.usd
47
+ };
48
+ }
49
+ function toTokenBalance(raw) {
50
+ const formatted = _viem.formatUnits.call(void 0, raw, 6);
51
+ const usd = Number(formatted);
52
+ return { raw, formatted, usd: Number.isFinite(usd) ? usd : 0 };
53
+ }
54
+ function polygonClient(rpcUrl) {
55
+ return _viem.createPublicClient.call(void 0, { chain: _chains.polygon, transport: _viem.http.call(void 0, rpcUrl) });
56
+ }
57
+ function throwIfAborted(signal) {
58
+ if (_optionalChain([signal, 'optionalAccess', _ => _.aborted])) {
59
+ throw _nullishCoalesce(signal.reason, () => ( new DOMException("Aborted", "AbortError")));
60
+ }
61
+ }
62
+
63
+
64
+ exports.getPolymarketAccount = getPolymarketAccount;
@@ -0,0 +1,57 @@
1
+ import { Address } from 'viem';
2
+
3
+ declare const POLYMARKET_POLYGON_CHAIN_ID = 137;
4
+
5
+ /**
6
+ * Headless Polymarket account lookup, exported via the
7
+ * `@rhinestone/deposit-modal/polymarket` subpath so a consumer can render
8
+ * the user's Polymarket address + balance in their own UI (no React, no
9
+ * modal, no wallet-connect stack in the bundle).
10
+ */
11
+
12
+ interface PolymarketTokenBalance {
13
+ /** Base units (6 decimals). */
14
+ raw: bigint;
15
+ /** `formatUnits(raw, 6)`. */
16
+ formatted: string;
17
+ /** 1:1 for pUSD and USDC.e. */
18
+ usd: number;
19
+ }
20
+ interface PolymarketAccount {
21
+ eoa: Address;
22
+ /** Present even when balances are zero. */
23
+ proxyWallet: Address;
24
+ chainId: typeof POLYMARKET_POLYGON_CHAIN_ID;
25
+ pusd: PolymarketTokenBalance;
26
+ usdce: PolymarketTokenBalance;
27
+ totalUsd: number;
28
+ }
29
+ /**
30
+ * Looks up the Polymarket proxy wallet for an EOA and reads its pUSD and
31
+ * USDC.e balances on Polygon.
32
+ *
33
+ * - Resolves `null` ONLY when the EOA has no Polymarket proxy at all.
34
+ * Found-but-empty resolves a full account with zeroed balances — the
35
+ * address is the headline.
36
+ * - A failed balance read (RPC outage) also resolves the account with
37
+ * zeroed balances rather than rejecting.
38
+ * - Transient Gamma failures (network, 5xx) and aborts reject, so a
39
+ * caller never mistakes an outage for "no account".
40
+ *
41
+ * The balance reported here is "what exists" at the proxy. The modal's
42
+ * own availability check additionally verifies the EOA can MOVE those
43
+ * funds (Safe owner / deposit-wallet owner) — an account whose EOA owns
44
+ * neither reports a balance here but routes to the modal's home screen
45
+ * when opened via `initialDappImport`.
46
+ *
47
+ * `signal` cancels the Gamma profile fetch and short-circuits between
48
+ * steps; an in-flight RPC balance read itself is not cancellable.
49
+ */
50
+ declare function getPolymarketAccount(params: {
51
+ eoa: Address | string;
52
+ /** Overrides the default public Polygon RPC. */
53
+ rpcUrl?: string;
54
+ signal?: AbortSignal;
55
+ }): Promise<PolymarketAccount | null>;
56
+
57
+ export { type PolymarketAccount, type PolymarketTokenBalance, getPolymarketAccount };
@@ -0,0 +1,57 @@
1
+ import { Address } from 'viem';
2
+
3
+ declare const POLYMARKET_POLYGON_CHAIN_ID = 137;
4
+
5
+ /**
6
+ * Headless Polymarket account lookup, exported via the
7
+ * `@rhinestone/deposit-modal/polymarket` subpath so a consumer can render
8
+ * the user's Polymarket address + balance in their own UI (no React, no
9
+ * modal, no wallet-connect stack in the bundle).
10
+ */
11
+
12
+ interface PolymarketTokenBalance {
13
+ /** Base units (6 decimals). */
14
+ raw: bigint;
15
+ /** `formatUnits(raw, 6)`. */
16
+ formatted: string;
17
+ /** 1:1 for pUSD and USDC.e. */
18
+ usd: number;
19
+ }
20
+ interface PolymarketAccount {
21
+ eoa: Address;
22
+ /** Present even when balances are zero. */
23
+ proxyWallet: Address;
24
+ chainId: typeof POLYMARKET_POLYGON_CHAIN_ID;
25
+ pusd: PolymarketTokenBalance;
26
+ usdce: PolymarketTokenBalance;
27
+ totalUsd: number;
28
+ }
29
+ /**
30
+ * Looks up the Polymarket proxy wallet for an EOA and reads its pUSD and
31
+ * USDC.e balances on Polygon.
32
+ *
33
+ * - Resolves `null` ONLY when the EOA has no Polymarket proxy at all.
34
+ * Found-but-empty resolves a full account with zeroed balances — the
35
+ * address is the headline.
36
+ * - A failed balance read (RPC outage) also resolves the account with
37
+ * zeroed balances rather than rejecting.
38
+ * - Transient Gamma failures (network, 5xx) and aborts reject, so a
39
+ * caller never mistakes an outage for "no account".
40
+ *
41
+ * The balance reported here is "what exists" at the proxy. The modal's
42
+ * own availability check additionally verifies the EOA can MOVE those
43
+ * funds (Safe owner / deposit-wallet owner) — an account whose EOA owns
44
+ * neither reports a balance here but routes to the modal's home screen
45
+ * when opened via `initialDappImport`.
46
+ *
47
+ * `signal` cancels the Gamma profile fetch and short-circuits between
48
+ * steps; an in-flight RPC balance read itself is not cancellable.
49
+ */
50
+ declare function getPolymarketAccount(params: {
51
+ eoa: Address | string;
52
+ /** Overrides the default public Polygon RPC. */
53
+ rpcUrl?: string;
54
+ signal?: AbortSignal;
55
+ }): Promise<PolymarketAccount | null>;
56
+
57
+ export { type PolymarketAccount, type PolymarketTokenBalance, getPolymarketAccount };