algorand / algorand/pyteal

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

Ouverte
#603 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Team Scytale
Langage dominant
Python
Étoiles
288
Forks
138
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.