@rhinestone/deposit-modal 0.1.40 → 0.1.41
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/dist/{DepositModalReown-ZZKRN6J3.cjs → DepositModalReown-GAQLILGK.cjs} +17 -8
- package/dist/{DepositModalReown-3HNOCOOO.mjs → DepositModalReown-WS6WNWJP.mjs} +15 -6
- package/dist/{WithdrawModalReown-XXCOZYVU.mjs → WithdrawModalReown-7CSCY55U.mjs} +4 -4
- package/dist/{WithdrawModalReown-2CWNDVJD.cjs → WithdrawModalReown-GCOVYZN2.cjs} +7 -7
- package/dist/{chunk-K7BHCDJQ.cjs → chunk-37CTMJMO.cjs} +181 -96
- package/dist/{chunk-F5S6RHUI.mjs → chunk-6PRJUXTM.mjs} +1488 -301
- package/dist/{chunk-CFLZYWX7.mjs → chunk-KWAFKVV6.mjs} +120 -35
- package/dist/{chunk-AHOFT42H.cjs → chunk-LT3QKJI2.cjs} +458 -115
- package/dist/{chunk-SJEIKMVO.mjs → chunk-MBOH6XW3.mjs} +26 -13
- package/dist/{chunk-FLXTBFMZ.cjs → chunk-NELAYNA3.cjs} +11 -0
- package/dist/{chunk-3O37UPSC.cjs → chunk-PTSYSG4U.cjs} +1552 -365
- package/dist/{chunk-V7I5T4SW.cjs → chunk-PWPW7GFB.cjs} +25 -12
- package/dist/{chunk-IC2M2DZ7.mjs → chunk-QIK6ONMQ.mjs} +392 -49
- package/dist/{chunk-I7RYTI4G.mjs → chunk-ZJQZEIHA.mjs} +11 -0
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +6 -6
- package/dist/constants.d.ts +6 -6
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +4 -4
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +3 -3
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/reown.cjs +5 -5
- package/dist/reown.d.cts +1 -1
- package/dist/reown.d.ts +1 -1
- package/dist/reown.mjs +4 -4
- package/dist/styles.css +64 -0
- package/dist/{types-CIaQPR6F.d.cts → types-CybmMKTE.d.cts} +9 -7
- package/dist/{types-Bp2n2RQ3.d.ts → types-e8CHSm2u.d.ts} +9 -7
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +3 -3
- package/package.json +18 -1
|
@@ -11,13 +11,16 @@ import {
|
|
|
11
11
|
createDepositService,
|
|
12
12
|
createSessionOwnerKey,
|
|
13
13
|
currencyFormatter,
|
|
14
|
+
debugError,
|
|
15
|
+
debugLog,
|
|
14
16
|
formatUserError,
|
|
15
17
|
getAssetId,
|
|
16
18
|
getPublicClient,
|
|
17
19
|
isNativeAsset,
|
|
18
20
|
loadSessionOwnerFromStorage,
|
|
19
|
-
saveSessionOwnerToStorage
|
|
20
|
-
|
|
21
|
+
saveSessionOwnerToStorage,
|
|
22
|
+
toEvmCaip2
|
|
23
|
+
} from "./chunk-QIK6ONMQ.mjs";
|
|
21
24
|
import {
|
|
22
25
|
DEFAULT_BACKEND_URL,
|
|
23
26
|
DEFAULT_SIGNER_ADDRESS,
|
|
@@ -30,7 +33,7 @@ import {
|
|
|
30
33
|
getTokenDecimalsByAddress,
|
|
31
34
|
getTokenIcon,
|
|
32
35
|
getTokenSymbol
|
|
33
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ZJQZEIHA.mjs";
|
|
34
37
|
|
|
35
38
|
// src/WithdrawModal.tsx
|
|
36
39
|
import {
|
|
@@ -900,6 +903,18 @@ function WithdrawFlow({
|
|
|
900
903
|
const [isSubmitting, setIsSubmitting] = useState2(false);
|
|
901
904
|
const [totalBalanceUsd, setTotalBalanceUsd] = useState2(0);
|
|
902
905
|
const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = useState2(false);
|
|
906
|
+
const logFlow = useCallback2(
|
|
907
|
+
(message, data) => {
|
|
908
|
+
debugLog(debug, "withdraw-flow", message, data);
|
|
909
|
+
},
|
|
910
|
+
[debug]
|
|
911
|
+
);
|
|
912
|
+
const logFlowError = useCallback2(
|
|
913
|
+
(message, error, data) => {
|
|
914
|
+
debugError(debug, "withdraw-flow", message, error, data);
|
|
915
|
+
},
|
|
916
|
+
[debug]
|
|
917
|
+
);
|
|
903
918
|
const [targetChain, setTargetChain] = useState2(targetChainProp);
|
|
904
919
|
const [targetToken, setTargetToken] = useState2(targetTokenProp);
|
|
905
920
|
useEffect2(() => {
|
|
@@ -917,20 +932,26 @@ function WithdrawFlow({
|
|
|
917
932
|
const options = [];
|
|
918
933
|
const seen = /* @__PURE__ */ new Set();
|
|
919
934
|
if (dappWalletClient?.account && dappAddress) {
|
|
935
|
+
const id = `evm:${dappWalletClient.account.address.toLowerCase()}`;
|
|
920
936
|
options.push({
|
|
937
|
+
id,
|
|
921
938
|
address: dappWalletClient.account.address,
|
|
922
939
|
label: "Connected Wallet",
|
|
923
940
|
kind: "connected"
|
|
924
941
|
});
|
|
925
|
-
seen.add(
|
|
942
|
+
seen.add(id);
|
|
926
943
|
}
|
|
927
944
|
if (reownWallet?.address && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient && !seen.has(reownWallet.address.toLowerCase())) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
945
|
+
const id = `evm:${reownWallet.address.toLowerCase()}`;
|
|
946
|
+
if (!seen.has(id)) {
|
|
947
|
+
options.push({
|
|
948
|
+
id,
|
|
949
|
+
address: reownWallet.address,
|
|
950
|
+
label: "External Wallet",
|
|
951
|
+
kind: "external",
|
|
952
|
+
icon: reownWallet.icon
|
|
953
|
+
});
|
|
954
|
+
}
|
|
934
955
|
}
|
|
935
956
|
return options;
|
|
936
957
|
}, [
|
|
@@ -942,7 +963,7 @@ function WithdrawFlow({
|
|
|
942
963
|
reownWallet?.publicClient
|
|
943
964
|
]);
|
|
944
965
|
const canAutoLock = hasCustomSigner || Boolean(dappWalletClient?.account && dappAddress) && !reownWallet;
|
|
945
|
-
const [
|
|
966
|
+
const [selectedWalletId, setSelectedWalletId] = useState2(null);
|
|
946
967
|
const signerContext = useMemo2(() => {
|
|
947
968
|
if (canAutoLock) {
|
|
948
969
|
if (hasCustomSigner) {
|
|
@@ -960,8 +981,10 @@ function WithdrawFlow({
|
|
|
960
981
|
switchChain: dappSwitchChain
|
|
961
982
|
};
|
|
962
983
|
}
|
|
963
|
-
if (!isConnectSelectionConfirmed || !
|
|
964
|
-
|
|
984
|
+
if (!isConnectSelectionConfirmed || !selectedWalletId) return null;
|
|
985
|
+
const selectedOption = walletOptions.find((option) => option.id === selectedWalletId);
|
|
986
|
+
if (!selectedOption || !selectedOption.address) return null;
|
|
987
|
+
if (selectedOption.kind === "connected" && dappWalletClient?.account && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
|
|
965
988
|
return {
|
|
966
989
|
ownerAddress: dappWalletClient.account.address,
|
|
967
990
|
walletClient: dappWalletClient,
|
|
@@ -969,7 +992,7 @@ function WithdrawFlow({
|
|
|
969
992
|
switchChain: dappSwitchChain
|
|
970
993
|
};
|
|
971
994
|
}
|
|
972
|
-
if (reownWallet?.address?.toLowerCase() ===
|
|
995
|
+
if (selectedOption.kind === "external" && reownWallet?.address?.toLowerCase() === selectedOption.address.toLowerCase() && reownWallet.walletClient && reownWallet.publicClient) {
|
|
973
996
|
return {
|
|
974
997
|
ownerAddress: reownWallet.address,
|
|
975
998
|
walletClient: reownWallet.walletClient,
|
|
@@ -982,7 +1005,8 @@ function WithdrawFlow({
|
|
|
982
1005
|
canAutoLock,
|
|
983
1006
|
hasCustomSigner,
|
|
984
1007
|
isConnectSelectionConfirmed,
|
|
985
|
-
|
|
1008
|
+
selectedWalletId,
|
|
1009
|
+
walletOptions,
|
|
986
1010
|
dappWalletClient,
|
|
987
1011
|
dappPublicClient,
|
|
988
1012
|
dappSwitchChain,
|
|
@@ -1008,20 +1032,40 @@ function WithdrawFlow({
|
|
|
1008
1032
|
useEffect2(() => {
|
|
1009
1033
|
onStepChange?.(stepIndex, currentBackHandler);
|
|
1010
1034
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
1035
|
+
useEffect2(() => {
|
|
1036
|
+
logFlow("state:changed", {
|
|
1037
|
+
step: step.type,
|
|
1038
|
+
sourceChain,
|
|
1039
|
+
sourceToken,
|
|
1040
|
+
targetChain,
|
|
1041
|
+
targetToken,
|
|
1042
|
+
selectedWalletId
|
|
1043
|
+
});
|
|
1044
|
+
}, [
|
|
1045
|
+
logFlow,
|
|
1046
|
+
selectedWalletId,
|
|
1047
|
+
sourceChain,
|
|
1048
|
+
sourceToken,
|
|
1049
|
+
step.type,
|
|
1050
|
+
targetChain,
|
|
1051
|
+
targetToken
|
|
1052
|
+
]);
|
|
1011
1053
|
useEffect2(() => {
|
|
1012
1054
|
onTotalBalanceChange?.(totalBalanceUsd);
|
|
1013
1055
|
}, [totalBalanceUsd, onTotalBalanceChange]);
|
|
1014
1056
|
const handleConnected = useCallback2(
|
|
1015
1057
|
(addr, smartAccount) => {
|
|
1058
|
+
logFlow("setup:connected", { address: addr, smartAccount });
|
|
1016
1059
|
onConnected?.({ address: addr, smartAccount });
|
|
1017
1060
|
},
|
|
1018
|
-
[onConnected]
|
|
1061
|
+
[logFlow, onConnected]
|
|
1019
1062
|
);
|
|
1020
1063
|
const handleError = useCallback2(
|
|
1021
1064
|
(message, code) => {
|
|
1065
|
+
logFlowError("flow:error", message, { code });
|
|
1022
1066
|
onError?.({ message, code });
|
|
1023
1067
|
},
|
|
1024
|
-
[onError]
|
|
1068
|
+
[logFlowError, onError]
|
|
1025
1069
|
);
|
|
1026
1070
|
const resolveSessionOwner = useCallback2(async (eoaAddress) => {
|
|
1027
1071
|
const localOwner = loadSessionOwnerFromStorage(eoaAddress);
|
|
@@ -1049,17 +1093,30 @@ function WithdrawFlow({
|
|
|
1049
1093
|
}
|
|
1050
1094
|
setIsSubmitting(true);
|
|
1051
1095
|
try {
|
|
1096
|
+
logFlow("submit:start", {
|
|
1097
|
+
ownerAddress: ownerAddress2,
|
|
1098
|
+
recipient,
|
|
1099
|
+
amount: amountValue,
|
|
1100
|
+
sourceChain,
|
|
1101
|
+
sourceToken,
|
|
1102
|
+
targetChain,
|
|
1103
|
+
targetToken
|
|
1104
|
+
});
|
|
1052
1105
|
const sessionOwner = await resolveSessionOwner(ownerAddress2);
|
|
1053
1106
|
const setup = await service.setupAccount({
|
|
1054
1107
|
ownerAddress: ownerAddress2,
|
|
1055
1108
|
sessionOwnerAddress: sessionOwner.address,
|
|
1056
|
-
targetChain,
|
|
1109
|
+
targetChain: toEvmCaip2(targetChain),
|
|
1057
1110
|
targetToken,
|
|
1058
1111
|
signerAddress,
|
|
1059
1112
|
sessionChainIds,
|
|
1060
1113
|
forceRegister
|
|
1061
1114
|
});
|
|
1062
1115
|
const smartAccount = setup.smartAccount;
|
|
1116
|
+
logFlow("setup:resolved", {
|
|
1117
|
+
smartAccount,
|
|
1118
|
+
needsRegistration: setup.needsRegistration
|
|
1119
|
+
});
|
|
1063
1120
|
if (setup.needsRegistration) {
|
|
1064
1121
|
if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
|
|
1065
1122
|
throw new Error("Missing registration payload from setup-account");
|
|
@@ -1090,11 +1147,12 @@ function WithdrawFlow({
|
|
|
1090
1147
|
eoaAddress: ownerAddress2,
|
|
1091
1148
|
sessionOwner: sessionOwner.address,
|
|
1092
1149
|
target: {
|
|
1093
|
-
chain: targetChain,
|
|
1150
|
+
chain: toEvmCaip2(targetChain),
|
|
1094
1151
|
token: targetToken,
|
|
1095
1152
|
recipient
|
|
1096
1153
|
}
|
|
1097
1154
|
});
|
|
1155
|
+
logFlow("register:success", { smartAccount });
|
|
1098
1156
|
}
|
|
1099
1157
|
handleConnected(ownerAddress2, smartAccount);
|
|
1100
1158
|
const amountUnits = parseUnits2(amountValue, asset.decimals);
|
|
@@ -1121,7 +1179,7 @@ function WithdrawFlow({
|
|
|
1121
1179
|
const { signature } = await onSignTransaction(request);
|
|
1122
1180
|
const relayResult = await service.relayWithdraw({
|
|
1123
1181
|
smartAccount,
|
|
1124
|
-
chainId: sourceChain,
|
|
1182
|
+
chainId: toEvmCaip2(sourceChain),
|
|
1125
1183
|
safeAddress,
|
|
1126
1184
|
safeTransaction: request.typedData.message,
|
|
1127
1185
|
signature
|
|
@@ -1150,6 +1208,13 @@ function WithdrawFlow({
|
|
|
1150
1208
|
chainId: sourceChain
|
|
1151
1209
|
});
|
|
1152
1210
|
}
|
|
1211
|
+
logFlow("withdraw:submitted", {
|
|
1212
|
+
txHash: result.txHash,
|
|
1213
|
+
smartAccount,
|
|
1214
|
+
amount: amountUnits.toString(),
|
|
1215
|
+
sourceChain,
|
|
1216
|
+
sourceToken
|
|
1217
|
+
});
|
|
1153
1218
|
onWithdrawSubmitted?.({
|
|
1154
1219
|
txHash: result.txHash,
|
|
1155
1220
|
sourceChain,
|
|
@@ -1166,6 +1231,12 @@ function WithdrawFlow({
|
|
|
1166
1231
|
});
|
|
1167
1232
|
} catch (err) {
|
|
1168
1233
|
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
1234
|
+
logFlowError("submit:failed", err, {
|
|
1235
|
+
sourceChain,
|
|
1236
|
+
sourceToken,
|
|
1237
|
+
targetChain,
|
|
1238
|
+
targetToken
|
|
1239
|
+
});
|
|
1169
1240
|
handleError(formatUserError(raw), "WITHDRAW_FLOW_ERROR");
|
|
1170
1241
|
throw err;
|
|
1171
1242
|
} finally {
|
|
@@ -1189,20 +1260,24 @@ function WithdrawFlow({
|
|
|
1189
1260
|
onWithdrawSubmitted,
|
|
1190
1261
|
onSignTransaction,
|
|
1191
1262
|
isSourceNative,
|
|
1192
|
-
handleError
|
|
1263
|
+
handleError,
|
|
1264
|
+
logFlow,
|
|
1265
|
+
logFlowError
|
|
1193
1266
|
]
|
|
1194
1267
|
);
|
|
1195
1268
|
const handleWithdrawComplete = useCallback2(
|
|
1196
1269
|
(txHash, destinationTxHash) => {
|
|
1270
|
+
logFlow("withdraw:complete", { txHash, destinationTxHash });
|
|
1197
1271
|
onWithdrawComplete?.({ txHash, destinationTxHash });
|
|
1198
1272
|
},
|
|
1199
|
-
[onWithdrawComplete]
|
|
1273
|
+
[logFlow, onWithdrawComplete]
|
|
1200
1274
|
);
|
|
1201
1275
|
const handleWithdrawFailed = useCallback2(
|
|
1202
1276
|
(txHash, error) => {
|
|
1277
|
+
logFlowError("withdraw:failed", error, { txHash });
|
|
1203
1278
|
onWithdrawFailed?.({ txHash, error });
|
|
1204
1279
|
},
|
|
1205
|
-
[onWithdrawFailed]
|
|
1280
|
+
[logFlowError, onWithdrawFailed]
|
|
1206
1281
|
);
|
|
1207
1282
|
const targetChainOptions = useMemo2(() => {
|
|
1208
1283
|
return SOURCE_CHAINS.filter(
|
|
@@ -1241,17 +1316,24 @@ function WithdrawFlow({
|
|
|
1241
1316
|
const handleTargetTokenChange = useCallback2((token) => {
|
|
1242
1317
|
setTargetToken(token);
|
|
1243
1318
|
}, []);
|
|
1244
|
-
const
|
|
1245
|
-
if (
|
|
1319
|
+
const selectedWalletIdEffective = useMemo2(() => {
|
|
1320
|
+
if (selectedWalletId) return selectedWalletId;
|
|
1246
1321
|
if (walletOptions.length === 1) {
|
|
1247
|
-
return walletOptions[0].
|
|
1322
|
+
return walletOptions[0].id;
|
|
1248
1323
|
}
|
|
1249
1324
|
return null;
|
|
1250
|
-
}, [
|
|
1325
|
+
}, [selectedWalletId, walletOptions]);
|
|
1326
|
+
const walletOptionsKey = useMemo2(
|
|
1327
|
+
() => walletOptions.map((option) => option.id).join(","),
|
|
1328
|
+
[walletOptions]
|
|
1329
|
+
);
|
|
1251
1330
|
const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
|
|
1331
|
+
useEffect2(() => {
|
|
1332
|
+
setIsConnectSelectionConfirmed(false);
|
|
1333
|
+
}, [walletOptionsKey, selectedWalletIdEffective]);
|
|
1252
1334
|
useEffect2(() => {
|
|
1253
1335
|
if (!showConnectStep && isConnectSelectionConfirmed && !signerContext) {
|
|
1254
|
-
|
|
1336
|
+
setSelectedWalletId(null);
|
|
1255
1337
|
setIsConnectSelectionConfirmed(false);
|
|
1256
1338
|
}
|
|
1257
1339
|
}, [showConnectStep, isConnectSelectionConfirmed, signerContext]);
|
|
@@ -1259,7 +1341,7 @@ function WithdrawFlow({
|
|
|
1259
1341
|
const selectedWalletIcon = useMemo2(() => {
|
|
1260
1342
|
if (!ownerAddress) return reownWallet?.icon;
|
|
1261
1343
|
const selected = walletOptions.find(
|
|
1262
|
-
(o) => o.address
|
|
1344
|
+
(o) => o.address?.toLowerCase() === ownerAddress.toLowerCase()
|
|
1263
1345
|
);
|
|
1264
1346
|
return selected?.icon ?? reownWallet?.icon;
|
|
1265
1347
|
}, [walletOptions, ownerAddress, reownWallet?.icon]);
|
|
@@ -1268,14 +1350,14 @@ function WithdrawFlow({
|
|
|
1268
1350
|
ConnectStep,
|
|
1269
1351
|
{
|
|
1270
1352
|
walletOptions,
|
|
1271
|
-
|
|
1272
|
-
|
|
1353
|
+
selectedWalletId: selectedWalletIdEffective,
|
|
1354
|
+
onSelectWallet: setSelectedWalletId,
|
|
1273
1355
|
onRequestConnect,
|
|
1274
1356
|
onConnect,
|
|
1275
1357
|
onDisconnect,
|
|
1276
1358
|
onContinue: () => {
|
|
1277
|
-
if (
|
|
1278
|
-
|
|
1359
|
+
if (selectedWalletIdEffective) {
|
|
1360
|
+
setSelectedWalletId(selectedWalletIdEffective);
|
|
1279
1361
|
}
|
|
1280
1362
|
setIsConnectSelectionConfirmed(true);
|
|
1281
1363
|
},
|
|
@@ -1340,7 +1422,7 @@ function WithdrawFlow({
|
|
|
1340
1422
|
// src/WithdrawModal.tsx
|
|
1341
1423
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1342
1424
|
var ReownWithdrawInner = lazy(
|
|
1343
|
-
() => import("./WithdrawModalReown-
|
|
1425
|
+
() => import("./WithdrawModalReown-7CSCY55U.mjs").then((m) => ({
|
|
1344
1426
|
default: m.WithdrawModalReown
|
|
1345
1427
|
}))
|
|
1346
1428
|
);
|
|
@@ -1395,7 +1477,10 @@ function WithdrawModalInner({
|
|
|
1395
1477
|
const backHandlerRef = useRef2(void 0);
|
|
1396
1478
|
const targetChain = getChainId(targetChainProp);
|
|
1397
1479
|
const sourceChain = getChainId(sourceChainProp);
|
|
1398
|
-
const service = useMemo3(
|
|
1480
|
+
const service = useMemo3(
|
|
1481
|
+
() => createDepositService(backendUrl, { debug, debugScope: "service:withdraw" }),
|
|
1482
|
+
[backendUrl, debug]
|
|
1483
|
+
);
|
|
1399
1484
|
useEffect3(() => {
|
|
1400
1485
|
if (isOpen && modalRef.current) {
|
|
1401
1486
|
applyTheme(modalRef.current, theme);
|