@ -3,9 +3,9 @@ var ethers = require('ethers')
module . exports = {
makeFullTupleTypeDefinition : function ( typeDef ) {
if ( typeDef && typeDef . type === 'tuple' && typeDef . components ) {
if ( typeDef && typeDef . type . indexOf ( 'tuple' ) === 0 && typeDef . components ) {
var innerTypes = typeDef . components . map ( ( innerType ) => innerType . type )
return 'tuple(' + innerTypes . join ( ',' ) + ')'
return ` tuple( ${ innerTypes . join ( ',' ) } ) ${ this . extractSize ( typeDef . type ) } `
}
return typeDef . type
} ,
@ -15,7 +15,7 @@ module.exports = {
if ( funABI . inputs && funABI . inputs . length ) {
for ( var i = 0 ; i < funABI . inputs . length ; i ++ ) {
var type = funABI . inputs [ i ] . type
types . push ( type === 'tuple' ? this . makeFullTupleTypeDefinition ( funABI . inputs [ i ] ) : type )
types . push ( type . indexOf ( 'tuple' ) === 0 ? this . makeFullTupleTypeDefinition ( funABI . inputs [ i ] ) : type )
if ( args . length < types . length ) {
args . push ( '' )
}
@ -85,14 +85,18 @@ module.exports = {
return serialized
} ,
extractSize : function ( type ) {
var size = type . match ( /([a-zA-Z0-9])(\[.*\])/ )
return size ? size [ 2 ] : ''
} ,
getFunction : function ( abi , fnName ) {
for ( var i = 0 ; i < abi . length ; i ++ ) {
var fn = abi [ i ]
if ( fn . type === 'function' && fnName === fn . name + '(' + fn . inputs . map ( ( value ) => {
if ( value . components ) {
// we extract the size (if array) and append it later
var size = value . type . match ( /([a-zA-Z0-9])(\[.*\])/ )
size = size ? size [ 2 ] : ''
var size = this . extractSize ( value . type )
return ` ( ${ value . components . map ( ( value ) => { return value . type } ).join(',')}) ${ size } `
} else {
return value . type