@rhinestone/deposit-modal 0.1.26 → 0.1.28

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.
@@ -8,8 +8,6 @@
8
8
 
9
9
 
10
10
 
11
-
12
-
13
11
  var _chunkCEIWN53Ncjs = require('./chunk-CEIWN53N.cjs');
14
12
 
15
13
  // src/components/ui/Modal.tsx
@@ -146,6 +144,71 @@ Modal.displayName = "Modal";
146
144
  function jsonReplacer(_key, value) {
147
145
  return typeof value === "bigint" ? value.toString() : value;
148
146
  }
147
+ function asRecord(value) {
148
+ return typeof value === "object" && value !== null ? value : null;
149
+ }
150
+ function toBigInt(value) {
151
+ if (typeof value === "bigint") return value;
152
+ if (typeof value === "number" && Number.isInteger(value)) return BigInt(value);
153
+ if (typeof value === "string" && value.trim() !== "") return BigInt(value);
154
+ throw new Error("Invalid bigint value");
155
+ }
156
+ function normalizeSessionTypedData(raw) {
157
+ const data = structuredClone(raw);
158
+ const domain = asRecord(data.domain);
159
+ if (domain && domain.chainId !== void 0 && domain.chainId !== null) {
160
+ domain.chainId = toBigInt(domain.chainId);
161
+ }
162
+ const message = asRecord(data.message);
163
+ if (!message || !Array.isArray(message.sessionsAndChainIds)) {
164
+ return data;
165
+ }
166
+ for (const entry of message.sessionsAndChainIds) {
167
+ const chainSession = asRecord(entry);
168
+ if (!chainSession) continue;
169
+ if (chainSession.chainId !== void 0 && chainSession.chainId !== null) {
170
+ chainSession.chainId = toBigInt(chainSession.chainId);
171
+ }
172
+ const session = asRecord(chainSession.session);
173
+ if (!session) continue;
174
+ if (session.nonce !== void 0 && session.nonce !== null) {
175
+ session.nonce = toBigInt(session.nonce);
176
+ }
177
+ if (session.expires !== void 0 && session.expires !== null) {
178
+ session.expires = toBigInt(session.expires);
179
+ }
180
+ }
181
+ return data;
182
+ }
183
+ function normalizeSetupAccountResponse(raw) {
184
+ const data = raw;
185
+ return {
186
+ smartAccount: data.smartAccount,
187
+ isRegistered: data.isRegistered,
188
+ targetChain: data.targetChain,
189
+ targetToken: data.targetToken,
190
+ needsRegistration: data.needsRegistration,
191
+ accountParams: data.accountParams,
192
+ sessionDetailsUnsigned: data.sessionDetailsUnsigned ? {
193
+ hashesAndChainIds: data.sessionDetailsUnsigned.hashesAndChainIds.map(
194
+ (h) => ({
195
+ chainId: toBigInt(h.chainId),
196
+ sessionDigest: h.sessionDigest
197
+ })
198
+ ),
199
+ data: normalizeSessionTypedData(data.sessionDetailsUnsigned.data)
200
+ } : void 0
201
+ };
202
+ }
203
+ function buildSessionDetails(unsigned, signature) {
204
+ return {
205
+ hashesAndChainIds: unsigned.hashesAndChainIds.map((h) => ({
206
+ chainId: toBigInt(h.chainId),
207
+ sessionDigest: h.sessionDigest
208
+ })),
209
+ signature
210
+ };
211
+ }
149
212
  function createDepositService(baseUrl) {
150
213
  const normalizedBaseUrl = baseUrl.replace(/\/$/, "");
151
214
  function apiUrl(path) {
@@ -153,8 +216,8 @@ function createDepositService(baseUrl) {
153
216
  return `${normalizedBaseUrl}${normalizedPath}`;
154
217
  }
155
218
  return {
156
- async prepareAccount(params) {
157
- const response = await fetch(apiUrl("/prepare-account"), {
219
+ async setupAccount(params) {
220
+ const response = await fetch(apiUrl("/setup-account"), {
158
221
  method: "POST",
159
222
  headers: { "Content-Type": "application/json" },
160
223
  body: JSON.stringify(params)
@@ -162,10 +225,10 @@ function createDepositService(baseUrl) {
162
225
  if (!response.ok) {
163
226
  const error = await response.json().catch(() => ({ error: "Unknown error" }));
164
227
  throw new Error(
165
- error.error || `Prepare account failed: ${response.status}`
228
+ error.error || `Setup account failed: ${response.status}`
166
229
  );
167
230
  }
168
- return response.json();
231
+ return normalizeSetupAccountResponse(await response.json());
169
232
  },
170
233
  async registerAccount(params) {
171
234
  const { eoaAddress, sessionOwner, ...account } = params;
@@ -189,17 +252,6 @@ function createDepositService(baseUrl) {
189
252
  }
190
253
  return response.json();
191
254
  },
192
- async checkAccount(address) {
193
- const response = await fetch(apiUrl(`/check/${address}`), {
194
- method: "GET",
195
- headers: { "Content-Type": "application/json" }
196
- });
197
- if (!response.ok) {
198
- const error = await response.json().catch(() => ({ error: "Unknown error" }));
199
- throw new Error(error.error || `Check failed: ${response.status}`);
200
- }
201
- return response.json();
202
- },
203
255
  async fetchPortfolio(address) {
204
256
  const response = await fetch(apiUrl(`/portfolio/${address}`), {
205
257
  method: "GET",
@@ -817,209 +869,12 @@ function ConnectStep({
817
869
  }
818
870
  ConnectStep.displayName = "ConnectStep";
819
871
 
820
- // src/core/account.ts
821
-
822
-
823
- var _sdk = require('@rhinestone/sdk');
824
- var _viem = require('viem');
825
- var _accounts = require('viem/accounts');
826
- function createViewOnlyAccount(address) {
827
- if (!address || address === _viem.zeroAddress) {
828
- throw new Error("Address is required");
829
- }
830
- return _accounts.toAccount.call(void 0, {
831
- address,
832
- signMessage: async () => {
833
- throw new Error("Account is view-only");
834
- },
835
- signTransaction: async () => {
836
- throw new Error("Account is view-only");
837
- },
838
- signTypedData: async () => {
839
- throw new Error("Account is view-only");
840
- }
841
- });
842
- }
843
- function getSessionSignerAccount(signerAddress) {
844
- if (!signerAddress || signerAddress === _viem.zeroAddress) {
845
- throw new Error("Signer address is required");
846
- }
847
- return _accounts.toAccount.call(void 0, {
848
- address: signerAddress,
849
- signMessage: async () => {
850
- throw new Error("Session signer is view-only");
851
- },
852
- signTransaction: async () => {
853
- throw new Error("Session signer is view-only");
854
- },
855
- signTypedData: async () => {
856
- throw new Error("Session signer is view-only");
857
- }
858
- });
859
- }
860
- function buildSession(chain, signerAddress) {
861
- const sessionSignerAccount = getSessionSignerAccount(signerAddress);
862
- return {
863
- owners: {
864
- type: "ecdsa",
865
- accounts: [sessionSignerAccount]
866
- },
867
- chain
868
- };
869
- }
870
- async function createSmartAccount(userSigner, sessionSigner, sdkApiKey) {
871
- const rhinestone = new (0, _sdk.RhinestoneSDK)({
872
- apiKey: _nullishCoalesce(sdkApiKey, () => ( ""))
873
- });
874
- const ownerAccounts = sessionSigner ? [userSigner, sessionSigner] : [userSigner];
875
- const config = {
876
- account: {
877
- type: "nexus"
878
- },
879
- owners: {
880
- type: "ecdsa",
881
- accounts: ownerAccounts,
882
- ...sessionSigner ? { threshold: 1 } : {}
883
- },
884
- experimental_sessions: {
885
- enabled: true
886
- }
887
- };
888
- const account = await rhinestone.createAccount(config);
889
- return account;
890
- }
891
- function getAccountAddress(account) {
892
- return account.getAddress();
893
- }
894
- function getAccountInitData(account) {
895
- const { factory, factoryData } = account.getInitData();
896
- if (!factory) {
897
- throw new Error("Account init data is not available");
898
- }
899
- return {
900
- factory,
901
- factoryData
902
- };
903
- }
904
- async function signEnableSessionWithOwner(rhinestoneAccount, sessionDetails, signer) {
905
- const originalOwners = rhinestoneAccount.config.owners;
906
- rhinestoneAccount.config.owners = {
907
- type: "ecdsa",
908
- accounts: [signer],
909
- threshold: 1,
910
- ..._optionalChain([originalOwners, 'optionalAccess', _41 => _41.type]) === "ecdsa" && originalOwners.module ? { module: originalOwners.module } : {}
911
- };
912
- try {
913
- return await rhinestoneAccount.experimental_signEnableSession(
914
- sessionDetails
915
- );
916
- } finally {
917
- rhinestoneAccount.config.owners = originalOwners;
918
- }
919
- }
920
- async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner, targetToken, sessionChainIds) {
921
- const isTargetTestnet = Boolean(targetChain.testnet);
922
- const chainsByNetworkType = _chunkCEIWN53Ncjs.SUPPORTED_CHAINS.filter(
923
- (chain) => Boolean(chain.testnet) === isTargetTestnet
924
- );
925
- const chainsById = new Map(
926
- chainsByNetworkType.map((chain) => [chain.id, chain])
927
- );
928
- let selectedChains = [...chainsByNetworkType];
929
- if (sessionChainIds && sessionChainIds.length > 0) {
930
- const selectedByCaller = [];
931
- for (const chainId of sessionChainIds) {
932
- const chain = chainsById.get(chainId);
933
- if (chain) {
934
- selectedByCaller.push(chain);
935
- }
936
- }
937
- if (selectedByCaller.length > 0) {
938
- selectedChains = selectedByCaller;
939
- }
940
- }
941
- if (targetToken) {
942
- const targetSymbol = _chunkCEIWN53Ncjs.getTokenSymbol.call(void 0,
943
- targetToken,
944
- targetChain.id
945
- ).toUpperCase();
946
- if (targetSymbol && targetSymbol !== "TOKEN") {
947
- const chainsForToken = selectedChains.filter(
948
- (chain) => _chunkCEIWN53Ncjs.getSupportedTokenSymbolsForChain.call(void 0, chain.id).includes(targetSymbol)
949
- );
950
- if (chainsForToken.length > 0) {
951
- selectedChains = chainsForToken;
952
- }
953
- }
954
- }
955
- if (!selectedChains.some((c) => c.id === targetChain.id)) {
956
- selectedChains.push(targetChain);
957
- }
958
- const uniqueChains = Array.from(
959
- new Map(selectedChains.map((chain) => [chain.id, chain])).values()
960
- );
961
- const sessions = uniqueChains.map(
962
- (chain) => buildSession(chain, signerAddress)
963
- );
964
- const sessionDetails = await rhinestoneAccount.experimental_getSessionDetails(sessions);
965
- const enableSignature = sessionSigner ? await signEnableSessionWithOwner(
966
- rhinestoneAccount,
967
- sessionDetails,
968
- sessionSigner
969
- ) : await rhinestoneAccount.experimental_signEnableSession(sessionDetails);
970
- if (!_optionalChain([sessionDetails, 'access', _42 => _42.hashesAndChainIds, 'optionalAccess', _43 => _43.length])) {
971
- throw new Error("Session details missing chain digests");
972
- }
973
- return {
974
- hashesAndChainIds: sessionDetails.hashesAndChainIds,
975
- signature: enableSignature
976
- };
977
- }
978
- function deserializeSessionData(raw) {
979
- const data = structuredClone(raw);
980
- const message = data.message;
981
- if (!_optionalChain([message, 'optionalAccess', _44 => _44.sessionsAndChainIds])) return data;
982
- for (const entry of message.sessionsAndChainIds) {
983
- const chainSession = entry;
984
- chainSession.chainId = BigInt(chainSession.chainId);
985
- const session = chainSession.session;
986
- if (session) {
987
- session.nonce = BigInt(session.nonce);
988
- session.expires = BigInt(session.expires);
989
- }
990
- }
991
- return data;
992
- }
993
- async function signSessionDetails(rhinestoneAccount, sessionDetailsUnsigned, signer) {
994
- const data = deserializeSessionData(sessionDetailsUnsigned.data);
995
- const hashesAndChainIds = sessionDetailsUnsigned.hashesAndChainIds.map(
996
- (h) => ({
997
- chainId: BigInt(h.chainId),
998
- sessionDigest: h.sessionDigest
999
- })
1000
- );
1001
- const sessionDetails = {
1002
- nonces: [],
1003
- hashesAndChainIds,
1004
- data
1005
- };
1006
- const signature = await signEnableSessionWithOwner(
1007
- rhinestoneAccount,
1008
- sessionDetails,
1009
- signer
1010
- );
1011
- return {
1012
- hashesAndChainIds,
1013
- signature
1014
- };
1015
- }
1016
-
1017
872
  // src/core/session-owner.ts
873
+ var _viem = require('viem');
1018
874
 
1019
875
 
1020
876
 
1021
-
1022
-
877
+ var _accounts = require('viem/accounts');
1023
878
  var STORAGE_PREFIX = "rhinestone:session-owner";
1024
879
  function storageKey(eoaAddress) {
1025
880
  return `${STORAGE_PREFIX}:${eoaAddress.toLowerCase()}`;
@@ -1112,22 +967,22 @@ function asString(value) {
1112
967
  return typeof value === "string" ? value : void 0;
1113
968
  }
1114
969
  function getEventTxHash(event) {
1115
- if (!_optionalChain([event, 'optionalAccess', _45 => _45.type])) return void 0;
970
+ if (!_optionalChain([event, 'optionalAccess', _41 => _41.type])) return void 0;
1116
971
  if (event.type === "deposit-received") {
1117
- return asString(_optionalChain([event, 'access', _46 => _46.data, 'optionalAccess', _47 => _47.transactionHash]));
972
+ return asString(_optionalChain([event, 'access', _42 => _42.data, 'optionalAccess', _43 => _43.transactionHash]));
1118
973
  }
1119
974
  if (event.type === "bridge-started" || event.type === "bridge-complete") {
1120
- const deposit = isRecord(_optionalChain([event, 'access', _48 => _48.data, 'optionalAccess', _49 => _49.deposit])) ? event.data.deposit : void 0;
1121
- return asString(_optionalChain([deposit, 'optionalAccess', _50 => _50.transactionHash]));
975
+ const deposit = isRecord(_optionalChain([event, 'access', _44 => _44.data, 'optionalAccess', _45 => _45.deposit])) ? event.data.deposit : void 0;
976
+ return asString(_optionalChain([deposit, 'optionalAccess', _46 => _46.transactionHash]));
1122
977
  }
1123
978
  if (event.type === "bridge-failed" || event.type === "error") {
1124
- const deposit = isRecord(_optionalChain([event, 'access', _51 => _51.data, 'optionalAccess', _52 => _52.deposit])) ? event.data.deposit : void 0;
1125
- return asString(_optionalChain([deposit, 'optionalAccess', _53 => _53.transactionHash]));
979
+ const deposit = isRecord(_optionalChain([event, 'access', _47 => _47.data, 'optionalAccess', _48 => _48.deposit])) ? event.data.deposit : void 0;
980
+ return asString(_optionalChain([deposit, 'optionalAccess', _49 => _49.transactionHash]));
1126
981
  }
1127
982
  return void 0;
1128
983
  }
1129
984
  function isDepositEvent(event) {
1130
- return _optionalChain([event, 'optionalAccess', _54 => _54.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _55 => _55.type]) === "bridge-started";
985
+ return _optionalChain([event, 'optionalAccess', _50 => _50.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _51 => _51.type]) === "bridge-started";
1131
986
  }
1132
987
 
1133
988
  // src/components/steps/ProcessingStep.tsx
@@ -1142,7 +997,7 @@ function isEventForTx(event, txHash) {
1142
997
  return eventTxHash.toLowerCase() === txHash.toLowerCase();
1143
998
  }
1144
999
  function formatBridgeFailedMessage(event) {
1145
- const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _56 => _56.data]), () => ( {}));
1000
+ const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _52 => _52.data]), () => ( {}));
1146
1001
  const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
1147
1002
  const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
1148
1003
  if (backendMessage.length > 0) {
@@ -1183,7 +1038,7 @@ function ProcessingStep({
1183
1038
  const intervalRef = _react.useRef.call(void 0, null);
1184
1039
  _react.useEffect.call(void 0, () => {
1185
1040
  if (directTransfer) {
1186
- _optionalChain([onDepositComplete, 'optionalCall', _57 => _57(txHash)]);
1041
+ _optionalChain([onDepositComplete, 'optionalCall', _53 => _53(txHash)]);
1187
1042
  return;
1188
1043
  }
1189
1044
  }, [directTransfer, txHash, onDepositComplete]);
@@ -1226,40 +1081,40 @@ function ProcessingStep({
1226
1081
  console.log("[deposit-modal] status poll", {
1227
1082
  type: lastEvent2.type,
1228
1083
  matchesTx: eventMatchesTx,
1229
- intentId: _optionalChain([eventData, 'optionalAccess', _58 => _58.intentId]),
1084
+ intentId: _optionalChain([eventData, 'optionalAccess', _54 => _54.intentId]),
1230
1085
  data: eventData
1231
1086
  });
1232
1087
  }
1233
1088
  if (!isMounted) return;
1234
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _59 => _59.type]) === "bridge-complete") {
1089
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _55 => _55.type]) === "bridge-complete") {
1235
1090
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1236
- const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _60 => _60.data, 'optionalAccess', _61 => _61.destination, 'optionalAccess', _62 => _62.transactionHash]);
1237
- _optionalChain([onDepositComplete, 'optionalCall', _63 => _63(txHash, destinationTxHash2)]);
1091
+ const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _56 => _56.data, 'optionalAccess', _57 => _57.destination, 'optionalAccess', _58 => _58.transactionHash]);
1092
+ _optionalChain([onDepositComplete, 'optionalCall', _59 => _59(txHash, destinationTxHash2)]);
1238
1093
  return;
1239
1094
  }
1240
- if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _64 => _64.type]) === "bridge-started") {
1095
+ if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _60 => _60.type]) === "bridge-started") {
1241
1096
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1242
- _optionalChain([onDepositComplete, 'optionalCall', _65 => _65(txHash)]);
1097
+ _optionalChain([onDepositComplete, 'optionalCall', _61 => _61(txHash)]);
1243
1098
  return;
1244
1099
  }
