@rhinestone/deposit-modal 0.8.1 → 0.9.0

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 (65) hide show
  1. package/README.md +193 -29
  2. package/dist/{chunk-2JPB3PLB.mjs → DepositModalReown-6KUAO5ZC.mjs} +56 -4
  3. package/dist/{chunk-Q3W53BKR.cjs → DepositModalReown-XC5RIU7Z.cjs} +62 -10
  4. package/dist/{caip-C_ZYFIGa.d.cts → caip-523Zrc3r.d.cts} +1 -3
  5. package/dist/{caip-C_ZYFIGa.d.ts → caip-523Zrc3r.d.ts} +1 -3
  6. package/dist/{chunk-D3Y7ZBED.cjs → chunk-22RV33LK.cjs} +2170 -1460
  7. package/dist/chunk-4WB2FHGC.mjs +865 -0
  8. package/dist/chunk-A223BLVC.mjs +801 -0
  9. package/dist/{chunk-HQWZCOMS.cjs → chunk-DIX7M3SP.cjs} +232 -601
  10. package/dist/{chunk-T43VUEJH.mjs → chunk-E4G5BOZP.mjs} +167 -536
  11. package/dist/chunk-H577RJN5.cjs +801 -0
  12. package/dist/{chunk-DABKCJVL.mjs → chunk-ILT2PITN.mjs} +60 -3
  13. package/dist/{chunk-7KHEIMWD.mjs → chunk-KKHLNFSA.mjs} +2436 -1726
  14. package/dist/chunk-LGVJWVSS.mjs +81 -0
  15. package/dist/chunk-NEXUCY4B.cjs +11 -0
  16. package/dist/chunk-NMIMRASD.cjs +1785 -0
  17. package/dist/chunk-OSI2CFGL.mjs +11 -0
  18. package/dist/chunk-PAGMU4RQ.cjs +865 -0
  19. package/dist/chunk-T7LGQFP3.cjs +81 -0
  20. package/dist/chunk-VN4BLZYC.cjs +2273 -0
  21. package/dist/chunk-VOGZAZB2.mjs +2273 -0
  22. package/dist/chunk-WYXBY2MQ.mjs +1785 -0
  23. package/dist/{chunk-4NN7UTWQ.cjs → chunk-YEBXUUH3.cjs} +63 -6
  24. package/dist/claim.cjs +10 -0
  25. package/dist/claim.d.cts +8 -0
  26. package/dist/claim.d.ts +8 -0
  27. package/dist/claim.mjs +10 -0
  28. package/dist/constants.cjs +3 -3
  29. package/dist/constants.d.cts +4 -2
  30. package/dist/constants.d.ts +4 -2
  31. package/dist/constants.mjs +5 -5
  32. package/dist/deposit.cjs +8 -6
  33. package/dist/deposit.d.cts +2 -2
  34. package/dist/deposit.d.ts +2 -2
  35. package/dist/deposit.mjs +7 -5
  36. package/dist/index.cjs +22 -12
  37. package/dist/index.d.cts +15 -2
  38. package/dist/index.d.ts +15 -2
  39. package/dist/index.mjs +21 -11
  40. package/dist/polymarket.cjs +5 -6
  41. package/dist/polymarket.mjs +2 -3
  42. package/dist/server.cjs +96 -0
  43. package/dist/server.d.cts +65 -0
  44. package/dist/server.d.ts +65 -0
  45. package/dist/server.mjs +96 -0
  46. package/dist/styles.css +263 -12
  47. package/dist/types-C0SGf-21.d.cts +606 -0
  48. package/dist/types-C0SGf-21.d.ts +606 -0
  49. package/dist/withdraw.cjs +6 -5
  50. package/dist/withdraw.d.cts +3 -6
  51. package/dist/withdraw.d.ts +3 -6
  52. package/dist/withdraw.mjs +5 -4
  53. package/package.json +53 -6
  54. package/dist/DepositModalReown-4BSHOQ5Y.mjs +0 -63
  55. package/dist/DepositModalReown-UND3DEJH.cjs +0 -63
  56. package/dist/WithdrawModalReown-FVXSSGY5.mjs +0 -46
  57. package/dist/WithdrawModalReown-TVZWJKQI.cjs +0 -46
  58. package/dist/chunk-7OKA6GNA.cjs +0 -4537
  59. package/dist/chunk-NASHLEVQ.mjs +0 -4537
  60. package/dist/chunk-O5OKA27M.mjs +0 -800
  61. package/dist/chunk-U7SVYWVD.cjs +0 -800
  62. package/dist/chunk-WK5AFRSP.mjs +0 -295
  63. package/dist/chunk-XRWQMIBY.cjs +0 -295
  64. package/dist/types--LQWg_4W.d.cts +0 -468
  65. package/dist/types--LQWg_4W.d.ts +0 -468
@@ -1,295 +0,0 @@
1
- import {
2
- getChainName
3
- } from "./chunk-O5OKA27M.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,295 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkU7SVYWVDcjs = require('./chunk-U7SVYWVD.cjs');
4
-
5
- // src/core/safe.ts
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
- var _viem = require('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 ${_chunkU7SVYWVDcjs.getChainName.call(void 0, 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: _viem.zeroAddress,
103
- refundReceiver: _viem.zeroAddress
104
- };
105
- const signature = _viem.concat.call(void 0, [
106
- _viem.pad.call(void 0, account.address, { size: 32 }),
107
- _viem.pad.call(void 0, _viem.toHex.call(void 0, 0), { size: 32 }),
108
- _viem.toHex.call(void 0, 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 = _viem.parseEventLogs.call(void 0, {
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 ${_chunkU7SVYWVDcjs.getChainName.call(void 0, 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 = _viem.encodeFunctionData.call(void 0, {
178
- abi: _viem.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: _viem.zeroAddress,
191
- refundReceiver: _viem.zeroAddress
192
- };
193
- const signature = _viem.concat.call(void 0, [
194
- _viem.pad.call(void 0, account.address, { size: 32 }),
195
- _viem.pad.call(void 0, _viem.toHex.call(void 0, 0), { size: 32 }),
196
- _viem.toHex.call(void 0, 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 = _viem.parseEventLogs.call(void 0, {
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: _viem.zeroAddress,
268
- refundReceiver: _viem.zeroAddress,
269
- nonce
270
- };
271
- const safeTxHash = _viem.hashTypedData.call(void 0, {
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
-
291
-
292
-
293
-
294
-
295
- exports.SAFE_ABI = SAFE_ABI; exports.executeSafeEthTransfer = executeSafeEthTransfer; exports.executeSafeErc20Transfer = executeSafeErc20Transfer; exports.buildSafeTransaction = buildSafeTransaction;