Skip to content

feat: HF14 prediction-market operations (op ids 60-105) - #4

Merged
chiliec merged 2 commits into
masterfrom
feat/prediction-market-ops
Oct 11, 2026
Merged

chiliec merged 2 commits into
masterfrom
feat/prediction-market-ops

Conversation

@chiliec

@chiliec chiliec commented Oct 9, 2026

Copy link
Copy Markdown
Member

Summary

OperationId stopped at 59 while the node is at 105. This PR closes the gap, with the HF14 "Onix" prediction-market protocol as the main payload.

  • HF13 / HF15 gap ops: FixedAward (60), TargetAccountSale (61), Bid (62, virtual), Outbid (63, virtual), SetRewardSharing (64), StakeholderReward (65, virtual), SetAgentPermission (105).
  • 23 HF14 prediction-market broadcast ops (66–83, 91–93, 98–99): PmOracleRegister, PmOracleUpdate, PmCreateMarket, PmPlaceBet, PmCommitBet, PmRevealBet, …, PmLeverageOpen/Close/Convert, PmDisputeOracleRespond, PmUnban. Encodable + decodable, memberwise inits with node defaults (side = -1, outcomeIndex = -1, allowInstantBet = true, endogeneityTier = 2, …).
  • 16 HF14 virtual ops (84–90, 94–97, 100–104): decode-only, isVirtual == true.
  • PmOracleUpdate carries real optionals and gets an explicit binaryEncode (synthesized encodeIfPresent drops the flag byte).
  • Client: prediction_market_api read methods (get_market, list_markets, get_account_positions, …) are routed to their namespace.
  • README: prediction-market example.

No encoder changes: VIZEncoder already covers Int8/Int16/…/Date/Data/Optional/Array.

Verification

  • 27 new round-trip fixtures (binary encode + JSON decode + AnyOperation decode). The 23 PM vectors are byte-identical to the ones in viz-python-lib/tests/test_pm_operations.py (shared with viz-php-lib and the node); the 4 gap-op vectors were produced with the viz-js-lib-oracle-verified @viz-cx/core serializer.
  • 4 new virtual-decode tests (stakeholder_reward, pm_payout, pm_leverage_resolve, pm_lp_payout).
  • All registered in XCTestManifests.swift. swift test --filter UnitTests: 155 tests, 0 failures.

Protocol reference: viz-cpp-node/libraries/protocol/include/graphene/protocol/{pm_operations,pm_virtual_operations,agent_operations}.hpp.

Out of scope: chain_properties_pm (the library has no chain-properties structs at all today) and typed wrappers for the PM read API.

- ops 60-65 (fixed_award, target_account_sale, bid, outbid,
  set_reward_sharing, stakeholder_reward) and 105 (set_agent_permission)
- 23 HF14 prediction-market broadcast ops (66-83, 91-93, 98-99)
- 16 HF14 prediction-market virtual ops, decode-only
- route prediction_market_api read methods in Client
- fixtures byte-verified against viz-python-lib / viz-php-lib vectors
The node's pm_leverage_open_operation declares int16_t outcome_index = 0
(leverage is binary-only); -1 is the pm_place_bet/pm_reveal_bet default
and was over-generalized. Also bump README install snippet to 0.2.0.
@chiliec
chiliec merged commit daa7454 into master Oct 11, 2026
1 check passed
@chiliec
chiliec deleted the feat/prediction-market-ops branch October 11, 2026 04:42
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.

1 participant