1245
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _66 => _66.type]) === "bridge-failed") {
1100
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _62 => _62.type]) === "bridge-failed") {
1246
1101
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
1247
1102
  setState({
1248
1103
  type: "failed",
1249
1104
  message: formatted.message,
1250
1105
  lastEvent: eventForCurrentTx
1251
1106
  });
1252
- _optionalChain([onDepositFailed, 'optionalCall', _67 => _67(txHash, formatted.message)]);
1107
+ _optionalChain([onDepositFailed, 'optionalCall', _63 => _63(txHash, formatted.message)]);
1253
1108
  return;
1254
1109
  }
1255
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _68 => _68.type]) === "error") {
1256
- const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _69 => _69.data, 'optionalAccess', _70 => _70.message]), () => ( "Unknown error"));
1110
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _64 => _64.type]) === "error") {
1111
+ const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _65 => _65.data, 'optionalAccess', _66 => _66.message]), () => ( "Unknown error"));
1257
1112
  setState({
1258
1113
  type: "failed",
1259
1114
  message: errorMessage,
1260
1115
  lastEvent: eventForCurrentTx
1261
1116
  });
1262
- _optionalChain([onDepositFailed, 'optionalCall', _71 => _71(txHash, errorMessage)]);
1117
+ _optionalChain([onDepositFailed, 'optionalCall', _67 => _67(txHash, errorMessage)]);
1263
1118
  return;
