@rhinestone/deposit-modal 0.10.0 → 0.11.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.
Files changed (49) hide show
  1. package/dist/{DepositModalReown-MTWT6Y66.mjs → DepositModalReown-6RVLEM3B.mjs} +96 -26
  2. package/dist/{DepositModalReown-S3DSFXTX.cjs → DepositModalReown-TXTLVZIQ.cjs} +97 -27
  3. package/dist/caip-D8aRWdEY.d.cts +40 -0
  4. package/dist/caip-D8aRWdEY.d.ts +40 -0
  5. package/dist/{chunk-A223BLVC.mjs → chunk-53IFZGSF.mjs} +177 -21
  6. package/dist/{chunk-W4YAOJPG.cjs → chunk-7RNEYPI4.cjs} +614 -560
  7. package/dist/{chunk-UMCDZJMG.cjs → chunk-BLJMYCBF.cjs} +92 -90
  8. package/dist/{chunk-KW32UBUQ.mjs → chunk-DYTRG4C7.mjs} +1 -1
  9. package/dist/{chunk-LR7MKHYV.mjs → chunk-G4FVZQOM.mjs} +23 -21
  10. package/dist/{chunk-DEF767BA.cjs → chunk-GWA6GFTI.cjs} +66 -63
  11. package/dist/{chunk-A42XAHIB.cjs → chunk-HCQWFL3A.cjs} +84 -101
  12. package/dist/{chunk-7TV7GLJB.mjs → chunk-ITAYM7SB.mjs} +723 -167
  13. package/dist/{chunk-YEBXUUH3.cjs → chunk-JPRV36DT.cjs} +2 -2
  14. package/dist/{chunk-VTVOHNXM.cjs → chunk-JYKMR6QI.cjs} +3 -3
  15. package/dist/{chunk-ILT2PITN.mjs → chunk-MZ53PDIX.mjs} +1 -1
  16. package/dist/{chunk-PUJHXHRA.cjs → chunk-NPSC5R22.cjs} +805 -249
  17. package/dist/{chunk-5OEWGJR4.mjs → chunk-QRR3Y7EK.mjs} +1 -1
  18. package/dist/{chunk-H577RJN5.cjs → chunk-TENL4H64.cjs} +186 -30
  19. package/dist/{chunk-MHIOMTMM.mjs → chunk-TRD2FCAR.mjs} +140 -86
  20. package/dist/{chunk-5NJYW5FT.mjs → chunk-VRNRRN2U.mjs} +12 -9
  21. package/dist/{chunk-VDGT6NZQ.mjs → chunk-WLDTBKRA.mjs} +14 -31
  22. package/dist/{chunk-NF4NBRUP.cjs → chunk-XVKBCDZI.cjs} +1 -1
  23. package/dist/claim.cjs +6 -6
  24. package/dist/claim.d.cts +3 -2
  25. package/dist/claim.d.ts +3 -2
  26. package/dist/claim.mjs +5 -5
  27. package/dist/{caip-523Zrc3r.d.cts → constants-FuzG3h4m.d.cts} +1 -18
  28. package/dist/{caip-523Zrc3r.d.ts → constants-FuzG3h4m.d.ts} +1 -18
  29. package/dist/constants.cjs +5 -3
  30. package/dist/constants.d.cts +3 -2
  31. package/dist/constants.d.ts +3 -2
  32. package/dist/constants.mjs +4 -2
  33. package/dist/deposit.cjs +8 -8
  34. package/dist/deposit.d.cts +3 -2
  35. package/dist/deposit.d.ts +3 -2
  36. package/dist/deposit.mjs +7 -7
  37. package/dist/index.cjs +12 -10
  38. package/dist/index.d.cts +3 -2
  39. package/dist/index.d.ts +3 -2
  40. package/dist/index.mjs +11 -9
  41. package/dist/polymarket.cjs +5 -5
  42. package/dist/polymarket.mjs +2 -2
  43. package/dist/{types-C0SGf-21.d.cts → types-C7wag_iL.d.cts} +4 -3
  44. package/dist/{types-C0SGf-21.d.ts → types-D4b6Cjox.d.ts} +4 -3
  45. package/dist/withdraw.cjs +6 -6
  46. package/dist/withdraw.d.cts +3 -2
  47. package/dist/withdraw.d.ts +3 -2
  48. package/dist/withdraw.mjs +5 -5
  49. package/package.json +1 -1
@@ -6,9 +6,13 @@ function toEvmCaip2(chainId) {
6
6
  }
