diff --git a/packages/abi/src/parser/specifications/v1/abi-type-mappers.ts b/packages/abi/src/parser/specifications/v1/abi-type-mappers.ts index 4be87328a5..5dad5545b1 100644 --- a/packages/abi/src/parser/specifications/v1/abi-type-mappers.ts +++ b/packages/abi/src/parser/specifications/v1/abi-type-mappers.ts @@ -21,14 +21,12 @@ function mapMetadata(type: ResolvableType | ResolvedType) { return result; } -function isResolvedType(type: ResolvableType | ResolvedType): type is ResolvedType { - return 'typeId' in type; -} - function isResolvedConcreteType( type: ResolvableType | ResolvedType ): type is ResolvedType & { typeId: string } { - return isResolvedType(type) && typeof type.typeId === 'string'; + const isResolvedType = 'typeId' in type; + + return isResolvedType && typeof type.typeId === 'string'; } function mapComponentType(component: ResolvableComponent): AbiTypeComponent { diff --git a/packages/abi/src/parser/specifications/v1/resolvable-type.ts b/packages/abi/src/parser/specifications/v1/resolvable-type.ts index f05f4040e5..04f297a9bf 100644 --- a/packages/abi/src/parser/specifications/v1/resolvable-type.ts +++ b/packages/abi/src/parser/specifications/v1/resolvable-type.ts @@ -338,8 +338,8 @@ export class ResolvableType { /** * The type parameter is either directly substituted with a type argument, - * or it's metadata type which accepts the type argument, - * so that metadata type needs to be resolved first. + * or it's a metadata type which accepts the type argument, + * so that metadata type will be resolved and subsitute the type parameter. */ const resolved = typeParamsArgsMap?.get(arg.metadataTypeId) ?? @@ -351,7 +351,11 @@ export class ResolvableType { return newMap; } - public resolve(concreteType: AbiConcreteTypeV1) { + /** + * Resolves the instance of `ResolvableType` with the specific concrete type's data. + * @returns a `ResolvedType` in which all its components are resolved. + */ + public resolve(concreteType: AbiConcreteTypeV1): ResolvedType { const concreteTypeArgs = concreteType.typeArguments?.map((typeArgument) => { const concreteTypeArg = this.findConcreteType(typeArgument); return this.resolveConcreteType(concreteTypeArg);