@koehler8/cms-ext-crypto 1.0.0-beta.4

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +198 -0
  3. package/components/CommunityStrip.vue +655 -0
  4. package/components/CuriosityTeaser.vue +842 -0
  5. package/components/HeaderWalletAction.vue +398 -0
  6. package/components/HeroPresale.vue +778 -0
  7. package/components/PercentDoughnut.vue +249 -0
  8. package/components/Presale.vue +507 -0
  9. package/components/PresaleAdmin.vue +1259 -0
  10. package/components/PresaleFaq.vue +95 -0
  11. package/components/ProgressFomo.vue +766 -0
  12. package/components/SocialProofFeed.vue +585 -0
  13. package/components/Tokenomics.vue +617 -0
  14. package/components/Trust.vue +123 -0
  15. package/components/TrustBar.vue +619 -0
  16. package/components/presale/BonusIncentive.vue +476 -0
  17. package/components/presale/Buy.vue +5388 -0
  18. package/components/presale/CountdownTimer.vue +326 -0
  19. package/components/presale/FirstTimeOnboarding.vue +443 -0
  20. package/components/presale/FuseMeter.vue +276 -0
  21. package/components/presale/HoldersBenefits.vue +135 -0
  22. package/components/presale/MomentumCard.vue +163 -0
  23. package/components/presale/PresaleFaqContent.vue +393 -0
  24. package/components/presale/PriceTimeline.vue +143 -0
  25. package/components/presale/Stake.vue +1415 -0
  26. package/components/presale/Status.vue +1113 -0
  27. package/components/presale/StatusMetric.vue +336 -0
  28. package/components/presale/StatusProgressBar.vue +98 -0
  29. package/components/presale/TrustSignals.vue +595 -0
  30. package/components/presale/buyAnalytics.js +58 -0
  31. package/components/presale/buyAssets.js +75 -0
  32. package/components/presale/buyTextHelpers.js +582 -0
  33. package/components/presale/priceSnapshotCache.js +72 -0
  34. package/components/presale/useBuyContentConfig.js +643 -0
  35. package/components/presale/useBuyOnboarding.js +338 -0
  36. package/components/presale/useBuyTransaction.js +464 -0
  37. package/components/presale/useBuyWallet.js +509 -0
  38. package/components/presale/useFomoProgress.js +578 -0
  39. package/components/presale/walletBalanceHelper.js +47 -0
  40. package/composables/usePresaleContext.js +24 -0
  41. package/content.defaults.json +171 -0
  42. package/extension.config.json +116 -0
  43. package/index.js +8 -0
  44. package/package.json +47 -0
  45. package/plugins/appKit.js +261 -0
  46. package/setup.js +29 -0
  47. package/stores/presale.js +70 -0
  48. package/utils/presaleContracts.js +69 -0
  49. package/utils/scrollToPresale.js +21 -0
  50. package/utils/tokenFormat.js +21 -0
  51. package/utils/walletTracking.js +175 -0
@@ -0,0 +1,72 @@
1
+ export function createPriceSnapshotCache({
2
+ initialEthPrice = 0,
3
+ initialTokenPrice = null,
4
+ windowMs = 12_000,
5
+ hasCustomRpc = true,
6
+ fetchEthPrice,
7
+ fetchTokenPrice,
8
+ onEthPriceUpdate,
9
+ onTokenPriceUpdate,
10
+ } = {}) {
11
+ let ethPrice = initialEthPrice;
12
+ let tokenPrice = initialTokenPrice;
13
+ let lastEthAt = 0;
14
+ let lastTokenAt = 0;
15
+
16
+ async function ensurePriceSnapshot({ force = false } = {}) {
17
+ const now = Date.now();
18
+
19
+ if (hasCustomRpc && (force || !ethPrice || now - lastEthAt > windowMs)) {
20
+ if (typeof fetchEthPrice === 'function') {
21
+ const next = await fetchEthPrice();
22
+ if (Number.isFinite(next) && next > 0) {
23
+ ethPrice = next;
24
+ lastEthAt = now;
25
+ onEthPriceUpdate?.(ethPrice);
26
+ }
27
+ }
28
+ } else if (!hasCustomRpc) {
29
+ lastEthAt = now;
30
+ }
31
+
32
+ if (hasCustomRpc && (force || tokenPrice === null || now - lastTokenAt > windowMs)) {
33
+ if (typeof fetchTokenPrice === 'function') {
34
+ const next = await fetchTokenPrice();
35
+ if (Number.isFinite(next) && next > 0) {
36
+ tokenPrice = next;
37
+ lastTokenAt = now;
38
+ onTokenPriceUpdate?.(tokenPrice);
39
+ }
40
+ }
41
+ } else if (!hasCustomRpc && tokenPrice === null) {
42
+ tokenPrice = initialTokenPrice;
43
+ lastTokenAt = now;
44
+ }
45
+
46
+ return {
47
+ ethUsdPrice: ethPrice,
48
+ tokenPrice,
49
+ };
50
+ }
51
+
52
+ function primePrices({ ethUsdPrice, tokenPrice: tokenValue, timestamp = Date.now() } = {}) {
53
+ if (Number.isFinite(ethUsdPrice) && ethUsdPrice > 0) {
54
+ ethPrice = ethUsdPrice;
55
+ lastEthAt = timestamp;
56
+ onEthPriceUpdate?.(ethPrice);
57
+ }
58
+ if (Number.isFinite(tokenValue) && tokenValue > 0) {
59
+ tokenPrice = tokenValue;
60
+ lastTokenAt = timestamp;
61
+ onTokenPriceUpdate?.(tokenPrice);
62
+ }
63
+ }
64
+
65
+ return {
66
+ ensurePriceSnapshot,
67
+ primePrices,
68
+ getEthUsdPrice: () => ethPrice,
69
+ getTokenPrice: () => tokenPrice,
70
+ getLastUpdateTimes: () => ({ lastEthAt, lastTokenAt }),
71
+ };
72
+ }