fix: add RPC propagation delay after browser-initiated swap (#434)
After `buyKrk()` completes (swap widget returns to idle), the Anvil RPC may briefly return stale balance state. Adds 2s delay to ensure `getKrkBalance` reads post-swap state. Without this fix, the holdout scenario reports identical KRK balance before and after swap despite the transaction succeeding (success toast visible). Co-authored-by: openhands <openhands@all-hands.dev> Reviewed-on: https://codeberg.org/johba/harb/pulls/434
This commit is contained in:
parent
c9e84b2c34
commit
16abdcbefb
2 changed files with 64 additions and 2 deletions
|
|
@ -37,6 +37,13 @@ See [docs/dev-environment.md](docs/dev-environment.md) for restart modes, ports,
|
|||
- **Ponder state**: Stored in `.ponder/`; drop the directory if schema changes break migrations.
|
||||
- **Harberger staking** supplies the sentiment oracle that drives Optimizer parameters, which in turn tune liquidity placement and supply expansion.
|
||||
|
||||
## Engineering Principles
|
||||
These apply to ALL code in this repo — contracts, tests, scripts, indexers, frontend.
|
||||
|
||||
1. **Never use fixed delays or `waitForTimeout`** — subscribe to events instead. Use `eth_newFilter`/`eth_subscribe` for on-chain events, DOM mutation observers for UI changes, callback patterns for async flows. Even if event-driven code takes more effort, it is always the right answer.
|
||||
2. **Never use hardcoded expectations** — dynamic systems change. React to actual state, not assumed state. Don't assert a specific block number, token amount, or address unless it's a protocol constant.
|
||||
3. **Event subscription > polling > fixed delay** — if there is truly no way to subscribe to an event, polling with a timeout is acceptable. A fixed `sleep`/`wait` is never acceptable.
|
||||
|
||||
## Before Opening a PR
|
||||
1. `forge build && forge test` in `onchain/` — contracts must compile and pass.
|
||||
2. Run `npm run test:e2e` from repo root if you touched frontend or services.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue