-
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.
Co-authored-by: Cy <[email protected]> Co-authored-by: Chloe <[email protected]> Co-authored-by: Trisha Reddy <[email protected]> Co-authored-by: rebekah-wang <[email protected]> Co-authored-by: anusha <[email protected]>
- Loading branch information
1 parent
abb4c69
commit 3cf7db9
Showing
12 changed files
with
489 additions
and
70 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 |
---|---|---|
@@ -1 +1,80 @@ | ||
// TODO | ||
import { base, showError } from "./util.js"; | ||
|
||
async function createABI(name, abi) { | ||
let object = { | ||
name: name, | ||
abi: abi, | ||
}; | ||
|
||
let res = await fetch(base + `/api/abi`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(object), | ||
}); | ||
|
||
if (res.status >= 400) { | ||
if (showError) { | ||
console.log(res); | ||
} | ||
} | ||
|
||
let data = await res.json(); | ||
|
||
let abi = await data["abi"]; | ||
|
||
return abi; | ||
} | ||
|
||
async function getABI(id) { | ||
let res = await fetch(base + `/api/abi/` + id); | ||
|
||
if (res.status >= 400) { | ||
if (showError) { | ||
console.log(res); | ||
} | ||
return null; | ||
} | ||
|
||
let object = await res.json(); | ||
let abis = await object["abis"]; | ||
return abis[0]; | ||
} | ||
|
||
async function updateABI(id, name, abi) { | ||
let obj = { | ||
name: name, | ||
abi: abi, | ||
}; | ||
|
||
let res = await fetch(base + `/api/abi/` + id, { | ||
method: "PUT", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(obj), | ||
}); | ||
|
||
if (res.status == 400) { | ||
alert("You must change your name or abi!"); | ||
} | ||
|
||
let data = await res.json(); | ||
let retABI = await data["abi"]; | ||
return retABI; | ||
} | ||
|
||
async function deleteABI(id) { | ||
let res = await fetch(base + `/api/abi/` + id, { | ||
method: "DELETE", | ||
}); | ||
|
||
if (res.status == 400) { | ||
alert("You must change your name or abi!"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
export { createABI, getABI, updateABI, deleteABI }; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.