Add ability to create dynamically sized `abi.DynamicArray`s
- 主要语言
- Python
- 星标
- 288
- 派生
- 138
- PR 合并指标
- 30 天内没有已合并 PR
描述
## 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.
贡献指南
评估
这个 Issue 还没有评估数据。