@rhinestone/deposit-modal 0.1.23 → 0.1.24

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 CHANGED
@@ -15,10 +15,14 @@ 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";
18
19
  import { executeSafeEthTransfer } from "@rhinestone/deposit-modal/safe";
19
20
  import { getChainName } from "@rhinestone/deposit-modal/constants";
20
21
  ```
21
22
 
23
+ If you use `reownAppId`, import modal components from
24
+ `@rhinestone/deposit-modal/reown`.
25
+
22
26
  ## DepositModal
23
27
 
24
28
  Deposits tokens from any supported chain into a target chain/token via a Rhinestone smart account.
@@ -88,7 +92,7 @@ Notes:
88
92
  | `defaultAmount` | `string` | No | Pre-filled amount |
89
93
  | `recipient` | `Address` | No | Custom recipient address |
90
94
  | `backendUrl` | `string` | No | Backend URL |
91
- | `rhinestoneApiKey` | `string` | No | Optional SDK api key forwarded to `RhinestoneSDK` during smart-account setup |
95
+ | `rhinestoneApiKey` | `string` | No | Deprecated in client flow (server-side account preparation now owns SDK access) |
92
96
  | `signerAddress` | `Address` | No | Session signer address |
93
97
  | `waitForFinalTx` | `boolean` | No | Wait for destination tx (default: true) |
94
98
  | `onRequestConnect` | `() => void` | No | Called when wallet connection needed |
@@ -6,21 +6,17 @@ import {
6
6
  ProcessingStep,
7
7
  accountFromPrivateKey,
8
8
  applyTheme,
9
+ buildSessionDetails,
9
10
  createDepositService,
10
11
  createSessionOwnerKey,
11
- createSmartAccount,
12
- createViewOnlyAccount,
13
12
  currencyFormatter,
14
13
  formatUserError,
15
- getAccountAddress,
16
- getAccountInitData,
17
14
  getAssetId,
18
15
  getPublicClient,
19
- getSessionDetails,
20
16
  isNativeAsset,
21
17
  loadSessionOwnerFromStorage,
22
18
  saveSessionOwnerToStorage
23
- } from "./chunk-JBT2ZV3Q.mjs";
19
+ } from "./chunk-P7SQQAAF.mjs";
24
20
  import {
25
21
  CHAIN_BY_ID,
26
22
  DEFAULT_BACKEND_URL,
@@ -42,9 +38,7 @@ import {
42
38
  useEffect as useEffect3,
43
39
  useMemo as useMemo3,
44
40
  useRef as useRef2,
45
- useState as useState3,
46
- lazy,
47
- Suspense
41
+ useState as useState3
48
42
  } from "react";
49
43
 
50
44
  // src/WithdrawFlow.tsx
@@ -559,9 +553,6 @@ function WithdrawFormStep({
559
553
  }
560
554
  WithdrawFormStep.displayName = "WithdrawFormStep";
561
555
 
562
- // src/WithdrawFlow.tsx
563
- import { walletClientToAccount } from "@rhinestone/sdk";
564
-
565
556
  // src/core/safe.ts
566
557
  import {
567
558
  concat,
@@ -862,7 +853,6 @@ function WithdrawFlow({
862
853
  recipient: defaultRecipient,
863
854
  amount: defaultAmount,
864
855
  service,
865
- rhinestoneApiKey,
866
856
  signerAddress = DEFAULT_SIGNER_ADDRESS,
867
857
  sessionChainIds,
868
858
  forceRegister = false,
@@ -1022,6 +1012,16 @@ function WithdrawFlow({
1022
1012
  address: created.address
1023
1013
  };
1024
1014
  }, []);
1015
+ const signSessionDetails = useCallback2(
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 = useCallback2(
1026
1026
  async (recipient, amountValue) => {
1027
1027
  const ownerAddress2 = signerContext?.ownerAddress;
@@ -1036,31 +1036,32 @@ function WithdrawFlow({
1036
1036
  }
1037
1037
  setIsSubmitting(true);
1038
1038
  try {
1039
- const signerAccount = signerContext?.walletClient ? walletClientToAccount(signerContext.walletClient) : createViewOnlyAccount(ownerAddress2);
1040
1039
  const sessionOwner = await resolveSessionOwner(ownerAddress2);
1041
- const account = await createSmartAccount(
1042
- signerAccount,
1043
- sessionOwner.account,
1044
- rhinestoneApiKey
1045
- );
1046
- const smartAccount = getAccountAddress(account);
1040
+ const prepared = await service.prepareAccount({
1041
+ ownerAddress: ownerAddress2,
1042
+ sessionOwnerAddress: sessionOwner.address,
1043
+ targetChain,
1044
+ targetToken,
1045
+ signerAddress,
1046
+ sessionChainIds
1047
+ });
1048
+ const smartAccount = prepared.smartAccount;
1047
1049
  const checkResult = await service.checkAccount(smartAccount);
1048
1050
  const targetMatches = checkResult.targetChain === targetChain && checkResult.targetToken?.toLowerCase() === targetToken.toLowerCase();
1049
1051
  if (!checkResult.isRegistered || forceRegister || !targetMatches) {
1050
- const initData = getAccountInitData(account);
1051
- const sessionDetails = await getSessionDetails(
1052
- account,
1053
- targetChainObj,
1054
- signerAddress,
1052
+ const signature = await signSessionDetails(
1055
1053
  sessionOwner.account,
1056
- targetToken,
1057
- sessionChainIds
1054
+ prepared.sessionDetailsUnsigned.data
1055
+ );
1056
+ const sessionDetails = buildSessionDetails(
1057
+ prepared.sessionDetailsUnsigned,
1058
+ signature
1058
1059
  );
1059
1060
  await service.registerAccount({
1060
1061
  address: smartAccount,
1061
1062
  accountParams: {
1062
- factory: initData.factory,
1063
- factoryData: initData.factoryData,
1063
+ factory: prepared.accountParams.factory,
1064
+ factoryData: prepared.accountParams.factoryData,
1064
1065
  sessionDetails
1065
1066
  },
1066
1067
  eoaAddress: ownerAddress2,
@@ -1147,7 +1148,6 @@ function WithdrawFlow({
1147
1148
  targetChain,
1148
1149
  targetToken,
1149
1150
  service,
1150
- rhinestoneApiKey,
1151
1151
  handleConnected,
1152
1152
  asset.decimals,
1153
1153
  safeAddress,
@@ -1156,7 +1156,8 @@ function WithdrawFlow({
1156
1156
  onWithdrawSubmitted,
1157
1157
  onRelayTransaction,
1158
1158
  isSourceNative,
1159
- handleError
1159
+ handleError,
1160
+ signSessionDetails
1160
1161
  ]
1161
1162
  );
1162
1163
  const handleWithdrawComplete = useCallback2(
@@ -1295,15 +1296,11 @@ function WithdrawFlow({
1295
1296
 
1296
1297
  // src/WithdrawModal.tsx
1297
1298
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1298
- var ReownWithdrawInner = lazy(
1299
- () => import("./WithdrawModalReown-ICP3DH6Q.mjs").then((m) => ({
1300
- default: m.WithdrawModalReown
1301
- }))
1302
- );
1303
1299
  function WithdrawModal(props) {
1304
- const needsReown = !!props.reownAppId;
1305
- if (needsReown) {
1306
- return /* @__PURE__ */ jsx3(Suspense, { fallback: null, children: /* @__PURE__ */ jsx3(ReownWithdrawInner, { ...props }) });
1300
+ if (props.reownAppId) {
1301
+ throw new Error(
1302
+ 'Reown support moved to "@rhinestone/deposit-modal/reown". Use that entrypoint when passing reownAppId.'
1303
+ );
1307
1304
  }
1308
1305
  return /* @__PURE__ */ jsx3(WithdrawModalInner, { ...props });
1309
1306
  }
@@ -1323,7 +1320,6 @@ function WithdrawModalInner({
1323
1320
  onClose,
1324
1321
  inline,
1325
1322
  backendUrl = DEFAULT_BACKEND_URL,
1326
- rhinestoneApiKey,
1327
1323
  signerAddress = DEFAULT_SIGNER_ADDRESS,
1328
1324
  sessionChainIds,
1329
1325
  forceRegister = false,
@@ -1492,7 +1488,6 @@ function WithdrawModalInner({
1492
1488
  recipient,
1493
1489
  amount: defaultAmount,
1494
1490
  service,
1495
- rhinestoneApiKey,
1496
1491
  signerAddress,
1497
1492
  sessionChainIds,
1498
1493
  forceRegister,