Skip to content

Commit

Permalink
refactor: capture generic type info only for boxes, global states, an…
Browse files Browse the repository at this point in the history
…d local states as type info is not needed for others
  • Loading branch information
boblat committed Jan 2, 2025
1 parent 8a4cf8c commit c29c885
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/test-transformer/visitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ExpressionVisitor {
if (type instanceof ptypes.FunctionPType) type = type.returnType

const isGeneric = isGenericType(type)
const needsToCaptureTypeInfo = isStateOrBoxType(type)
const isArc4Encoded = isArc4EncodedType(type)
const info = isGeneric || isArc4Encoded ? getGenericTypeInfo(type) : undefined
let updatedNode = node
Expand All @@ -129,7 +130,7 @@ class ExpressionVisitor {
}
updatedNode = stubbedFunctionName ? nodeFactory.callStubbedFunction(stubbedFunctionName, updatedNode, infoArg) : updatedNode
}
return isGeneric
return needsToCaptureTypeInfo
? nodeFactory.captureGenericTypeInfo(ts.visitEachChild(updatedNode, this.visit, this.context), JSON.stringify(info))
: ts.visitEachChild(updatedNode, this.visit, this.context)
}
Expand Down Expand Up @@ -311,6 +312,9 @@ const isGenericType = (type: ptypes.PType): boolean =>
ptypes.TuplePType,
)

const isStateOrBoxType = (type: ptypes.PType): boolean =>
instanceOfAny(type, ptypes.BoxMapPType, ptypes.BoxPType, ptypes.GlobalStateType, ptypes.LocalStateType)

const isArc4EncodedType = (type: ptypes.PType): boolean =>
instanceOfAny(
type,
Expand Down

0 comments on commit c29c885

Please sign in to comment.