TLD price tiers (pricing.js): 1 char $500 (was $10) 2 char $250 (was $8) 3 char $150 (was $6) 4-6ch $100 (was $5) 7-10ch $50 (was $5) 11+ch $25 (was $4) Payment approval (register-flow.js): New stepApprove(...) gates the actual sign+broadcast on an explicit user gesture — PIN pad when a PIN blob exists on this device, wallet password otherwise. Same "3 wrong PINs → wipe, fall back to password" behavior as the sign-in unlock step. Wired between stepConfirm(Tld)? and stepRegister(Tld)? so both name mints and TLD mints require approval even when the wallet is already in memory. tld.html fee card: reflects the new $25–$500 range instead of the "≈ 1,250,000 sat · ≈ $5" placeholder.
72 lines
3.1 KiB
JavaScript
72 lines
3.1 KiB
JavaScript
// Sirius.X pricing model — deterministic per-label cost so users can predict
|
|
// what a name or TLD will cost before they click Register. Public tiers only;
|
|
// operator-level discounts and coupon overrides land in a future revision
|
|
// (the plan is oracle-fed rates + coupon-code redemption at mint time).
|
|
//
|
|
// Exposed as window.siriusPricing so both the register-flow modal and the
|
|
// inline search widgets on landing/tld.html use one source of truth.
|
|
|
|
(() => {
|
|
// Chipnet placeholder rate: mainnet swaps this for a real BCH/USD oracle.
|
|
// The numbers keep the demo transactions in the "few chipnet coins" range
|
|
// so a single faucet visit covers a name or a TLD.
|
|
const CHIPNET_SATS_PER_USD = 250_000;
|
|
|
|
const usdToSats = (usd) => BigInt(Math.max(0, Math.round(Number(usd) * CHIPNET_SATS_PER_USD)));
|
|
|
|
const cleanLabel = (s) => String(s || "").toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
|
|
// Tier picker — LENGTH-first, then downshift for "less brandable" shapes
|
|
// (all-digits, hyphenated). Kept as multiplicative modifiers so tiers
|
|
// remain the primary story and mods just soften an edge case.
|
|
function priceForName(label) {
|
|
const s = cleanLabel(label);
|
|
if (!s) return { usd: 0, tier: "invalid" };
|
|
let usd, tier;
|
|
if (s.length === 1) { usd = 5.00; tier = "premium-1"; }
|
|
else if (s.length === 2) { usd = 3.00; tier = "short-2"; }
|
|
else if (s.length === 3) { usd = 2.00; tier = "short-3"; }
|
|
else if (s.length <= 5) { usd = 1.00; tier = "standard"; }
|
|
else if (s.length <= 7) { usd = 0.50; tier = "long"; }
|
|
else if (s.length <= 16) { usd = 0.25; tier = "extended"; }
|
|
else { usd = 0.10; tier = "very-long"; }
|
|
// Modifiers.
|
|
if (/^\d+$/.test(s)) { usd = round2(usd * 0.5); tier += "+digits"; }
|
|
if (s.includes("-")) { usd = round2(usd * 0.7); tier += "+hyphen"; }
|
|
return { usd, tier, sats: usdToSats(usd) };
|
|
}
|
|
|
|
function priceForTld(label) {
|
|
const s = cleanLabel(label);
|
|
if (!s) return { usd: 0, tier: "invalid" };
|
|
let usd, tier;
|
|
if (s.length === 1) { usd = 500.00; tier = "premium-1"; }
|
|
else if (s.length === 2) { usd = 250.00; tier = "short-2"; }
|
|
else if (s.length === 3) { usd = 150.00; tier = "short-3"; }
|
|
else if (s.length <= 6) { usd = 100.00; tier = "standard"; }
|
|
else if (s.length <= 10) { usd = 50.00; tier = "long"; }
|
|
else { usd = 25.00; tier = "extended"; }
|
|
return { usd, tier, sats: usdToSats(usd) };
|
|
}
|
|
|
|
// Rounded USD → display string. Under $1 shows cents ($0.25); $1 and up
|
|
// shows whole dollars ($5) unless there's a fractional part.
|
|
function formatUsd(usd) {
|
|
const n = Number(usd || 0);
|
|
if (n >= 1 && n === Math.floor(n)) return `$${n}`;
|
|
return `$${n.toFixed(2)}`;
|
|
}
|
|
function formatSats(sats) {
|
|
return `${BigInt(sats || 0n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")} sat`;
|
|
}
|
|
function round2(n) { return Math.round(Number(n) * 100) / 100; }
|
|
|
|
window.siriusPricing = {
|
|
priceForName,
|
|
priceForTld,
|
|
formatUsd,
|
|
formatSats,
|
|
usdToSats,
|
|
CHIPNET_SATS_PER_USD,
|
|
};
|
|
})();
|