Gift Dew to friends from the friend list

Wherever Dew is sold (every build but Play), each friend in Profile has a
gift button. It opens a Gift Dew window with the balance and the node's
exchange rate in XMR and USD, an amount in whole Dew with what it is
worth, and a Send button; gifts are final and say so. The node moves the
Dew in one signed debit and credit. A gift whose answer is uncertain is
kept and sent again with the same request until the node confirms or
refuses it, so it never goes twice; missing Dew, a non-friend and refused
requests are explained.
This commit is contained in:
waozi committed 2026-10-16 02:52:23 -03:00
1 parent 13175486f4
commit 7c8fd0458b
23 files changed
+1050 -6

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+42
View File
@@ -5284,6 +5284,48 @@ Pošli Monero na tuto adresu. Dew se objeví po %d potvrzeních.
[dew_about_usd]
asi %s USD
---
[dew_gift_title]
Darovat Dew
---
[dew_gift_to]
Pro %s
---
[dew_gift_amount]
Množství Dew
---
[dew_gift_up_to]
Posílejte celé Dew, nejvýše %s Dew.
---
[dew_gift_too_much]
To je víc než vašich %s Dew.
---
[dew_gift_worth]
Hodnota %s
---
[dew_gift_send]
Poslat %s Dew
---
[dew_gift_sending]
Odesílání…
---
[dew_gift_waiting]
Čeká se na potvrzení uzlu. Dar se odešle jen jednou.
---
[dew_gift_sent]
Odesláno %s Dew pro %s.
---
[dew_gift_funds]
Na tento dar nemáte dost Dew.
---
[dew_gift_not_friend]
Dew můžete darovat jen přátelům.
---
[dew_gift_failed]
Dar nebyl odeslán. Zkuste to znovu.
---
[dew_gift_final]
Dar nelze vzít zpět.
---
[profile_dew_topup_hint_usd]
Na tuto adresu pošli alespoň %s XMR (asi %s USD). Dew se připíše po %d potvrzeních.
+42
View File
@@ -5278,6 +5278,48 @@ Sende Monero an diese Adresse. Dew erscheint nach %d Bestätigungen.
[dew_about_usd]
etwa %s USD
---
[dew_gift_title]
Dew schenken
---
[dew_gift_to]
An %s
---
[dew_gift_amount]
Menge in Dew
---
[dew_gift_up_to]
Ganze Dew senden, bis zu %s Dew.
---
[dew_gift_too_much]
Das ist mehr als deine %s Dew.
---
[dew_gift_worth]
Wert: %s
---
[dew_gift_send]
%s Dew senden
---
[dew_gift_sending]
Wird gesendet…
---
[dew_gift_waiting]
Warte auf die Bestätigung des Knotens. Dein Geschenk wird nur einmal gesendet.
---
[dew_gift_sent]
%s Dew an %s gesendet.
---
[dew_gift_funds]
Nicht genug Dew für dieses Geschenk.
---
[dew_gift_not_friend]
Du kannst Dew nur an Freunde verschenken.
---
[dew_gift_failed]
Das Geschenk wurde nicht gesendet. Bitte versuche es erneut.
---
[dew_gift_final]
Ein Geschenk kann nicht zurückgenommen werden.
---
[profile_dew_topup_hint_usd]
Sende mindestens %s XMR (etwa %s USD) an diese Adresse. Dew wird nach %d Bestätigungen gutgeschrieben.
+42
View File
@@ -5302,6 +5302,48 @@ Send Monero to this address. Dew appears after %d confirmations.
[dew_about_usd]
about %s USD
---
[dew_gift_title]
Gift Dew
---
[dew_gift_to]
To %s
---
[dew_gift_amount]
Amount in Dew
---
[dew_gift_up_to]
Send whole Dew, up to %s Dew.
---
[dew_gift_too_much]
That is more than your %s Dew.
---
[dew_gift_worth]
Worth %s
---
[dew_gift_send]
Send %s Dew
---
[dew_gift_sending]
Sending…
---
[dew_gift_waiting]
Waiting for the node to confirm. Your gift is sent only once.
---
[dew_gift_sent]
Sent %s Dew to %s.
---
[dew_gift_funds]
Not enough Dew for this gift.
---
[dew_gift_not_friend]
You can only gift Dew to friends.
---
[dew_gift_failed]
The gift was not sent. Please try again.
---
[dew_gift_final]
A gift can't be taken back.
---
[profile_dew_topup_hint_usd]
Send at least %s XMR (about %s USD) to this address. Dew appears after %d confirmations.
+42
View File
@@ -5278,6 +5278,48 @@ Envía Monero a esta dirección. Dew aparece tras %d confirmaciones.
[dew_about_usd]
unos %s USD
---
[dew_gift_title]
Regalar Dew
---
[dew_gift_to]
Para %s
---
[dew_gift_amount]
Cantidad de Dew
---
[dew_gift_up_to]
Envía Dew enteros, hasta %s Dew.
---
[dew_gift_too_much]
Es más que tus %s Dew.
---
[dew_gift_worth]
Vale %s
---
[dew_gift_send]
Enviar %s Dew
---
[dew_gift_sending]
Enviando…
---
[dew_gift_waiting]
Esperando la confirmación del nodo. Tu regalo se envía una sola vez.
---
[dew_gift_sent]
Enviaste %s Dew a %s.
---
[dew_gift_funds]
No tienes suficiente Dew para este regalo.
---
[dew_gift_not_friend]
Solo puedes regalar Dew a amigos.
---
[dew_gift_failed]
El regalo no se envió. Inténtalo de nuevo.
---
[dew_gift_final]
Un regalo no se puede deshacer.
---
[profile_dew_topup_hint_usd]
Envía al menos %s XMR (unos %s USD) a esta dirección. Dew aparece tras %d confirmaciones.
+42
View File
@@ -5266,6 +5266,48 @@ Envoyez des Monero à cette adresse. Les Dew apparaissent après %d confirmation
[dew_about_usd]
environ %s USD
---
[dew_gift_title]
Offrir des Dew
---
[dew_gift_to]
Pour %s
---
[dew_gift_amount]
Montant en Dew
---
[dew_gift_up_to]
Envoyez des Dew entiers, jusqu'à %s Dew.
---
[dew_gift_too_much]
C'est plus que vos %s Dew.
---
[dew_gift_worth]
Valeur : %s
---
[dew_gift_send]
Envoyer %s Dew
---
[dew_gift_sending]
Envoi…
---
[dew_gift_waiting]
En attente de la confirmation du nœud. Votre cadeau n'est envoyé qu'une fois.
---
[dew_gift_sent]
%s Dew envoyés à %s.
---
[dew_gift_funds]
Pas assez de Dew pour ce cadeau.
---
[dew_gift_not_friend]
Vous ne pouvez offrir des Dew qu'à vos amis.
---
[dew_gift_failed]
Le cadeau n'a pas été envoyé. Veuillez réessayer.
---
[dew_gift_final]
Un cadeau ne peut pas être annulé.
---
[profile_dew_topup_hint_usd]
Envoyez au moins %s XMR (environ %s USD) à cette adresse. Les Dew apparaissent après %d confirmations.
+42
View File
@@ -5267,6 +5267,48 @@ Kirim Monero ke alamat ini. Dew muncul setelah %d konfirmasi.
[dew_about_usd]
sekitar %s USD
---
[dew_gift_title]
Hadiahkan Dew
---
[dew_gift_to]
Untuk %s
---
[dew_gift_amount]
Jumlah Dew
---
[dew_gift_up_to]
Kirim Dew utuh, hingga %s Dew.
---
[dew_gift_too_much]
Itu lebih dari %s Dew milikmu.
---
[dew_gift_worth]
Senilai %s
---
[dew_gift_send]
Kirim %s Dew
---
[dew_gift_sending]
Mengirim…
---
[dew_gift_waiting]
Menunggu konfirmasi node. Hadiahmu hanya dikirim sekali.
---
[dew_gift_sent]
%s Dew terkirim ke %s.
---
[dew_gift_funds]
Dew tidak cukup untuk hadiah ini.
---
[dew_gift_not_friend]
Kamu hanya bisa menghadiahkan Dew kepada teman.
---
[dew_gift_failed]
Hadiah tidak terkirim. Silakan coba lagi.
---
[dew_gift_final]
Hadiah tidak bisa ditarik kembali.
---
[profile_dew_topup_hint_usd]
Kirim setidaknya %s XMR (sekitar %s USD) ke alamat ini. Dew masuk setelah %d konfirmasi.
+42
View File
@@ -5267,6 +5267,48 @@ Invia Monero a questo indirizzo. Dew appare dopo %d conferme.
[dew_about_usd]
circa %s USD
---
[dew_gift_title]
Regala Dew
---
[dew_gift_to]
A %s
---
[dew_gift_amount]
Quantità di Dew
---
[dew_gift_up_to]
Invia Dew interi, fino a %s Dew.
---
[dew_gift_too_much]
È più dei tuoi %s Dew.
---
[dew_gift_worth]
Valore: %s
---
[dew_gift_send]
Invia %s Dew
---
[dew_gift_sending]
Invio…
---
[dew_gift_waiting]
In attesa della conferma del nodo. Il tuo regalo viene inviato una sola volta.
---
[dew_gift_sent]
Inviati %s Dew a %s.
---
[dew_gift_funds]
Dew insufficienti per questo regalo.
---
[dew_gift_not_friend]
Puoi regalare Dew solo agli amici.
---
[dew_gift_failed]
Il regalo non è stato inviato. Riprova.
---
[dew_gift_final]
Un regalo non si può annullare.
---
[profile_dew_topup_hint_usd]
Invia almeno %s XMR (circa %s USD) a questo indirizzo. Dew compare dopo %d conferme.
+42
View File
@@ -5263,6 +5263,48 @@ Moneroアドレスを取得できませんでした。もう一度お試しく
[dew_about_usd]
約%s USD
---
[dew_gift_title]
Dewを贈る
---
[dew_gift_to]
%sへ
---
[dew_gift_amount]
Dewの数
---
[dew_gift_up_to]
Dewは整数で、%s Dewまで送れます。
---
[dew_gift_too_much]
あなたの%s Dewより多い額です。
---
[dew_gift_worth]
価値 %s
---
[dew_gift_send]
%s Dewを送る
---
[dew_gift_sending]
送信中…
---
[dew_gift_waiting]
ノードの確認を待っています。贈り物は一度だけ送られます。
---
[dew_gift_sent]
%s Dewを%sに送りました。
---
[dew_gift_funds]
この贈り物にはDewが足りません。
---
[dew_gift_not_friend]
Dewを贈れるのは友だちだけです。
---
[dew_gift_failed]
贈り物は送られませんでした。もう一度お試しください。
---
[dew_gift_final]
贈り物は取り消せません。
---
[profile_dew_topup_hint_usd]
このアドレスに%s XMR(約%s USD)以上を送ってください。%d回の承認後にDewが反映されます。
+42
View File
@@ -5273,6 +5273,48 @@ Monero 주소를 가져오지 못했습니다. 다시 시도하세요.
[dew_about_usd]
약 %s USD
---
[dew_gift_title]
Dew 선물하기
---
[dew_gift_to]
%s에게
---
[dew_gift_amount]
Dew 수량
---
[dew_gift_up_to]
Dew는 정수로, 최대 %s Dew까지 보낼 수 있어요.
---
[dew_gift_too_much]
보유한 %s Dew보다 많아요.
---
[dew_gift_worth]
가치 %s
---
[dew_gift_send]
%s Dew 보내기
---
[dew_gift_sending]
보내는 중…
---
[dew_gift_waiting]
노드의 확인을 기다리고 있어요. 선물은 한 번만 보내져요.
---
[dew_gift_sent]
%s Dew를 %s에게 보냈어요.
---
[dew_gift_funds]
이 선물을 보내기에 Dew가 부족해요.
---
[dew_gift_not_friend]
Dew는 친구에게만 선물할 수 있어요.
---
[dew_gift_failed]
선물을 보내지 못했어요. 다시 시도해 주세요.
---
[dew_gift_final]
선물은 되돌릴 수 없어요.
---
[profile_dew_topup_hint_usd]
이 주소로 최소 %s XMR(약 %s USD)를 보내세요. %d회 확인 후 Dew가 반영돼요.
+42
View File
@@ -5276,6 +5276,48 @@ Envie Monero para este endereço. Dew aparece após %d confirmações.
[dew_about_usd]
cerca de %s USD
---
[dew_gift_title]
Presentear Dew
---
[dew_gift_to]
Para %s
---
[dew_gift_amount]
Quantidade de Dew
---
[dew_gift_up_to]
Envie Dew inteiros, até %s Dew.
---
[dew_gift_too_much]
É mais do que seus %s Dew.
---
[dew_gift_worth]
Vale %s
---
[dew_gift_send]
Enviar %s Dew
---
[dew_gift_sending]
Enviando…
---
[dew_gift_waiting]
Aguardando a confirmação do nó. Seu presente é enviado só uma vez.
---
[dew_gift_sent]
%s Dew enviados para %s.
---
[dew_gift_funds]
Dew insuficiente para este presente.
---
[dew_gift_not_friend]
Você só pode presentear Dew a amigos.
---
[dew_gift_failed]
O presente não foi enviado. Tente novamente.
---
[dew_gift_final]
Um presente não pode ser desfeito.
---
[profile_dew_topup_hint_usd]
Envie pelo menos %s XMR (cerca de %s USD) para este endereço. Dew aparece após %d confirmações.
+42
View File
@@ -5272,6 +5272,48 @@ Lumi остаётся без сети, пока вы не примете её у
[dew_about_usd]
примерно %s USD
---
[dew_gift_title]
Подарить Dew
---
[dew_gift_to]
Для %s
---
[dew_gift_amount]
Количество Dew
---
[dew_gift_up_to]
Отправляйте целые Dew, до %s Dew.
---
[dew_gift_too_much]
Это больше, чем ваши %s Dew.
---
[dew_gift_worth]
Стоимость: %s
---
[dew_gift_send]
Отправить %s Dew
---
[dew_gift_sending]
Отправка…
---
[dew_gift_waiting]
Ждём подтверждения узла. Подарок отправляется только один раз.
---
[dew_gift_sent]
Отправлено %s Dew для %s.
---
[dew_gift_funds]
Недостаточно Dew для этого подарка.
---
[dew_gift_not_friend]
Дарить Dew можно только друзьям.
---
[dew_gift_failed]
Подарок не отправлен. Попробуйте ещё раз.
---
[dew_gift_final]
Подарок нельзя вернуть.
---
[profile_dew_topup_hint_usd]
Отправь не менее %s XMR (примерно %s USD) на этот адрес. Dew появится после %d подтверждений.
+42
View File
@@ -5278,6 +5278,48 @@ Dew不足,请先使用Monero充值。
[dew_about_usd]
约%s USD
---
[dew_gift_title]
赠送 Dew
---
[dew_gift_to]
给 %s
---
[dew_gift_amount]
Dew 数量
---
[dew_gift_up_to]
以整数 Dew 发送,最多 %s Dew。
---
[dew_gift_too_much]
这超过了你的 %s Dew。
---
[dew_gift_worth]
价值 %s
---
[dew_gift_send]
发送 %s Dew
---
[dew_gift_sending]
正在发送…
---
[dew_gift_waiting]
正在等待节点确认。礼物只会发送一次。
---
[dew_gift_sent]
已发送 %s Dew 给 %s。
---
[dew_gift_funds]
Dew 不足,无法送出这份礼物。
---
[dew_gift_not_friend]
只能向好友赠送 Dew。
---
[dew_gift_failed]
礼物未送出。请重试。
---
[dew_gift_final]
礼物送出后无法撤回。
---
[profile_dew_topup_hint_usd]
向此地址发送至少%s XMR(约%s USD)。经过%d次确认后,Dew将到账。
+11 -3
View File
@@ -118,6 +118,7 @@ PackageNow :: () -> s64 #foreign c "now_seconds";
#import, file "../breaks/app_breaks.zi";
#import, file "../screens/profile_screen.zi";
#import, file "../screens/profile_dew.zi";
#import, file "../screens/profile_dew_gift.zi";
#import, file "../screens/profile_social.zi";
#import, file "../screens/settings/settings_screen.zi";
#import, file "../screens/settings/settings_audio.zi";
@@ -1000,6 +1001,10 @@ draw_global_modal :: (app: *InnerBreeze) {
ProfileTopUpModalDraw(app)
return
}
if app.modal.type == cast(ModalType)ModalDewGift {
ProfileDewGiftModalDraw(app)
return
}
if app.modal.type == cast(ModalType)ModalTaiChiCourse ||
app.modal.type == cast(ModalType)ModalTaiChiCustomize {
tai_chi_modal_draw(app)
@@ -1162,7 +1167,8 @@ updateapp :: (app: *InnerBreeze) {
((app.launcher_open || (app.modal.active != 0 &&
(app.modal.type == cast(ModalType)ModalPracticeDownloads ||
app.modal.type == cast(ModalType)ModalStoragePlans ||
app.modal.type == cast(ModalType)ModalDewTopUp))) && IsKeyPressed(APP_KEY_ESCAPE))
app.modal.type == cast(ModalType)ModalDewTopUp ||
app.modal.type == cast(ModalType)ModalDewGift))) && IsKeyPressed(APP_KEY_ESCAPE))
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
if IsKeyPressed(KEY_BACKSPACE) && ((app.breathing.screen == ScreenStart && app.practice_tab != PRACTICE_TAB_PLAY) || app.breathing.screen == ScreenSession || app.breathing.screen == ScreenMeditation || app.breathing.screen == ScreenSunSalutation || app.breathing.screen == ScreenPatterns || app.breathing.screen == ScreenTaiChi) {
back_requested = true
@@ -1641,8 +1647,10 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
app_profile_record_habits(profile_habits_start)
profile_sync_start = app_profile_now()
if DewAvailable() {
DewTick(app.breathing.screen == ScreenProfile && app.profile_tab == PROFILE_TAB_OVERVIEW,
GetTime())
// The balance stays current on the Profile overview and while a gift is chosen.
dew_visible := (app.breathing.screen == ScreenProfile && app.profile_tab == PROFILE_TAB_OVERVIEW) ||
(app.modal.active != 0 && app.modal.type == cast(ModalType)ModalDewGift)
DewTick(dew_visible, GetTime())
if DewTakeSyncRequest() {
unused app_request_sync(app)
}
+1
View File
@@ -32,6 +32,7 @@ ModalType :: enum {
ModalPracticeDownloads
ModalStoragePlans
ModalDewTopUp
ModalDewGift
}
#program_export
+15 -1
View File
@@ -42,6 +42,7 @@
#import, file "../storage/dew.zi";
#import, file "../storage/practice_unlocks.zi";
#import, file "../screens/profile_dew.zi";
#import, file "../screens/profile_dew_gift.zi";
#import, file "../storage/account_types.zi";
#import, file "../storage/sync_result.zi";
#import, file "../screens/elist_types.zi";
@@ -927,7 +928,8 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
app.profile_tab = PROFILE_TAB_OVERVIEW
app.breathing.screen = ScreenProfile
} else if scene_text == "profile_dew" || scene_text == "storage_plans" ||
scene_text == "storage_plans_1gb" || scene_text == "dew_top_up" {
scene_text == "storage_plans_1gb" || scene_text == "dew_top_up" ||
scene_text == "dew_gift" {
// A fixture Dew account in the isolated data root; nothing is fetched.
account: AccountKeys = .{}
if sync_account_generate(*account) == 0 ||
@@ -967,6 +969,18 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
dew_confirmations = 10
ProfileTopUpOpen(app)
}
if scene_text == "dew_gift" {
// A fixture friend; nothing is sent.
friend := "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
unused storage_set_social_cache_json("friends.list",
"{\"friends\":[{\"user_id_hash\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"alias\":\"lotus\"}]}")
app.profile_friends_loaded = 0
app.profile_tab = PROFILE_TAB_FRIENDS
ProfileDewGiftOpen(app, friend, "@lotus")
unused AppCopyText("3", profile_gift_amount[:])
profile_gift_cursor = 1
profile_gift_anchor = 1
}
} else if scene_text == "practice_unlock_price" {
// Tai Chi as an account without it sees it, at a fixture offer and
// rate; nothing is fetched or charged.
+250
View File
@@ -0,0 +1,250 @@
// The Gift Dew window: sends whole Dew from this account to a friend, with
// what the amount is worth in Monero and US dollars at the node's rates.
#import "geometry"
#import "text_props"
#import "text_widget"
#import "text_field_widget"
#import "text_input_props"
#import "button_props"
#import "control_props"
#import "button_widget"
#import "modal_props"
#import "modal_frame_widget"
#import "scroll_props"
#import "scroll_widget"
#import "layout"
#import "tree"
#import "text_buffer"
#import, file "../storage/dew.zi";
#import, file "../platform/dew_payment.zi";
#import, file "../platform/raylib_text_input.zi";
#import, file "../app/app_types.zi";
#import, file "../app/draw.zi";
#import, file "../app/metrics.zi";
#import, file "../app/locale.zi";
#import, file "../app/text_buffers.zi";
#import, file "../app/modal_rules.zi";
#import, file "../app/app_modal_state.zi";
#import, file "profile_dew.zi";
#import, file "dew_worth.zi";
using ButtonTone;
using ButtonEmphasis;
using ModalType;
// MingCute's regular gift icon (Apache-2.0), copied from kryonlabs/mingcute's
// generated shapes.
DEW_GIFT_ICON :: "S2br:M5 12H19M5 12H19M5 12V18C5 19.1046 5.89543 20 7 20H17C18.1046 20 19 19.1046 19 18V12M5 12C4.44772 12 4 11.5523 4 11V8C4 7.44772 4.44772 7 5 7H19C19.5523 7 20 7.44772 20 8V11C20 11.5523 19.5523 12 19 12M12 20V7M12 7V6M12 7H11C9.34315 7 8 5.65685 8 4V3.5C8 3.22386 8.22386 3 8.5 3H9C10.6569 3 12 4.34315 12 6M12 7H13C14.6569 7 16 5.65685 16 4V3.5C16 3.22386 15.7761 3 15.5 3H15C13.3431 3 12 4.34315 12 6"
// Gifts are whole Dew; nine digits is far more than any balance.
DEW_GIFT_DIGITS :: 9
DEW_GIFT_FOCUS :: 815
profile_gift_recipient: [65]u8;
profile_gift_name: [96]u8;
profile_gift_amount: [16]u8;
profile_gift_cursor: s32;
profile_gift_anchor: s32;
profile_gift_scroll_x: s32;
profile_gift_focused: bool;
profile_gift_scroll: s32;
// Friends can be gifted Dew wherever Dew is sold, once this account is on
// the Waozi node.
ProfileDewGiftAvailable :: () -> bool {
return DewAvailable() && DewReady()
}
ProfileDewGiftOpen :: (app: *InnerBreeze, recipient: string, name: string) {
if !ProfileDewGiftAvailable() || recipient.count != 64 {
return
}
unused AppCopyText(recipient, profile_gift_recipient[:])
unused AppCopyText(name, profile_gift_name[:])
profile_gift_amount = .{}
profile_gift_cursor = 0
profile_gift_anchor = 0
profile_gift_scroll_x = 0
profile_gift_focused = true
profile_gift_scroll = 0
// A finished gift's outcome belongs to the window that sent it.
if dew_gift_attempt[0] == cast(u8)0 {
dew_gift_state = DewGiftNone
dew_gift_notice = ""
}
app_open_modal(app, cast(ModalType)ModalDewGift)
}
// The typed whole Dew in units, or 0 while nothing valid is typed.
ProfileDewGiftUnits :: () -> s64 {
amount := TextUntilNul(profile_gift_amount[:])
if amount.count == 0 || amount.count > DEW_GIFT_DIGITS {
return 0
}
whole: s64 = 0
for byte: amount {
if byte < cast(u8)48 || byte > cast(u8)57 {
return 0
}
whole = whole * 10 + cast(s64)(byte - cast(u8)48)
}
return whole * DewUnits
}
// The last gift's outcome, when it went to the friend this window is for.
ProfileDewGiftForThisFriend :: () -> bool {
return TextUntilNul(dew_gift_recipient[:]) == TextUntilNul(profile_gift_recipient[:])
}
ProfileDewGiftAmountField :: (app: *InnerBreeze, x: s32, y: s32, width: s32, waiting: bool) {
typed: [64]u8
field := TextField(app.ui.session, TextFieldProps.{
.key = KeyHash("profile/gift/amount"),
.bounds = Rectangle.{cast(float32)x, cast(float32)y,
cast(float32)width, cast(float32)AppScale(48)},
.value = FrameTextHold(*app.ui.frame_text, TextUntilNul(profile_gift_amount[:])),
.label = LocaleText("dew_gift_amount"),
.placeholder = LocaleText("dew_gift_amount"),
.cursor = profile_gift_cursor,
.anchor = profile_gift_anchor,
.scroll_x = profile_gift_scroll_x,
.focused = profile_gift_focused && !waiting,
.focus_id = DEW_GIFT_FOCUS,
.max_bytes = DEW_GIFT_DIGITS,
.max_codepoints = DEW_GIFT_DIGITS,
.numeric = true,
.disabled = waiting,
.input = SampleTextFieldInput(profile_gift_focused && !waiting, typed[:]),
.scale = MetricsScale()})
if field.edit.changed {
unused AppReplaceText(profile_gift_amount[:], field.edit.start,
field.edit.end, field.edit.replacement)
}
profile_gift_cursor = field.cursor
profile_gift_anchor = field.anchor
profile_gift_scroll_x = field.scroll_x
profile_gift_focused = field.focused
if field.clipboard_write {
unused TextInputWriteClipboard(field.clipboard_text)
}
}
// Measuring and drawing use the same wrapped lines and controls.
ProfileDewGiftContent :: (app: *InnerBreeze, x: s32, y: *s32, width: s32, draw: bool) {
line: [256]u8
name := TextUntilNul(profile_gift_name[:])
to_arguments: [1]FormatArg = .[FormatArg.{.text = name, .is_text = true}]
unused FormatTemplate(LocaleText("dew_gift_to"), to_arguments[:], line[:])
ProfileDewText(app, TextUntilNul(line[:]), x, y, width, AppFontSize(), draw)
if !dew_account.known {
ProfileDewText(app, LocaleText(ifx dew_notice.count > 0 then "profile_dew_error"
else "profile_dew_loading"), x, y, width, AppSmallFontSize(), draw)
return
}
line = .{}
ProfileDewFormatDew(dew_account.balance, LocaleText("profile_dew_balance_line"), line[:])
DewAppendWorth(dew_account.balance, line[:])
ProfileDewText(app, TextUntilNul(line[:]), x, y, width, AppSmallFontSize(), draw)
line = .{}
if ProfileDewExchangeText(line[:]) {
ProfileDewText(app, TextUntilNul(line[:]), x, y, width, AppSmallFontSize(), draw)
}
y.* += AppScale(4)
waiting := dew_gift_attempt[0] != cast(u8)0
if draw {
ProfileDewGiftAmountField(app, x, y.*, width, waiting)
}
y.* += AppScale(48) + AppScale(8)
units := ProfileDewGiftUnits()
largest := dew_account.balance / DewUnits * DewUnits
// The line under the amount: what it is worth, or why it cannot be sent.
line = .{}
if units > dew_account.balance {
ProfileDewFormatDew(dew_account.balance, LocaleText("dew_gift_too_much"), line[:])
} else if units > 0 {
worth: [128]u8
if DewWorthText(units, worth[:]) {
worth_arguments: [1]FormatArg = .[FormatArg.{.text = TextUntilNul(worth[:]), .is_text = true}]
unused FormatTemplate(LocaleText("dew_gift_worth"), worth_arguments[:], line[:])
}
} else if largest > 0 {
ProfileDewFormatDew(largest, LocaleText("dew_gift_up_to"), line[:])
} else {
unused AppCopyText(LocaleText("profile_dew_funds"), line[:])
}
ProfileDewText(app, TextUntilNul(line[:]), x, y, width, AppSmallFontSize(), draw)
// What happened to the last gift to this friend.
line = .{}
if waiting {
unused AppCopyText(LocaleText(ifx dew_gift_notice.count > 0 then dew_gift_notice
else "dew_gift_sending"), line[:])
} else if dew_gift_state == DewGiftSent && ProfileDewGiftForThisFriend() {
amount: [48]u8
unused DewFormat(dew_gift_units, DewUnits, amount[:])
sent_arguments: [2]FormatArg = .[
FormatArg.{.text = TextUntilNul(amount[:]), .is_text = true},
FormatArg.{.text = name, .is_text = true}]
unused FormatTemplate(LocaleText("dew_gift_sent"), sent_arguments[:], line[:])
} else if dew_gift_state == DewGiftRefused && ProfileDewGiftForThisFriend() &&
dew_gift_notice.count > 0 {
unused AppCopyText(LocaleText(dew_gift_notice), line[:])
}
if line[0] != cast(u8)0 {
ProfileDewText(app, TextUntilNul(line[:]), x, y, width, AppFontSize(), draw)
}
line = .{}
if units > 0 {
ProfileDewFormatDew(units, LocaleText("dew_gift_send"), line[:])
} else {
unused AppCopyText(LocaleText("dew_gift_title"), line[:])
}
disabled := waiting || units <= 0 || units > dew_account.balance
if ProfileDewButton(app, TextUntilNul(line[:]), x, y, width, disabled, draw) {
if DewSendGift(TextUntilNul(profile_gift_recipient[:]), units) {
profile_gift_amount = .{}
profile_gift_cursor = 0
profile_gift_anchor = 0
profile_gift_scroll_x = 0
}
}
ProfileDewText(app, LocaleText("dew_gift_final"), x, y, width, AppSmallFontSize(), draw)
}
ProfileDewGiftModalDraw :: (app: *InnerBreeze) {
DewRatesRefresh()
width := app.ui.view_width - AppScale(32)
if width > AppScale(480) {
width = AppScale(480)
}
measured: s32 = 0
ProfileDewGiftContent(app, 0, *measured, width - AppScale(46), false)
height := measured + AppScale(96)
if height > app.ui.view_height - AppScale(48) {
height = app.ui.view_height - AppScale(48)
}
frame := ModalFrame(app.ui.session, ModalFrameProps.{
.key = KeyHash("profile/gift/modal"), .title = LocaleText("dew_gift_title"),
.width = width, .height = height, .scale = MetricsScale(),
.title_at_start = true, .strong_title = true,
.has_right_action = true, .right_label = LocaleText("close_button")})
// Signing out or switching accounts closes the window.
if frame.dismissed || frame.right_clicked || !ProfileDewGiftAvailable() {
app_close_modal(app)
return
}
if !frame.opened {
return
}
content_w := cast(s32)frame.layout.content.width - AppScale(10)
content_h: s32 = 0
ProfileDewGiftContent(app, 0, *content_h, content_w, false)
scroll := Scroll(app.ui.session, ScrollProps.{
.key = KeyHash("profile/gift/scroll"), .bounds = frame.layout.content,
.content_height = content_h, .scroll_offset = profile_gift_scroll})
profile_gift_scroll = scroll.scroll_offset
if scroll.opened {
y := cast(s32)scroll.content.y
ProfileDewGiftContent(app, cast(s32)scroll.content.x, *y, content_w, true)
End(app.ui.session)
}
End(app.ui.session)
}
+16
View File
@@ -36,6 +36,7 @@ using TextWrap;
#import "byte_text_linux"
#import "date_time"
#import, file "../app/app_nav_state.zi";
#import, file "profile_dew_gift.zi";
c2 :: #system_library "c";
app_request_friend_decline :: (app: *InnerBreeze, friend_id: string) #foreign c2;
app_request_friend_accept :: (app: *InnerBreeze, friend_id: string) #foreign c2;
@@ -286,6 +287,21 @@ draw_json_people :: (json: string, array_key: string,
icon_padding := AppScale(6)
button_w := icon_size + icon_padding * 2
// Where Dew is sold, a friend can be sent some.
if ProfileDewGiftAvailable() {
if Button(CurrentApp().ui.session, ButtonProps.{
.id = 0,
.bounds = Rectangle.{cast(float32)(x + w - button_w * 2 - AppScale(6)),
cast(float32)(y.* - AppScale(6)),
cast(float32)button_w, cast(float32)button_w},
.label = LocaleText("dew_gift_title"),
.icon_shape = DEW_GIFT_ICON, .icon_only = true,
.tone = cast(ButtonTone)ButtonToneAccent, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft
}) != 0 {
ProfileDewGiftOpen(app, AppTextFromCString(*display_id[0], 80),
AppTextFromCString(*title[0], 96))
}
}
if Button(CurrentApp().ui.session, ButtonProps.{
.id = 0,
.bounds = Rectangle.{cast(float32)(x + w - button_w), cast(float32)(y.* - AppScale(6)),
+146 -2
View File
@@ -23,6 +23,13 @@ DewUnits :: 1000000
DewRead :: 1
DewUpgrade :: 2
DewAddress :: 3
DewGift :: 4
// Where a gift to a friend stands, for the window that sends it.
DewGiftNone :: 0
DewGiftSending :: 1
DewGiftSent :: 2
DewGiftRefused :: 3
// The node's paid storage sizes, in the order the app offers them.
DewPlanCount :: 2
@@ -76,6 +83,14 @@ dew_action: s32;
dew_next_refresh: float64;
dew_notice: string;
dew_sync_requested: bool;
// A gift waiting for the node's answer, as the request it sends, kept until
// the node confirms or refuses it so an uncertain send repeats the same ID.
dew_gift_attempt: [192]u8;
dew_gift_retry_at: float64;
dew_gift_state: s32;
dew_gift_notice: string;
dew_gift_recipient: [65]u8;
dew_gift_units: s64;
DewReady :: () -> bool {
return StoredAccountMode() == AccountModeOwner && storage_sync_enabled() != 0 &&
@@ -96,6 +111,12 @@ DewCancel :: () {
dew_next_refresh = 0.0
dew_notice = ""
dew_sync_requested = false
dew_gift_attempt = .{}
dew_gift_retry_at = 0.0
dew_gift_state = DewGiftNone
dew_gift_notice = ""
dew_gift_recipient = .{}
dew_gift_units = 0
}
DewTakeSyncRequest :: () -> bool {
@@ -120,6 +141,13 @@ DewContext :: () {
if FieldAt(TextUntilNul(dew_attempt[:]), 0, "request_id") < 0 {
dew_attempt[0] = cast(u8)0
}
// A gift still unconfirmed when the app closed is sent again as it was.
unused storage_get_social_cache_json("dew.gift", *dew_gift_attempt[0], 192)
if DewGiftAttemptLoad() {
dew_gift_state = DewGiftSending
} else {
dew_gift_attempt[0] = cast(u8)0
}
}
// Read integer units without converting credit through floating point.
@@ -245,8 +273,12 @@ DewBegin :: (action: s32, path: string, body: string) -> bool {
}
dew_response = .{}
dew_action = action
method := "GET"
if action == DewUpgrade || action == DewGift {
method = "POST"
}
if !BeginStoredRequest(*dew_operation, DewNode, NetworkTransport(*dew_transfer),
ifx action == DewUpgrade then "POST" else "GET", path, body, dew_response[:], true) {
method, path, body, dew_response[:], true) {
dew_notice = "profile_dew_error"
return false
}
@@ -294,6 +326,81 @@ DewAttemptSize :: () -> s32 {
return DewPlanSlot(TextUntilNul(size[:])) + 1
}
// Reads the waiting gift's friend and amount; false without a whole request.
DewGiftAttemptLoad :: () -> bool {
attempt := TextUntilNul(dew_gift_attempt[:])
recipient: [65]u8
request_id: [65]u8
units: s64
if attempt.count == 0 ||
ReadStringText(attempt, FieldAt(attempt, 0, "recipient"), recipient[:]) != 64 ||
ReadStringText(attempt, FieldAt(attempt, 0, "request_id"), request_id[:]) < 8 ||
!DewInteger(attempt, FieldAt(attempt, 0, "units"), *units) || units <= 0 {
return false
}
dew_gift_recipient = recipient
dew_gift_units = units
return true
}
// Sends `units` to the friend whose account ID is `recipient`. The request is
// saved first, so it is repeated with the same ID until the node answers.
DewSendGift :: (recipient: string, units: s64) -> bool {
DewContext()
if !DewReady() || dew_gift_attempt[0] != cast(u8)0 || recipient.count != 64 || units <= 0 ||
TextUntilNul(dew_identity[:]) == recipient {
return false
}
request_id: [37]u8
storage_make_uuid(*request_id[0])
amount: [24]u8
unused AppFormatS64(units, amount[:])
attempt: [192]u8
unused AppCopyText("{\"recipient\":\"", attempt[:])
unused AppAppendText(recipient, attempt[:])
unused AppAppendText("\",\"units\":", attempt[:])
unused AppAppendText(TextUntilNul(amount[:]), attempt[:])
unused AppAppendText(",\"request_id\":\"", attempt[:])
unused AppAppendText(TextUntilNul(request_id[:]), attempt[:])
unused AppAppendText("\"}", attempt[:])
if storage_set_social_cache_json("dew.gift", TextUntilNul(attempt[:])) == 0 {
dew_gift_state = DewGiftRefused
dew_gift_notice = "dew_gift_failed"
return false
}
dew_gift_attempt = attempt
unused DewGiftAttemptLoad()
dew_gift_state = DewGiftSending
dew_gift_notice = ""
dew_gift_retry_at = 0.0
return true
}
// Forgets the waiting gift once the node has answered it for certain.
DewGiftSettle :: (state: s32, notice: string) {
unused storage_set_social_cache_json("dew.gift", "{}")
dew_gift_attempt[0] = cast(u8)0
dew_gift_state = state
dew_gift_notice = notice
}
// The node's answer must name the request it was sent, with the sender's new balance.
DewParseGift :: (json: string, balance: *s64) -> bool {
attempt := TextUntilNul(dew_gift_attempt[:])
sent_id: [65]u8
answer_id: [65]u8
recipient: [65]u8
units: s64
unused ReadStringText(attempt, FieldAt(attempt, 0, "request_id"), sent_id[:])
return Space(json, ValueEnd(json, 0, 0)) == cast(s32)json.count &&
ReadStringText(json, FieldAt(json, 0, "request_id"), answer_id[:]) >= 8 &&
TextUntilNul(answer_id[:]) == TextUntilNul(sent_id[:]) &&
ReadStringText(json, FieldAt(json, 0, "recipient"), recipient[:]) == 64 &&
TextUntilNul(recipient[:]) == TextUntilNul(dew_gift_recipient[:]) &&
DewInteger(json, FieldAt(json, 0, "units"), *units) && units == dew_gift_units &&
DewInteger(json, FieldAt(json, 0, "balance"), balance)
}
DewTopUp :: () {
DewContext()
if DewBegin(DewAddress, "/api/v1/tokens/purchases/monero/address", "") {
@@ -354,13 +461,26 @@ DewParseAddress :: (json: string) -> bool {
DewTick :: (visible: bool, now: float64) {
DewContext()
refresh_soon := false
if dew_operation.active {
if !PollStoredOperation(*dew_operation) {
return
}
if dew_operation.result == cast(s32)AuthResult.AUTH_OK {
json := TextUntilNul(dew_response[:])
if dew_action == DewAddress {
if dew_action == DewGift {
balance: s64
if DewParseGift(json, *balance) {
if dew_account.known {
dew_account.balance = balance
}
DewGiftSettle(DewGiftSent, "")
refresh_soon = true
} else {
dew_gift_notice = "dew_gift_waiting"
dew_gift_retry_at = now + 15.0
}
} else if dew_action == DewAddress {
if !DewParseAddress(json) {
dew_notice = "profile_dew_error"
}
@@ -389,6 +509,19 @@ DewTick :: (visible: bool, now: float64) {
dew_notice = "profile_dew_error"
}
}
} else if dew_action == DewGift {
status := dew_operation.request.status
if status == 402 {
DewGiftSettle(DewGiftRefused, "dew_gift_funds")
} else if status == 403 {
DewGiftSettle(DewGiftRefused, "dew_gift_not_friend")
} else if status == 400 || status == 409 {
DewGiftSettle(DewGiftRefused, "dew_gift_failed")
} else {
// Without a certain answer the same request goes again shortly.
dew_gift_notice = "dew_gift_waiting"
dew_gift_retry_at = now + 15.0
}
} else {
dew_notice = "profile_dew_error"
status := dew_operation.request.status
@@ -401,6 +534,17 @@ DewTick :: (visible: bool, now: float64) {
}
}
dew_next_refresh = now + 15.0
if refresh_soon {
dew_next_refresh = now
}
}
// A waiting gift goes before anything else the node is asked.
if dew_gift_attempt[0] != cast(u8)0 && DewReady() && !dew_operation.active &&
now >= dew_gift_retry_at {
attempt := dew_gift_attempt
unused DewBegin(DewGift, "/api/v1/tokens/gifts", TextUntilNul(attempt[:]))
dew_gift_retry_at = now + 15.0
return
}
if visible && DewReady() && !dew_operation.active && now >= dew_next_refresh {
unused DewBegin(DewRead, "/api/v1/storage/plan", "")
+107
View File
@@ -33,6 +33,12 @@ address_network: string = "mainnet";
address_asset: string = "waozi:token";
address_confirmations: s64 = 10;
address_atomic: s64 = 1000000000000LL;
gift_requests: s32;
gift_balance: s64;
// Answers a gift as if for another request, which settles nothing.
gift_reply_foreign: bool;
last_gift_body: [256]u8;
TestFriend :: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
TestAddress :: "8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Reply :: (output: []u8) -> bool {
@@ -72,6 +78,27 @@ AddressReply :: (output: []u8) -> bool {
return writer.valid
}
// The node echoes the gift it was sent, with the sender's new balance.
GiftReply :: (body: string, output: []u8) -> bool {
request_id: [65]u8
recipient: [65]u8
units: s64
unused ReadStringText(body, FieldAt(body, 0, "request_id"), request_id[:])
unused ReadStringText(body, FieldAt(body, 0, "recipient"), recipient[:])
unused DewInteger(body, FieldAt(body, 0, "units"), *units)
writer := Writer.{output, 0, true}
writer = WriteText(writer, "{\"request_id\":\"")
writer = WriteText(writer, ifx gift_reply_foreign then "another-request-id" else TextUntilNul(request_id[:]))
writer = WriteText(writer, "\",\"recipient\":\"")
writer = WriteText(writer, TextUntilNul(recipient[:]))
writer = WriteText(writer, "\",\"units\":")
writer = WriteDecimal(writer, units)
writer = WriteText(writer, ",\"balance\":")
writer = WriteDecimal(writer, gift_balance)
writer = WriteText(writer, ",\"receipt_id\":\"gift-receipt\"}\n")
return writer.valid
}
FakeStart :: (context: *void, request: HttpRequest, output: []u8) -> bool {
unused context
challenge := "https://api.waozi.xyz/api/v1/sync/challenge?user_id="
@@ -96,6 +123,12 @@ FakeStart :: (context: *void, request: HttpRequest, output: []u8) -> bool {
check_true("unlocks are read with an authenticated GET", request.method == "GET" && request.body.count == 0)
return AppCopyText("{\"unlocks\":[{\"product\":\"inbe.practice.taichi\",\"receipt_id\":\"r1\",\"created_at\":1}],\"products\":[{\"product\":\"inbe.practice.taichi\",\"price_units\":1000000,\"regular_price_units\":10000000,\"trial_until\":1807801200}]}", output)
}
if request.url == "https://api.waozi.xyz/api/v1/tokens/gifts" {
gift_requests += 1
check_true("gifts are sent with an authenticated POST", request.method == "POST")
unused AppCopyText(request.body, last_gift_body[:])
return GiftReply(request.body, output)
}
check_true("only the storage endpoint is requested", request.url == "https://api.waozi.xyz/api/v1/storage/plan")
requests += 1
unused AppCopyText(request.body, last_body[:])
@@ -290,6 +323,80 @@ Check :: () -> s32 {
"{\"xmr_usd_cents\":1.5,\"updated_at\":0,\"sources\":[],\"xmr_atomic_units\":1,\"token_units\":1}", *broken))
dew_rates = DewRates.{}
check_true("without rates nothing converts", DewXmrAtomic(10 * DewUnits) == 0)
// A gift to a friend moves whole requests: one at a time, never to
// oneself, and an uncertain one is sent again as it was.
response_status = 200
check_true("no gift to oneself", !DewSendGift(TextUntilNul(owner.public_id[:]), DewUnits))
check_true("no empty gift", !DewSendGift(TestFriend, 0))
check_true("no gift to a malformed account", !DewSendGift("bbbb", DewUnits))
check_int("refused gifts send nothing", gift_requests, 0)
response_balance = 11000000
DewTick(true, 200.0)
Finish()
check_true("balance known before gifting", dew_account.known && dew_account.balance == 11000000)
gift_balance = 9000000
check_true("gift accepted", DewSendGift(TestFriend, 2 * DewUnits))
check_true("one gift at a time", !DewSendGift(TestFriend, DewUnits))
check_true("a new gift is sending", dew_gift_state == DewGiftSending && dew_gift_units == 2 * DewUnits)
Finish()
check_int("one gift request", gift_requests, 1)
gift := TextUntilNul(last_gift_body[:])
gift_recipient: [65]u8
gift_request: [65]u8
gift_units: s64
check_true("gift names the friend", ReadStringText(gift, FieldAt(gift, 0, "recipient"), gift_recipient[:]) == 64 &&
TextUntilNul(gift_recipient[:]) == TestFriend)
check_true("gift sends integer units", DewInteger(gift, FieldAt(gift, 0, "units"), *gift_units) && gift_units == 2000000)
check_true("gift carries a request ID", ReadStringText(gift, FieldAt(gift, 0, "request_id"), gift_request[:]) >= 8)
check_true("confirmed gift shows the sender's new balance", dew_gift_state == DewGiftSent &&
dew_account.balance == 9000000 && dew_gift_attempt[0] == cast(u8)0)
saved_gift: [192]u8
unused storage_get_social_cache_json("dew.gift", *saved_gift[0], 192)
check_true("a confirmed gift is forgotten", TextUntilNul(saved_gift[:]) == "{}")
response_status = 503
check_true("second gift accepted", DewSendGift(TestFriend, DewUnits))
Finish()
check_true("uncertain gift is kept to send again", dew_gift_attempt[0] != cast(u8)0 &&
dew_gift_state == DewGiftSending && dew_gift_notice == "dew_gift_waiting")
uncertain: [192]u8 = dew_gift_attempt
DewTick(false, 2.0)
check_true("an uncertain gift waits before repeating", !dew_operation.active)
DewCancel()
DewContext()
check_true("uncertain gift survives restart", TextUntilNul(dew_gift_attempt[:]) == TextUntilNul(uncertain[:]) &&
dew_gift_state == DewGiftSending && dew_gift_units == DewUnits &&
TextUntilNul(dew_gift_recipient[:]) == TestFriend)
response_status = 200
gift_balance = 8000000
Finish()
check_true("the retry repeats the same request", TextUntilNul(last_gift_body[:]) == TextUntilNul(uncertain[:]))
check_true("retried gift confirmed once", dew_gift_state == DewGiftSent && dew_gift_attempt[0] == cast(u8)0)
gift_reply_foreign = true
check_true("third gift accepted", DewSendGift(TestFriend, DewUnits))
Finish()
check_true("an answer for another request settles nothing", dew_gift_attempt[0] != cast(u8)0 &&
dew_gift_notice == "dew_gift_waiting")
gift_reply_foreign = false
DewTick(false, 30.0)
Finish()
check_true("the gift settles when the node answers it", dew_gift_state == DewGiftSent && dew_gift_attempt[0] == cast(u8)0)
response_status = 402
check_true("unaffordable gift accepted for the node to judge", DewSendGift(TestFriend, 50 * DewUnits))
Finish()
check_true("missing Dew is explained", dew_gift_state == DewGiftRefused &&
dew_gift_notice == "dew_gift_funds" && dew_gift_attempt[0] == cast(u8)0)
response_status = 403
unused DewSendGift(TestFriend, DewUnits)
Finish()
check_true("gifts only reach friends", dew_gift_notice == "dew_gift_not_friend" && dew_gift_attempt[0] == cast(u8)0)
response_status = 409
unused DewSendGift(TestFriend, DewUnits)
Finish()
check_true("a refused request is not repeated", dew_gift_notice == "dew_gift_failed" && dew_gift_attempt[0] == cast(u8)0)
response_status = 200
storage_set_setting_text("sync_public_id", "another-account")
DewContext()
check_true("account change clears the old balance", !dew_account.known && dew_address[0] == cast(u8)0)