Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cb454ea39 | ||
|
|
ae163fa781 | ||
|
|
a426bee522 |
No files matched your search
+16
-1
@@ -1,5 +1,20 @@
|
||||
# Changelog
|
||||
|
||||
## [0.2.2] - 2026-10-27
|
||||
|
||||
- Sign in once for every waozi.xyz site: a profile signed in on Arcade, Apfelwurm or here is used by the others in the same browser, and logging out on one logs it out of the shared sign-in.
|
||||
|
||||
## [0.2.1] - 2026-10-27
|
||||
|
||||
- The Profile opens even when a saved account key on this browser cannot be read; it says so, keeps the key aside and lets you sign in again.
|
||||
|
||||
## [0.2.0] - 2026-10-27
|
||||
|
||||
- See incoming Monero payments with their confirmations until the Dew is added.
|
||||
- Read what Dew is and how to pay right away, while the page loads.
|
||||
- Use the page in German or Spanish, chosen by your browser or ?lang=de / ?lang=es.
|
||||
- Open a link such as dew.waozi.xyz/?account=ID to top up that account without signing in; the Profile's Top up in the apps opens it for your own account.
|
||||
|
||||
## [0.1.0] - 2026-10-27
|
||||
|
||||
- Top up Dew at dew.waozi.xyz: sign in with your Waozi profile, see your balance, and pay with Monero in any amount or with almost any other coin through Trocador from 100 Dew.
|
||||
- Top up Dew at dew.waozi.xyz: sign in with your profile, see your balance, and pay with Monero in any amount or with almost any other coin through Trocador from 100 Dew.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[dew.waozi.xyz](https://dew.waozi.xyz) is one focused page for topping up
|
||||
Dew, the currency every Waozi app shares: Inner Breeze, Arcade, Shovey,
|
||||
Apfelwurm and the rest. You sign in with the same Waozi profile those apps
|
||||
Apfelwurm and the rest. You sign in with the same profile those apps
|
||||
use, see your balance, and pay:
|
||||
|
||||
- **Monero, any amount.** Each account has its own Monero address on the
|
||||
|
||||
+99
-19
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>Dew</title>
|
||||
<meta name="description" content="Dew is the one currency for every Waozi app. Sign in with your Waozi profile and top up with Monero or almost any other coin.">
|
||||
<meta name="description" content="Dew is the one currency for every Waozi app. Sign in with your profile and top up with Monero or almost any other coin.">
|
||||
<meta name="theme-color" content="#0e1a20">
|
||||
<link rel="canonical" href="https://dew.waozi.xyz/">
|
||||
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
||||
@@ -19,33 +19,100 @@
|
||||
<style>
|
||||
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: #0e1a20; color: #e8f3f7; }
|
||||
canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
|
||||
#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: #0e1a20; font: 600 16px/1.4 system-ui, sans-serif; transition: opacity .3s ease; }
|
||||
#loading { position: fixed; inset: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 32px 20px; box-sizing: border-box; background: radial-gradient(circle at 75% 20%, #1d4e61, #0e1a20 60%); font: 400 17px/1.55 system-ui, sans-serif; transition: opacity .3s ease; }
|
||||
#loading.done { opacity: 0; pointer-events: none; }
|
||||
#loading img { width: 64px; height: 64px; }
|
||||
#loading .track { width: min(280px, 70vw); height: 6px; border-radius: 3px; background: #ffffff26; overflow: hidden; }
|
||||
#loading .bar { width: 0; height: 100%; background: #2f9fc4; transition: width .2s ease; }
|
||||
#loading .failed { display: none; color: #ffb4a8; text-align: center; padding: 0 24px; }
|
||||
#loading.error .failed { display: block; }
|
||||
.intro { width: min(520px, 100%); }
|
||||
.intro header { display: flex; align-items: center; gap: 16px; }
|
||||
.intro img { width: 56px; height: 56px; }
|
||||
.intro h1 { margin: 0; font-size: 44px; line-height: 1; }
|
||||
.intro .lede { margin: 18px 0 8px; font-size: 21px; font-weight: 600; }
|
||||
.intro p { margin: 10px 0 0; color: #bcd6df; }
|
||||
.track { width: min(520px, 100%); height: 6px; margin-top: 28px; border-radius: 3px; background: #ffffff26; overflow: hidden; }
|
||||
.bar { width: 0; height: 100%; background: #2f9fc4; transition: width .2s ease; }
|
||||
#loading.error .track { display: none; }
|
||||
#loading .status { width: min(520px, 100%); margin: 14px 0 0; color: #ffd8a8; }
|
||||
#loading .retry { margin-top: 14px; padding: 10px 22px; border: 0; border-radius: 999px; background: #2f9fc4; color: #fff; font: 600 16px system-ui, sans-serif; cursor: pointer; }
|
||||
#loading { flex-direction: column; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" tabindex="0"></canvas>
|
||||
<div id="loading" role="status" aria-live="polite">
|
||||
<img src="icon.svg" alt="">
|
||||
<div class="track"><div class="bar"></div></div>
|
||||
<p class="failed">Dew could not start. Reload the page to try again.</p>
|
||||
<noscript><p>Dew needs JavaScript and WebAssembly to run.</p></noscript>
|
||||
<div class="intro" lang="en">
|
||||
<header><img src="icon.svg" alt=""><h1>Dew</h1></header>
|
||||
<p class="lede">One currency for every Waozi app.</p>
|
||||
<p>Dew follows your profile into Inner Breeze, Arcade, Shovey and Apfelwurm. Unlock practices and storage, dress up your worm, and earn it by playing.</p>
|
||||
<p>Top up with Monero in any amount, or from 100 Dew with Bitcoin, Ethereum, USDT and hundreds of other coins.</p>
|
||||
<noscript><p>Dew needs JavaScript and WebAssembly to run.</p></noscript>
|
||||
</div>
|
||||
<div class="intro" lang="de" hidden>
|
||||
<header><img src="icon.svg" alt=""><h1>Dew</h1></header>
|
||||
<p class="lede">Eine Währung für alle Waozi-Apps.</p>
|
||||
<p>Dew begleitet dein Profil in Inner Breeze, Arcade, Shovey und Apfelwurm. Schalte Übungen und Speicher frei, kleide deinen Wurm ein und verdiene es beim Spielen.</p>
|
||||
<p>Lade es mit Monero in beliebiger Höhe auf oder ab 100 Dew mit Bitcoin, Ethereum, USDT und Hunderten anderer Coins.</p>
|
||||
</div>
|
||||
<div class="intro" lang="es" hidden>
|
||||
<header><img src="icon.svg" alt=""><h1>Dew</h1></header>
|
||||
<p class="lede">Una moneda para todas las apps de Waozi.</p>
|
||||
<p>Dew acompaña a tu perfil en Inner Breeze, Arcade, Shovey y Apfelwurm. Desbloquea prácticas y almacenamiento, viste a tu gusano y gánalo jugando.</p>
|
||||
<p>Recárgalo con Monero en cualquier cantidad, o desde 100 Dew con Bitcoin, Ethereum, USDT y cientos de monedas más.</p>
|
||||
</div>
|
||||
<div class="track" aria-hidden="true"><div class="bar"></div></div>
|
||||
<p class="status" hidden></p>
|
||||
<button type="button" class="retry" hidden></button>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
var loading = document.getElementById('loading');
|
||||
var bar = loading.querySelector('.bar');
|
||||
function failed() { loading.classList.add('error'); }
|
||||
var status = loading.querySelector('.status');
|
||||
var retry = loading.querySelector('.retry');
|
||||
// The intro speaks the page's language, as the app will: ?lang=, then the browser's.
|
||||
var asked = /[?&]lang=(de|es|en)\b/.exec(location.search);
|
||||
var language = (asked ? asked[1] : (navigator.language || 'en')).slice(0, 2).toLowerCase();
|
||||
if (language !== 'de' && language !== 'es') language = 'en';
|
||||
document.documentElement.lang = language;
|
||||
loading.querySelectorAll('.intro').forEach(function (intro) { intro.hidden = intro.lang !== language; });
|
||||
var words = {
|
||||
en: { again: 'Dew did not load. Trying again in {s} s…', failed: 'Dew could not load. Check your connection and try again.', slow: 'Still loading… this can take a moment on a slow connection.', button: 'Try again' },
|
||||
de: { again: 'Dew wurde nicht geladen. Neuer Versuch in {s} s …', failed: 'Dew konnte nicht geladen werden. Prüfe deine Verbindung und versuche es erneut.', slow: 'Wird noch geladen … bei einer langsamen Verbindung kann das dauern.', button: 'Erneut versuchen' },
|
||||
es: { again: 'Dew no se cargó. Reintentando en {s} s…', failed: 'Dew no se pudo cargar. Revisa tu conexión e inténtalo de nuevo.', slow: 'Todavía cargando… puede tardar con una conexión lenta.', button: 'Reintentar' }
|
||||
}[language];
|
||||
function say(text) { status.textContent = text; status.hidden = false; }
|
||||
function remembered() { try { return +sessionStorage.getItem('dew-load-retries') || 0; } catch (e) { return 3; } }
|
||||
function remember(count) { try { sessionStorage.setItem('dew-load-retries', String(count)); } catch (e) {} }
|
||||
retry.textContent = words.button;
|
||||
retry.onclick = function () { remember(0); location.reload(); };
|
||||
// A failed download, such as a server error while a new domain is
|
||||
// set up, reloads the page by itself a few times before asking.
|
||||
var ended = false;
|
||||
function failed() {
|
||||
if (ended) return;
|
||||
ended = true;
|
||||
loading.classList.add('error');
|
||||
var tries = remembered();
|
||||
retry.hidden = false;
|
||||
if (tries >= 3) { say(words.failed); return; }
|
||||
remember(tries + 1);
|
||||
var seconds = 5;
|
||||
say(words.again.replace('{s}', seconds));
|
||||
var timer = setInterval(function () {
|
||||
seconds -= 1;
|
||||
if (seconds > 0) { say(words.again.replace('{s}', seconds)); return; }
|
||||
clearInterval(timer);
|
||||
location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
var slow = setTimeout(function () { if (!ended) say(words.slow); }, 25000);
|
||||
// The page reports ready once it is about to draw.
|
||||
function watch() {
|
||||
if (window.Module && Module.profileReady) { loading.classList.add('done'); return; }
|
||||
requestAnimationFrame(watch);
|
||||
if (window.Module && Module.profileReady) {
|
||||
clearTimeout(slow);
|
||||
remember(0);
|
||||
loading.classList.add('done');
|
||||
return;
|
||||
}
|
||||
if (!ended) requestAnimationFrame(watch);
|
||||
}
|
||||
window.Module = {
|
||||
canvas: document.getElementById('canvas'),
|
||||
@@ -56,11 +123,24 @@
|
||||
onAbort: failed,
|
||||
onExit: function (code) { if (code !== 0) failed(); }
|
||||
};
|
||||
var script = document.createElement('script');
|
||||
script.src = 'runtime.js';
|
||||
script.onerror = failed;
|
||||
document.body.appendChild(script);
|
||||
watch();
|
||||
function start() {
|
||||
var script = document.createElement('script');
|
||||
script.src = 'runtime.js';
|
||||
script.onerror = failed;
|
||||
document.body.appendChild(script);
|
||||
watch();
|
||||
}
|
||||
// One sign-in for every waozi.xyz site: account.waozi.xyz hands over
|
||||
// the shared key before the app starts. It never holds the page up for
|
||||
// long, and the page starts without it if the hub cannot be reached.
|
||||
var started = false;
|
||||
function go() { if (!started) { started = true; start(); } }
|
||||
var shared = document.createElement('script');
|
||||
shared.src = 'https://account.waozi.xyz/share.js';
|
||||
shared.onload = function () { WaoziAccount.attach(Module, 2500).then(go, go); };
|
||||
shared.onerror = go;
|
||||
setTimeout(go, 4000);
|
||||
document.head.appendChild(shared);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
+259
-123
@@ -1,8 +1,10 @@
|
||||
// dew.waozi.xyz: one focused page for buying Dew, the currency every Waozi
|
||||
// app shares. The account comes from Entity's shared Profile, whose provider
|
||||
// keeps the keys; this page only reads the balance and the account's own
|
||||
// Monero address from the node and draws them.
|
||||
// keeps the keys; this page only reads the balance, deposits and the
|
||||
// account's own Monero address from the node and draws them. A link may name
|
||||
// another account (?account=ID), whose public address the page then shows.
|
||||
#import "topup_model"
|
||||
#import "topup_copy"
|
||||
#import "entity/native_host"
|
||||
#import "entity/dew_model"
|
||||
#import "qrcode/qrcode"
|
||||
@@ -55,6 +57,7 @@ DewPalette :: () -> WidgetPalette {
|
||||
|
||||
AmountField :: struct { cursor: s32; anchor: s32; scroll_x: s32; focused: bool }
|
||||
|
||||
topup_copy: TopupCopy;
|
||||
DEW_PRESETS: [4]s64 = .[100, 500, 1000, 5000];
|
||||
// The chosen preset, or -1 while the typed amount counts.
|
||||
topup_preset: s32 = 1;
|
||||
@@ -62,10 +65,16 @@ topup_typed: [16]u8;
|
||||
topup_field: AmountField;
|
||||
topup_scroll: s32;
|
||||
topup_content_height: float32 = 1600.0;
|
||||
topup_card_heights: [4]float32 = .[180.0, 200.0, 420.0, 260.0];
|
||||
topup_card_heights: [5]float32 = .[180.0, 160.0, 200.0, 420.0, 260.0];
|
||||
topup_copied_until: float64;
|
||||
topup_refreshed_at: float64 = -100000.0;
|
||||
topup_address_at: float64 = -100000.0;
|
||||
topup_deposits_at: float64 = -100000.0;
|
||||
// After a request the node did not answer, the next waits longer each time
|
||||
// (10 s doubling to 5 min), so a struggling node is not flooded.
|
||||
topup_attempt_pending: bool;
|
||||
topup_failures: s32;
|
||||
topup_retry_at: float64;
|
||||
|
||||
// The node's public rate and dollar price, fetched every ten minutes.
|
||||
topup_rates: DewRates;
|
||||
@@ -75,6 +84,27 @@ topup_rates_at: float64 = -1000000.0;
|
||||
topup_rates_transfer: HttpTransfer;
|
||||
topup_rates_answer: [4096]u8;
|
||||
|
||||
// The account a link names: 0 none, 1 loading, 2 known, 3 not found.
|
||||
TOPUP_GUEST_NONE :: 0
|
||||
TOPUP_GUEST_LOADING :: 1
|
||||
TOPUP_GUEST_KNOWN :: 2
|
||||
TOPUP_GUEST_INVALID :: 3
|
||||
topup_reference: [80]u8;
|
||||
topup_guest_state: s32;
|
||||
topup_guest_running: bool;
|
||||
topup_guest_at: float64 = -1000000.0;
|
||||
topup_guest_transfer: HttpTransfer;
|
||||
topup_guest_answer: [8192]u8;
|
||||
topup_guest_funding: DewFunding;
|
||||
topup_guest_account: [65]u8;
|
||||
topup_guest_alias: [40]u8;
|
||||
|
||||
// The newest deposits of the signed-in account, read from Entity's last list.
|
||||
topup_deposits: [3]DewDeposit;
|
||||
topup_deposit_count: s32 = -1;
|
||||
topup_deposits_parsed_at: float64 = -100000.0;
|
||||
topup_credited: s64 = -1;
|
||||
|
||||
// The QR code of the current wallet link, built only when the link changes.
|
||||
QrRect :: struct { column: s32; row: s32; width: s32; height: s32 }
|
||||
QR_RECTS :: 2048
|
||||
@@ -87,25 +117,79 @@ topup_qr_count: s32;
|
||||
topup_link: [1024]u8;
|
||||
topup_wallet: [512]u8;
|
||||
|
||||
// Keeps the balance, address and rate fresh. Requests share Entity's one
|
||||
// Dew queue, so each waits for the previous to finish.
|
||||
// The page's language ("de", "es" or anything else for English) and its
|
||||
// query, such as "?account=ID&lang=de".
|
||||
TopupStart :: (query: string, language: string) {
|
||||
chosen: [8]u8
|
||||
asked := QueryValue(query, "lang", chosen[:])
|
||||
topup_copy = TopupCopyFor(ifx asked != "" then asked else language)
|
||||
if QueryValue(query, "account", topup_reference[:]) != "" { topup_guest_state = TOPUP_GUEST_LOADING }
|
||||
}
|
||||
|
||||
// Keeps the balance, address, deposits and rate fresh. Requests share
|
||||
// Entity's one Dew queue, so each waits for the previous to finish.
|
||||
TopupPump :: (now: float64) {
|
||||
TopupRatesPump(now)
|
||||
TopupGuestPump(now)
|
||||
status := EntityHostDewStatus()
|
||||
if !status.ready || status.busy { return }
|
||||
if !status.known && now - topup_refreshed_at > 10000.0 {
|
||||
if EntityHostDewRequest("refresh") { topup_refreshed_at = now }
|
||||
if !status.ready {
|
||||
topup_deposit_count = -1
|
||||
topup_credited = -1
|
||||
return
|
||||
}
|
||||
if !status.funded && status.funding_allowed && now - topup_address_at > 15000.0 {
|
||||
if EntityHostDewRequest("address") { topup_address_at = now }
|
||||
if now - topup_deposits_parsed_at > 2000.0 {
|
||||
topup_deposits_parsed_at = now
|
||||
TopupReadDeposits()
|
||||
}
|
||||
if status.busy { return }
|
||||
if topup_attempt_pending {
|
||||
topup_attempt_pending = false
|
||||
if status.error {
|
||||
if topup_failures < 5 { topup_failures += 1 }
|
||||
topup_retry_at = now + 10000.0 * cast(float64)(1 << cast(u32)(topup_failures - 1))
|
||||
if topup_retry_at > now + 300000.0 { topup_retry_at = now + 300000.0 }
|
||||
} else {
|
||||
topup_failures = 0
|
||||
topup_retry_at = 0.0
|
||||
}
|
||||
}
|
||||
if now < topup_retry_at { return }
|
||||
if !status.known || status.error && now - topup_refreshed_at > 10000.0 {
|
||||
if EntityHostDewRequest("refresh") { topup_refreshed_at = now; topup_attempt_pending = true }
|
||||
return
|
||||
}
|
||||
if !status.funded && status.funding_allowed {
|
||||
if EntityHostDewRequest("address") { topup_address_at = now; topup_attempt_pending = true }
|
||||
return
|
||||
}
|
||||
if status.funded && now - topup_deposits_at > 20000.0 {
|
||||
if EntityHostDewRequest("deposits") { topup_deposits_at = now; topup_attempt_pending = true }
|
||||
return
|
||||
}
|
||||
if now - topup_refreshed_at > 30000.0 {
|
||||
if EntityHostDewRequest("refresh") { topup_refreshed_at = now }
|
||||
if EntityHostDewRequest("refresh") { topup_refreshed_at = now; topup_attempt_pending = true }
|
||||
}
|
||||
}
|
||||
|
||||
// Asks again at once, from the Retry button.
|
||||
TopupRetry :: () {
|
||||
topup_retry_at = 0.0
|
||||
topup_refreshed_at = -100000.0
|
||||
}
|
||||
|
||||
// A deposit the node newly credits refreshes the balance at once.
|
||||
TopupReadDeposits :: () {
|
||||
count := DewParseDeposits(EntityHostDewDeposits(), topup_deposits[:])
|
||||
if count < 0 { return }
|
||||
topup_deposit_count = count
|
||||
credited: s64 = 0
|
||||
for index: 0..count - 1 {
|
||||
if TextUntilNul(topup_deposits[index].status[:]) == "credited" { credited += 1 }
|
||||
}
|
||||
if topup_credited >= 0 && credited > topup_credited { topup_refreshed_at = -100000.0 }
|
||||
topup_credited = credited
|
||||
}
|
||||
|
||||
TopupRatesPump :: (now: float64) {
|
||||
if topup_rates_running {
|
||||
status: s32
|
||||
@@ -127,16 +211,53 @@ TopupRatesPump :: (now: float64) {
|
||||
topup_rates_running = HttpTransferStart(*topup_rates_transfer, request, topup_rates_answer[:], 20000)
|
||||
}
|
||||
|
||||
// The public address of the account a link names; no sign-in needed.
|
||||
TopupGuestPump :: (now: float64) {
|
||||
if topup_guest_running {
|
||||
status: s32
|
||||
done := HttpTransferPoll(*topup_guest_transfer, *status)
|
||||
if done < 0 { return }
|
||||
topup_guest_running = false
|
||||
if done == 1 && status == 200 && DewParseRecipient(TextUntilNul(topup_guest_answer[:]),
|
||||
*topup_guest_funding, topup_guest_account[:], topup_guest_alias[:]) {
|
||||
topup_guest_state = TOPUP_GUEST_KNOWN
|
||||
} else if done == 1 && (status == 400 || status == 404) {
|
||||
topup_guest_state = TOPUP_GUEST_INVALID
|
||||
}
|
||||
HttpTransferCancel(*topup_guest_transfer)
|
||||
return
|
||||
}
|
||||
if topup_guest_state != TOPUP_GUEST_LOADING || now - topup_guest_at < 15000.0 { return }
|
||||
topup_guest_at = now
|
||||
url: [256]u8
|
||||
at: s64 = 0
|
||||
if !Append(url[:], *at, "https://api.waozi.xyz/api/v1/tokens/purchases/monero/address/") ||
|
||||
!Append(url[:], *at, TextUntilNul(topup_reference[:])) {
|
||||
topup_guest_state = TOPUP_GUEST_INVALID
|
||||
return
|
||||
}
|
||||
request := HttpRequest.{.method = "GET", .url = TextUntilNul(url[:]), .accept = "application/json"}
|
||||
topup_guest_answer = .{}
|
||||
topup_guest_running = HttpTransferStart(*topup_guest_transfer, request, topup_guest_answer[:], 20000)
|
||||
}
|
||||
|
||||
// Draws the page; returns TOPUP_SIGN_IN or TOPUP_PROFILE when the Profile
|
||||
// should open.
|
||||
TopupFrame :: (session: Session, viewport: Rectangle, input: TextFieldInput, now: float64) -> s32 {
|
||||
copy := topup_copy
|
||||
action: s32 = TOPUP_NONE
|
||||
status := EntityHostDewStatus()
|
||||
rate := ifx status.funded then DewRate.{status.funding.atomic, status.funding.units} else topup_rates.rate
|
||||
// A link to the signed-in account's own address is the ordinary page.
|
||||
guest := topup_guest_state == TOPUP_GUEST_KNOWN &&
|
||||
!(status.funded && TextUntilNul(status.funding.address[:]) == TextUntilNul(topup_guest_funding.address[:]))
|
||||
funded := guest || status.funded
|
||||
funding := ifx guest then topup_guest_funding else status.funding
|
||||
rate := ifx funded then DewRate.{funding.atomic, funding.units} else topup_rates.rate
|
||||
usd := ifx topup_rates_known then topup_rates.usd_cents else cast(s64)0
|
||||
dew := ifx topup_preset >= 0 then DEW_PRESETS[topup_preset] else DewTyped(TextUntilNul(topup_typed[:]))
|
||||
atomic := DewAtomic(dew, rate)
|
||||
minimum := DewAtLeast(TROCADOR_MINIMUM_ATOMIC, rate)
|
||||
filled: [512]u8
|
||||
|
||||
Box(session, BoxProps.{.key = cast(u64)60000, .bounds = viewport, .fill = ColorFromPacked(cast(u32)DEW_BACKGROUND)})
|
||||
scroll := Scroll(session, ScrollProps.{.key = cast(u64)60001, .bounds = viewport,
|
||||
@@ -156,31 +277,47 @@ TopupFrame :: (session: Session, viewport: Rectangle, input: TextFieldInput, now
|
||||
SvgIcon(session, SvgIconProps.{.shape = DROP_SHAPE, .color = Color.{255, 255, 255, 255},
|
||||
.bounds = Rectangle.{x + 12.0, y + 11.0, 24.0, 26.0}})
|
||||
Text(session, TextProps.{.key = cast(u64)60003, .text = "Dew", .font = 32,
|
||||
.bounds = Rectangle.{x + 62.0, y + 4.0, column - 200.0, 40.0}})
|
||||
profile_label := ifx status.ready then "Profile" else "Sign in"
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60004, .id = 60004, .label = profile_label,
|
||||
.bounds = Rectangle.{x + column - 120.0, y + 4.0, 120.0, 40.0},
|
||||
.bounds = Rectangle.{x + 62.0, y + 4.0, column - 220.0, 40.0}})
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60004, .id = 60004,
|
||||
.label = ifx status.ready then copy.profile else copy.sign_in,
|
||||
.bounds = Rectangle.{x + column - 140.0, y + 4.0, 140.0, 40.0},
|
||||
.tone = ButtonTone.ButtonToneAccent, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
action = ifx status.ready then TOPUP_PROFILE else TOPUP_SIGN_IN
|
||||
}
|
||||
y += 62.0
|
||||
Line(session, 60005, "One currency for every Waozi app. Top it up here with Monero or almost any other coin.", x, *y, column, 17, 26.0)
|
||||
Line(session, 60005, copy.tagline, x, *y, column, 17, 26.0)
|
||||
|
||||
// The balance.
|
||||
// Whose Dew, and the balance.
|
||||
inner := column - 36.0
|
||||
card_y := y
|
||||
Card(session, 60010, x, y, column, topup_card_heights[0])
|
||||
y += 18.0
|
||||
if guest {
|
||||
name := TextUntilNul(topup_guest_alias[:])
|
||||
short: [16]u8
|
||||
if name == "" {
|
||||
unused CopyCString(TextUntilNul(topup_guest_account[:])[:8], short[:])
|
||||
name = TextUntilNul(short[:])
|
||||
}
|
||||
Line(session, 60019, Fill(copy.guest_for, name, "", "", filled[:]), x + 18.0, *y, inner, 18, 10.0)
|
||||
}
|
||||
if topup_guest_state == TOPUP_GUEST_INVALID {
|
||||
Line(session, 60009, copy.account_invalid, x + 18.0, *y, inner, 15, 10.0)
|
||||
}
|
||||
if !status.ready {
|
||||
Line(session, 60011, "Sign in with your Waozi profile to see your Dew and top it up.", x + 18.0, *y, inner, 18, 10.0)
|
||||
Line(session, 60012, "Use the same profile as in Inner Breeze, Arcade or Shovey: link this browser from the app, or import your key.", x + 18.0, *y, inner, 14, 14.0)
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60013, .id = 60013, .label = "Sign in",
|
||||
if guest {
|
||||
Line(session, 60012, copy.guest_hint, x + 18.0, *y, inner, 14, 14.0)
|
||||
} else {
|
||||
Line(session, 60011, copy.sign_in_title, x + 18.0, *y, inner, 18, 10.0)
|
||||
Line(session, 60012, copy.sign_in_hint, x + 18.0, *y, inner, 14, 14.0)
|
||||
}
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60013, .id = 60013, .label = copy.sign_in,
|
||||
.bounds = Rectangle.{x + 18.0, y, inner, 48.0}, .tone = ButtonTone.ButtonToneAccent}) != 0 {
|
||||
action = TOPUP_SIGN_IN
|
||||
}
|
||||
y += 48.0
|
||||
} else {
|
||||
Line(session, 60014, "Your balance", x + 18.0, *y, inner, 14, 4.0)
|
||||
Line(session, 60014, copy.balance, x + 18.0, *y, inner, 14, 4.0)
|
||||
amount: [64]u8
|
||||
balance := "…"
|
||||
if status.known && DewFormat(status.account.balance, DewUnits, amount[:], "Dew") { balance = TextUntilNul(amount[:]) }
|
||||
@@ -191,23 +328,46 @@ TopupFrame :: (session: Session, viewport: Rectangle, input: TextFieldInput, now
|
||||
}
|
||||
who := TextUntilNul(status.alias[:])
|
||||
if who == "" { who = TextUntilNul(status.name[:]) }
|
||||
if who != "" {
|
||||
signed: [128]u8
|
||||
Line(session, 60017, Joined("Signed in as ", who, signed[:]), x + 18.0, *y, inner, 14, 4.0)
|
||||
}
|
||||
if who != "" { Line(session, 60017, Fill(copy.signed_in_as, who, "", "", filled[:]), x + 18.0, *y, inner, 14, 4.0) }
|
||||
if status.error {
|
||||
Line(session, 60018, "The node did not answer. The balance shown is the last one it confirmed.", x + 18.0, *y, inner, 14, 4.0)
|
||||
wait := cast(s64)((topup_retry_at - now) / 1000.0) + 1
|
||||
seconds: [24]u8
|
||||
Line(session, 60018, ifx topup_retry_at > now then Fill(copy.node_retry, FormatInteger(wait, seconds[:]), "", "", filled[:]) else copy.node_error,
|
||||
x + 18.0, *y, inner, 14, 8.0)
|
||||
if topup_retry_at > now && Button(session, ButtonProps.{.key = cast(u64)60008, .id = 60008, .label = copy.retry_now,
|
||||
.bounds = Rectangle.{x + 18.0, y, 180.0, 40.0}, .tone = ButtonTone.ButtonToneAccent,
|
||||
.emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
TopupRetry()
|
||||
}
|
||||
if topup_retry_at > now { y += 48.0 }
|
||||
}
|
||||
}
|
||||
y += 18.0
|
||||
topup_card_heights[0] = y - card_y
|
||||
y += 16.0
|
||||
|
||||
// Payments on their way to the signed-in account.
|
||||
if status.ready && status.funded && !guest && topup_deposit_count >= 0 {
|
||||
card_y = y
|
||||
Card(session, 60060, x, y, column, topup_card_heights[1])
|
||||
y += 18.0
|
||||
Line(session, 60061, copy.incoming, x + 18.0, *y, inner, 21, 10.0)
|
||||
if topup_deposit_count == 0 { Line(session, 60062, copy.no_deposits, x + 18.0, *y, inner, 15, 0.0) }
|
||||
for index: 0..topup_deposit_count - 1 {
|
||||
line: [256]u8
|
||||
Line(session, cast(u64)(60063 + index), DepositText(topup_deposits[index], funding.confirmations, line[:]),
|
||||
x + 18.0, *y, inner, 15, 6.0)
|
||||
}
|
||||
y += 18.0
|
||||
topup_card_heights[1] = y - card_y
|
||||
y += 16.0
|
||||
}
|
||||
|
||||
// How much Dew.
|
||||
card_y = y
|
||||
Card(session, 60020, x, y, column, topup_card_heights[1])
|
||||
Card(session, 60020, x, y, column, topup_card_heights[2])
|
||||
y += 18.0
|
||||
Line(session, 60021, "How much Dew?", x + 18.0, *y, inner, 21, 12.0)
|
||||
Line(session, 60021, copy.how_much, x + 18.0, *y, inner, 21, 12.0)
|
||||
gap: float32 = 8.0
|
||||
chip := (inner - gap * 3.0) / 4.0
|
||||
for index: 0..3 {
|
||||
@@ -223,73 +383,78 @@ TopupFrame :: (session: Session, viewport: Rectangle, input: TextFieldInput, now
|
||||
}
|
||||
}
|
||||
y += 56.0
|
||||
if AmountInput(session, Rectangle.{x + 18.0, y, inner, 46.0}, input) && topup_typed[0] != cast(u8)0 { topup_preset = -1 }
|
||||
if AmountInput(session, Rectangle.{x + 18.0, y, inner, 46.0}, input, copy) && topup_typed[0] != cast(u8)0 { topup_preset = -1 }
|
||||
if topup_field.focused && topup_typed[0] != cast(u8)0 { topup_preset = -1 }
|
||||
y += 56.0
|
||||
summary: [192]u8
|
||||
Line(session, 60027, AmountText(dew, atomic, usd, summary[:]), x + 18.0, *y, inner, 16, 0.0)
|
||||
Line(session, 60027, AmountText(dew, atomic, usd, filled[:]), x + 18.0, *y, inner, 16, 0.0)
|
||||
y += 18.0
|
||||
topup_card_heights[1] = y - card_y
|
||||
topup_card_heights[2] = y - card_y
|
||||
y += 16.0
|
||||
|
||||
// Monero, any amount.
|
||||
card_y = y
|
||||
Card(session, 60030, x, y, column, topup_card_heights[2])
|
||||
Card(session, 60030, x, y, column, topup_card_heights[3])
|
||||
y += 18.0
|
||||
Line(session, 60031, "Pay with Monero", x + 18.0, *y, inner, 21, 8.0)
|
||||
Line(session, 60032, "Any amount works. You get Dew for exactly the Monero that arrives.", x + 18.0, *y, inner, 15, 14.0)
|
||||
if !status.ready {
|
||||
Line(session, 60033, "Sign in to see your own Monero address.", x + 18.0, *y, inner, 15, 0.0)
|
||||
} else if !status.funded {
|
||||
Line(session, 60034, ifx status.error then "Your address could not be loaded yet. Trying again…" else "Getting your address…", x + 18.0, *y, inner, 15, 0.0)
|
||||
} else {
|
||||
address := TextUntilNul(status.funding.address[:])
|
||||
Line(session, 60031, copy.pay_monero, x + 18.0, *y, inner, 21, 8.0)
|
||||
Line(session, 60032, copy.any_amount, x + 18.0, *y, inner, 15, 14.0)
|
||||
if funded {
|
||||
address := TextUntilNul(funding.address[:])
|
||||
wallet := MoneroUri(address, ifx atomic > 0 then atomic else cast(s64)0, topup_wallet[:])
|
||||
side := DrawQr(session, wallet, x + 18.0, y, inner)
|
||||
if side > 0.0 { y += side + 14.0 }
|
||||
Line(session, 60035, address, x + 18.0, *y, inner, 15, 12.0)
|
||||
copied := now < topup_copied_until
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60036, .id = 60036, .label = ifx copied then "Copied" else "Copy address",
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60036, .id = 60036, .label = ifx copied then copy.copied else copy.copy_address,
|
||||
.bounds = Rectangle.{x + 18.0, y, inner, 46.0}, .tone = ButtonTone.ButtonToneAccent,
|
||||
.emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
if SystemClipboardSet(address) { topup_copied_until = now + 2000.0 }
|
||||
}
|
||||
y += 58.0
|
||||
wait: [160]u8
|
||||
Line(session, 60037, ConfirmationText(status.funding.confirmations, wait[:]), x + 18.0, *y, inner, 14, 0.0)
|
||||
minutes: [24]u8
|
||||
count: [24]u8
|
||||
Line(session, 60037, Fill(copy.confirmations, FormatInteger(funding.confirmations, count[:]),
|
||||
FormatInteger(funding.confirmations * 2, minutes[:]), "", filled[:]), x + 18.0, *y, inner, 14, 0.0)
|
||||
} else if !status.ready && topup_guest_state != TOPUP_GUEST_LOADING {
|
||||
Line(session, 60033, copy.sign_in_address, x + 18.0, *y, inner, 15, 0.0)
|
||||
} else {
|
||||
Line(session, 60034, ifx status.error then copy.address_retry else copy.address_loading, x + 18.0, *y, inner, 15, 0.0)
|
||||
}
|
||||
y += 18.0
|
||||
topup_card_heights[2] = y - card_y
|
||||
topup_card_heights[3] = y - card_y
|
||||
y += 16.0
|
||||
|
||||
// Any other coin, through Trocador.
|
||||
card_y = y
|
||||
Card(session, 60040, x, y, column, topup_card_heights[3])
|
||||
Card(session, 60040, x, y, column, topup_card_heights[4])
|
||||
y += 18.0
|
||||
Line(session, 60041, "Pay with another coin", x + 18.0, *y, inner, 21, 8.0)
|
||||
Line(session, 60042, "Bitcoin, Ethereum, Litecoin, USDT and hundreds more. Trocador swaps your coin to Monero and sends it to your Dew address.", x + 18.0, *y, inner, 15, 14.0)
|
||||
Line(session, 60041, copy.other_coin, x + 18.0, *y, inner, 21, 8.0)
|
||||
Line(session, 60042, copy.other_coin_body, x + 18.0, *y, inner, 15, 14.0)
|
||||
link := ""
|
||||
if status.funded && atomic > 0 { link = TrocadorUrl(TextUntilNul(status.funding.address[:]), atomic, dew, topup_link[:]) }
|
||||
pay: [96]u8
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60043, .id = 60043, .label = PayText(dew, pay[:]),
|
||||
if funded && atomic > 0 { link = TrocadorUrl(TextUntilNul(funding.address[:]), atomic, dew, copy.language, topup_link[:]) }
|
||||
digits: [24]u8
|
||||
pay: [128]u8
|
||||
pay_label := ifx dew > 0 then Fill(copy.pay_other, FormatInteger(dew, digits[:]), "", "", pay[:]) else copy.other_coin
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60043, .id = 60043, .label = pay_label,
|
||||
.bounds = Rectangle.{x + 18.0, y, inner, 48.0}, .tone = ButtonTone.ButtonToneAccent,
|
||||
.disabled = link == ""}) != 0 && link != "" {
|
||||
unused OpenUri(link)
|
||||
}
|
||||
y += 60.0
|
||||
if !status.ready {
|
||||
Line(session, 60044, "Sign in first, so Trocador sends to your own address.", x + 18.0, *y, inner, 14, 6.0)
|
||||
if !funded && !status.ready && topup_guest_state != TOPUP_GUEST_LOADING {
|
||||
Line(session, 60044, copy.sign_in_first, x + 18.0, *y, inner, 14, 6.0)
|
||||
} else if minimum > 0 && dew < minimum {
|
||||
least: [160]u8
|
||||
Line(session, 60045, MinimumText(minimum, rate, least[:]), x + 18.0, *y, inner, 14, 6.0)
|
||||
least: [24]u8
|
||||
xmr: [48]u8
|
||||
Line(session, 60045, Fill(copy.minimum, FormatInteger(minimum, least[:]), XmrText(TROCADOR_MINIMUM_ATOMIC, xmr[:]), "", filled[:]),
|
||||
x + 18.0, *y, inner, 14, 6.0)
|
||||
}
|
||||
fee: [192]u8
|
||||
Line(session, 60046, FeeText(dew, fee[:]), x + 18.0, *y, inner, 14, 0.0)
|
||||
fee := ifx dew > 0 then Fill(copy.fee, FormatInteger(dew, digits[:]), "", "", filled[:]) else copy.opens
|
||||
Line(session, 60046, fee, x + 18.0, *y, inner, 14, 0.0)
|
||||
y += 18.0
|
||||
topup_card_heights[3] = y - card_y
|
||||
topup_card_heights[4] = y - card_y
|
||||
y += 24.0
|
||||
|
||||
Line(session, 60050, "Dew works in every Waozi app: unlock practices and storage in Inner Breeze, dress up in Apfelwurm, earn it in Shovey and send it to friends.", x, *y, column, 15, 10.0)
|
||||
Line(session, 60050, copy.footer, x, *y, column, 15, 10.0)
|
||||
if Button(session, ButtonProps.{.key = cast(u64)60051, .id = 60051, .label = "waozi.xyz",
|
||||
.bounds = Rectangle.{x, y, 140.0, 40.0}, .tone = ButtonTone.ButtonToneAccent,
|
||||
.emphasis = ButtonEmphasis.ButtonEmphasisGhost}) != 0 {
|
||||
@@ -316,11 +481,11 @@ Line :: (session: Session, key: u64, text: string, x: float32, y: *float32, widt
|
||||
y.* += height + gap
|
||||
}
|
||||
|
||||
AmountInput :: (session: Session, bounds: Rectangle, input: TextFieldInput) -> bool {
|
||||
AmountInput :: (session: Session, bounds: Rectangle, input: TextFieldInput, copy: TopupCopy) -> bool {
|
||||
snapshot: [16]u8
|
||||
snapshot = topup_typed
|
||||
props := TextFieldProps.{.key = cast(u64)60026, .focus_id = 60026, .bounds = bounds,
|
||||
.label = "Other amount", .placeholder = "Other amount in Dew",
|
||||
.label = copy.other_amount, .placeholder = copy.other_amount_hint,
|
||||
.value = TextUntilNul(snapshot[:]), .cursor = topup_field.cursor, .anchor = topup_field.anchor,
|
||||
.scroll_x = topup_field.scroll_x, .focused = topup_field.focused,
|
||||
.max_bytes = 7, .max_codepoints = 7, .numeric = true}
|
||||
@@ -404,78 +569,49 @@ QrBuild :: () {
|
||||
}
|
||||
}
|
||||
|
||||
Joined :: (first: string, second: string, output: []u8) -> string {
|
||||
// "0.05 XMR · about $29.53".
|
||||
XmrAndUsd :: (atomic: s64, usd_cents: s64, output: []u8) -> string {
|
||||
xmr: [48]u8
|
||||
dollars: [48]u8
|
||||
about: [96]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, first) || !Append(output, *at, second) { return first }
|
||||
if !Append(output, *at, XmrText(atomic, xmr[:])) { return "" }
|
||||
usd := UsdText(UsdCents(atomic, usd_cents), dollars[:])
|
||||
if usd != "" && (!Append(output, *at, " · ") || !Append(output, *at, Fill(topup_copy.about, usd, "", "", about[:]))) { return "" }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
// "0.1234 XMR · about $72.90" for a balance in token units.
|
||||
// A balance in token units as Monero and dollars.
|
||||
WorthText :: (units: s64, rate: DewRate, usd_cents: s64, output: []u8) -> string {
|
||||
reduced := ReducedRate(rate)
|
||||
if reduced.units <= 0 || units < 0 || units > 9223372036854775807 / reduced.atomic { return "" }
|
||||
atomic := units * reduced.atomic / reduced.units
|
||||
xmr: [48]u8
|
||||
dollars: [48]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, XmrText(atomic, xmr[:])) { return "" }
|
||||
worth := UsdText(UsdCents(atomic, usd_cents), dollars[:])
|
||||
if worth != "" && (!Append(output, *at, " · ") || !Append(output, *at, worth)) { return "" }
|
||||
return TextUntilNul(output)
|
||||
return XmrAndUsd(units * reduced.atomic / reduced.units, usd_cents, output)
|
||||
}
|
||||
|
||||
// "500 Dew = 0.05 XMR · about $29.54".
|
||||
AmountText :: (dew: s64, atomic: s64, usd_cents: s64, output: []u8) -> string {
|
||||
if dew <= 0 { return "Choose an amount, or type any whole number of Dew." }
|
||||
if atomic <= 0 { return "Loading the rate…" }
|
||||
if dew <= 0 { return topup_copy.choose_amount }
|
||||
if atomic <= 0 { return topup_copy.loading_rate }
|
||||
digits: [24]u8
|
||||
worth: [160]u8
|
||||
return Fill(topup_copy.amount, FormatInteger(dew, digits[:]), XmrAndUsd(atomic, usd_cents, worth[:]), "", output)
|
||||
}
|
||||
|
||||
// One deposit as "0.05 XMR · 3 of 10 confirmations" or what became of it.
|
||||
DepositText :: (deposit: DewDeposit, required: s64, output: []u8) -> string {
|
||||
xmr: [48]u8
|
||||
dollars: [48]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, FormatInteger(dew, digits[:])) || !Append(output, *at, " Dew = ") ||
|
||||
!Append(output, *at, XmrText(atomic, xmr[:])) { return "" }
|
||||
worth := UsdText(UsdCents(atomic, usd_cents), dollars[:])
|
||||
if worth != "" && (!Append(output, *at, " · ") || !Append(output, *at, worth)) { return "" }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
PayText :: (dew: s64, output: []u8) -> string {
|
||||
if dew <= 0 { return "Pay with another coin" }
|
||||
digits: [24]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, "Pay ") || !Append(output, *at, FormatInteger(dew, digits[:])) ||
|
||||
!Append(output, *at, " Dew with another coin") { return "Pay with another coin" }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
// "Other coins need at least 100 Dew (0.01 XMR)."
|
||||
MinimumText :: (minimum: s64, rate: DewRate, output: []u8) -> string {
|
||||
digits: [24]u8
|
||||
xmr: [48]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, "Other coins need at least ") || !Append(output, *at, FormatInteger(minimum, digits[:])) ||
|
||||
!Append(output, *at, " Dew (") || !Append(output, *at, XmrText(TROCADOR_MINIMUM_ATOMIC, xmr[:])) ||
|
||||
!Append(output, *at, "). Monero takes any amount.") { return "" }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
FeeText :: (dew: s64, output: []u8) -> string {
|
||||
if dew <= 0 { return "Opens trocador.app in a new tab." }
|
||||
digits: [24]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, "Opens trocador.app in a new tab. Trocador adds its swap fee to what you pay, so ") ||
|
||||
!Append(output, *at, FormatInteger(dew, digits[:])) ||
|
||||
!Append(output, *at, " Dew reach you; whatever Monero arrives becomes Dew.") { return "" }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
// Monero adds a block about every two minutes.
|
||||
ConfirmationText :: (confirmations: s64, output: []u8) -> string {
|
||||
digits: [24]u8
|
||||
minutes: [24]u8
|
||||
at: s64 = 0
|
||||
if !Append(output, *at, "Your Dew arrives after ") || !Append(output, *at, FormatInteger(confirmations, digits[:])) ||
|
||||
!Append(output, *at, " confirmations, about ") || !Append(output, *at, FormatInteger(confirmations * 2, minutes[:])) ||
|
||||
!Append(output, *at, " minutes after you send.") { return "" }
|
||||
return TextUntilNul(output)
|
||||
first: [24]u8
|
||||
second: [24]u8
|
||||
amount := XmrText(deposit.atomic, xmr[:])
|
||||
state := TextUntilNul(deposit.status[:])
|
||||
if state == "credited" {
|
||||
dew: [48]u8
|
||||
unused DewFormat(deposit.units, DewUnits, dew[:])
|
||||
return Fill(topup_copy.deposit_credited, amount, TextUntilNul(dew[:]), "", output)
|
||||
}
|
||||
if state == "confirmed" { return Fill(topup_copy.deposit_confirmed, amount, "", "", output) }
|
||||
if state == "below_minimum" { return Fill(topup_copy.deposit_below, amount, "", "", output) }
|
||||
if state == "double_spend" { return Fill(topup_copy.deposit_double, amount, "", "", output) }
|
||||
seen := ifx deposit.confirmations < required then deposit.confirmations else required
|
||||
return Fill(topup_copy.deposit_confirming, amount, FormatInteger(seen, first[:]), FormatInteger(required, second[:]), output)
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
// The page's words in English, German and Spanish. %1, %2 and %3 stand for
|
||||
// the values Fill puts in, so each language keeps its own word order.
|
||||
TopupCopy :: struct {
|
||||
language: string
|
||||
tagline: string
|
||||
sign_in: string
|
||||
profile: string
|
||||
back: string
|
||||
sign_in_title: string
|
||||
sign_in_hint: string
|
||||
balance: string
|
||||
signed_in_as: string
|
||||
node_error: string
|
||||
node_retry: string
|
||||
retry_now: string
|
||||
guest_for: string
|
||||
guest_hint: string
|
||||
account_invalid: string
|
||||
how_much: string
|
||||
other_amount: string
|
||||
other_amount_hint: string
|
||||
choose_amount: string
|
||||
loading_rate: string
|
||||
amount: string
|
||||
about: string
|
||||
pay_monero: string
|
||||
any_amount: string
|
||||
sign_in_address: string
|
||||
address_retry: string
|
||||
address_loading: string
|
||||
copy_address: string
|
||||
copied: string
|
||||
confirmations: string
|
||||
incoming: string
|
||||
no_deposits: string
|
||||
deposit_confirming: string
|
||||
deposit_confirmed: string
|
||||
deposit_credited: string
|
||||
deposit_below: string
|
||||
deposit_double: string
|
||||
other_coin: string
|
||||
other_coin_body: string
|
||||
pay_other: string
|
||||
sign_in_first: string
|
||||
minimum: string
|
||||
opens: string
|
||||
fee: string
|
||||
footer: string
|
||||
}
|
||||
|
||||
TopupEnglish :: () -> TopupCopy {
|
||||
return TopupCopy.{
|
||||
.language = "en",
|
||||
.tagline = "One currency for every Waozi app. Top it up here with Monero or almost any other coin.",
|
||||
.sign_in = "Sign in",
|
||||
.profile = "Profile",
|
||||
.back = "Back",
|
||||
.sign_in_title = "Sign in with your profile to see your Dew and top it up.",
|
||||
.sign_in_hint = "Use the same profile as in Inner Breeze, Arcade or Shovey: link this browser from the app, or import your key.",
|
||||
.balance = "Your balance",
|
||||
.signed_in_as = "Signed in as %1",
|
||||
.node_error = "The node did not answer. The balance shown is the last one it confirmed.",
|
||||
.node_retry = "The Dew node is not answering right now. Trying again in %1 s.",
|
||||
.retry_now = "Retry now",
|
||||
.guest_for = "You are topping up Dew for %1.",
|
||||
.guest_hint = "Sign in to see the balance. You don't need to for paying.",
|
||||
.account_invalid = "That account link is not valid. Sign in to top up your own Dew.",
|
||||
.how_much = "How much Dew?",
|
||||
.other_amount = "Other amount",
|
||||
.other_amount_hint = "Other amount in Dew",
|
||||
.choose_amount = "Choose an amount, or type any whole number of Dew.",
|
||||
.loading_rate = "Loading the rate…",
|
||||
.amount = "%1 Dew = %2",
|
||||
.about = "about %1",
|
||||
.pay_monero = "Pay with Monero",
|
||||
.any_amount = "Any amount works. You get Dew for exactly the Monero that arrives.",
|
||||
.sign_in_address = "Sign in to see your own Monero address.",
|
||||
.address_retry = "The address could not be loaded yet. Trying again…",
|
||||
.address_loading = "Getting the address…",
|
||||
.copy_address = "Copy address",
|
||||
.copied = "Copied",
|
||||
.confirmations = "Dew arrives after %1 confirmations, about %2 minutes after you send.",
|
||||
.incoming = "Incoming payments",
|
||||
.no_deposits = "No payment seen yet. It shows up here as soon as it reaches the network.",
|
||||
.deposit_confirming = "%1 · %2 of %3 confirmations",
|
||||
.deposit_confirmed = "%1 · confirmed, adding Dew…",
|
||||
.deposit_credited = "%1 · %2 Dew added",
|
||||
.deposit_below = "%1 · below the minimum",
|
||||
.deposit_double = "%1 · rejected (double spend)",
|
||||
.other_coin = "Pay with another coin",
|
||||
.other_coin_body = "Bitcoin, Ethereum, Litecoin, USDT and hundreds more. Trocador swaps the coin to Monero and sends it to the Dew address.",
|
||||
.pay_other = "Buy %1 Dew with another coin",
|
||||
.sign_in_first = "Sign in first, so Trocador sends to your own address.",
|
||||
.minimum = "Other coins need at least %1 Dew (%2). Monero takes any amount.",
|
||||
.opens = "Opens trocador.app in a new tab.",
|
||||
.fee = "Opens trocador.app in a new tab. Trocador adds its swap fee to what you pay, so %1 Dew arrive; whatever Monero arrives becomes Dew.",
|
||||
.footer = "Dew works in every Waozi app: unlock practices and storage in Inner Breeze, dress up your worm in Apfelwurm and earn it in Shovey."}
|
||||
}
|
||||
|
||||
TopupGerman :: () -> TopupCopy {
|
||||
return TopupCopy.{
|
||||
.language = "de",
|
||||
.tagline = "Eine Währung für alle Waozi-Apps. Lade sie hier mit Monero oder fast jedem anderen Coin auf.",
|
||||
.sign_in = "Anmelden",
|
||||
.profile = "Profil",
|
||||
.back = "Zurück",
|
||||
.sign_in_title = "Melde dich mit deinem Profil an, um dein Dew zu sehen und aufzuladen.",
|
||||
.sign_in_hint = "Nutze dasselbe Profil wie in Inner Breeze, Arcade oder Shovey: Verknüpfe diesen Browser in der App oder importiere deinen Schlüssel.",
|
||||
.balance = "Dein Guthaben",
|
||||
.signed_in_as = "Angemeldet als %1",
|
||||
.node_error = "Der Knoten hat nicht geantwortet. Das angezeigte Guthaben ist das zuletzt bestätigte.",
|
||||
.node_retry = "Der Dew-Knoten antwortet gerade nicht. Neuer Versuch in %1 s.",
|
||||
.retry_now = "Jetzt erneut versuchen",
|
||||
.guest_for = "Du lädst Dew für %1 auf.",
|
||||
.guest_hint = "Melde dich an, um das Guthaben zu sehen. Zum Bezahlen ist das nicht nötig.",
|
||||
.account_invalid = "Dieser Kontolink ist ungültig. Melde dich an, um dein eigenes Dew aufzuladen.",
|
||||
.how_much = "Wie viel Dew?",
|
||||
.other_amount = "Anderer Betrag",
|
||||
.other_amount_hint = "Anderer Betrag in Dew",
|
||||
.choose_amount = "Wähle einen Betrag oder gib eine ganze Zahl Dew ein.",
|
||||
.loading_rate = "Kurs wird geladen …",
|
||||
.amount = "%1 Dew = %2",
|
||||
.about = "etwa %1",
|
||||
.pay_monero = "Mit Monero bezahlen",
|
||||
.any_amount = "Jeder Betrag funktioniert. Du bekommst Dew für genau das Monero, das ankommt.",
|
||||
.sign_in_address = "Melde dich an, um deine eigene Monero-Adresse zu sehen.",
|
||||
.address_retry = "Die Adresse konnte noch nicht geladen werden. Neuer Versuch …",
|
||||
.address_loading = "Adresse wird geladen …",
|
||||
.copy_address = "Adresse kopieren",
|
||||
.copied = "Kopiert",
|
||||
.confirmations = "Dew kommt nach %1 Bestätigungen an, etwa %2 Minuten nach dem Senden.",
|
||||
.incoming = "Eingehende Zahlungen",
|
||||
.no_deposits = "Noch keine Zahlung gesehen. Sie erscheint hier, sobald sie im Netzwerk ist.",
|
||||
.deposit_confirming = "%1 · %2 von %3 Bestätigungen",
|
||||
.deposit_confirmed = "%1 · bestätigt, Dew wird gutgeschrieben …",
|
||||
.deposit_credited = "%1 · %2 Dew gutgeschrieben",
|
||||
.deposit_below = "%1 · unter dem Mindestbetrag",
|
||||
.deposit_double = "%1 · abgelehnt (doppelt ausgegeben)",
|
||||
.other_coin = "Mit einem anderen Coin bezahlen",
|
||||
.other_coin_body = "Bitcoin, Ethereum, Litecoin, USDT und Hunderte mehr. Trocador tauscht den Coin in Monero und schickt es an die Dew-Adresse.",
|
||||
.pay_other = "%1 Dew mit anderem Coin kaufen",
|
||||
.sign_in_first = "Melde dich zuerst an, damit Trocador an deine eigene Adresse sendet.",
|
||||
.minimum = "Andere Coins brauchen mindestens %1 Dew (%2). Monero nimmt jeden Betrag.",
|
||||
.opens = "Öffnet trocador.app in einem neuen Tab.",
|
||||
.fee = "Öffnet trocador.app in einem neuen Tab. Trocador schlägt seine Tauschgebühr auf deinen Betrag auf, damit %1 Dew ankommen; jedes ankommende Monero wird zu Dew.",
|
||||
.footer = "Dew funktioniert in jeder Waozi-App: Schalte Übungen und Speicher in Inner Breeze frei, kleide deinen Wurm in Apfelwurm ein und verdiene es in Shovey."}
|
||||
}
|
||||
|
||||
TopupSpanish :: () -> TopupCopy {
|
||||
return TopupCopy.{
|
||||
.language = "es",
|
||||
.tagline = "Una moneda para todas las apps de Waozi. Recárgala aquí con Monero o casi cualquier otra moneda.",
|
||||
.sign_in = "Iniciar sesión",
|
||||
.profile = "Perfil",
|
||||
.back = "Atrás",
|
||||
.sign_in_title = "Inicia sesión con tu perfil para ver tu Dew y recargarlo.",
|
||||
.sign_in_hint = "Usa el mismo perfil que en Inner Breeze, Arcade o Shovey: vincula este navegador desde la app o importa tu clave.",
|
||||
.balance = "Tu saldo",
|
||||
.signed_in_as = "Sesión iniciada como %1",
|
||||
.node_error = "El nodo no respondió. El saldo mostrado es el último que confirmó.",
|
||||
.node_retry = "El nodo de Dew no responde ahora mismo. Reintentando en %1 s.",
|
||||
.retry_now = "Reintentar ahora",
|
||||
.guest_for = "Estás recargando Dew para %1.",
|
||||
.guest_hint = "Inicia sesión para ver el saldo. No hace falta para pagar.",
|
||||
.account_invalid = "Ese enlace de cuenta no es válido. Inicia sesión para recargar tu propio Dew.",
|
||||
.how_much = "¿Cuánto Dew?",
|
||||
.other_amount = "Otra cantidad",
|
||||
.other_amount_hint = "Otra cantidad en Dew",
|
||||
.choose_amount = "Elige una cantidad o escribe cualquier número entero de Dew.",
|
||||
.loading_rate = "Cargando la tasa…",
|
||||
.amount = "%1 Dew = %2",
|
||||
.about = "unos %1",
|
||||
.pay_monero = "Pagar con Monero",
|
||||
.any_amount = "Funciona cualquier cantidad. Recibes Dew por exactamente el Monero que llega.",
|
||||
.sign_in_address = "Inicia sesión para ver tu propia dirección de Monero.",
|
||||
.address_retry = "La dirección aún no se pudo cargar. Reintentando…",
|
||||
.address_loading = "Obteniendo la dirección…",
|
||||
.copy_address = "Copiar dirección",
|
||||
.copied = "Copiada",
|
||||
.confirmations = "El Dew llega tras %1 confirmaciones, unos %2 minutos después del envío.",
|
||||
.incoming = "Pagos entrantes",
|
||||
.no_deposits = "Aún no se ha visto ningún pago. Aparecerá aquí en cuanto llegue a la red.",
|
||||
.deposit_confirming = "%1 · %2 de %3 confirmaciones",
|
||||
.deposit_confirmed = "%1 · confirmado, añadiendo Dew…",
|
||||
.deposit_credited = "%1 · %2 Dew añadidos",
|
||||
.deposit_below = "%1 · por debajo del mínimo",
|
||||
.deposit_double = "%1 · rechazado (doble gasto)",
|
||||
.other_coin = "Pagar con otra moneda",
|
||||
.other_coin_body = "Bitcoin, Ethereum, Litecoin, USDT y cientos más. Trocador cambia la moneda a Monero y la envía a la dirección de Dew.",
|
||||
.pay_other = "Comprar %1 Dew con otra moneda",
|
||||
.sign_in_first = "Inicia sesión primero para que Trocador envíe a tu propia dirección.",
|
||||
.minimum = "Otras monedas necesitan al menos %1 Dew (%2). Monero acepta cualquier cantidad.",
|
||||
.opens = "Abre trocador.app en una pestaña nueva.",
|
||||
.fee = "Abre trocador.app en una pestaña nueva. Trocador suma su comisión de cambio a lo que pagas, así llegan %1 Dew; todo Monero que llegue se convierte en Dew.",
|
||||
.footer = "Dew funciona en todas las apps de Waozi: desbloquea prácticas y almacenamiento en Inner Breeze, viste a tu gusano en Apfelwurm y gánalo en Shovey."}
|
||||
}
|
||||
|
||||
// The copy for a browser language such as "de-AT"; English otherwise.
|
||||
TopupCopyFor :: (language: string) -> TopupCopy {
|
||||
if language.count >= 2 {
|
||||
first := language[0] | cast(u8)32
|
||||
second := language[1] | cast(u8)32
|
||||
if first == cast(u8)100 && second == cast(u8)101 { return TopupGerman() }
|
||||
if first == cast(u8)101 && second == cast(u8)115 { return TopupSpanish() }
|
||||
}
|
||||
return TopupEnglish()
|
||||
}
|
||||
+107
-4
@@ -73,12 +73,13 @@ XmrText :: (atomic: s64, output: []u8) -> string {
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
// "about $29.54", or "" without a known price.
|
||||
// "$29.54", or "" without a known price.
|
||||
UsdText :: (cents: s64, output: []u8) -> string {
|
||||
if cents <= 0 || output.count < 32 { return "" }
|
||||
digits: [24]u8
|
||||
at: s64 = 0
|
||||
for byte: "about $" { output[at] = byte; at += 1 }
|
||||
output[at] = cast(u8)36
|
||||
at += 1
|
||||
for byte: FormatInteger(cents / 100, digits[:]) { output[at] = byte; at += 1 }
|
||||
output[at] = cast(u8)46
|
||||
output[at + 1] = cast(u8)(48 + cents % 100 / 10)
|
||||
@@ -144,13 +145,16 @@ MoneroUri :: (address: string, atomic: s64, output: []u8) -> string {
|
||||
// it and sends exactly atomic piconero to the account's own address, where
|
||||
// the node credits the Dew as for any Monero payment. Monero itself is paid
|
||||
// on the page, so AnonPay offers only the other coins.
|
||||
TrocadorUrl :: (address: string, atomic: s64, dew: s64, output: []u8) -> string {
|
||||
TrocadorUrl :: (address: string, atomic: s64, dew: s64, language: string, output: []u8) -> string {
|
||||
amount: [48]u8
|
||||
digits: [24]u8
|
||||
at: s64 = 0
|
||||
if !AddressSafe(address) || atomic < TROCADOR_MINIMUM_ATOMIC || dew <= 0 ||
|
||||
!DewFormat(atomic, PICONERO, amount[:]) { return "" }
|
||||
if !Append(output, *at, "https://trocador.app/anonpay/?ticker_to=xmr&network_to=Mainnet&address=") ||
|
||||
// Trocador shows its checkout in German or Spanish under /de/ and /es/.
|
||||
if !Append(output, *at, "https://trocador.app/") ||
|
||||
((language == "de" || language == "es") && (!Append(output, *at, language) || !Append(output, *at, "/"))) ||
|
||||
!Append(output, *at, "anonpay/?ticker_to=xmr&network_to=Mainnet&address=") ||
|
||||
!Append(output, *at, address) || !Append(output, *at, "&amount=") ||
|
||||
!Append(output, *at, TextUntilNul(amount[:])) || !Append(output, *at, "&name=Dew&description=") ||
|
||||
!Append(output, *at, FormatInteger(dew, digits[:])) ||
|
||||
@@ -159,3 +163,102 @@ TrocadorUrl :: (address: string, atomic: s64, dew: s64, output: []u8) -> string
|
||||
}
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
// A template with %1, %2 and %3 filled in, cut short only if output is full.
|
||||
Fill :: (template: string, first: string, second: string, third: string, output: []u8) -> string {
|
||||
at: s64 = 0
|
||||
index: s64 = 0
|
||||
while index < template.count {
|
||||
byte := template[index]
|
||||
value := ""
|
||||
placeholder := false
|
||||
if byte == cast(u8)37 && index + 1 < template.count {
|
||||
next := template[index + 1]
|
||||
placeholder = next == cast(u8)49 || next == cast(u8)50 || next == cast(u8)51
|
||||
value = ifx next == cast(u8)49 then first else ifx next == cast(u8)50 then second else third
|
||||
}
|
||||
if placeholder {
|
||||
if !Append(output, *at, value) { break }
|
||||
index += 2
|
||||
continue
|
||||
}
|
||||
if at + 1 >= output.count { break }
|
||||
output[at] = byte
|
||||
at += 1
|
||||
output[at] = cast(u8)0
|
||||
index += 1
|
||||
}
|
||||
if output.count > 0 && at < output.count { output[at] = cast(u8)0 }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
|
||||
// The value of name in a page query such as "?account=abc&lang=de"; ""
|
||||
// when it is missing, empty or holds anything but letters, digits, '.',
|
||||
// '_' and '-'.
|
||||
QueryValue :: (query: string, name: string, output: []u8) -> string {
|
||||
start: s64 = ifx query.count > 0 && query[0] == cast(u8)63 then 1 else 0
|
||||
index := start
|
||||
while index <= query.count {
|
||||
if index == query.count || query[index] == cast(u8)38 {
|
||||
part := query[start:index]
|
||||
if part.count > name.count && part[:name.count] == name && part[name.count] == cast(u8)61 {
|
||||
value := part[name.count + 1:]
|
||||
if !ReferenceValid(value) || !CopyCString(value, output) { return "" }
|
||||
return TextUntilNul(output)
|
||||
}
|
||||
start = index + 1
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// An account ID or alias as a link may name it.
|
||||
ReferenceValid :: (value: string) -> bool {
|
||||
if value.count == 0 || value.count > 64 { return false }
|
||||
for byte: value {
|
||||
digit := byte >= cast(u8)48 && byte <= cast(u8)57
|
||||
letter := (byte >= cast(u8)65 && byte <= cast(u8)90) || (byte >= cast(u8)97 && byte <= cast(u8)122)
|
||||
if !digit && !letter && byte != cast(u8)46 && byte != cast(u8)95 && byte != cast(u8)45 { return false }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// The public GET /api/v1/tokens/purchases/monero/address/REFERENCE answer:
|
||||
// whose address it is and where to pay.
|
||||
DewParseRecipient :: (json: string, funding: *DewFunding, account: []u8, alias: []u8) -> bool {
|
||||
id: [65]u8
|
||||
if ReadStringText(json, FieldAt(json, 0, "account_id"), id[:]) != 64 ||
|
||||
!DewParseFunding(json, TextUntilNul(id[:]), funding) || !CopyCString(TextUntilNul(id[:]), account) { return false }
|
||||
if alias.count > 0 { alias[0] = cast(u8)0 }
|
||||
if ReadStringText(json, FieldAt(json, 0, "alias"), alias) < 0 && alias.count > 0 { alias[0] = cast(u8)0 }
|
||||
return true
|
||||
}
|
||||
|
||||
DewDeposit :: struct {
|
||||
atomic: s64
|
||||
units: s64
|
||||
confirmations: s64
|
||||
status: [24]u8
|
||||
}
|
||||
|
||||
// The newest deposits from {"deposits":[…]}, at most output.count; -1 when
|
||||
// the answer is not a deposit list.
|
||||
DewParseDeposits :: (json: string, output: []DewDeposit) -> s32 {
|
||||
list := FieldAt(json, 0, "deposits")
|
||||
count := ArrayCount(json, list)
|
||||
if json.count == 0 || count < 0 { return -1 }
|
||||
used: s32 = 0
|
||||
for index: 0..count - 1 {
|
||||
if cast(s64)used >= output.count { break }
|
||||
at := ElementAt(json, list, cast(s32)index)
|
||||
deposit: DewDeposit
|
||||
if !DewInteger(json, FieldAt(json, at, "amount_atomic"), *deposit.atomic) ||
|
||||
!DewInteger(json, FieldAt(json, at, "confirmations"), *deposit.confirmations) ||
|
||||
ReadStringText(json, FieldAt(json, at, "status"), deposit.status[:]) <= 0 { continue }
|
||||
if !DewInteger(json, FieldAt(json, at, "token_units"), *deposit.units) { deposit.units = 0 }
|
||||
output[used] = deposit
|
||||
used += 1
|
||||
}
|
||||
return used
|
||||
}
|
||||
+23
-3
@@ -22,10 +22,25 @@ using Canvas :: #import "kryon/Canvas";
|
||||
#import "kryon/drawing_props"
|
||||
#import "kryon/widget_palette"
|
||||
#import "kryon/TestDriver"
|
||||
#import "kryon/PageRoute"
|
||||
#import "std/file"
|
||||
#import "std/web"
|
||||
#import "std/c_string"
|
||||
#import "std/byte_text_linux"
|
||||
#import "entity/native_host"
|
||||
#import "topup"
|
||||
#import "topup_copy"
|
||||
|
||||
// The browser's preferred language, such as "de-AT".
|
||||
BrowserLanguage :: (output: []u8) -> string {
|
||||
navigator := WebGetObject(WebGlobal, WebName("navigator"))
|
||||
if navigator == 0 { return "" }
|
||||
handle := WebAsObject(WebGet(navigator, WebName("language")))
|
||||
if handle == 0 { return "" }
|
||||
length := WebCopyString(handle, output)
|
||||
if length <= 0 || length >= cast(s32)output.count { return "" }
|
||||
return TextFromBytes(output[:length])
|
||||
}
|
||||
|
||||
#program_export
|
||||
main :: () -> s32 {
|
||||
@@ -37,6 +52,10 @@ main :: () -> s32 {
|
||||
profile_bytes, found := ReadEntireFile("/entity.zx")
|
||||
defer { AppFileFree(profile_bytes) }
|
||||
if !found || !EntityHostOpen(profile_bytes, "/kryon-apps/profile", "dew", true) { return 1 }
|
||||
// This page is the top-up: the Profile's Top up comes back here.
|
||||
EntityHostTopUpUrl("")
|
||||
language: [64]u8
|
||||
TopupStart(TextFromCString(GetRouteQuery()), BrowserLanguage(language[:]))
|
||||
defer { unused EntityHostClose(); unused BundleStorageSync(false) }
|
||||
session := SessionOpen()
|
||||
if !SessionValid(session) { return 1 }
|
||||
@@ -77,12 +96,13 @@ main :: () -> s32 {
|
||||
.fill = ColorFromPacked(palette.background)})
|
||||
bounds := Rectangle.{viewport.x, viewport.y + 56.0, viewport.width, viewport.height - 56.0}
|
||||
if !EntityHostFrame(session, bounds, key, modifiers, input, true) { return 1 }
|
||||
Text(session, TextProps.{.key = cast(u64)49002, .text = "Profile", .font = 20,
|
||||
Text(session, TextProps.{.key = cast(u64)49002, .text = topup_copy.profile, .font = 20,
|
||||
.bounds = Rectangle.{100.0, 12.0, viewport.width - 200.0, 36.0}})
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49001, .id = 49001, .label = "Back",
|
||||
.bounds = Rectangle.{8.0, 6.0, 76.0, 44.0}}) != 0 || key == 256 {
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49001, .id = 49001, .label = topup_copy.back,
|
||||
.bounds = Rectangle.{8.0, 6.0, 92.0, 44.0}}) != 0 || key == 256 {
|
||||
if !EntityHostBack() && EntityHostSave() { profile = false }
|
||||
}
|
||||
if EntityHostTopUpRequested() && EntityHostSave() { profile = false }
|
||||
} else {
|
||||
action := TopupFrame(session, viewport, input, PageNow())
|
||||
if action != TOPUP_NONE {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#import "topup_model"
|
||||
#import "std/c_string"
|
||||
#import "std/text_buffer"
|
||||
#import "entity/dew_model"
|
||||
|
||||
ADDRESS :: "8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd"
|
||||
|
||||
@@ -27,8 +29,8 @@ main :: () -> s32 {
|
||||
if XmrText(1000000000000, text[:]) != "1 XMR" { return 11 }
|
||||
if UsdCents(50000000000, 59078) != 2953 { return 12 }
|
||||
if UsdCents(3000000000000000, 59078) != 177234000 { return 13 }
|
||||
if UsdText(2953, text[:]) != "about $29.53" { return 14 }
|
||||
if UsdText(5, text[:]) != "about $0.05" || UsdText(0, text[:]) != "" { return 15 }
|
||||
if UsdText(2953, text[:]) != "$29.53" { return 14 }
|
||||
if UsdText(5, text[:]) != "$0.05" || UsdText(0, text[:]) != "" { return 15 }
|
||||
|
||||
if DewTyped("250") != 250 || DewTyped("") != 0 || DewTyped("12a") != 0 || DewTyped("12345678") != 0 { return 16 }
|
||||
|
||||
@@ -43,11 +45,41 @@ main :: () -> s32 {
|
||||
if MoneroUri(ADDRESS, 0, link[:]) != "monero:8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd" { return 22 }
|
||||
if MoneroUri("8bad&address", 1, link[:]) != "" { return 23 }
|
||||
expected := "https://trocador.app/anonpay/?ticker_to=xmr&network_to=Mainnet&address=8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd&amount=0.05&name=Dew&description=500%20Dew&simple_mode=True&remove_direct_pay=True&buttonbgcolor=2f9fc4&textcolor=ffffff"
|
||||
if TrocadorUrl(ADDRESS, 50000000000, 500, link[:]) != expected { return 24 }
|
||||
if TrocadorUrl(ADDRESS, 50000000000, 500, "en", link[:]) != expected { return 24 }
|
||||
// Below Trocador's floor there is no link; Monero takes any amount.
|
||||
if TrocadorUrl(ADDRESS, TROCADOR_MINIMUM_ATOMIC - 1, 99, link[:]) != "" { return 25 }
|
||||
if TrocadorUrl("8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd&email=x", 50000000000, 500, link[:]) != "" { return 26 }
|
||||
if TrocadorUrl(ADDRESS, TROCADOR_MINIMUM_ATOMIC - 1, 99, "en", link[:]) != "" { return 25 }
|
||||
if TrocadorUrl("8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd&email=x", 50000000000, 500, "en", link[:]) != "" { return 26 }
|
||||
short: [40]u8
|
||||
if TrocadorUrl(ADDRESS, 50000000000, 500, short[:]) != "" { return 27 }
|
||||
if TrocadorUrl(ADDRESS, 50000000000, 500, "en", short[:]) != "" { return 27 }
|
||||
if TrocadorUrl(ADDRESS, 50000000000, 500, "de", link[:]) != "https://trocador.app/de/anonpay/?ticker_to=xmr&network_to=Mainnet&address=8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd&amount=0.05&name=Dew&description=500%20Dew&simple_mode=True&remove_direct_pay=True&buttonbgcolor=2f9fc4&textcolor=ffffff" { return 28 }
|
||||
|
||||
filled: [256]u8
|
||||
if Fill("%1 · %2 of %3 confirmations", "0.05 XMR", "3", "10", filled[:]) != "0.05 XMR · 3 of 10 confirmations" { return 30 }
|
||||
if Fill("Dew kommt nach %1 Bestätigungen an", "10", "", "", filled[:]) != "Dew kommt nach 10 Bestätigungen an" { return 31 }
|
||||
if Fill("100% sure, %4 stays", "x", "", "", filled[:]) != "100% sure, %4 stays" { return 32 }
|
||||
tiny: [8]u8
|
||||
if Fill("%1 Dew", "123456789", "", "", tiny[:]) != "" { return 33 }
|
||||
|
||||
value: [80]u8
|
||||
if QueryValue("?account=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&lang=de", "account", value[:]) != "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" { return 40 }
|
||||
if QueryValue("?account=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&lang=de", "lang", value[:]) != "de" { return 41 }
|
||||
if QueryValue("lang=es", "lang", value[:]) != "es" || QueryValue("?mini", "account", value[:]) != "" { return 42 }
|
||||
if QueryValue("?account=a%20b", "account", value[:]) != "" || QueryValue("?accounts=x", "account", value[:]) != "" { return 43 }
|
||||
if !ReferenceValid("emerald") || ReferenceValid("") || ReferenceValid("a b") { return 44 }
|
||||
|
||||
funding: DewFunding
|
||||
account: [65]u8
|
||||
alias: [40]u8
|
||||
recipient := "{\"account_id\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"alias\":\"emerald\",\"asset_id\":\"waozi:token\",\"address\":\"8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd\",\"uri\":\"monero:8AbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCdEfGhJkAbCd\",\"network\":\"mainnet\",\"confirmations_required\":10,\"minimum_atomic_amount\":1,\"rate\":{\"xmr_atomic_units\":1000000000000,\"token_units\":10000000000}}"
|
||||
if !DewParseRecipient(recipient, *funding, account[:], alias[:]) { return 50 }
|
||||
if TextUntilNul(account[:]) != "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" || TextUntilNul(alias[:]) != "emerald" || funding.confirmations != 10 || funding.minimum != 1 { return 51 }
|
||||
if DewParseRecipient("{\"account_id\":\"short\"}", *funding, account[:], alias[:]) { return 52 }
|
||||
|
||||
deposits: [3]DewDeposit
|
||||
list := "{\"deposits\":[{\"tx_id\":\"t1\",\"amount_atomic\":50000000000,\"confirmations\":3,\"status\":\"confirming\",\"first_seen_at\":\"2026-10-27T17:00:00Z\"},{\"tx_id\":\"t0\",\"amount_atomic\":10000000000,\"token_units\":100000000,\"confirmations\":12,\"status\":\"credited\",\"first_seen_at\":\"2026-10-26T17:00:00Z\"}]}"
|
||||
if DewParseDeposits(list, deposits[:]) != 2 { return 60 }
|
||||
if deposits[0].atomic != 50000000000 || deposits[0].confirmations != 3 || TextUntilNul(deposits[0].status[:]) != "confirming" || deposits[0].units != 0 { return 61 }
|
||||
if deposits[1].units != 100000000 || TextUntilNul(deposits[1].status[:]) != "credited" { return 62 }
|
||||
if DewParseDeposits("{\"deposits\":[]}", deposits[:]) != 0 || DewParseDeposits("{}", deposits[:]) != -1 || DewParseDeposits("", deposits[:]) != -1 { return 63 }
|
||||
return 0
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Open dew.waozi.xyz's build in a private headless browser: the page must draw
|
||||
// without a failed frame, and its Sign in button must open the shared Profile.
|
||||
// Usage: node tests/web_site_test.mjs SITE_DIR
|
||||
// Usage: node tests/web_site_test.mjs SITE_DIR|URL
|
||||
import { spawn } from 'node:child_process';
|
||||
import { createServer } from 'node:http';
|
||||
import { access, mkdtemp, readFile, rm } from 'node:fs/promises';
|
||||
@@ -8,8 +8,10 @@ import { tmpdir } from 'node:os';
|
||||
import { extname, join, normalize } from 'node:path';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
|
||||
// SITE_DIR is served locally; an https URL tests the deployed site instead.
|
||||
const site = process.argv[2];
|
||||
if (!site) throw new Error('Usage: node tests/web_site_test.mjs SITE_DIR');
|
||||
if (!site) throw new Error('Usage: node tests/web_site_test.mjs SITE_DIR|URL');
|
||||
const live = /^https:\/\//.test(site);
|
||||
const types = { '.html': 'text/html', '.js': 'text/javascript', '.wasm': 'application/wasm', '.json': 'application/json',
|
||||
'.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.webmanifest': 'application/manifest+json' };
|
||||
const server = createServer(async (request, response) => {
|
||||
@@ -55,7 +57,7 @@ try {
|
||||
};
|
||||
await command('Runtime.enable'); await command('Page.enable');
|
||||
await command('Emulation.setDeviceMetricsOverride', { width: 1280, height: 800, deviceScaleFactor: 1, mobile: false });
|
||||
await command('Page.navigate', { url: `http://127.0.0.1:${server.address().port}/` });
|
||||
await command('Page.navigate', { url: live ? site : `http://127.0.0.1:${server.address().port}/` });
|
||||
let ready = false;
|
||||
const deadline = Date.now() + 60000;
|
||||
while (!ready && Date.now() < deadline) {
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "0.1.0"
|
||||
"version": "0.2.2"
|
||||
}
|
||||
+12
-12
@@ -9,14 +9,6 @@
|
||||
"ref": "master",
|
||||
"url": "https://github.com/ziranlang/qrcode.git"
|
||||
},
|
||||
{
|
||||
"commit": "e771eb1edc7e2c641307fc5d4d185ebe4e168db0",
|
||||
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "p3127065409ca96f6", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
|
||||
"id": "p11cf3dfff58c77a3",
|
||||
"name": "Entity",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/waozixyz/entity.git"
|
||||
},
|
||||
{
|
||||
"commit": "0931212f92d5f1a3f8b1be80abab7a9695bda50e",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
@@ -36,7 +28,7 @@
|
||||
},
|
||||
{
|
||||
"commit": "22d2ddbdc236796953c905a05a2cebf5ab1b4ff3",
|
||||
"dependencies": {"liboqs": "pe6e1a0c8fb76aa60"},
|
||||
"dependencies": {"liboqs": "pe86510e9fb3fef51"},
|
||||
"id": "p7098ac9cd92f7e5f",
|
||||
"name": "Oqs",
|
||||
"ref": "master",
|
||||
@@ -59,6 +51,14 @@
|
||||
"ref": "master",
|
||||
"url": "https://github.com/ziranlang/daochi-client.git"
|
||||
},
|
||||
{
|
||||
"commit": "7d37be6e1f0643c01b35545e42e48c633f19a90d",
|
||||
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "p3127065409ca96f6", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
|
||||
"id": "p6feeecb5bfff3686",
|
||||
"name": "Entity",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/waozixyz/entity.git"
|
||||
},
|
||||
{
|
||||
"commit": "944826f70779a6b6cd53f6b06a75b36f4d8a2558",
|
||||
"dependencies": {},
|
||||
@@ -68,9 +68,9 @@
|
||||
"url": "https://github.com/ziranlang/crypto.git"
|
||||
},
|
||||
{
|
||||
"commit": "c98cd0cff056978d63b18fad8d013d58bacd9b5d",
|
||||
"commit": "48955d1117ed6207a12d2a4c9e4162283d3420a5",
|
||||
"dependencies": {},
|
||||
"id": "pe6e1a0c8fb76aa60",
|
||||
"id": "pe86510e9fb3fef51",
|
||||
"name": "liboqs",
|
||||
"ref": "main",
|
||||
"source": true,
|
||||
@@ -78,7 +78,7 @@
|
||||
}
|
||||
],
|
||||
"root": {
|
||||
"dependencies": {"entity": "p11cf3dfff58c77a3", "kryon": "p3127065409ca96f6", "qrcode": "p0dfa70137405b096"},
|
||||
"dependencies": {"entity": "p6feeecb5bfff3686", "kryon": "p3127065409ca96f6", "qrcode": "p0dfa70137405b096"},
|
||||
"name": "Dew"
|
||||
},
|
||||
"toolchain": {
|
||||
|
||||
Reference in new issue
Block a user