-
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 #11 from OriumNetwork/feature--ON-509-update
ON-509: add mustache for subgraph manifest generation
- Loading branch information
Showing
9 changed files
with
185 additions
and
171 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,10 @@ | ||
{ | ||
"network": "goerli", | ||
"erc721": [ | ||
{ | ||
"name": "ChronosTraveler", | ||
"address": "0x450c91d1fe9f3d57b91218f6ff96f7994eec4d32", | ||
"startBlock": 8099655 | ||
} | ||
] | ||
} |
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,22 @@ | ||
{ | ||
"network": "mumbai", | ||
"erc721": [ | ||
{ | ||
"name": "AavegotchiGotchi", | ||
"address": "0x83e73D9CF22dFc3A767EA1cE0611F7f50306622e", | ||
"startBlock": 34467860 | ||
}, | ||
{ | ||
"name": "AavegotchiParcel", | ||
"address": "0xBcCf68d104aCEa36b1EA20BBE8f06ceD12CaC008", | ||
"startBlock": 38134604 | ||
} | ||
], | ||
"erc1155": [ | ||
{ | ||
"name": "AavegotchiWearable", | ||
"address": "0x1b1bcB49A744a09aEd636CDD9893508BdF1431A8", | ||
"startBlock": 34467877 | ||
} | ||
] | ||
} |
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,27 @@ | ||
{ | ||
"network": "matic", | ||
"erc721": [ | ||
{ | ||
"name": "AavegotchiGotchi", | ||
"address": "0x86935f11c86623dec8a25696e1c19a8659cbf95d", | ||
"startBlock": 11516320 | ||
}, | ||
{ | ||
"name": "AavegotchiParcel", | ||
"address": "0x1D0360BaC7299C86Ec8E99d0c1C9A95FEfaF2a11", | ||
"startBlock": 20667840 | ||
}, | ||
{ | ||
"name": "ChronosTravaler", | ||
"address": "0xa03c4e40d1fcaa826591007a17ca929ef8adbf1c", | ||
"startBlock": 36796276 | ||
} | ||
], | ||
"erc1155": [ | ||
{ | ||
"name": "AavegotchiWearable", | ||
"address": "0x58de9aabcaeec0f69883c94318810ad79cc6a44f", | ||
"startBlock": 35999793 | ||
} | ||
] | ||
} |
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,60 @@ | ||
const Mustache = require('mustache') | ||
const fs = require('fs') | ||
|
||
// receive network name as argument | ||
async function main(args) { | ||
const networkName = getNetworkName(args) | ||
const networkData = require(`./config/${networkName}.json`) | ||
const template = fs.readFileSync('./subgraph.template.yaml', 'utf8') | ||
const parsedData = putFirstElementFlag(networkData) | ||
const output = Mustache.render(template, parsedData) | ||
writeOutput(output) | ||
} | ||
|
||
function getNetworkName(args) { | ||
if (args.length < 3) { | ||
throw new Error('Missing network name argument') | ||
} | ||
return args[2] | ||
} | ||
|
||
function writeOutput(output) { | ||
fs.writeFileSync('./subgraph.yaml', output) | ||
} | ||
|
||
function putFirstElementFlag(data) { | ||
const dataWithFirstElementFlag = replaceFirstElementFlag(data) | ||
return arrayToObj(dataWithFirstElementFlag) | ||
} | ||
function replaceFirstElementFlag(data) { | ||
return Object.keys(data).map((key, index) => { | ||
if (Array.isArray(data[key]) && data[key].length > 0) { | ||
return { | ||
[key]: data[key].map((item, index) => { | ||
if (index === 0) { | ||
return { ...item, isFirstElement: true } | ||
} else { | ||
return item | ||
} | ||
}), | ||
} | ||
} | ||
return { [key]: data[key] } | ||
}) | ||
} | ||
|
||
function arrayToObj(data) { | ||
return data.reduce((acc, curr) => { | ||
return { ...acc, ...curr } | ||
}, {}) | ||
} | ||
|
||
main(process.argv) | ||
.then(() => { | ||
console.log('Done') | ||
process.exit() | ||
}) | ||
.catch(err => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.