@rhinestone/deposit-modal 0.2.5-alpha.0 → 0.3.0-alpha.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.
- package/README.md +40 -211
- package/dist/{DepositModalReown-GIODYNOK.mjs → DepositModalReown-GXY65HZP.mjs} +3 -5
- package/dist/{DepositModalReown-SVVA3OZ6.cjs → DepositModalReown-HVIEA6YA.cjs} +4 -6
- package/dist/QRCode-SMMYPUQC.cjs +58 -0
- package/dist/QRCode-YMQTKSSK.mjs +58 -0
- package/dist/{WithdrawModalReown-VNTKGALT.cjs → WithdrawModalReown-4M3PBY2T.cjs} +4 -5
- package/dist/{WithdrawModalReown-HTEB4XGU.mjs → WithdrawModalReown-O6V6KRH6.mjs} +3 -4
- package/dist/{chunk-AHQY2O3U.cjs → chunk-7SYZG47X.cjs} +1731 -2161
- package/dist/{chunk-WHW3ZMOT.mjs → chunk-EEHUOFIW.mjs} +107 -90
- package/dist/{chunk-WA4RA4HB.mjs → chunk-FKPTIHU7.mjs} +916 -424
- package/dist/{chunk-RQ2VCKLS.mjs → chunk-U5QIFNG4.mjs} +1815 -2245
- package/dist/{chunk-DUGDAMAF.mjs → chunk-UIHAYD7J.mjs} +1089 -796
- package/dist/{chunk-R2HP743T.cjs → chunk-XCAF6B3D.cjs} +51 -34
- package/dist/{chunk-KE6CJVOV.cjs → chunk-Y3RA3YGA.cjs} +1110 -817
- package/dist/{chunk-4S262VLP.cjs → chunk-Z2SIC2TH.cjs} +965 -473
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +3 -2
- package/dist/constants.d.ts +3 -2
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +4 -6
- package/dist/deposit.d.cts +2 -3
- package/dist/deposit.d.ts +2 -3
- package/dist/deposit.mjs +3 -5
- package/dist/index.cjs +5 -7
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +4 -6
- package/dist/styles.css +1068 -752
- package/dist/{types-D0NawmZ8.d.cts → types-DRou84ZM.d.cts} +147 -40
- package/dist/{types-CeFbJ-MW.d.ts → types-DRou84ZM.d.ts} +147 -40
- package/dist/withdraw.cjs +4 -5
- package/dist/withdraw.d.cts +2 -3
- package/dist/withdraw.d.ts +2 -3
- package/dist/withdraw.mjs +3 -4
- package/package.json +13 -12
- package/dist/chunk-J2SWZSXL.mjs +0 -295
- package/dist/chunk-LHOHM67Z.mjs +0 -234
- package/dist/chunk-YKGL66EF.cjs +0 -295
- package/dist/chunk-ZHLQMSQM.cjs +0 -234
- package/dist/reown.cjs +0 -18
- package/dist/reown.d.cts +0 -10
- package/dist/reown.d.ts +0 -10
- package/dist/reown.mjs +0 -18
- package/dist/safe-CB7TvRCc.d.cts +0 -62
- package/dist/safe-CB7TvRCc.d.ts +0 -62
- package/dist/safe.cjs +0 -22
- package/dist/safe.d.cts +0 -14
- package/dist/safe.d.ts +0 -14
- package/dist/safe.mjs +0 -22
package/dist/chunk-YKGL66EF.cjs
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkR2HP743Tcjs = require('./chunk-R2HP743T.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 ${_chunkR2HP743Tcjs.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 ${_chunkR2HP743Tcjs.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;
|
package/dist/chunk-ZHLQMSQM.cjs
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunkYKGL66EFcjs = require('./chunk-YKGL66EF.cjs');
|
|
4
|
-
|
|
5
|
-
// src/core/polymarket-safe.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _viem = require('viem');
|
|
22
|
-
var POLYMARKET_POLYGON_CHAIN_ID = 137;
|
|
23
|
-
var POLYMARKET_SAFE_FACTORY_ADDRESS = "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b";
|
|
24
|
-
var POLYMARKET_SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf";
|
|
25
|
-
var POLYMARKET_USDCE_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
26
|
-
var POLYMARKET_PUSD_ADDRESS = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB";
|
|
27
|
-
var POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS = "0x2957922Eb93258b93368531d39fAcCA3B4dC5854";
|
|
28
|
-
var SAFE_MULTI_SEND_CALL_ONLY_ADDRESS = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D";
|
|
29
|
-
var COLLATERAL_OFFRAMP_ABI = _viem.parseAbi.call(void 0, [
|
|
30
|
-
"function unwrap(address _asset, address _to, uint256 _amount)"
|
|
31
|
-
]);
|
|
32
|
-
var MULTI_SEND_ABI = _viem.parseAbi.call(void 0, ["function multiSend(bytes transactions)"]);
|
|
33
|
-
function derivePolymarketSafeAddress(owner) {
|
|
34
|
-
const checksummedOwner = _viem.getAddress.call(void 0, owner);
|
|
35
|
-
const salt = _viem.keccak256.call(void 0,
|
|
36
|
-
_viem.encodeAbiParameters.call(void 0, [{ type: "address" }], [checksummedOwner])
|
|
37
|
-
);
|
|
38
|
-
return _viem.getCreate2Address.call(void 0, {
|
|
39
|
-
from: POLYMARKET_SAFE_FACTORY_ADDRESS,
|
|
40
|
-
salt,
|
|
41
|
-
bytecodeHash: POLYMARKET_SAFE_INIT_CODE_HASH
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function isPolymarketAsset(asset) {
|
|
45
|
-
return asset.source === "polymarket";
|
|
46
|
-
}
|
|
47
|
-
async function fetchPolymarketBalances(params) {
|
|
48
|
-
const safeAddress = derivePolymarketSafeAddress(params.owner);
|
|
49
|
-
const balances = await Promise.all([
|
|
50
|
-
readTokenBalance(params.publicClient, POLYMARKET_USDCE_ADDRESS, safeAddress),
|
|
51
|
-
readTokenBalance(params.publicClient, POLYMARKET_PUSD_ADDRESS, safeAddress)
|
|
52
|
-
]);
|
|
53
|
-
const [usdceBalance, pusdBalance] = balances;
|
|
54
|
-
const assets = [];
|
|
55
|
-
if (usdceBalance > 0n) {
|
|
56
|
-
assets.push(
|
|
57
|
-
buildPolymarketAsset({
|
|
58
|
-
kind: "usdce",
|
|
59
|
-
safeAddress,
|
|
60
|
-
balance: usdceBalance
|
|
61
|
-
})
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
if (pusdBalance > 0n) {
|
|
65
|
-
assets.push(
|
|
66
|
-
buildPolymarketAsset({
|
|
67
|
-
kind: "pusd",
|
|
68
|
-
safeAddress,
|
|
69
|
-
balance: pusdBalance
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
safeAddress,
|
|
75
|
-
assets,
|
|
76
|
-
totalUsd: assets.reduce((sum, asset) => sum + (_nullishCoalesce(asset.balanceUsd, () => ( 0))), 0)
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
async function executePolymarketSafeTransfer(params) {
|
|
80
|
-
const account = params.walletClient.account;
|
|
81
|
-
const chain = params.walletClient.chain;
|
|
82
|
-
if (!account || !chain) {
|
|
83
|
-
throw new Error("Wallet not connected");
|
|
84
|
-
}
|
|
85
|
-
if (chain.id !== POLYMARKET_POLYGON_CHAIN_ID) {
|
|
86
|
-
throw new Error("Switch to Polygon to sign");
|
|
87
|
-
}
|
|
88
|
-
const isOwner = await params.publicClient.readContract({
|
|
89
|
-
address: params.safeAddress,
|
|
90
|
-
abi: _chunkYKGL66EFcjs.SAFE_ABI,
|
|
91
|
-
functionName: "isOwner",
|
|
92
|
-
args: [account.address]
|
|
93
|
-
});
|
|
94
|
-
if (!isOwner) {
|
|
95
|
-
throw new Error("Connected wallet is not a Polymarket Safe owner");
|
|
96
|
-
}
|
|
97
|
-
const safeTx = params.tokenKind === "pusd" ? buildPusdUnwrapSafeTx(params.recipient, params.amount) : buildUsdceTransferSafeTx(params.recipient, params.amount);
|
|
98
|
-
const signature = _viem.concat.call(void 0, [
|
|
99
|
-
_viem.pad.call(void 0, account.address, { size: 32 }),
|
|
100
|
-
_viem.pad.call(void 0, _viem.toHex.call(void 0, 0), { size: 32 }),
|
|
101
|
-
_viem.toHex.call(void 0, 1, { size: 1 })
|
|
102
|
-
]);
|
|
103
|
-
const txHash = await params.walletClient.writeContract({
|
|
104
|
-
account,
|
|
105
|
-
chain,
|
|
106
|
-
address: params.safeAddress,
|
|
107
|
-
abi: _chunkYKGL66EFcjs.SAFE_ABI,
|
|
108
|
-
functionName: "execTransaction",
|
|
109
|
-
args: [
|
|
110
|
-
safeTx.to,
|
|
111
|
-
0n,
|
|
112
|
-
safeTx.data,
|
|
113
|
-
safeTx.operation,
|
|
114
|
-
0n,
|
|
115
|
-
0n,
|
|
116
|
-
0n,
|
|
117
|
-
_viem.zeroAddress,
|
|
118
|
-
_viem.zeroAddress,
|
|
119
|
-
signature
|
|
120
|
-
]
|
|
121
|
-
});
|
|
122
|
-
const receipt = await params.publicClient.waitForTransactionReceipt({
|
|
123
|
-
hash: txHash
|
|
124
|
-
});
|
|
125
|
-
const parsed = _viem.parseEventLogs.call(void 0, {
|
|
126
|
-
abi: _chunkYKGL66EFcjs.SAFE_ABI,
|
|
127
|
-
logs: receipt.logs.filter(
|
|
128
|
-
(log) => log.address.toLowerCase() === params.safeAddress.toLowerCase()
|
|
129
|
-
),
|
|
130
|
-
strict: false
|
|
131
|
-
});
|
|
132
|
-
if (parsed.some((log) => log.eventName === "ExecutionFailure")) {
|
|
133
|
-
throw new Error("Polymarket Safe transaction failed");
|
|
134
|
-
}
|
|
135
|
-
if (!parsed.some((log) => log.eventName === "ExecutionSuccess")) {
|
|
136
|
-
throw new Error("Polymarket Safe transaction status unavailable");
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
txHash,
|
|
140
|
-
sourceToken: POLYMARKET_USDCE_ADDRESS,
|
|
141
|
-
sourceSymbol: params.tokenKind === "pusd" ? "pUSD" : "USDC.e"
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function buildPolymarketAsset(params) {
|
|
145
|
-
const isPusd = params.kind === "pusd";
|
|
146
|
-
const symbol = isPusd ? "pUSD" : "USDC.e";
|
|
147
|
-
const balanceUsd = Number(_viem.formatUnits.call(void 0, params.balance, 6));
|
|
148
|
-
return {
|
|
149
|
-
id: `polymarket:${params.kind}`,
|
|
150
|
-
chainId: POLYMARKET_POLYGON_CHAIN_ID,
|
|
151
|
-
token: isPusd ? POLYMARKET_PUSD_ADDRESS : POLYMARKET_USDCE_ADDRESS,
|
|
152
|
-
symbol,
|
|
153
|
-
name: isPusd ? "Polymarket USD" : "Polygon USDC.e",
|
|
154
|
-
decimals: 6,
|
|
155
|
-
balance: params.balance.toString(),
|
|
156
|
-
balanceUsd: Number.isFinite(balanceUsd) ? balanceUsd : 0,
|
|
157
|
-
source: "polymarket",
|
|
158
|
-
sourceLabel: "Polymarket",
|
|
159
|
-
balanceAddress: params.safeAddress,
|
|
160
|
-
depositToken: POLYMARKET_USDCE_ADDRESS,
|
|
161
|
-
polymarketTokenKind: params.kind,
|
|
162
|
-
polymarketSafeAddress: params.safeAddress,
|
|
163
|
-
reviewLabel: isPusd ? "You send pUSD from Polymarket" : "You send USDC.e from Polymarket"
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
async function readTokenBalance(publicClient, token, holder) {
|
|
167
|
-
try {
|
|
168
|
-
return await publicClient.readContract({
|
|
169
|
-
address: token,
|
|
170
|
-
abi: _viem.erc20Abi,
|
|
171
|
-
functionName: "balanceOf",
|
|
172
|
-
args: [holder]
|
|
173
|
-
});
|
|
174
|
-
} catch (e) {
|
|
175
|
-
return 0n;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function buildUsdceTransferSafeTx(recipient, amount) {
|
|
179
|
-
return {
|
|
180
|
-
to: POLYMARKET_USDCE_ADDRESS,
|
|
181
|
-
data: _viem.encodeFunctionData.call(void 0, {
|
|
182
|
-
abi: _viem.erc20Abi,
|
|
183
|
-
functionName: "transfer",
|
|
184
|
-
args: [recipient, amount]
|
|
185
|
-
}),
|
|
186
|
-
operation: 0
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
function buildPusdUnwrapSafeTx(recipient, amount) {
|
|
190
|
-
const approveData = _viem.encodeFunctionData.call(void 0, {
|
|
191
|
-
abi: _viem.erc20Abi,
|
|
192
|
-
functionName: "approve",
|
|
193
|
-
args: [POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS, amount]
|
|
194
|
-
});
|
|
195
|
-
const unwrapData = _viem.encodeFunctionData.call(void 0, {
|
|
196
|
-
abi: COLLATERAL_OFFRAMP_ABI,
|
|
197
|
-
functionName: "unwrap",
|
|
198
|
-
args: [POLYMARKET_USDCE_ADDRESS, recipient, amount]
|
|
199
|
-
});
|
|
200
|
-
return {
|
|
201
|
-
to: SAFE_MULTI_SEND_CALL_ONLY_ADDRESS,
|
|
202
|
-
data: _viem.encodeFunctionData.call(void 0, {
|
|
203
|
-
abi: MULTI_SEND_ABI,
|
|
204
|
-
functionName: "multiSend",
|
|
205
|
-
args: [
|
|
206
|
-
_viem.concat.call(void 0, [
|
|
207
|
-
encodeMultiSendCall(POLYMARKET_PUSD_ADDRESS, approveData),
|
|
208
|
-
encodeMultiSendCall(POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS, unwrapData)
|
|
209
|
-
])
|
|
210
|
-
]
|
|
211
|
-
}),
|
|
212
|
-
operation: 1
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function encodeMultiSendCall(to, data) {
|
|
216
|
-
return _viem.encodePacked.call(void 0,
|
|
217
|
-
["uint8", "address", "uint256", "uint256", "bytes"],
|
|
218
|
-
[0, to, 0n, BigInt((data.length - 2) / 2), data]
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
exports.POLYMARKET_POLYGON_CHAIN_ID = POLYMARKET_POLYGON_CHAIN_ID; exports.POLYMARKET_SAFE_FACTORY_ADDRESS = POLYMARKET_SAFE_FACTORY_ADDRESS; exports.POLYMARKET_SAFE_INIT_CODE_HASH = POLYMARKET_SAFE_INIT_CODE_HASH; exports.POLYMARKET_USDCE_ADDRESS = POLYMARKET_USDCE_ADDRESS; exports.POLYMARKET_PUSD_ADDRESS = POLYMARKET_PUSD_ADDRESS; exports.POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS = POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS; exports.SAFE_MULTI_SEND_CALL_ONLY_ADDRESS = SAFE_MULTI_SEND_CALL_ONLY_ADDRESS; exports.derivePolymarketSafeAddress = derivePolymarketSafeAddress; exports.isPolymarketAsset = isPolymarketAsset; exports.fetchPolymarketBalances = fetchPolymarketBalances; exports.executePolymarketSafeTransfer = executePolymarketSafeTransfer;
|
package/dist/reown.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkAHQY2O3Ucjs = require('./chunk-AHQY2O3U.cjs');
|
|
4
|
-
require('./chunk-ZHLQMSQM.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunk4S262VLPcjs = require('./chunk-4S262VLP.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkYQFH2WSWcjs = require('./chunk-YQFH2WSW.cjs');
|
|
11
|
-
require('./chunk-KE6CJVOV.cjs');
|
|
12
|
-
require('./chunk-YKGL66EF.cjs');
|
|
13
|
-
require('./chunk-R2HP743T.cjs');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.DepositModal = _chunkAHQY2O3Ucjs.DepositModal; exports.WithdrawModal = _chunk4S262VLPcjs.WithdrawModal; exports.disconnectWallet = _chunkYQFH2WSWcjs.disconnectWallet;
|
package/dist/reown.d.cts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { DepositModal } from './deposit.cjs';
|
|
2
|
-
export { WithdrawModal } from './withdraw.cjs';
|
|
3
|
-
export { A as AssetOption, a as ConnectedEventData, D as DepositCompleteEventData, c as DepositFailedEventData, d as DepositModalBranding, e as DepositModalProps, f as DepositModalTheme, g as DepositModalUIConfig, h as DepositSubmittedEventData, E as ErrorEventData, W as WithdrawCompleteEventData, k as WithdrawFailedEventData, l as WithdrawModalProps, m as WithdrawSubmittedEventData } from './types-D0NawmZ8.cjs';
|
|
4
|
-
export { S as SafeTransactionRequest } from './safe-CB7TvRCc.cjs';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
6
|
-
import 'viem';
|
|
7
|
-
|
|
8
|
-
declare function disconnectWallet(): Promise<void>;
|
|
9
|
-
|
|
10
|
-
export { disconnectWallet };
|
package/dist/reown.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { DepositModal } from './deposit.js';
|
|
2
|
-
export { WithdrawModal } from './withdraw.js';
|
|
3
|
-
export { A as AssetOption, a as ConnectedEventData, D as DepositCompleteEventData, c as DepositFailedEventData, d as DepositModalBranding, e as DepositModalProps, f as DepositModalTheme, g as DepositModalUIConfig, h as DepositSubmittedEventData, E as ErrorEventData, W as WithdrawCompleteEventData, k as WithdrawFailedEventData, l as WithdrawModalProps, m as WithdrawSubmittedEventData } from './types-CeFbJ-MW.js';
|
|
4
|
-
export { S as SafeTransactionRequest } from './safe-CB7TvRCc.js';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
6
|
-
import 'viem';
|
|
7
|
-
|
|
8
|
-
declare function disconnectWallet(): Promise<void>;
|
|
9
|
-
|
|
10
|
-
export { disconnectWallet };
|
package/dist/reown.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DepositModal
|
|
3
|
-
} from "./chunk-RQ2VCKLS.mjs";
|
|
4
|
-
import "./chunk-LHOHM67Z.mjs";
|
|
5
|
-
import {
|
|
6
|
-
WithdrawModal
|
|
7
|
-
} from "./chunk-WA4RA4HB.mjs";
|
|
8
|
-
import {
|
|
9
|
-
disconnectWallet
|
|
10
|
-
} from "./chunk-5YXAQB6A.mjs";
|
|
11
|
-
import "./chunk-DUGDAMAF.mjs";
|
|
12
|
-
import "./chunk-J2SWZSXL.mjs";
|
|
13
|
-
import "./chunk-WHW3ZMOT.mjs";
|
|
14
|
-
export {
|
|
15
|
-
DepositModal,
|
|
16
|
-
WithdrawModal,
|
|
17
|
-
disconnectWallet
|
|
18
|
-
};
|
package/dist/safe-CB7TvRCc.d.cts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Address, Hex } from 'viem';
|
|
2
|
-
|
|
3
|
-
interface SafeTransactionRequest {
|
|
4
|
-
chainId: number;
|
|
5
|
-
safeAddress: Address;
|
|
6
|
-
safeTxHash: Hex;
|
|
7
|
-
typedData: {
|
|
8
|
-
domain: {
|
|
9
|
-
chainId: number;
|
|
10
|
-
verifyingContract: Address;
|
|
11
|
-
};
|
|
12
|
-
types: typeof SAFE_TX_TYPES;
|
|
13
|
-
primaryType: "SafeTx";
|
|
14
|
-
message: {
|
|
15
|
-
to: Address;
|
|
16
|
-
value: bigint;
|
|
17
|
-
data: Hex;
|
|
18
|
-
operation: number;
|
|
19
|
-
safeTxGas: bigint;
|
|
20
|
-
baseGas: bigint;
|
|
21
|
-
gasPrice: bigint;
|
|
22
|
-
gasToken: Address;
|
|
23
|
-
refundReceiver: Address;
|
|
24
|
-
nonce: bigint;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
declare const SAFE_TX_TYPES: {
|
|
29
|
-
readonly SafeTx: readonly [{
|
|
30
|
-
readonly name: "to";
|
|
31
|
-
readonly type: "address";
|
|
32
|
-
}, {
|
|
33
|
-
readonly name: "value";
|
|
34
|
-
readonly type: "uint256";
|
|
35
|
-
}, {
|
|
36
|
-
readonly name: "data";
|
|
37
|
-
readonly type: "bytes";
|
|
38
|
-
}, {
|
|
39
|
-
readonly name: "operation";
|
|
40
|
-
readonly type: "uint8";
|
|
41
|
-
}, {
|
|
42
|
-
readonly name: "safeTxGas";
|
|
43
|
-
readonly type: "uint256";
|
|
44
|
-
}, {
|
|
45
|
-
readonly name: "baseGas";
|
|
46
|
-
readonly type: "uint256";
|
|
47
|
-
}, {
|
|
48
|
-
readonly name: "gasPrice";
|
|
49
|
-
readonly type: "uint256";
|
|
50
|
-
}, {
|
|
51
|
-
readonly name: "gasToken";
|
|
52
|
-
readonly type: "address";
|
|
53
|
-
}, {
|
|
54
|
-
readonly name: "refundReceiver";
|
|
55
|
-
readonly type: "address";
|
|
56
|
-
}, {
|
|
57
|
-
readonly name: "nonce";
|
|
58
|
-
readonly type: "uint256";
|
|
59
|
-
}];
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type { SafeTransactionRequest as S };
|