@rhinestone/deposit-modal 0.12.1 → 0.13.0
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 +30 -16
- package/dist/ClaimModal-CREZO27I.mjs +11 -0
- package/dist/ClaimModal-JRIA32U2.cjs +11 -0
- package/dist/{DepositModalReown-SXAXHYTN.mjs → DepositModalReown-3H75G3XQ.mjs} +44 -22
- package/dist/{DepositModalReown-CH6FUTCR.cjs → DepositModalReown-YNNHLAV2.cjs} +57 -35
- package/dist/{QRCode-WUC652SH.mjs → QRCode-5RGIZZHL.mjs} +1 -1
- package/dist/{QRCode-5DXFNKI2.cjs → QRCode-JKXG4RHN.cjs} +2 -2
- package/dist/WithdrawModal-NVRX44IZ.mjs +10 -0
- package/dist/WithdrawModal-YYSBPCJJ.cjs +10 -0
- package/dist/{chunk-2BOEUV6B.cjs → chunk-2G2EIN4A.cjs} +1510 -896
- package/dist/{chunk-O7BCVQ6L.cjs → chunk-4KCSH4T3.cjs} +157 -199
- package/dist/{chunk-UGK4JRK6.cjs → chunk-5NUIKYSF.cjs} +83 -209
- package/dist/{chunk-ZLCY33FQ.cjs → chunk-7N77GIP4.cjs} +102 -88
- package/dist/{chunk-PVWZN66D.mjs → chunk-COCBCQQC.mjs} +121 -86
- package/dist/chunk-CVGNCUVU.cjs +154 -0
- package/dist/{chunk-KPWB2JAX.mjs → chunk-DSIZNRWA.mjs} +1540 -926
- package/dist/{chunk-75DVGSAX.cjs → chunk-DW2EQA2U.cjs} +6 -3
- package/dist/{chunk-2K44IE3V.mjs → chunk-EOMT5LKX.mjs} +374 -151
- package/dist/chunk-FZ5FZFIG.mjs +31 -0
- package/dist/chunk-GACIGCSN.cjs +31 -0
- package/dist/{chunk-TYBMAUGH.cjs → chunk-HOGZKHHY.cjs} +3 -3
- package/dist/{chunk-TQWEGW3A.mjs → chunk-LTMMETAB.mjs} +29 -15
- package/dist/{chunk-O4AXBFHU.mjs → chunk-OLCD75JK.mjs} +20 -146
- package/dist/{chunk-FKHPVLJY.cjs → chunk-RAADLTSW.cjs} +240 -205
- package/dist/{chunk-4ZXQPFNU.mjs → chunk-RN5VKWI6.mjs} +4 -1
- package/dist/{chunk-3STTWRAN.mjs → chunk-VUATPOWJ.mjs} +147 -189
- package/dist/{chunk-NHGFU3WC.mjs → chunk-XYJFEN5D.mjs} +1 -1
- package/dist/chunk-YREVFB64.mjs +154 -0
- package/dist/{chunk-65MLWUQD.cjs → chunk-ZMT4ATHR.cjs} +437 -214
- package/dist/claim.cjs +7 -6
- package/dist/claim.d.cts +11 -3
- package/dist/claim.d.ts +11 -3
- package/dist/claim.mjs +6 -5
- package/dist/{constants-FuzG3h4m.d.cts → constants-DBrWhJWE.d.cts} +12 -7
- package/dist/{constants-FuzG3h4m.d.ts → constants-DBrWhJWE.d.ts} +12 -7
- package/dist/constants.cjs +3 -9
- package/dist/constants.d.cts +2 -3
- package/dist/constants.d.ts +2 -3
- package/dist/constants.mjs +4 -10
- package/dist/deposit.cjs +8 -8
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +7 -7
- package/dist/embed.cjs +1268 -0
- package/dist/embed.d.cts +177 -0
- package/dist/embed.d.ts +177 -0
- package/dist/embed.mjs +1268 -0
- package/dist/index.cjs +11 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +14 -19
- package/dist/modal-ui-state-OD1RmKkK.d.cts +30 -0
- package/dist/modal-ui-state-OD1RmKkK.d.ts +30 -0
- package/dist/polymarket.cjs +17 -7
- package/dist/polymarket.mjs +13 -3
- package/dist/styles.css +133 -98
- package/dist/{types-oFblf65g.d.ts → types-B89I8_8H.d.ts} +27 -1
- package/dist/{types-BO4iP6fG.d.cts → types-nnDR4tqA.d.cts} +27 -1
- package/dist/withdraw.cjs +6 -6
- package/dist/withdraw.d.cts +11 -3
- package/dist/withdraw.d.ts +11 -3
- package/dist/withdraw.mjs +5 -5
- package/package.json +33 -1
- package/dist/chunk-DMYA7U53.cjs +0 -11
- package/dist/chunk-O2TQLD4I.mjs +0 -11
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
serviceHeaders
|
|
3
|
+
} from "./chunk-FZ5FZFIG.mjs";
|
|
4
4
|
import {
|
|
5
|
-
CHAIN_BY_ID,
|
|
6
5
|
CHAIN_DISPLAY_ORDER,
|
|
7
6
|
HYPERCORE_CHAIN_ID,
|
|
8
|
-
HYPERCORE_MAINNET_CAIP2,
|
|
9
7
|
HYPERCORE_SOURCE_TOKENS,
|
|
10
8
|
HYPERCORE_SPOT_CAIP2,
|
|
11
9
|
ICON_CDN,
|
|
@@ -27,7 +25,7 @@ import {
|
|
|
27
25
|
setRuntimeTokens,
|
|
28
26
|
toEvmCaip2,
|
|
29
27
|
tokenIconUrl
|
|
30
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-VUATPOWJ.mjs";
|
|
31
29
|
|
|
32
30
|
// src/components/ui/Modal.tsx
|
|
33
31
|
import {
|
|
@@ -172,9 +170,6 @@ import {
|
|
|
172
170
|
ArrowRight,
|
|
173
171
|
ArrowUpRight,
|
|
174
172
|
AlertTriangle,
|
|
175
|
-
Percent,
|
|
176
|
-
Clock,
|
|
177
|
-
CirclePlus,
|
|
178
173
|
CircleArrowOutUpLeft,
|
|
179
174
|
CreditCard,
|
|
180
175
|
Landmark,
|
|
@@ -218,9 +213,6 @@ var InfoIcon = Info;
|
|
|
218
213
|
var CopyIcon = Copy;
|
|
219
214
|
var ArrowUpRightIcon = ArrowUpRight;
|
|
220
215
|
var AlertTriangleIcon = AlertTriangle;
|
|
221
|
-
var PercentIcon = Percent;
|
|
222
|
-
var ClockIcon = Clock;
|
|
223
|
-
var PlusCircleIcon = CirclePlus;
|
|
224
216
|
var CircleArrowOutUpLeftIcon = CircleArrowOutUpLeft;
|
|
225
217
|
var CardIcon = CreditCard;
|
|
226
218
|
var BankIcon = Landmark;
|
|
@@ -467,7 +459,7 @@ function normalizeForLog(value, depth = 0) {
|
|
|
467
459
|
const output = {};
|
|
468
460
|
for (const [key, raw] of Object.entries(input)) {
|
|
469
461
|
const keyLower = key.toLowerCase();
|
|
470
|
-
if (keyLower.includes("signature") || keyLower.includes("privatekey") || keyLower.includes("sessiondetails")) {
|
|
462
|
+
if (keyLower.includes("signature") || keyLower.includes("privatekey") || keyLower.includes("sessiondetails") || keyLower.includes("rpcurl") || keyLower.includes("apikey") || keyLower.includes("authorization")) {
|
|
471
463
|
output[key] = "[Redacted]";
|
|
472
464
|
continue;
|
|
473
465
|
}
|
|
@@ -579,17 +571,14 @@ function parseChainCatalog(body) {
|
|
|
579
571
|
return { all, byCaip2, byChainId };
|
|
580
572
|
}
|
|
581
573
|
function aliasHyperCoreOrigin(byCaip2, all) {
|
|
574
|
+
if (byCaip2.has(HYPERCORE_SPOT_CAIP2)) return;
|
|
582
575
|
const origin = all.find((c) => isHyperCoreCaip2(c.caip2) && c.deposit) ?? all.find((c) => isHyperCoreCaip2(c.caip2));
|
|
583
|
-
if (
|
|
584
|
-
byCaip2.set(HYPERCORE_MAINNET_CAIP2, origin);
|
|
585
|
-
if (!byCaip2.has(HYPERCORE_SPOT_CAIP2)) {
|
|
586
|
-
byCaip2.set(HYPERCORE_SPOT_CAIP2, origin);
|
|
587
|
-
}
|
|
576
|
+
if (origin) byCaip2.set(HYPERCORE_SPOT_CAIP2, origin);
|
|
588
577
|
}
|
|
589
578
|
function catalogKeyForChain(chainId) {
|
|
590
579
|
if (chainId === "solana") return SOLANA_MAINNET_CAIP2;
|
|
591
580
|
if (chainId === "hypercore" || chainId === HYPERCORE_CHAIN_ID) {
|
|
592
|
-
return
|
|
581
|
+
return HYPERCORE_SPOT_CAIP2;
|
|
593
582
|
}
|
|
594
583
|
return chainId;
|
|
595
584
|
}
|
|
@@ -817,7 +806,8 @@ function parseQuoteOutput(raw) {
|
|
|
817
806
|
};
|
|
818
807
|
}
|
|
819
808
|
function parseFeeLine(raw) {
|
|
820
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
809
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
810
|
+
return null;
|
|
821
811
|
const line = raw;
|
|
822
812
|
const usd = line.usd;
|
|
823
813
|
if (typeof usd !== "number" || !Number.isFinite(usd) || usd < 0) return null;
|
|
@@ -854,6 +844,13 @@ function resolveAppFeeBps(appFees, sourceChainCaip2, sourceToken) {
|
|
|
854
844
|
const bps = override ?? appFees?.feeBps ?? 0;
|
|
855
845
|
return bps > 0 ? bps : 0;
|
|
856
846
|
}
|
|
847
|
+
var PermitDepositSubmitError = class extends Error {
|
|
848
|
+
constructor(message, safeToTransfer) {
|
|
849
|
+
super(message);
|
|
850
|
+
this.safeToTransfer = safeToTransfer;
|
|
851
|
+
this.name = "PermitDepositSubmitError";
|
|
852
|
+
}
|
|
853
|
+
};
|
|
857
854
|
function createDepositService(baseUrl, options) {
|
|
858
855
|
const normalizedBaseUrl = baseUrl.replace(/\/$/, "");
|
|
859
856
|
const debug = options?.debug === true;
|
|
@@ -894,7 +891,7 @@ function createDepositService(baseUrl, options) {
|
|
|
894
891
|
try {
|
|
895
892
|
const response = await fetch(apiUrl("/qr/tokens"), {
|
|
896
893
|
method: "GET",
|
|
897
|
-
headers:
|
|
894
|
+
headers: serviceHeaders()
|
|
898
895
|
});
|
|
899
896
|
if (!response.ok) {
|
|
900
897
|
debugLog(debug, scope, "getTopTokens:unavailable", {
|
|
@@ -921,7 +918,7 @@ function createDepositService(baseUrl, options) {
|
|
|
921
918
|
try {
|
|
922
919
|
const response = await fetch(apiUrl("/chains"), {
|
|
923
920
|
method: "GET",
|
|
924
|
-
headers:
|
|
921
|
+
headers: serviceHeaders()
|
|
925
922
|
});
|
|
926
923
|
if (!response.ok) {
|
|
927
924
|
debugLog(debug, scope, "getChains:unavailable", {
|
|
@@ -975,18 +972,15 @@ function createDepositService(baseUrl, options) {
|
|
|
975
972
|
});
|
|
976
973
|
const response = await fetch(url, {
|
|
977
974
|
method: "POST",
|
|
978
|
-
headers:
|
|
975
|
+
headers: serviceHeaders(),
|
|
979
976
|
body: JSON.stringify({ account: params })
|
|
980
977
|
});
|
|
981
978
|
if (!response.ok) {
|
|
982
979
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
983
|
-
debugError(
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
error,
|
|
988
|
-
{ status: response.status, salt: params.salt }
|
|
989
|
-
);
|
|
980
|
+
debugError(debug, scope, "registerManagedAccount:failed", error, {
|
|
981
|
+
status: response.status,
|
|
982
|
+
salt: params.salt
|
|
983
|
+
});
|
|
990
984
|
const detail = Array.isArray(error.details) ? error.details.map((d) => d?.message).filter(Boolean).join("; ") : void 0;
|
|
991
985
|
const base = error.error || `Account registration failed: ${response.status}`;
|
|
992
986
|
throw new Error(detail ? `${base}: ${detail}` : base);
|
|
@@ -1003,100 +997,104 @@ function createDepositService(baseUrl, options) {
|
|
|
1003
997
|
};
|
|
1004
998
|
},
|
|
1005
999
|
async fetchPortfolio(address, options2) {
|
|
1006
|
-
return cachedPortfolio(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1015
|
-
debugError(
|
|
1016
|
-
debug,
|
|
1017
|
-
scope,
|
|
1018
|
-
"fetchPortfolio:failed",
|
|
1019
|
-
error,
|
|
1020
|
-
{ status: response.status, address }
|
|
1021
|
-
);
|
|
1022
|
-
throw new Error(
|
|
1023
|
-
error.error || `Portfolio fetch failed: ${response.status}`
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
|
-
const data = await response.json();
|
|
1027
|
-
const direct = normalizeDirectPortfolio(data);
|
|
1028
|
-
if (direct.tokens.length > 0) {
|
|
1029
|
-
debugLog(debug, scope, "fetchPortfolio:success", {
|
|
1030
|
-
address,
|
|
1031
|
-
source: "direct",
|
|
1032
|
-
tokenCount: direct.tokens.length,
|
|
1033
|
-
totalUsd: direct.totalUsd
|
|
1000
|
+
return cachedPortfolio(
|
|
1001
|
+
`evm:${address.toLowerCase()}`,
|
|
1002
|
+
async () => {
|
|
1003
|
+
const url = apiUrl(`/portfolio/${address}?includeUnsupported=true`);
|
|
1004
|
+
debugLog(debug, scope, "fetchPortfolio:request", { url, address });
|
|
1005
|
+
const response = await fetch(url, {
|
|
1006
|
+
method: "GET",
|
|
1007
|
+
headers: serviceHeaders()
|
|
1034
1008
|
});
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1009
|
+
if (!response.ok) {
|
|
1010
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1011
|
+
debugError(debug, scope, "fetchPortfolio:failed", error, {
|
|
1012
|
+
status: response.status,
|
|
1013
|
+
address
|
|
1014
|
+
});
|
|
1015
|
+
throw new Error(
|
|
1016
|
+
error.error || `Portfolio fetch failed: ${response.status}`
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
const data = await response.json();
|
|
1020
|
+
const direct = normalizeDirectPortfolio(data);
|
|
1021
|
+
if (direct.tokens.length > 0) {
|
|
1022
|
+
debugLog(debug, scope, "fetchPortfolio:success", {
|
|
1023
|
+
address,
|
|
1024
|
+
source: "direct",
|
|
1025
|
+
tokenCount: direct.tokens.length,
|
|
1026
|
+
totalUsd: direct.totalUsd
|
|
1027
|
+
});
|
|
1028
|
+
return direct;
|
|
1029
|
+
}
|
|
1030
|
+
const portfolioData = extractOrchestratorPortfolio(data);
|
|
1031
|
+
if (portfolioData) {
|
|
1032
|
+
const normalized = normalizeOrchestratorPortfolio(portfolioData);
|
|
1033
|
+
debugLog(debug, scope, "fetchPortfolio:success", {
|
|
1034
|
+
address,
|
|
1035
|
+
source: "orchestrator",
|
|
1036
|
+
tokenCount: normalized.tokens.length,
|
|
1037
|
+
totalUsd: normalized.totalUsd
|
|
1038
|
+
});
|
|
1039
|
+
return normalized;
|
|
1040
|
+
}
|
|
1041
|
+
debugLog(debug, scope, "fetchPortfolio:empty", { address });
|
|
1042
|
+
return { tokens: [], totalUsd: 0 };
|
|
1043
|
+
},
|
|
1044
|
+
options2?.forceRefresh
|
|
1045
|
+
);
|
|
1046
|
+
},
|
|
1047
|
+
async fetchSolanaPortfolio(address, options2) {
|
|
1048
|
+
return cachedPortfolio(
|
|
1049
|
+
`sol:${address}`,
|
|
1050
|
+
async () => {
|
|
1051
|
+
const url = apiUrl(`/portfolio/solana/${address}`);
|
|
1052
|
+
debugLog(debug, scope, "fetchSolanaPortfolio:request", {
|
|
1053
|
+
url,
|
|
1054
|
+
address
|
|
1055
|
+
});
|
|
1056
|
+
const response = await fetch(url, {
|
|
1057
|
+
method: "GET",
|
|
1058
|
+
headers: serviceHeaders()
|
|
1059
|
+
});
|
|
1060
|
+
if (!response.ok) {
|
|
1061
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1062
|
+
debugError(debug, scope, "fetchSolanaPortfolio:failed", error, {
|
|
1063
|
+
status: response.status,
|
|
1064
|
+
address
|
|
1065
|
+
});
|
|
1066
|
+
throw new Error(
|
|
1067
|
+
error.error || `Solana portfolio fetch failed: ${response.status}`
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
const data = await response.json();
|
|
1071
|
+
const normalized = normalizeDirectPortfolio(data);
|
|
1072
|
+
debugLog(debug, scope, "fetchSolanaPortfolio:success", {
|
|
1041
1073
|
address,
|
|
1042
|
-
source: "orchestrator",
|
|
1043
1074
|
tokenCount: normalized.tokens.length,
|
|
1044
1075
|
totalUsd: normalized.totalUsd
|
|
1045
1076
|
});
|
|
1046
1077
|
return normalized;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
}, options2?.forceRefresh);
|
|
1051
|
-
},
|
|
1052
|
-
async fetchSolanaPortfolio(address, options2) {
|
|
1053
|
-
return cachedPortfolio(`sol:${address}`, async () => {
|
|
1054
|
-
const url = apiUrl(`/portfolio/solana/${address}`);
|
|
1055
|
-
debugLog(debug, scope, "fetchSolanaPortfolio:request", { url, address });
|
|
1056
|
-
const response = await fetch(url, {
|
|
1057
|
-
method: "GET",
|
|
1058
|
-
headers: SERVICE_HEADERS
|
|
1059
|
-
});
|
|
1060
|
-
if (!response.ok) {
|
|
1061
|
-
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1062
|
-
debugError(
|
|
1063
|
-
debug,
|
|
1064
|
-
scope,
|
|
1065
|
-
"fetchSolanaPortfolio:failed",
|
|
1066
|
-
error,
|
|
1067
|
-
{ status: response.status, address }
|
|
1068
|
-
);
|
|
1069
|
-
throw new Error(
|
|
1070
|
-
error.error || `Solana portfolio fetch failed: ${response.status}`
|
|
1071
|
-
);
|
|
1072
|
-
}
|
|
1073
|
-
const data = await response.json();
|
|
1074
|
-
const normalized = normalizeDirectPortfolio(data);
|
|
1075
|
-
debugLog(debug, scope, "fetchSolanaPortfolio:success", {
|
|
1076
|
-
address,
|
|
1077
|
-
tokenCount: normalized.tokens.length,
|
|
1078
|
-
totalUsd: normalized.totalUsd
|
|
1079
|
-
});
|
|
1080
|
-
return normalized;
|
|
1081
|
-
}, options2?.forceRefresh);
|
|
1078
|
+
},
|
|
1079
|
+
options2?.forceRefresh
|
|
1080
|
+
);
|
|
1082
1081
|
},
|
|
1083
1082
|
async checkAccount(address) {
|
|
1084
1083
|
const url = apiUrl(`/check/${address}`);
|
|
1085
1084
|
debugLog(debug, scope, "checkAccount:request", { url, address });
|
|
1086
1085
|
const response = await fetch(url, {
|
|
1087
1086
|
method: "GET",
|
|
1088
|
-
headers:
|
|
1087
|
+
headers: serviceHeaders()
|
|
1089
1088
|
});
|
|
1090
1089
|
if (!response.ok) {
|
|
1091
1090
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1092
|
-
debugError(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1091
|
+
debugError(debug, scope, "checkAccount:failed", error, {
|
|
1092
|
+
status: response.status,
|
|
1093
|
+
address
|
|
1094
|
+
});
|
|
1095
|
+
throw new Error(
|
|
1096
|
+
error.error || `Account check failed: ${response.status}`
|
|
1098
1097
|
);
|
|
1099
|
-
throw new Error(error.error || `Account check failed: ${response.status}`);
|
|
1100
1098
|
}
|
|
1101
1099
|
const data = await response.json();
|
|
1102
1100
|
const result = {
|
|
@@ -1116,11 +1114,13 @@ function createDepositService(baseUrl, options) {
|
|
|
1116
1114
|
const normalized = txHash.startsWith("0x") || txHash.startsWith("0X") ? txHash.toLowerCase() : txHash;
|
|
1117
1115
|
const txHashParam = encodeURIComponent(normalized);
|
|
1118
1116
|
const url = apiUrl(
|
|
1119
|
-
`/deposits?account=${encodeURIComponent(
|
|
1117
|
+
`/deposits?account=${encodeURIComponent(
|
|
1118
|
+
address
|
|
1119
|
+
)}&txHash=${txHashParam}&limit=1`
|
|
1120
1120
|
);
|
|
1121
1121
|
const response = await fetch(url, {
|
|
1122
1122
|
method: "GET",
|
|
1123
|
-
headers:
|
|
1123
|
+
headers: serviceHeaders(),
|
|
1124
1124
|
cache: "no-store"
|
|
1125
1125
|
});
|
|
1126
1126
|
if (!response.ok) {
|
|
@@ -1148,7 +1148,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1148
1148
|
);
|
|
1149
1149
|
const response = await fetch(url, {
|
|
1150
1150
|
method: "GET",
|
|
1151
|
-
headers:
|
|
1151
|
+
headers: serviceHeaders(),
|
|
1152
1152
|
cache: "no-store"
|
|
1153
1153
|
});
|
|
1154
1154
|
if (!response.ok) {
|
|
@@ -1172,7 +1172,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1172
1172
|
);
|
|
1173
1173
|
const response = await fetch(url, {
|
|
1174
1174
|
method: "GET",
|
|
1175
|
-
headers:
|
|
1175
|
+
headers: serviceHeaders(),
|
|
1176
1176
|
cache: "no-store"
|
|
1177
1177
|
});
|
|
1178
1178
|
if (!response.ok) {
|
|
@@ -1194,7 +1194,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1194
1194
|
async getPositions(address) {
|
|
1195
1195
|
const url = apiUrl(`/positions/${address}`);
|
|
1196
1196
|
debugLog(debug, scope, "getPositions:request", { url, address });
|
|
1197
|
-
const response = await fetch(url, { headers:
|
|
1197
|
+
const response = await fetch(url, { headers: serviceHeaders() });
|
|
1198
1198
|
if (!response.ok) {
|
|
1199
1199
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1200
1200
|
debugError(debug, scope, "getPositions:failed", error, {
|
|
@@ -1228,7 +1228,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1228
1228
|
});
|
|
1229
1229
|
const response = await fetch(url, {
|
|
1230
1230
|
method: "POST",
|
|
1231
|
-
headers:
|
|
1231
|
+
headers: serviceHeaders(),
|
|
1232
1232
|
body: JSON.stringify({ account, market, chainId, asset, amount })
|
|
1233
1233
|
});
|
|
1234
1234
|
if (!response.ok) {
|
|
@@ -1264,7 +1264,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1264
1264
|
});
|
|
1265
1265
|
const response = await fetch(url, {
|
|
1266
1266
|
method: "POST",
|
|
1267
|
-
headers:
|
|
1267
|
+
headers: serviceHeaders(),
|
|
1268
1268
|
body: JSON.stringify({
|
|
1269
1269
|
depositWallet,
|
|
1270
1270
|
owner,
|
|
@@ -1306,18 +1306,15 @@ function createDepositService(baseUrl, options) {
|
|
|
1306
1306
|
});
|
|
1307
1307
|
const response = await fetch(url, {
|
|
1308
1308
|
method: "GET",
|
|
1309
|
-
headers:
|
|
1309
|
+
headers: serviceHeaders(),
|
|
1310
1310
|
cache: "no-store"
|
|
1311
1311
|
});
|
|
1312
1312
|
if (!response.ok) {
|
|
1313
1313
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1314
|
-
debugError(
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
error,
|
|
1319
|
-
{ status: response.status, recipient: shortRef(params.recipient) }
|
|
1320
|
-
);
|
|
1314
|
+
debugError(debug, scope, "fetchDepositHistory:failed", error, {
|
|
1315
|
+
status: response.status,
|
|
1316
|
+
recipient: shortRef(params.recipient)
|
|
1317
|
+
});
|
|
1321
1318
|
throw new Error(
|
|
1322
1319
|
error.error || `Deposit history fetch failed: ${response.status}`
|
|
1323
1320
|
);
|
|
@@ -1359,7 +1356,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1359
1356
|
});
|
|
1360
1357
|
const response = await fetch(url, {
|
|
1361
1358
|
method: "GET",
|
|
1362
|
-
headers:
|
|
1359
|
+
headers: serviceHeaders(),
|
|
1363
1360
|
cache: "no-store"
|
|
1364
1361
|
});
|
|
1365
1362
|
if (!response.ok) {
|
|
@@ -1391,7 +1388,10 @@ function createDepositService(baseUrl, options) {
|
|
|
1391
1388
|
const body = {
|
|
1392
1389
|
account: params.account,
|
|
1393
1390
|
// HyperCore has its own CAIP-2 namespace — never the eip155 placeholder.
|
|
1394
|
-
|
|
1391
|
+
// The branch is unreachable against today's processor whatever venue it
|
|
1392
|
+
// names: `sourceToken` is validated as a 20-byte 0x address on every
|
|
1393
|
+
// chain, and a HyperCore source token is a 16-byte Core spot tokenId.
|
|
1394
|
+
sourceChainId: params.sourceChainId === "hypercore" ? HYPERCORE_SPOT_CAIP2 : `eip155:${params.sourceChainId}`,
|
|
1395
1395
|
sourceToken: params.sourceToken,
|
|
1396
1396
|
amount: params.amount
|
|
1397
1397
|
};
|
|
@@ -1404,7 +1404,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1404
1404
|
try {
|
|
1405
1405
|
const response = await fetch(url, {
|
|
1406
1406
|
method: "POST",
|
|
1407
|
-
headers:
|
|
1407
|
+
headers: serviceHeaders(),
|
|
1408
1408
|
body: JSON.stringify(body),
|
|
1409
1409
|
cache: "no-store"
|
|
1410
1410
|
});
|
|
@@ -1432,6 +1432,154 @@ function createDepositService(baseUrl, options) {
|
|
|
1432
1432
|
return null;
|
|
1433
1433
|
}
|
|
1434
1434
|
},
|
|
1435
|
+
async preparePermitDeposit(params) {
|
|
1436
|
+
const url = apiUrl("/deposits/permit/prepare");
|
|
1437
|
+
debugLog(debug, scope, "preparePermitDeposit:request", {
|
|
1438
|
+
url,
|
|
1439
|
+
account: shortRef(params.account),
|
|
1440
|
+
sourceChain: params.sourceChain,
|
|
1441
|
+
token: params.token,
|
|
1442
|
+
amount: params.amount
|
|
1443
|
+
});
|
|
1444
|
+
try {
|
|
1445
|
+
const response = await fetch(url, {
|
|
1446
|
+
method: "POST",
|
|
1447
|
+
headers: serviceHeaders(),
|
|
1448
|
+
body: JSON.stringify({ ...params, kind: "auto" }),
|
|
1449
|
+
cache: "no-store"
|
|
1450
|
+
});
|
|
1451
|
+
if (!response.ok) {
|
|
1452
|
+
debugLog(debug, scope, "preparePermitDeposit:unavailable", {
|
|
1453
|
+
status: response.status
|
|
1454
|
+
});
|
|
1455
|
+
return null;
|
|
1456
|
+
}
|
|
1457
|
+
const data = await response.json();
|
|
1458
|
+
if (!data || typeof data.available !== "boolean") {
|
|
1459
|
+
debugLog(debug, scope, "preparePermitDeposit:unavailable", {
|
|
1460
|
+
status: response.status,
|
|
1461
|
+
reason: "malformed"
|
|
1462
|
+
});
|
|
1463
|
+
return null;
|
|
1464
|
+
}
|
|
1465
|
+
if (data.available === false) {
|
|
1466
|
+
const reason = data.reason;
|
|
1467
|
+
if (reason !== "permit2-approval-required" && reason !== "unsupported-token" && reason !== "unsupported-owner") {
|
|
1468
|
+
return null;
|
|
1469
|
+
}
|
|
1470
|
+
debugLog(debug, scope, "preparePermitDeposit:unavailable", {
|
|
1471
|
+
status: response.status,
|
|
1472
|
+
reason
|
|
1473
|
+
});
|
|
1474
|
+
const approval = data.approval;
|
|
1475
|
+
const parsedApproval = approval && typeof approval.token === "string" && typeof approval.spender === "string" && typeof approval.minimumAmount === "string" ? {
|
|
1476
|
+
token: approval.token,
|
|
1477
|
+
spender: approval.spender,
|
|
1478
|
+
minimumAmount: approval.minimumAmount
|
|
1479
|
+
} : void 0;
|
|
1480
|
+
return {
|
|
1481
|
+
available: false,
|
|
1482
|
+
reason,
|
|
1483
|
+
...parsedApproval && { approval: parsedApproval }
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
const authorization = data.authorization;
|
|
1487
|
+
if (!authorization || typeof authorization.typedData !== "object" || authorization.typedData === null || typeof authorization.nonce !== "string") {
|
|
1488
|
+
return null;
|
|
1489
|
+
}
|
|
1490
|
+
if (authorization.kind === "erc3009" && typeof authorization.validAfter === "string" && typeof authorization.validBefore === "string") {
|
|
1491
|
+
debugLog(debug, scope, "preparePermitDeposit:success", {
|
|
1492
|
+
kind: authorization.kind,
|
|
1493
|
+
nonce: authorization.nonce
|
|
1494
|
+
});
|
|
1495
|
+
return {
|
|
1496
|
+
available: true,
|
|
1497
|
+
authorization: {
|
|
1498
|
+
kind: "erc3009",
|
|
1499
|
+
typedData: authorization.typedData,
|
|
1500
|
+
nonce: authorization.nonce,
|
|
1501
|
+
validAfter: authorization.validAfter,
|
|
1502
|
+
validBefore: authorization.validBefore
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
if ((authorization.kind === "erc2612" || authorization.kind === "permit2") && typeof authorization.deadline === "string") {
|
|
1507
|
+
debugLog(debug, scope, "preparePermitDeposit:success", {
|
|
1508
|
+
kind: authorization.kind,
|
|
1509
|
+
nonce: authorization.nonce
|
|
1510
|
+
});
|
|
1511
|
+
return {
|
|
1512
|
+
available: true,
|
|
1513
|
+
authorization: {
|
|
1514
|
+
kind: authorization.kind,
|
|
1515
|
+
typedData: authorization.typedData,
|
|
1516
|
+
nonce: authorization.nonce,
|
|
1517
|
+
deadline: authorization.deadline
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
return null;
|
|
1522
|
+
} catch (error) {
|
|
1523
|
+
debugError(debug, scope, "preparePermitDeposit:error", error);
|
|
1524
|
+
return null;
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
async submitPermitDeposit(params) {
|
|
1528
|
+
const url = apiUrl("/deposits/permit");
|
|
1529
|
+
debugLog(debug, scope, "submitPermitDeposit:request", {
|
|
1530
|
+
url,
|
|
1531
|
+
account: shortRef(params.account),
|
|
1532
|
+
sourceChain: params.sourceChain,
|
|
1533
|
+
token: params.token,
|
|
1534
|
+
amount: params.amount,
|
|
1535
|
+
nonce: params.nonce
|
|
1536
|
+
});
|
|
1537
|
+
let response;
|
|
1538
|
+
try {
|
|
1539
|
+
response = await fetch(url, {
|
|
1540
|
+
method: "POST",
|
|
1541
|
+
headers: serviceHeaders(),
|
|
1542
|
+
body: JSON.stringify(params)
|
|
1543
|
+
});
|
|
1544
|
+
} catch (error) {
|
|
1545
|
+
const message = error instanceof Error ? error.message : "Network error";
|
|
1546
|
+
throw new PermitDepositSubmitError(message, false);
|
|
1547
|
+
}
|
|
1548
|
+
if (!response.ok) {
|
|
1549
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1550
|
+
debugError(debug, scope, "submitPermitDeposit:failed", error, {
|
|
1551
|
+
status: response.status,
|
|
1552
|
+
account: shortRef(params.account)
|
|
1553
|
+
});
|
|
1554
|
+
const safeToTransfer = [400, 401, 403, 404, 422].includes(
|
|
1555
|
+
response.status
|
|
1556
|
+
);
|
|
1557
|
+
throw new PermitDepositSubmitError(
|
|
1558
|
+
error.error || `Permit deposit failed: ${response.status}`,
|
|
1559
|
+
safeToTransfer
|
|
1560
|
+
);
|
|
1561
|
+
}
|
|
1562
|
+
const result = await response.json();
|
|
1563
|
+
if (typeof result?.txHash !== "string" || result.txHash.length === 0) {
|
|
1564
|
+
debugError(debug, scope, "submitPermitDeposit:failed", result, {
|
|
1565
|
+
reason: "missing txHash"
|
|
1566
|
+
});
|
|
1567
|
+
throw new PermitDepositSubmitError(
|
|
1568
|
+
"Permit deposit response missing txHash",
|
|
1569
|
+
false
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
1572
|
+
debugLog(debug, scope, "submitPermitDeposit:success", {
|
|
1573
|
+
depositId: result.depositId,
|
|
1574
|
+
txHash: shortRef(result.txHash),
|
|
1575
|
+
status: result.status
|
|
1576
|
+
});
|
|
1577
|
+
return {
|
|
1578
|
+
depositId: result.depositId ?? "",
|
|
1579
|
+
txHash: result.txHash,
|
|
1580
|
+
status: result.status ?? "processing"
|
|
1581
|
+
};
|
|
1582
|
+
},
|
|
1435
1583
|
async fetchPrices(symbols) {
|
|
1436
1584
|
const list = symbols.filter((s) => s.length > 0);
|
|
1437
1585
|
if (list.length === 0) return {};
|
|
@@ -1441,7 +1589,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1441
1589
|
try {
|
|
1442
1590
|
const response = await fetch(url, {
|
|
1443
1591
|
method: "GET",
|
|
1444
|
-
headers:
|
|
1592
|
+
headers: serviceHeaders(),
|
|
1445
1593
|
cache: "no-store"
|
|
1446
1594
|
});
|
|
1447
1595
|
if (!response.ok) {
|
|
@@ -1466,12 +1614,14 @@ function createDepositService(baseUrl, options) {
|
|
|
1466
1614
|
const list = caip2Ids.filter((id) => id.length > 0);
|
|
1467
1615
|
if (list.length === 0) return {};
|
|
1468
1616
|
const url = apiUrl(
|
|
1469
|
-
`/prices?${new URLSearchParams({
|
|
1617
|
+
`/prices?${new URLSearchParams({
|
|
1618
|
+
addresses: list.join(",")
|
|
1619
|
+
}).toString()}`
|
|
1470
1620
|
);
|
|
1471
1621
|
try {
|
|
1472
1622
|
const response = await fetch(url, {
|
|
1473
1623
|
method: "GET",
|
|
1474
|
-
headers:
|
|
1624
|
+
headers: serviceHeaders(),
|
|
1475
1625
|
cache: "no-store"
|
|
1476
1626
|
});
|
|
1477
1627
|
if (!response.ok) {
|
|
@@ -1496,7 +1646,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1496
1646
|
});
|
|
1497
1647
|
const response = await fetch(url, {
|
|
1498
1648
|
method: "POST",
|
|
1499
|
-
headers:
|
|
1649
|
+
headers: serviceHeaders(),
|
|
1500
1650
|
body: JSON.stringify(params)
|
|
1501
1651
|
});
|
|
1502
1652
|
if (!response.ok) {
|
|
@@ -1528,7 +1678,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1528
1678
|
});
|
|
1529
1679
|
const response = await fetch(url, {
|
|
1530
1680
|
method: "POST",
|
|
1531
|
-
headers:
|
|
1681
|
+
headers: serviceHeaders(),
|
|
1532
1682
|
body: JSON.stringify(params)
|
|
1533
1683
|
});
|
|
1534
1684
|
if (!response.ok) {
|
|
@@ -1565,7 +1715,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1565
1715
|
debugLog(debug, scope, "getSwappedConnectExchanges:request");
|
|
1566
1716
|
const response = await fetch(url, {
|
|
1567
1717
|
method: "GET",
|
|
1568
|
-
headers:
|
|
1718
|
+
headers: serviceHeaders(),
|
|
1569
1719
|
cache: "no-store"
|
|
1570
1720
|
});
|
|
1571
1721
|
if (!response.ok) {
|
|
@@ -1618,7 +1768,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1618
1768
|
try {
|
|
1619
1769
|
const response = await fetch(url, {
|
|
1620
1770
|
method: "GET",
|
|
1621
|
-
headers:
|
|
1771
|
+
headers: serviceHeaders(),
|
|
1622
1772
|
cache: "no-store"
|
|
1623
1773
|
});
|
|
1624
1774
|
if (!response.ok) {
|
|
@@ -1704,7 +1854,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1704
1854
|
try {
|
|
1705
1855
|
const response = await fetch(url, {
|
|
1706
1856
|
method: "GET",
|
|
1707
|
-
headers:
|
|
1857
|
+
headers: serviceHeaders(),
|
|
1708
1858
|
cache: "no-store"
|
|
1709
1859
|
});
|
|
1710
1860
|
if (!response.ok) {
|
|
@@ -1731,7 +1881,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1731
1881
|
);
|
|
1732
1882
|
const response = await fetch(url, {
|
|
1733
1883
|
method: "GET",
|
|
1734
|
-
headers:
|
|
1884
|
+
headers: serviceHeaders(),
|
|
1735
1885
|
cache: "no-store"
|
|
1736
1886
|
});
|
|
1737
1887
|
if (!response.ok) return null;
|
|
@@ -1800,9 +1950,15 @@ function normalizeOrchestratorPortfolio(data) {
|
|
|
1800
1950
|
if (!resolvedTokenAddress) {
|
|
1801
1951
|
continue;
|
|
1802
1952
|
}
|
|
1803
|
-
const registrySymbol = getTokenSymbol(
|
|
1953
|
+
const registrySymbol = getTokenSymbol(
|
|
1954
|
+
resolvedTokenAddress,
|
|
1955
|
+
chainBalance.chainId
|
|
1956
|
+
);
|
|
1804
1957
|
const symbol = registrySymbol !== "Token" ? registrySymbol : normalizedName || "Token";
|
|
1805
|
-
const decimals = registrySymbol !== "Token" ? getTokenDecimalsByAddress(
|
|
1958
|
+
const decimals = registrySymbol !== "Token" ? getTokenDecimalsByAddress(
|
|
1959
|
+
resolvedTokenAddress,
|
|
1960
|
+
chainBalance.chainId
|
|
1961
|
+
) : tokenData.tokenDecimals ?? 18;
|
|
1806
1962
|
tokens.push({
|
|
1807
1963
|
chainId: chainBalance.chainId,
|
|
1808
1964
|
address: resolvedTokenAddress,
|
|
@@ -1823,8 +1979,8 @@ function normalizeDirectToken(token) {
|
|
|
1823
1979
|
const rawChainId = extractNumber(token, "chainId") ?? extractNumber(token.chain, "id");
|
|
1824
1980
|
const rawChainString = extractString(token, "chainId") ?? extractString(token.chain, "id");
|
|
1825
1981
|
const chainId = rawChainId ?? (rawChainString ? isSolanaCaip2(rawChainString) || rawChainString.toLowerCase() === "solana" ? "solana" : (
|
|
1826
|
-
// HyperCore
|
|
1827
|
-
// instead of dropping it as an unparseable chain string.
|
|
1982
|
+
// HyperCore is a non-EVM source under its own namespace; keep its
|
|
1983
|
+
// USDC instead of dropping it as an unparseable chain string.
|
|
1828
1984
|
isHyperCoreCaip2(rawChainString) || rawChainString.toLowerCase() === "hypercore" ? "hypercore" : parseEvmChainId(rawChainString)
|
|
1829
1985
|
) : null);
|
|
1830
1986
|
if (chainId === null) return null;
|
|
@@ -1909,32 +2065,65 @@ import {
|
|
|
1909
2065
|
useContext as useContext2,
|
|
1910
2066
|
useEffect as useEffect2,
|
|
1911
2067
|
useMemo as useMemo2,
|
|
1912
|
-
useState as useState2
|
|
2068
|
+
useState as useState2,
|
|
2069
|
+
useSyncExternalStore
|
|
1913
2070
|
} from "react";
|
|
1914
2071
|
|
|
1915
2072
|
// src/core/public-client.ts
|
|
1916
2073
|
import { createPublicClient, http } from "viem";
|
|
1917
2074
|
var clientCache = /* @__PURE__ */ new Map();
|
|
1918
2075
|
var runtimeChainById = /* @__PURE__ */ new Map();
|
|
2076
|
+
var BOOTSTRAP_RPC_URL = {
|
|
2077
|
+
1: "https://eth.merkle.io",
|
|
2078
|
+
10: "https://mainnet.optimism.io",
|
|
2079
|
+
56: "https://56.rpc.thirdweb.com",
|
|
2080
|
+
100: "https://rpc.gnosischain.com",
|
|
2081
|
+
130: "https://mainnet.unichain.org",
|
|
2082
|
+
137: "https://polygon.drpc.org",
|
|
2083
|
+
143: "https://rpc.monad.xyz",
|
|
2084
|
+
146: "https://rpc.soniclabs.com",
|
|
2085
|
+
999: "https://rpc.hyperliquid.xyz/evm",
|
|
2086
|
+
1868: "https://rpc.soneium.org",
|
|
2087
|
+
8453: "https://mainnet.base.org",
|
|
2088
|
+
9745: "https://rpc.plasma.to",
|
|
2089
|
+
42161: "https://arb1.arbitrum.io/rpc",
|
|
2090
|
+
747474: "https://rpc.katana.network"
|
|
2091
|
+
};
|
|
2092
|
+
var runtimeChainsVersion = 0;
|
|
2093
|
+
var runtimeChainListeners = /* @__PURE__ */ new Set();
|
|
2094
|
+
function subscribeToRuntimeChains(listener) {
|
|
2095
|
+
runtimeChainListeners.add(listener);
|
|
2096
|
+
return () => {
|
|
2097
|
+
runtimeChainListeners.delete(listener);
|
|
2098
|
+
};
|
|
2099
|
+
}
|
|
2100
|
+
function getRuntimeChainsVersion() {
|
|
2101
|
+
return runtimeChainsVersion;
|
|
2102
|
+
}
|
|
1919
2103
|
function setRuntimeChains(chains) {
|
|
2104
|
+
let changed = false;
|
|
1920
2105
|
for (const chain of chains) {
|
|
1921
2106
|
const known = runtimeChainById.get(chain.id);
|
|
1922
2107
|
if (known === chain) continue;
|
|
1923
2108
|
runtimeChainById.set(chain.id, chain);
|
|
2109
|
+
changed = true;
|
|
1924
2110
|
for (const key of clientCache.keys()) {
|
|
1925
2111
|
if (key.startsWith(`${chain.id}|`)) clientCache.delete(key);
|
|
1926
2112
|
}
|
|
1927
2113
|
}
|
|
2114
|
+
if (!changed) return;
|
|
2115
|
+
runtimeChainsVersion += 1;
|
|
2116
|
+
for (const listener of runtimeChainListeners) listener();
|
|
1928
2117
|
}
|
|
1929
2118
|
function getPublicClient(chainId, rpcUrls) {
|
|
1930
2119
|
const url = rpcUrlFor(rpcUrls, chainId);
|
|
1931
2120
|
const cacheKey = `${chainId}|${url ?? ""}`;
|
|
1932
2121
|
let client = clientCache.get(cacheKey);
|
|
1933
2122
|
if (!client) {
|
|
1934
|
-
const chain =
|
|
2123
|
+
const chain = runtimeChainById.get(chainId);
|
|
1935
2124
|
client = createPublicClient({
|
|
1936
2125
|
chain,
|
|
1937
|
-
transport: http(url)
|
|
2126
|
+
transport: http(url ?? (chain ? void 0 : BOOTSTRAP_RPC_URL[chainId]))
|
|
1938
2127
|
});
|
|
1939
2128
|
clientCache.set(cacheKey, client);
|
|
1940
2129
|
}
|
|
@@ -2095,7 +2284,8 @@ function publishRuntimeChainMeta(catalog) {
|
|
|
2095
2284
|
chainId,
|
|
2096
2285
|
name: chain.name,
|
|
2097
2286
|
iconUrl: chain.iconUrl ?? void 0,
|
|
2098
|
-
nativeSymbol: chain.nativeToken.symbol
|
|
2287
|
+
nativeSymbol: chain.nativeToken.symbol,
|
|
2288
|
+
explorerUrl: chain.explorer?.url
|
|
2099
2289
|
}));
|
|
2100
2290
|
})
|
|
2101
2291
|
);
|
|
@@ -2204,6 +2394,20 @@ function useChainName() {
|
|
|
2204
2394
|
};
|
|
2205
2395
|
}, [catalog]);
|
|
2206
2396
|
}
|
|
2397
|
+
function useRuntimeChainsVersion() {
|
|
2398
|
+
return useSyncExternalStore(
|
|
2399
|
+
subscribeToRuntimeChains,
|
|
2400
|
+
getRuntimeChainsVersion,
|
|
2401
|
+
getRuntimeChainsVersion
|
|
2402
|
+
);
|
|
2403
|
+
}
|
|
2404
|
+
function useReadClient(chainId, rpcUrls) {
|
|
2405
|
+
const version = useRuntimeChainsVersion();
|
|
2406
|
+
return useMemo2(
|
|
2407
|
+
() => getPublicClient(chainId, rpcUrls),
|
|
2408
|
+
[chainId, rpcUrls, version]
|
|
2409
|
+
);
|
|
2410
|
+
}
|
|
2207
2411
|
function useExplorerTxUrl() {
|
|
2208
2412
|
const { catalog } = useChainCatalog();
|
|
2209
2413
|
return useMemo2(() => {
|
|
@@ -2770,15 +2974,32 @@ var CUSTOM_PRIMARY_VARS = [
|
|
|
2770
2974
|
"--rs-primary-foreground",
|
|
2771
2975
|
"--rs-border-accent"
|
|
2772
2976
|
];
|
|
2977
|
+
var DARK_SCHEME_QUERY = "(prefers-color-scheme: dark)";
|
|
2978
|
+
var NOTHING_TO_STOP = () => {
|
|
2979
|
+
};
|
|
2980
|
+
function resolveThemeMode(mode) {
|
|
2981
|
+
if (mode !== "system") return mode;
|
|
2982
|
+
return globalThis.matchMedia?.(DARK_SCHEME_QUERY).matches ? "dark" : "light";
|
|
2983
|
+
}
|
|
2984
|
+
function followSystemAppearance(mode, onChange) {
|
|
2985
|
+
if (mode !== "system") return NOTHING_TO_STOP;
|
|
2986
|
+
const query = globalThis.matchMedia?.(DARK_SCHEME_QUERY);
|
|
2987
|
+
if (!query) return NOTHING_TO_STOP;
|
|
2988
|
+
query.addEventListener("change", onChange);
|
|
2989
|
+
return () => query.removeEventListener("change", onChange);
|
|
2990
|
+
}
|
|
2773
2991
|
function applyTheme(element, theme) {
|
|
2774
|
-
if (!element) return;
|
|
2992
|
+
if (!element) return NOTHING_TO_STOP;
|
|
2775
2993
|
const parent = element.parentElement;
|
|
2776
2994
|
const targets = parent?.classList.contains("rs-modal-content") ? [element, parent] : [element];
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2995
|
+
const paintMode = () => {
|
|
2996
|
+
const resolved = resolveThemeMode(theme?.mode);
|
|
2997
|
+
for (const t of targets) {
|
|
2998
|
+
if (resolved) t.setAttribute("data-theme", resolved);
|
|
2999
|
+
else t.removeAttribute("data-theme");
|
|
3000
|
+
}
|
|
3001
|
+
};
|
|
3002
|
+
paintMode();
|
|
2782
3003
|
if (theme?.fontColor) {
|
|
2783
3004
|
setVar(targets, "--rs-foreground", theme.fontColor);
|
|
2784
3005
|
}
|
|
@@ -2828,6 +3049,7 @@ function applyTheme(element, theme) {
|
|
|
2828
3049
|
setVar(targets, "--rs-radius-lg", scale.lg);
|
|
2829
3050
|
setVar(targets, "--rs-radius", scale.md);
|
|
2830
3051
|
}
|
|
3052
|
+
return followSystemAppearance(theme?.mode, paintMode);
|
|
2831
3053
|
}
|
|
2832
3054
|
|
|
2833
3055
|
// src/core/backend-url.ts
|
|
@@ -2858,9 +3080,6 @@ export {
|
|
|
2858
3080
|
CopyIcon,
|
|
2859
3081
|
ArrowUpRightIcon,
|
|
2860
3082
|
AlertTriangleIcon,
|
|
2861
|
-
PercentIcon,
|
|
2862
|
-
ClockIcon,
|
|
2863
|
-
PlusCircleIcon,
|
|
2864
3083
|
CircleArrowOutUpLeftIcon,
|
|
2865
3084
|
CardIcon,
|
|
2866
3085
|
BankIcon,
|
|
@@ -2884,6 +3103,7 @@ export {
|
|
|
2884
3103
|
SwappedConnectFeeChangedError,
|
|
2885
3104
|
SUPPORTED_CONNECT_EXCHANGE_COUNT,
|
|
2886
3105
|
resolveAppFeeBps,
|
|
3106
|
+
PermitDepositSubmitError,
|
|
2887
3107
|
createDepositService,
|
|
2888
3108
|
rpcUrlFor,
|
|
2889
3109
|
RpcUrlsProvider,
|
|
@@ -2899,6 +3119,7 @@ export {
|
|
|
2899
3119
|
useTargetTokens,
|
|
2900
3120
|
useIsDepositChain,
|
|
2901
3121
|
useChainName,
|
|
3122
|
+
useReadClient,
|
|
2902
3123
|
useExplorerTxUrl,
|
|
2903
3124
|
ChainCatalogProvider,
|
|
2904
3125
|
useLatestRef,
|
|
@@ -2918,6 +3139,8 @@ export {
|
|
|
2918
3139
|
estimateReceiveAmount,
|
|
2919
3140
|
formatQuotedReceive,
|
|
2920
3141
|
formatReceiveEstimate,
|
|
3142
|
+
resolveThemeMode,
|
|
3143
|
+
followSystemAppearance,
|
|
2921
3144
|
applyTheme,
|
|
2922
3145
|
checkBackendUrl
|
|
2923
3146
|
};
|