@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 +5 -1
- package/dist/{chunk-J7UK4L5T.mjs → chunk-35DWLO33.mjs} +36 -41
- package/dist/{chunk-W7ZYJB2X.cjs → chunk-A2PDOYYE.cjs} +81 -89
- package/dist/{chunk-BO745KAB.cjs → chunk-ANQQMGNN.cjs} +116 -197
- package/dist/{chunk-V6HZJZOL.cjs → chunk-O3I5KVXA.cjs} +72 -77
- package/dist/{chunk-JBT2ZV3Q.mjs → chunk-P7SQQAAF.mjs} +89 -170
- package/dist/{chunk-N2LJOFT2.mjs → chunk-ZMVCDFXM.mjs} +40 -48
- 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 +197 -0
- package/dist/reown.d.cts +14 -0
- package/dist/reown.d.ts +14 -0
- package/dist/reown.mjs +197 -0
- package/dist/{types-D_xeOU8G.d.cts → types-CUww05xT.d.cts} +14 -1
- package/dist/{types-DnGF9RJJ.d.ts → types-Z6GjVWFR.d.ts} +14 -1
- 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 +33 -11
- package/dist/DepositModalReown-324WTBDE.cjs +0 -33
- package/dist/DepositModalReown-YTWIR7A4.mjs +0 -33
- package/dist/WithdrawModalReown-ICP3DH6Q.mjs +0 -33
- package/dist/WithdrawModalReown-ZNTE2G6W.cjs +0 -33
- package/dist/chunk-6VJ2ZTNQ.cjs +0 -90
- package/dist/chunk-LBEP3A2Z.mjs +0 -90
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CHAIN_BY_ID,
|
|
3
3
|
NATIVE_TOKEN_ADDRESS,
|
|
4
|
-
SUPPORTED_CHAINS,
|
|
5
4
|
getChainIcon,
|
|
6
5
|
getChainName,
|
|
7
6
|
getExplorerTxUrl,
|
|
8
|
-
getSupportedTokenSymbolsForChain,
|
|
9
7
|
getTokenAddress,
|
|
10
8
|
getTokenDecimalsByAddress,
|
|
11
9
|
getTokenSymbol,
|
|
@@ -153,6 +151,21 @@ function createDepositService(baseUrl) {
|
|
|
153
151
|
return `${normalizedBaseUrl}${normalizedPath}`;
|
|
154
152
|
}
|
|
155
153
|
return {
|
|
154
|
+
async prepareAccount(params) {
|
|
155
|
+
const response = await fetch(apiUrl("/prepare-account"), {
|
|
156
|
+
method: "POST",
|
|
157
|
+
headers: { "Content-Type": "application/json" },
|
|
158
|
+
body: JSON.stringify(params, jsonReplacer)
|
|
159
|
+
});
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
162
|
+
throw new Error(
|
|
163
|
+
error.error || `Prepare account failed: ${response.status}`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const payload = await response.json();
|
|
167
|
+
return normalizePrepareAccountResponse(payload);
|
|
168
|
+
},
|
|
156
169
|
async registerAccount(params) {
|
|
157
170
|
const { eoaAddress, sessionOwner, ...account } = params;
|
|
158
171
|
const response = await fetch(apiUrl("/register"), {
|
|
@@ -236,6 +249,58 @@ function createDepositService(baseUrl) {
|
|
|
236
249
|
}
|
|
237
250
|
};
|
|
238
251
|
}
|
|
252
|
+
function buildSessionDetails(sessionDetailsUnsigned, signature) {
|
|
253
|
+
return {
|
|
254
|
+
hashesAndChainIds: sessionDetailsUnsigned.hashesAndChainIds,
|
|
255
|
+
signature
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function normalizePrepareAccountResponse(payload) {
|
|
259
|
+
if (!isRecord(payload)) {
|
|
260
|
+
throw new Error("Invalid prepare-account response");
|
|
261
|
+
}
|
|
262
|
+
const smartAccount = extractString(payload, "smartAccount");
|
|
263
|
+
const accountParams = isRecord(payload.accountParams) ? payload.accountParams : null;
|
|
264
|
+
const sessionDetailsUnsigned = isRecord(payload.sessionDetailsUnsigned) ? payload.sessionDetailsUnsigned : null;
|
|
265
|
+
if (!smartAccount || !accountParams || !sessionDetailsUnsigned) {
|
|
266
|
+
throw new Error("Missing prepare-account fields");
|
|
267
|
+
}
|
|
268
|
+
const factory = extractString(accountParams, "factory");
|
|
269
|
+
const factoryData = extractString(accountParams, "factoryData");
|
|
270
|
+
if (!factory || !factoryData) {
|
|
271
|
+
throw new Error("Invalid account params from prepare-account");
|
|
272
|
+
}
|
|
273
|
+
const rawHashes = Array.isArray(sessionDetailsUnsigned.hashesAndChainIds) ? sessionDetailsUnsigned.hashesAndChainIds : null;
|
|
274
|
+
if (!rawHashes) {
|
|
275
|
+
throw new Error("Missing session hashes from prepare-account");
|
|
276
|
+
}
|
|
277
|
+
const hashesAndChainIds = rawHashes.map((value) => {
|
|
278
|
+
if (!isRecord(value)) return null;
|
|
279
|
+
const sessionDigest = extractString(value, "sessionDigest");
|
|
280
|
+
const chainId = toBigInt(value.chainId);
|
|
281
|
+
if (!sessionDigest || chainId === null) return null;
|
|
282
|
+
return {
|
|
283
|
+
chainId,
|
|
284
|
+
sessionDigest
|
|
285
|
+
};
|
|
286
|
+
}).filter(
|
|
287
|
+
(item) => item !== null
|
|
288
|
+
);
|
|
289
|
+
if (hashesAndChainIds.length === 0) {
|
|
290
|
+
throw new Error("Session hashes are empty");
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
smartAccount,
|
|
294
|
+
accountParams: {
|
|
295
|
+
factory,
|
|
296
|
+
factoryData
|
|
297
|
+
},
|
|
298
|
+
sessionDetailsUnsigned: {
|
|
299
|
+
hashesAndChainIds,
|
|
300
|
+
data: sessionDetailsUnsigned.data
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
239
304
|
function normalizeDirectPortfolio(data) {
|
|
240
305
|
const rawTokens = extractArray(data, "tokens") ?? extractArray(
|
|
241
306
|
data?.data,
|
|
@@ -321,6 +386,23 @@ function extractTokenAddress(tokenData, chainId) {
|
|
|
321
386
|
const token = tokenData;
|
|
322
387
|
return token.tokenAddress ?? token.address ?? token.addresses?.[chainId] ?? token.token?.address ?? token.token?.addresses?.[chainId];
|
|
323
388
|
}
|
|
389
|
+
function isRecord(value) {
|
|
390
|
+
return typeof value === "object" && value !== null;
|
|
391
|
+
}
|
|
392
|
+
function toBigInt(value) {
|
|
393
|
+
if (typeof value === "bigint") return value;
|
|
394
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0) {
|
|
395
|
+
return BigInt(value);
|
|
396
|
+
}
|
|
397
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
398
|
+
try {
|
|
399
|
+
return BigInt(value);
|
|
400
|
+
} catch {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
324
406
|
function extractArray(data, key) {
|
|
325
407
|
if (!data || typeof data !== "object") return null;
|
|
326
408
|
const record = data;
|
|
@@ -769,165 +851,6 @@ function ConnectStep({
|
|
|
769
851
|
}
|
|
770
852
|
ConnectStep.displayName = "ConnectStep";
|
|
771
853
|
|
|
772
|
-
// src/core/account.ts
|
|
773
|
-
import {
|
|
774
|
-
RhinestoneSDK
|
|
775
|
-
} from "@rhinestone/sdk";
|
|
776
|
-
import { zeroAddress } from "viem";
|
|
777
|
-
import { toAccount } from "viem/accounts";
|
|
778
|
-
function createViewOnlyAccount(address) {
|
|
779
|
-
if (!address || address === zeroAddress) {
|
|
780
|
-
throw new Error("Address is required");
|
|
781
|
-
}
|
|
782
|
-
return toAccount({
|
|
783
|
-
address,
|
|
784
|
-
signMessage: async () => {
|
|
785
|
-
throw new Error("Account is view-only");
|
|
786
|
-
},
|
|
787
|
-
signTransaction: async () => {
|
|
788
|
-
throw new Error("Account is view-only");
|
|
789
|
-
},
|
|
790
|
-
signTypedData: async () => {
|
|
791
|
-
throw new Error("Account is view-only");
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
function getSessionSignerAccount(signerAddress) {
|
|
796
|
-
if (!signerAddress || signerAddress === zeroAddress) {
|
|
797
|
-
throw new Error("Signer address is required");
|
|
798
|
-
}
|
|
799
|
-
return toAccount({
|
|
800
|
-
address: signerAddress,
|
|
801
|
-
signMessage: async () => {
|
|
802
|
-
throw new Error("Session signer is view-only");
|
|
803
|
-
},
|
|
804
|
-
signTransaction: async () => {
|
|
805
|
-
throw new Error("Session signer is view-only");
|
|
806
|
-
},
|
|
807
|
-
signTypedData: async () => {
|
|
808
|
-
throw new Error("Session signer is view-only");
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
function buildSession(chain, signerAddress) {
|
|
813
|
-
const sessionSignerAccount = getSessionSignerAccount(signerAddress);
|
|
814
|
-
return {
|
|
815
|
-
owners: {
|
|
816
|
-
type: "ecdsa",
|
|
817
|
-
accounts: [sessionSignerAccount]
|
|
818
|
-
},
|
|
819
|
-
chain
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
async function createSmartAccount(userSigner, sessionSigner, sdkApiKey) {
|
|
823
|
-
const rhinestone = new RhinestoneSDK({
|
|
824
|
-
apiKey: sdkApiKey ?? ""
|
|
825
|
-
});
|
|
826
|
-
const ownerAccounts = sessionSigner ? [userSigner, sessionSigner] : [userSigner];
|
|
827
|
-
const config = {
|
|
828
|
-
account: {
|
|
829
|
-
type: "nexus"
|
|
830
|
-
},
|
|
831
|
-
owners: {
|
|
832
|
-
type: "ecdsa",
|
|
833
|
-
accounts: ownerAccounts,
|
|
834
|
-
...sessionSigner ? { threshold: 1 } : {}
|
|
835
|
-
},
|
|
836
|
-
experimental_sessions: {
|
|
837
|
-
enabled: true
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
const account = await rhinestone.createAccount(config);
|
|
841
|
-
return account;
|
|
842
|
-
}
|
|
843
|
-
function getAccountAddress(account) {
|
|
844
|
-
return account.getAddress();
|
|
845
|
-
}
|
|
846
|
-
function getAccountInitData(account) {
|
|
847
|
-
const { factory, factoryData } = account.getInitData();
|
|
848
|
-
if (!factory) {
|
|
849
|
-
throw new Error("Account init data is not available");
|
|
850
|
-
}
|
|
851
|
-
return {
|
|
852
|
-
factory,
|
|
853
|
-
factoryData
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
async function signEnableSessionWithOwner(rhinestoneAccount, sessionDetails, signer) {
|
|
857
|
-
const originalOwners = rhinestoneAccount.config.owners;
|
|
858
|
-
rhinestoneAccount.config.owners = {
|
|
859
|
-
type: "ecdsa",
|
|
860
|
-
accounts: [signer],
|
|
861
|
-
threshold: 1,
|
|
862
|
-
...originalOwners?.type === "ecdsa" && originalOwners.module ? { module: originalOwners.module } : {}
|
|
863
|
-
};
|
|
864
|
-
try {
|
|
865
|
-
return await rhinestoneAccount.experimental_signEnableSession(
|
|
866
|
-
sessionDetails
|
|
867
|
-
);
|
|
868
|
-
} finally {
|
|
869
|
-
rhinestoneAccount.config.owners = originalOwners;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner, targetToken, sessionChainIds) {
|
|
873
|
-
const isTargetTestnet = Boolean(targetChain.testnet);
|
|
874
|
-
const chainsByNetworkType = SUPPORTED_CHAINS.filter(
|
|
875
|
-
(chain) => Boolean(chain.testnet) === isTargetTestnet
|
|
876
|
-
);
|
|
877
|
-
const chainsById = new Map(
|
|
878
|
-
chainsByNetworkType.map((chain) => [chain.id, chain])
|
|
879
|
-
);
|
|
880
|
-
let selectedChains = [...chainsByNetworkType];
|
|
881
|
-
if (sessionChainIds && sessionChainIds.length > 0) {
|
|
882
|
-
const selectedByCaller = [];
|
|
883
|
-
for (const chainId of sessionChainIds) {
|
|
884
|
-
const chain = chainsById.get(chainId);
|
|
885
|
-
if (chain) {
|
|
886
|
-
selectedByCaller.push(chain);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
if (selectedByCaller.length > 0) {
|
|
890
|
-
selectedChains = selectedByCaller;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
if (targetToken) {
|
|
894
|
-
const targetSymbol = getTokenSymbol(
|
|
895
|
-
targetToken,
|
|
896
|
-
targetChain.id
|
|
897
|
-
).toUpperCase();
|
|
898
|
-
if (targetSymbol && targetSymbol !== "TOKEN") {
|
|
899
|
-
const chainsForToken = selectedChains.filter(
|
|
900
|
-
(chain) => getSupportedTokenSymbolsForChain(chain.id).includes(targetSymbol)
|
|
901
|
-
);
|
|
902
|
-
if (chainsForToken.length > 0) {
|
|
903
|
-
selectedChains = chainsForToken;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
if (!selectedChains.some((c) => c.id === targetChain.id)) {
|
|
908
|
-
selectedChains.push(targetChain);
|
|
909
|
-
}
|
|
910
|
-
const uniqueChains = Array.from(
|
|
911
|
-
new Map(selectedChains.map((chain) => [chain.id, chain])).values()
|
|
912
|
-
);
|
|
913
|
-
const sessions = uniqueChains.map(
|
|
914
|
-
(chain) => buildSession(chain, signerAddress)
|
|
915
|
-
);
|
|
916
|
-
const sessionDetails = await rhinestoneAccount.experimental_getSessionDetails(sessions);
|
|
917
|
-
const enableSignature = sessionSigner ? await signEnableSessionWithOwner(
|
|
918
|
-
rhinestoneAccount,
|
|
919
|
-
sessionDetails,
|
|
920
|
-
sessionSigner
|
|
921
|
-
) : await rhinestoneAccount.experimental_signEnableSession(sessionDetails);
|
|
922
|
-
if (!sessionDetails.hashesAndChainIds?.length) {
|
|
923
|
-
throw new Error("Session details missing chain digests");
|
|
924
|
-
}
|
|
925
|
-
return {
|
|
926
|
-
hashesAndChainIds: sessionDetails.hashesAndChainIds,
|
|
927
|
-
signature: enableSignature
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
|
|
931
854
|
// src/core/session-owner.ts
|
|
932
855
|
import { isAddress } from "viem";
|
|
933
856
|
import {
|
|
@@ -1019,7 +942,7 @@ function PoweredBy() {
|
|
|
1019
942
|
}
|
|
1020
943
|
|
|
1021
944
|
// src/core/webhook.ts
|
|
1022
|
-
function
|
|
945
|
+
function isRecord2(value) {
|
|
1023
946
|
return typeof value === "object" && value !== null;
|
|
1024
947
|
}
|
|
1025
948
|
function asString(value) {
|
|
@@ -1031,11 +954,11 @@ function getEventTxHash(event) {
|
|
|
1031
954
|
return asString(event.data?.transactionHash);
|
|
1032
955
|
}
|
|
1033
956
|
if (event.type === "bridge-started" || event.type === "bridge-complete") {
|
|
1034
|
-
const deposit =
|
|
957
|
+
const deposit = isRecord2(event.data?.deposit) ? event.data.deposit : void 0;
|
|
1035
958
|
return asString(deposit?.transactionHash);
|
|
1036
959
|
}
|
|
1037
960
|
if (event.type === "bridge-failed" || event.type === "error") {
|
|
1038
|
-
const deposit =
|
|
961
|
+
const deposit = isRecord2(event.data?.deposit) ? event.data.deposit : void 0;
|
|
1039
962
|
return asString(deposit?.transactionHash);
|
|
1040
963
|
}
|
|
1041
964
|
return void 0;
|
|
@@ -1623,20 +1546,16 @@ export {
|
|
|
1623
1546
|
Spinner,
|
|
1624
1547
|
Button,
|
|
1625
1548
|
ConnectStep,
|
|
1626
|
-
createViewOnlyAccount,
|
|
1627
|
-
createSmartAccount,
|
|
1628
|
-
getAccountAddress,
|
|
1629
|
-
getAccountInitData,
|
|
1630
|
-
getSessionDetails,
|
|
1631
1549
|
loadSessionOwnerFromStorage,
|
|
1632
1550
|
saveSessionOwnerToStorage,
|
|
1633
1551
|
createSessionOwnerKey,
|
|
1634
1552
|
accountFromPrivateKey,
|
|
1635
|
-
PoweredBy,
|
|
1636
1553
|
createDepositService,
|
|
1554
|
+
buildSessionDetails,
|
|
1637
1555
|
getAssetId,
|
|
1638
1556
|
portfolioToAssets,
|
|
1639
1557
|
isNativeAsset,
|
|
1558
|
+
PoweredBy,
|
|
1640
1559
|
currencyFormatter,
|
|
1641
1560
|
tokenFormatter,
|
|
1642
1561
|
formatUserError,
|
|
@@ -7,25 +7,21 @@ 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
|
-
getAccountAddress,
|
|
17
|
-
getAccountInitData,
|
|
18
15
|
getAssetId,
|
|
19
16
|
getEventTxHash,
|
|
20
17
|
getPublicClient,
|
|
21
|
-
getSessionDetails,
|
|
22
18
|
isDepositEvent,
|
|
23
19
|
isNativeAsset,
|
|
24
20
|
loadSessionOwnerFromStorage,
|
|
25
21
|
portfolioToAssets,
|
|
26
22
|
saveSessionOwnerToStorage,
|
|
27
23
|
tokenFormatter
|
|
28
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-P7SQQAAF.mjs";
|
|
29
25
|
import {
|
|
30
26
|
CHAIN_BY_ID,
|
|
31
27
|
DEFAULT_BACKEND_URL,
|
|
@@ -49,9 +45,7 @@ import {
|
|
|
49
45
|
useEffect as useEffect7,
|
|
50
46
|
useRef as useRef5,
|
|
51
47
|
useState as useState8,
|
|
52
|
-
useCallback as useCallback4
|
|
53
|
-
lazy,
|
|
54
|
-
Suspense
|
|
48
|
+
useCallback as useCallback4
|
|
55
49
|
} from "react";
|
|
56
50
|
|
|
57
51
|
// src/DepositFlow.tsx
|
|
@@ -59,7 +53,6 @@ import { useState as useState7, useCallback as useCallback3, useMemo as useMemo6
|
|
|
59
53
|
|
|
60
54
|
// src/components/steps/SetupStep.tsx
|
|
61
55
|
import { useState, useEffect, useRef, useCallback } from "react";
|
|
62
|
-
import { walletClientToAccount } from "@rhinestone/sdk";
|
|
63
56
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
64
57
|
async function resolveSessionOwner(eoaAddress) {
|
|
65
58
|
const localOwner = loadSessionOwnerFromStorage(eoaAddress);
|
|
@@ -80,9 +73,7 @@ function SetupStep({
|
|
|
80
73
|
walletClient,
|
|
81
74
|
address,
|
|
82
75
|
targetChain,
|
|
83
|
-
targetChainObj,
|
|
84
76
|
targetToken,
|
|
85
|
-
rhinestoneApiKey,
|
|
86
77
|
signerAddress,
|
|
87
78
|
sessionChainIds,
|
|
88
79
|
recipient,
|
|
@@ -94,8 +85,18 @@ function SetupStep({
|
|
|
94
85
|
}) {
|
|
95
86
|
const [state, setState] = useState({ type: "idle" });
|
|
96
87
|
const setupInitiatedRef = useRef(false);
|
|
88
|
+
const signSessionDetails = useCallback(
|
|
89
|
+
async (sessionOwner, typedData) => {
|
|
90
|
+
const signer = sessionOwner.account;
|
|
91
|
+
if (!signer.signTypedData) {
|
|
92
|
+
throw new Error("Session owner cannot sign typed data");
|
|
93
|
+
}
|
|
94
|
+
return await signer.signTypedData(typedData);
|
|
95
|
+
},
|
|
96
|
+
[]
|
|
97
|
+
);
|
|
97
98
|
const runSetup = useCallback(async () => {
|
|
98
|
-
if (!address
|
|
99
|
+
if (!address) {
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
102
|
if (walletClient && !walletClient.account) {
|
|
@@ -103,14 +104,16 @@ function SetupStep({
|
|
|
103
104
|
}
|
|
104
105
|
try {
|
|
105
106
|
setState({ type: "creating-account" });
|
|
106
|
-
const signerAccount = walletClient ? walletClientToAccount(walletClient) : createViewOnlyAccount(address);
|
|
107
107
|
const sessionOwner = await resolveSessionOwner(address);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
sessionOwner.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
const prepared = await service.prepareAccount({
|
|
109
|
+
ownerAddress: address,
|
|
110
|
+
sessionOwnerAddress: sessionOwner.address,
|
|
111
|
+
targetChain,
|
|
112
|
+
targetToken,
|
|
113
|
+
signerAddress,
|
|
114
|
+
sessionChainIds
|
|
115
|
+
});
|
|
116
|
+
const smartAccount = prepared.smartAccount;
|
|
114
117
|
setState({ type: "checking" });
|
|
115
118
|
const checkResult = await service.checkAccount(smartAccount);
|
|
116
119
|
if (checkResult.isRegistered && !forceRegister) {
|
|
@@ -123,21 +126,20 @@ function SetupStep({
|
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
128
|
setState({ type: "signing-session" });
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
sessionChainIds
|
|
129
|
+
const signature = await signSessionDetails(
|
|
130
|
+
sessionOwner,
|
|
131
|
+
prepared.sessionDetailsUnsigned.data
|
|
132
|
+
);
|
|
133
|
+
const sessionDetails = buildSessionDetails(
|
|
134
|
+
prepared.sessionDetailsUnsigned,
|
|
135
|
+
signature
|
|
134
136
|
);
|
|
135
137
|
setState({ type: "registering" });
|
|
136
138
|
await service.registerAccount({
|
|
137
139
|
address: smartAccount,
|
|
138
140
|
accountParams: {
|
|
139
|
-
factory:
|
|
140
|
-
factoryData:
|
|
141
|
+
factory: prepared.accountParams.factory,
|
|
142
|
+
factoryData: prepared.accountParams.factoryData,
|
|
141
143
|
sessionDetails
|
|
142
144
|
},
|
|
143
145
|
eoaAddress: address,
|
|
@@ -159,10 +161,8 @@ function SetupStep({
|
|
|
159
161
|
}, [
|
|
160
162
|
address,
|
|
161
163
|
walletClient,
|
|
162
|
-
targetChainObj,
|
|
163
164
|
targetChain,
|
|
164
165
|
targetToken,
|
|
165
|
-
rhinestoneApiKey,
|
|
166
166
|
signerAddress,
|
|
167
167
|
sessionChainIds,
|
|
168
168
|
recipient,
|
|
@@ -170,15 +170,16 @@ function SetupStep({
|
|
|
170
170
|
service,
|
|
171
171
|
onSetupComplete,
|
|
172
172
|
onError,
|
|
173
|
-
onConnected
|
|
173
|
+
onConnected,
|
|
174
|
+
signSessionDetails
|
|
174
175
|
]);
|
|
175
176
|
useEffect(() => {
|
|
176
177
|
const hasWallet = walletClient ? Boolean(walletClient.account) : true;
|
|
177
|
-
if (address && hasWallet &&
|
|
178
|
+
if (address && hasWallet && !setupInitiatedRef.current && state.type === "idle") {
|
|
178
179
|
setupInitiatedRef.current = true;
|
|
179
180
|
runSetup();
|
|
180
181
|
}
|
|
181
|
-
}, [address, walletClient,
|
|
182
|
+
}, [address, walletClient, state.type, runSetup]);
|
|
182
183
|
const handleRetry = () => {
|
|
183
184
|
setupInitiatedRef.current = false;
|
|
184
185
|
setState({ type: "idle" });
|
|
@@ -1650,7 +1651,6 @@ function DepositFlow({
|
|
|
1650
1651
|
sourceToken: defaultSourceToken,
|
|
1651
1652
|
amount: defaultAmount,
|
|
1652
1653
|
recipient,
|
|
1653
|
-
rhinestoneApiKey,
|
|
1654
1654
|
signerAddress = DEFAULT_SIGNER_ADDRESS,
|
|
1655
1655
|
sessionChainIds,
|
|
1656
1656
|
forceRegister = false,
|
|
@@ -1973,9 +1973,7 @@ function DepositFlow({
|
|
|
1973
1973
|
{
|
|
1974
1974
|
address: sessionKeyAddress,
|
|
1975
1975
|
targetChain,
|
|
1976
|
-
targetChainObj,
|
|
1977
1976
|
targetToken,
|
|
1978
|
-
rhinestoneApiKey,
|
|
1979
1977
|
signerAddress,
|
|
1980
1978
|
sessionChainIds,
|
|
1981
1979
|
recipient,
|
|
@@ -2036,9 +2034,7 @@ function DepositFlow({
|
|
|
2036
2034
|
walletClient: signerContext.walletClient,
|
|
2037
2035
|
address: ownerAddress,
|
|
2038
2036
|
targetChain,
|
|
2039
|
-
targetChainObj,
|
|
2040
2037
|
targetToken,
|
|
2041
|
-
rhinestoneApiKey,
|
|
2042
2038
|
signerAddress,
|
|
2043
2039
|
sessionChainIds,
|
|
2044
2040
|
recipient,
|
|
@@ -2119,13 +2115,11 @@ function DepositFlow({
|
|
|
2119
2115
|
|
|
2120
2116
|
// src/DepositModal.tsx
|
|
2121
2117
|
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2122
|
-
var ReownDepositInner = lazy(
|
|
2123
|
-
() => import("./DepositModalReown-YTWIR7A4.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
2124
|
-
);
|
|
2125
2118
|
function DepositModal(props) {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2119
|
+
if (props.reownAppId) {
|
|
2120
|
+
throw new Error(
|
|
2121
|
+
'Reown support moved to "@rhinestone/deposit-modal/reown". Use that entrypoint when passing reownAppId.'
|
|
2122
|
+
);
|
|
2129
2123
|
}
|
|
2130
2124
|
return /* @__PURE__ */ jsx8(DepositModalInner, { ...props });
|
|
2131
2125
|
}
|
|
@@ -2144,7 +2138,6 @@ function DepositModalInner({
|
|
|
2144
2138
|
defaultAmount,
|
|
2145
2139
|
recipient,
|
|
2146
2140
|
backendUrl = DEFAULT_BACKEND_URL,
|
|
2147
|
-
rhinestoneApiKey,
|
|
2148
2141
|
signerAddress = DEFAULT_SIGNER_ADDRESS,
|
|
2149
2142
|
sessionChainIds,
|
|
2150
2143
|
forceRegister = false,
|
|
@@ -2314,7 +2307,6 @@ function DepositModalInner({
|
|
|
2314
2307
|
sourceToken,
|
|
2315
2308
|
amount: defaultAmount,
|
|
2316
2309
|
recipient,
|
|
2317
|
-
rhinestoneApiKey,
|
|
2318
2310
|
signerAddress,
|
|
2319
2311
|
sessionChainIds,
|
|
2320
2312
|
forceRegister,
|
package/dist/deposit.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkA2PDOYYEcjs = require('./chunk-A2PDOYYE.cjs');
|
|
4
|
+
require('./chunk-ANQQMGNN.cjs');
|
|
5
5
|
require('./chunk-CEIWN53N.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.DepositModal =
|
|
8
|
+
exports.DepositModal = _chunkA2PDOYYEcjs.DepositModal;
|
package/dist/deposit.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { c as DepositModalProps } from './types-
|
|
3
|
-
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData } from './types-
|
|
2
|
+
import { c as DepositModalProps } from './types-CUww05xT.cjs';
|
|
3
|
+
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData } from './types-CUww05xT.cjs';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import './safe.cjs';
|
|
6
6
|
|
package/dist/deposit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { c as DepositModalProps } from './types-
|
|
3
|
-
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData } from './types-
|
|
2
|
+
import { c as DepositModalProps } from './types-Z6GjVWFR.js';
|
|
3
|
+
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData } from './types-Z6GjVWFR.js';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import './safe.js';
|
|
6
6
|
|
package/dist/deposit.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkA2PDOYYEcjs = require('./chunk-A2PDOYYE.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('./chunk-
|
|
6
|
+
var _chunkO3I5KVXAcjs = require('./chunk-O3I5KVXA.cjs');
|
|
7
|
+
require('./chunk-ANQQMGNN.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -64,4 +64,4 @@ var _chunkCEIWN53Ncjs = require('./chunk-CEIWN53N.cjs');
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
exports.CHAIN_BY_ID = _chunkCEIWN53Ncjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkCEIWN53Ncjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkCEIWN53Ncjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal =
|
|
67
|
+
exports.CHAIN_BY_ID = _chunkCEIWN53Ncjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkCEIWN53Ncjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkCEIWN53Ncjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal = _chunkA2PDOYYEcjs.DepositModal; exports.NATIVE_TOKEN_ADDRESS = _chunkCEIWN53Ncjs.NATIVE_TOKEN_ADDRESS; exports.SOURCE_CHAINS = _chunkCEIWN53Ncjs.SOURCE_CHAINS; exports.SUPPORTED_CHAINS = _chunkCEIWN53Ncjs.SUPPORTED_CHAINS; exports.WithdrawModal = _chunkO3I5KVXAcjs.WithdrawModal; exports.chainRegistry = _chunkCEIWN53Ncjs.chainRegistry; exports.findChainIdForToken = _chunkCEIWN53Ncjs.findChainIdForToken; exports.getChainBadge = _chunkCEIWN53Ncjs.getChainBadge; exports.getChainIcon = _chunkCEIWN53Ncjs.getChainIcon; exports.getChainId = _chunkCEIWN53Ncjs.getChainId; exports.getChainName = _chunkCEIWN53Ncjs.getChainName; exports.getChainObject = _chunkCEIWN53Ncjs.getChainObject; exports.getExplorerName = _chunkCEIWN53Ncjs.getExplorerName; exports.getExplorerTxUrl = _chunkCEIWN53Ncjs.getExplorerTxUrl; exports.getExplorerUrl = _chunkCEIWN53Ncjs.getExplorerUrl; exports.getSupportedChainIds = _chunkCEIWN53Ncjs.getSupportedChainIds; exports.getSupportedTargetTokens = _chunkCEIWN53Ncjs.getSupportedTargetTokens; exports.getSupportedTokenSymbolsForChain = _chunkCEIWN53Ncjs.getSupportedTokenSymbolsForChain; exports.getTokenAddress = _chunkCEIWN53Ncjs.getTokenAddress; exports.getTokenDecimals = _chunkCEIWN53Ncjs.getTokenDecimals; exports.getTokenDecimalsByAddress = _chunkCEIWN53Ncjs.getTokenDecimalsByAddress; exports.getTokenIcon = _chunkCEIWN53Ncjs.getTokenIcon; exports.getTokenSymbol = _chunkCEIWN53Ncjs.getTokenSymbol; exports.getUsdcAddress = _chunkCEIWN53Ncjs.getUsdcAddress; exports.getUsdcDecimals = _chunkCEIWN53Ncjs.getUsdcDecimals; exports.isSupportedTokenAddressForChain = _chunkCEIWN53Ncjs.isSupportedTokenAddressForChain;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DepositModal } from './deposit.cjs';
|
|
2
2
|
export { WithdrawModal } from './withdraw.cjs';
|
|
3
|
-
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, c as DepositModalProps, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData, W as
|
|
3
|
+
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, c as DepositModalProps, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData, R as ReownWallet, W as WalletOption, g as WithdrawCompleteEventData, h as WithdrawFailedEventData, i as WithdrawModalProps, j as WithdrawSubmittedEventData } from './types-CUww05xT.cjs';
|
|
4
4
|
export { CHAIN_BY_ID, DEFAULT_BACKEND_URL, DEFAULT_SIGNER_ADDRESS, NATIVE_TOKEN_ADDRESS, SOURCE_CHAINS, SUPPORTED_CHAINS, findChainIdForToken, getChainBadge, getChainIcon, getChainId, getChainName, getChainObject, getExplorerName, getExplorerTxUrl, getExplorerUrl, getSupportedChainIds, getSupportedTargetTokens, getSupportedTokenSymbolsForChain, getTokenAddress, getTokenDecimals, getTokenDecimalsByAddress, getTokenIcon, getTokenSymbol, getUsdcAddress, getUsdcDecimals, isSupportedTokenAddressForChain } from './constants.cjs';
|
|
5
5
|
export { SafeTransactionRequest } from './safe.cjs';
|
|
6
6
|
export { chainRegistry } from '@rhinestone/shared-configs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DepositModal } from './deposit.js';
|
|
2
2
|
export { WithdrawModal } from './withdraw.js';
|
|
3
|
-
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, c as DepositModalProps, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData, W as
|
|
3
|
+
export { A as AssetOption, C as ConnectedEventData, D as DepositCompleteEventData, a as DepositFailedEventData, b as DepositModalBranding, c as DepositModalProps, d as DepositModalTheme, e as DepositModalUIConfig, f as DepositSubmittedEventData, E as ErrorEventData, R as ReownWallet, W as WalletOption, g as WithdrawCompleteEventData, h as WithdrawFailedEventData, i as WithdrawModalProps, j as WithdrawSubmittedEventData } from './types-Z6GjVWFR.js';
|
|
4
4
|
export { CHAIN_BY_ID, DEFAULT_BACKEND_URL, DEFAULT_SIGNER_ADDRESS, NATIVE_TOKEN_ADDRESS, SOURCE_CHAINS, SUPPORTED_CHAINS, findChainIdForToken, getChainBadge, getChainIcon, getChainId, getChainName, getChainObject, getExplorerName, getExplorerTxUrl, getExplorerUrl, getSupportedChainIds, getSupportedTargetTokens, getSupportedTokenSymbolsForChain, getTokenAddress, getTokenDecimals, getTokenDecimalsByAddress, getTokenIcon, getTokenSymbol, getUsdcAddress, getUsdcDecimals, isSupportedTokenAddressForChain } from './constants.js';
|
|
5
5
|
export { SafeTransactionRequest } from './safe.js';
|
|
6
6
|
export { chainRegistry } from '@rhinestone/shared-configs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DepositModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZMVCDFXM.mjs";
|
|
4
4
|
import {
|
|
5
5
|
WithdrawModal
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-35DWLO33.mjs";
|
|
7
|
+
import "./chunk-P7SQQAAF.mjs";
|
|
8
8
|
import {
|
|
9
9
|
CHAIN_BY_ID,
|
|
10
10
|
DEFAULT_BACKEND_URL,
|