@rhinestone/deposit-modal 0.1.24 → 0.1.26
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 +1 -5
- package/dist/DepositModalReown-4WZF2HMJ.mjs +33 -0
- package/dist/DepositModalReown-NKDYLTKD.cjs +33 -0
- package/dist/WithdrawModalReown-244RQ5FZ.mjs +33 -0
- package/dist/WithdrawModalReown-GL4TM22D.cjs +33 -0
- package/dist/{chunk-P7SQQAAF.mjs → chunk-3FK5FAUL.mjs} +244 -76
- package/dist/{chunk-ANQQMGNN.cjs → chunk-4Q6QCALP.cjs} +271 -103
- package/dist/{chunk-O3I5KVXA.cjs → chunk-4WULBRUA.cjs} +97 -81
- package/dist/chunk-6VJ2ZTNQ.cjs +90 -0
- package/dist/{chunk-A2PDOYYE.cjs → chunk-7QCFFKB5.cjs} +78 -68
- package/dist/{chunk-35DWLO33.mjs → chunk-DJAUNNEW.mjs} +61 -45
- package/dist/chunk-LBEP3A2Z.mjs +90 -0
- package/dist/{chunk-ZMVCDFXM.mjs → chunk-W42B54IA.mjs} +37 -27
- 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 +6 -191
- package/dist/reown.d.cts +4 -12
- package/dist/reown.d.ts +4 -12
- package/dist/reown.mjs +8 -193
- package/dist/{types-CUww05xT.d.cts → types-BwaQ7jK5.d.cts} +3 -16
- package/dist/{types-Z6GjVWFR.d.ts → types-CgXyx46m.d.ts} +3 -16
- 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 +16 -33
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
|
|
11
13
|
var _chunkCEIWN53Ncjs = require('./chunk-CEIWN53N.cjs');
|
|
12
14
|
|
|
13
15
|
// src/components/ui/Modal.tsx
|
|
@@ -155,7 +157,7 @@ function createDepositService(baseUrl) {
|
|
|
155
157
|
const response = await fetch(apiUrl("/prepare-account"), {
|
|
156
158
|
method: "POST",
|
|
157
159
|
headers: { "Content-Type": "application/json" },
|
|
158
|
-
body: JSON.stringify(params
|
|
160
|
+
body: JSON.stringify(params)
|
|
159
161
|
});
|
|
160
162
|
if (!response.ok) {
|
|
161
163
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -163,8 +165,7 @@ function createDepositService(baseUrl) {
|
|
|
163
165
|
error.error || `Prepare account failed: ${response.status}`
|
|
164
166
|
);
|
|
165
167
|
}
|
|
166
|
-
|
|
167
|
-
return normalizePrepareAccountResponse(payload);
|
|
168
|
+
return response.json();
|
|
168
169
|
},
|
|
169
170
|
async registerAccount(params) {
|
|
170
171
|
const { eoaAddress, sessionOwner, ...account } = params;
|
|
@@ -246,58 +247,40 @@ function createDepositService(baseUrl) {
|
|
|
246
247
|
return { lastEvent: void 0 };
|
|
247
248
|
}
|
|
248
249
|
return response.json();
|
|
249
|
-
}
|
|
250
|
-
};
|
|
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
250
|
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
251
|
+
async relayWithdraw(params) {
|
|
252
|
+
const { smartAccount, chainId, safeAddress, safeTransaction, signature } = params;
|
|
253
|
+
const response = await fetch(apiUrl(`/relay-withdraw`), {
|
|
254
|
+
method: "POST",
|
|
255
|
+
headers: { "Content-Type": "application/json" },
|
|
256
|
+
body: JSON.stringify(
|
|
257
|
+
{
|
|
258
|
+
chainId,
|
|
259
|
+
safeAddress,
|
|
260
|
+
safeTransaction: {
|
|
261
|
+
to: safeTransaction.to,
|
|
262
|
+
value: safeTransaction.value.toString(),
|
|
263
|
+
data: safeTransaction.data,
|
|
264
|
+
operation: safeTransaction.operation,
|
|
265
|
+
safeTxGas: safeTransaction.safeTxGas.toString(),
|
|
266
|
+
baseGas: safeTransaction.baseGas.toString(),
|
|
267
|
+
gasPrice: safeTransaction.gasPrice.toString(),
|
|
268
|
+
gasToken: safeTransaction.gasToken,
|
|
269
|
+
refundReceiver: safeTransaction.refundReceiver,
|
|
270
|
+
nonce: safeTransaction.nonce.toString()
|
|
271
|
+
},
|
|
272
|
+
signature
|
|
273
|
+
},
|
|
274
|
+
jsonReplacer
|
|
275
|
+
)
|
|
276
|
+
});
|
|
277
|
+
if (!response.ok) {
|
|
278
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
279
|
+
throw new Error(
|
|
280
|
+
error.error || `Relay withdraw failed: ${response.status}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return response.json();
|
|
301
284
|
}
|
|
302
285
|
};
|
|
303
286
|
}
|
|
@@ -386,23 +369,6 @@ function extractTokenAddress(tokenData, chainId) {
|
|
|
386
369
|
const token = tokenData;
|
|
387
370
|
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]])));
|
|
388
371
|
}
|
|
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
|
-
}
|
|
406
372
|
function extractArray(data, key) {
|
|
407
373
|
if (!data || typeof data !== "object") return null;
|
|
408
374
|
const record = data;
|
|
@@ -455,7 +421,7 @@ function safeBigInt(value) {
|
|
|
455
421
|
if (!value) return BigInt(0);
|
|
456
422
|
try {
|
|
457
423
|
return BigInt(value);
|
|
458
|
-
} catch (
|
|
424
|
+
} catch (e) {
|
|
459
425
|
return BigInt(0);
|
|
460
426
|
}
|
|
461
427
|
}
|
|
@@ -851,12 +817,209 @@ function ConnectStep({
|
|
|
851
817
|
}
|
|
852
818
|
ConnectStep.displayName = "ConnectStep";
|
|
853
819
|
|
|
854
|
-
// src/core/
|
|
820
|
+
// src/core/account.ts
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
var _sdk = require('@rhinestone/sdk');
|
|
855
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
|
+
// src/core/session-owner.ts
|
|
1018
|
+
|
|
1019
|
+
|
|
856
1020
|
|
|
857
1021
|
|
|
858
1022
|
|
|
859
|
-
var _accounts = require('viem/accounts');
|
|
860
1023
|
var STORAGE_PREFIX = "rhinestone:session-owner";
|
|
861
1024
|
function storageKey(eoaAddress) {
|
|
862
1025
|
return `${STORAGE_PREFIX}:${eoaAddress.toLowerCase()}`;
|
|
@@ -873,7 +1036,7 @@ function loadSessionOwnerFromStorage(eoaAddress) {
|
|
|
873
1036
|
privateKey: parsed.privateKey,
|
|
874
1037
|
address: account.address
|
|
875
1038
|
};
|
|
876
|
-
} catch (
|
|
1039
|
+
} catch (e2) {
|
|
877
1040
|
return null;
|
|
878
1041
|
}
|
|
879
1042
|
}
|
|
@@ -942,29 +1105,29 @@ function PoweredBy() {
|
|
|
942
1105
|
}
|
|
943
1106
|
|
|
944
1107
|
// src/core/webhook.ts
|
|
945
|
-
function
|
|
1108
|
+
function isRecord(value) {
|
|
946
1109
|
return typeof value === "object" && value !== null;
|
|
947
1110
|
}
|
|
948
1111
|
function asString(value) {
|
|
949
1112
|
return typeof value === "string" ? value : void 0;
|
|
950
1113
|
}
|
|
951
1114
|
function getEventTxHash(event) {
|
|
952
|
-
if (!_optionalChain([event, 'optionalAccess',
|
|
1115
|
+
if (!_optionalChain([event, 'optionalAccess', _45 => _45.type])) return void 0;
|
|
953
1116
|
if (event.type === "deposit-received") {
|
|
954
|
-
return asString(_optionalChain([event, 'access',
|
|
1117
|
+
return asString(_optionalChain([event, 'access', _46 => _46.data, 'optionalAccess', _47 => _47.transactionHash]));
|
|
955
1118
|
}
|
|
956
1119
|
if (event.type === "bridge-started" || event.type === "bridge-complete") {
|
|
957
|
-
const deposit =
|
|
958
|
-
return asString(_optionalChain([deposit, 'optionalAccess',
|
|
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]));
|
|
959
1122
|
}
|
|
960
1123
|
if (event.type === "bridge-failed" || event.type === "error") {
|
|
961
|
-
const deposit =
|
|
962
|
-
return asString(_optionalChain([deposit, 'optionalAccess',
|
|
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]));
|
|
963
1126
|
}
|
|
964
1127
|
return void 0;
|
|
965
1128
|
}
|
|
966
1129
|
function isDepositEvent(event) {
|
|
967
|
-
return _optionalChain([event, 'optionalAccess',
|
|
1130
|
+
return _optionalChain([event, 'optionalAccess', _54 => _54.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _55 => _55.type]) === "bridge-started";
|
|
968
1131
|
}
|
|
969
1132
|
|
|
970
1133
|
// src/components/steps/ProcessingStep.tsx
|
|
@@ -979,7 +1142,7 @@ function isEventForTx(event, txHash) {
|
|
|
979
1142
|
return eventTxHash.toLowerCase() === txHash.toLowerCase();
|
|
980
1143
|
}
|
|
981
1144
|
function formatBridgeFailedMessage(event) {
|
|
982
|
-
const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1145
|
+
const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _56 => _56.data]), () => ( {}));
|
|
983
1146
|
const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
|
|
984
1147
|
const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
|
|
985
1148
|
if (backendMessage.length > 0) {
|
|
@@ -1020,7 +1183,7 @@ function ProcessingStep({
|
|
|
1020
1183
|
const intervalRef = _react.useRef.call(void 0, null);
|
|
1021
1184
|
_react.useEffect.call(void 0, () => {
|
|
1022
1185
|
if (directTransfer) {
|
|
1023
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1186
|
+
_optionalChain([onDepositComplete, 'optionalCall', _57 => _57(txHash)]);
|
|
1024
1187
|
return;
|
|
1025
1188
|
}
|
|
1026
1189
|
}, [directTransfer, txHash, onDepositComplete]);
|
|
@@ -1063,45 +1226,45 @@ function ProcessingStep({
|
|
|
1063
1226
|
console.log("[deposit-modal] status poll", {
|
|
1064
1227
|
type: lastEvent2.type,
|
|
1065
1228
|
matchesTx: eventMatchesTx,
|
|
1066
|
-
intentId: _optionalChain([eventData, 'optionalAccess',
|
|
1229
|
+
intentId: _optionalChain([eventData, 'optionalAccess', _58 => _58.intentId]),
|
|
1067
1230
|
data: eventData
|
|
1068
1231
|
});
|
|
1069
1232
|
}
|
|
1070
1233
|
if (!isMounted) return;
|
|
1071
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1234
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _59 => _59.type]) === "bridge-complete") {
|
|
1072
1235
|
setState({ type: "complete", lastEvent: eventForCurrentTx });
|
|
1073
|
-
const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access',
|
|
1074
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
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)]);
|
|
1075
1238
|
return;
|
|
1076
1239
|
}
|
|
1077
|
-
if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1240
|
+
if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _64 => _64.type]) === "bridge-started") {
|
|
1078
1241
|
setState({ type: "complete", lastEvent: eventForCurrentTx });
|
|
1079
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1242
|
+
_optionalChain([onDepositComplete, 'optionalCall', _65 => _65(txHash)]);
|
|
1080
1243
|
return;
|
|
1081
1244
|
}
|
|
1082
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1245
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _66 => _66.type]) === "bridge-failed") {
|
|
1083
1246
|
const formatted = formatBridgeFailedMessage(eventForCurrentTx);
|
|
1084
1247
|
setState({
|
|
1085
1248
|
type: "failed",
|
|
1086
1249
|
message: formatted.message,
|
|
1087
1250
|
lastEvent: eventForCurrentTx
|
|
1088
1251
|
});
|
|
1089
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
1252
|
+
_optionalChain([onDepositFailed, 'optionalCall', _67 => _67(txHash, formatted.message)]);
|
|
1090
1253
|
return;
|
|
1091
1254
|
}
|
|
1092
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1093
|
-
const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access',
|
|
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"));
|
|
1094
1257
|
setState({
|
|
1095
1258
|
type: "failed",
|
|
1096
1259
|
message: errorMessage,
|
|
1097
1260
|
lastEvent: eventForCurrentTx
|
|
1098
1261
|
});
|
|
1099
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
1262
|
+
_optionalChain([onDepositFailed, 'optionalCall', _71 => _71(txHash, errorMessage)]);
|
|
1100
1263
|
return;
|
|
1101
1264
|
}
|
|
1102
1265
|
setState({ type: "processing", lastEvent: eventForCurrentTx });
|
|
1103
1266
|
scheduleNextPoll();
|
|
1104
|
-
} catch (
|
|
1267
|
+
} catch (e3) {
|
|
1105
1268
|
scheduleNextPoll();
|
|
1106
1269
|
}
|
|
1107
1270
|
}
|
|
@@ -1144,7 +1307,7 @@ function ProcessingStep({
|
|
|
1144
1307
|
processTimeoutRef.current = setTimeout(() => {
|
|
1145
1308
|
const message = "We couldn't confirm your transfer. Please contact support if funds do not arrive.";
|
|
1146
1309
|
setState({ type: "error", message });
|
|
1147
|
-
_optionalChain([onError, 'optionalCall',
|
|
1310
|
+
_optionalChain([onError, 'optionalCall', _72 => _72(message, "PROCESS_TIMEOUT")]);
|
|
1148
1311
|
}, PROCESS_TIMEOUT_MS);
|
|
1149
1312
|
return () => {
|
|
1150
1313
|
if (processTimeoutRef.current) {
|
|
@@ -1157,10 +1320,10 @@ function ProcessingStep({
|
|
|
1157
1320
|
const isComplete = state.type === "complete";
|
|
1158
1321
|
const isProcessing = state.type === "processing";
|
|
1159
1322
|
const lastEvent = state.type === "processing" || state.type === "complete" || state.type === "failed" ? state.lastEvent : void 0;
|
|
1160
|
-
const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess',
|
|
1323
|
+
const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _73 => _73.type]) === "bridge-started";
|
|
1161
1324
|
const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
|
|
1162
1325
|
const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
|
|
1163
|
-
const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess',
|
|
1326
|
+
const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _74 => _74.data, 'optionalAccess', _75 => _75.destination, 'optionalAccess', _76 => _76.transactionHash]) || null;
|
|
1164
1327
|
const sourceExplorerUrl = _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, sourceChain, txHash);
|
|
1165
1328
|
const destExplorerUrl = destinationTxHash ? _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
|
|
1166
1329
|
const truncateHash = (hash) => `${hash.slice(0, 10)}...${hash.slice(-8)}`;
|
|
@@ -1178,7 +1341,7 @@ function ProcessingStep({
|
|
|
1178
1341
|
const numeric = Number(raw);
|
|
1179
1342
|
if (!Number.isFinite(numeric)) return raw;
|
|
1180
1343
|
return numeric.toLocaleString("en-US", { maximumFractionDigits: 6 });
|
|
1181
|
-
} catch (
|
|
1344
|
+
} catch (e4) {
|
|
1182
1345
|
return Number(amount).toLocaleString("en-US", {
|
|
1183
1346
|
maximumFractionDigits: 6
|
|
1184
1347
|
});
|
|
@@ -1393,7 +1556,7 @@ function ProcessingStep({
|
|
|
1393
1556
|
{
|
|
1394
1557
|
className: `rs-step-description ${isError ? "rs-text-error" : "rs-text-secondary"}`,
|
|
1395
1558
|
children: [
|
|
1396
|
-
state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess',
|
|
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)}.`),
|
|
1397
1560
|
state.type === "failed" && state.message,
|
|
1398
1561
|
state.type === "error" && state.message
|
|
1399
1562
|
]
|
|
@@ -1564,4 +1727,9 @@ function getPublicClient(chainId) {
|
|
|
1564
1727
|
|
|
1565
1728
|
|
|
1566
1729
|
|
|
1567
|
-
|
|
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;
|