-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from OilerNetwork/ui-enhancements
UI enhancements
- Loading branch information
Showing
4 changed files
with
91 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"use server"; | ||
|
||
import { NextResponse } from "next/server"; | ||
import { createJobRequest } from "@/lib/utils"; | ||
import { FossilParams } from "@/lib/types"; | ||
|
||
export async function POST(request: Request) { | ||
// Parse the request body | ||
const body = await request.json(); | ||
const params: FossilParams = body; | ||
|
||
const { targetTimestamp, roundDuration, clientAddress, vaultAddress } = | ||
params; | ||
|
||
if (!targetTimestamp || !roundDuration || !clientAddress || !vaultAddress) { | ||
return NextResponse.json( | ||
{ | ||
error: | ||
"Missing targetTimestamp, roundDuration, clientAddress, or vaultAddress parameter", | ||
}, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
// Create request | ||
let fossilRequest = createJobRequest({ | ||
targetTimestamp, | ||
roundDuration, | ||
clientAddress, | ||
vaultAddress, | ||
}); | ||
|
||
// Set API key (kept secret on the server side) | ||
fossilRequest.headers["x-api-key"] = process.env.FOSSIL_API_KEY; | ||
|
||
// Send Fossil request | ||
try { | ||
const resp = await fetch( | ||
`${process.env.NEXT_PUBLIC_FOSSIL_API_URL}/pricing_data`, | ||
fossilRequest, | ||
); | ||
|
||
console.log("RAW", resp); | ||
|
||
if (!resp.ok) { | ||
console.error("Fossil request failed:", resp.statusText); | ||
// Return error response to the client | ||
return NextResponse.json( | ||
{ error: "Fossil request failed: " + resp.statusText }, | ||
{ status: resp.status }, | ||
); | ||
} | ||
|
||
const data = await resp.json(); | ||
// Return the data to the client | ||
return NextResponse.json(data); | ||
} catch (error: any) { | ||
console.error("Error sending Fossil request:", error); | ||
// Return error response to the client | ||
return NextResponse.json( | ||
{ error: "Error sending Fossil request: " + error.message }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters