@rhinestone/deposit-modal 0.1.26 → 0.1.27

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.
@@ -7,10 +7,9 @@ import {
7
7
  Spinner,
8
8
  accountFromPrivateKey,
9
9
  applyTheme,
10
+ buildSessionDetails,
10
11
  createDepositService,
11
12
  createSessionOwnerKey,
12
- createSmartAccount,
13
- createViewOnlyAccount,
14
13
  currencyFormatter,
15
14
  formatUserError,
16
15
  getAssetId,
@@ -21,11 +20,9 @@ import {
21
20
  loadSessionOwnerFromStorage,
22
21
  portfolioToAssets,
23
22
  saveSessionOwnerToStorage,
24
- signSessionDetails,
25
23
  tokenFormatter
26
- } from "./chunk-3FK5FAUL.mjs";
24
+ } from "./chunk-YOFGP4FV.mjs";
27
25
  import {
28
- CHAIN_BY_ID,
29
26
  DEFAULT_BACKEND_URL,
30
27
  DEFAULT_SIGNER_ADDRESS,
31
28
  NATIVE_TOKEN_ADDRESS,
@@ -57,7 +54,6 @@ import { useState as useState7, useCallback as useCallback3, useMemo as useMemo6
57
54
 
58
55
  // src/components/steps/SetupStep.tsx
59
56
  import { useState, useEffect, useRef, useCallback } from "react";
60
- import { walletClientToAccount } from "@rhinestone/sdk";
61
57
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
62
58
  async function resolveSessionOwner(eoaAddress) {
63
59
  const localOwner = loadSessionOwnerFromStorage(eoaAddress);
@@ -78,9 +74,7 @@ function SetupStep({
78
74
  walletClient,
79
75
  address,
80
76
  targetChain,
81
- targetChainObj,
82
77
  targetToken,
83
- rhinestoneApiKey,
84
78
  signerAddress,
85
79
  sessionChainIds,
86
80
  recipient,
@@ -93,7 +87,7 @@ function SetupStep({
93
87
  const [state, setState] = useState({ type: "idle" });
94
88
  const setupInitiatedRef = useRef(false);
95
89
  const runSetup = useCallback(async () => {
96
- if (!address || !targetChainObj) {
90
+ if (!address) {
97
91
  return;
98
92
  }
99
93
  if (walletClient && !walletClient.account) {
@@ -102,15 +96,8 @@ function SetupStep({
102
96
  try {
103
97
  setState({ type: "creating-account" });
104
98
  const sessionOwner = await resolveSessionOwner(address);
105
- const prepared = await service.prepareAccount({
106
- ownerAddress: address,
107
- sessionOwnerAddress: sessionOwner.address,
108
- targetChain,
109
- targetToken,
110
- signerAddress,
111
- sessionChainIds
112
- });
113
- const smartAccount = prepared.smartAccount;
99
+ const computed = await service.computeAddress(address, sessionOwner.address);
100
+ const smartAccount = computed.smartAccount;
114
101
  setState({ type: "checking" });
115
102
  const checkResult = await service.checkAccount(smartAccount);
116
103
  if (checkResult.isRegistered && !forceRegister) {
@@ -123,16 +110,27 @@ function SetupStep({
123
110
  }
124
111
  }
125
112
  setState({ type: "signing-session" });
126
- const signerAccount = walletClient ? walletClientToAccount(walletClient) : createViewOnlyAccount(address);
127
- const account = await createSmartAccount(
128
- signerAccount,
129
- sessionOwner.account,
130
- rhinestoneApiKey
131
- );
132
- const sessionDetails = await signSessionDetails(
133
- account,
113
+ const prepared = await service.prepareAccount({
114
+ ownerAddress: address,
115
+ sessionOwnerAddress: sessionOwner.address,
116
+ targetChain,
117
+ targetToken,
118
+ signerAddress,
119
+ sessionChainIds
120
+ });
121
+ if (!sessionOwner.account.signTypedData) {
122
+ throw new Error("Session owner account does not support signTypedData");
123
+ }
124
+ const typedData = prepared.sessionDetailsUnsigned.data;
125
+ const signature = await sessionOwner.account.signTypedData({
126
+ domain: typedData.domain,
127
+ types: typedData.types,
128
+ primaryType: typedData.primaryType,
129
+ message: typedData.message
130
+ });
131
+ const sessionDetails = buildSessionDetails(
134
132
  prepared.sessionDetailsUnsigned,
135
- sessionOwner.account
133
+ signature
136
134
  );
137
135
  setState({ type: "registering" });
138
136
  await service.registerAccount({
@@ -161,10 +159,8 @@ function SetupStep({
161
159
  }, [
162
160
  address,
163
161
  walletClient,
164
- targetChainObj,
165
162
  targetChain,
166
163
  targetToken,
167
- rhinestoneApiKey,
168
164
  signerAddress,
169
165
  sessionChainIds,
170
166
  recipient,
@@ -176,11 +172,11 @@ function SetupStep({
176
172
  ]);
177
173
  useEffect(() => {
178
174
  const hasWallet = walletClient ? Boolean(walletClient.account) : true;
179
- if (address && hasWallet && targetChainObj && !setupInitiatedRef.current && state.type === "idle") {
175
+ if (address && hasWallet && !setupInitiatedRef.current && state.type === "idle") {
180
176
  setupInitiatedRef.current = true;
181
177
  runSetup();
182
178
  }
183
- }, [address, walletClient, targetChainObj, state.type, runSetup]);
179
+ }, [address, walletClient, state.type, runSetup]);
184
180
  const handleRetry = () => {
185
181
  setupInitiatedRef.current = false;
186
182
  setState({ type: "idle" });
@@ -1652,7 +1648,6 @@ function DepositFlow({
1652
1648
  sourceToken: defaultSourceToken,
1653
1649
  amount: defaultAmount,
1654
1650
  recipient,
1655
- rhinestoneApiKey,
1656
1651
  signerAddress = DEFAULT_SIGNER_ADDRESS,
1657
1652
  sessionChainIds,
1658
1653
  forceRegister = false,
@@ -1677,7 +1672,6 @@ function DepositFlow({
1677
1672
  const [totalBalanceUsd, setTotalBalanceUsd] = useState7(0);
1678
1673
  const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = useState7(false);
1679
1674
  const [selectedConnectAddress, setSelectedConnectAddress] = useState7(null);
1680
- const targetChainObj = useMemo6(() => CHAIN_BY_ID[targetChain], [targetChain]);
1681
1675
  const dappSwitchChain = useMemo6(() => {
1682
1676
  if (!dappWalletClient?.switchChain) return void 0;
1683
1677
  return async (chainId) => {
@@ -1970,14 +1964,12 @@ function DepositFlow({
1970
1964
  if (isDepositAddressMode) {
1971
1965
  if (!dappAddress || !sessionKeyAddress) return null;
1972
1966
  return /* @__PURE__ */ jsxs7("div", { className: "rs-modal-body", children: [
1973
- step.type === "setup" && targetChainObj && /* @__PURE__ */ jsx7(
1967
+ step.type === "setup" && /* @__PURE__ */ jsx7(
1974
1968
  SetupStep,
1975
1969
  {
1976
1970
  address: sessionKeyAddress,
1977
1971
  targetChain,
1978
- targetChainObj,
1979
1972
  targetToken,
1980
- rhinestoneApiKey,
1981
1973
  signerAddress,
1982
1974
  sessionChainIds,
1983
1975
  recipient,
@@ -2032,15 +2024,13 @@ function DepositFlow({
2032
2024
  return getPublicClient(chainId);
2033
2025
  };
2034
2026
  return /* @__PURE__ */ jsxs7("div", { className: "rs-modal-body", children: [
2035
- step.type === "setup" && targetChainObj && /* @__PURE__ */ jsx7(
2027
+ step.type === "setup" && /* @__PURE__ */ jsx7(
2036
2028
  SetupStep,
2037
2029
  {
2038
2030
  walletClient: signerContext.walletClient,
2039
2031
  address: ownerAddress,
2040
2032
  targetChain,
2041
- targetChainObj,
2042
2033
  targetToken,
2043
- rhinestoneApiKey,
2044
2034
  signerAddress,
2045
2035
  sessionChainIds,
2046
2036
  recipient,
@@ -2122,7 +2112,7 @@ function DepositFlow({
2122
2112
  // src/DepositModal.tsx
2123
2113
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
2124
2114
  var ReownDepositInner = lazy(
2125
- () => import("./DepositModalReown-4WZF2HMJ.mjs").then((m) => ({ default: m.DepositModalReown }))
2115
+ () => import("./DepositModalReown-PFKTSKDS.mjs").then((m) => ({ default: m.DepositModalReown }))
2126
2116
  );
2127
2117
  function DepositModal(props) {
2128
2118
  const needsReown = !!props.reownAppId;
@@ -2146,7 +2136,6 @@ function DepositModalInner({
2146
2136
  defaultAmount,
2147
2137
  recipient,
2148
2138
  backendUrl = DEFAULT_BACKEND_URL,
2149
- rhinestoneApiKey,
2150
2139
  signerAddress = DEFAULT_SIGNER_ADDRESS,
2151
2140
  sessionChainIds,
2152
2141
  forceRegister = false,
@@ -2316,7 +2305,6 @@ function DepositModalInner({
2316
2305
  sourceToken,
2317
2306
  amount: defaultAmount,
2318
2307
  recipient,
2319
- rhinestoneApiKey,
2320
2308
  signerAddress,
2321
2309
  sessionChainIds,
2322
2310
  forceRegister,
@@ -6,23 +6,18 @@ 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-3FK5FAUL.mjs";
19
+ } from "./chunk-YOFGP4FV.mjs";
24
20
  import {
25
- CHAIN_BY_ID,
26
21
  DEFAULT_BACKEND_URL,
27
22
  DEFAULT_SIGNER_ADDRESS,
28
23
  NATIVE_TOKEN_ADDRESS,
@@ -559,9 +554,6 @@ function WithdrawFormStep({
559
554
  }
560
555
  WithdrawFormStep.displayName = "WithdrawFormStep";
561
556
 
562
- // src/WithdrawFlow.tsx
563
- import { walletClientToAccount } from "@rhinestone/sdk";
564
-
565
557
  // src/core/safe.ts
566
558
  import {
567
559
  concat,
@@ -862,7 +854,6 @@ function WithdrawFlow({
862
854
  recipient: defaultRecipient,
863
855
  amount: defaultAmount,
864
856
  service,
865
- rhinestoneApiKey,
866
857
  signerAddress = DEFAULT_SIGNER_ADDRESS,
867
858
  sessionChainIds,
868
859
  forceRegister = false,
@@ -892,7 +883,6 @@ function WithdrawFlow({
892
883
  setTargetChain(targetChainProp);
893
884
  setTargetToken(targetTokenProp);
894
885
  }, [targetChainProp, targetTokenProp]);
895
- const targetChainObj = useMemo2(() => CHAIN_BY_ID[targetChain], [targetChain]);
896
886
  const hasCustomSigner = Boolean(dappAddress && onSignTransaction);
897
887
  const dappSwitchChain = useMemo2(() => {
898
888
  if (!dappWalletClient?.switchChain) return void 0;
@@ -1031,36 +1021,46 @@ function WithdrawFlow({
1031
1021
  if (!onSignTransaction && !signerContext?.walletClient) {
1032
1022
  throw new Error("Wallet not connected");
1033
1023
  }
1034
- if (!targetChainObj) {
1035
- throw new Error("Unsupported target chain");
1036
- }
1037
1024
  setIsSubmitting(true);
1038
1025
  try {
1039
- const signerAccount = signerContext?.walletClient ? walletClientToAccount(signerContext.walletClient) : createViewOnlyAccount(ownerAddress2);
1040
1026
  const sessionOwner = await resolveSessionOwner(ownerAddress2);
1041
- const account = await createSmartAccount(
1042
- signerAccount,
1043
- sessionOwner.account,
1044
- rhinestoneApiKey
1027
+ const computed = await service.computeAddress(
1028
+ ownerAddress2,
1029
+ sessionOwner.address
1045
1030
  );
1046
- const smartAccount = getAccountAddress(account);
1031
+ const smartAccount = computed.smartAccount;
1047
1032
  const checkResult = await service.checkAccount(smartAccount);
1048
1033
  const targetMatches = checkResult.targetChain === targetChain && checkResult.targetToken?.toLowerCase() === targetToken.toLowerCase();
1049
1034
  if (!checkResult.isRegistered || forceRegister || !targetMatches) {
1050
- const initData = getAccountInitData(account);
1051
- const sessionDetails = await getSessionDetails(
1052
- account,
1053
- targetChainObj,
1054
- signerAddress,
1055
- sessionOwner.account,
1035
+ const prepared = await service.prepareAccount({
1036
+ ownerAddress: ownerAddress2,
1037
+ sessionOwnerAddress: sessionOwner.address,
1038
+ targetChain,
1056
1039
  targetToken,
1040
+ signerAddress,
1057
1041
  sessionChainIds
1042
+ });
1043
+ const typedData = prepared.sessionDetailsUnsigned.data;
1044
+ if (!sessionOwner.account.signTypedData) {
1045
+ throw new Error(
1046
+ "Session owner account does not support signTypedData"
1047
+ );
1048
+ }
1049
+ const signature = await sessionOwner.account.signTypedData({
1050
+ domain: typedData.domain,
1051
+ types: typedData.types,
1052
+ primaryType: typedData.primaryType,
1053
+ message: typedData.message
1054
+ });
1055
+ const sessionDetails = buildSessionDetails(
1056
+ prepared.sessionDetailsUnsigned,
1057
+ signature
1058
1058
  );
1059
1059
  await service.registerAccount({
1060
1060
  address: smartAccount,
1061
1061
  accountParams: {
1062
- factory: initData.factory,
1063
- factoryData: initData.factoryData,
1062
+ factory: prepared.accountParams.factory,
1063
+ factoryData: prepared.accountParams.factoryData,
1064
1064
  sessionDetails
1065
1065
  },
1066
1066
  eoaAddress: ownerAddress2,
@@ -1150,7 +1150,6 @@ function WithdrawFlow({
1150
1150
  },
1151
1151
  [
1152
1152
  signerContext,
1153
- targetChainObj,
1154
1153
  resolveSessionOwner,
1155
1154
  signerAddress,
1156
1155
  sessionChainIds,
@@ -1158,7 +1157,6 @@ function WithdrawFlow({
1158
1157
  targetChain,
1159
1158
  targetToken,
1160
1159
  service,
1161
- rhinestoneApiKey,
1162
1160
  handleConnected,
1163
1161
  asset.decimals,
1164
1162
  safeAddress,
@@ -1307,7 +1305,7 @@ function WithdrawFlow({
1307
1305
  // src/WithdrawModal.tsx
1308
1306
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1309
1307
  var ReownWithdrawInner = lazy(
1310
- () => import("./WithdrawModalReown-244RQ5FZ.mjs").then((m) => ({
1308
+ () => import("./WithdrawModalReown-6AAWH35J.mjs").then((m) => ({
1311
1309
  default: m.WithdrawModalReown
1312
1310
  }))
1313
1311
  );
@@ -1334,7 +1332,6 @@ function WithdrawModalInner({
1334
1332
  onClose,
1335
1333
  inline,
1336
1334
  backendUrl = DEFAULT_BACKEND_URL,
1337
- rhinestoneApiKey,
1338
1335
  signerAddress = DEFAULT_SIGNER_ADDRESS,
1339
1336
  sessionChainIds,
1340
1337
  forceRegister = false,
@@ -1503,7 +1500,6 @@ function WithdrawModalInner({
1503
1500
  recipient,
1504
1501
  amount: defaultAmount,
1505
1502
  service,
1506
- rhinestoneApiKey,
1507
1503
  signerAddress,
1508
1504
  sessionChainIds,
1509
1505
  forceRegister,