Skip to content

Commit 18c57aa

Browse files
committed
pre-commit
1 parent 01d5a32 commit 18c57aa

File tree

5 files changed

+78
-74
lines changed

5 files changed

+78
-74
lines changed

components/LazerPriceIdTable.tsx

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { useEffect, useState } from "react";
22
import { StyledTd } from "./Table";
33

4-
5-
64
const fetchLazerPriceIdMetadata = async () => {
7-
const response = await fetch("https://pyth-lazer-staging.dourolabs.app/history/v1/symbols");
8-
const data = await response.json();
9-
return data;
10-
}
5+
const response = await fetch(
6+
"https://pyth-lazer-staging.dourolabs.app/history/v1/symbols"
7+
);
8+
const data = await response.json();
9+
return data;
10+
};
1111

1212
type LazerPriceIdMetadata = {
13-
asset_type: string;
14-
description: string;
15-
exponent: number;
16-
name: string;
17-
pyth_lazer_id: number;
18-
symbol: string;
19-
}
13+
asset_type: string;
14+
description: string;
15+
exponent: number;
16+
name: string;
17+
pyth_lazer_id: number;
18+
symbol: string;
19+
};
2020

2121
enum LazerPriceIdStateType {
2222
NotLoaded,
@@ -26,68 +26,73 @@ enum LazerPriceIdStateType {
2626
}
2727

2828
const LazerPriceIdState = {
29-
NotLoaded: () => ({ type: LazerPriceIdStateType.NotLoaded as const }),
30-
Loading: () => ({ type: LazerPriceIdStateType.Loading as const }),
31-
Loaded: (priceFeeds: LazerPriceIdMetadata[]) => ({
32-
type: LazerPriceIdStateType.Loaded as const,
33-
priceFeeds,
34-
}),
35-
Error: (error: unknown) => ({
29+
NotLoaded: () => ({ type: LazerPriceIdStateType.NotLoaded as const }),
30+
Loading: () => ({ type: LazerPriceIdStateType.Loading as const }),
31+
Loaded: (priceFeeds: LazerPriceIdMetadata[]) => ({
32+
type: LazerPriceIdStateType.Loaded as const,
33+
priceFeeds,
34+
}),
35+
Error: (error: unknown) => ({
3636
type: LazerPriceIdStateType.Error as const,
3737
error,
3838
}),
3939
};
4040

41-
type LazerPriceIdState = ReturnType<typeof LazerPriceIdState[keyof typeof LazerPriceIdState]>;
41+
type LazerPriceIdState = ReturnType<
42+
typeof LazerPriceIdState[keyof typeof LazerPriceIdState]
43+
>;
4244

4345
const useLazerPriceIdState = () => {
44-
const [state, setState] = useState<LazerPriceIdState>(LazerPriceIdState.NotLoaded());
46+
const [state, setState] = useState<LazerPriceIdState>(
47+
LazerPriceIdState.NotLoaded()
48+
);
4549

46-
useEffect(() => {
47-
setState(LazerPriceIdState.Loading());
48-
fetchLazerPriceIdMetadata().then(priceFeeds => setState(LazerPriceIdState.Loaded(priceFeeds)))
49-
.catch(error => setState(LazerPriceIdState.Error(error)));
50-
}, []);
50+
useEffect(() => {
51+
setState(LazerPriceIdState.Loading());
52+
fetchLazerPriceIdMetadata()
53+
.then((priceFeeds) => setState(LazerPriceIdState.Loaded(priceFeeds)))
54+
.catch((error) => setState(LazerPriceIdState.Error(error)));
55+
}, []);
5156

52-
return state;
53-
}
57+
return state;
58+
};
5459

5560
export function LazerPriceIdTable() {
56-
const lazerPriceIdState = useLazerPriceIdState();
61+
const lazerPriceIdState = useLazerPriceIdState();
5762

58-
switch (lazerPriceIdState.type) {
59-
case LazerPriceIdStateType.NotLoaded:
60-
return <div>Loading...</div>;
61-
case LazerPriceIdStateType.Loading:
62-
return <div>Loading...</div>;
63-
case LazerPriceIdStateType.Loaded:
64-
return (
65-
<table>
66-
<thead>
67-
<tr>
68-
<th>Asset Type</th>
69-
<th>Description</th>
70-
<th>Name</th>
71-
<th>Symbol</th>
72-
<th>Pyth Lazer Id</th>
73-
<th>Exponent</th>
74-
</tr>
75-
</thead>
76-
<tbody>
77-
{lazerPriceIdState.priceFeeds.map(priceFeed => (
78-
<tr key={priceFeed.symbol}>
79-
<StyledTd>{priceFeed.asset_type}</StyledTd>
80-
<StyledTd>{priceFeed.description}</StyledTd>
81-
<StyledTd>{priceFeed.name}</StyledTd>
82-
<StyledTd>{priceFeed.symbol}</StyledTd>
83-
<StyledTd>{priceFeed.pyth_lazer_id}</StyledTd>
84-
<StyledTd>{priceFeed.exponent}</StyledTd>
85-
</tr>
86-
))}
87-
</tbody>
88-
</table>
89-
)
90-
case LazerPriceIdStateType.Error:
91-
return <div>Error</div>;
92-
}
93-
}
63+
switch (lazerPriceIdState.type) {
64+
case LazerPriceIdStateType.NotLoaded:
65+
return <div>Loading...</div>;
66+
case LazerPriceIdStateType.Loading:
67+
return <div>Loading...</div>;
68+
case LazerPriceIdStateType.Loaded:
69+
return (
70+
<table>
71+
<thead>
72+
<tr>
73+
<th>Asset Type</th>
74+
<th>Description</th>
75+
<th>Name</th>
76+
<th>Symbol</th>
77+
<th>Pyth Lazer Id</th>
78+
<th>Exponent</th>
79+
</tr>
80+
</thead>
81+
<tbody>
82+
{lazerPriceIdState.priceFeeds.map((priceFeed) => (
83+
<tr key={priceFeed.symbol}>
84+
<StyledTd>{priceFeed.asset_type}</StyledTd>
85+
<StyledTd>{priceFeed.description}</StyledTd>
86+
<StyledTd>{priceFeed.name}</StyledTd>
87+
<StyledTd>{priceFeed.symbol}</StyledTd>
88+
<StyledTd>{priceFeed.pyth_lazer_id}</StyledTd>
89+
<StyledTd>{priceFeed.exponent}</StyledTd>
90+
</tr>
91+
))}
92+
</tbody>
93+
</table>
94+
);
95+
case LazerPriceIdStateType.Error:
96+
return <div>Error</div>;
97+
}
98+
}

pages/express-relay/_meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"type": "separator"
1616
},
1717

18-
"integrate-as-consumer": "Integrate as a Consumer",
19-
"integrate-as-publisher": "Integrate as a Publisher",
18+
"integrate-as-protocol": "Integrate as a Protocol",
19+
"integrate-as-searcher": "Integrate as a Searcher",
2020

2121
"-- Reference Material": {
2222
"title": "Reference Material",

pages/lazer/_meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"href": "TODO:",
3131
"newWindow": true
3232
},
33-
33+
3434
"websocket-api-reference": "Websocket API Reference",
3535
"contract-addresses": "Contract Addresses",
36-
36+
3737
"errors": "Error Codes",
3838
"examples": {
3939
"title": "Example Application ↗",

pages/lazer/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Lazer
22

3-
TODO: Fill this up.
3+
TODO: Fill this up.
44

5-
6-
TODO: Add a banner up to get a access token.
5+
TODO: Add a banner up to get a access token.

pages/lazer/price-feeds.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LazerPriceIdTable} from "../../components/LazerPriceIdTable";
1+
import { LazerPriceIdTable } from "../../components/LazerPriceIdTable";
22

33
# Lazer Price Feeds
44

0 commit comments

Comments
 (0)