Skip to content

Commit c33846b

Browse files
Feat/blockchain contracts (#847)
* feat(about): blockchain-contracts page + component dependencies - Updated v2/about/resources/blockchain-contracts.mdx - Added ResponseField, Icons components (new) - Updated Links, CustomCardTitle, DataEmbed components - Added contractAddressesData to snippets/data/changelogs/ - Added Arbitrum logo assets + Livepeer-Logo-Symbol-Mask.svg Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(nav): move blockchain-contracts to Protocol section Moved from About > Resources to About > Livepeer Protocol, after core-mechanisms, across all 4 language groups (en/es/fr/cn). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 02ec668 commit c33846b

13 files changed

Lines changed: 2331 additions & 465 deletions

File tree

‎docs.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,7 @@
21632163
"pages": [
21642164
"v2/about/livepeer-protocol/overview",
21652165
"v2/about/livepeer-protocol/core-mechanisms",
2166+
"v2/about/resources/blockchain-contracts",
21662167
"v2/about/livepeer-protocol/livepeer-token",
21672168
"v2/about/livepeer-protocol/governance-model",
21682169
"v2/about/livepeer-protocol/treasury",
@@ -2188,7 +2189,6 @@
21882189
"pages": [
21892190
"v2/about/resources/livepeer-whitepaper",
21902191
"v2/about/resources/livepeer-glossary",
2191-
"v2/about/resources/blockchain-contracts",
21922192
"v2/about/resources/technical-roadmap"
21932193
]
21942194
}
@@ -3505,6 +3505,7 @@
35053505
"pages": [
35063506
"v2/es/about/livepeer-protocol/overview",
35073507
"v2/es/about/livepeer-protocol/core-mechanisms",
3508+
"v2/es/about/resources/blockchain-contracts",
35083509
"v2/es/about/livepeer-protocol/livepeer-token",
35093510
"v2/es/about/livepeer-protocol/governance-model",
35103511
"v2/es/about/livepeer-protocol/treasury",
@@ -3530,7 +3531,6 @@
35303531
"pages": [
35313532
"v2/es/about/resources/livepeer-whitepaper",
35323533
"v2/es/about/resources/livepeer-glossary",
3533-
"v2/es/about/resources/blockchain-contracts",
35343534
"v2/es/about/resources/technical-roadmap"
35353535
]
35363536
}
@@ -3567,6 +3567,7 @@
35673567
"pages": [
35683568
"v2/fr/about/livepeer-protocol/overview",
35693569
"v2/fr/about/livepeer-protocol/core-mechanisms",
3570+
"v2/fr/about/resources/blockchain-contracts",
35703571
"v2/fr/about/livepeer-protocol/livepeer-token",
35713572
"v2/fr/about/livepeer-protocol/governance-model",
35723573
"v2/fr/about/livepeer-protocol/treasury",
@@ -3592,7 +3593,6 @@
35923593
"pages": [
35933594
"v2/fr/about/resources/livepeer-whitepaper",
35943595
"v2/fr/about/resources/livepeer-glossary",
3595-
"v2/fr/about/resources/blockchain-contracts",
35963596
"v2/fr/about/resources/technical-roadmap"
35973597
]
35983598
}
@@ -3629,6 +3629,7 @@
36293629
"pages": [
36303630
"v2/cn/about/livepeer-protocol/overview",
36313631
"v2/cn/about/livepeer-protocol/core-mechanisms",
3632+
"v2/cn/about/resources/blockchain-contracts",
36323633
"v2/cn/about/livepeer-protocol/livepeer-token",
36333634
"v2/cn/about/livepeer-protocol/governance-model",
36343635
"v2/cn/about/livepeer-protocol/treasury",
@@ -3654,7 +3655,6 @@
36543655
"pages": [
36553656
"v2/cn/about/resources/livepeer-whitepaper",
36563657
"v2/cn/about/resources/livepeer-glossary",
3657-
"v2/cn/about/resources/blockchain-contracts",
36583658
"v2/cn/about/resources/technical-roadmap"
36593659
]
36603660
}
Lines changed: 9 additions & 0 deletions
Loading
71.5 KB
Loading
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
/**
2+
* @component ValueResponseField
3+
* @type displays
4+
* @subniche response-fields
5+
* @status stable
6+
* @description API response field with name, type, and value display.
7+
* @accepts children, className, style, ...props
8+
* @aiDiscoverability none
9+
* @param {React.ReactNode} description - Primary content rendered by the component.
10+
* @param {string} [post=null] - Post used by the component.
11+
* @param {string} [label="value"] - Label text rendered by the component.
12+
* @param {boolean} [line=true] - Boolean flag that controls component behaviour.
13+
* @param {React.ReactNode} children - Content rendered inside the component.
14+
* @param {object} [props] - Additional props forwarded to ResponseField.
15+
* @param {string} [className=""] - CSS class name.
16+
* @param {object} [style={}] - Inline style overrides.
17+
*/
18+
const ValueResponseField = ({
19+
description,
20+
post = null,
21+
label = "value",
22+
line = true,
23+
children,
24+
className = "",
25+
style = {},
26+
...props
27+
}) => {
28+
const hasDescription =
29+
typeof description === "function" || description != null || children != null;
30+
31+
if (!hasDescription) {
32+
console.warn("[ValueResponseField] Missing required prop: description");
33+
return null;
34+
}
35+
36+
const value = post
37+
? [
38+
<span>
39+
<span style={{ color: "gray" }}>{label}: </span>
40+
<span style={{ color: "var(--lp-color-response-field-value)" }}>{post[0]}</span>
41+
</span>,
42+
]
43+
: null;
44+
45+
return (
46+
<div className={[!line ? "vrf-noline" : "", className].filter(Boolean).join(" ") || undefined} style={style}>
47+
<style>{`
48+
.vrf-noline > .field {
49+
border-bottom: none;
50+
margin-bottom: -0.5rem;
51+
padding: 0;
52+
}
53+
`}</style>
54+
<ResponseField {...props} post={value}>
55+
{typeof description === "function" ? description() : description}
56+
{children}
57+
</ResponseField>
58+
</div>
59+
);
60+
};
61+
62+
const expandableCode = () => {
63+
return (
64+
<Expandable title="Required Flags">
65+
<ResponseField name="flag" type="type" default="hi">
66+
Description
67+
</ResponseField>
68+
</Expandable>
69+
);
70+
};
71+
72+
/**
73+
* @component CustomResponseField
74+
* @type displays
75+
* @subniche response-fields
76+
* @status stable
77+
* @description Custom-styled API response field with configurable margin.
78+
* @accepts className, style, ...props
79+
* @aiDiscoverability none
80+
* @param {React.ReactNode} description - Primary content rendered by the component.
81+
* @param {object} [props] - Additional props forwarded to ResponseField.
82+
* @param {string} [className=""] - CSS class name.
83+
* @param {object} [style={}] - Inline style overrides.
84+
*/
85+
const CustomResponseField = ({ description, className = "", style = {}, ...props }) => {
86+
const uniqueId = `custom-rf-${Math.random().toString(36).substring(2, 11)}`;
87+
88+
return (
89+
<div className={[uniqueId, className].filter(Boolean).join(" ")} style={style}>
90+
<style>{`
91+
.${uniqueId} > .field {
92+
border-bottom: none;
93+
margin-bottom: -20px;
94+
}
95+
`}</style>
96+
<ResponseField {...props}>{description}</ResponseField>
97+
</div>
98+
);
99+
};
100+
101+
/**
102+
* @component ResponseFieldExpandable
103+
* @type displays
104+
* @subniche response-fields
105+
* @status stable
106+
* @description Expandable response field that reveals nested content on click.
107+
* @accepts className, style, ...props
108+
* @aiDiscoverability none
109+
* @param {object} [fields={}] - Fields used by the component.
110+
* @param {object} [props] - Additional props forwarded to Expandable.
111+
* @param {string} [className=""] - CSS class name.
112+
* @param {object} [style={}] - Inline style overrides.
113+
*/
114+
const ResponseFieldExpandable = ({ fields = {}, className = "", style = {}, ...props }) => {
115+
const fieldsArray = Array.isArray(fields) ? fields : Object.values(fields);
116+
if (fieldsArray.length === 0) {
117+
return null;
118+
}
119+
120+
return (
121+
<Expandable className={className} style={style} {...props}>
122+
{fieldsArray.map((field, index) => (
123+
<ValueResponseField key={index} {...field} />
124+
))}
125+
</Expandable>
126+
);
127+
};
128+
129+
/**
130+
* @component ResponseFieldAccordion
131+
* @type displays
132+
* @subniche response-fields
133+
* @status stable
134+
* @description Accordion-style response field with collapsible detail section.
135+
* @accepts className, style, ...props
136+
* @aiDiscoverability none
137+
* @param {object} [fields={}] - Fields used by the component.
138+
* @param {object} [props] - Additional props forwarded to Accordion.
139+
* @param {string} [className=""] - CSS class name.
140+
* @param {object} [style={}] - Inline style overrides.
141+
*/
142+
const ResponseFieldAccordion = ({ fields = {}, className = "", style = {}, ...props }) => {
143+
const fieldsArray = Array.isArray(fields) ? fields : Object.values(fields);
144+
if (fieldsArray.length === 0) {
145+
console.warn("[ResponseFieldAccordion] Missing or invalid fields");
146+
return null;
147+
}
148+
149+
return (
150+
<Accordion className={className} style={style} {...props}>
151+
{fieldsArray.map((field, index) => (
152+
<ValueResponseField key={index} {...field} />
153+
))}
154+
</Accordion>
155+
);
156+
};
157+
158+
// Wrapper that chooses accordion or expandable layout at runtime.
159+
/**
160+
* @component ResponseFieldGroup
161+
* @type displays
162+
* @subniche response-fields
163+
* @status stable
164+
* @description Container for grouping multiple response fields with consistent spacing.
165+
* @accepts className, style, ...props
166+
* @aiDiscoverability none
167+
* @param {string} [component="accordion"] - Component used by the component.
168+
* @param {object} [fields={}] - Fields used by the component.
169+
* @param {object} [props] - Additional props forwarded to the selected wrapper component.
170+
* @param {string} [className=""] - CSS class name.
171+
* @param {object} [style={}] - Inline style overrides.
172+
*/
173+
const ResponseFieldGroup = ({
174+
component = "accordion",
175+
fields = {},
176+
className = "",
177+
style = {},
178+
...props
179+
}) => {
180+
const fieldsArray = Array.isArray(fields) ? fields : Object.values(fields);
181+
if (fieldsArray.length === 0) {
182+
console.warn("[ResponseFieldGroup] Missing or invalid fields");
183+
return null;
184+
}
185+
186+
const componentMap = {
187+
expandable: Expandable,
188+
accordion: Accordion,
189+
};
190+
const Component = componentMap[component] || Accordion;
191+
return (
192+
<Component className={className} style={style} {...props}>
193+
{fieldsArray.map((field, index) => (
194+
<ValueResponseField key={index} {...field} />
195+
))}
196+
</Component>
197+
);
198+
};
199+
200+
/**
201+
* @component FunctionField
202+
* @type displays
203+
* @subniche response-fields
204+
* @status stable
205+
* @description Solidity function signature field with typed parameter pairs and optional return type.
206+
* @accepts children, className, style, ...rest
207+
* @aiDiscoverability none
208+
* @param {string} name - Function name.
209+
* @param {string[]} [params=[]] - Parameter strings in "type name" format (e.g. "bytes32 _id").
210+
* @param {string} [returns] - Return type (e.g. "address", "uint256").
211+
* @param {React.ReactNode} children - Description of the function.
212+
* @param {boolean} [line=true] - Show bottom border.
213+
* @param {object} [style={}] - Inline style overrides.
214+
* @param {string} [className=""] - CSS class name.
215+
*/
216+
const FunctionField = ({
217+
name,
218+
params = [],
219+
returns,
220+
children,
221+
line = true,
222+
style = {},
223+
className = '',
224+
...rest
225+
}) => {
226+
const paramsFormatted = params.length > 0
227+
? params.map(p => {
228+
const parts = p.split(/\s+/)
229+
const type = parts[0]
230+
const pName = parts.slice(1).join(' ')
231+
return pName ? `${pName}: ${type}` : type
232+
}).join(', ')
233+
: ''
234+
235+
const returnType = returns ? `returns: ${returns}` : 'returns: void'
236+
237+
const post = params.length > 0
238+
? [
239+
<span>
240+
<span style={{ color: "white" }}>params: </span>
241+
<span style={{ color: "var(--lp-color-arbitrum, #3ea6f8)" }}>({paramsFormatted})</span>
242+
</span>,
243+
]
244+
: null
245+
246+
return (
247+
<div className={className} style={style} {...rest}>
248+
<ResponseField name={name} type={returnType} post={post}>
249+
{children}
250+
</ResponseField>
251+
</div>
252+
)
253+
}
254+
255+
export {
256+
ValueResponseField,
257+
CustomResponseField,
258+
ResponseFieldExpandable,
259+
ResponseFieldAccordion,
260+
ResponseFieldGroup,
261+
FunctionField,
262+
};

0 commit comments

Comments
 (0)