Make Dew status and payment quotes reliable
This commit is contained in:
1 parent
829771c6d1
commit
9ea32baf78
17 files changed
+122
-29
No files matched your search
@@ -5,6 +5,8 @@
|
||||
- Profile shows Dew credit, with Monero top-ups and prepaid 1 GB storage on the Waozi node: fixed monthly or yearly XMR prices, outside Google Play.
|
||||
- Share a list with a friend after they accept an invitation inside Lists.
|
||||
### Changed
|
||||
|
||||
- Dew balances and upgrades load reliably, and top-ups show the minimum payment and required confirmations.
|
||||
- Lists uses compact, scrollable tabs and larger task controls.
|
||||
|
||||
## [2.1.33] - 2026-10-13
|
||||
|
||||
@@ -4,4 +4,5 @@ Added
|
||||
- Share a list with a friend after they accept an invitation inside Lists.
|
||||
Changed
|
||||
---
|
||||
- Dew balances and upgrades load reliably, and top-ups show the minimum payment and required confirmations.
|
||||
- Lists uses compact, scrollable tabs and larger task controls.
|
||||
+1
-1
@@ -3625,7 +3625,7 @@ Tento uzel nenabízí rozšíření úložiště.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Pošli XMR na tuto adresu. Dew se připíše po %d potvrzeních.
|
||||
Na tuto adresu pošli alespoň %s XMR. Dew se připíše po %d potvrzeních.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3619,7 +3619,7 @@ Dieser Knoten bietet keine Speichererweiterungen an.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Sende XMR an diese Adresse. Dew erscheint nach %d Bestätigungen.
|
||||
Sende mindestens %s XMR an diese Adresse. Dew wird nach %d Bestätigungen gutgeschrieben.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3643,7 +3643,7 @@ Storage upgrades are not available on this node.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Send XMR to this address. Dew appears after %d confirmations.
|
||||
Send at least %s XMR to this address. Dew appears after %d confirmations.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3619,7 +3619,7 @@ Este nodo no ofrece ampliaciones de almacenamiento.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Envía XMR a esta dirección. Dew aparecerá tras %d confirmaciones.
|
||||
Envía al menos %s XMR a esta dirección. Dew aparece tras %d confirmaciones.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3607,7 +3607,7 @@ Ce nœud ne propose pas d’extension de stockage.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Envoyez des XMR à cette adresse. Dew apparaît après %d confirmations.
|
||||
Envoyez au moins %s XMR à cette adresse. Les Dew apparaissent après %d confirmations.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3608,7 +3608,7 @@ Node ini tidak menyediakan peningkatan penyimpanan.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Kirim XMR ke alamat ini. Dew masuk setelah %d konfirmasi.
|
||||
Kirim setidaknya %s XMR ke alamat ini. Dew masuk setelah %d konfirmasi.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3608,7 +3608,7 @@ Questo nodo non offre ampliamenti dello spazio.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Invia XMR a questo indirizzo. Dew appare dopo %d conferme.
|
||||
Invia almeno %s XMR a questo indirizzo. Dew compare dopo %d conferme.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3604,7 +3604,7 @@ Dewが不足しています。先にMoneroでチャージしてください。
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
このアドレスにXMRを送信してください。%d回の承認後にDewが反映されます。
|
||||
このアドレスに%s XMR以上を送ってください。%d回の承認後にDewが反映されます。
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3614,7 +3614,7 @@ Dew가 부족해요. 먼저 Monero로 충전하세요.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
이 주소로 XMR을 보내세요. %d회 확인 후 Dew가 반영돼요.
|
||||
이 주소로 최소 %s XMR를 보내세요. %d회 확인 후 Dew가 반영돼요.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3617,7 +3617,7 @@ Este nó não oferece ampliações de armazenamento.
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Envie XMR para este endereço. Dew aparece após %d confirmações.
|
||||
Envie pelo menos %s XMR para este endereço. Dew aparece após %d confirmações.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3613,7 +3613,7 @@ Lumi остаётся без сети, пока вы не примете её у
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
Отправь XMR на этот адрес. Dew появится после %d подтверждений.
|
||||
Отправь не менее %s XMR на этот адрес. Dew появится после %d подтверждений.
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
+1
-1
@@ -3619,7 +3619,7 @@ Dew不足,请先使用Monero充值。
|
||||
---
|
||||
|
||||
[profile_dew_topup_hint]
|
||||
请向此地址发送XMR。经过%d次确认后,Dew将到账。
|
||||
向此地址发送至少%s XMR。经过%d次确认后,Dew将到账。
|
||||
---
|
||||
|
||||
[profile_dew_rate]
|
||||
|
||||
@@ -131,7 +131,12 @@ ProfileDewContent :: (app: *InnerBreeze, x: s32, y: *s32, width: s32,
|
||||
return
|
||||
}
|
||||
hint: [384]u8
|
||||
unused FormatNumberTemplate(LocaleText("profile_dew_topup_hint"), cast(s32)dew_confirmations, hint[:])
|
||||
minimum: [48]u8
|
||||
unused DewFormat(dew_minimum_atomic, 1000000000000LL, minimum[:])
|
||||
hint_arguments: [2]FormatArg = .[
|
||||
FormatArg.{.text = TextUntilNul(minimum[:]), .is_text = true},
|
||||
FormatArg.{.number = cast(s32)dew_confirmations}]
|
||||
unused FormatTemplate(LocaleText("profile_dew_topup_hint"), hint_arguments[:], hint[:])
|
||||
ProfileDewText(app, TextUntilNul(hint[:]), x, y, width, AppSmallFontSize(), draw)
|
||||
xmr: [48]u8
|
||||
dew: [48]u8
|
||||
|
||||
+40
-7
@@ -44,6 +44,7 @@ dew_address: [128]u8;
|
||||
dew_rate_atomic: s64;
|
||||
dew_rate_units: s64;
|
||||
dew_confirmations: s64;
|
||||
dew_minimum_atomic: s64;
|
||||
dew_action: s32;
|
||||
dew_next_refresh: float64;
|
||||
dew_notice: string;
|
||||
@@ -60,6 +61,10 @@ DewCancel :: () {
|
||||
dew_identity = .{}
|
||||
dew_attempt = .{}
|
||||
dew_address = .{}
|
||||
dew_rate_atomic = 0
|
||||
dew_rate_units = 0
|
||||
dew_confirmations = 0
|
||||
dew_minimum_atomic = 0
|
||||
dew_action = 0
|
||||
dew_next_refresh = 0.0
|
||||
dew_notice = ""
|
||||
@@ -117,7 +122,7 @@ DewParseAccount :: (json: string, identity: string, account: *DewAccount) -> boo
|
||||
asset: [32]u8
|
||||
plan := FieldAt(json, 0, "plan")
|
||||
units: s64
|
||||
if ValueEnd(json, 0, 0) != cast(s32)json.count || plan < 0 ||
|
||||
if Space(json, ValueEnd(json, 0, 0)) != cast(s32)json.count || plan < 0 ||
|
||||
ReadStringText(json, FieldAt(json, 0, "account_id"), owner[:]) != 64 ||
|
||||
TextUntilNul(owner[:]) != identity ||
|
||||
ReadStringText(json, FieldAt(json, 0, "asset_id"), asset[:]) != 11 ||
|
||||
@@ -218,15 +223,33 @@ DewBuyStorage :: (period: string) {
|
||||
|
||||
DewTopUp :: () {
|
||||
DewContext()
|
||||
unused DewBegin(DewAddress, "/api/v1/tokens/purchases/monero/address", "")
|
||||
if DewBegin(DewAddress, "/api/v1/tokens/purchases/monero/address", "") {
|
||||
dew_address = .{}
|
||||
dew_rate_atomic = 0
|
||||
dew_rate_units = 0
|
||||
dew_confirmations = 0
|
||||
dew_minimum_atomic = 0
|
||||
}
|
||||
}
|
||||
|
||||
DewParseAddress :: (json: string) -> bool {
|
||||
owner: [65]u8
|
||||
address: [128]u8
|
||||
if ReadStringText(json, FieldAt(json, 0, "account_id"), owner[:]) != 64 ||
|
||||
asset: [32]u8
|
||||
network: [16]u8
|
||||
atomic: s64
|
||||
units: s64
|
||||
confirmations: s64
|
||||
minimum: s64
|
||||
if Space(json, ValueEnd(json, 0, 0)) != cast(s32)json.count ||
|
||||
ReadStringText(json, FieldAt(json, 0, "account_id"), owner[:]) != 64 ||
|
||||
TextUntilNul(owner[:]) != TextUntilNul(dew_identity[:]) ||
|
||||
ReadStringText(json, FieldAt(json, 0, "address"), address[:]) != 95 {
|
||||
ReadStringText(json, FieldAt(json, 0, "asset_id"), asset[:]) != 11 ||
|
||||
TextUntilNul(asset[:]) != "waozi:token" ||
|
||||
ReadStringText(json, FieldAt(json, 0, "network"), network[:]) != 7 ||
|
||||
TextUntilNul(network[:]) != "mainnet" ||
|
||||
ReadStringText(json, FieldAt(json, 0, "address"), address[:]) != 95 ||
|
||||
(address[0] != cast(u8)52 && address[0] != cast(u8)56) {
|
||||
return false
|
||||
}
|
||||
alphabet := "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||
@@ -241,12 +264,18 @@ DewParseAddress :: (json: string) -> bool {
|
||||
}
|
||||
rate := FieldAt(json, 0, "rate")
|
||||
if rate < 0 ||
|
||||
!DewInteger(json, FieldAt(json, rate, "xmr_atomic_units"), *dew_rate_atomic) || dew_rate_atomic <= 0 ||
|
||||
!DewInteger(json, FieldAt(json, rate, "token_units"), *dew_rate_units) || dew_rate_units <= 0 ||
|
||||
!DewInteger(json, FieldAt(json, 0, "confirmations_required"), *dew_confirmations) || dew_confirmations <= 0 {
|
||||
!DewInteger(json, FieldAt(json, rate, "xmr_atomic_units"), *atomic) || atomic <= 0 ||
|
||||
!DewInteger(json, FieldAt(json, rate, "token_units"), *units) || units <= 0 ||
|
||||
!DewInteger(json, FieldAt(json, 0, "confirmations_required"), *confirmations) ||
|
||||
confirmations <= 0 || confirmations > 2147483647 ||
|
||||
!DewInteger(json, FieldAt(json, 0, "minimum_atomic_amount"), *minimum) || minimum <= 0 {
|
||||
return false
|
||||
}
|
||||
dew_address = address
|
||||
dew_rate_atomic = atomic
|
||||
dew_rate_units = units
|
||||
dew_confirmations = confirmations
|
||||
dew_minimum_atomic = minimum
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -265,6 +294,7 @@ DewTick :: (visible: bool, now: float64) {
|
||||
} else {
|
||||
received: DewAccount
|
||||
if DewParseAccount(json, TextUntilNul(dew_identity[:]), *received) {
|
||||
previous := SyncNodeStorageRead(DewNode)
|
||||
dew_account = received
|
||||
storage := SyncNodeStorage.{
|
||||
.known = true,
|
||||
@@ -273,6 +303,9 @@ DewTick :: (visible: bool, now: float64) {
|
||||
.checked_at = DewNow(),
|
||||
.full = received.limit_bytes > 0 && received.used_bytes >= received.limit_bytes}
|
||||
SyncNodeStorageWrite(DewNode, storage)
|
||||
if previous.known && previous.full && !storage.full {
|
||||
dew_sync_requested = true
|
||||
}
|
||||
if dew_action == DewUpgrade {
|
||||
unused storage_set_social_cache_json("dew.upgrade", "{}")
|
||||
dew_attempt[0] = cast(u8)0
|
||||
|
||||
+61
-9
@@ -15,6 +15,7 @@
|
||||
#import "byte_text_linux"
|
||||
#import "json_scan"
|
||||
#import, file "../src/storage/sync_async.zi";
|
||||
#import, file "../src/storage/sync_node_storage.zi";
|
||||
#import, file "../src/storage/storage_core.zi";
|
||||
#import, file "../src/app/text_buffers.zi";
|
||||
|
||||
@@ -24,7 +25,11 @@ response_balance: s64 = 1234567;
|
||||
requests: s32;
|
||||
last_body: [256]u8;
|
||||
address_requests: s32;
|
||||
TestAddress :: "4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
address_network: string = "mainnet";
|
||||
address_asset: string = "waozi:token";
|
||||
address_confirmations: s64 = 10;
|
||||
address_atomic: s64 = 1000000000000LL;
|
||||
TestAddress :: "8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
|
||||
Reply :: (output: []u8) -> bool {
|
||||
writer := Writer.{output, 0, true}
|
||||
@@ -32,7 +37,25 @@ Reply :: (output: []u8) -> bool {
|
||||
writer = WriteText(writer, TextUntilNul(owner.public_id[:]))
|
||||
writer = WriteText(writer, "\",\"asset_id\":\"waozi:token\",\"units_per_dew\":1000000,\"enabled\":true,\"monthly_xmr_atomic_units\":1000000000,\"yearly_xmr_atomic_units\":10000000000,\"used_bytes\":1024,\"plan\":{\"balance\":")
|
||||
writer = WriteDecimal(writer, response_balance)
|
||||
writer = WriteText(writer, ",\"limit_bytes\":10485760,\"expires_at\":0}}")
|
||||
writer = WriteText(writer, ",\"limit_bytes\":10485760,\"expires_at\":0}}\n")
|
||||
return writer.valid
|
||||
}
|
||||
|
||||
AddressReply :: (output: []u8) -> bool {
|
||||
writer := Writer.{output, 0, true}
|
||||
writer = WriteText(writer, "{\"account_id\":\"")
|
||||
writer = WriteText(writer, TextUntilNul(owner.public_id[:]))
|
||||
writer = WriteText(writer, "\",\"asset_id\":\"")
|
||||
writer = WriteText(writer, address_asset)
|
||||
writer = WriteText(writer, "\",\"network\":\"")
|
||||
writer = WriteText(writer, address_network)
|
||||
writer = WriteText(writer, "\",\"address\":\"")
|
||||
writer = WriteText(writer, TestAddress)
|
||||
writer = WriteText(writer, "\",\"rate\":{\"xmr_atomic_units\":")
|
||||
writer = WriteDecimal(writer, address_atomic)
|
||||
writer = WriteText(writer, ",\"token_units\":5000000},\"confirmations_required\":")
|
||||
writer = WriteDecimal(writer, address_confirmations)
|
||||
writer = WriteText(writer, ",\"minimum_atomic_amount\":1000}\n")
|
||||
return writer.valid
|
||||
}
|
||||
|
||||
@@ -52,13 +75,7 @@ FakeStart :: (context: *void, request: HttpRequest, output: []u8) -> bool {
|
||||
if request.url == "https://api.waozi.xyz/api/v1/tokens/purchases/monero/address" {
|
||||
address_requests += 1
|
||||
check_true("address lookup uses authenticated GET", request.method == "GET" && request.body.count == 0)
|
||||
writer := Writer.{output, 0, true}
|
||||
writer = WriteText(writer, "{\"account_id\":\"")
|
||||
writer = WriteText(writer, TextUntilNul(owner.public_id[:]))
|
||||
writer = WriteText(writer, "\",\"address\":\"")
|
||||
writer = WriteText(writer, TestAddress)
|
||||
writer = WriteText(writer, "\",\"rate\":{\"xmr_atomic_units\":1000000000000,\"token_units\":5000000},\"confirmations_required\":10}")
|
||||
return writer.valid
|
||||
return AddressReply(output)
|
||||
}
|
||||
check_true("only the storage endpoint is requested", request.url == "https://api.waozi.xyz/api/v1/storage/plan")
|
||||
requests += 1
|
||||
@@ -132,6 +149,34 @@ Check :: () -> s32 {
|
||||
check_true("Monero address belongs to the connected account", TextUntilNul(dew_address[:]) == TestAddress)
|
||||
check_true("Monero quote preserves atomic units", dew_rate_atomic == 1000000000000LL && dew_rate_units == 5000000 && dew_confirmations == 10)
|
||||
check_true("foreign Monero account rejected", !DewParseAddress("{\"account_id\":\"another-account\"}"))
|
||||
check_true("minimum Monero deposit loaded", dew_minimum_atomic == 1000)
|
||||
invalid: [8192]u8
|
||||
address_network = "stagenet"
|
||||
unused AddressReply(invalid[:])
|
||||
check_true("test network payment rejected", !DewParseAddress(TextUntilNul(invalid[:])))
|
||||
address_network = "mainnet"
|
||||
address_asset = "other:token"
|
||||
unused AddressReply(invalid[:])
|
||||
check_true("foreign payment asset rejected", !DewParseAddress(TextUntilNul(invalid[:])))
|
||||
address_asset = "waozi:token"
|
||||
address_atomic = 99
|
||||
address_confirmations = 0
|
||||
unused AddressReply(invalid[:])
|
||||
check_true("invalid quote rejected atomically", !DewParseAddress(TextUntilNul(invalid[:])) &&
|
||||
dew_rate_atomic == 1000000000000LL && dew_confirmations == 10 && dew_minimum_atomic == 1000)
|
||||
address_atomic = 1000000000000LL
|
||||
address_confirmations = 10
|
||||
response_status = 503
|
||||
DewTopUp()
|
||||
check_true("new address lookup hides the previous quote", dew_address[0] == cast(u8)0)
|
||||
Finish()
|
||||
check_true("failed lookup cannot show a stale payment address", dew_address[0] == cast(u8)0)
|
||||
response_status = 200
|
||||
DewTopUp()
|
||||
Finish()
|
||||
check_true("safe payment lookup recovers", TextUntilNul(dew_address[:]) == TestAddress)
|
||||
parsed: DewAccount
|
||||
check_true("extra JSON documents rejected", !DewParseAccount("{}\n{}", TextUntilNul(owner.public_id[:]), *parsed))
|
||||
|
||||
response_balance = 234567
|
||||
DewBuyStorage("monthly")
|
||||
@@ -160,6 +205,13 @@ Check :: () -> s32 {
|
||||
DewBuyStorage("monthly")
|
||||
Finish()
|
||||
check_true("insufficient credit is explained", dew_notice == "profile_dew_funds" && dew_attempt[0] == cast(u8)0)
|
||||
unused DewTakeSyncRequest()
|
||||
SyncNodeStorageWrite(DewNode, SyncNodeStorage.{.known = true,
|
||||
.used_bytes = 10485760, .limit_bytes = 10485760, .checked_at = DewNow(), .full = true})
|
||||
response_status = 200
|
||||
DewTick(true, 100.0)
|
||||
Finish()
|
||||
check_true("allowance refreshed from another device wakes sync once", DewTakeSyncRequest() && !DewTakeSyncRequest())
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user