@rhinestone/deposit-modal 0.1.24 → 0.1.25
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 +1 -5
- package/dist/DepositModalReown-4A5HJK74.mjs +33 -0
- package/dist/DepositModalReown-QQ6WI265.cjs +33 -0
- package/dist/WithdrawModalReown-HBORIX2O.mjs +33 -0
- package/dist/WithdrawModalReown-L77OC26X.cjs +33 -0
- package/dist/{chunk-O3I5KVXA.cjs → chunk-4QDHXCPG.cjs} +97 -81
- package/dist/chunk-6VJ2ZTNQ.cjs +90 -0
- package/dist/{chunk-35DWLO33.mjs → chunk-B3HMNWR4.mjs} +61 -45
- package/dist/{chunk-ANQQMGNN.cjs → chunk-CZWAKYDR.cjs} +230 -115
- package/dist/{chunk-P7SQQAAF.mjs → chunk-GAFLOODV.mjs} +203 -88
- package/dist/{chunk-ZMVCDFXM.mjs → chunk-JAR372KJ.mjs} +48 -40
- package/dist/chunk-LBEP3A2Z.mjs +90 -0
- package/dist/{chunk-A2PDOYYE.cjs → chunk-VBNFP3JF.cjs} +89 -81
- package/dist/deposit.cjs +3 -3
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/reown.cjs +6 -191
- package/dist/reown.d.cts +4 -12
- package/dist/reown.d.ts +4 -12
- package/dist/reown.mjs +8 -193
- package/dist/{types-CUww05xT.d.cts → types-BwaQ7jK5.d.cts} +3 -16
- package/dist/{types-Z6GjVWFR.d.ts → types-CgXyx46m.d.ts} +3 -16
- package/dist/withdraw.cjs +3 -3
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +2 -2
- package/package.json +16 -33
package/README.md
CHANGED
|
@@ -15,14 +15,10 @@ Prefer subpath imports so apps only bundle what they use:
|
|
|
15
15
|
```tsx
|
|
16
16
|
import { DepositModal } from "@rhinestone/deposit-modal/deposit";
|
|
17
17
|
import { WithdrawModal } from "@rhinestone/deposit-modal/withdraw";
|
|
18
|
-
import { DepositModal as DepositModalReown } from "@rhinestone/deposit-modal/reown";
|
|
19
18
|
import { executeSafeEthTransfer } from "@rhinestone/deposit-modal/safe";
|
|
20
19
|
import { getChainName } from "@rhinestone/deposit-modal/constants";
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
If you use `reownAppId`, import modal components from
|
|
24
|
-
`@rhinestone/deposit-modal/reown`.
|
|
25
|
-
|
|
26
22
|
## DepositModal
|
|
27
23
|
|
|
28
24
|
Deposits tokens from any supported chain into a target chain/token via a Rhinestone smart account.
|
|
@@ -92,7 +88,7 @@ Notes:
|
|
|
92
88
|
| `defaultAmount` | `string` | No | Pre-filled amount |
|
|
93
89
|
| `recipient` | `Address` | No | Custom recipient address |
|
|
94
90
|
| `backendUrl` | `string` | No | Backend URL |
|
|
95
|
-
| `rhinestoneApiKey` | `string` | No |
|
|
91
|
+
| `rhinestoneApiKey` | `string` | No | Optional SDK api key forwarded to `RhinestoneSDK` during smart-account setup |
|
|
96
92
|
| `signerAddress` | `Address` | No | Session signer address |
|
|
97
93
|
| `waitForFinalTx` | `boolean` | No | Wait for destination tx (default: true) |
|
|
98
94
|
| `onRequestConnect` | `() => void` | No | Called when wallet connection needed |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DepositModalInner
|
|
3
|
+
} from "./chunk-JAR372KJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ReownWalletProvider,
|
|
6
|
+
useReownWallet
|
|
7
|
+
} from "./chunk-LBEP3A2Z.mjs";
|
|
8
|
+
import "./chunk-GAFLOODV.mjs";
|
|
9
|
+
import "./chunk-A6QLADED.mjs";
|
|
10
|
+
|
|
11
|
+
// src/DepositModalReown.tsx
|
|
12
|
+
import { useCallback } from "react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
function DepositModalWithReown(props) {
|
|
15
|
+
const reown = useReownWallet();
|
|
16
|
+
const handleConnect = useCallback(() => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
DepositModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function DepositModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ jsx(DepositModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
DepositModalReown
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkVBNFP3JFcjs = require('./chunk-VBNFP3JF.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk6VJ2ZTNQcjs = require('./chunk-6VJ2ZTNQ.cjs');
|
|
8
|
+
require('./chunk-CZWAKYDR.cjs');
|
|
9
|
+
require('./chunk-CEIWN53N.cjs');
|
|
10
|
+
|
|
11
|
+
// src/DepositModalReown.tsx
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
+
function DepositModalWithReown(props) {
|
|
15
|
+
const reown = _chunk6VJ2ZTNQcjs.useReownWallet.call(void 0, );
|
|
16
|
+
const handleConnect = _react.useCallback.call(void 0, () => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
20
|
+
_chunkVBNFP3JFcjs.DepositModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function DepositModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk6VJ2ZTNQcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DepositModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.DepositModalReown = DepositModalReown;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WithdrawModalInner
|
|
3
|
+
} from "./chunk-B3HMNWR4.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ReownWalletProvider,
|
|
6
|
+
useReownWallet
|
|
7
|
+
} from "./chunk-LBEP3A2Z.mjs";
|
|
8
|
+
import "./chunk-GAFLOODV.mjs";
|
|
9
|
+
import "./chunk-A6QLADED.mjs";
|
|
10
|
+
|
|
11
|
+
// src/WithdrawModalReown.tsx
|
|
12
|
+
import { useCallback } from "react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
function WithdrawModalWithReown(props) {
|
|
15
|
+
const reown = useReownWallet();
|
|
16
|
+
const handleConnect = useCallback(() => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
WithdrawModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function WithdrawModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ jsx(WithdrawModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
WithdrawModalReown
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk4QDHXCPGcjs = require('./chunk-4QDHXCPG.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk6VJ2ZTNQcjs = require('./chunk-6VJ2ZTNQ.cjs');
|
|
8
|
+
require('./chunk-CZWAKYDR.cjs');
|
|
9
|
+
require('./chunk-CEIWN53N.cjs');
|
|
10
|
+
|
|
11
|
+
// src/WithdrawModalReown.tsx
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
+
function WithdrawModalWithReown(props) {
|
|
15
|
+
const reown = _chunk6VJ2ZTNQcjs.useReownWallet.call(void 0, );
|
|
16
|
+
const handleConnect = _react.useCallback.call(void 0, () => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
20
|
+
_chunk4QDHXCPGcjs.WithdrawModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function WithdrawModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk6VJ2ZTNQcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.WithdrawModalReown = WithdrawModalReown;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkCZWAKYDRcjs = require('./chunk-CZWAKYDR.cjs');
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
|
|
@@ -39,6 +43,8 @@ var _chunkCEIWN53Ncjs = require('./chunk-CEIWN53N.cjs');
|
|
|
39
43
|
|
|
40
44
|
|
|
41
45
|
|
|
46
|
+
|
|
47
|
+
|
|
42
48
|
var _react = require('react');
|
|
43
49
|
|
|
44
50
|
// src/WithdrawFlow.tsx
|
|
@@ -109,7 +115,7 @@ function WithdrawFormStep({
|
|
|
109
115
|
setIsSwitching(true);
|
|
110
116
|
switchChain(asset.chainId).catch((err) => {
|
|
111
117
|
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
112
|
-
setError(
|
|
118
|
+
setError(_chunkCZWAKYDRcjs.formatUserError.call(void 0, raw));
|
|
113
119
|
}).finally(() => {
|
|
114
120
|
setIsSwitching(false);
|
|
115
121
|
});
|
|
@@ -126,7 +132,7 @@ function WithdrawFormStep({
|
|
|
126
132
|
return;
|
|
127
133
|
}
|
|
128
134
|
try {
|
|
129
|
-
const bal =
|
|
135
|
+
const bal = _chunkCZWAKYDRcjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
|
|
130
136
|
address: asset.token,
|
|
131
137
|
abi: _viem.erc20Abi,
|
|
132
138
|
functionName: "balanceOf",
|
|
@@ -228,7 +234,7 @@ function WithdrawFormStep({
|
|
|
228
234
|
await onSubmit(recipient, amount);
|
|
229
235
|
} catch (err) {
|
|
230
236
|
const raw = err instanceof Error ? err.message : "Withdrawal failed";
|
|
231
|
-
setError(
|
|
237
|
+
setError(_chunkCZWAKYDRcjs.formatUserError.call(void 0, raw));
|
|
232
238
|
} finally {
|
|
233
239
|
setIsSubmitting(false);
|
|
234
240
|
}
|
|
@@ -240,7 +246,7 @@ function WithdrawFormStep({
|
|
|
240
246
|
await switchChain(asset.chainId);
|
|
241
247
|
} catch (err) {
|
|
242
248
|
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
243
|
-
setError(
|
|
249
|
+
setError(_chunkCZWAKYDRcjs.formatUserError.call(void 0, raw));
|
|
244
250
|
} finally {
|
|
245
251
|
setIsSwitching(false);
|
|
246
252
|
}
|
|
@@ -330,7 +336,7 @@ function WithdrawFormStep({
|
|
|
330
336
|
] })
|
|
331
337
|
] }),
|
|
332
338
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-amount-info", children: [
|
|
333
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ?
|
|
339
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkCZWAKYDRcjs.currencyFormatter.format(amountUsd) : "$0.00" }),
|
|
334
340
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-withdraw-balance", children: [
|
|
335
341
|
formattedBalance,
|
|
336
342
|
" ",
|
|
@@ -507,7 +513,7 @@ function WithdrawFormStep({
|
|
|
507
513
|
" to continue."
|
|
508
514
|
] }),
|
|
509
515
|
switchChain && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
510
|
-
|
|
516
|
+
_chunkCZWAKYDRcjs.Button,
|
|
511
517
|
{
|
|
512
518
|
variant: "outline",
|
|
513
519
|
size: "small",
|
|
@@ -539,7 +545,7 @@ function WithdrawFormStep({
|
|
|
539
545
|
] })
|
|
540
546
|
] }),
|
|
541
547
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
542
|
-
|
|
548
|
+
_chunkCZWAKYDRcjs.Button,
|
|
543
549
|
{
|
|
544
550
|
onClick: handleWithdraw,
|
|
545
551
|
fullWidth: true,
|
|
@@ -548,11 +554,14 @@ function WithdrawFormStep({
|
|
|
548
554
|
children: isBusy ? "Preparing..." : "Withdraw"
|
|
549
555
|
}
|
|
550
556
|
) }),
|
|
551
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
557
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCZWAKYDRcjs.PoweredBy, {})
|
|
552
558
|
] });
|
|
553
559
|
}
|
|
554
560
|
WithdrawFormStep.displayName = "WithdrawFormStep";
|
|
555
561
|
|
|
562
|
+
// src/WithdrawFlow.tsx
|
|
563
|
+
var _sdk = require('@rhinestone/sdk');
|
|
564
|
+
|
|
556
565
|
// src/core/safe.ts
|
|
557
566
|
|
|
558
567
|
|
|
@@ -853,13 +862,14 @@ function WithdrawFlow({
|
|
|
853
862
|
recipient: defaultRecipient,
|
|
854
863
|
amount: defaultAmount,
|
|
855
864
|
service,
|
|
865
|
+
rhinestoneApiKey,
|
|
856
866
|
signerAddress = _chunkCEIWN53Ncjs.DEFAULT_SIGNER_ADDRESS,
|
|
857
867
|
sessionChainIds,
|
|
858
868
|
forceRegister = false,
|
|
859
869
|
waitForFinalTx = true,
|
|
860
870
|
reownWallet,
|
|
861
871
|
onConnect,
|
|
862
|
-
|
|
872
|
+
onSignTransaction,
|
|
863
873
|
onRequestConnect,
|
|
864
874
|
connectButtonLabel,
|
|
865
875
|
onStepChange,
|
|
@@ -883,7 +893,7 @@ function WithdrawFlow({
|
|
|
883
893
|
setTargetToken(targetTokenProp);
|
|
884
894
|
}, [targetChainProp, targetTokenProp]);
|
|
885
895
|
const targetChainObj = _react.useMemo.call(void 0, () => _chunkCEIWN53Ncjs.CHAIN_BY_ID[targetChain], [targetChain]);
|
|
886
|
-
const hasCustomSigner = Boolean(dappAddress &&
|
|
896
|
+
const hasCustomSigner = Boolean(dappAddress && onSignTransaction);
|
|
887
897
|
const dappSwitchChain = _react.useMemo.call(void 0, () => {
|
|
888
898
|
if (!_optionalChain([dappWalletClient, 'optionalAccess', _6 => _6.switchChain])) return void 0;
|
|
889
899
|
return async (chainId) => {
|
|
@@ -923,14 +933,14 @@ function WithdrawFlow({
|
|
|
923
933
|
return {
|
|
924
934
|
ownerAddress: dappAddress,
|
|
925
935
|
walletClient: _nullishCoalesce(dappWalletClient, () => ( void 0)),
|
|
926
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
936
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkCZWAKYDRcjs.getPublicClient.call(void 0, sourceChain))),
|
|
927
937
|
switchChain: dappSwitchChain
|
|
928
938
|
};
|
|
929
939
|
}
|
|
930
940
|
return {
|
|
931
941
|
ownerAddress: dappWalletClient.account.address,
|
|
932
942
|
walletClient: dappWalletClient,
|
|
933
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
943
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkCZWAKYDRcjs.getPublicClient.call(void 0, sourceChain))),
|
|
934
944
|
switchChain: dappSwitchChain
|
|
935
945
|
};
|
|
936
946
|
}
|
|
@@ -939,7 +949,7 @@ function WithdrawFlow({
|
|
|
939
949
|
return {
|
|
940
950
|
ownerAddress: dappWalletClient.account.address,
|
|
941
951
|
walletClient: dappWalletClient,
|
|
942
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
952
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkCZWAKYDRcjs.getPublicClient.call(void 0, sourceChain))),
|
|
943
953
|
switchChain: dappSwitchChain
|
|
944
954
|
};
|
|
945
955
|
}
|
|
@@ -968,7 +978,7 @@ function WithdrawFlow({
|
|
|
968
978
|
const symbol = _chunkCEIWN53Ncjs.getTokenSymbol.call(void 0, sourceToken, sourceChain);
|
|
969
979
|
const decimals = _chunkCEIWN53Ncjs.getTokenDecimalsByAddress.call(void 0, sourceToken, sourceChain);
|
|
970
980
|
return {
|
|
971
|
-
id:
|
|
981
|
+
id: _chunkCZWAKYDRcjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
|
|
972
982
|
chainId: sourceChain,
|
|
973
983
|
token: sourceToken,
|
|
974
984
|
symbol,
|
|
@@ -998,37 +1008,27 @@ function WithdrawFlow({
|
|
|
998
1008
|
[onError]
|
|
999
1009
|
);
|
|
1000
1010
|
const resolveSessionOwner = _react.useCallback.call(void 0, async (eoaAddress) => {
|
|
1001
|
-
const localOwner =
|
|
1011
|
+
const localOwner = _chunkCZWAKYDRcjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
|
|
1002
1012
|
if (localOwner) {
|
|
1003
1013
|
return {
|
|
1004
|
-
account:
|
|
1014
|
+
account: _chunkCZWAKYDRcjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
|
|
1005
1015
|
address: localOwner.address
|
|
1006
1016
|
};
|
|
1007
1017
|
}
|
|
1008
|
-
const created =
|
|
1009
|
-
|
|
1018
|
+
const created = _chunkCZWAKYDRcjs.createSessionOwnerKey.call(void 0, );
|
|
1019
|
+
_chunkCZWAKYDRcjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
|
|
1010
1020
|
return {
|
|
1011
1021
|
account: created.account,
|
|
1012
1022
|
address: created.address
|
|
1013
1023
|
};
|
|
1014
1024
|
}, []);
|
|
1015
|
-
const signSessionDetails = _react.useCallback.call(void 0,
|
|
1016
|
-
async (sessionOwnerAccount, typedData) => {
|
|
1017
|
-
const signer = sessionOwnerAccount;
|
|
1018
|
-
if (!signer.signTypedData) {
|
|
1019
|
-
throw new Error("Session owner cannot sign typed data");
|
|
1020
|
-
}
|
|
1021
|
-
return await signer.signTypedData(typedData);
|
|
1022
|
-
},
|
|
1023
|
-
[]
|
|
1024
|
-
);
|
|
1025
1025
|
const handleFormSubmit = _react.useCallback.call(void 0,
|
|
1026
1026
|
async (recipient, amountValue) => {
|
|
1027
1027
|
const ownerAddress2 = _optionalChain([signerContext, 'optionalAccess', _22 => _22.ownerAddress]);
|
|
1028
1028
|
if (!ownerAddress2) {
|
|
1029
1029
|
throw new Error("Wallet not connected");
|
|
1030
1030
|
}
|
|
1031
|
-
if (!
|
|
1031
|
+
if (!onSignTransaction && !_optionalChain([signerContext, 'optionalAccess', _23 => _23.walletClient])) {
|
|
1032
1032
|
throw new Error("Wallet not connected");
|
|
1033
1033
|
}
|
|
1034
1034
|
if (!targetChainObj) {
|
|
@@ -1036,32 +1036,31 @@ function WithdrawFlow({
|
|
|
1036
1036
|
}
|
|
1037
1037
|
setIsSubmitting(true);
|
|
1038
1038
|
try {
|
|
1039
|
+
const signerAccount = _optionalChain([signerContext, 'optionalAccess', _24 => _24.walletClient]) ? _sdk.walletClientToAccount.call(void 0, signerContext.walletClient) : _chunkCZWAKYDRcjs.createViewOnlyAccount.call(void 0, ownerAddress2);
|
|
1039
1040
|
const sessionOwner = await resolveSessionOwner(ownerAddress2);
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
sessionChainIds
|
|
1047
|
-
});
|
|
1048
|
-
const smartAccount = prepared.smartAccount;
|
|
1041
|
+
const account = await _chunkCZWAKYDRcjs.createSmartAccount.call(void 0,
|
|
1042
|
+
signerAccount,
|
|
1043
|
+
sessionOwner.account,
|
|
1044
|
+
rhinestoneApiKey
|
|
1045
|
+
);
|
|
1046
|
+
const smartAccount = _chunkCZWAKYDRcjs.getAccountAddress.call(void 0, account);
|
|
1049
1047
|
const checkResult = await service.checkAccount(smartAccount);
|
|
1050
|
-
const targetMatches = checkResult.targetChain === targetChain && _optionalChain([checkResult, 'access',
|
|
1048
|
+
const targetMatches = checkResult.targetChain === targetChain && _optionalChain([checkResult, 'access', _25 => _25.targetToken, 'optionalAccess', _26 => _26.toLowerCase, 'call', _27 => _27()]) === targetToken.toLowerCase();
|
|
1051
1049
|
if (!checkResult.isRegistered || forceRegister || !targetMatches) {
|
|
1052
|
-
const
|
|
1050
|
+
const initData = _chunkCZWAKYDRcjs.getAccountInitData.call(void 0, account);
|
|
1051
|
+
const sessionDetails = await _chunkCZWAKYDRcjs.getSessionDetails.call(void 0,
|
|
1052
|
+
account,
|
|
1053
|
+
targetChainObj,
|
|
1054
|
+
signerAddress,
|
|
1053
1055
|
sessionOwner.account,
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
const sessionDetails = _chunkANQQMGNNcjs.buildSessionDetails.call(void 0,
|
|
1057
|
-
prepared.sessionDetailsUnsigned,
|
|
1058
|
-
signature
|
|
1056
|
+
targetToken,
|
|
1057
|
+
sessionChainIds
|
|
1059
1058
|
);
|
|
1060
1059
|
await service.registerAccount({
|
|
1061
1060
|
address: smartAccount,
|
|
1062
1061
|
accountParams: {
|
|
1063
|
-
factory:
|
|
1064
|
-
factoryData:
|
|
1062
|
+
factory: initData.factory,
|
|
1063
|
+
factoryData: initData.factoryData,
|
|
1065
1064
|
sessionDetails
|
|
1066
1065
|
},
|
|
1067
1066
|
eoaAddress: ownerAddress2,
|
|
@@ -1075,9 +1074,9 @@ function WithdrawFlow({
|
|
|
1075
1074
|
}
|
|
1076
1075
|
handleConnected(ownerAddress2, smartAccount);
|
|
1077
1076
|
const amountUnits = _viem.parseUnits.call(void 0, amountValue, asset.decimals);
|
|
1078
|
-
const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess',
|
|
1077
|
+
const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _28 => _28.publicClient]), () => ( _chunkCZWAKYDRcjs.getPublicClient.call(void 0, sourceChain)));
|
|
1079
1078
|
let result;
|
|
1080
|
-
if (
|
|
1079
|
+
if (onSignTransaction) {
|
|
1081
1080
|
const transferData = isSourceNative ? { to: smartAccount, value: amountUnits, data: "0x" } : {
|
|
1082
1081
|
to: sourceToken,
|
|
1083
1082
|
value: 0n,
|
|
@@ -1095,7 +1094,18 @@ function WithdrawFlow({
|
|
|
1095
1094
|
data: transferData.data,
|
|
1096
1095
|
chainId: sourceChain
|
|
1097
1096
|
});
|
|
1098
|
-
|
|
1097
|
+
const { signature } = await onSignTransaction(request);
|
|
1098
|
+
const relayResult = await service.relayWithdraw({
|
|
1099
|
+
smartAccount,
|
|
1100
|
+
chainId: sourceChain,
|
|
1101
|
+
safeAddress,
|
|
1102
|
+
safeTransaction: request.typedData.message,
|
|
1103
|
+
signature
|
|
1104
|
+
});
|
|
1105
|
+
if (!relayResult.txHash) {
|
|
1106
|
+
throw new Error("Relay succeeded but no txHash returned");
|
|
1107
|
+
}
|
|
1108
|
+
result = { txHash: relayResult.txHash };
|
|
1099
1109
|
} else if (isSourceNative) {
|
|
1100
1110
|
result = await executeSafeEthTransfer({
|
|
1101
1111
|
walletClient: signerContext.walletClient,
|
|
@@ -1116,7 +1126,7 @@ function WithdrawFlow({
|
|
|
1116
1126
|
chainId: sourceChain
|
|
1117
1127
|
});
|
|
1118
1128
|
}
|
|
1119
|
-
_optionalChain([onWithdrawSubmitted, 'optionalCall',
|
|
1129
|
+
_optionalChain([onWithdrawSubmitted, 'optionalCall', _29 => _29({
|
|
1120
1130
|
txHash: result.txHash,
|
|
1121
1131
|
sourceChain,
|
|
1122
1132
|
amount: amountUnits.toString(),
|
|
@@ -1132,7 +1142,7 @@ function WithdrawFlow({
|
|
|
1132
1142
|
});
|
|
1133
1143
|
} catch (err) {
|
|
1134
1144
|
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
1135
|
-
handleError(
|
|
1145
|
+
handleError(_chunkCZWAKYDRcjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
|
|
1136
1146
|
throw err;
|
|
1137
1147
|
} finally {
|
|
1138
1148
|
setIsSubmitting(false);
|
|
@@ -1148,27 +1158,27 @@ function WithdrawFlow({
|
|
|
1148
1158
|
targetChain,
|
|
1149
1159
|
targetToken,
|
|
1150
1160
|
service,
|
|
1161
|
+
rhinestoneApiKey,
|
|
1151
1162
|
handleConnected,
|
|
1152
1163
|
asset.decimals,
|
|
1153
1164
|
safeAddress,
|
|
1154
1165
|
sourceToken,
|
|
1155
1166
|
sourceChain,
|
|
1156
1167
|
onWithdrawSubmitted,
|
|
1157
|
-
|
|
1168
|
+
onSignTransaction,
|
|
1158
1169
|
isSourceNative,
|
|
1159
|
-
handleError
|
|
1160
|
-
signSessionDetails
|
|
1170
|
+
handleError
|
|
1161
1171
|
]
|
|
1162
1172
|
);
|
|
1163
1173
|
const handleWithdrawComplete = _react.useCallback.call(void 0,
|
|
1164
1174
|
(txHash, destinationTxHash) => {
|
|
1165
|
-
_optionalChain([onWithdrawComplete, 'optionalCall',
|
|
1175
|
+
_optionalChain([onWithdrawComplete, 'optionalCall', _30 => _30({ txHash, destinationTxHash })]);
|
|
1166
1176
|
},
|
|
1167
1177
|
[onWithdrawComplete]
|
|
1168
1178
|
);
|
|
1169
1179
|
const handleWithdrawFailed = _react.useCallback.call(void 0,
|
|
1170
1180
|
(txHash, error) => {
|
|
1171
|
-
_optionalChain([onWithdrawFailed, 'optionalCall',
|
|
1181
|
+
_optionalChain([onWithdrawFailed, 'optionalCall', _31 => _31({ txHash, error })]);
|
|
1172
1182
|
},
|
|
1173
1183
|
[onWithdrawFailed]
|
|
1174
1184
|
);
|
|
@@ -1226,7 +1236,7 @@ function WithdrawFlow({
|
|
|
1226
1236
|
}, [walletOptionsKey, selectedConnectAddressEffective]);
|
|
1227
1237
|
if (showConnectStep) {
|
|
1228
1238
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1229
|
-
|
|
1239
|
+
_chunkCZWAKYDRcjs.ConnectStep,
|
|
1230
1240
|
{
|
|
1231
1241
|
walletOptions,
|
|
1232
1242
|
selectedAddress: selectedConnectAddressEffective,
|
|
@@ -1244,9 +1254,9 @@ function WithdrawFlow({
|
|
|
1244
1254
|
) });
|
|
1245
1255
|
}
|
|
1246
1256
|
if (!signerContext) return null;
|
|
1247
|
-
if (!
|
|
1257
|
+
if (!onSignTransaction && !signerContext.walletClient) return null;
|
|
1248
1258
|
const ownerAddress = signerContext.ownerAddress;
|
|
1249
|
-
const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => (
|
|
1259
|
+
const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkCZWAKYDRcjs.getPublicClient.call(void 0, sourceChain)));
|
|
1250
1260
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
|
|
1251
1261
|
step.type === "form" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1252
1262
|
WithdrawFormStep,
|
|
@@ -1271,7 +1281,7 @@ function WithdrawFlow({
|
|
|
1271
1281
|
}
|
|
1272
1282
|
),
|
|
1273
1283
|
step.type === "processing" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1274
|
-
|
|
1284
|
+
_chunkCZWAKYDRcjs.ProcessingStep,
|
|
1275
1285
|
{
|
|
1276
1286
|
smartAccount: step.smartAccount,
|
|
1277
1287
|
txHash: step.txHash,
|
|
@@ -1296,11 +1306,15 @@ function WithdrawFlow({
|
|
|
1296
1306
|
|
|
1297
1307
|
// src/WithdrawModal.tsx
|
|
1298
1308
|
|
|
1309
|
+
var ReownWithdrawInner = _react.lazy.call(void 0,
|
|
1310
|
+
() => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-L77OC26X.cjs"))).then((m) => ({
|
|
1311
|
+
default: m.WithdrawModalReown
|
|
1312
|
+
}))
|
|
1313
|
+
);
|
|
1299
1314
|
function WithdrawModal(props) {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
);
|
|
1315
|
+
const needsReown = !!props.reownAppId;
|
|
1316
|
+
if (needsReown) {
|
|
1317
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReownWithdrawInner, { ...props }) });
|
|
1304
1318
|
}
|
|
1305
1319
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalInner, { ...props });
|
|
1306
1320
|
}
|
|
@@ -1320,13 +1334,14 @@ function WithdrawModalInner({
|
|
|
1320
1334
|
onClose,
|
|
1321
1335
|
inline,
|
|
1322
1336
|
backendUrl = _chunkCEIWN53Ncjs.DEFAULT_BACKEND_URL,
|
|
1337
|
+
rhinestoneApiKey,
|
|
1323
1338
|
signerAddress = _chunkCEIWN53Ncjs.DEFAULT_SIGNER_ADDRESS,
|
|
1324
1339
|
sessionChainIds,
|
|
1325
1340
|
forceRegister = false,
|
|
1326
1341
|
waitForFinalTx = true,
|
|
1327
1342
|
reownWallet,
|
|
1328
1343
|
onConnect,
|
|
1329
|
-
|
|
1344
|
+
onSignTransaction,
|
|
1330
1345
|
onRequestConnect,
|
|
1331
1346
|
connectButtonLabel,
|
|
1332
1347
|
theme,
|
|
@@ -1347,17 +1362,17 @@ function WithdrawModalInner({
|
|
|
1347
1362
|
const backHandlerRef = _react.useRef.call(void 0, void 0);
|
|
1348
1363
|
const targetChain = _chunkCEIWN53Ncjs.getChainId.call(void 0, targetChainProp);
|
|
1349
1364
|
const sourceChain = _chunkCEIWN53Ncjs.getChainId.call(void 0, sourceChainProp);
|
|
1350
|
-
const service = _react.useMemo.call(void 0, () =>
|
|
1365
|
+
const service = _react.useMemo.call(void 0, () => _chunkCZWAKYDRcjs.createDepositService.call(void 0, backendUrl), [backendUrl]);
|
|
1351
1366
|
_react.useEffect.call(void 0, () => {
|
|
1352
1367
|
if (isOpen && modalRef.current) {
|
|
1353
|
-
|
|
1368
|
+
_chunkCZWAKYDRcjs.applyTheme.call(void 0, modalRef.current, theme);
|
|
1354
1369
|
}
|
|
1355
1370
|
}, [isOpen, theme]);
|
|
1356
1371
|
const hasCalledReady = _react.useRef.call(void 0, false);
|
|
1357
1372
|
_react.useEffect.call(void 0, () => {
|
|
1358
1373
|
if (isOpen && !hasCalledReady.current) {
|
|
1359
1374
|
hasCalledReady.current = true;
|
|
1360
|
-
_optionalChain([onReady, 'optionalCall',
|
|
1375
|
+
_optionalChain([onReady, 'optionalCall', _32 => _32()]);
|
|
1361
1376
|
}
|
|
1362
1377
|
}, [isOpen, onReady]);
|
|
1363
1378
|
_react.useEffect.call(void 0, () => {
|
|
@@ -1376,17 +1391,17 @@ function WithdrawModalInner({
|
|
|
1376
1391
|
setTotalBalanceUsd(balance);
|
|
1377
1392
|
}, []);
|
|
1378
1393
|
const handleBack = _react.useCallback.call(void 0, () => {
|
|
1379
|
-
_optionalChain([backHandlerRef, 'access',
|
|
1394
|
+
_optionalChain([backHandlerRef, 'access', _33 => _33.current, 'optionalCall', _34 => _34()]);
|
|
1380
1395
|
}, []);
|
|
1381
|
-
const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
1382
|
-
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
1383
|
-
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
1384
|
-
const balanceTitle = _optionalChain([uiConfig, 'optionalAccess',
|
|
1385
|
-
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess',
|
|
1386
|
-
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess',
|
|
1396
|
+
const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _35 => _35.showLogo]), () => ( false));
|
|
1397
|
+
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _36 => _36.showStepper]), () => ( false));
|
|
1398
|
+
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _37 => _37.showBackButton]), () => ( true));
|
|
1399
|
+
const balanceTitle = _optionalChain([uiConfig, 'optionalAccess', _38 => _38.balanceTitle]);
|
|
1400
|
+
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _39 => _39.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
|
|
1401
|
+
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _40 => _40.title]), () => ( "Withdraw"));
|
|
1387
1402
|
const canGoBack = currentStepIndex > 0 && currentStepIndex < 3 && backHandlerRef.current;
|
|
1388
1403
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1389
|
-
|
|
1404
|
+
_chunkCZWAKYDRcjs.Modal,
|
|
1390
1405
|
{
|
|
1391
1406
|
isOpen,
|
|
1392
1407
|
onClose,
|
|
@@ -1444,7 +1459,7 @@ function WithdrawModalInner({
|
|
|
1444
1459
|
] }),
|
|
1445
1460
|
balanceTitle && totalBalanceUsd !== null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header-balance", children: [
|
|
1446
1461
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-label", children: balanceTitle }),
|
|
1447
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children:
|
|
1462
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _chunkCZWAKYDRcjs.currencyFormatter.format(totalBalanceUsd) })
|
|
1448
1463
|
] })
|
|
1449
1464
|
] }),
|
|
1450
1465
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -1488,13 +1503,14 @@ function WithdrawModalInner({
|
|
|
1488
1503
|
recipient,
|
|
1489
1504
|
amount: defaultAmount,
|
|
1490
1505
|
service,
|
|
1506
|
+
rhinestoneApiKey,
|
|
1491
1507
|
signerAddress,
|
|
1492
1508
|
sessionChainIds,
|
|
1493
1509
|
forceRegister,
|
|
1494
1510
|
waitForFinalTx,
|
|
1495
1511
|
reownWallet,
|
|
1496
1512
|
onConnect,
|
|
1497
|
-
|
|
1513
|
+
onSignTransaction,
|
|
1498
1514
|
onRequestConnect,
|
|
1499
1515
|
connectButtonLabel,
|
|
1500
1516
|
onStepChange: handleStepChange,
|