22pragma solidity ^ 0.8.20 ;
33
44import "./PostRegistry.sol " ;
5- import "./LinkGraph.sol " ;
65import "./StakeEngine.sol " ;
6+ import "./LinkGraph.sol " ;
77import "./ScoreEngine.sol " ;
88
99/// @title ProtocolViews
10- /// @notice Read-only aggregation over PostRegistry + StakeEngine + LinkGraph + ScoreEngine.
11- /// No storage; no mutation; deterministic output.
10+ /// @notice Read-only aggregation layer for UI/indexers.
1211contract ProtocolViews {
1312 PostRegistry public immutable registry;
1413 StakeEngine public immutable stake;
1514 LinkGraph public immutable graph;
1615 ScoreEngine public immutable score;
1716
1817 struct ClaimSummary {
19- uint256 postId;
20- address creator;
21- uint256 version;
2218 string text;
2319 uint256 supportStake;
2420 uint256 challengeStake;
@@ -40,107 +36,73 @@ contract ProtocolViews {
4036 score = ScoreEngine (score_);
4137 }
4238
43- // ------------------------------------------------------------------------
44- // Claim summary
45- // ------------------------------------------------------------------------
46-
4739 function getClaimSummary (uint256 claimPostId )
4840 external
4941 view
50- returns (ClaimSummary memory summary )
42+ returns (ClaimSummary memory s )
5143 {
5244 (
53- address creator ,
54- uint256 version ,
45+ ,
46+ ,
5547 PostRegistry.ContentType ct ,
5648 uint256 contentId
5749 ) = registry.getPost (claimPostId);
5850
59- require (ct == PostRegistry.ContentType.Claim, "ProtocolViews: not claim " );
51+ require (ct == PostRegistry.ContentType.Claim, "not claim " );
6052
61- string memory text = registry.getClaim (contentId);
53+ s. text = registry.getClaim (contentId);
6254
63- (uint256 supportStake , uint256 challengeStake ) =
55+ (s. supportStake, s. challengeStake) =
6456 stake.getPostTotals (claimPostId);
6557
66- int256 baseVS = score.baseVSRay (claimPostId);
67- int256 effectiveVS = score.effectiveVSRay (claimPostId);
68-
69- uint256 incomingCount =
70- graph.getIncoming (claimPostId).length ;
71-
72- uint256 outgoingCount =
73- graph.getOutgoing (claimPostId).length ;
74-
75- summary = ClaimSummary ({
76- postId: claimPostId,
77- creator: creator,
78- version: version,
79- text: text,
80- supportStake: supportStake,
81- challengeStake: challengeStake,
82- baseVSRay: baseVS,
83- effectiveVSRay: effectiveVS,
84- incomingCount: incomingCount,
85- outgoingCount: outgoingCount
86- });
58+ s.baseVSRay = score.baseVSRay (claimPostId);
59+ s.effectiveVSRay = score.effectiveVSRay (claimPostId);
60+
61+ s.incomingCount = graph.getIncoming (claimPostId).length ;
62+ s.outgoingCount = graph.getOutgoing (claimPostId).length ;
8763 }
8864
89- // ------------------------------------------------------------------------
90- // Raw VS passthroughs
91- // ------------------------------------------------------------------------
65+ // passthrough helpers
9266
93- /// @notice Raw base VS in ray (1e18 = +1.0, -1e18 = -1.0).
9467 function getBaseVSRay (uint256 claimPostId ) external view returns (int256 ) {
9568 return score.baseVSRay (claimPostId);
9669 }
9770
98- /// @notice Raw effective VS in ray (multi-hop, symmetrical).
9971 function getEffectiveVSRay (uint256 claimPostId ) external view returns (int256 ) {
10072 return score.effectiveVSRay (claimPostId);
10173 }
10274
103- // ------------------------------------------------------------------------
104- // Graph passthroughs
105- // ------------------------------------------------------------------------
106-
107- function getOutgoingEdges (uint256 claimPostId )
75+ function getIncomingEdges (uint256 claimPostId )
10876 external
10977 view
110- returns (LinkGraph.Edge [] memory )
78+ returns (LinkGraph.IncomingEdge [] memory )
11179 {
112- return graph.getOutgoing (claimPostId);
80+ return graph.getIncoming (claimPostId);
11381 }
11482
115- function getIncomingEdges (uint256 claimPostId )
83+ function getOutgoingEdges (uint256 claimPostId )
11684 external
11785 view
118- returns (LinkGraph.IncomingEdge [] memory )
86+ returns (LinkGraph.Edge [] memory )
11987 {
120- return graph.getIncoming (claimPostId);
88+ return graph.getOutgoing (claimPostId);
12189 }
12290
123- /// @notice Resolve link metadata for a link post id.
12491 function getLinkMeta (uint256 linkPostId )
12592 external
12693 view
127- returns (
128- uint256 independentClaimPostId ,
129- uint256 dependentClaimPostId ,
130- bool isChallenge
131- )
94+ returns (uint256 from , uint256 to , bool isChallenge )
13295 {
13396 (
13497 ,
13598 ,
13699 PostRegistry.ContentType ct ,
137- uint256 contentId
100+ uint256 linkId
138101 ) = registry.getPost (linkPostId);
139102
140- require (ct == PostRegistry.ContentType.Link, "ProtocolViews: not link " );
103+ require (ct == PostRegistry.ContentType.Link, "not link " );
141104
142- (independentClaimPostId, dependentClaimPostId, isChallenge) =
143- registry.getLink (contentId);
105+ return registry.getLink (linkId);
144106 }
145107}
146108
0 commit comments