You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An ARC4 StaticArray is an array of a fixed size. The item type is specified by the first generic parameter and the size is specified by the second.
Request
I'm requesting that the Puya-TS implementation of StaticArray support the ability to specify the size of the array with TemplateVar<UintN<8>>. This is currently not possible in Tealscript and I think it would be great to have in Puya-TS.
The text was updated successfully, but these errors were encountered:
ericsharma
changed the title
Feature Request: Uint64 TemplateVar support for defining the length of an ARC4 StaticArray
Feature Request: UintN TemplateVar support for defining the length of an ARC4 StaticArray
Feb 5, 2025
I would be interested to see the real world use case of this feature as it's possible there are simpler solutions.
Having said that, currently template variables are persisted all the way into teal output and only replaced when outputting byte code. The idea being that the variables can be replaced with values as late as deploy time.
In the case of using a template variable in a type declaration, one would need to make the replacement in after reading the typescript source code and before creating the typescript program to parse those files. A simpler solution might be to just replace the value in your typescript source code with an external script prior to invoking build
The idea being that the variables can be replaced with values as late as deploy time.
This is what I want. For situations where the length of the static array is not known when writing the smart contract but IS known when deploying.
A simpler solution might be to just replace the value in your typescript source code with an external script prior to invoking build
I'm doing this in Tealscript and I don't find it simple at all. The DX is hacky and also requires me to rebuild every time I change the length of the array. For me, a simpler solution would be to build once and then change the length of the static array as I would any other template var.
Perhaps allowing for a template variable to be used in a type declaration is not the best way to accommodate this enhancement but I do think that there should be template variable support for static arrays.
Definition of ARC4 StaticArray
An ARC4 StaticArray is an array of a fixed size. The item type is specified by the first generic parameter and the size is specified by the second.
Request
I'm requesting that the Puya-TS implementation of StaticArray support the ability to specify the size of the array with
TemplateVar<UintN<8>>
. This is currently not possible in Tealscript and I think it would be great to have in Puya-TS.References
Idea briefly discussed in this discord thread
The text was updated successfully, but these errors were encountered: