Skip to content

feat(tholos): add set_bond_amount, admin-gated like update_resolvers/set_paused - #150

Merged
collinsezedike merged 4 commits into
drydocs:mainfrom
JohnArayaE:feat/set-bond-amount
Sep 4, 2026
Merged

feat(tholos): add set_bond_amount, admin-gated like update_resolvers/set_paused#150
collinsezedike merged 4 commits into
drydocs:mainfrom
JohnArayaE:feat/set-bond-amount

Conversation

@JohnArayaE

Copy link
Copy Markdown
Contributor

Summary

Adds set_bond_amount(new_bond_amount), admin-gated the same way update_resolvers and set_paused already are, validated against the same bounds initialize already enforces (bond_amount > 0, bond_amount <= MAX_BOND_AMOUNT). Emits a new BondAmountUpdated event on change.

A bond change only affects assertions created after the call: Assertion.bond already pins the bond amount at creation, and every payout path (dispute, finalize, resolve) reads that field, never the live DataKey::BondAmount. This PR makes that pinning guarantee explicit via a new doc comment on Assertion.bond, and adds a regression test proving a set_bond_amount call does not retroactively change an already-open assertion's payout.

docs/src/CONTRACT.md is updated to match: a new set_bond_amount function entry, the BondAmountUpdated event row, and the pinning note on Assertion.bond's field description.

Tests added

  • Happy path + regression: bond change applies to new assertions only, verified against an already-open assertion's payout.
  • Admin auth-gating, verified via env.auths().
  • Bound validation: zero, negative, above MAX_BOND_AMOUNT, and exactly at MAX_BOND_AMOUNT.
  • Rejection before initialize (NotInitialized).

Test plan

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test pass locally (76 passed in tholos, 107 in tholos-v2, unaffected)
  • CONTRACT.md updated to match the changed public interface
  • scripts/testnet-smoke.sh run against testnet — not run; this change is additive and doesn't affect the existing deployed flow (assert/dispute/resolve/finalize)
  • cargo build -p tholos --target wasm32v1-none --release builds successfully

Closes #134

…set_paused

Adds set_bond_amount(new_bond_amount) validated against the same bounds initialize already enforces (bond_amount > 0, bond_amount <= MAX_BOND_AMOUNT), emitting a new BondAmountUpdated event on change. A bond change only affects assertions created afterward: Assertion.bond already pins the bond amount at creation and every payout path (dispute, finalize, resolve) reads that field, never the live DataKey::BondAmount. Makes that pinning guarantee explicit via a new doc comment on Assertion.bond, and adds a regression test proving a set_bond_amount call does not retroactively change an already-open assertion's payout, plus tests for the happy path, admin auth-gating, and bound validation.

Closes drydocs#134
Adds the missing Errors section to set_bond_amount's doc comment (NotInitialized, InvalidBondAmount), per CONTRIBUTING.md's doc-comment convention. Updates docs/src/CONTRACT.md to keep the public interface reference in sync: adds the set_bond_amount function entry, the BondAmountUpdated event row, and notes the Assertion.bond pinning guarantee in its field table.
Regenerates packages/tholos-sdk/src from contracts/tholos's compiled wasm to include the new set_bond_amount function, per the CI drift check and packages/tholos-sdk/README.md's regeneration instructions.

@collinsezedike collinsezedike 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.

@JohnArayaE thank you for the contribution. This looks good, there is nothing to flag.

@collinsezedike
collinsezedike merged commit 86d436e into drydocs:main Sep 4, 2026
4 checks passed
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.

[Feature] bond_amount is immutable post-initialize in tholos v1

2 participants