Skip to content

feat(#97): choose AdSense or AdMob on 2a, and prove the chosen one - #104

Merged
Lexirieru merged 6 commits into
mainfrom
feat/admob-fe
Oct 30, 2026
Merged

Lexirieru merged 6 commits into
mainfrom
feat/admob-fe

Conversation

@Nabil-Aufa

@Nabil-Aufa Nabil-Aufa commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #97 once the flow completes for both sources against the relay (see "After merge").

Targets main (#75 is merged). Ready for review, @Lexirieru.

Safe to merge before #106. With NEXT_PUBLIC_CONTRACT_TAKES_SOURCE unset, every call to the contract is byte for byte what main sends today. AdSense behaves exactly as now. An AdMob proof gets as far as the offer, and the deployed contract refuses it at simulation ("Forepay is not taking AdMob proofs yet"), before the wallet is asked to sign.

What changed

Commit What
f4eddd5 2a asks "Where you earn": AdSense (Websites) or AdMob (Apps). The Google sign-in asks for the chosen source's read-only scope only. A token without it counts as the creator stopping. POST /proofs carries source: "admob" for AdMob only, so an AdSense request is byte for byte what it was. The kept job records its source. noAdmob and googleSignInAdmob panels. The mock answers AdMob the relay's way.
e3d8aaa e2e for AdMob on the relay build. The tiles stack below about 19rem of card, where they spilled at 320.
980639d The chosen tile is highlighted from state, and e2e pins which one.
1cb136f Fixes from a strict review (two rounds, PASS), below.
17cf2a3 Tightens one e2e wait.
0b2a5d1 #106 puts source first in request_advance and nullifier_for. Both calls now lead with vec[symbol("AdSense")] or vec[symbol("AdMob")], behind NEXT_PUBLIC_CONTRACT_TAKES_SOURCE=1. Unit tests for the encoding, flag off and flag on. The relay build sets the flag, and e2e asserts which source each call carried.

Fixes found in review:

  • A job kept as AdMob, resumed after leaving /advance, made Prove again ask Google for adsense.readonly. proofRunning now returns the kept job's source, which becomes the choice, so Prove again and Back stay on AdMob. An e2e test walks it across a real remount.
  • The contract's refusals that name AdSense (10, 11, 14, 30) name AdMob for an AdMob proof.

How the AdMob figure is used

As docs/api.md on #100 describes it: the relay returns revenueMicros (the signed figure) and revenueUsd (the exact decimal, display only).

After merge

In this order, from the front end's side (also on #106):

  1. fix(#16): read request_advance with #94's leading source, and tag AdMob's nullifier #107 deploys to the API host.
  2. feat(#94): AdMob as a second revenue source, and refuse an unpinned claim owner #106: propose_upgrade, the 24-hour timelock, then execute_upgrade.
  3. @AncungAulia sets NEXT_PUBLIC_CONTRACT_TAKES_SOURCE=1 on forepay-vue5 and redeploys, right away. Between 2 and 3 nobody can accept an advance, but nothing is lost: the refusal comes at simulation.
  4. set_claim_owner, then the AdSense and AdMob templates.

Also needed for AdMob from the browser: admob.readonly on the OAuth client (#98).

Answered on this PR

For the board (@AncungAulia)

New on 2a, not on the board yet. A proposal in the board's tile style: $radius-tile, $brand stroke and $brand-subtle fill when chosen, the same as the "Shape tile" token. It sits under the body copy, above the two lists:

Where Now
Legend "Where you earn"
Tiles "AdSense" / "Websites", "AdMob" / "Apps". Side by side from about 19rem of card, stacked on the narrowest phones
2a body "Sign in with Google in a secure window. We read your {AdSense / AdMob} revenue for the last three months and nothing else."
What we read "Your {AdSense / AdMob} publisher ID"

Board strings that now name the source:

Where Board Now
Reading "Reading your revenue" "Reading your AdSense revenue" / "Reading your AdMob revenue"
Waiting body "…owns your AdSense, and allow Forepay to see your AdSense reports…" The same, with AdMob for AdMob
Checking body "…really came from AdSense." "…from AdMob." for AdMob
2b sentence and breakdown "…you earned on AdSense…", "Your AdSense revenue, Jul to Sep 2026" AdMob for AdMob

New panels, "Prove again" + "Back" like their AdSense twins:

Panel Title / body
noAdmob "We could not use your AdMob account" / "We could not find one AdMob account on this Google account. Sign in with the account that owns your AdMob, then try again. Nothing was charged."
googleSignInAdmob "Google did not let us read AdMob" / "Sign in again and allow Forepay to see your AdMob reports. Nothing was charged."

Not done here

Checked

  • Lint and typecheck are clean.
  • 201 unit tests pass.
  • Playwright: 244 pass, 22 skipped, both builds. That includes the AdMob runs on the relay build, desktop and mobile, through to "Advance received" with both calls carrying AdMob.
  • A strict review against the pen file, Playwright and real Chrome (1440, 768, 390, 320, keyboard and screen-reader names) passed on the second round; the source commit passed an independent review.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
forepay-vue5 Ready Ready Preview Oct 29, 2026 8:02pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
forepay Skipped Skipped Oct 29, 2026 8:02pm UTC

Lin1er added a commit that referenced this pull request Oct 27, 2026
A report with no row is how AdMob says the account earned nothing. That is
not a shape the relay failed to expect, so the front end should not tell the
creator to try again in a few minutes (asked on #104).
@Lin1er

Lin1er commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

@Nabil-Aufa, answers to your two questions:

1. A code for AdMob at zero: done on #100 (1c83371). A report with no row now fails with code: "empty", before the attestor, and provider is back to meaning only "a shape we did not expect". docs/api.md on #100 has the row:

code Meaning What the creator can do
empty AdMob reports no earnings in the window (no row, #93) Nothing to prove for these months

Only AdMob sends it. AdSense at zero still answers with a total row, so it is not a relay error; it would reach the offer as $0. Your "No AdMob revenue in these months" panel can key on empty.

2. admob.readonly on the OAuth client. #86 is not submitted yet: it still waits on the forepay.xyz TXT record in Search Console (@AncungAulia), then Branding and submit. So the consent screen is still in Testing, and I agree with you: adding the scope now does not restart a review, because none has started. It also means the review, when it is submitted, covers both scopes at once instead of a second round later (#98).

Two things it needs, both on the console side, so I am leaving the call to whoever holds the project there:

  • admob.readonly added to the client's scopes.
  • The AdMob account owner added as a test user, so their sign-in is allowed while the app is in Testing.

Until then prove:admob from the CLI remains the way a real AdMob proof is made, and it already worked once against the real attestor (#96).

@Lin1er

Lin1er commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Correction to point 1 above: I was wrong that AdSense at zero answers with a total row. I checked the AdSense report for the account outside the team: it is READY and earned nothing in Jul–Sep, and AdSense sent only headers, startDate and endDate. There were no totals, no averages and no row count. The relay therefore failed it as provider too.

Fixed on #100 (3102f64). A report with only those three keys is now empty, before the attestor, the same as AdMob, and there is a test with that exact shape. So empty comes from both sources, and the panel can be source-neutral or name the source the job already records. The docs/api.md row now reads:

code Meaning What the creator can do
empty No earnings in the window: AdMob sends no row (#93), AdSense only headers and the dates Nothing to prove for these months

@Lin1er

Lin1er commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

@Nabil-Aufa, an update on question 2: the consent screen is now published (#86, 2026-10-27), and @Lin1er is adding admob.readonly to it. Once the scope is on, any Google account can sign in for AdMob, past the "unverified app" warning; no test-user list.

That leaves two things before the browser flow works against the real relay:

The legal pages for the second scope are on #105.

Nabil-Aufa and others added 5 commits October 30, 2026 02:31
- 2a asks where the creator earns, AdSense (websites) or AdMob (apps). The
  Google sign-in asks for that source's read-only scope only, and a token
  without it counts as the creator stopping.
- POST /proofs carries `source: "admob"` for AdMob only, so an AdSense
  request is what it was before. The kept job records its source, and a
  resumed job proves what it was started for.
- The relay's `token` and `account` failures name AdMob for an AdMob proof
  (googleSignInAdmob, noAdmob). The waiting, checking and offer copy name
  the source.
- An AdMob figure is sized from its micros truncated to cents (`provenUsd`).
  `request_advance` gets the signed micros; its AdMob arguments land with #94.
- The mock answers AdMob the relay's way, so the flow runs without a relay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arrowest phones

- relay.spec: choosing AdMob asks Google for admob.readonly only, sends
  `source: "admob"`, sizes the offer from the micros truncated to cents and
  names AdMob on the offer. A Google account with no AdMob gets the AdMob
  panel, and Prove again stays on AdMob.
- The two source tiles sit side by side from about 19rem of card, and stack
  below it, where "AdSense" spilled out of its tile at 320 (layout.spec).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pins which one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ays so

From a strict review:
- A job kept as AdMob made the choice again only for its own resume. After
  leaving and coming back, Prove again asked Google for adsense.readonly and
  the relay proved AdSense. `proofRunning` now returns the kept job's source,
  and `prove(src)` makes it the choice, so Prove again and Back stay on it.
- "Reading your revenue" names the source, from the kept job on a resume.
- The contract's refusals that name AdSense (10, 11, 14, 30) name AdMob for
  an AdMob proof.
- The source tiles say "Websites" and "Apps", so neither wraps where the
  other does not, and the tile's ring is the only focus indicator.
- An AdMob request without micros is cut to cents before `quote`, which
  refuses a third decimal place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…urce, once the contract takes it

#106 (#94) puts `source: Source` first in both calls. Behind NEXT_PUBLIC_CONTRACT_TAKES_SOURCE=1 the
front end sends it, as `vec[symbol("AdSense")]` or `vec[symbol("AdMob")]`; unset, the calls are what
they were, so this can merge before the upgrade and the switch is one env change when it executes.

The relay e2e build runs as against #106's contract and the mock build as before it. The stub sizes an
AdMob request_advance from its micros, and the AdMob test now goes through to 2d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lin1er added a commit that referenced this pull request Oct 29, 2026
A report with no row is how AdMob says the account earned nothing. That is
not a shape the relay failed to expect, so the front end should not tell the
creator to try again in a few minutes (asked on #104).
@Nabil-Aufa
Nabil-Aufa marked this pull request as ready for review October 30, 2026 13:22
@Nabil-Aufa
Nabil-Aufa requested a review from Lexirieru October 30, 2026 13:22

@Lexirieru Lexirieru left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, @Nabil-Aufa. The part I came to check hardest — the encoding, and the decision to put AdMob's micros into a parameter literally named revenue_usd — is right, and right for a reason you state rather than assume.

Verified here

What Result
pnpm vitest run in fe/ 28 files, 201 tests, 201 pass
sourceArg against #106's ABI scvVec([scvSymbol("AdSense" | "AdMob")]) is exactly how a Source unit variant encodes
Argument order against the merged request_advance (env, source, borrower, revenue_usd, pub_id, window_start, window_end, timestamp_s, epoch, signature, recovery_id) — advanceArgs matches position for position
Every nullifierFor / provenUsd / advanceArgs call site all pass the source through; none falls back to the AdSense default by omission

On the micros: #106's revenue_cents dispatches on the source — parse_usd_cents for AdSense, parse_micros_cents for AdMob — and revenue_key picks revenueUsd or revenueMicros for the context rebuild. So the signed micros string belongs in revenue_usd, and sending the decimal there instead would be the bug. The parameter name is the thing that's wrong, and it's wrong in the contract, not here.

provenUsd truncates with BigInt(micros) / 10_000n, which is what parse_micros_cents does, down to refusing to round up.

The fallback fails loud — checked, not assumed

I went after the !req.revenueMicros path, where "0.004567" becomes "0.00", expecting it to turn a loud refusal into a silent $0 offer. It does not. Simulated against the live contract CCQFL2Q6…I2HS:

quote("0.00")  ->  HostError: Error(Contract, #31)   // AdvanceTooSmall

So a sub-cent figure stops at the quote with a named error, before the wallet is involved. The fallback is safe, and only reachable if the relay omits revenueMicros, which #100 never does.

One thing for the sequence, and it is not about AdMob

The step your "After merge" list numbers 3 is the risky one, and it is riskier than the list makes it look:

@AncungAulia sets NEXT_PUBLIC_CONTRACT_TAKES_SOURCE=1 on forepay-vue5 and redeploys, right away.

Between execute_upgrade and that rebuild, AdSense is down too — not only AdMob. The live bundle sends nine arguments to a ten-argument function, so every advance fails at simulation, including the one the demo walks through. You say "nothing is lost", which is true, and I want to be precise about what is: no funds, no proofs, no state. Only the app, for as long as the rebuild takes.

Two things follow:

  • NEXT_PUBLIC_* is inlined at build time. Setting the variable in Vercel and not redeploying changes nothing at all, and the symptom is identical to not having set it. Your wording already says "redeploys" — I am underlining it because this is the step where that distinction bites.
  • This is a booked human handoff, not a note in a PR body. @AncungAulia has to be at a keyboard at the moment I run execute_upgrade. I will not run it until that is agreed, and I will post the timestamp here and on #94 beforehand.

Not blocking, and already on your list

AdvanceDetails saying "AdSense revenue" for the first AdMob advance is the one that becomes visibly wrong rather than merely incomplete. #107 just merged and /advances now carries source per row, read from the call itself — so the data is there, and it needs no second contract read. Small follow-up, worth doing before the demo rather than after.

Merging. With the flag unset, every call this ships is byte for byte what main sends today, which I checked by reading withSource rather than by trusting the claim.

@Lexirieru
Lexirieru merged commit f415506 into main Oct 30, 2026
9 checks passed
Lin1er added a commit that referenced this pull request Oct 30, 2026
A report with no row is how AdMob says the account earned nothing. That is
not a shape the relay failed to expect, so the front end should not tell the
creator to try again in a few minutes (asked on #104).
Lexirieru pushed a commit that referenced this pull request Oct 30, 2026
…ST /proofs (#100)

* feat(#95): an AdMob provider beside AdSense, selected by source on POST /proofs

be/src/admob/ proves the trailing AdMob revenue the way be/src/adsense/
proves AdSense's: a POST to networkReport:generate whose JSON body carries
the window (signed byte for byte, #93), with regexes written against the
bytes #93 read from a real account, including the \n,\r\n separator.

- The figure is extracted as revenueMicros, an integer; the contract
  truncates it to cents (#94). At zero AdMob sends no row, and the relay
  stops with provider before the attestor.
- The AdSense audit takes a ClaimShape, so both sources share one
  allow-list, credential scan and signature check. AdSense's behaviour
  and its request JSON are unchanged.
- POST /proofs takes source: "adsense" | "admob", defaulting to adsense.
- prove:admob produces one real proof, with the token passed inline, as
  the input to the AdMob template (#96).
- A test pins the signed value order for AdMob, dates before pub_id,
  which is what the contract has to rebuild (#94).

docs/admob-provider.md and docs/api.md describe it. 117 BE tests pass.

* fix(#95): AdMob at zero fails with its own code, empty, not provider

A report with no row is how AdMob says the account earned nothing. That is
not a shape the relay failed to expect, so the front end should not tell the
creator to try again in a few minutes (asked on #104).

* fix(#95): AdSense at zero fails as empty too

An approved AdSense account with no earnings answers with only its headers and
dates: no totals, no averages, no row count. That failed as provider, the same
as a shape we did not expect. It is now empty, before the attestor, like AdMob.

* test(#95): an AdMob proof is held to the relay's own claim owner too (#102)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AdMob (#90): front end, choosing the revenue source on 2a

3 participants