fix: dont overwrite if already claimed

This commit is contained in:
yj 2021-04-27 20:40:32 -05:00
parent e74a42a431
commit aa605fb796
10 changed files with 43 additions and 73 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,32 +1,26 @@
{ {
"cname": "rally", "cname": "rally",
"name": "Rally", "name": "Rally",
"description": "", "description": "Rally is a decentralized network enabling creators to monetize and align themselves with their community.",
"path": "rally", "path": "rallygov.eth",
"previousPaths": [], "previousPaths": ["rally"],
"folder": "rally", "folder": "rally",
"type": "snapshot", "type": "snapshot",
"suffix": "RLY", "suffix": "RLY",
"coinGeckoPriceString": "", "coinGeckoPriceString": "rally-2",
"tokenContractAddress": "null", "tokenContractAddress": "0xf1f955016EcbCd7321c7266BccFB96c68ea5E49b",
"isEnabled": false, "isEnabled": true,
"hasOnchain": false,
"claim": { "claim": {
"isClaimed": false, "isClaimed": true,
"claimer": "", "claimer": "",
"signature": "" "signature": ""
}, },
"isHybrid": false, "hasOnchain": false,
"hasDelegation": false, "isHybrid": false,
"snapshotSpaceName": "rally", "hasDelegation": false,
"invalidSnapshots": [], "snapshotSpaceName": "rallygov.eth",
"branding": { "invalidSnapshots": [],
"primaryColor": "", "branding": {},
"accentColor": "" "discourseForum": {},
}, "safeAddress": null
"discourseForum": {
"url": "",
"categoryId": ""
},
"safeAddress": null
} }

View File

@ -1,32 +0,0 @@
{
"cname": "rallygov.eth",
"name": "Rally",
"description": "",
"path": "rallygov.eth",
"previousPaths": [],
"folder": "rallygov.eth",
"type": "snapshot",
"suffix": "RLY",
"coinGeckoPriceString": "",
"tokenContractAddress": "null",
"isEnabled": false,
"hasOnchain": false,
"claim": {
"isClaimed": false,
"claimer": "",
"signature": ""
},
"isHybrid": false,
"hasDelegation": false,
"snapshotSpaceName": "rallygov.eth",
"invalidSnapshots": [],
"branding": {
"primaryColor": "",
"accentColor": ""
},
"discourseForum": {
"url": "",
"categoryId": ""
},
"safeAddress": null
}

View File

@ -125,19 +125,27 @@ async function createSkeletons(spaces: Record<string, any>) {
const suffix = spaces[key].symbol; const suffix = spaces[key].symbol;
const name = spaces[key].name; const name = spaces[key].name;
exec(`sh ./scripts/add_new_protocol.sh ${key} ${tokenAddress} ${suffix} ${name}`, (error, stdout, stderr) => { const file = fs.readFileSync(`./protocols/${key}/index.json`);
if (error !== null) {
console.log(`exec error: ${error}`); const fileAsJson: any = JSON.parse(file.toString());
if (!fileAsJson.claim?.isClaimed) {
exec(`sh ./scripts/add_new_protocol.sh ${key} ${tokenAddress} ${suffix} ${name}`, (error, stdout, stderr) => {
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
if (tokenAddress) {
const tokenAbi = await extractTokenAbi(tokenAddress);
fs.writeFileSync(`./protocols/${key}/contracts/token.json`, JSON.stringify(tokenAbi));
} }
});
if (tokenAddress) { await delay(1000); // workaround for Etherscan api request limit
const tokenAbi = await extractTokenAbi(tokenAddress); } else {
console.log("Already claimed!");
fs.writeFileSync(`./protocols/${key}/contracts/token.json`, JSON.stringify(tokenAbi));
} }
await delay(1000); // workaround for Etherscan api request limit
} }
} }