I have done some work on captioned subject. For example, I can extract all getter functions (and some constructors as well) of all given smart contracts (in abi json file format). Then i can call (extracted) function of respective contract one by one after deploying (that) contracts on ganache. Now i am facing problem that how to extract setter functions (which take some inputs of 1, 2, 3 or more arguments) name alongwith their parameter's type/name. So that i could caller such setter function with some valid random values.
function abiExpr()
{
for(i=0; i<sources.length; i++){ // here sources has my contracts in json files
if(!getterFunctionsObject[i])
getterFunctionsObject[i] = [] // making array to store getter function of each contract... I think , its not a good way ... but it working...
if(!constrObject[i])
constrObject[i] = [] // making array to store constructor of each contract
if(!setterFunctionsObject[i])
setterFunctionsObject[i] = [] //making array to store setter function of each contract
if(!settersParameters[i])
settersParameters[i] = []
if(!settersParameters[i][i])
settersParameters[i][i] = [] // HERE I AM STUCK, and confused how to achiev..... want to make array to store every parameter of each setter for each contract ... *
for (let item of sources[i].abi) {
if (item.type === "constructor") /// its OK for some constructor
{
constrObject[i].push(item.inputs)
}
if (item.type === "function") // its OK 100 %
{
if((item.inputs).length ==0 && item.stateMutability==='view')
getterFunctionsObject[i].push(item.name)
}
if (item.type === "function") /// its not working .. HOW to achieve ...
{
if((item.inputs).length>0)
{
for(t=0 ; t<(item.inputs).length; t++)
{
if ((item.inputs[t].name).length>0)
{
setterFunctionsObject[i].push(item.name)
settersParameters[i][t].push(item.inputs[t].name)
}
}
}
}
}
}
}
In order to summarize, how to store each parameter of each setter function of each contract. Is there any ABI APIs for my above mentioned tasks? If possible, also need some better coding approach, as i think above code is not good practice.
NOTE: For setter function, I means which take some parameters , and getter function means which just return some output.