@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,212 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkAJHFNHG3cjs = require('./chunk-AJHFNHG3.cjs');
4
+
5
+ // src/core/dapp-imports/polymarket/constants.ts
6
+ var POLYMARKET_POLYGON_CHAIN_ID = 137;
7
+ var POLYMARKET_PUSD_ADDRESS = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB";
8
+ var POLYMARKET_USDCE_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
9
+ var POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS = "0x2957922Eb93258b93368531d39fAcCA3B4dC5854";
10
+ var SAFE_MULTI_SEND_CALL_ONLY_ADDRESS = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D";
11
+ var GAMMA_API_PUBLIC_PROFILE = "https://gamma-api.polymarket.com/public-profile";
12
+ var POLYMARKET_ICON_URL = "data:image/svg+xml,%3Csvg width='512' height='512' viewBox='0 0 512 512' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='512' height='512' fill='%232E5CFF'/%3E%3Cpath d='M375.84 389.422C375.84 403.572 375.84 410.647 371.212 414.154C366.585 417.662 359.773 415.75 346.15 411.927L127.22 350.493C119.012 348.19 114.907 347.038 112.534 343.907C110.161 340.776 110.161 336.513 110.161 327.988V184.012C110.161 175.487 110.161 171.224 112.534 168.093C114.907 164.962 119.012 163.81 127.22 161.507L346.15 100.072C359.773 96.2495 366.585 94.338 371.212 97.8455C375.84 101.353 375.84 108.428 375.84 122.578V389.422ZM164.761 330.463L346.035 381.337V279.595L164.761 330.463ZM139.963 306.862L321.201 256L139.963 205.138V306.862ZM164.759 181.537L346.035 232.406V130.663L164.759 181.537Z' fill='white'/%3E%3C/svg%3E";
13
+
14
+ // src/core/dapp-imports/polymarket/gamma-api.ts
15
+ var _viem = require('viem');
16
+ async function fetchPolymarketProxyWallet(eoa, signal) {
17
+ const url = `${GAMMA_API_PUBLIC_PROFILE}?address=${eoa}`;
18
+ const response = await fetch(url, { signal });
19
+ if (response.status === 404) {
20
+ return null;
21
+ }
22
+ if (!response.ok) {
23
+ throw new Error(
24
+ `Polymarket profile request failed: ${response.status}`
25
+ );
26
+ }
27
+ let payload;
28
+ try {
29
+ payload = await response.json();
30
+ } catch (e) {
31
+ return null;
32
+ }
33
+ const raw = payload.proxyWallet;
34
+ if (!raw || !_viem.isAddress.call(void 0, raw)) {
35
+ return null;
36
+ }
37
+ const checksummed = _viem.getAddress.call(void 0, raw);
38
+ if (checksummed === _viem.zeroAddress) {
39
+ return null;
40
+ }
41
+ return checksummed;
42
+ }
43
+
44
+ // src/core/dapp-imports/polymarket/safe.ts
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+ var COLLATERAL_OFFRAMP_ABI = _viem.parseAbi.call(void 0, [
57
+ "function unwrap(address _asset, address _to, uint256 _amount)"
58
+ ]);
59
+ var MULTI_SEND_ABI = _viem.parseAbi.call(void 0, ["function multiSend(bytes transactions)"]);
60
+ async function readPolymarketBalances(params) {
61
+ const { publicClient, proxyWallet } = params;
62
+ const results = await publicClient.multicall({
63
+ allowFailure: true,
64
+ contracts: [
65
+ {
66
+ address: POLYMARKET_PUSD_ADDRESS,
67
+ abi: _viem.erc20Abi,
68
+ functionName: "balanceOf",
69
+ args: [proxyWallet]
70
+ },
71
+ {
72
+ address: POLYMARKET_USDCE_ADDRESS,
73
+ abi: _viem.erc20Abi,
74
+ functionName: "balanceOf",
75
+ args: [proxyWallet]
76
+ }
77
+ ]
78
+ });
79
+ return {
80
+ pusd: results[0].status === "success" ? results[0].result : 0n,
81
+ usdce: results[1].status === "success" ? results[1].result : 0n
82
+ };
83
+ }
84
+ async function executePolymarketSafeTransfer(params) {
85
+ const {
86
+ walletClient,
87
+ publicClient,
88
+ safeAddress,
89
+ recipient,
90
+ amount,
91
+ tokenKind
92
+ } = params;
93
+ const account = walletClient.account;
94
+ const chain = walletClient.chain;
95
+ if (!account || !chain) {
96
+ throw new Error("Wallet not connected");
97
+ }
98
+ if (chain.id !== POLYMARKET_POLYGON_CHAIN_ID) {
99
+ throw new Error("Switch to Polygon to sign");
100
+ }
101
+ const isOwner = await publicClient.readContract({
102
+ address: safeAddress,
103
+ abi: _chunkAJHFNHG3cjs.SAFE_ABI,
104
+ functionName: "isOwner",
105
+ args: [account.address]
106
+ });
107
+ if (!isOwner) {
108
+ throw new Error("Connected wallet is not a Polymarket Safe owner");
109
+ }
110
+ const safeTx = tokenKind === "pusd" ? buildPusdUnwrapSafeTx(recipient, amount) : buildUsdceTransferSafeTx(recipient, amount);
111
+ const signature = _viem.concat.call(void 0, [
112
+ _viem.pad.call(void 0, account.address, { size: 32 }),
113
+ _viem.pad.call(void 0, _viem.toHex.call(void 0, 0), { size: 32 }),
114
+ _viem.toHex.call(void 0, 1, { size: 1 })
115
+ ]);
116
+ const txHash = await walletClient.writeContract({
117
+ account,
118
+ chain,
119
+ address: safeAddress,
120
+ abi: _chunkAJHFNHG3cjs.SAFE_ABI,
121
+ functionName: "execTransaction",
122
+ args: [
123
+ safeTx.to,
124
+ 0n,
125
+ safeTx.data,
126
+ safeTx.operation,
127
+ 0n,
128
+ 0n,
129
+ 0n,
130
+ _viem.zeroAddress,
131
+ _viem.zeroAddress,
132
+ signature
133
+ ]
134
+ });
135
+ const receipt = await publicClient.waitForTransactionReceipt({
136
+ hash: txHash
137
+ });
138
+ const parsed = _viem.parseEventLogs.call(void 0, {
139
+ abi: _chunkAJHFNHG3cjs.SAFE_ABI,
140
+ logs: receipt.logs.filter(
141
+ (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
142
+ ),
143
+ strict: false
144
+ });
145
+ if (parsed.some((log) => log.eventName === "ExecutionFailure")) {
146
+ throw new Error("Polymarket Safe transaction failed");
147
+ }
148
+ if (!parsed.some((log) => log.eventName === "ExecutionSuccess")) {
149
+ throw new Error("Polymarket Safe transaction status unavailable");
150
+ }
151
+ return {
152
+ txHash,
153
+ // The smart account always receives USDC.e — pUSD is unwrapped to USDC.e
154
+ // before it lands at `recipient`.
155
+ sourceToken: POLYMARKET_USDCE_ADDRESS,
156
+ sourceSymbol: tokenKind === "pusd" ? "pUSD" : "USDC.e"
157
+ };
158
+ }
159
+ function buildUsdceTransferSafeTx(recipient, amount) {
160
+ return {
161
+ to: POLYMARKET_USDCE_ADDRESS,
162
+ data: _viem.encodeFunctionData.call(void 0, {
163
+ abi: _viem.erc20Abi,
164
+ functionName: "transfer",
165
+ args: [recipient, amount]
166
+ }),
167
+ operation: 0
168
+ };
169
+ }
170
+ function buildPusdUnwrapSafeTx(recipient, amount) {
171
+ const approveData = _viem.encodeFunctionData.call(void 0, {
172
+ abi: _viem.erc20Abi,
173
+ functionName: "approve",
174
+ args: [POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS, amount]
175
+ });
176
+ const unwrapData = _viem.encodeFunctionData.call(void 0, {
177
+ abi: COLLATERAL_OFFRAMP_ABI,
178
+ functionName: "unwrap",
179
+ args: [POLYMARKET_USDCE_ADDRESS, recipient, amount]
180
+ });
181
+ return {
182
+ to: SAFE_MULTI_SEND_CALL_ONLY_ADDRESS,
183
+ data: _viem.encodeFunctionData.call(void 0, {
184
+ abi: MULTI_SEND_ABI,
185
+ functionName: "multiSend",
186
+ args: [
187
+ _viem.concat.call(void 0, [
188
+ encodeMultiSendCall(POLYMARKET_PUSD_ADDRESS, approveData),
189
+ encodeMultiSendCall(POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS, unwrapData)
190
+ ])
191
+ ]
192
+ }),
193
+ operation: 1
194
+ };
195
+ }
196
+ function encodeMultiSendCall(to, data) {
197
+ return _viem.encodePacked.call(void 0,
198
+ ["uint8", "address", "uint256", "uint256", "bytes"],
199
+ [0, to, 0n, BigInt((data.length - 2) / 2), data]
200
+ );
201
+ }
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+ exports.POLYMARKET_POLYGON_CHAIN_ID = POLYMARKET_POLYGON_CHAIN_ID; exports.POLYMARKET_PUSD_ADDRESS = POLYMARKET_PUSD_ADDRESS; exports.POLYMARKET_USDCE_ADDRESS = POLYMARKET_USDCE_ADDRESS; exports.POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS = POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS; exports.POLYMARKET_ICON_URL = POLYMARKET_ICON_URL; exports.fetchPolymarketProxyWallet = fetchPolymarketProxyWallet; exports.readPolymarketBalances = readPolymarketBalances; exports.executePolymarketSafeTransfer = executePolymarketSafeTransfer;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isUnsupportedChainSwitchError
3
- } from "./chunk-KAWJABTW.mjs";
3
+ } from "./chunk-3C35DVPE.mjs";
4
4
  import {
5
5
  SUPPORTED_CHAINS,
6
6
  getChainName