mirror of
https://github.com/Instadapp/boardroom-inc-protocol-Info.git
synced 2024-07-29 22:37:02 +00:00
fix: write token and abit
This commit is contained in:
parent
6f2dd66c31
commit
c7740624dd
File diff suppressed because one or more lines are too long
|
@ -24,12 +24,12 @@ do
|
|||
touch ./protocols/$arg/header.png
|
||||
|
||||
echo '{
|
||||
"cname": "",
|
||||
"name": "",
|
||||
"cname": "'"$arg"'",
|
||||
"name": "'"$arg"'",
|
||||
"description": "",
|
||||
"path": "",
|
||||
"previousPaths": [],
|
||||
"folder": "",
|
||||
"folder": "'"$arg"'",
|
||||
"type": "snapshot",
|
||||
"suffix": "",
|
||||
"coinGeckoPriceString": "",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { exec } from "child_process";
|
||||
import axios from "axios";
|
||||
import fs from "fs";
|
||||
|
||||
|
@ -55,12 +56,16 @@ function extractTokenAddress(space: Space): string | null {
|
|||
}
|
||||
}
|
||||
|
||||
async function extractTokenAbi(tokenAddress: string) {
|
||||
const data = await axios.get(
|
||||
async function extractTokenAbi(tokenAddress: string | null) {
|
||||
if (!tokenAddress) {
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await axios.get(
|
||||
`https://api.etherscan.io/api?module=contract&action=getabi&address=${tokenAddress}&apikey=${process.env.ETHERSCAN_API_TOKEN}`,
|
||||
);
|
||||
|
||||
console.log(data);
|
||||
return res.data.result;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
|
@ -74,13 +79,26 @@ async function run() {
|
|||
|
||||
fs.writeFileSync("./allprotocols.json", JSON.stringify(withMembers));
|
||||
|
||||
for (let i = 0; i < Object.keys(withMembers).length; i++) {
|
||||
// for (let i = 0; i < Object.keys(withMembers).length; i++) {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const key = Object.keys(withMembers)[i];
|
||||
|
||||
const tokenAddress = extractTokenAddress(withMembers[key]);
|
||||
const tokenAbi = extractTokenAbi(tokenAddress);
|
||||
|
||||
console.log(tokenAddress);
|
||||
const myShellScript = exec(`sh ./scripts/add_new_protocol.sh ${key}`, (error, stdout, stderr) => {
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
|
||||
if (error !== null) {
|
||||
console.log(`exec error: ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(myShellScript);
|
||||
|
||||
const tokenAbi = await extractTokenAbi(tokenAddress);
|
||||
|
||||
fs.writeFileSync(`./protocols/${key}/contracts/token.json`, JSON.stringify(tokenAbi));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user