Skip to content

Commit

Permalink
Merge branch 'ns/feat/abi-parser' into ns/feat/abi-typegen
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Dec 17, 2024
2 parents 1c7f6a1 + b6c5936 commit 92bae57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 3 additions & 5 deletions packages/abi/src/parser/specifications/v1/abi-type-mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions packages/abi/src/parser/specifications/v1/resolvable-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) ??
Expand All @@ -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);
Expand Down

0 comments on commit 92bae57

Please sign in to comment.