@rhinestone/deposit-modal 0.1.24 → 0.1.25
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-4A5HJK74.mjs +33 -0
- package/dist/DepositModalReown-QQ6WI265.cjs +33 -0
- package/dist/WithdrawModalReown-HBORIX2O.mjs +33 -0
- package/dist/WithdrawModalReown-L77OC26X.cjs +33 -0
- package/dist/{chunk-O3I5KVXA.cjs → chunk-4QDHXCPG.cjs} +97 -81
- package/dist/chunk-6VJ2ZTNQ.cjs +90 -0
- package/dist/{chunk-35DWLO33.mjs → chunk-B3HMNWR4.mjs} +61 -45
- package/dist/{chunk-ANQQMGNN.cjs → chunk-CZWAKYDR.cjs} +230 -115
- package/dist/{chunk-P7SQQAAF.mjs → chunk-GAFLOODV.mjs} +203 -88
- package/dist/{chunk-ZMVCDFXM.mjs → chunk-JAR372KJ.mjs} +48 -40
- package/dist/chunk-LBEP3A2Z.mjs +90 -0
- package/dist/{chunk-A2PDOYYE.cjs → chunk-VBNFP3JF.cjs} +89 -81
- 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
|
|
@@ -151,21 +153,6 @@ function createDepositService(baseUrl) {
|
|
|
151
153
|
return `${normalizedBaseUrl}${normalizedPath}`;
|
|
152
154
|
}
|
|
153
155
|
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
|
-
},
|
|
169
156
|
async registerAccount(params) {
|
|
170
157
|
const { eoaAddress, sessionOwner, ...account } = params;
|
|
171
158
|
const response = await fetch(apiUrl("/register"), {
|
|
@@ -246,58 +233,40 @@ function createDepositService(baseUrl) {
|
|
|
246
233
|
return { lastEvent: void 0 };
|
|
247
234
|
}
|
|
248
235
|
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
236
|
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
237
|
+
async relayWithdraw(params) {
|
|
238
|
+
const { smartAccount, chainId, safeAddress, safeTransaction, signature } = params;
|
|
239
|
+
const response = await fetch(apiUrl(`/relay-withdraw`), {
|
|
240
|
+
method: "POST",
|
|
241
|
+
headers: { "Content-Type": "application/json" },
|
|
242
|
+
body: JSON.stringify(
|
|
243
|
+
{
|
|
244
|
+
chainId,
|
|
245
|
+
safeAddress,
|
|
246
|
+
safeTransaction: {
|
|
247
|
+
to: safeTransaction.to,
|
|
248
|
+
value: safeTransaction.value.toString(),
|
|
249
|
+
data: safeTransaction.data,
|
|
250
|
+
operation: safeTransaction.operation,
|
|
251
|
+
safeTxGas: safeTransaction.safeTxGas.toString(),
|
|
252
|
+
baseGas: safeTransaction.baseGas.toString(),
|
|
253
|
+
gasPrice: safeTransaction.gasPrice.toString(),
|
|
254
|
+
gasToken: safeTransaction.gasToken,
|
|
255
|
+
refundReceiver: safeTransaction.refundReceiver,
|
|
256
|
+
nonce: safeTransaction.nonce.toString()
|
|
257
|
+
},
|
|
258
|
+
signature
|
|
259
|
+
},
|
|
260
|
+
jsonReplacer
|
|
261
|
+
)
|
|
262
|
+
});
|
|
263
|
+
if (!response.ok) {
|
|
264
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
265
|
+
throw new Error(
|
|
266
|
+
error.error || `Relay withdraw failed: ${response.status}`
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return response.json();
|
|
301
270
|
}
|
|
302
271
|
};
|
|
303
272
|
}
|
|
@@ -386,23 +355,6 @@ function extractTokenAddress(tokenData, chainId) {
|
|
|
386
355
|
const token = tokenData;
|
|
387
356
|
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
357
|
}
|
|
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
358
|
function extractArray(data, key) {
|
|
407
359
|
if (!data || typeof data !== "object") return null;
|
|
408
360
|
const record = data;
|
|
@@ -455,7 +407,7 @@ function safeBigInt(value) {
|
|
|
455
407
|
if (!value) return BigInt(0);
|
|
456
408
|
try {
|
|
457
409
|
return BigInt(value);
|
|
458
|
-
} catch (
|
|
410
|
+
} catch (e) {
|
|
459
411
|
return BigInt(0);
|
|
460
412
|
}
|
|
461
413
|
}
|
|
@@ -851,12 +803,171 @@ function ConnectStep({
|
|
|
851
803
|
}
|
|
852
804
|
ConnectStep.displayName = "ConnectStep";
|
|
853
805
|
|
|
854
|
-
// src/core/
|
|
806
|
+
// src/core/account.ts
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
var _sdk = require('@rhinestone/sdk');
|
|
855
810
|
var _viem = require('viem');
|
|
811
|
+
var _accounts = require('viem/accounts');
|
|
812
|
+
function createViewOnlyAccount(address) {
|
|
813
|
+
if (!address || address === _viem.zeroAddress) {
|
|
814
|
+
throw new Error("Address is required");
|
|
815
|
+
}
|
|
816
|
+
return _accounts.toAccount.call(void 0, {
|
|
817
|
+
address,
|
|
818
|
+
signMessage: async () => {
|
|
819
|
+
throw new Error("Account is view-only");
|
|
820
|
+
},
|
|
821
|
+
signTransaction: async () => {
|
|
822
|
+
throw new Error("Account is view-only");
|
|
823
|
+
},
|
|
824
|
+
signTypedData: async () => {
|
|
825
|
+
throw new Error("Account is view-only");
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
function getSessionSignerAccount(signerAddress) {
|
|
830
|
+
if (!signerAddress || signerAddress === _viem.zeroAddress) {
|
|
831
|
+
throw new Error("Signer address is required");
|
|
832
|
+
}
|
|
833
|
+
return _accounts.toAccount.call(void 0, {
|
|
834
|
+
address: signerAddress,
|
|
835
|
+
signMessage: async () => {
|
|
836
|
+
throw new Error("Session signer is view-only");
|
|
837
|
+
},
|
|
838
|
+
signTransaction: async () => {
|
|
839
|
+
throw new Error("Session signer is view-only");
|
|
840
|
+
},
|
|
841
|
+
signTypedData: async () => {
|
|
842
|
+
throw new Error("Session signer is view-only");
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
function buildSession(chain, signerAddress) {
|
|
847
|
+
const sessionSignerAccount = getSessionSignerAccount(signerAddress);
|
|
848
|
+
return {
|
|
849
|
+
owners: {
|
|
850
|
+
type: "ecdsa",
|
|
851
|
+
accounts: [sessionSignerAccount]
|
|
852
|
+
},
|
|
853
|
+
chain
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
async function createSmartAccount(userSigner, sessionSigner, sdkApiKey) {
|
|
857
|
+
const rhinestone = new (0, _sdk.RhinestoneSDK)({
|
|
858
|
+
apiKey: _nullishCoalesce(sdkApiKey, () => ( ""))
|
|
859
|
+
});
|
|
860
|
+
const ownerAccounts = sessionSigner ? [userSigner, sessionSigner] : [userSigner];
|
|
861
|
+
const config = {
|
|
862
|
+
account: {
|
|
863
|
+
type: "nexus"
|
|
864
|
+
},
|
|
865
|
+
owners: {
|
|
866
|
+
type: "ecdsa",
|
|
867
|
+
accounts: ownerAccounts,
|
|
868
|
+
...sessionSigner ? { threshold: 1 } : {}
|
|
869
|
+
},
|
|
870
|
+
experimental_sessions: {
|
|
871
|
+
enabled: true
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
const account = await rhinestone.createAccount(config);
|
|
875
|
+
return account;
|
|
876
|
+
}
|
|
877
|
+
function getAccountAddress(account) {
|
|
878
|
+
return account.getAddress();
|
|
879
|
+
}
|
|
880
|
+
function getAccountInitData(account) {
|
|
881
|
+
const { factory, factoryData } = account.getInitData();
|
|
882
|
+
if (!factory) {
|
|
883
|
+
throw new Error("Account init data is not available");
|
|
884
|
+
}
|
|
885
|
+
return {
|
|
886
|
+
factory,
|
|
887
|
+
factoryData
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
async function signEnableSessionWithOwner(rhinestoneAccount, sessionDetails, signer) {
|
|
891
|
+
const originalOwners = rhinestoneAccount.config.owners;
|
|
892
|
+
rhinestoneAccount.config.owners = {
|
|
893
|
+
type: "ecdsa",
|
|
894
|
+
accounts: [signer],
|
|
895
|
+
threshold: 1,
|
|
896
|
+
..._optionalChain([originalOwners, 'optionalAccess', _41 => _41.type]) === "ecdsa" && originalOwners.module ? { module: originalOwners.module } : {}
|
|
897
|
+
};
|
|
898
|
+
try {
|
|
899
|
+
return await rhinestoneAccount.experimental_signEnableSession(
|
|
900
|
+
sessionDetails
|
|
901
|
+
);
|
|
902
|
+
} finally {
|
|
903
|
+
rhinestoneAccount.config.owners = originalOwners;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
async function getSessionDetails(rhinestoneAccount, targetChain, signerAddress, sessionSigner, targetToken, sessionChainIds) {
|
|
907
|
+
const isTargetTestnet = Boolean(targetChain.testnet);
|
|
908
|
+
const chainsByNetworkType = _chunkCEIWN53Ncjs.SUPPORTED_CHAINS.filter(
|
|
909
|
+
(chain) => Boolean(chain.testnet) === isTargetTestnet
|
|
910
|
+
);
|
|
911
|
+
const chainsById = new Map(
|
|
912
|
+
chainsByNetworkType.map((chain) => [chain.id, chain])
|
|
913
|
+
);
|
|
914
|
+
let selectedChains = [...chainsByNetworkType];
|
|
915
|
+
if (sessionChainIds && sessionChainIds.length > 0) {
|
|
916
|
+
const selectedByCaller = [];
|
|
917
|
+
for (const chainId of sessionChainIds) {
|
|
918
|
+
const chain = chainsById.get(chainId);
|
|
919
|
+
if (chain) {
|
|
920
|
+
selectedByCaller.push(chain);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (selectedByCaller.length > 0) {
|
|
924
|
+
selectedChains = selectedByCaller;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (targetToken) {
|
|
928
|
+
const targetSymbol = _chunkCEIWN53Ncjs.getTokenSymbol.call(void 0,
|
|
929
|
+
targetToken,
|
|
930
|
+
targetChain.id
|
|
931
|
+
).toUpperCase();
|
|
932
|
+
if (targetSymbol && targetSymbol !== "TOKEN") {
|
|
933
|
+
const chainsForToken = selectedChains.filter(
|
|
934
|
+
(chain) => _chunkCEIWN53Ncjs.getSupportedTokenSymbolsForChain.call(void 0, chain.id).includes(targetSymbol)
|
|
935
|
+
);
|
|
936
|
+
if (chainsForToken.length > 0) {
|
|
937
|
+
selectedChains = chainsForToken;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
if (!selectedChains.some((c) => c.id === targetChain.id)) {
|
|
942
|
+
selectedChains.push(targetChain);
|
|
943
|
+
}
|
|
944
|
+
const uniqueChains = Array.from(
|
|
945
|
+
new Map(selectedChains.map((chain) => [chain.id, chain])).values()
|
|
946
|
+
);
|
|
947
|
+
const sessions = uniqueChains.map(
|
|
948
|
+
(chain) => buildSession(chain, signerAddress)
|
|
949
|
+
);
|
|
950
|
+
const sessionDetails = await rhinestoneAccount.experimental_getSessionDetails(sessions);
|
|
951
|
+
const enableSignature = sessionSigner ? await signEnableSessionWithOwner(
|
|
952
|
+
rhinestoneAccount,
|
|
953
|
+
sessionDetails,
|
|
954
|
+
sessionSigner
|
|
955
|
+
) : await rhinestoneAccount.experimental_signEnableSession(sessionDetails);
|
|
956
|
+
if (!_optionalChain([sessionDetails, 'access', _42 => _42.hashesAndChainIds, 'optionalAccess', _43 => _43.length])) {
|
|
957
|
+
throw new Error("Session details missing chain digests");
|
|
958
|
+
}
|
|
959
|
+
return {
|
|
960
|
+
hashesAndChainIds: sessionDetails.hashesAndChainIds,
|
|
961
|
+
signature: enableSignature
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// src/core/session-owner.ts
|
|
966
|
+
|
|
967
|
+
|
|
856
968
|
|
|
857
969
|
|
|
858
970
|
|
|
859
|
-
var _accounts = require('viem/accounts');
|
|
860
971
|
var STORAGE_PREFIX = "rhinestone:session-owner";
|
|
861
972
|
function storageKey(eoaAddress) {
|
|
862
973
|
return `${STORAGE_PREFIX}:${eoaAddress.toLowerCase()}`;
|
|
@@ -873,7 +984,7 @@ function loadSessionOwnerFromStorage(eoaAddress) {
|
|
|
873
984
|
privateKey: parsed.privateKey,
|
|
874
985
|
address: account.address
|
|
875
986
|
};
|
|
876
|
-
} catch (
|
|
987
|
+
} catch (e2) {
|
|
877
988
|
return null;
|
|
878
989
|
}
|
|
879
990
|
}
|
|
@@ -942,29 +1053,29 @@ function PoweredBy() {
|
|
|
942
1053
|
}
|
|
943
1054
|
|
|
944
1055
|
// src/core/webhook.ts
|
|
945
|
-
function
|
|
1056
|
+
function isRecord(value) {
|
|
946
1057
|
return typeof value === "object" && value !== null;
|
|
947
1058
|
}
|
|
948
1059
|
function asString(value) {
|
|
949
1060
|
return typeof value === "string" ? value : void 0;
|
|
950
1061
|
}
|
|
951
1062
|
function getEventTxHash(event) {
|
|
952
|
-
if (!_optionalChain([event, 'optionalAccess',
|
|
1063
|
+
if (!_optionalChain([event, 'optionalAccess', _44 => _44.type])) return void 0;
|
|
953
1064
|
if (event.type === "deposit-received") {
|
|
954
|
-
return asString(_optionalChain([event, 'access',
|
|
1065
|
+
return asString(_optionalChain([event, 'access', _45 => _45.data, 'optionalAccess', _46 => _46.transactionHash]));
|
|
955
1066
|
}
|
|
956
1067
|
if (event.type === "bridge-started" || event.type === "bridge-complete") {
|
|
957
|
-
const deposit =
|
|
958
|
-
return asString(_optionalChain([deposit, 'optionalAccess',
|
|
1068
|
+
const deposit = isRecord(_optionalChain([event, 'access', _47 => _47.data, 'optionalAccess', _48 => _48.deposit])) ? event.data.deposit : void 0;
|
|
1069
|
+
return asString(_optionalChain([deposit, 'optionalAccess', _49 => _49.transactionHash]));
|
|
959
1070
|
}
|
|
960
1071
|
if (event.type === "bridge-failed" || event.type === "error") {
|
|
961
|
-
const deposit =
|
|
962
|
-
return asString(_optionalChain([deposit, 'optionalAccess',
|
|
1072
|
+
const deposit = isRecord(_optionalChain([event, 'access', _50 => _50.data, 'optionalAccess', _51 => _51.deposit])) ? event.data.deposit : void 0;
|
|
1073
|
+
return asString(_optionalChain([deposit, 'optionalAccess', _52 => _52.transactionHash]));
|
|
963
1074
|
}
|
|
964
1075
|
return void 0;
|
|
965
1076
|
}
|
|
966
1077
|
function isDepositEvent(event) {
|
|
967
|
-
return _optionalChain([event, 'optionalAccess',
|
|
1078
|
+
return _optionalChain([event, 'optionalAccess', _53 => _53.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _54 => _54.type]) === "bridge-started";
|
|
968
1079
|
}
|
|
969
1080
|
|
|
970
1081
|
// src/components/steps/ProcessingStep.tsx
|
|
@@ -979,7 +1090,7 @@ function isEventForTx(event, txHash) {
|
|
|
979
1090
|
return eventTxHash.toLowerCase() === txHash.toLowerCase();
|
|
980
1091
|
}
|
|
981
1092
|
function formatBridgeFailedMessage(event) {
|
|
982
|
-
const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess',
|
|
1093
|
+
const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _55 => _55.data]), () => ( {}));
|
|
983
1094
|
const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
|
|
984
1095
|
const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
|
|
985
1096
|
if (backendMessage.length > 0) {
|
|
@@ -1020,7 +1131,7 @@ function ProcessingStep({
|
|
|
1020
1131
|
const intervalRef = _react.useRef.call(void 0, null);
|
|
1021
1132
|
_react.useEffect.call(void 0, () => {
|
|
1022
1133
|
if (directTransfer) {
|
|
1023
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1134
|
+
_optionalChain([onDepositComplete, 'optionalCall', _56 => _56(txHash)]);
|
|
1024
1135
|
return;
|
|
1025
1136
|
}
|
|
1026
1137
|
}, [directTransfer, txHash, onDepositComplete]);
|
|
@@ -1063,45 +1174,45 @@ function ProcessingStep({
|
|
|
1063
1174
|
console.log("[deposit-modal] status poll", {
|
|
1064
1175
|
type: lastEvent2.type,
|
|
1065
1176
|
matchesTx: eventMatchesTx,
|
|
1066
|
-
intentId: _optionalChain([eventData, 'optionalAccess',
|
|
1177
|
+
intentId: _optionalChain([eventData, 'optionalAccess', _57 => _57.intentId]),
|
|
1067
1178
|
data: eventData
|
|
1068
1179
|
});
|
|
1069
1180
|
}
|
|
1070
1181
|
if (!isMounted) return;
|
|
1071
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1182
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _58 => _58.type]) === "bridge-complete") {
|
|
1072
1183
|
setState({ type: "complete", lastEvent: eventForCurrentTx });
|
|
1073
|
-
const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access',
|
|
1074
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1184
|
+
const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _59 => _59.data, 'optionalAccess', _60 => _60.destination, 'optionalAccess', _61 => _61.transactionHash]);
|
|
1185
|
+
_optionalChain([onDepositComplete, 'optionalCall', _62 => _62(txHash, destinationTxHash2)]);
|
|
1075
1186
|
return;
|
|
1076
1187
|
}
|
|
1077
|
-
if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1188
|
+
if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _63 => _63.type]) === "bridge-started") {
|
|
1078
1189
|
setState({ type: "complete", lastEvent: eventForCurrentTx });
|
|
1079
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
1190
|
+
_optionalChain([onDepositComplete, 'optionalCall', _64 => _64(txHash)]);
|
|
1080
1191
|
return;
|
|
1081
1192
|
}
|
|
1082
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1193
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _65 => _65.type]) === "bridge-failed") {
|
|
1083
1194
|
const formatted = formatBridgeFailedMessage(eventForCurrentTx);
|
|
1084
1195
|
setState({
|
|
1085
1196
|
type: "failed",
|
|
1086
1197
|
message: formatted.message,
|
|
1087
1198
|
lastEvent: eventForCurrentTx
|
|
1088
1199
|
});
|
|
1089
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
1200
|
+
_optionalChain([onDepositFailed, 'optionalCall', _66 => _66(txHash, formatted.message)]);
|
|
1090
1201
|
return;
|
|
1091
1202
|
}
|
|
1092
|
-
if (_optionalChain([eventForCurrentTx, 'optionalAccess',
|
|
1093
|
-
const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access',
|
|
1203
|
+
if (_optionalChain([eventForCurrentTx, 'optionalAccess', _67 => _67.type]) === "error") {
|
|
1204
|
+
const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _68 => _68.data, 'optionalAccess', _69 => _69.message]), () => ( "Unknown error"));
|
|
1094
1205
|
setState({
|
|
1095
1206
|
type: "failed",
|
|
1096
1207
|
message: errorMessage,
|
|
1097
1208
|
lastEvent: eventForCurrentTx
|
|
1098
1209
|
});
|
|
1099
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
1210
|
+
_optionalChain([onDepositFailed, 'optionalCall', _70 => _70(txHash, errorMessage)]);
|
|
1100
1211
|
return;
|
|
1101
1212
|
}
|
|
1102
1213
|
setState({ type: "processing", lastEvent: eventForCurrentTx });
|
|
1103
1214
|
scheduleNextPoll();
|
|
1104
|
-
} catch (
|
|
1215
|
+
} catch (e3) {
|
|
1105
1216
|
scheduleNextPoll();
|
|
1106
1217
|
}
|
|
1107
1218
|
}
|
|
@@ -1144,7 +1255,7 @@ function ProcessingStep({
|
|
|
1144
1255
|
processTimeoutRef.current = setTimeout(() => {
|
|
1145
1256
|
const message = "We couldn't confirm your transfer. Please contact support if funds do not arrive.";
|
|
1146
1257
|
setState({ type: "error", message });
|
|
1147
|
-
_optionalChain([onError, 'optionalCall',
|
|
1258
|
+
_optionalChain([onError, 'optionalCall', _71 => _71(message, "PROCESS_TIMEOUT")]);
|
|
1148
1259
|
}, PROCESS_TIMEOUT_MS);
|
|
1149
1260
|
return () => {
|
|
1150
1261
|
if (processTimeoutRef.current) {
|
|
@@ -1157,10 +1268,10 @@ function ProcessingStep({
|
|
|
1157
1268
|
const isComplete = state.type === "complete";
|
|
1158
1269
|
const isProcessing = state.type === "processing";
|
|
1159
1270
|
const lastEvent = state.type === "processing" || state.type === "complete" || state.type === "failed" ? state.lastEvent : void 0;
|
|
1160
|
-
const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess',
|
|
1271
|
+
const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _72 => _72.type]) === "bridge-started";
|
|
1161
1272
|
const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
|
|
1162
1273
|
const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
|
|
1163
|
-
const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess',
|
|
1274
|
+
const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _73 => _73.data, 'optionalAccess', _74 => _74.destination, 'optionalAccess', _75 => _75.transactionHash]) || null;
|
|
1164
1275
|
const sourceExplorerUrl = _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, sourceChain, txHash);
|
|
1165
1276
|
const destExplorerUrl = destinationTxHash ? _chunkCEIWN53Ncjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
|
|
1166
1277
|
const truncateHash = (hash) => `${hash.slice(0, 10)}...${hash.slice(-8)}`;
|
|
@@ -1178,7 +1289,7 @@ function ProcessingStep({
|
|
|
1178
1289
|
const numeric = Number(raw);
|
|
1179
1290
|
if (!Number.isFinite(numeric)) return raw;
|
|
1180
1291
|
return numeric.toLocaleString("en-US", { maximumFractionDigits: 6 });
|
|
1181
|
-
} catch (
|
|
1292
|
+
} catch (e4) {
|
|
1182
1293
|
return Number(amount).toLocaleString("en-US", {
|
|
1183
1294
|
maximumFractionDigits: 6
|
|
1184
1295
|
});
|
|
@@ -1393,7 +1504,7 @@ function ProcessingStep({
|
|
|
1393
1504
|
{
|
|
1394
1505
|
className: `rs-step-description ${isError ? "rs-text-error" : "rs-text-secondary"}`,
|
|
1395
1506
|
children: [
|
|
1396
|
-
state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess',
|
|
1507
|
+
state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess', _76 => _76.type]) === "deposit-received" ? "Transfer received. Preparing bridge..." : _optionalChain([lastEvent, 'optionalAccess', _77 => _77.type]) === "bridge-started" ? "Transfer confirmed. Funds arriving shortly..." : `Bridging your ${flowNoun} to ${_chunkCEIWN53Ncjs.getChainName.call(void 0, targetChain)}.`),
|
|
1397
1508
|
state.type === "failed" && state.message,
|
|
1398
1509
|
state.type === "error" && state.message
|
|
1399
1510
|
]
|
|
@@ -1564,4 +1675,8 @@ function getPublicClient(chainId) {
|
|
|
1564
1675
|
|
|
1565
1676
|
|
|
1566
1677
|
|
|
1567
|
-
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
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;
|