Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch missing endpoints #93

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions adapters/balance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ export async function latest(
timestampDeployed: number,
): Promise<number> {
if (!res) {
let r = await fetch(`https://api.llama.fi/emission/${adapter}`).then((r) =>
r.json(),
);
let r;
try {
r = await fetch(`https://api.llama.fi/emission/${adapter}`).then((r) =>
r.json(),
);
} catch {
return timestampDeployed;
}
if (!r.body) return timestampDeployed;
r = JSON.parse(r.body);
return r.metadata.incompleteSections == null ||
Expand Down
11 changes: 8 additions & 3 deletions adapters/supply/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ let res: number;

export async function latest(key: string, reference: number): Promise<number> {
if (!res) {
let r = await fetch(`https://api.llama.fi/emission/${key}`).then((r) =>
r.json(),
);
let r;
try {
r = await fetch(`https://api.llama.fi/emission/${key}`).then((r) =>
r.json(),
);
} catch {
return reference;
}
if (!r.body) return reference;
r = JSON.parse(r.body);
return r.metadata.incompleteSections == null ||
Expand Down
11 changes: 7 additions & 4 deletions utils/convertToChartData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ async function appendMissingDataSections(
const incompleteSections = data.metadata.incompleteSections;
if (incompleteSections == null || incompleteSections.length == 0) return;

let res = await fetch(`https://api.llama.fi/emission/${protocol}`).then((r) =>
r.json(),
);
let res = [];
try {
res = await fetch(`https://api.llama.fi/emission/${protocol}`).then((r) =>
r.json(),
);
} catch {}
let body = res.body ? JSON.parse(res.body) : [];
res = body && body.length != 0 ? body.documentedData?.data ?? body.data : [];
res = body && body.length ? body.documentedData?.data ?? body.data : [];

if (nullsInApiData(res)) {
await sendMessage(
Expand Down
Loading