1264
1119
  }
1265
1120
  setState({ type: "processing", lastEvent: eventForCurrentTx });
@@ -1307,7 +1162,7 @@ function ProcessingStep({
1307
1162
  processTimeoutRef.current = setTimeout(() => {
1308
1163
  const message = "We couldn't confirm your transfer. Please contact support if funds do not arrive.";
1309
1164
  setState({ type: "error", message });
1310
- _optionalChain([onError, 'optionalCall', _72 => _72(message, "PROCESS_TIMEOUT")]);
1165
+ _optionalChain([onError, 'optionalCall', _68 => _68(message, "PROCESS_TIMEOUT")]);
1311
1166
  }, PROCESS_TIMEOUT_MS);
1312
1167
  return () => {
1313
1168
  if (processTimeoutRef.current) {
@@ -1320,10 +1175,10 @@ function ProcessingStep({
1320
1175
  const isComplete = state.type === "complete";
1321
1176
  const isProcessing = state.type === "processing";
1322
1177
  const lastEvent = state.type === "processing" || state.type === "complete" || state.type === "failed" ? state.lastEvent : void 0;
1323
- const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _73 => _73.type]) === "bridge-started";
1178
+ const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _69 => _69.type]) === "bridge-started";
1324
1179
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
1325
1180
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
1326
- const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _74 => _74.data, 'optionalAccess', _75 => _75.destination, 'optionalAccess', _76 => _76.transactionHash]) || null;
1181
+ const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _70 => _70.data, 'optionalAccess', _71 => _71.destination, 'optionalAccess', _72 => _72.transactionHash]) || null;
1327
1182
  const sourceExplorerUrl = _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, sourceChain, txHash);
