Skip to content

Commit f092ac3

Browse files
committed
refactor: improve code formatting and readability in PythCore, PythLazer, and PythContext components
1 parent 3fc5914 commit f092ac3

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

governance/xc_admin/packages/xc_admin_frontend/components/programs/PythCore.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,10 @@ const PythCore: React.FC<PythCoreProps> = ({ proposerServerUrl }) => {
399399

400400
useEffect(() => {
401401
if (!dataIsLoading && rawConfig) {
402-
const downloadableConfig = getDownloadableConfig(rawConfig) as Record<string, DownloadableProduct>
402+
const downloadableConfig = getDownloadableConfig(rawConfig) as Record<
403+
string,
404+
DownloadableProduct
405+
>
403406
setData(downloadableConfig)
404407
}
405408
}, [rawConfig, dataIsLoading, cluster])

governance/xc_admin/packages/xc_admin_frontend/components/programs/PythLazer.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ interface PythLazerProps {
1515
}
1616

1717
interface ModalContentProps {
18-
changes: Record<string, {
19-
prev?: Partial<LazerState>;
20-
new?: Partial<LazerState>;
21-
}>,
22-
onSendProposal: () => void,
18+
changes: Record<
19+
string,
20+
{
21+
prev?: Partial<LazerState>
22+
new?: Partial<LazerState>
23+
}
24+
>
25+
onSendProposal: () => void
2326
isSendProposalButtonLoading: boolean
2427
}
2528

2629
const ModalContent: React.FC<ModalContentProps> = ({
2730
changes,
2831
onSendProposal,
29-
isSendProposalButtonLoading
32+
isSendProposalButtonLoading,
3033
}) => {
3134
return (
3235
<>
@@ -35,7 +38,10 @@ const ModalContent: React.FC<ModalContentProps> = ({
3538
<tbody>
3639
{Object.entries(changes).map(([key, change]) => (
3740
<tr key={key}>
38-
<td className="base16 py-4 pl-6 pr-2 font-bold lg:pl-6" colSpan={2}>
41+
<td
42+
className="base16 py-4 pl-6 pr-2 font-bold lg:pl-6"
43+
colSpan={2}
44+
>
3945
{key}
4046
</td>
4147
<td className="py-3 pl-6 pr-1 lg:pl-6">
@@ -64,14 +70,18 @@ const ModalContent: React.FC<ModalContentProps> = ({
6470
}
6571

6672
const PythLazer = ({
67-
proposerServerUrl: _proposerServerUrl
73+
proposerServerUrl: _proposerServerUrl,
6874
}: PythLazerProps) => {
6975
const { dataIsLoading, lazerState } = usePythContext()
7076
const { cluster } = useContext(ClusterContext)
7177

72-
const [dataChanges, setDataChanges] = useState<Record<string, { prev?: Partial<LazerState>; new?: Partial<LazerState> }>>()
78+
const [dataChanges, setDataChanges] =
79+
useState<
80+
Record<string, { prev?: Partial<LazerState>; new?: Partial<LazerState> }>
81+
>()
7382
const [isModalOpen, setIsModalOpen] = useState(false)
74-
const [isSendProposalButtonLoading, setIsSendProposalButtonLoading] = useState(false)
83+
const [isSendProposalButtonLoading, setIsSendProposalButtonLoading] =
84+
useState(false)
7585

7686
const openModal = () => {
7787
setIsModalOpen(true)
@@ -84,7 +94,9 @@ const PythLazer = ({
8494
const handleDownloadJsonButtonClick = () => {
8595
if (!lazerState) return
8696

87-
const dataStr = 'data:text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(lazerState, null, 2))
97+
const dataStr =
98+
'data:text/json;charset=utf-8,' +
99+
encodeURIComponent(JSON.stringify(lazerState, null, 2))
88100
const downloadAnchor = document.createElement('a')
89101
downloadAnchor.setAttribute('href', dataStr)
90102
downloadAnchor.setAttribute('download', `lazer_config_${cluster}.json`)
@@ -142,7 +154,7 @@ const PythLazer = ({
142154
setIsSendProposalButtonLoading(true)
143155
try {
144156
// In a real implementation, this would send the proposal to the server
145-
await new Promise(resolve => setTimeout(resolve, 2000)) // Mock delay
157+
await new Promise((resolve) => setTimeout(resolve, 2000)) // Mock delay
146158

147159
// Close the modal and show success notification
148160
setIsModalOpen(false)

governance/xc_admin/packages/xc_admin_frontend/contexts/PythContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ export const PythContextProvider: React.FC<PythContextProviderProps> = ({
6464
const fetchLazerState = async () => {
6565
try {
6666
// Get the Lazer config and transform it to downloadable format
67-
const lazerConfig = getConfig[ProgramType.PYTH_LAZER]({});
67+
const lazerConfig = getConfig[ProgramType.PYTH_LAZER]({})
6868
// Since we know this is a LazerState object, we can cast it
69-
setLazerState(lazerConfig.state);
69+
setLazerState(lazerConfig.state)
7070
} catch (error) {
71-
console.error("Error fetching Lazer state:", error)
71+
console.error('Error fetching Lazer state:', error)
7272
}
7373
}
7474

0 commit comments

Comments
 (0)