algorand / algorand/pyteal

Add ability to set individual elements in ABI containers

オープン
#602 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
Team Scytale
主要言語
Python
スター
288
フォーク
138
PR マージ指標
30日以内にマージされた PR はありません

説明

## Problem
Right now the `Tuple`, `StaticArray`, and `DynamicArray` ABI type containers have `set` methods which can be used to set the entire container's value.

However, it's not currently possible to set the value of only a single element in that container.

## Possible Solution
Perhaps the existing `TupleElement` and `ArrayElement` classes which are returned from `__getitem__` for tuples and arrays, respectively, can be extended to allow modifying individual values as well.

That would make something like this possible:
```python
def f() -> Expr:
a = abi.make(abi.Bool)
b = abi.make(abi.Uint64)
c = abi.make(abi.Tuple2[abi.Bool, abi.Uint64])
return Seq(
a.set(True), # a=True, b=uninitialized, c=uninitialized
b.set(100), # a=True, b=100, c=uninitialized
c.set(a, b), # a=True, b=100, c=[True,100]
a.set(False), # a=False, b=100, c=[True,100]
c[0].set(a) # a=False, b=100, c=[False,100]
# the above line would be the proposed change
)
```

## Follow-up Concerns
If a way to set individual elements in a container is adopted, that doesn't change the fact that a container must be fully populated with all elements before any other operation can happen. Should we instead allow containers to be partially initialized, or initialized with default values?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。