* @param {String} fullType - type given by the AST
* @return {Array} containing all the dimensions and size of the array (e.g ['[3]', '[]'] )
*/
functionextractDimensions(fullType){
varret=[]
if(fullType.indexOf('[')!==-1){
varsquareBracket=/\[([0-9]+|\s*)\]/g
vardim=fullType.match(squareBracket)
returndim
}
returnret
}
/**
* parse the full type
*
* @param {String} fullType - type given by the AST (ex: uint[2] storage ref[2])
* @return {String} returns the token type (used to instanciate the right decoder) (uint[2] storage ref[2] will return 'array', uint256 will return uintX)
*/
functionextractTokenType(fullType){
if(fullType.indexOf('[')!==-1){
return'array'
}
if(fullType.indexOf(' ')!==-1){
fullType=fullType.split(' ')[0]
}
varchar=fullType.indexOf('bytes')===0?'X':''
returnfullType.replace(/[0-9]+/g,char)
}
/**
* parse the type and return an object representing the type
*
* @param {Object} type - type name given by the ast node
* @param {Object} stateDefinitions - all state stateDefinitions given by the AST (including struct and enum type declaration)
* @return {Object} - return the corresponding decoder