algorand / algorand/pyteal

Add ability to create dynamically sized `abi.DynamicArray`s

Đang mở
#603 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Team Scytale
Ngôn ngữ chính
Python
Star
288
Fork
138
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.