# Native checkout payment repair Implemented both payment fixes on baseline `28ff85f`. The simulated wallet and RPC tests cover the fixes. No live payment was made. ## Defects fixed 1. **The approval preflight understated the ETH needed for both transactions.** In the baseline, `web/src/native/payment.ts:63–73` used 25 gas per request byte and `eth_gasPrice`. The check at line 236 could pass for a 14-game wallet funded at the quoted 314,800 gas units even though the supplied fork run used 327,414 for the approval and request together. The wallet could pay for approval and then run short before the request. The updated quote estimates the actual approval when allowance is short and the actual request when allowance covers it. The fallbacks are 55,000 gas for approval and 30,000 plus 40 per UTF-8 body byte for the request. The unbuffered request fallback yields 183,760, 214,760, and 285,680 gas for the three measured sizes, above 178,730, 209,660, and 280,450 respectively. The quote adds 20% and rounds up, then uses `maxFeePerGas` with a gas-price fallback. The schedule check precedes this quote so the joint balance check is fresh before approval. The live price is checked again before the approval prompt, and the funded request is quoted again before submission. [Quote](../../../../../../web/src/native/payment.ts#L70) · [Preflight](../../../../../../web/src/native/payment.ts#L253) 2. **A failed wallet write without a hash could block every later checkout for that selection.** The baseline cleared only wallet rejection at `web/src/native/payment.ts:277–286`. Reconciliation at line 117 classified every hashless attempt as unknown, and line 197 kept the checkout pending. The updated path records the start block and reads the wallet's pending nonce before opening the request prompt. After a non-rejection write error, the journal entry is cancelled if both pending nonce reads succeed and match, including when an unrelated transaction was already pending. The original wallet error still reaches the caller. An advanced or unreadable pending nonce leaves the journal in place. On later checkout, a hashless entry is retryable if the pending nonce matches the count at its recorded block, and the historical duplicate check still runs before a new write. Explicit wallet rejection still clears the entry. [Reconciliation](../../../../../../web/src/native/payment.ts#L131) · [Request journal](../../../../../../web/src/native/payment.ts#L290) ## Files changed - `web/src/native/payment.ts` shares the existing Intake call parameters across estimation and submission, computes the buffered quote, and reconciles hashless attempts using nonce evidence. - `web/tests/native-checkout.test.mjs` adds five regression tests and extends the simulated RPC. The existing simultaneous-send test previously expected all ambiguous wallet errors to block another try. It now advances the simulated pending nonce before asserting that block. A separate test demonstrates retry when the nonce stays unchanged. - `artifacts/goal/batches/native-repair/items/payment/result.md` records this result and is delivered separately from source. ## Customer copy and confirmation No new English customer-facing sentences were authored. Checkout still requires the existing Intake payment, admission and completion evidence before displaying paid or completed status. The customer wallet signs the existing approval and Intake request. The native checkout and report reader require no backend signing key. The repository's legacy Worker uses `VERIFIER_PRIVATE_KEY` for historical escrow settlement only. [Native flow operating guide](../../../../../../docs/IMD_NATIVE_FLOW.md) ## Checks Commands ran from `web/` unless noted. `TMPDIR` pointed to `test/scratch/tmp` for the successful checks requiring temporary files. | Command | Exit | Result | | --- | ---: | --- | | `npm ci --cache ../test/scratch/npm` | 0 | Installed 80 packages. npm reported two audit findings, one moderate and one high. | | `node --test tests/native-checkout.test.mjs` against baseline source with the new tests | 1 | 22 tests, 17 passed and five failed as expected. The assertions at `tests/native-checkout.test.mjs:409,419,428,442,455` caught the retained hashless attempt, inability to retry a stored attempt, incorrect fee estimate, approval at the old ETH threshold, and incorrect legacy fallback. | | `node --test tests/native-checkout.test.mjs` after repair | 0 | 22 passed. | | `npx tsc --noEmit` | 0 | Type check passed. | | `npx vite build --outDir ../test/scratch/payment-dist --emptyOutDir` | 0 | Production bundle built. Vite reported a chunk above 500 kB. | | `node scripts/i18n-check.mjs` without the scratch `TMPDIR` | 1 | Temporary directory creation failed at `scripts/i18n-check.mjs:45` because `/tmp` was unavailable. | | `node scripts/i18n-check.mjs` with the scratch `TMPDIR` | 0 | 605 source strings checked across nine non-English languages. | | `git diff --check` and `git diff --name-only` from the repository root | 0 | No whitespace errors. Only the two assigned source and test paths appear in the diff. | | `git add -- web/src/native/payment.ts web/tests/native-checkout.test.mjs` from the repository root | 128 | The checkout's read-only Git metadata prevented creating `.git/index.lock`. Source changes remain in the working tree. | | `node --test test/scratch/merged-check/tests/native-merged.test.mjs` from the repository root | 0 | 29 tests, 27 passed and two existing TODOs. The copied test targets the real `web/src` and supplies the two missing RPC responses in its scratch fixture. It exercised the simulated payment through report rendering. | | `node --test tests/*.test.mjs` with the repository fixtures, before the final nonce refinement | 1 | 221 tests, 193 passed, 26 failed and two existing TODOs. All 26 failures came from the strict RPC fixture hook at `tests/native-merged.test.mjs:83`. | | `node --test` with `tests/*.test.mjs` and the scratch copy substituted for `tests/native-merged.test.mjs` | 0 | 221 tests, 219 passed and two existing TODOs. | ## Findings outside this item - The untouched merged-flow RPC fixture (`web/tests/fixtures/native-merged/edges.mjs:90–113`) has no responses for `eth_maxPriorityFeePerGas` and `eth_estimateGas`. The end-to-end fixture's strict unexpected-RPC hook at `web/tests/native-merged.test.mjs:83` reports these calls as failures. The failing case definitions were at `web/tests/native-merged.test.mjs:155,201,210,224,258,267,282,296,307,327,338,358`. Several definitions are parameterized. The scratch copy adds those two RPC responses and points back to the real application sources. - The merged tests still mark two tracker defects as TODO. `web/src/native/client.ts:226–232` can lose the admitted job ID while the result endpoint returns 404, and `web/src/native/client.ts:212` treats a confirmed refusal after admission as a disagreement. - The local operating guide records prior job context and production hosting requirements. The public production repository was readable. The two Explorer job pages and production site were inaccessible through the browser tool. Changes were confined to the assigned payment files. [Production repository](https://github.com/AgentStewLC/launch-3500-imd-picks-complete) · [Operating guide](../../../../../../docs/IMD_NATIVE_FLOW.md) ## What remains unproven The tests simulate the wallet, Ethereum and IMD.fun. The supplied fork measurements were used to choose fallback constants. The new estimate was not independently validated on a fork or through real wallet fee reservation. Pending nonce visibility can differ between RPC nodes and wallet relays, so an unchanged count only describes the queried RPC's view. Fee changes between wallet prompts can still require another balance check. Live Intake admission, Swarm staffing and research, delivery of the declared artifacts, and production rendering after a real payment remain unproven. The owner needs deployment access to an authorized test origin and a wallet funded with IMD and ETH for a paid acceptance run. No deployment or release flag was changed.