Add ability to create dynamically sized `abi.DynamicArray`s
- Lenguaje dominante
- Python
- Estrellas
- 288
- Forks
- 138
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
## Problem
Contract methods which return dynamic arrays likely do not know the size of the array they need to return at compile time.
Unfortunately, the only way to initialize/modify an `abi.DynamicArray` value is with the `set` method: https://github.com/algorand/pyteal/blob/a3b5b297cbc638ea19fb582d0f402f8ebb3ced4e/pyteal/ast/abi/array_dynamic.py#L55-L58
This method only allows `values` to be a compile-time sequence of values, or to be another dynamic array. As a consequence of this, it's not currently possible to create an array of arbitrary length at runtime in PyTeal.
## Possible Solutions
There are two possible solutions that could address this problem.
1. Add the ability to append new elements to an existing dynamic array. #604 is the start of a PR to do this.
2. If implemented in conjunction with #602, add the ability to create an arbitrary-sized dynamic array at runtime, perhaps with a default value to fill the array with. This would be similar in spirit to languages like Go or C, where you can dynamically allocate an array of a certain size and then set its elements individually.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.