@rhinestone/deposit-modal 0.1.22 → 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
|
@@ -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
|
|
@@ -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 = _nullishCoalesce(_nullishCoalesce(extractArray(data, "tokens"), () => ( extractArray(
|
|
241
306
|
_optionalChain([data, 'optionalAccess', _ => _.data]),
|
|
@@ -321,6 +386,23 @@ function extractTokenAddress(tokenData, chainId) {
|
|
|
321
386
|
const token = tokenData;
|
|
322
387
|
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access', _18 => _18.addresses, 'optionalAccess', _19 => _19[chainId]]))), () => ( _optionalChain([token, 'access', _20 => _20.token, 'optionalAccess', _21 => _21.address]))), () => ( _optionalChain([token, 'access', _22 => _22.token, 'optionalAccess', _23 => _23.addresses, 'optionalAccess', _24 => _24[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 (e) {
|
|
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;
|
|
@@ -373,7 +455,7 @@ function safeBigInt(value) {
|
|
|
373
455
|
if (!value) return BigInt(0);
|
|
374
456
|
try {
|
|
375
457
|
return BigInt(value);
|
|
376
|
-
} catch (
|
|
458
|
+
} catch (e2) {
|
|
377
459
|
return BigInt(0);
|
|
378
460
|
}
|
|
379
461
|
}
|
|
@@ -769,171 +851,12 @@ function ConnectStep({
|
|
|
769
851
|
}
|
|
770
852
|
ConnectStep.displayName = "ConnectStep";
|
|
771
853
|
|
|
772
|
-
// src/core/account.ts
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
var _sdk = require('@rhinestone/sdk');
|
|
776
|
-
var _viem = require('viem');
|
|
777
|
-
var _accounts = require('viem/accounts');
|
|
778
|
-
function createViewOnlyAccount(address) {
|
|
779
|
-
if (!address || address === _viem.zeroAddress) {
|
|
780
|
-
throw new Error("Address is required");
|
|
781
|
-
}
|
|
782
|
-
return _accounts.toAccount.call(void 0, {
|
|
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 === _viem.zeroAddress) {
|
|
797
|
-
throw new Error("Signer address is required");
|
|
798
|
-
}
|
|
799
|
-
return _accounts.toAccount.call(void 0, {
|
|
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 (0, _sdk.RhinestoneSDK)({
|
|
824
|
-
apiKey: _nullishCoalesce(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
|
-
..._optionalChain([originalOwners, 'optionalAccess', _41 => _41.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 = _chunkCEIWN53Ncjs.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 = _chunkCEIWN53Ncjs.getTokenSymbol.call(void 0,
|
|
895
|
-
targetToken,
|
|
896
|
-
targetChain.id
|
|
897
|
-
).toUpperCase();
|
|
898
|
-
if (targetSymbol && targetSymbol !== "TOKEN") {
|
|
899
|
-
const chainsForToken = selectedChains.filter(
|
|
900
|
-
(chain) => _chunkCEIWN53Ncjs.getSupportedTokenSymbolsForChain.call(void 0, 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 (!_optionalChain([sessionDetails, 'access', _42 => _42.hashesAndChainIds, 'optionalAccess', _43 => _43.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
|
|
855
|
+
var _viem = require('viem');
|
|
932
856
|
|
|
933
857
|
|
|
934
858
|
|
|
935
|
-
|
|
936
|
-
|
|
859
|
+
var _accounts = require('viem/accounts');
|
|
937
860
|
var STORAGE_PREFIX = "rhinestone:session-owner";
|
|
938
861
|
function storageKey(eoaAddress) {
|
|
939
862
|
return `${STORAGE_PREFIX}:${eoaAddress.toLowerCase()}`;
|
|
@@ -950,7 +873,7 @@ function loadSessionOwnerFromStorage(eoaAddress) {
|
|
|
950
873
|
privateKey: parsed.privateKey,
|
|
951
874
|
address: account.address
|
|
952
875
|
};
|
|
953
|
-
} catch (
|
|
876
|
+
} catch (e3) {
|
|
954
877
|
return null;
|
|
955
878
|
}
|
|
956
879
|
}
|
|
@@ -1019,29 +942,29 @@ 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) {
|
|
1026
949
|
return typeof value === "string" ? value : void 0;
|
|
1027
950
|
}
|
|
1028
951
|
function getEventTxHash(event) {
|
|
1029
|
-
if (!_optionalChain([event, 'optionalAccess',
|
|
952
|
+
if (!_optionalChain([event, 'optionalAccess', _41 => _41.type])) return void 0;
|
|
1030
953
|
if (event.type === "deposit-received") {
|
|
1031
|
-
return asString(_optionalChain([event, 'access',
|
|
954
|
+
return asString(_optionalChain([event, 'access', _42 => _42.data, 'optionalAccess', _43 => _43.transactionHash]));
|
|
1032
955
|
}
|
|
1033
956
|
if (event.type === "bridge-started" || event.type === "bridge-complete") {
|
|
1034
|
-
const deposit =
|
|
1035
|
-
return asString(_optionalChain([deposit, 'optionalAccess',
|
|
957
|
+
const deposit = isRecord2(_optionalChain([event, 'access', _44 => _44.data, 'optionalAccess', _45 => _45.deposit])) ? event.data.deposit : void 0;
|
|
958
|
+
return asString(_optionalChain([deposit, 'optionalAccess', _46 => _46.transactionHash]));
|
|
1036
959
|
}
|
|
1037
960
|
if (event.type === "bridge-failed" || event.type === "error") {
|
|
1038
|
-
const deposit =
|
|
1039
|
-
return asString(_optionalChain([deposit, 'optionalAccess',
|
|
961
|
+
const deposit = isRecord2(_optionalChain([event, 'access', _47 => _47.data, 'optionalAccess', _48 => _48.deposit])) ? event.data.deposit : void 0;
|
|
962
|
+
return asString(_optionalChain([deposit, 'optionalAccess', _49 => _49.transactionHash]));
|
|
1040
963
|
}
|
|
1041
964
|
return void 0;
|
|
1042
965
|
}
|
|
1043
966
|
function isDepositEvent(event) {
|
|
1044
|
-
return _optionalChain([event, 'optionalAccess',
|
|
967
|
+
return _optionalChain([event, 'optionalAccess', _50 => _50.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _51 => _51.type]) === "bridge-started";
|
|
1045
968
|
}
|
|
1046
969
|
|
|
1047
970
|
// src/components/steps/ProcessingStep.tsx
|
|
@@ -1056,7 +979,7 @@ function isEventForTx(event, txHash) {
|
|
|
1056
979
|
return eventTxHash.toLowerCase() === txHash.toLowerCase();
|
|
1057
980
|
}
|
|
1058
981
|
function formatBridgeFailedMessage(event) {
|
|
1059
|
-
const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
982
|
+
const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _52 => _52.data]), () => ( {}));
|
|
1060
983
|
const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
|
|
1061
984
|
const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
|
|
1062
985
|
if (backendMessage.length > 0) {
|
|
@@ -1097,7 +1020,7 @@ function ProcessingStep({
|
|
|
1097
1020
|
const intervalRef = _react.useRef.call(void 0, null);
|
|
1098
1021
|
_react.useEffect.call(void 0, () => {
|
|
1099
1022
|
if (directTransfer) {
|
|
1100
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1023
|
+
_optionalChain([onDepositComplete, 'optionalCall', _53 => _53(txHash)]);
|
|
1101
1024
|
return;
|
|
1102
1025
|
}
|
|
1103
1026
|
}, [directTransfer, txHash, onDepositComplete]);
|
|
@@ -1140,45 +1063,45 @@ function ProcessingStep({
|
|
|
1140
1063
|
console.log("[deposit-modal] status poll", {
|
|
1141
1064
|
type: lastEvent2.type,
|
|
1142
1065
|
matchesTx: eventMatchesTx,
|
|
1143
|
-
intentId: _optionalChain([eventData, 'optionalAccess',
|
|
1066
|
+
intentId: _optionalChain([eventData, 'optionalAccess', _54 => _54.intentId]),
|
|
1144
1067
|
data: eventData
|
|
1145
1068
|
});
|
|
1146
1069
|
}
|
|
1147
1070
|
if (!isMounted) return;
|
|
1148
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1071
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _55 => _55.type]) === "bridge-complete") {
|
|
1149
1072
|
setState({ type: "complete", lastEvent: eventForCurrentTx });
|
|
1150
|
-
const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access',
|
|
1151
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1073
|
+
const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _56 => _56.data, 'optionalAccess', _57 => _57.destination, 'optionalAccess', _58 => _58.transactionHash]);
|
|
1074
|
+
_optionalChain([onDepositComplete, 'optionalCall', _59 => _59(txHash, destinationTxHash2)]);
|
|
1152
1075
|
return;
|
|
1153
1076
|
}
|
|
1154
|
-
if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1077
|
+
if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _60 => _60.type]) === "bridge-started") {
|
|
1155
1078
|
setState({ type: "complete", lastEvent: eventForCurrentTx });
|
|
1156
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1079
|
+
_optionalChain([onDepositComplete, 'optionalCall', _61 => _61(txHash)]);
|
|
1157
1080
|
return;
|
|
1158
1081
|
}
|
|
1159
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1082
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _62 => _62.type]) === "bridge-failed") {
|
|
1160
1083
|
const formatted = formatBridgeFailedMessage(eventForCurrentTx);
|
|
1161
1084
|
setState({
|
|
1162
1085
|
type: "failed",
|
|
1163
1086
|
message: formatted.message,
|
|
1164
1087
|
lastEvent: eventForCurrentTx
|
|
1165
1088
|
});
|
|
1166
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
1089
|
+
_optionalChain([onDepositFailed, 'optionalCall', _63 => _63(txHash, formatted.message)]);
|
|
1167
1090
|
return;
|
|
1168
1091
|
}
|
|
1169
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1170
|
-
const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access',
|
|
1092
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _64 => _64.type]) === "error") {
|
|
1093
|
+
const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _65 => _65.data, 'optionalAccess', _66 => _66.message]), () => ( "Unknown error"));
|
|
1171
1094
|
setState({
|
|
1172
1095
|
type: "failed",
|
|
1173
1096
|
message: errorMessage,
|
|
1174
1097
|
lastEvent: eventForCurrentTx
|
|
1175
1098
|
});
|
|
1176
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
1099
|
+
_optionalChain([onDepositFailed, 'optionalCall', _67 => _67(txHash, errorMessage)]);
|
|
1177
1100
|
return;
|
|
1178
1101
|
}
|
|
1179
1102
|
setState({ type: "processing", lastEvent: eventForCurrentTx });
|
|
1180
1103
|
scheduleNextPoll();
|
|
1181
|
-
} catch (
|
|
1104
|
+
} catch (e4) {
|
|
1182
1105
|
scheduleNextPoll();
|
|
1183
1106
|
}
|
|
1184
1107
|
}
|
|
@@ -1221,7 +1144,7 @@ function ProcessingStep({
|
|
|
1221
1144
|
processTimeoutRef.current = setTimeout(() => {
|
|
1222
1145
|
const message = "We couldn't confirm your transfer. Please contact support if funds do not arrive.";
|
|
1223
1146
|
setState({ type: "error", message });
|
|
1224
|
-
_optionalChain([onError, 'optionalCall',
|
|
1147
|
+
_optionalChain([onError, 'optionalCall', _68 => _68(message, "PROCESS_TIMEOUT")]);
|
|
1225
1148
|
}, PROCESS_TIMEOUT_MS);
|
|
1226
1149
|
return () => {
|
|
1227
1150
|
if (processTimeoutRef.current) {
|
|
@@ -1234,10 +1157,10 @@ function ProcessingStep({
|
|
|
1234
1157
|
const isComplete = state.type === "complete";
|
|
1235
1158
|
const isProcessing = state.type === "processing";
|
|
1236
1159
|
const lastEvent = state.type === "processing" || state.type === "complete" || state.type === "failed" ? state.lastEvent : void 0;
|
|
1237
|
-
const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess',
|
|
1160
|
+
const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _69 => _69.type]) === "bridge-started";
|
|
1238
1161
|
const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
|
|
1239
1162
|
const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
|
|
1240
|
-
const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess',
|
|
1163
|
+
const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _70 => _70.data, 'optionalAccess', _71 => _71.destination, 'optionalAccess', _72 => _72.transactionHash]) || null;
|
|
1241
1164
|
const sourceExplorerUrl = _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, sourceChain, txHash);
|
|
1242
1165
|
const destExplorerUrl = destinationTxHash ? _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
|
|
1243
1166
|
const truncateHash = (hash) => `${hash.slice(0, 10)}...${hash.slice(-8)}`;
|
|
@@ -1255,7 +1178,7 @@ function ProcessingStep({
|
|
|
1255
1178
|
const numeric = Number(raw);
|
|
1256
1179
|
if (!Number.isFinite(numeric)) return raw;
|
|
1257
1180
|
return numeric.toLocaleString("en-US", { maximumFractionDigits: 6 });
|
|
1258
|
-
} catch (
|
|
1181
|
+
} catch (e5) {
|
|
1259
1182
|
return Number(amount).toLocaleString("en-US", {
|
|
1260
1183
|
maximumFractionDigits: 6
|
|
1261
1184
|
});
|
|
@@ -1470,7 +1393,7 @@ function ProcessingStep({
|
|
|
1470
1393
|
{
|
|
1471
1394
|
className: `rs-step-description ${isError ? "rs-text-error" : "rs-text-secondary"}`,
|
|
1472
1395
|
children: [
|
|
1473
|
-
state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess',
|
|
1396
|
+
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)}.`),
|
|
1474
1397
|
state.type === "failed" && state.message,
|
|
1475
1398
|
state.type === "error" && state.message
|
|
1476
1399
|
]
|
|
@@ -1641,8 +1564,4 @@ function getPublicClient(chainId) {
|
|
|
1641
1564
|
|
|
1642
1565
|
|
|
1643
1566
|
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
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.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;
|
|
1567
|
+
exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.createDepositService = createDepositService; exports.buildSessionDetails = buildSessionDetails; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; 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;
|