1328
1183
  const destExplorerUrl = destinationTxHash ? _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
1329
1184
  const truncateHash = (hash) => `${hash.slice(0, 10)}...${hash.slice(-8)}`;
@@ -1556,7 +1411,7 @@ function ProcessingStep({
1556
1411
  {
1557
1412
  className: `rs-step-description ${isError ? "rs-text-error" : "rs-text-secondary"}`,
1558
1413
  children: [
1559
- state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess', _77 => _77.type]) === "deposit-received" ? "Transfer received. Preparing bridge..." : _optionalChain([lastEvent, 'optionalAccess', _78 => _78.type]) === "bridge-started" ? "Transfer confirmed. Funds arriving shortly..." : `Bridging your ${flowNoun} to ${_chunkCEIWN53Ncjs.getChainName.call(void 0, targetChain)}.`),
1414
+ state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess', _73 => _73.type]) === "deposit-received" ? "Transfer received. Preparing bridge..." : _optionalChain([lastEvent, 'optionalAccess', _74 => _74.type]) === "bridge-started" ? "Transfer confirmed. Funds arriving shortly..." : `Bridging your ${flowNoun} to ${_chunkCEIWN53Ncjs.getChainName.call(void 0, targetChain)}.`),
1560
1415
  state.type === "failed" && state.message,
1561
1416
  state.type === "error" && state.message
1562
1417
  ]
@@ -1727,9 +1582,4 @@ function getPublicClient(chainId) {
1727
1582
 
1728
1583
 
1729
1584
 
1730
-
1731
-
1732
-
1733
-
1734
-
1735
- exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.createViewOnlyAccount = createViewOnlyAccount; exports.createSmartAccount = createSmartAccount; exports.getAccountAddress = getAccountAddress; exports.getAccountInitData = getAccountInitData; exports.getSessionDetails = getSessionDetails; exports.signSessionDetails = signSessionDetails; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.PoweredBy = PoweredBy; exports.createDepositService = createDepositService; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
1585
+ exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.PoweredBy = PoweredBy; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
@@ -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-RQSAANC3.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,41 @@ 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
1045
- );
1046
- const smartAccount = getAccountAddress(account);
1047
- const checkResult = await service.checkAccount(smartAccount);
1048
- const targetMatches = checkResult.targetChain === targetChain && checkResult.targetToken?.toLowerCase() === targetToken.toLowerCase();
1049
- if (!checkResult.isRegistered || forceRegister || !targetMatches) {
1050
- const initData = getAccountInitData(account);
1051
- const sessionDetails = await getSessionDetails(
1052
- account,
1053
- targetChainObj,
1054
- signerAddress,
1055
- sessionOwner.account,
1056
- targetToken,
1057
- sessionChainIds
1058
- );
1027
+ const setup = await service.setupAccount({
1028
+ ownerAddress: ownerAddress2,
1029
+ sessionOwnerAddress: sessionOwner.address,
1030
+ targetChain,
1031
+ targetToken,
1032
+ signerAddress,
1033
+ sessionChainIds,
1034
+ forceRegister
1035
+ });
1036
+ const smartAccount = setup.smartAccount;
1037
+ if (setup.needsRegistration) {
1038
+ if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
1039
+ throw new Error("Missing registration payload from setup-account");
1040
+ }
1041
+ const typedData = setup.sessionDetailsUnsigned.data;
1042
+ if (!sessionOwner.account.signTypedData) {
1043
+ throw new Error(
1044
+ "Session owner account does not support signTypedData"
1045
+ );
1046
+ }
1047
+ const signature = await sessionOwner.account.signTypedData({
1048
+ domain: typedData.domain,
1049
+ types: typedData.types,
1050
+ primaryType: typedData.primaryType,
1051
+ message: typedData.message
1052
+ });
1053
+ const sessionDetails = buildSessionDetails(setup.sessionDetailsUnsigned, signature);
1059
1054
  await service.registerAccount({
1060
1055
  address: smartAccount,
1061
1056
  accountParams: {
1062
- factory: initData.factory,
1063
- factoryData: initData.factoryData,
1057
+ factory: setup.accountParams.factory,
1058
+ factoryData: setup.accountParams.factoryData,
1064
1059
  sessionDetails
1065
1060
  },
1066
1061
  eoaAddress: ownerAddress2,
@@ -1150,7 +1145,6 @@ function WithdrawFlow({
1150
1145
  },
1151
1146
  [
1152
1147
  signerContext,
1153
- targetChainObj,
1154
1148
  resolveSessionOwner,
1155
1149
  signerAddress,
1156
1150
  sessionChainIds,
@@ -1158,7 +1152,6 @@ function WithdrawFlow({
1158
1152
  targetChain,
1159
1153
  targetToken,
1160
1154
  service,
1161
- rhinestoneApiKey,
1162
1155
  handleConnected,
1163
1156
  asset.decimals,
1164
1157
  safeAddress,
@@ -1307,7 +1300,7 @@ function WithdrawFlow({
1307
1300
  // src/WithdrawModal.tsx
1308
1301
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1309
1302
  var ReownWithdrawInner = lazy(
1310
- () => import("./WithdrawModalReown-244RQ5FZ.mjs").then((m) => ({
1303
+ () => import("./WithdrawModalReown-LIYQG2BW.mjs").then((m) => ({
1311
1304
  default: m.WithdrawModalReown
1312
1305
  }))
1313
1306
  );
@@ -1334,7 +1327,6 @@ function WithdrawModalInner({
1334
1327
  onClose,
1335
1328
  inline,
1336
1329
  backendUrl = DEFAULT_BACKEND_URL,
1337
- rhinestoneApiKey,
1338
1330
  signerAddress = DEFAULT_SIGNER_ADDRESS,
1339
1331
  sessionChainIds,
1340
1332
  forceRegister = false,
@@ -1503,7 +1495,6 @@ function WithdrawModalInner({
1503
1495
  recipient,
1504
1496
  amount: defaultAmount,
1505
1497
  service,
1506
- rhinestoneApiKey,
1507
1498
  signerAddress,
1508
1499
  sessionChainIds,
1509
1500
  forceRegister,