-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the Acre API requests to separate functions and set the Acre API endpoint via env variables.
- Loading branch information
1 parent
8b1b61c
commit bb0c208
Showing
8 changed files
with
76 additions
and
23 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
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
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,31 @@ | ||
import { env } from "#/constants" | ||
import axiosStatic from "axios" | ||
|
||
const axios = axiosStatic.create({ baseURL: env.ACRE_API_ENDPOINT }) | ||
|
||
export async function getSession() { | ||
const response = await axios.get<{ nonce: string } | { address: string }>( | ||
"session", | ||
{ | ||
withCredentials: true, | ||
}, | ||
) | ||
|
||
return response.data | ||
} | ||
|
||
export async function createSession(message: string, signature: string) { | ||
const response = await axios.post<{ success: boolean }>( | ||
"session", | ||
{ message, signature }, | ||
{ withCredentials: true }, | ||
) | ||
|
||
if (!response.data) { | ||
throw new Error("Failed to create Acre session") | ||
} | ||
} | ||
|
||
export async function deleteSession() { | ||
await axios.delete("session") | ||
} |
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