@@ -452,13 +452,10 @@ function getFunctionArguments(fnDef: FunctionDefinition, context: ContractDefini
452
452
const storageVar = 'v_' + storageType . replace ( / [ ^ 0 - 9 a - z A - Z $ _ ] + / g, '_' ) ;
453
453
// The argument is an index to an array in storage.
454
454
return { name, type : 'uint256' , storageVar, storageType } ;
455
- } else if ( p . typeName ?. nodeType == 'UserDefinedTypeName' ) {
456
- const type = getVarType ( p , context , deref , 'calldata' ) ;
457
- const udvtType = 'bytes32' ; // TODO: Do an actual resolution
458
- return { name, type, udvtType } ;
459
455
} else {
460
456
const type = getVarType ( p , context , deref , 'calldata' ) ;
461
- return { name, type } ;
457
+ const udvtType = getVarUdvtType ( p , context , deref , 'calldata' ) ;
458
+ return { name, type, udvtType } ;
462
459
}
463
460
} ) ;
464
461
}
@@ -513,6 +510,27 @@ function getType(typeName: TypeName, context: ContractDefinition, deref: ASTDere
513
510
return type ;
514
511
}
515
512
513
+ function getVarUdvtType ( varDecl : VariableDeclaration , context : ContractDefinition , deref : ASTDereferencer , location : StorageLocation | null = varDecl . storageLocation ) : string | undefined {
514
+ if ( ! varDecl . typeName ) {
515
+ throw new Error ( 'Missing type information' ) ;
516
+ }
517
+ return getUdvtType ( varDecl . typeName , context , deref , location ) ;
518
+ }
519
+
520
+ function getUdvtType ( typeName : TypeName , context : ContractDefinition , deref : ASTDereferencer , location : StorageLocation | null ) : string | undefined {
521
+ const { typeString, typeIdentifier } = typeName . typeDescriptions ;
522
+ if ( typeof typeString !== 'string' || typeof typeIdentifier !== 'string' ) {
523
+ throw new Error ( 'Missing type information' ) ;
524
+ }
525
+
526
+ // TODO: recover UDVT underlying properly
527
+ if ( typeIdentifier . startsWith ( 't_userDefinedValueType' ) ) {
528
+ return 'bytes32' ;
529
+ } else {
530
+ return undefined ;
531
+ }
532
+ }
533
+
516
534
function getVariables ( contract : ContractDefinition , deref : ASTDereferencer , subset ?: Visibility [ ] ) : VariableDeclaration [ ] {
517
535
const parents = contract . linearizedBaseContracts . map ( deref ( 'ContractDefinition' ) ) ;
518
536
0 commit comments