Commit e17645e
fix(cli): init mpp polls faucet balance and updates funded summary
Before this change, `run402 init mpp --json` reported
`allowance.funded: false` and `balance.usd_micros: 0` even after a
successful Tempo faucet top-up. Two problems:
1. `summary.allowance` was snapshotted BEFORE the faucet branch ran
(captured from the pre-faucet `allowance.funded`), so the JSON
emit never reflected the post-faucet state even though
`saveAllowance(...)` persisted `funded: true`.
2. The MPP path re-read the balance only once after the faucet call,
while the Tempo RPC read is racy relative to faucet settlement
(the human-readable line was "faucet sent — checking balance..."
and then the JSON reported usd_micros: 0).
Fix: after a successful faucet on the MPP rail, poll `readContract`
up to 30 times with 1s intervals — mirroring the x402 path that has
used this pattern since initial MPP support. On both rails, write the
up-to-date `funded` state onto `summary.allowance` so the final JSON
matches the allowance storage and the human-readable output.
Regression test (`init mpp --json reports funded=true after faucet
settles (GH-81)`) asserts `summary.allowance.funded === true` and
`summary.balance.usd_micros > 0` after the faucet branch runs. The
test fails on pre-fix `init.mjs` (reproduces the issue exactly).
Refs #81
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 13138a8 commit e17645e
2 files changed
Lines changed: 36 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1578 | 1598 | | |
1579 | 1599 | | |
1580 | 1600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
120 | 126 | | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
124 | | - | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
| |||
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
| 141 | + | |
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
| |||
162 | 170 | | |
163 | 171 | | |
164 | 172 | | |
| 173 | + | |
165 | 174 | | |
166 | 175 | | |
167 | 176 | | |
| |||
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| 186 | + | |
177 | 187 | | |
178 | 188 | | |
179 | 189 | | |
| |||
0 commit comments