You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
deff() ->Expr:
a=abi.make(abi.Bool)
b=abi.make(abi.Uint64)
c=abi.make(abi.Tuple2[abi.Bool, abi.Uint64])
returnSeq(
a.set(True), # a=True, b=uninitialized, c=uninitializedb.set(100), # a=True, b=100, c=uninitializedc.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?
The text was updated successfully, but these errors were encountered:
Problem
Right now the
Tuple
,StaticArray
, andDynamicArray
ABI type containers haveset
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
andArrayElement
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:
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?
The text was updated successfully, but these errors were encountered: