refactor flashstake

This commit is contained in:
g1nt0ki
2023-01-10 19:48:28 +01:00
parent cdf0ad920a
commit 66d20b0185
5 changed files with 65 additions and 535 deletions

View File

@@ -59,7 +59,7 @@ function transform(obj, file) {
for (const [key, value] of Object.entries(obj)) {
if (!value.inputs) console.log('inputs missing', file)
const iLen = value.inputs.length === 0
const oLen = value.outputs.length === 1
const oLen = value.outputs?.length === 1
const oType = oLen && value.outputs[0].type
if (iLen && oLen && knownTypes.has(oType)) {
res[key] = `${oType}:${value.name}`
@@ -77,7 +77,7 @@ function print() {
if (Array.isArray(data)) {
res = {}
data
.filter(i => i.type === 'function')
.filter(i => i.type === 'function' || i.type === 'event')
// .filter(i => isTransformable({ test: i}))
// .filter(i => i.stateMutability === 'view' || i.stateMutability === 'pure')
.forEach(i => res[i.name ?? 'ignore'] = i)
@@ -89,86 +89,7 @@ function print() {
}
const data = {
"get_registry": {
"name": "get_registry",
"outputs": [
{
"type": "address",
"name": ""
}
],
"inputs": [],
"stateMutability": "view",
"type": "function",
"gas": 1061
},
"pool_list": {
"stateMutability": "view",
"type": "function",
"name": "pool_list",
"inputs": [
{
"name": "arg0",
"type": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address"
}
],
"gas": 2217
},
"pool_count": {
"stateMutability": "view",
"type": "function",
"name": "pool_count",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"gas": 2138
},
"get_id_info": {
"name": "get_id_info",
"outputs": [
{
"type": "address",
"name": "addr"
},
{
"type": "bool",
"name": "is_active"
},
{
"type": "uint256",
"name": "version"
},
{
"type": "uint256",
"name": "last_modified"
},
{
"type": "string",
"name": "description"
}
],
"inputs": [
{
"type": "uint256",
"name": "arg0"
}
],
"stateMutability": "view",
"type": "function",
"gas": 12168
},
}
const data =
print()