Repository navigation
fix(#16): read request_advance with #94's leading source, and tag AdMob's nullifier - #107
Conversation
…ob's nullifier #106 puts a Source first in request_advance. The history routes read its arguments by position, so after the upgrade every new advance would have read the source as the borrower and dropped out of /advances and /transactions without an error. Calls already on chain keep the old five arguments, so both shapes are read. An AdMob nullifier appends len || "admob", as claim::nullifier_of does on #106; the value is checked against that contract's nullifier_for. /advances rows gain source.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Lexirieru
left a comment
There was a problem hiding this comment.
Approving. This is the catch of the week, @Lin1er — a break with no error, no 502 and no failing test, found by reading #106's argument order against code that nobody had changed. The Repayment screen would have gone quietly empty for every advance taken after the upgrade, AdSense included, and we would have blamed the contract.
Verified here, not read off CI
| What | Result |
|---|---|
npx tsx --test "src/**/*.test.ts" in be/ |
104 pass, 0 fail (5.8s) |
npx eslint . |
clean, exit 0 |
npx tsc --noEmit |
clean, exit 0 |
nullifierFor(pub-1234567890123456, 2026-07-01, 2026-09-30, "AdMob") |
b4e99442…d93a58, derived independently in Python from docs/interface.md |
| The same inputs, AdSense | 3140b7a0…4ba31a, the literal #106 pins |
Both literals match a Python derivation I wrote from the spec, so your TypeScript, #106's Rust and that Python agree on the tagged nullifier. I also read #106's merged signature to check the positional skip: request_advance(env, source, borrower, revenue_usd, pub_id, window_start, window_end, …), so after stripping the source, [borrower, , pubId, windowStart, windowEnd] lands on exactly the right five. Both call sites — advanceCalls and ledgerTransactions — go through requestArgs, which is what makes this a fix rather than half a fix.
The Array.isArray(args[0]) discriminator is the right call. A unit variant arrives as ["AdMob"] and an address as a G… string; the two cannot collide, and it needs no flag, no config and no coordination with the upgrade.
One note, not blocking
source = args[0][0] === "AdMob" ? "AdMob" : "AdSense";An unrecognized tag becomes AdSense. With Source holding exactly two variants that is correct today. But if a third source is ever added, this computes the untagged nullifier for it, readAdvance finds no record, the row is dropped by the record?.borrower === borrower filter, and it vanishes from /advances — the same silent disappearance this PR exists to fix, arriving by the same route. #106's source_tag gives every non-AdSense source a tag, so the asymmetry is in the contract's favour and only this line defaults the wrong way.
Worth one line, whenever Source next grows: treat an unknown tag as unknown and let it fail loudly, rather than calling it AdSense. Nothing to change now.
Merging, and why it is safe before the upgrade
Both shapes are read, so this is correct against the deployed v0.4.0 and against v0.5.0. Merging it now means the host can pick it up well before execute_upgrade, which is the window that matters.
* docs(#17): the relay host runs main, at 03da644 The host was fast-forwarded from 29d6719 and restarted. The only runtime change is #92's wording; health, config, ready and CORS were checked from outside afterwards. * docs(#17): the relay host runs feat/admob-relay at 3102f64, for AdMob before #100 merges * docs(#17): the relay host runs feat/admob-relay rebased onto main, at 1095ba6 * docs(#17): #107 is on the relay host, at 8097128, before #106's upgrade * docs(#17): the relay host is back on main, at 2ea1e15
…PI's source (#108) * fix(#97): Advance details name AdMob for an AdMob advance, from the API's source #107 adds `source` to every /advances row, read from the request_advance call. The client keeps it, and reads a row without one (an API from before #107) or with an unknown one as AdSense. "AdSense revenue, …" on Repayment becomes "AdMob revenue, …" for an AdMob advance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(#97): keep the revenue window whole when the Advance details label wraps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Nabil-Aufa <181296848+Nabil-Aufa@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Found while reviewing #106. This has to be deployed before #106's
execute_upgrade, or with it.The problem
#106 puts
source: Sourcefirst inrequest_advance. The history routes (#16) read that call's arguments by position:After the upgrade,
callBorrowerwould be the source (["AdSense"]). That never equals the wallet, so every advance taken after the upgrade, AdSense included, would silently disappear from/advancesand/transactions. There would be no error and no 502, just an empty ledger on the Repayment screen. It is the same "argument order shifted" break @Nabil-Aufa found for the front end on #106, on the API side.The fix
["AdMob"], a unit enum variant as a vec holding its symbol. NoG…string has that shape, so the two cannot be confused.len ‖ "admob", likeclaim::nullifier_ofon feat(#94): AdMob as a second revenue source, and refuse an unpinned claim owner #106. AdSense appends nothing, so every nullifier already on chain is unchanged./advancesrows gainsource("AdSense"or"AdMob"). It is read from the call itself, so it is whatadvance_source(nullifier)returns, without a second read. That covers theAdvanceDetailsgap feat(#97): choose AdSense or AdMob on 2a, and prove the chosen one #104 lists.Checked
["AdSense"]firstdeepEqualto the original, nullifier included["AdMob"]firstb4e99442…3a58, equal to #106's ownnullifier_for(AdMob, …), run on648f8643140b7a0…a31a, the literal #106 pins inthe_adsense_nullifier_bytes_did_not_changeBE lint and typecheck are clean, and 104/104 tests pass.
docs/api.mddocumentssourceand the tagged nullifier.Deploy
Merging this changes nothing on chain. The relay host picks it up through #100's rebase. Until the upgrade, every call is five arguments and reads exactly as today.