@rhinestone/deposit-modal 0.2.4 → 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-CY5MSQGK.mjs → DepositModalReown-GXY65HZP.mjs} +3 -3
- package/dist/{DepositModalReown-2UMPITRN.cjs → DepositModalReown-HVIEA6YA.cjs} +4 -4
- package/dist/QRCode-SMMYPUQC.cjs +58 -0
- package/dist/QRCode-YMQTKSSK.mjs +58 -0
- package/dist/{WithdrawModalReown-Z5BUZQ4Z.cjs → WithdrawModalReown-4M3PBY2T.cjs} +4 -4
- package/dist/{WithdrawModalReown-YSRO5ZTA.mjs → WithdrawModalReown-O6V6KRH6.mjs} +3 -3
- package/dist/{chunk-ARGMXV6E.cjs → chunk-7SYZG47X.cjs} +1723 -1881
- package/dist/{chunk-WHW3ZMOT.mjs → chunk-EEHUOFIW.mjs} +107 -90
- package/dist/{chunk-KJEHVIPZ.mjs → chunk-FKPTIHU7.mjs} +631 -423
- package/dist/{chunk-HFQV7EHS.mjs → chunk-U5QIFNG4.mjs} +1774 -1932
- package/dist/{chunk-WNFGZS56.mjs → chunk-UIHAYD7J.mjs} +1079 -784
- package/dist/{chunk-R2HP743T.cjs → chunk-XCAF6B3D.cjs} +51 -34
- package/dist/{chunk-NFXJEOE6.cjs → chunk-Y3RA3YGA.cjs} +1101 -806
- package/dist/{chunk-QUOP5C6V.cjs → chunk-Z2SIC2TH.cjs} +686 -478
- 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 -4
- package/dist/deposit.d.cts +2 -3
- package/dist/deposit.d.ts +2 -3
- package/dist/deposit.mjs +3 -3
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +4 -4
- package/dist/styles.css +1068 -752
- package/dist/{types-DGQzvl6v.d.ts → types-DRou84ZM.d.cts} +147 -33
- package/dist/{types-DJ1fzNC7.d.cts → types-DRou84ZM.d.ts} +147 -33
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -3
- package/dist/withdraw.d.ts +2 -3
- package/dist/withdraw.mjs +3 -3
- package/package.json +13 -12
- package/dist/reown.cjs +0 -16
- package/dist/reown.d.cts +0 -10
- package/dist/reown.d.ts +0 -10
- package/dist/reown.mjs +0 -16
- package/dist/safe.cjs +0 -1
- package/dist/safe.d.cts +0 -62
- package/dist/safe.d.ts +0 -62
- package/dist/safe.mjs +0 -0
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var _chunkNFXJEOE6cjs = require('./chunk-NFXJEOE6.cjs');
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
|
|
@@ -29,12 +28,20 @@ var _chunkNFXJEOE6cjs = require('./chunk-NFXJEOE6.cjs');
|
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
|
|
31
|
+
var _chunkY3RA3YGAcjs = require('./chunk-Y3RA3YGA.cjs');
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
var _chunkXCAF6B3Dcjs = require('./chunk-XCAF6B3D.cjs');
|
|
38
45
|
|
|
39
46
|
// src/WithdrawModal.tsx
|
|
40
47
|
|
|
@@ -50,6 +57,121 @@ var _react = require('react');
|
|
|
50
57
|
// src/WithdrawFlow.tsx
|
|
51
58
|
|
|
52
59
|
|
|
60
|
+
// src/store/withdraw.tsx
|
|
61
|
+
|
|
62
|
+
var _zustand = require('zustand');
|
|
63
|
+
var _vanilla = require('zustand/vanilla');
|
|
64
|
+
function unreachable(action) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`[deposit-modal/withdraw-store] Unhandled action: ${JSON.stringify(action)}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function applyWithdrawAction(state, action) {
|
|
70
|
+
switch (action.type) {
|
|
71
|
+
case "wallet/id-selected":
|
|
72
|
+
return { ...state, selectedWalletId: action.walletId };
|
|
73
|
+
case "registration/started":
|
|
74
|
+
return {
|
|
75
|
+
...state,
|
|
76
|
+
registration: state.registration.kind === "ready" ? {
|
|
77
|
+
kind: "stale",
|
|
78
|
+
smartAccount: state.registration.smartAccount,
|
|
79
|
+
registeredTarget: state.registration.registeredTarget
|
|
80
|
+
} : { kind: "pending" }
|
|
81
|
+
};
|
|
82
|
+
case "registration/ready":
|
|
83
|
+
return {
|
|
84
|
+
...state,
|
|
85
|
+
registration: {
|
|
86
|
+
kind: "ready",
|
|
87
|
+
smartAccount: action.smartAccount,
|
|
88
|
+
registeredTarget: action.registeredTarget
|
|
89
|
+
},
|
|
90
|
+
step: state.step === "connect" ? "form" : state.step
|
|
91
|
+
};
|
|
92
|
+
case "registration/failed":
|
|
93
|
+
return {
|
|
94
|
+
...state,
|
|
95
|
+
registration: { kind: "failed", error: action.error }
|
|
96
|
+
};
|
|
97
|
+
case "form/continue":
|
|
98
|
+
return {
|
|
99
|
+
...state,
|
|
100
|
+
amount: action.amount,
|
|
101
|
+
recipient: action.recipient,
|
|
102
|
+
step: "review"
|
|
103
|
+
};
|
|
104
|
+
case "review/back":
|
|
105
|
+
return { ...state, step: "form" };
|
|
106
|
+
case "withdraw/submitted":
|
|
107
|
+
return { ...state, txHash: action.txHash, step: "processing" };
|
|
108
|
+
case "withdraw/complete":
|
|
109
|
+
return { ...state, step: "complete" };
|
|
110
|
+
case "withdraw/failed":
|
|
111
|
+
return { ...state, step: "failed" };
|
|
112
|
+
case "flow/reset":
|
|
113
|
+
return {
|
|
114
|
+
...state,
|
|
115
|
+
step: "form",
|
|
116
|
+
amount: null,
|
|
117
|
+
recipient: null,
|
|
118
|
+
txHash: null
|
|
119
|
+
};
|
|
120
|
+
case "modal/reset":
|
|
121
|
+
return {
|
|
122
|
+
...state,
|
|
123
|
+
step: "connect",
|
|
124
|
+
selectedWalletId: null,
|
|
125
|
+
registration: { kind: "idle" },
|
|
126
|
+
amount: null,
|
|
127
|
+
recipient: null,
|
|
128
|
+
txHash: null
|
|
129
|
+
};
|
|
130
|
+
default:
|
|
131
|
+
return unreachable(action);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function createWithdrawStore() {
|
|
135
|
+
const store = _vanilla.createStore.call(void 0, () => ({
|
|
136
|
+
step: "connect",
|
|
137
|
+
selectedWalletId: null,
|
|
138
|
+
registration: { kind: "idle" },
|
|
139
|
+
amount: null,
|
|
140
|
+
recipient: null,
|
|
141
|
+
txHash: null
|
|
142
|
+
}));
|
|
143
|
+
return {
|
|
144
|
+
...store,
|
|
145
|
+
dispatch(action) {
|
|
146
|
+
store.setState((state) => applyWithdrawAction(state, action));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
var WithdrawStoreContext = _react.createContext.call(void 0, null);
|
|
151
|
+
function WithdrawStoreProvider({
|
|
152
|
+
store,
|
|
153
|
+
children
|
|
154
|
+
}) {
|
|
155
|
+
return _react.createElement.call(void 0,
|
|
156
|
+
WithdrawStoreContext.Provider,
|
|
157
|
+
{ value: store },
|
|
158
|
+
children
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
function useWithdrawStoreApi() {
|
|
162
|
+
const store = _react.useContext.call(void 0, WithdrawStoreContext);
|
|
163
|
+
if (!store) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
"useWithdrawStore must be called inside <WithdrawStoreProvider>"
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return store;
|
|
169
|
+
}
|
|
170
|
+
function useWithdrawStore(selector) {
|
|
171
|
+
const store = useWithdrawStoreApi();
|
|
172
|
+
return _zustand.useStore.call(void 0, store, selector);
|
|
173
|
+
}
|
|
174
|
+
|
|
53
175
|
// src/components/steps/WithdrawFormStep.tsx
|
|
54
176
|
|
|
55
177
|
var _viem = require('viem');
|
|
@@ -82,6 +204,9 @@ function WithdrawFormStep({
|
|
|
82
204
|
switchChain,
|
|
83
205
|
walletIcon,
|
|
84
206
|
submitting = false,
|
|
207
|
+
registrationPending = false,
|
|
208
|
+
registrationError = null,
|
|
209
|
+
onRecipientChange,
|
|
85
210
|
onSubmit,
|
|
86
211
|
onBalanceUsdChange
|
|
87
212
|
}) {
|
|
@@ -107,8 +232,8 @@ function WithdrawFormStep({
|
|
|
107
232
|
const chainMismatch = Boolean(
|
|
108
233
|
_optionalChain([walletClient, 'optionalAccess', _3 => _3.chain, 'optionalAccess', _4 => _4.id]) && walletClient.chain.id !== asset.chainId
|
|
109
234
|
);
|
|
110
|
-
const targetSymbol =
|
|
111
|
-
const targetChainName =
|
|
235
|
+
const targetSymbol = _chunkXCAF6B3Dcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
236
|
+
const targetChainName = _chunkXCAF6B3Dcjs.getChainName.call(void 0, targetChain);
|
|
112
237
|
const isBusy = submitting || isSubmitting;
|
|
113
238
|
const seededRecipientRef = _react.useRef.call(void 0, _nullishCoalesce(defaultRecipient, () => ( "")));
|
|
114
239
|
_react.useEffect.call(void 0, () => {
|
|
@@ -127,7 +252,7 @@ function WithdrawFormStep({
|
|
|
127
252
|
setIsSwitching(true);
|
|
128
253
|
switchChain(asset.chainId).catch((err) => {
|
|
129
254
|
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
130
|
-
setError(
|
|
255
|
+
setError(_chunkY3RA3YGAcjs.formatUserError.call(void 0, raw));
|
|
131
256
|
}).finally(() => {
|
|
132
257
|
setIsSwitching(false);
|
|
133
258
|
});
|
|
@@ -147,7 +272,7 @@ function WithdrawFormStep({
|
|
|
147
272
|
return;
|
|
148
273
|
}
|
|
149
274
|
try {
|
|
150
|
-
const bal =
|
|
275
|
+
const bal = _chunkY3RA3YGAcjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
|
|
151
276
|
address: asset.token,
|
|
152
277
|
abi: _viem.erc20Abi,
|
|
153
278
|
functionName: "balanceOf",
|
|
@@ -220,8 +345,9 @@ function WithdrawFormStep({
|
|
|
220
345
|
const handleUseConnected = _react.useCallback.call(void 0, () => {
|
|
221
346
|
if (!preferredConnectedRecipient) return;
|
|
222
347
|
setRecipient(preferredConnectedRecipient);
|
|
348
|
+
_optionalChain([onRecipientChange, 'optionalCall', _6 => _6(preferredConnectedRecipient)]);
|
|
223
349
|
setError(null);
|
|
224
|
-
}, [preferredConnectedRecipient]);
|
|
350
|
+
}, [preferredConnectedRecipient, onRecipientChange]);
|
|
225
351
|
const handleWithdraw = _react.useCallback.call(void 0, async () => {
|
|
226
352
|
if (!recipient || !/^0x[a-fA-F0-9]{40}$/.test(recipient)) {
|
|
227
353
|
setError("Enter a valid recipient address");
|
|
@@ -250,7 +376,7 @@ function WithdrawFormStep({
|
|
|
250
376
|
await onSubmit(recipient, amount);
|
|
251
377
|
} catch (err) {
|
|
252
378
|
const raw = err instanceof Error ? err.message : "Withdrawal failed";
|
|
253
|
-
setError(
|
|
379
|
+
setError(_chunkY3RA3YGAcjs.formatUserError.call(void 0, raw));
|
|
254
380
|
} finally {
|
|
255
381
|
setIsSubmitting(false);
|
|
256
382
|
}
|
|
@@ -258,15 +384,16 @@ function WithdrawFormStep({
|
|
|
258
384
|
if (isBalanceLoading) {
|
|
259
385
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
260
386
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body rs-withdraw-loading", children: [
|
|
261
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
387
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.Spinner, { className: "rs-spinner--lg" }),
|
|
262
388
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-title", children: "Loading on-chain balance" }),
|
|
263
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-subtitle", children: chainMismatch ? `Switch to ${
|
|
389
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-subtitle", children: chainMismatch ? `Switch to ${_chunkXCAF6B3Dcjs.getChainName.call(void 0, asset.chainId)} to continue.` : "Please wait before withdrawing." })
|
|
264
390
|
] }),
|
|
265
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
391
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.PoweredBy, {})
|
|
266
392
|
] });
|
|
267
393
|
}
|
|
268
394
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
269
395
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body rs-withdraw-form", children: [
|
|
396
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.BodyHeader, { icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.CircleArrowOutUpLeftIcon, {}), title: "Withdraw" }),
|
|
270
397
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-section", children: [
|
|
271
398
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: "rs-withdraw-label", children: "Recipient address" }),
|
|
272
399
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-input-row", children: [
|
|
@@ -278,7 +405,9 @@ function WithdrawFormStep({
|
|
|
278
405
|
placeholder: "0x...",
|
|
279
406
|
value: recipient,
|
|
280
407
|
onChange: (e) => {
|
|
281
|
-
|
|
408
|
+
const next = e.target.value.trim();
|
|
409
|
+
setRecipient(next);
|
|
410
|
+
_optionalChain([onRecipientChange, 'optionalCall', _7 => _7(next)]);
|
|
282
411
|
if (error) setError(null);
|
|
283
412
|
}
|
|
284
413
|
}
|
|
@@ -302,24 +431,7 @@ function WithdrawFormStep({
|
|
|
302
431
|
),
|
|
303
432
|
isRecipientConnected ? null : "Use connected"
|
|
304
433
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
305
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
306
|
-
"svg",
|
|
307
|
-
{
|
|
308
|
-
viewBox: "0 0 24 24",
|
|
309
|
-
fill: "none",
|
|
310
|
-
stroke: "currentColor",
|
|
311
|
-
strokeWidth: "2",
|
|
312
|
-
className: "rs-withdraw-use-connected-icon",
|
|
313
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
314
|
-
"path",
|
|
315
|
-
{
|
|
316
|
-
strokeLinecap: "round",
|
|
317
|
-
strokeLinejoin: "round",
|
|
318
|
-
d: "M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"
|
|
319
|
-
}
|
|
320
|
-
)
|
|
321
|
-
}
|
|
322
|
-
),
|
|
434
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.WalletIcon, { className: "rs-withdraw-use-connected-icon" }),
|
|
323
435
|
isRecipientConnected ? null : "Use connected"
|
|
324
436
|
] })
|
|
325
437
|
}
|
|
@@ -346,22 +458,19 @@ function WithdrawFormStep({
|
|
|
346
458
|
}
|
|
347
459
|
}
|
|
348
460
|
),
|
|
349
|
-
/* @__PURE__ */ _jsxruntime.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
"button",
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
)
|
|
361
|
-
] })
|
|
461
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-amount-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
462
|
+
"button",
|
|
463
|
+
{
|
|
464
|
+
type: "button",
|
|
465
|
+
className: "rs-withdraw-max-btn",
|
|
466
|
+
onClick: handleMaxClick,
|
|
467
|
+
disabled: balance === null,
|
|
468
|
+
children: "Max"
|
|
469
|
+
}
|
|
470
|
+
) })
|
|
362
471
|
] }),
|
|
363
472
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-amount-info", children: [
|
|
364
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ?
|
|
473
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkY3RA3YGAcjs.currencyFormatter.format(amountUsd) : "$0.00" }),
|
|
365
474
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-withdraw-balance", children: [
|
|
366
475
|
"Balance: ",
|
|
367
476
|
formattedBalance,
|
|
@@ -372,12 +481,12 @@ function WithdrawFormStep({
|
|
|
372
481
|
] }),
|
|
373
482
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-receive-row", children: [
|
|
374
483
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-receive-col", children: [
|
|
375
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: "rs-withdraw-label", children: "Receive
|
|
484
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: "rs-withdraw-label rs-withdraw-label--sm", children: "Receive chain" }),
|
|
376
485
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
377
486
|
"div",
|
|
378
487
|
{
|
|
379
488
|
className: "rs-withdraw-dropdown-container",
|
|
380
|
-
ref:
|
|
489
|
+
ref: chainDropdownRef,
|
|
381
490
|
children: [
|
|
382
491
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
383
492
|
"button",
|
|
@@ -385,79 +494,67 @@ function WithdrawFormStep({
|
|
|
385
494
|
type: "button",
|
|
386
495
|
className: "rs-withdraw-dropdown",
|
|
387
496
|
onClick: () => {
|
|
388
|
-
|
|
389
|
-
|
|
497
|
+
setShowChainDropdown(!showChainDropdown);
|
|
498
|
+
setShowTokenDropdown(false);
|
|
390
499
|
},
|
|
391
500
|
children: [
|
|
392
501
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-dropdown-value", children: [
|
|
393
|
-
|
|
502
|
+
_chunkXCAF6B3Dcjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
394
503
|
"img",
|
|
395
504
|
{
|
|
396
|
-
src:
|
|
397
|
-
alt:
|
|
505
|
+
src: _chunkXCAF6B3Dcjs.getChainIcon.call(void 0, targetChain),
|
|
506
|
+
alt: targetChainName,
|
|
398
507
|
className: "rs-withdraw-dropdown-icon"
|
|
399
508
|
}
|
|
400
509
|
),
|
|
401
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
510
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: targetChainName })
|
|
402
511
|
] }),
|
|
403
512
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
404
|
-
|
|
513
|
+
_chunkY3RA3YGAcjs.ChevronDownIcon,
|
|
405
514
|
{
|
|
406
|
-
viewBox: "0 0 24 24",
|
|
407
|
-
fill: "none",
|
|
408
|
-
stroke: "currentColor",
|
|
409
|
-
strokeWidth: "2",
|
|
410
515
|
className: "rs-withdraw-dropdown-arrow",
|
|
411
516
|
style: {
|
|
412
|
-
transform:
|
|
413
|
-
}
|
|
414
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
415
|
-
"path",
|
|
416
|
-
{
|
|
417
|
-
strokeLinecap: "round",
|
|
418
|
-
strokeLinejoin: "round",
|
|
419
|
-
d: "M19 9l-7 7-7-7"
|
|
420
|
-
}
|
|
421
|
-
)
|
|
517
|
+
transform: showChainDropdown ? "rotate(180deg)" : void 0
|
|
518
|
+
}
|
|
422
519
|
}
|
|
423
520
|
)
|
|
424
521
|
]
|
|
425
522
|
}
|
|
426
523
|
),
|
|
427
|
-
|
|
524
|
+
showChainDropdown && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-dropdown-menu", children: targetChains.map((chain) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
428
525
|
"button",
|
|
429
526
|
{
|
|
430
527
|
type: "button",
|
|
431
528
|
className: "rs-withdraw-dropdown-item",
|
|
432
529
|
onClick: () => {
|
|
433
|
-
|
|
434
|
-
|
|
530
|
+
onTargetChainChange(chain.id);
|
|
531
|
+
setShowChainDropdown(false);
|
|
435
532
|
},
|
|
436
533
|
children: [
|
|
437
|
-
|
|
534
|
+
_chunkXCAF6B3Dcjs.getChainIcon.call(void 0, chain.id) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
438
535
|
"img",
|
|
439
536
|
{
|
|
440
|
-
src:
|
|
441
|
-
alt:
|
|
537
|
+
src: _chunkXCAF6B3Dcjs.getChainIcon.call(void 0, chain.id),
|
|
538
|
+
alt: chain.name,
|
|
442
539
|
className: "rs-withdraw-dropdown-icon"
|
|
443
540
|
}
|
|
444
541
|
),
|
|
445
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
542
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: chain.name })
|
|
446
543
|
]
|
|
447
544
|
},
|
|
448
|
-
|
|
545
|
+
chain.id
|
|
449
546
|
)) })
|
|
450
547
|
]
|
|
451
548
|
}
|
|
452
549
|
)
|
|
453
550
|
] }),
|
|
454
551
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-receive-col", children: [
|
|
455
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: "rs-withdraw-label", children: "Receive
|
|
552
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: "rs-withdraw-label rs-withdraw-label--sm", children: "Receive token" }),
|
|
456
553
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
457
554
|
"div",
|
|
458
555
|
{
|
|
459
556
|
className: "rs-withdraw-dropdown-container",
|
|
460
|
-
ref:
|
|
557
|
+
ref: tokenDropdownRef,
|
|
461
558
|
children: [
|
|
462
559
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
463
560
|
"button",
|
|
@@ -465,110 +562,209 @@ function WithdrawFormStep({
|
|
|
465
562
|
type: "button",
|
|
466
563
|
className: "rs-withdraw-dropdown",
|
|
467
564
|
onClick: () => {
|
|
468
|
-
|
|
469
|
-
|
|
565
|
+
setShowTokenDropdown(!showTokenDropdown);
|
|
566
|
+
setShowChainDropdown(false);
|
|
470
567
|
},
|
|
471
568
|
children: [
|
|
472
569
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-dropdown-value", children: [
|
|
473
|
-
|
|
570
|
+
_chunkXCAF6B3Dcjs.getTokenIcon.call(void 0, targetSymbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
474
571
|
"img",
|
|
475
572
|
{
|
|
476
|
-
src:
|
|
477
|
-
alt:
|
|
573
|
+
src: _chunkXCAF6B3Dcjs.getTokenIcon.call(void 0, targetSymbol),
|
|
574
|
+
alt: targetSymbol,
|
|
478
575
|
className: "rs-withdraw-dropdown-icon"
|
|
479
576
|
}
|
|
480
577
|
),
|
|
481
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
578
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: targetSymbol })
|
|
482
579
|
] }),
|
|
483
580
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
484
|
-
|
|
581
|
+
_chunkY3RA3YGAcjs.ChevronDownIcon,
|
|
485
582
|
{
|
|
486
|
-
viewBox: "0 0 24 24",
|
|
487
|
-
fill: "none",
|
|
488
|
-
stroke: "currentColor",
|
|
489
|
-
strokeWidth: "2",
|
|
490
583
|
className: "rs-withdraw-dropdown-arrow",
|
|
491
584
|
style: {
|
|
492
|
-
transform:
|
|
493
|
-
}
|
|
494
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
495
|
-
"path",
|
|
496
|
-
{
|
|
497
|
-
strokeLinecap: "round",
|
|
498
|
-
strokeLinejoin: "round",
|
|
499
|
-
d: "M19 9l-7 7-7-7"
|
|
500
|
-
}
|
|
501
|
-
)
|
|
585
|
+
transform: showTokenDropdown ? "rotate(180deg)" : void 0
|
|
586
|
+
}
|
|
502
587
|
}
|
|
503
588
|
)
|
|
504
589
|
]
|
|
505
590
|
}
|
|
506
591
|
),
|
|
507
|
-
|
|
592
|
+
showTokenDropdown && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-dropdown-menu", children: targetTokenOptions.map((option) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
508
593
|
"button",
|
|
509
594
|
{
|
|
510
595
|
type: "button",
|
|
511
596
|
className: "rs-withdraw-dropdown-item",
|
|
512
597
|
onClick: () => {
|
|
513
|
-
|
|
514
|
-
|
|
598
|
+
onTargetTokenChange(option.address);
|
|
599
|
+
setShowTokenDropdown(false);
|
|
515
600
|
},
|
|
516
601
|
children: [
|
|
517
|
-
|
|
602
|
+
_chunkXCAF6B3Dcjs.getTokenIcon.call(void 0, option.symbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
518
603
|
"img",
|
|
519
604
|
{
|
|
520
|
-
src:
|
|
521
|
-
alt:
|
|
605
|
+
src: _chunkXCAF6B3Dcjs.getTokenIcon.call(void 0, option.symbol),
|
|
606
|
+
alt: option.symbol,
|
|
522
607
|
className: "rs-withdraw-dropdown-icon"
|
|
523
608
|
}
|
|
524
609
|
),
|
|
525
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
610
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: option.symbol })
|
|
526
611
|
]
|
|
527
612
|
},
|
|
528
|
-
|
|
613
|
+
option.address
|
|
529
614
|
)) })
|
|
530
615
|
]
|
|
531
616
|
}
|
|
532
617
|
)
|
|
533
618
|
] })
|
|
534
619
|
] }),
|
|
535
|
-
chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${
|
|
620
|
+
chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${_chunkXCAF6B3Dcjs.getChainName.call(void 0, asset.chainId)}...` : `Switch to ${_chunkXCAF6B3Dcjs.getChainName.call(void 0, asset.chainId)} to continue.` }) }),
|
|
536
621
|
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-error", children: [
|
|
537
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
538
|
-
"svg",
|
|
539
|
-
{
|
|
540
|
-
viewBox: "0 0 24 24",
|
|
541
|
-
fill: "none",
|
|
542
|
-
stroke: "currentColor",
|
|
543
|
-
strokeWidth: "2",
|
|
544
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
545
|
-
"path",
|
|
546
|
-
{
|
|
547
|
-
strokeLinecap: "round",
|
|
548
|
-
strokeLinejoin: "round",
|
|
549
|
-
d: "M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
|
|
550
|
-
}
|
|
551
|
-
)
|
|
552
|
-
}
|
|
553
|
-
),
|
|
622
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.AlertTriangleIcon, {}),
|
|
554
623
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: error })
|
|
624
|
+
] }),
|
|
625
|
+
!error && registrationError && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-error", children: [
|
|
626
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.AlertTriangleIcon, {}),
|
|
627
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: registrationError })
|
|
555
628
|
] })
|
|
556
629
|
] }),
|
|
557
630
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
558
|
-
|
|
631
|
+
_chunkY3RA3YGAcjs.Button,
|
|
559
632
|
{
|
|
560
633
|
onClick: handleWithdraw,
|
|
561
634
|
fullWidth: true,
|
|
562
635
|
loading: isBusy,
|
|
563
|
-
disabled: !recipient || !amount || chainMismatch || isBusy,
|
|
564
|
-
children: isBusy ? "Preparing..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
|
|
636
|
+
disabled: !recipient || !amount || chainMismatch || isBusy || Boolean(registrationError),
|
|
637
|
+
children: isBusy ? "Preparing..." : registrationPending ? "Preparing session..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
|
|
565
638
|
}
|
|
566
639
|
) }),
|
|
567
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
640
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.PoweredBy, {})
|
|
568
641
|
] });
|
|
569
642
|
}
|
|
570
643
|
WithdrawFormStep.displayName = "WithdrawFormStep";
|
|
571
644
|
|
|
645
|
+
// src/components/steps/WithdrawReviewStep.tsx
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
function shortenAddress(addr) {
|
|
649
|
+
return addr.length > 12 ? `${addr.slice(0, 6)}\u2026${addr.slice(-4)}` : addr;
|
|
650
|
+
}
|
|
651
|
+
function WithdrawReviewStep({
|
|
652
|
+
sourceChain,
|
|
653
|
+
sourceSymbol,
|
|
654
|
+
targetChain,
|
|
655
|
+
targetToken,
|
|
656
|
+
amount,
|
|
657
|
+
recipient,
|
|
658
|
+
estimatedTime = "< 1 min",
|
|
659
|
+
registrationPending = false,
|
|
660
|
+
registrationError = null,
|
|
661
|
+
onConfirm,
|
|
662
|
+
onError
|
|
663
|
+
}) {
|
|
664
|
+
const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
|
|
665
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
666
|
+
const sourceChainName = _chunkXCAF6B3Dcjs.getChainName.call(void 0, sourceChain);
|
|
667
|
+
const sourceChainIcon = _chunkXCAF6B3Dcjs.getChainIcon.call(void 0, sourceChain);
|
|
668
|
+
const targetSymbol = _chunkXCAF6B3Dcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
669
|
+
const targetChainName = _chunkXCAF6B3Dcjs.getChainName.call(void 0, targetChain);
|
|
670
|
+
const targetChainIcon = _chunkXCAF6B3Dcjs.getChainIcon.call(void 0, targetChain);
|
|
671
|
+
const sourceTokenIcon = _chunkXCAF6B3Dcjs.getTokenIcon.call(void 0, sourceSymbol);
|
|
672
|
+
const targetTokenIcon = _chunkXCAF6B3Dcjs.getTokenIcon.call(void 0, targetSymbol);
|
|
673
|
+
const handleConfirm = async () => {
|
|
674
|
+
setError(null);
|
|
675
|
+
setIsSubmitting(true);
|
|
676
|
+
try {
|
|
677
|
+
await onConfirm();
|
|
678
|
+
} catch (err) {
|
|
679
|
+
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
680
|
+
const message = _chunkY3RA3YGAcjs.formatUserError.call(void 0, raw);
|
|
681
|
+
setError(message);
|
|
682
|
+
_optionalChain([onError, 'optionalCall', _8 => _8(message, "WITHDRAW_REVIEW_ERROR")]);
|
|
683
|
+
} finally {
|
|
684
|
+
setIsSubmitting(false);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
const disabled = isSubmitting || registrationPending || Boolean(registrationError);
|
|
688
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
|
|
689
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
690
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
691
|
+
_chunkY3RA3YGAcjs.BodyHeader,
|
|
692
|
+
{
|
|
693
|
+
icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.CircleArrowOutUpLeftIcon, {}),
|
|
694
|
+
title: "Review withdrawal"
|
|
695
|
+
}
|
|
696
|
+
),
|
|
697
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-details", children: [
|
|
698
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
|
|
699
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "You send" }),
|
|
700
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-detail-value", children: [
|
|
701
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
|
|
702
|
+
amount,
|
|
703
|
+
" ",
|
|
704
|
+
sourceSymbol
|
|
705
|
+
] }),
|
|
706
|
+
sourceTokenIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: sourceTokenIcon, alt: "" }) })
|
|
707
|
+
] })
|
|
708
|
+
] }),
|
|
709
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
|
|
710
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Source chain" }),
|
|
711
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-detail-value", children: [
|
|
712
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: sourceChainName }),
|
|
713
|
+
sourceChainIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: sourceChainIcon, alt: "" }) })
|
|
714
|
+
] })
|
|
715
|
+
] }),
|
|
716
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
|
|
717
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Recipient" }),
|
|
718
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-value", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: shortenAddress(recipient) }) })
|
|
719
|
+
] }),
|
|
720
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
|
|
721
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Receive" }),
|
|
722
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-detail-value", children: [
|
|
723
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
|
|
724
|
+
amount,
|
|
725
|
+
" ",
|
|
726
|
+
targetSymbol
|
|
727
|
+
] }),
|
|
728
|
+
targetTokenIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: targetTokenIcon, alt: "" }) })
|
|
729
|
+
] })
|
|
730
|
+
] }),
|
|
731
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
|
|
732
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Destination chain" }),
|
|
733
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-detail-value", children: [
|
|
734
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: targetChainName }),
|
|
735
|
+
targetChainIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: targetChainIcon, alt: "" }) })
|
|
736
|
+
] })
|
|
737
|
+
] }),
|
|
738
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
|
|
739
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Estimated time" }),
|
|
740
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-value", children: estimatedTime })
|
|
741
|
+
] })
|
|
742
|
+
] }),
|
|
743
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-error", role: "alert", children: [
|
|
744
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
745
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: error })
|
|
746
|
+
] }),
|
|
747
|
+
!error && registrationError && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-error", role: "alert", children: [
|
|
748
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
749
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: registrationError })
|
|
750
|
+
] }),
|
|
751
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
752
|
+
_chunkY3RA3YGAcjs.Button,
|
|
753
|
+
{
|
|
754
|
+
onClick: handleConfirm,
|
|
755
|
+
loading: isSubmitting,
|
|
756
|
+
loadingText: "Submitting transaction...",
|
|
757
|
+
disabled,
|
|
758
|
+
fullWidth: true,
|
|
759
|
+
children: "Continue"
|
|
760
|
+
}
|
|
761
|
+
)
|
|
762
|
+
] }),
|
|
763
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.PoweredBy, {})
|
|
764
|
+
] });
|
|
765
|
+
}
|
|
766
|
+
WithdrawReviewStep.displayName = "WithdrawReviewStep";
|
|
767
|
+
|
|
572
768
|
// src/core/safe.ts
|
|
573
769
|
|
|
574
770
|
|
|
@@ -647,7 +843,7 @@ async function executeSafeEthTransfer(params) {
|
|
|
647
843
|
throw new Error("Wallet not connected");
|
|
648
844
|
}
|
|
649
845
|
if (chain.id !== chainId) {
|
|
650
|
-
throw new Error(`Switch to ${
|
|
846
|
+
throw new Error(`Switch to ${_chunkXCAF6B3Dcjs.getChainName.call(void 0, chainId)} to sign`);
|
|
651
847
|
}
|
|
652
848
|
const isOwner = await publicClient.readContract({
|
|
653
849
|
address: safeAddress,
|
|
@@ -730,7 +926,7 @@ async function executeSafeErc20Transfer(params) {
|
|
|
730
926
|
throw new Error("Wallet not connected");
|
|
731
927
|
}
|
|
732
928
|
if (chain.id !== chainId) {
|
|
733
|
-
throw new Error(`Switch to ${
|
|
929
|
+
throw new Error(`Switch to ${_chunkXCAF6B3Dcjs.getChainName.call(void 0, chainId)} to sign`);
|
|
734
930
|
}
|
|
735
931
|
const isOwner = await publicClient.readContract({
|
|
736
932
|
address: safeAddress,
|
|
@@ -857,6 +1053,24 @@ async function buildSafeTransaction(params) {
|
|
|
857
1053
|
// src/WithdrawFlow.tsx
|
|
858
1054
|
|
|
859
1055
|
|
|
1056
|
+
var ADDR_REGEX = /^0x[a-fA-F0-9]{40}$/;
|
|
1057
|
+
var REGISTRATION_DEBOUNCE_MS = 600;
|
|
1058
|
+
function resolveSessionOwner(eoaAddress) {
|
|
1059
|
+
const localOwner = _chunkY3RA3YGAcjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
|
|
1060
|
+
if (localOwner) {
|
|
1061
|
+
return {
|
|
1062
|
+
account: _chunkY3RA3YGAcjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
|
|
1063
|
+
address: localOwner.address
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
const created = _chunkY3RA3YGAcjs.createSessionOwnerKey.call(void 0, );
|
|
1067
|
+
_chunkY3RA3YGAcjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
|
|
1068
|
+
return { account: created.account, address: created.address };
|
|
1069
|
+
}
|
|
1070
|
+
function targetsEqual(a, b) {
|
|
1071
|
+
if (!a) return false;
|
|
1072
|
+
return a.chain === b.chain && a.token.toLowerCase() === b.token.toLowerCase() && (_nullishCoalesce(_optionalChain([a, 'access', _9 => _9.recipient, 'optionalAccess', _10 => _10.toLowerCase, 'call', _11 => _11()]), () => ( ""))) === (_nullishCoalesce(_optionalChain([b, 'access', _12 => _12.recipient, 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()]), () => ( "")));
|
|
1073
|
+
}
|
|
860
1074
|
function WithdrawFlow({
|
|
861
1075
|
dappWalletClient,
|
|
862
1076
|
dappPublicClient,
|
|
@@ -870,7 +1084,7 @@ function WithdrawFlow({
|
|
|
870
1084
|
amount: defaultAmount,
|
|
871
1085
|
service,
|
|
872
1086
|
allowedRoutes,
|
|
873
|
-
signerAddress =
|
|
1087
|
+
signerAddress = _chunkXCAF6B3Dcjs.DEFAULT_SIGNER_ADDRESS,
|
|
874
1088
|
sessionChainIds,
|
|
875
1089
|
forceRegister = false,
|
|
876
1090
|
waitForFinalTx = true,
|
|
@@ -879,59 +1093,54 @@ function WithdrawFlow({
|
|
|
879
1093
|
onDisconnect,
|
|
880
1094
|
onSignTransaction,
|
|
881
1095
|
onRequestConnect,
|
|
882
|
-
connectButtonLabel,
|
|
883
1096
|
onStepChange,
|
|
884
|
-
onTotalBalanceChange,
|
|
885
1097
|
onClose,
|
|
886
|
-
|
|
887
|
-
onWithdrawSubmitted,
|
|
888
|
-
onWithdrawComplete,
|
|
889
|
-
onWithdrawFailed,
|
|
1098
|
+
onLifecycle,
|
|
890
1099
|
onEvent,
|
|
891
1100
|
onError,
|
|
892
1101
|
debug
|
|
893
1102
|
}) {
|
|
894
|
-
const onStepChangeRef =
|
|
895
|
-
const
|
|
896
|
-
const
|
|
897
|
-
const
|
|
898
|
-
const onWithdrawSubmittedRef = _chunkNFXJEOE6cjs.useLatestRef.call(void 0, onWithdrawSubmitted);
|
|
899
|
-
const onWithdrawCompleteRef = _chunkNFXJEOE6cjs.useLatestRef.call(void 0, onWithdrawComplete);
|
|
900
|
-
const onWithdrawFailedRef = _chunkNFXJEOE6cjs.useLatestRef.call(void 0, onWithdrawFailed);
|
|
901
|
-
const onErrorRef = _chunkNFXJEOE6cjs.useLatestRef.call(void 0, onError);
|
|
902
|
-
const [step, setStep] = _react.useState.call(void 0, { type: "form" });
|
|
903
|
-
const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
|
|
904
|
-
const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, 0);
|
|
905
|
-
const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = _react.useState.call(void 0, false);
|
|
1103
|
+
const onStepChangeRef = _chunkY3RA3YGAcjs.useLatestRef.call(void 0, onStepChange);
|
|
1104
|
+
const onEventRef = _chunkY3RA3YGAcjs.useLatestRef.call(void 0, onEvent);
|
|
1105
|
+
const onLifecycleRef = _chunkY3RA3YGAcjs.useLatestRef.call(void 0, onLifecycle);
|
|
1106
|
+
const onErrorRef = _chunkY3RA3YGAcjs.useLatestRef.call(void 0, onError);
|
|
906
1107
|
const logFlow = _react.useCallback.call(void 0,
|
|
907
1108
|
(message, data) => {
|
|
908
|
-
|
|
1109
|
+
_chunkY3RA3YGAcjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
|
|
909
1110
|
},
|
|
910
1111
|
[debug]
|
|
911
1112
|
);
|
|
912
1113
|
const logFlowError = _react.useCallback.call(void 0,
|
|
913
1114
|
(message, error, data) => {
|
|
914
|
-
|
|
1115
|
+
_chunkY3RA3YGAcjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
|
|
915
1116
|
},
|
|
916
1117
|
[debug]
|
|
917
1118
|
);
|
|
918
1119
|
const [targetChain, setTargetChain] = _react.useState.call(void 0, targetChainProp);
|
|
919
1120
|
const [targetToken, setTargetToken] = _react.useState.call(void 0, targetTokenProp);
|
|
1121
|
+
const [recipientInput, setRecipientInput] = _react.useState.call(void 0,
|
|
1122
|
+
_nullishCoalesce(defaultRecipient, () => ( ""))
|
|
1123
|
+
);
|
|
1124
|
+
const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, 0);
|
|
1125
|
+
const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = _react.useState.call(void 0, false);
|
|
920
1126
|
_react.useEffect.call(void 0, () => {
|
|
921
1127
|
setTargetChain(targetChainProp);
|
|
922
1128
|
setTargetToken(targetTokenProp);
|
|
923
1129
|
}, [targetChainProp, targetTokenProp]);
|
|
1130
|
+
_react.useEffect.call(void 0, () => {
|
|
1131
|
+
if (defaultRecipient) setRecipientInput(defaultRecipient);
|
|
1132
|
+
}, [defaultRecipient]);
|
|
924
1133
|
const hasCustomSigner = Boolean(dappAddress && onSignTransaction);
|
|
925
1134
|
const dappSwitchChain = _react.useMemo.call(void 0, () => {
|
|
926
|
-
if (!_optionalChain([dappWalletClient, 'optionalAccess',
|
|
1135
|
+
if (!_optionalChain([dappWalletClient, 'optionalAccess', _15 => _15.switchChain])) return void 0;
|
|
927
1136
|
return async (chainId) => {
|
|
928
|
-
await _optionalChain([dappWalletClient, 'access',
|
|
1137
|
+
await _optionalChain([dappWalletClient, 'access', _16 => _16.switchChain, 'optionalCall', _17 => _17({ id: chainId })]);
|
|
929
1138
|
};
|
|
930
1139
|
}, [dappWalletClient]);
|
|
931
1140
|
const walletOptions = _react.useMemo.call(void 0, () => {
|
|
932
1141
|
const options = [];
|
|
933
1142
|
const seen = /* @__PURE__ */ new Set();
|
|
934
|
-
if (_optionalChain([dappWalletClient, 'optionalAccess',
|
|
1143
|
+
if (_optionalChain([dappWalletClient, 'optionalAccess', _18 => _18.account]) && dappAddress) {
|
|
935
1144
|
const id = `evm:${dappWalletClient.account.address.toLowerCase()}`;
|
|
936
1145
|
options.push({
|
|
937
1146
|
id,
|
|
@@ -941,7 +1150,7 @@ function WithdrawFlow({
|
|
|
941
1150
|
});
|
|
942
1151
|
seen.add(id);
|
|
943
1152
|
}
|
|
944
|
-
if (_optionalChain([reownWallet, 'optionalAccess',
|
|
1153
|
+
if (_optionalChain([reownWallet, 'optionalAccess', _19 => _19.address]) && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient) {
|
|
945
1154
|
const id = `evm:${reownWallet.address.toLowerCase()}`;
|
|
946
1155
|
if (!seen.has(id)) {
|
|
947
1156
|
options.push({
|
|
@@ -957,42 +1166,50 @@ function WithdrawFlow({
|
|
|
957
1166
|
}, [
|
|
958
1167
|
dappWalletClient,
|
|
959
1168
|
dappAddress,
|
|
960
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
961
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
962
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
963
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
1169
|
+
_optionalChain([reownWallet, 'optionalAccess', _20 => _20.address]),
|
|
1170
|
+
_optionalChain([reownWallet, 'optionalAccess', _21 => _21.isConnected]),
|
|
1171
|
+
_optionalChain([reownWallet, 'optionalAccess', _22 => _22.walletClient]),
|
|
1172
|
+
_optionalChain([reownWallet, 'optionalAccess', _23 => _23.publicClient]),
|
|
1173
|
+
_optionalChain([reownWallet, 'optionalAccess', _24 => _24.icon])
|
|
964
1174
|
]);
|
|
965
|
-
const canAutoLock = hasCustomSigner || Boolean(_optionalChain([dappWalletClient, 'optionalAccess',
|
|
966
|
-
const
|
|
1175
|
+
const canAutoLock = hasCustomSigner || Boolean(_optionalChain([dappWalletClient, 'optionalAccess', _25 => _25.account]) && dappAddress) && !reownWallet;
|
|
1176
|
+
const storeApi = useWithdrawStoreApi();
|
|
1177
|
+
const selectedWalletId = useWithdrawStore((s) => s.selectedWalletId);
|
|
1178
|
+
const registration = useWithdrawStore((s) => s.registration);
|
|
1179
|
+
const flowStep = useWithdrawStore((s) => s.step);
|
|
1180
|
+
const setSelectedWalletId = _react.useCallback.call(void 0,
|
|
1181
|
+
(walletId) => storeApi.dispatch({ type: "wallet/id-selected", walletId }),
|
|
1182
|
+
[storeApi]
|
|
1183
|
+
);
|
|
967
1184
|
const signerContext = _react.useMemo.call(void 0, () => {
|
|
968
1185
|
if (canAutoLock) {
|
|
969
1186
|
if (hasCustomSigner) {
|
|
970
1187
|
return {
|
|
971
1188
|
ownerAddress: dappAddress,
|
|
972
1189
|
walletClient: _nullishCoalesce(dappWalletClient, () => ( void 0)),
|
|
973
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
1190
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkY3RA3YGAcjs.getPublicClient.call(void 0, sourceChain))),
|
|
974
1191
|
switchChain: dappSwitchChain
|
|
975
1192
|
};
|
|
976
1193
|
}
|
|
977
1194
|
return {
|
|
978
1195
|
ownerAddress: dappWalletClient.account.address,
|
|
979
1196
|
walletClient: dappWalletClient,
|
|
980
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
1197
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkY3RA3YGAcjs.getPublicClient.call(void 0, sourceChain))),
|
|
981
1198
|
switchChain: dappSwitchChain
|
|
982
1199
|
};
|
|
983
1200
|
}
|
|
984
1201
|
if (!isConnectSelectionConfirmed || !selectedWalletId) return null;
|
|
985
|
-
const selectedOption = walletOptions.find((
|
|
1202
|
+
const selectedOption = walletOptions.find((o) => o.id === selectedWalletId);
|
|
986
1203
|
if (!selectedOption || !selectedOption.address) return null;
|
|
987
|
-
if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess',
|
|
1204
|
+
if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess', _26 => _26.account]) && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
|
|
988
1205
|
return {
|
|
989
1206
|
ownerAddress: dappWalletClient.account.address,
|
|
990
1207
|
walletClient: dappWalletClient,
|
|
991
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
1208
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkY3RA3YGAcjs.getPublicClient.call(void 0, sourceChain))),
|
|
992
1209
|
switchChain: dappSwitchChain
|
|
993
1210
|
};
|
|
994
1211
|
}
|
|
995
|
-
if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess',
|
|
1212
|
+
if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess', _27 => _27.address, 'optionalAccess', _28 => _28.toLowerCase, 'call', _29 => _29()]) === selectedOption.address.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
|
|
996
1213
|
return {
|
|
997
1214
|
ownerAddress: reownWallet.address,
|
|
998
1215
|
walletClient: reownWallet.walletClient,
|
|
@@ -1014,11 +1231,136 @@ function WithdrawFlow({
|
|
|
1014
1231
|
reownWallet,
|
|
1015
1232
|
sourceChain
|
|
1016
1233
|
]);
|
|
1234
|
+
const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _30 => _30.ownerAddress]);
|
|
1235
|
+
const recipientForRegistration = _react.useMemo.call(void 0, () => {
|
|
1236
|
+
if (!recipientInput) return void 0;
|
|
1237
|
+
return ADDR_REGEX.test(recipientInput) ? recipientInput : void 0;
|
|
1238
|
+
}, [recipientInput]);
|
|
1239
|
+
_react.useEffect.call(void 0, () => {
|
|
1240
|
+
if (!ownerAddress) return;
|
|
1241
|
+
const desiredTarget = {
|
|
1242
|
+
chain: targetChain,
|
|
1243
|
+
token: targetToken,
|
|
1244
|
+
recipient: recipientForRegistration
|
|
1245
|
+
};
|
|
1246
|
+
const current = storeApi.getState().registration;
|
|
1247
|
+
if (current.kind === "ready" && targetsEqual(current.registeredTarget, desiredTarget)) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
let cancelled = false;
|
|
1251
|
+
const timeout = setTimeout(async () => {
|
|
1252
|
+
try {
|
|
1253
|
+
storeApi.dispatch({ type: "registration/started" });
|
|
1254
|
+
const sessionOwner = resolveSessionOwner(ownerAddress);
|
|
1255
|
+
if (cancelled) return;
|
|
1256
|
+
logFlow("auto-register:setup", {
|
|
1257
|
+
ownerAddress,
|
|
1258
|
+
targetChain,
|
|
1259
|
+
targetToken,
|
|
1260
|
+
recipient: recipientForRegistration
|
|
1261
|
+
});
|
|
1262
|
+
const setup = await service.setupAccount({
|
|
1263
|
+
ownerAddress,
|
|
1264
|
+
sessionOwnerAddress: sessionOwner.address,
|
|
1265
|
+
targetChain: _chunkY3RA3YGAcjs.toEvmCaip2.call(void 0, targetChain),
|
|
1266
|
+
targetToken,
|
|
1267
|
+
recipient: recipientForRegistration,
|
|
1268
|
+
signerAddress,
|
|
1269
|
+
sessionChainIds,
|
|
1270
|
+
forceRegister
|
|
1271
|
+
});
|
|
1272
|
+
if (cancelled) return;
|
|
1273
|
+
if (setup.needsRegistration) {
|
|
1274
|
+
if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
|
|
1275
|
+
throw new Error("Missing registration payload from setup-account");
|
|
1276
|
+
}
|
|
1277
|
+
const typedData = setup.sessionDetailsUnsigned.data;
|
|
1278
|
+
if (!sessionOwner.account.signTypedData) {
|
|
1279
|
+
throw new Error(
|
|
1280
|
+
"Session owner account does not support signTypedData"
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1283
|
+
const signature = await sessionOwner.account.signTypedData({
|
|
1284
|
+
domain: typedData.domain,
|
|
1285
|
+
types: typedData.types,
|
|
1286
|
+
primaryType: typedData.primaryType,
|
|
1287
|
+
message: typedData.message
|
|
1288
|
+
});
|
|
1289
|
+
if (cancelled) return;
|
|
1290
|
+
const sessionDetails = _chunkY3RA3YGAcjs.buildSessionDetails.call(void 0,
|
|
1291
|
+
setup.sessionDetailsUnsigned,
|
|
1292
|
+
signature
|
|
1293
|
+
);
|
|
1294
|
+
await service.registerAccount({
|
|
1295
|
+
address: setup.smartAccount,
|
|
1296
|
+
accountParams: {
|
|
1297
|
+
factory: setup.accountParams.factory,
|
|
1298
|
+
factoryData: setup.accountParams.factoryData,
|
|
1299
|
+
sessionDetails
|
|
1300
|
+
},
|
|
1301
|
+
eoaAddress: ownerAddress,
|
|
1302
|
+
sessionOwner: sessionOwner.address,
|
|
1303
|
+
target: {
|
|
1304
|
+
chain: _chunkY3RA3YGAcjs.toEvmCaip2.call(void 0, targetChain),
|
|
1305
|
+
token: targetToken,
|
|
1306
|
+
recipient: recipientForRegistration
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
if (cancelled) return;
|
|
1310
|
+
logFlow("auto-register:registered", {
|
|
1311
|
+
smartAccount: setup.smartAccount
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
storeApi.dispatch({
|
|
1315
|
+
type: "registration/ready",
|
|
1316
|
+
smartAccount: setup.smartAccount,
|
|
1317
|
+
registeredTarget: desiredTarget
|
|
1318
|
+
});
|
|
1319
|
+
_optionalChain([onLifecycleRef, 'access', _31 => _31.current, 'optionalCall', _32 => _32({
|
|
1320
|
+
type: "connected",
|
|
1321
|
+
address: ownerAddress,
|
|
1322
|
+
smartAccount: setup.smartAccount
|
|
1323
|
+
})]);
|
|
1324
|
+
} catch (err) {
|
|
1325
|
+
if (cancelled) return;
|
|
1326
|
+
const raw = err instanceof Error ? err.message : "Registration failed";
|
|
1327
|
+
const message = _chunkY3RA3YGAcjs.formatUserError.call(void 0, raw);
|
|
1328
|
+
logFlowError("auto-register:failed", err, {
|
|
1329
|
+
ownerAddress,
|
|
1330
|
+
targetChain,
|
|
1331
|
+
targetToken
|
|
1332
|
+
});
|
|
1333
|
+
storeApi.dispatch({
|
|
1334
|
+
type: "registration/failed",
|
|
1335
|
+
error: message
|
|
1336
|
+
});
|
|
1337
|
+
_optionalChain([onErrorRef, 'access', _33 => _33.current, 'optionalCall', _34 => _34({ message, code: "WITHDRAW_REGISTER_FAILED" })]);
|
|
1338
|
+
}
|
|
1339
|
+
}, REGISTRATION_DEBOUNCE_MS);
|
|
1340
|
+
return () => {
|
|
1341
|
+
cancelled = true;
|
|
1342
|
+
clearTimeout(timeout);
|
|
1343
|
+
};
|
|
1344
|
+
}, [
|
|
1345
|
+
ownerAddress,
|
|
1346
|
+
targetChain,
|
|
1347
|
+
targetToken,
|
|
1348
|
+
recipientForRegistration,
|
|
1349
|
+
service,
|
|
1350
|
+
signerAddress,
|
|
1351
|
+
sessionChainIds,
|
|
1352
|
+
forceRegister,
|
|
1353
|
+
storeApi,
|
|
1354
|
+
logFlow,
|
|
1355
|
+
logFlowError,
|
|
1356
|
+
onLifecycleRef,
|
|
1357
|
+
onErrorRef
|
|
1358
|
+
]);
|
|
1017
1359
|
const asset = _react.useMemo.call(void 0, () => {
|
|
1018
|
-
const symbol =
|
|
1019
|
-
const decimals =
|
|
1360
|
+
const symbol = _chunkXCAF6B3Dcjs.getTokenSymbol.call(void 0, sourceToken, sourceChain);
|
|
1361
|
+
const decimals = _chunkXCAF6B3Dcjs.getTokenDecimalsByAddress.call(void 0, sourceToken, sourceChain);
|
|
1020
1362
|
return {
|
|
1021
|
-
id:
|
|
1363
|
+
id: _chunkY3RA3YGAcjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
|
|
1022
1364
|
chainId: sourceChain,
|
|
1023
1365
|
token: sourceToken,
|
|
1024
1366
|
symbol,
|
|
@@ -1026,89 +1368,65 @@ function WithdrawFlow({
|
|
|
1026
1368
|
decimals
|
|
1027
1369
|
};
|
|
1028
1370
|
}, [sourceChain, sourceToken]);
|
|
1029
|
-
const isSourceNative = sourceToken.toLowerCase() ===
|
|
1371
|
+
const isSourceNative = sourceToken.toLowerCase() === _chunkXCAF6B3Dcjs.NATIVE_TOKEN_ADDRESS.toLowerCase();
|
|
1030
1372
|
const isSameRoute = targetChain === sourceChain && targetToken.toLowerCase() === sourceToken.toLowerCase();
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1373
|
+
const reviewBackHandler = _react.useCallback.call(void 0, () => {
|
|
1374
|
+
storeApi.dispatch({ type: "review/back" });
|
|
1375
|
+
}, [storeApi]);
|
|
1033
1376
|
_react.useEffect.call(void 0, () => {
|
|
1034
|
-
_optionalChain([onStepChangeRef, 'access',
|
|
1035
|
-
|
|
1377
|
+
_optionalChain([onStepChangeRef, 'access', _35 => _35.current, 'optionalCall', _36 => _36(
|
|
1378
|
+
flowStep === "review" ? reviewBackHandler : void 0
|
|
1379
|
+
)]);
|
|
1380
|
+
}, [flowStep, reviewBackHandler, onStepChangeRef]);
|
|
1036
1381
|
const lastStepOpenEventKeyRef = _react.useRef.call(void 0, null);
|
|
1037
1382
|
_react.useEffect.call(void 0, () => {
|
|
1038
|
-
if (
|
|
1383
|
+
if (flowStep !== "form") {
|
|
1039
1384
|
lastStepOpenEventKeyRef.current = null;
|
|
1040
1385
|
return;
|
|
1041
1386
|
}
|
|
1042
|
-
if (lastStepOpenEventKeyRef.current === "form")
|
|
1043
|
-
return;
|
|
1044
|
-
}
|
|
1387
|
+
if (lastStepOpenEventKeyRef.current === "form") return;
|
|
1045
1388
|
lastStepOpenEventKeyRef.current = "form";
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
}, [step.type, targetToken, targetChain, totalBalanceUsd, onEventRef]);
|
|
1389
|
+
const tokenSymbol = _chunkXCAF6B3Dcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
1390
|
+
const chainName = _chunkXCAF6B3Dcjs.getChainName.call(void 0, targetChain);
|
|
1391
|
+
_optionalChain([onEventRef, 'access', _37 => _37.current, 'optionalCall', _38 => _38({
|
|
1392
|
+
type: "withdraw_modal_select_amount_open",
|
|
1393
|
+
pred_balance: totalBalanceUsd,
|
|
1394
|
+
default_token: tokenSymbol,
|
|
1395
|
+
default_chain: chainName
|
|
1396
|
+
})]);
|
|
1397
|
+
}, [flowStep, targetToken, targetChain, totalBalanceUsd, onEventRef]);
|
|
1057
1398
|
_react.useEffect.call(void 0, () => {
|
|
1058
1399
|
logFlow("state:changed", {
|
|
1059
|
-
step:
|
|
1400
|
+
step: flowStep,
|
|
1060
1401
|
sourceChain,
|
|
1061
1402
|
sourceToken,
|
|
1062
1403
|
targetChain,
|
|
1063
1404
|
targetToken,
|
|
1064
|
-
selectedWalletId
|
|
1405
|
+
selectedWalletId,
|
|
1406
|
+
registration: registration.kind
|
|
1065
1407
|
});
|
|
1066
1408
|
}, [
|
|
1067
1409
|
logFlow,
|
|
1068
1410
|
selectedWalletId,
|
|
1069
1411
|
sourceChain,
|
|
1070
1412
|
sourceToken,
|
|
1071
|
-
|
|
1413
|
+
flowStep,
|
|
1072
1414
|
targetChain,
|
|
1073
|
-
targetToken
|
|
1415
|
+
targetToken,
|
|
1416
|
+
registration.kind
|
|
1074
1417
|
]);
|
|
1075
|
-
_react.useEffect.call(void 0, () => {
|
|
1076
|
-
_optionalChain([onTotalBalanceChangeRef, 'access', _24 => _24.current, 'optionalCall', _25 => _25(totalBalanceUsd)]);
|
|
1077
|
-
}, [totalBalanceUsd, onTotalBalanceChangeRef]);
|
|
1078
|
-
const handleConnected = _react.useCallback.call(void 0,
|
|
1079
|
-
(addr, smartAccount) => {
|
|
1080
|
-
logFlow("setup:connected", { address: addr, smartAccount });
|
|
1081
|
-
_optionalChain([onConnectedRef, 'access', _26 => _26.current, 'optionalCall', _27 => _27({ address: addr, smartAccount })]);
|
|
1082
|
-
},
|
|
1083
|
-
[logFlow, onConnectedRef]
|
|
1084
|
-
);
|
|
1085
1418
|
const handleError = _react.useCallback.call(void 0,
|
|
1086
1419
|
(message, code) => {
|
|
1087
1420
|
logFlowError("flow:error", message, { code });
|
|
1088
|
-
_optionalChain([onErrorRef, 'access',
|
|
1421
|
+
_optionalChain([onErrorRef, 'access', _39 => _39.current, 'optionalCall', _40 => _40({ message, code })]);
|
|
1089
1422
|
},
|
|
1090
1423
|
[logFlowError, onErrorRef]
|
|
1091
1424
|
);
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
address: localOwner.address
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
const created = _chunkNFXJEOE6cjs.createSessionOwnerKey.call(void 0, );
|
|
1101
|
-
_chunkNFXJEOE6cjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
|
|
1102
|
-
return {
|
|
1103
|
-
account: created.account,
|
|
1104
|
-
address: created.address
|
|
1105
|
-
};
|
|
1106
|
-
}, []);
|
|
1107
|
-
const handleFormSubmit = _react.useCallback.call(void 0,
|
|
1108
|
-
async (recipient, amountValue) => {
|
|
1109
|
-
const tokenSymbol = _chunkR2HP743Tcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
1110
|
-
const chainName = _chunkR2HP743Tcjs.getChainName.call(void 0, targetChain);
|
|
1111
|
-
_optionalChain([onEventRef, 'access', _30 => _30.current, 'optionalCall', _31 => _31({
|
|
1425
|
+
const handleFormContinue = _react.useCallback.call(void 0,
|
|
1426
|
+
(recipient, amountValue) => {
|
|
1427
|
+
const tokenSymbol = _chunkXCAF6B3Dcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
1428
|
+
const chainName = _chunkXCAF6B3Dcjs.getChainName.call(void 0, targetChain);
|
|
1429
|
+
_optionalChain([onEventRef, 'access', _41 => _41.current, 'optionalCall', _42 => _42({
|
|
1112
1430
|
type: "withdraw_modal_select_amount_cta_click",
|
|
1113
1431
|
pred_balance: totalBalanceUsd,
|
|
1114
1432
|
selected_token: tokenSymbol,
|
|
@@ -1116,17 +1434,32 @@ function WithdrawFlow({
|
|
|
1116
1434
|
amount: amountValue,
|
|
1117
1435
|
cta_name: "withdraw"
|
|
1118
1436
|
})]);
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1437
|
+
storeApi.dispatch({
|
|
1438
|
+
type: "form/continue",
|
|
1439
|
+
amount: amountValue,
|
|
1440
|
+
recipient
|
|
1441
|
+
});
|
|
1442
|
+
},
|
|
1443
|
+
[targetToken, targetChain, totalBalanceUsd, onEventRef, storeApi]
|
|
1444
|
+
);
|
|
1445
|
+
const handleReviewConfirm = _react.useCallback.call(void 0,
|
|
1446
|
+
async () => {
|
|
1447
|
+
const state = storeApi.getState();
|
|
1448
|
+
if (state.registration.kind !== "ready") {
|
|
1449
|
+
throw new Error("Session not ready");
|
|
1122
1450
|
}
|
|
1123
|
-
|
|
1451
|
+
const smartAccount = state.registration.smartAccount;
|
|
1452
|
+
const recipient = state.recipient;
|
|
1453
|
+
const amountValue = state.amount;
|
|
1454
|
+
if (!recipient || !amountValue) {
|
|
1455
|
+
throw new Error("Missing recipient or amount");
|
|
1456
|
+
}
|
|
1457
|
+
if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _43 => _43.walletClient])) {
|
|
1124
1458
|
throw new Error("Wallet not connected");
|
|
1125
1459
|
}
|
|
1126
|
-
setIsSubmitting(true);
|
|
1127
1460
|
try {
|
|
1128
1461
|
logFlow("submit:start", {
|
|
1129
|
-
|
|
1462
|
+
smartAccount,
|
|
1130
1463
|
recipient,
|
|
1131
1464
|
amount: amountValue,
|
|
1132
1465
|
sourceChain,
|
|
@@ -1134,62 +1467,8 @@ function WithdrawFlow({
|
|
|
1134
1467
|
targetChain,
|
|
1135
1468
|
targetToken
|
|
1136
1469
|
});
|
|
1137
|
-
const sessionOwner = await resolveSessionOwner(ownerAddress2);
|
|
1138
|
-
const setup = await service.setupAccount({
|
|
1139
|
-
ownerAddress: ownerAddress2,
|
|
1140
|
-
sessionOwnerAddress: sessionOwner.address,
|
|
1141
|
-
targetChain: _chunkNFXJEOE6cjs.toEvmCaip2.call(void 0, targetChain),
|
|
1142
|
-
targetToken,
|
|
1143
|
-
recipient,
|
|
1144
|
-
signerAddress,
|
|
1145
|
-
sessionChainIds,
|
|
1146
|
-
forceRegister
|
|
1147
|
-
});
|
|
1148
|
-
const smartAccount = setup.smartAccount;
|
|
1149
|
-
logFlow("setup:resolved", {
|
|
1150
|
-
smartAccount,
|
|
1151
|
-
needsRegistration: setup.needsRegistration
|
|
1152
|
-
});
|
|
1153
|
-
if (setup.needsRegistration) {
|
|
1154
|
-
if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
|
|
1155
|
-
throw new Error("Missing registration payload from setup-account");
|
|
1156
|
-
}
|
|
1157
|
-
const typedData = setup.sessionDetailsUnsigned.data;
|
|
1158
|
-
if (!sessionOwner.account.signTypedData) {
|
|
1159
|
-
throw new Error(
|
|
1160
|
-
"Session owner account does not support signTypedData"
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
const signature = await sessionOwner.account.signTypedData({
|
|
1164
|
-
domain: typedData.domain,
|
|
1165
|
-
types: typedData.types,
|
|
1166
|
-
primaryType: typedData.primaryType,
|
|
1167
|
-
message: typedData.message
|
|
1168
|
-
});
|
|
1169
|
-
const sessionDetails = _chunkNFXJEOE6cjs.buildSessionDetails.call(void 0,
|
|
1170
|
-
setup.sessionDetailsUnsigned,
|
|
1171
|
-
signature
|
|
1172
|
-
);
|
|
1173
|
-
await service.registerAccount({
|
|
1174
|
-
address: smartAccount,
|
|
1175
|
-
accountParams: {
|
|
1176
|
-
factory: setup.accountParams.factory,
|
|
1177
|
-
factoryData: setup.accountParams.factoryData,
|
|
1178
|
-
sessionDetails
|
|
1179
|
-
},
|
|
1180
|
-
eoaAddress: ownerAddress2,
|
|
1181
|
-
sessionOwner: sessionOwner.address,
|
|
1182
|
-
target: {
|
|
1183
|
-
chain: _chunkNFXJEOE6cjs.toEvmCaip2.call(void 0, targetChain),
|
|
1184
|
-
token: targetToken,
|
|
1185
|
-
recipient
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
logFlow("register:success", { smartAccount });
|
|
1189
|
-
}
|
|
1190
|
-
handleConnected(ownerAddress2, smartAccount);
|
|
1191
1470
|
const amountUnits = _viem.parseUnits.call(void 0, amountValue, asset.decimals);
|
|
1192
|
-
const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess',
|
|
1471
|
+
const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _44 => _44.publicClient]), () => ( _chunkY3RA3YGAcjs.getPublicClient.call(void 0, sourceChain)));
|
|
1193
1472
|
let result;
|
|
1194
1473
|
if (onSignTransaction) {
|
|
1195
1474
|
const transferTarget = isSameRoute ? recipient : smartAccount;
|
|
@@ -1213,7 +1492,7 @@ function WithdrawFlow({
|
|
|
1213
1492
|
const { signature } = await onSignTransaction(request);
|
|
1214
1493
|
const relayResult = await service.relayWithdraw({
|
|
1215
1494
|
smartAccount,
|
|
1216
|
-
chainId:
|
|
1495
|
+
chainId: _chunkY3RA3YGAcjs.toEvmCaip2.call(void 0, sourceChain),
|
|
1217
1496
|
safeAddress,
|
|
1218
1497
|
safeTransaction: request.typedData.message,
|
|
1219
1498
|
signature
|
|
@@ -1249,21 +1528,14 @@ function WithdrawFlow({
|
|
|
1249
1528
|
sourceChain,
|
|
1250
1529
|
sourceToken
|
|
1251
1530
|
});
|
|
1252
|
-
_optionalChain([
|
|
1531
|
+
_optionalChain([onLifecycleRef, 'access', _45 => _45.current, 'optionalCall', _46 => _46({
|
|
1532
|
+
type: "submitted",
|
|
1253
1533
|
txHash: result.txHash,
|
|
1254
1534
|
sourceChain,
|
|
1255
1535
|
amount: amountUnits.toString(),
|
|
1256
1536
|
safeAddress
|
|
1257
1537
|
})]);
|
|
1258
|
-
|
|
1259
|
-
type: "processing",
|
|
1260
|
-
smartAccount,
|
|
1261
|
-
txHash: result.txHash,
|
|
1262
|
-
sourceChain,
|
|
1263
|
-
sourceToken,
|
|
1264
|
-
amount: amountUnits.toString(),
|
|
1265
|
-
directTransfer: isSameRoute
|
|
1266
|
-
});
|
|
1538
|
+
storeApi.dispatch({ type: "withdraw/submitted", txHash: result.txHash });
|
|
1267
1539
|
} catch (err) {
|
|
1268
1540
|
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
1269
1541
|
logFlowError("submit:failed", err, {
|
|
@@ -1272,22 +1544,15 @@ function WithdrawFlow({
|
|
|
1272
1544
|
targetChain,
|
|
1273
1545
|
targetToken
|
|
1274
1546
|
});
|
|
1275
|
-
handleError(
|
|
1547
|
+
handleError(_chunkY3RA3YGAcjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
|
|
1276
1548
|
throw err;
|
|
1277
|
-
} finally {
|
|
1278
|
-
setIsSubmitting(false);
|
|
1279
1549
|
}
|
|
1280
1550
|
},
|
|
1281
1551
|
[
|
|
1282
1552
|
signerContext,
|
|
1283
|
-
resolveSessionOwner,
|
|
1284
|
-
signerAddress,
|
|
1285
|
-
sessionChainIds,
|
|
1286
|
-
forceRegister,
|
|
1287
1553
|
targetChain,
|
|
1288
1554
|
targetToken,
|
|
1289
1555
|
service,
|
|
1290
|
-
handleConnected,
|
|
1291
1556
|
asset.decimals,
|
|
1292
1557
|
safeAddress,
|
|
1293
1558
|
sourceToken,
|
|
@@ -1298,15 +1563,15 @@ function WithdrawFlow({
|
|
|
1298
1563
|
handleError,
|
|
1299
1564
|
logFlow,
|
|
1300
1565
|
logFlowError,
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
onWithdrawSubmittedRef
|
|
1566
|
+
onLifecycleRef,
|
|
1567
|
+
storeApi
|
|
1304
1568
|
]
|
|
1305
1569
|
);
|
|
1306
1570
|
const handleWithdrawComplete = _react.useCallback.call(void 0,
|
|
1307
1571
|
(txHash, destinationTxHash, context) => {
|
|
1308
1572
|
logFlow("withdraw:complete", { txHash, destinationTxHash, ...context });
|
|
1309
|
-
_optionalChain([
|
|
1573
|
+
_optionalChain([onLifecycleRef, 'access', _47 => _47.current, 'optionalCall', _48 => _48({
|
|
1574
|
+
type: "complete",
|
|
1310
1575
|
txHash,
|
|
1311
1576
|
destinationTxHash,
|
|
1312
1577
|
amount: context.amount,
|
|
@@ -1315,28 +1580,34 @@ function WithdrawFlow({
|
|
|
1315
1580
|
targetChain: context.targetChain,
|
|
1316
1581
|
targetToken: context.targetToken
|
|
1317
1582
|
})]);
|
|
1583
|
+
storeApi.dispatch({ type: "withdraw/complete" });
|
|
1318
1584
|
},
|
|
1319
|
-
[logFlow,
|
|
1585
|
+
[logFlow, onLifecycleRef, storeApi]
|
|
1320
1586
|
);
|
|
1321
1587
|
const handleWithdrawFailed = _react.useCallback.call(void 0,
|
|
1322
1588
|
(txHash, error) => {
|
|
1323
1589
|
logFlowError("withdraw:failed", error, { txHash });
|
|
1324
|
-
_optionalChain([
|
|
1590
|
+
_optionalChain([onLifecycleRef, 'access', _49 => _49.current, 'optionalCall', _50 => _50({
|
|
1591
|
+
type: "failed",
|
|
1592
|
+
txHash,
|
|
1593
|
+
error
|
|
1594
|
+
})]);
|
|
1595
|
+
storeApi.dispatch({ type: "withdraw/failed" });
|
|
1325
1596
|
},
|
|
1326
|
-
[logFlowError,
|
|
1597
|
+
[logFlowError, onLifecycleRef, storeApi]
|
|
1327
1598
|
);
|
|
1328
1599
|
const allowedChainSet = _react.useMemo.call(void 0,
|
|
1329
|
-
() => _optionalChain([allowedRoutes, 'optionalAccess',
|
|
1330
|
-
[_optionalChain([allowedRoutes, 'optionalAccess',
|
|
1600
|
+
() => _optionalChain([allowedRoutes, 'optionalAccess', _51 => _51.sourceChains]) ? new Set(allowedRoutes.sourceChains) : null,
|
|
1601
|
+
[_optionalChain([allowedRoutes, 'optionalAccess', _52 => _52.sourceChains])]
|
|
1331
1602
|
);
|
|
1332
1603
|
const allowedTokenSet = _react.useMemo.call(void 0,
|
|
1333
|
-
() => _optionalChain([allowedRoutes, 'optionalAccess',
|
|
1334
|
-
[_optionalChain([allowedRoutes, 'optionalAccess',
|
|
1604
|
+
() => _optionalChain([allowedRoutes, 'optionalAccess', _53 => _53.sourceTokens]) ? new Set(allowedRoutes.sourceTokens.map((s) => s.toUpperCase())) : null,
|
|
1605
|
+
[_optionalChain([allowedRoutes, 'optionalAccess', _54 => _54.sourceTokens])]
|
|
1335
1606
|
);
|
|
1336
1607
|
const targetChainOptions = _react.useMemo.call(void 0, () => {
|
|
1337
|
-
return
|
|
1608
|
+
return _chunkXCAF6B3Dcjs.SOURCE_CHAINS.filter((chain) => {
|
|
1338
1609
|
if (allowedChainSet && !allowedChainSet.has(chain.id)) return false;
|
|
1339
|
-
const tokens =
|
|
1610
|
+
const tokens = _chunkXCAF6B3Dcjs.getSupportedTargetTokens.call(void 0, chain.id);
|
|
1340
1611
|
if (allowedTokenSet) {
|
|
1341
1612
|
return tokens.some((t) => allowedTokenSet.has(t.symbol.toUpperCase()));
|
|
1342
1613
|
}
|
|
@@ -1344,7 +1615,7 @@ function WithdrawFlow({
|
|
|
1344
1615
|
});
|
|
1345
1616
|
}, [allowedChainSet, allowedTokenSet]);
|
|
1346
1617
|
const targetTokenOptions = _react.useMemo.call(void 0, () => {
|
|
1347
|
-
const tokens =
|
|
1618
|
+
const tokens = _chunkXCAF6B3Dcjs.getSupportedTargetTokens.call(void 0, targetChain);
|
|
1348
1619
|
if (!allowedTokenSet) return tokens;
|
|
1349
1620
|
return tokens.filter((t) => allowedTokenSet.has(t.symbol.toUpperCase()));
|
|
1350
1621
|
}, [targetChain, allowedTokenSet]);
|
|
@@ -1353,20 +1624,18 @@ function WithdrawFlow({
|
|
|
1353
1624
|
const matches = targetTokenOptions.some(
|
|
1354
1625
|
(option) => option.address.toLowerCase() === targetToken.toLowerCase()
|
|
1355
1626
|
);
|
|
1356
|
-
if (!matches)
|
|
1357
|
-
setTargetToken(targetTokenOptions[0].address);
|
|
1358
|
-
}
|
|
1627
|
+
if (!matches) setTargetToken(targetTokenOptions[0].address);
|
|
1359
1628
|
}, [targetToken, targetTokenOptions]);
|
|
1360
1629
|
const handleTargetChainChange = _react.useCallback.call(void 0,
|
|
1361
1630
|
(chainId) => {
|
|
1362
1631
|
setTargetChain(chainId);
|
|
1363
|
-
let options =
|
|
1632
|
+
let options = _chunkXCAF6B3Dcjs.getSupportedTargetTokens.call(void 0, chainId);
|
|
1364
1633
|
if (allowedTokenSet) {
|
|
1365
|
-
options = options.filter(
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
return;
|
|
1634
|
+
options = options.filter(
|
|
1635
|
+
(t) => allowedTokenSet.has(t.symbol.toUpperCase())
|
|
1636
|
+
);
|
|
1369
1637
|
}
|
|
1638
|
+
if (options.length === 0) return;
|
|
1370
1639
|
const currentlySupported = options.some(
|
|
1371
1640
|
(option) => option.address.toLowerCase() === targetToken.toLowerCase()
|
|
1372
1641
|
);
|
|
@@ -1381,60 +1650,49 @@ function WithdrawFlow({
|
|
|
1381
1650
|
}, []);
|
|
1382
1651
|
const selectedWalletIdEffective = _react.useMemo.call(void 0, () => {
|
|
1383
1652
|
if (selectedWalletId) return selectedWalletId;
|
|
1384
|
-
if (walletOptions.length === 1)
|
|
1385
|
-
return walletOptions[0].id;
|
|
1386
|
-
}
|
|
1653
|
+
if (walletOptions.length === 1) return walletOptions[0].id;
|
|
1387
1654
|
return null;
|
|
1388
1655
|
}, [selectedWalletId, walletOptions]);
|
|
1389
1656
|
const walletOptionsKey = _react.useMemo.call(void 0,
|
|
1390
|
-
() => walletOptions.map((
|
|
1657
|
+
() => walletOptions.map((o) => o.id).join(","),
|
|
1391
1658
|
[walletOptions]
|
|
1392
1659
|
);
|
|
1393
1660
|
const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
|
|
1394
1661
|
_react.useEffect.call(void 0, () => {
|
|
1395
1662
|
setIsConnectSelectionConfirmed(false);
|
|
1396
|
-
}, [walletOptionsKey
|
|
1397
|
-
|
|
1398
|
-
if (!showConnectStep && isConnectSelectionConfirmed && !signerContext) {
|
|
1399
|
-
setSelectedWalletId(null);
|
|
1400
|
-
setIsConnectSelectionConfirmed(false);
|
|
1401
|
-
}
|
|
1402
|
-
}, [showConnectStep, isConnectSelectionConfirmed, signerContext]);
|
|
1403
|
-
const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _45 => _45.ownerAddress]);
|
|
1404
|
-
const selectedWalletOption = selectedWalletIdEffective ? _nullishCoalesce(walletOptions.find((option) => option.id === selectedWalletIdEffective), () => ( null)) : null;
|
|
1663
|
+
}, [walletOptionsKey]);
|
|
1664
|
+
const selectedWalletOption = selectedWalletIdEffective ? _nullishCoalesce(walletOptions.find((o) => o.id === selectedWalletIdEffective), () => ( null)) : null;
|
|
1405
1665
|
const selectedWalletIcon = _react.useMemo.call(void 0, () => {
|
|
1406
1666
|
if (!ownerAddress) return void 0;
|
|
1407
1667
|
const selected = walletOptions.find(
|
|
1408
|
-
(o) => _optionalChain([o, 'access',
|
|
1668
|
+
(o) => _optionalChain([o, 'access', _55 => _55.address, 'optionalAccess', _56 => _56.toLowerCase, 'call', _57 => _57()]) === ownerAddress.toLowerCase()
|
|
1409
1669
|
);
|
|
1410
|
-
return _optionalChain([selected, 'optionalAccess',
|
|
1411
|
-
}, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess',
|
|
1670
|
+
return _optionalChain([selected, 'optionalAccess', _58 => _58.kind]) === "external" ? _nullishCoalesce(selected.icon, () => ( _optionalChain([reownWallet, 'optionalAccess', _59 => _59.icon]))) : void 0;
|
|
1671
|
+
}, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _60 => _60.icon])]);
|
|
1412
1672
|
if (showConnectStep) {
|
|
1413
1673
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1414
|
-
|
|
1674
|
+
_chunkY3RA3YGAcjs.ConnectStep,
|
|
1415
1675
|
{
|
|
1416
1676
|
walletOptions,
|
|
1417
|
-
|
|
1418
|
-
|
|
1677
|
+
onConfirmWallet: (walletId) => {
|
|
1678
|
+
setSelectedWalletId(walletId);
|
|
1679
|
+
setIsConnectSelectionConfirmed(true);
|
|
1680
|
+
},
|
|
1419
1681
|
onRequestConnect,
|
|
1420
1682
|
onConnect,
|
|
1421
1683
|
onDisconnect,
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
setSelectedWalletId(selectedWalletIdEffective);
|
|
1425
|
-
}
|
|
1426
|
-
setIsConnectSelectionConfirmed(true);
|
|
1427
|
-
},
|
|
1428
|
-
connectButtonLabel
|
|
1684
|
+
title: "Withdraw",
|
|
1685
|
+
subtitle: "Choose a wallet to continue"
|
|
1429
1686
|
}
|
|
1430
1687
|
) });
|
|
1431
1688
|
}
|
|
1432
1689
|
if (!signerContext) return null;
|
|
1433
1690
|
if (!onSignTransaction && !signerContext.walletClient) return null;
|
|
1434
|
-
const resolvedConnectedRecipient = _optionalChain([selectedWalletOption, 'optionalAccess',
|
|
1435
|
-
const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => (
|
|
1691
|
+
const resolvedConnectedRecipient = _optionalChain([selectedWalletOption, 'optionalAccess', _61 => _61.kind]) === "external" ? selectedWalletOption.address : void 0;
|
|
1692
|
+
const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkY3RA3YGAcjs.getPublicClient.call(void 0, sourceChain)));
|
|
1693
|
+
const stepView = deriveStepView(flowStep, registration);
|
|
1436
1694
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
|
|
1437
|
-
|
|
1695
|
+
stepView === "form" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1438
1696
|
WithdrawFormStep,
|
|
1439
1697
|
{
|
|
1440
1698
|
walletClient: signerContext.walletClient,
|
|
@@ -1452,27 +1710,44 @@ function WithdrawFlow({
|
|
|
1452
1710
|
onTargetTokenChange: handleTargetTokenChange,
|
|
1453
1711
|
switchChain: signerContext.switchChain,
|
|
1454
1712
|
walletIcon: selectedWalletIcon,
|
|
1455
|
-
|
|
1456
|
-
|
|
1713
|
+
registrationPending: registration.kind === "pending" || registration.kind === "stale",
|
|
1714
|
+
registrationError: registration.kind === "failed" ? registration.error : null,
|
|
1715
|
+
onRecipientChange: setRecipientInput,
|
|
1716
|
+
onSubmit: async (r, a) => handleFormContinue(r, a),
|
|
1457
1717
|
onBalanceUsdChange: setTotalBalanceUsd
|
|
1458
1718
|
}
|
|
1459
1719
|
),
|
|
1460
|
-
|
|
1461
|
-
|
|
1720
|
+
stepView === "review" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1721
|
+
WithdrawReviewStep,
|
|
1722
|
+
{
|
|
1723
|
+
sourceChain,
|
|
1724
|
+
sourceSymbol: asset.symbol,
|
|
1725
|
+
targetChain,
|
|
1726
|
+
targetToken,
|
|
1727
|
+
amount: _nullishCoalesce(storeApi.getState().amount, () => ( "0")),
|
|
1728
|
+
recipient: _nullishCoalesce(_nullishCoalesce(storeApi.getState().recipient, () => ( recipientForRegistration)), () => ( "0x0")),
|
|
1729
|
+
registrationPending: registration.kind === "pending" || registration.kind === "stale",
|
|
1730
|
+
registrationError: registration.kind === "failed" ? registration.error : null,
|
|
1731
|
+
onConfirm: handleReviewConfirm,
|
|
1732
|
+
onError: handleError
|
|
1733
|
+
}
|
|
1734
|
+
),
|
|
1735
|
+
stepView === "processing" && registration.kind !== "idle" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1736
|
+
_chunkY3RA3YGAcjs.ProcessingStep,
|
|
1462
1737
|
{
|
|
1463
|
-
smartAccount:
|
|
1464
|
-
txHash:
|
|
1465
|
-
sourceChain
|
|
1466
|
-
sourceToken
|
|
1738
|
+
smartAccount: registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : "0x0",
|
|
1739
|
+
txHash: _nullishCoalesce(storeApi.getState().txHash, () => ( "0x0")),
|
|
1740
|
+
sourceChain,
|
|
1741
|
+
sourceToken,
|
|
1467
1742
|
targetChain,
|
|
1468
1743
|
targetToken,
|
|
1469
|
-
amount:
|
|
1470
|
-
directTransfer:
|
|
1744
|
+
amount: _nullishCoalesce(storeApi.getState().amount, () => ( "0")),
|
|
1745
|
+
directTransfer: isSameRoute,
|
|
1471
1746
|
waitForFinalTx,
|
|
1472
1747
|
service,
|
|
1473
1748
|
flowLabel: "withdraw",
|
|
1474
1749
|
onClose,
|
|
1475
|
-
onNewDeposit: () =>
|
|
1750
|
+
onNewDeposit: () => storeApi.dispatch({ type: "flow/reset" }),
|
|
1476
1751
|
onDepositComplete: handleWithdrawComplete,
|
|
1477
1752
|
onDepositFailed: handleWithdrawFailed,
|
|
1478
1753
|
onError: handleError,
|
|
@@ -1481,11 +1756,18 @@ function WithdrawFlow({
|
|
|
1481
1756
|
)
|
|
1482
1757
|
] });
|
|
1483
1758
|
}
|
|
1759
|
+
function deriveStepView(step, _registration) {
|
|
1760
|
+
if (step === "review") return "review";
|
|
1761
|
+
if (step === "processing" || step === "complete" || step === "failed") {
|
|
1762
|
+
return "processing";
|
|
1763
|
+
}
|
|
1764
|
+
return "form";
|
|
1765
|
+
}
|
|
1484
1766
|
|
|
1485
1767
|
// src/WithdrawModal.tsx
|
|
1486
1768
|
|
|
1487
1769
|
var ReownWithdrawInner = _react.lazy.call(void 0,
|
|
1488
|
-
() => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-
|
|
1770
|
+
() => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-4M3PBY2T.cjs"))).then((m) => ({
|
|
1489
1771
|
default: m.WithdrawModalReown
|
|
1490
1772
|
}))
|
|
1491
1773
|
);
|
|
@@ -1513,8 +1795,8 @@ function WithdrawModalInner({
|
|
|
1513
1795
|
inline,
|
|
1514
1796
|
closeOnOverlayClick,
|
|
1515
1797
|
allowedRoutes,
|
|
1516
|
-
backendUrl =
|
|
1517
|
-
signerAddress =
|
|
1798
|
+
backendUrl = _chunkXCAF6B3Dcjs.DEFAULT_BACKEND_URL,
|
|
1799
|
+
signerAddress = _chunkXCAF6B3Dcjs.DEFAULT_SIGNER_ADDRESS,
|
|
1518
1800
|
sessionChainIds,
|
|
1519
1801
|
forceRegister = false,
|
|
1520
1802
|
waitForFinalTx = true,
|
|
@@ -1523,68 +1805,58 @@ function WithdrawModalInner({
|
|
|
1523
1805
|
onDisconnect,
|
|
1524
1806
|
onSignTransaction,
|
|
1525
1807
|
onRequestConnect,
|
|
1526
|
-
connectButtonLabel,
|
|
1527
1808
|
theme,
|
|
1528
|
-
branding,
|
|
1529
1809
|
uiConfig,
|
|
1530
1810
|
className,
|
|
1531
1811
|
onReady,
|
|
1532
|
-
|
|
1533
|
-
onWithdrawSubmitted,
|
|
1534
|
-
onWithdrawComplete,
|
|
1535
|
-
onWithdrawFailed,
|
|
1812
|
+
onLifecycle,
|
|
1536
1813
|
onEvent,
|
|
1537
1814
|
onError,
|
|
1538
1815
|
debug
|
|
1539
1816
|
}) {
|
|
1540
1817
|
const modalRef = _react.useRef.call(void 0, null);
|
|
1541
|
-
const onReadyRef =
|
|
1542
|
-
const [
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
const targetChain =
|
|
1546
|
-
const sourceChain =
|
|
1818
|
+
const onReadyRef = _chunkY3RA3YGAcjs.useLatestRef.call(void 0, onReady);
|
|
1819
|
+
const [backHandler, setBackHandler] = _react.useState.call(void 0,
|
|
1820
|
+
void 0
|
|
1821
|
+
);
|
|
1822
|
+
const targetChain = _chunkXCAF6B3Dcjs.getChainId.call(void 0, targetChainProp);
|
|
1823
|
+
const sourceChain = _chunkXCAF6B3Dcjs.getChainId.call(void 0, sourceChainProp);
|
|
1547
1824
|
const service = _react.useMemo.call(void 0,
|
|
1548
|
-
() =>
|
|
1825
|
+
() => _chunkY3RA3YGAcjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
|
|
1549
1826
|
[backendUrl, debug]
|
|
1550
1827
|
);
|
|
1828
|
+
const store = _react.useMemo.call(void 0, () => createWithdrawStore(), []);
|
|
1829
|
+
const onErrorRef = _chunkY3RA3YGAcjs.useLatestRef.call(void 0, onError);
|
|
1830
|
+
_react.useEffect.call(void 0, () => {
|
|
1831
|
+
if (isOpen && onSignTransaction && !dappAddress) {
|
|
1832
|
+
_optionalChain([onErrorRef, 'access', _62 => _62.current, 'optionalCall', _63 => _63({
|
|
1833
|
+
message: "WithdrawModal requires `dappAddress` when `onSignTransaction` is provided.",
|
|
1834
|
+
code: "WITHDRAW_MISSING_DAPP_ADDRESS"
|
|
1835
|
+
})]);
|
|
1836
|
+
}
|
|
1837
|
+
}, [isOpen, onSignTransaction, dappAddress, onErrorRef]);
|
|
1551
1838
|
_react.useEffect.call(void 0, () => {
|
|
1552
1839
|
if (isOpen && modalRef.current) {
|
|
1553
|
-
|
|
1840
|
+
_chunkY3RA3YGAcjs.applyTheme.call(void 0, modalRef.current, theme);
|
|
1554
1841
|
}
|
|
1555
1842
|
}, [isOpen, theme]);
|
|
1556
1843
|
_react.useEffect.call(void 0, () => {
|
|
1557
1844
|
if (isOpen) {
|
|
1558
|
-
_optionalChain([onReadyRef, 'access',
|
|
1845
|
+
_optionalChain([onReadyRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65()]);
|
|
1559
1846
|
}
|
|
1560
1847
|
}, [isOpen, onReadyRef]);
|
|
1561
1848
|
_react.useEffect.call(void 0, () => {
|
|
1562
1849
|
if (!isOpen) {
|
|
1563
|
-
|
|
1850
|
+
store.dispatch({ type: "modal/reset" });
|
|
1564
1851
|
}
|
|
1565
|
-
}, [isOpen]);
|
|
1566
|
-
const handleStepChange = _react.useCallback.call(void 0,
|
|
1567
|
-
(
|
|
1568
|
-
setCurrentStepIndex(stepIndex);
|
|
1569
|
-
backHandlerRef.current = onBack;
|
|
1570
|
-
},
|
|
1571
|
-
[]
|
|
1572
|
-
);
|
|
1573
|
-
const handleTotalBalanceChange = _react.useCallback.call(void 0, (balance2) => {
|
|
1574
|
-
setTotalBalanceUsd(balance2);
|
|
1852
|
+
}, [isOpen, store]);
|
|
1853
|
+
const handleStepChange = _react.useCallback.call(void 0, (onBack) => {
|
|
1854
|
+
setBackHandler(() => onBack);
|
|
1575
1855
|
}, []);
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _58 => _58.showStepper]), () => ( false));
|
|
1581
|
-
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _59 => _59.showBackButton]), () => ( true));
|
|
1582
|
-
const balance = _optionalChain([uiConfig, 'optionalAccess', _60 => _60.balance]);
|
|
1583
|
-
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _61 => _61.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
|
|
1584
|
-
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _62 => _62.title]), () => ( "Withdraw"));
|
|
1585
|
-
const canGoBack = currentStepIndex > 0 && currentStepIndex < 3 && backHandlerRef.current;
|
|
1586
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1587
|
-
_chunkNFXJEOE6cjs.Modal,
|
|
1856
|
+
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _66 => _66.showBackButton]), () => ( true));
|
|
1857
|
+
const canGoBack = backHandler !== void 0;
|
|
1858
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawStoreProvider, { store, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1859
|
+
_chunkY3RA3YGAcjs.Modal,
|
|
1588
1860
|
{
|
|
1589
1861
|
isOpen,
|
|
1590
1862
|
onClose,
|
|
@@ -1593,59 +1865,16 @@ function WithdrawModalInner({
|
|
|
1593
1865
|
closeOnOverlayClick,
|
|
1594
1866
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: modalRef, className: "rs-modal", children: [
|
|
1595
1867
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header--redesigned", children: [
|
|
1596
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1868
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && backHandler && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1597
1869
|
"button",
|
|
1598
1870
|
{
|
|
1599
1871
|
type: "button",
|
|
1600
1872
|
className: "rs-modal-header-back",
|
|
1601
1873
|
"aria-label": "Go back",
|
|
1602
|
-
onClick:
|
|
1603
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1604
|
-
"svg",
|
|
1605
|
-
{
|
|
1606
|
-
viewBox: "0 0 24 24",
|
|
1607
|
-
fill: "none",
|
|
1608
|
-
stroke: "currentColor",
|
|
1609
|
-
strokeWidth: "2",
|
|
1610
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1611
|
-
"path",
|
|
1612
|
-
{
|
|
1613
|
-
strokeLinecap: "round",
|
|
1614
|
-
strokeLinejoin: "round",
|
|
1615
|
-
d: "M15.75 19.5L8.25 12l7.5-7.5"
|
|
1616
|
-
}
|
|
1617
|
-
)
|
|
1618
|
-
}
|
|
1619
|
-
)
|
|
1874
|
+
onClick: backHandler,
|
|
1875
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.ChevronLeftIcon, {})
|
|
1620
1876
|
}
|
|
1621
1877
|
) }),
|
|
1622
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header-nav-center", children: [
|
|
1623
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header-title-row", children: [
|
|
1624
|
-
showLogo && logoUrl && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1625
|
-
"img",
|
|
1626
|
-
{
|
|
1627
|
-
src: logoUrl,
|
|
1628
|
-
alt: "",
|
|
1629
|
-
className: "rs-modal-logo",
|
|
1630
|
-
onError: (e) => {
|
|
1631
|
-
e.target.style.display = "none";
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
),
|
|
1635
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-title", children: title }),
|
|
1636
|
-
showStepper && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-progress", style: { marginLeft: 8 }, children: [0, 1].map((i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1637
|
-
"div",
|
|
1638
|
-
{
|
|
1639
|
-
className: `rs-modal-progress-dot ${i <= currentStepIndex ? "rs-modal-progress-dot--active" : "rs-modal-progress-dot--inactive"}`
|
|
1640
|
-
},
|
|
1641
|
-
i
|
|
1642
|
-
)) })
|
|
1643
|
-
] }),
|
|
1644
|
-
balance && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header-balance", children: [
|
|
1645
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-label", children: balance.title }),
|
|
1646
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ? _chunkNFXJEOE6cjs.currencyFormatter.format(totalBalanceUsd) : null))) })
|
|
1647
|
-
] })
|
|
1648
|
-
] }),
|
|
1649
1878
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1650
1879
|
"button",
|
|
1651
1880
|
{
|
|
@@ -1653,23 +1882,7 @@ function WithdrawModalInner({
|
|
|
1653
1882
|
onClick: onClose,
|
|
1654
1883
|
className: "rs-modal-close",
|
|
1655
1884
|
"aria-label": "Close",
|
|
1656
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1657
|
-
"svg",
|
|
1658
|
-
{
|
|
1659
|
-
viewBox: "0 0 24 24",
|
|
1660
|
-
fill: "none",
|
|
1661
|
-
stroke: "currentColor",
|
|
1662
|
-
strokeWidth: "2",
|
|
1663
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1664
|
-
"path",
|
|
1665
|
-
{
|
|
1666
|
-
strokeLinecap: "round",
|
|
1667
|
-
strokeLinejoin: "round",
|
|
1668
|
-
d: "M6 18L18 6M6 6l12 12"
|
|
1669
|
-
}
|
|
1670
|
-
)
|
|
1671
|
-
}
|
|
1672
|
-
)
|
|
1885
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3RA3YGAcjs.CloseIcon, {})
|
|
1673
1886
|
}
|
|
1674
1887
|
) })
|
|
1675
1888
|
] }),
|
|
@@ -1697,14 +1910,9 @@ function WithdrawModalInner({
|
|
|
1697
1910
|
onDisconnect,
|
|
1698
1911
|
onSignTransaction,
|
|
1699
1912
|
onRequestConnect,
|
|
1700
|
-
connectButtonLabel,
|
|
1701
1913
|
onStepChange: handleStepChange,
|
|
1702
|
-
onTotalBalanceChange: handleTotalBalanceChange,
|
|
1703
1914
|
onClose,
|
|
1704
|
-
|
|
1705
|
-
onWithdrawSubmitted,
|
|
1706
|
-
onWithdrawComplete,
|
|
1707
|
-
onWithdrawFailed,
|
|
1915
|
+
onLifecycle,
|
|
1708
1916
|
onEvent,
|
|
1709
1917
|
onError,
|
|
1710
1918
|
debug
|
|
@@ -1712,7 +1920,7 @@ function WithdrawModalInner({
|
|
|
1712
1920
|
)
|
|
1713
1921
|
] })
|
|
1714
1922
|
}
|
|
1715
|
-
);
|
|
1923
|
+
) });
|
|
1716
1924
|
}
|
|
1717
1925
|
|
|
1718
1926
|
|