7
7
  function targetChainToCaip2(targetChain) {
8
8
  if (targetChain === "solana") return SOLANA_MAINNET_CAIP2;
9
- if (targetChain === HYPERCORE_CHAIN_ID) return HYPERCORE_MAINNET_CAIP2;
9
+ if (isHyperCoreDestination(targetChain)) return HYPERCORE_SPOT_CAIP2;
10
10
  return toEvmCaip2(targetChain);
11
11
  }
12
+ function targetChainToAccountKey(targetChain) {
13
+ if (isHyperCoreDestination(targetChain)) return HYPERCORE_MAINNET_CAIP2;
14
+ return targetChainToCaip2(targetChain);
15
+ }
12
16
  function parseEvmChainId(value) {
13
17
  if (typeof value === "number" && Number.isFinite(value)) {
14
18
  return value;
@@ -27,6 +31,13 @@ function isHyperCoreCaip2(value) {
27
31
  }
28
32
  var HYPERCORE_CHAIN_ID = 1337;
29
33
  var HYPERCORE_MAINNET_CAIP2 = "hypercore:mainnet";
34
+ var HYPERCORE_SPOT_CAIP2 = "hypercore:spot";
35
+ function targetChainToChainId(targetChain) {
36
+ return isHyperCoreDestination(targetChain) ? "hypercore" : targetChain;
37
+ }
38
+ function isHyperCoreDestination(targetChain) {
39
+ return targetChain === HYPERCORE_SPOT_CAIP2 || targetChain === HYPERCORE_CHAIN_ID;
40
+ }
30
41
  var HYPERCORE_USDC_ADDRESS = "0xb88339CB7199b77E23DB6E890353E22632Ba630f";
31
42
  var HYPERCORE_USDT0_ADDRESS = "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb";
32
43
  var HYPERCORE_SOURCE_TOKENS = [
@@ -35,7 +46,7 @@ var HYPERCORE_SOURCE_TOKENS = [
35
46
  ];
36
47
  var HYPERCORE_MIN_DEPOSIT_USD = 1;
37
48
  function isVirtualDestination(targetChain) {
38
- return targetChain === "solana" || targetChain === HYPERCORE_CHAIN_ID;
49
+ return targetChain === "solana" || isHyperCoreDestination(targetChain);
39
50
  }
40
51
 
41
52
  // src/core/solana-tokens.ts
@@ -81,6 +92,29 @@ import {
81
92
  soneium,
82
93
  unichain
83
94
  } from "viem/chains";
95
+
96
+ // src/core/runtime-chain-meta.ts
97
+ var byChainId = /* @__PURE__ */ new Map();
98
+ function setRuntimeChainMeta(entries) {
99
+ for (const entry of entries) {
100
+ byChainId.set(entry.chainId, {
101
+ name: entry.name,
102
+ iconUrl: entry.iconUrl,
103
+ nativeSymbol: entry.nativeSymbol
104
+ });
105
+ }
106
+ }
107
+ function getRuntimeNativeSymbol(chainId) {
108
+ return byChainId.get(chainId)?.nativeSymbol;
109
+ }
110
+ function getRuntimeChainName(chainId) {
111
+ return byChainId.get(chainId)?.name;
112
+ }
113
+ function getRuntimeChainIconUrl(chainId) {
114
+ return byChainId.get(chainId)?.iconUrl;
115
+ }
116
+
117
+ // src/core/icons.ts
84
118
  var ICON_CDN = "https://s3.rhinestone.dev";
85
119
  var CHAIN_ICON_SLUGS = {
86
120
  [mainnet.id]: "mainnet",
@@ -96,7 +130,13 @@ var CHAIN_ICON_SLUGS = {
96
130
  [hyperliquid.id]: "hypeevm",
97
131
  [monad.id]: "monad",
98
132
  [unichain.id]: "unichain",
99
- [katana.id]: "katana"
133
+ [katana.id]: "katana",
134
+ // Live deposit sources that predate this map being catalog-backed. Kept as
135
+ // plain ids rather than viem imports: this is the FALLBACK for chains the
136
+ // backend has not annotated with `iconUrl` yet, so it should not grow a
137
+ // build-time dependency on a chain definition to name a file.
138
+ 43114: "avalanche",
139
+ 4663: "robinhood"
100
140
  };
101
141
  function cdnIconUrl(dir, slug) {
102
142
  return `${ICON_CDN}/${dir}/${slug}.svg`;
@@ -113,12 +153,18 @@ function getChainIcon(chainId) {
113
153
  if (chainId === "hypercore" || chainId === HYPERCORE_CHAIN_ID) {
114
154
  return CHAIN_ICONS[hyperliquid.id];
115
155
  }
116
- return CHAIN_ICONS[chainId];
156
+ return CHAIN_ICONS[chainId] ?? getRuntimeChainIconUrl(chainId);
117
157
  }
118
158
  var ICON_SLUG_ALIASES = {
119
159
  "usdc.e": "usdc",
120
160
  wsol: "sol",
121
- xdai: "dai"
161
+ xdai: "dai",
162
+ // A wrapped token is the same asset and the CDN hosts only the underlying
163
+ // mark, so these fall back to it rather than to a text badge. `weth` is the
164
+ // one the deposit flow offers on nearly every chain, and it has been showing
165
+ // as text since the icons moved to the CDN.
166
+ weth: "eth",
167
+ wavax: "avax"
122
168
  };
123
169
  function tokenIconUrl(symbol) {
124
170
  const key = symbol.toLowerCase().replace(/₮/g, "t");
@@ -146,6 +192,70 @@ import {
146
192
  soneium as soneium2,
147
193
  unichain as unichain2
148
194
  } from "viem/chains";
195
+
196
+ // src/core/runtime-token-meta.ts
197
+ var bySymbol = /* @__PURE__ */ new Map();
198
+ var byAddress = /* @__PURE__ */ new Map();
199
+ var symbolsByChain = /* @__PURE__ */ new Map();
200
+ function symbolKey(chainId, symbol) {
201
+ return `${chainId}:${symbol.trim().toUpperCase()}`;
202
+ }
203
+ function addressKey(chainId, address) {
204
+ return `${chainId}:${address.toLowerCase()}`;
205
+ }
206
+ function setRuntimeTokens(tokens) {
207
+ for (const token of tokens) {
208
+ const sKey = symbolKey(token.chainId, token.symbol);
209
+ if (!bySymbol.has(sKey)) {
210
+ bySymbol.set(sKey, token);
211
+ const list = symbolsByChain.get(token.chainId);
212
+ if (list) list.push(token.symbol);
213
+ else symbolsByChain.set(token.chainId, [token.symbol]);
214
+ }
215
+ byAddress.set(addressKey(token.chainId, token.address), token);
216
+ }
217
+ }
218
+ function publishShortlistTokens(shortlist) {
219
+ const tokens = [];
220
+ for (const [chainKey, entries] of Object.entries(shortlist)) {
221
+ const chainId = Number(chainKey);
222
+ if (!Number.isInteger(chainId)) continue;
223
+ for (const entry of entries) {
224
+ if (!/^0x[a-fA-F0-9]{40}$/.test(entry.address)) continue;
225
+ tokens.push({
226
+ chainId,
227
+ symbol: entry.symbol,
228
+ address: entry.address,
229
+ decimals: entry.decimals
230
+ });
231
+ }
232
+ }
233
+ setRuntimeTokens(tokens);
234
+ }
235
+ function getRuntimeToken(chainId, symbol) {
236
+ return bySymbol.get(symbolKey(chainId, symbol));
237
+ }
238
+ function getRuntimeTokenByAddress(chainId, address) {
239
+ return byAddress.get(addressKey(chainId, address));
240
+ }
241
+ function getRuntimeTokenSymbols(chainId) {
242
+ return symbolsByChain.get(chainId) ?? [];
243
+ }
244
+ function findRuntimeDecimalsByAddress(address) {
245
+ return findByAddress(address)?.decimals;
246
+ }
247
+ function findRuntimeSymbolByAddress(address) {
248
+ return findByAddress(address)?.symbol;
249
+ }
250
+ function findByAddress(address) {
251
+ const suffix = `:${address.toLowerCase()}`;
252
+ for (const [key, token] of byAddress) {
253
+ if (key.endsWith(suffix)) return token;
254
+ }
255
+ return void 0;
256
+ }
257
+
258
+ // src/core/constants.ts
149
259
  var NATIVE_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
150
260
  var ALL_CHAINS_BY_ID = {
151
261
  [mainnet2.id]: mainnet2,
@@ -520,13 +630,14 @@ function normalizeTokenSymbol(symbol) {
520
630
  return trimmed.toUpperCase();
521
631
  }
522
632
  function isSymbolSupportedOnChain(symbol, chainId) {
633
+ const normalized = normalizeTokenSymbol(symbol);
523
634
  const symbols = SUPPORTED_TOKENS_BY_CHAIN[chainId];
524
- if (!symbols) return false;
525
- return symbols.includes(normalizeTokenSymbol(symbol));
635
+ if (symbols?.includes(normalized)) return true;
636
+ return getRuntimeToken(chainId, normalized) !== void 0;
526
637
  }
527
638
  function getTokenFromRegistry(chainId, symbol) {
528
639
  const chainEntry = chainRegistry[String(chainId)];
529
- if (!chainEntry) return void 0;
640
+ if (!chainEntry) return runtimeToken(chainId, normalizeTokenSymbol(symbol));
530
641
  const normalized = normalizeTokenSymbol(symbol);
531
642
  const token = chainEntry.tokens.find(
532
643
  (t) => t.symbol.toUpperCase() === normalized
@@ -534,7 +645,11 @@ function getTokenFromRegistry(chainId, symbol) {
534
645
  if (token) {
535
646
  return { address: token.address, decimals: token.decimals };
536
647
  }
537
- return void 0;
648
+ return runtimeToken(chainId, normalized);
649
+ }
650
+ function runtimeToken(chainId, symbol) {
651
+ const token = getRuntimeToken(chainId, symbol);
652
+ return token ? { address: token.address, decimals: token.decimals } : void 0;
538
653
  }
539
654
  function getUsdcAddress(chainId) {
540
655
  const token = getTokenFromRegistry(chainId, "USDC");
@@ -565,8 +680,9 @@ function getTokenDecimals(symbol, chainId) {
565
680
  return token?.decimals ?? 18;
566
681
  }
567
682
  function getTargetTokenSymbolsForChain(chainId) {
568
- const symbols = SUPPORTED_TOKENS_BY_CHAIN[chainId] ?? [];
569
- return [...symbols];
683
+ const symbols = SUPPORTED_TOKENS_BY_CHAIN[chainId];
684
+ if (symbols?.length) return [...symbols];
685
+ return getRuntimeTokenSymbols(chainId);
570
686
  }
571
687
  function getSupportedTokenSymbolsForChain(chainId) {
572
688
  return getTargetTokenSymbolsForChain(chainId);
@@ -587,7 +703,13 @@ function isSupportedTokenAddressForChain(token, chainId) {
587
703
  return expected.address.toLowerCase() === normalized;
588
704
  }
589
705
  function getSupportedTargetTokens(chainId) {
590
- const symbols = getSupportedTokenSymbolsForChain(chainId);
706
+ return toTokenOptions(getSupportedTokenSymbolsForChain(chainId), chainId);
707
+ }
708
+ function getBundledTargetTokens(chainId) {
709
+ const symbols = SUPPORTED_TOKENS_BY_CHAIN[chainId];
710
+ return symbols?.length ? toTokenOptions([...symbols], chainId) : [];
711
+ }
712
+ function toTokenOptions(symbols, chainId) {
591
713
  const options = [];
592
714
  for (const symbol of symbols) {
593
715
  const address = getTokenAddress(symbol, chainId);
@@ -620,7 +742,11 @@ function findTokenDecimals(token, chainId) {
620
742
  );
621
743
  if (found) return found.decimals;
622
744
  }
623
- return void 0;
745
+ if (chainId) {
746
+ const onChain = getRuntimeTokenByAddress(chainId, normalized);
747
+ if (onChain) return onChain.decimals;
748
+ }
749
+ return findRuntimeDecimalsByAddress(normalized);
624
750
  }
625
751
  function getTokenDecimalsByAddress(token, chainId) {
626
752
  return findTokenDecimals(token, chainId) ?? 18;
@@ -652,7 +778,10 @@ var NATIVE_SYMBOL_BY_CHAIN = {
652
778
  [hyperliquid2.id]: "HYPE"
653
779
  };
654
780
  function getNativeSymbol(chainId) {
655
- return chainId != null && NATIVE_SYMBOL_BY_CHAIN[chainId] || "ETH";
781
+ if (chainId == null) return "ETH";
782
+ const bundled = NATIVE_SYMBOL_BY_CHAIN[chainId];
783
+ if (bundled) return bundled;
784
+ return getRuntimeNativeSymbol(chainId) ?? "ETH";
656
785
  }
657
786
  function getTokenSymbol(token, chainId) {
658
787
  const normalized = token.toLowerCase();
@@ -674,13 +803,17 @@ function getTokenSymbol(token, chainId) {
674
803
  );
675
804
  if (found) return found.symbol;
676
805
  }
677
- return "Token";
806
+ if (chainId) {
807
+ const onChain = getRuntimeTokenByAddress(chainId, normalized);
808
+ if (onChain) return onChain.symbol;
809
+ }
810
+ return findRuntimeSymbolByAddress(normalized) ?? "Token";
678
811
  }
679
812
  function getTargetTokenSymbol(token, chain) {
680
813
  if (chain === "solana") {
681
814
  return getSolanaTokenByMint(String(token))?.symbol ?? "Token";
682
815
  }
683
- return getTokenSymbol(token, chain);
816
+ return getTokenSymbol(token, resolveDisplayChainId(chain));
684
817
  }
685
818
  function isStablecoinSymbol(symbol) {
686
819
  return /^(usdc|usdt|usdt0|dai|usd)$/i.test(symbol);
@@ -717,17 +850,30 @@ function getChainName(chainId) {
717
850
  if (chain) return chain.name;
718
851
  const chainEntry = chainRegistry[String(id)];
719
852
  if (chainEntry) return chainEntry.name;
853
+ const runtimeName = getRuntimeChainName(id);
854
+ if (runtimeName) return runtimeName;
720
855
  return `Chain ${id}`;
721
856
  }
722
857
  function getChainBadge(chainId) {
723
858
  if (chainId === "solana") {
724
859
  return { shortLabel: "SOL", color: "#9945FF", bg: "#F3EEFF" };
725
860
  }
726
- return CHAIN_BADGES[resolveDisplayChainId(chainId)] || {
727
- shortLabel: "Net",
728
- color: "#64748B",
729
- bg: "#F1F5F9"
730
- };
861
+ const id = resolveDisplayChainId(chainId);
862
+ const curated = CHAIN_BADGES[id];
863
+ if (curated) return curated;
864
+ const name = getRuntimeChainName(id);
865
+ if (!name) {
866
+ return { shortLabel: "Net", color: "#64748B", bg: "#F1F5F9" };
867
+ }
868
+ return { shortLabel: name, ...badgeColorsFor(name) };
869
+ }
870
+ function badgeColorsFor(name) {
871
+ let hash = 0;
872
+ for (let i = 0; i < name.length; i++) {
873
+ hash = hash * 31 + name.charCodeAt(i) | 0;
874
+ }
875
+ const hue = Math.abs(hash) % 360;
876
+ return { color: `hsl(${hue} 55% 38%)`, bg: `hsl(${hue} 70% 95%)` };
731
877
  }
732
878
  function getExplorerUrl(chainId) {
733
879
  if (chainId === "solana") return "https://solscan.io";
@@ -748,13 +894,18 @@ function getExplorerName(chainId) {
748
894
  }
749
895
 
750
896
  export {
897
+ SOLANA_MAINNET_CAIP2,
751
898
  toEvmCaip2,
752
899
  targetChainToCaip2,
900
+ targetChainToAccountKey,
753
901
  parseEvmChainId,
754
902
  isSolanaCaip2,
755
903
  isHyperCoreCaip2,
756
904
  HYPERCORE_CHAIN_ID,
757
905
  HYPERCORE_MAINNET_CAIP2,
906
+ HYPERCORE_SPOT_CAIP2,
907
+ targetChainToChainId,
908
+ isHyperCoreDestination,
758
909
  HYPERCORE_USDC_ADDRESS,
759
910
  HYPERCORE_USDT0_ADDRESS,
760
911
  HYPERCORE_SOURCE_TOKENS,
@@ -764,12 +915,16 @@ export {
764
915
  getSolanaTokenBySymbol,
765
916
  getSolanaTokenByMint,
766
917
  isNativeSol,
918
+ setRuntimeChainMeta,
919
+ setRuntimeTokens,
920
+ publishShortlistTokens,
767
921
  ICON_CDN,
768
922
  cdnIconUrl,
769
923
  getChainIcon,
770
924
  tokenIconUrl,
771
925
  getTokenIcon,
772
926
  NATIVE_TOKEN_ADDRESS,
927
+ CHAIN_DISPLAY_ORDER,
773
928
  CHAIN_BY_ID,
774
929
  SOURCE_CHAINS,
775
930
  SUPPORTED_CHAINS,
@@ -785,6 +940,7 @@ export {
785
940
  getSupportedChainIds,
786
941
  isSupportedTokenAddressForChain,
787
942
  getSupportedTargetTokens,
943
+ getBundledTargetTokens,
788
944
  findTokenDecimals,
789
945
  getTokenDecimalsByAddress,
790
946
  findChainIdForToken,