mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Get value for dynamic arrays (#66)
* Implement getting values of dynamic arrays. * Add tests for dynamic arrays of value types. Co-authored-by: nikugogoi <95nikass@gmail.com>
This commit is contained in:
co-authored by
nikugogoi
parent
3439dd4041
commit
d4db1f5d28
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.6;
|
||||
|
||||
contract TestDynamicArrays {
|
||||
// Dynamic sized array variable will use 1 single slot which contains number of array elements.
|
||||
int[] intArray;
|
||||
|
||||
// Dynamic sized array always uses the next consecutive single slot.
|
||||
uint128[] uintArray;
|
||||
|
||||
bool[] boolArray;
|
||||
|
||||
address[] addressArray;
|
||||
|
||||
bytes10[] fixedBytesArray;
|
||||
|
||||
enum Choices { Choice0, Choice1, Choice2, Choice3 }
|
||||
|
||||
Choices[] enumArray;
|
||||
|
||||
// Set variable intArray.
|
||||
function setIntArray(int[] calldata value) external {
|
||||
intArray = value;
|
||||
}
|
||||
|
||||
// Set variable uintArray.
|
||||
function setUintArray(uint128[] calldata value) external {
|
||||
uintArray = value;
|
||||
}
|
||||
|
||||
// Set variable boolArray.
|
||||
function setBoolArray(bool[] calldata value) external {
|
||||
boolArray = value;
|
||||
}
|
||||
|
||||
// Set variable addressArray.
|
||||
function setAddressArray(address[] calldata value) external {
|
||||
addressArray = value;
|
||||
}
|
||||
|
||||
// Set variable fixedBytesArray.
|
||||
function setFixedBytesArray(bytes10[] calldata value) external {
|
||||
fixedBytesArray = value;
|
||||
}
|
||||
|
||||
// Set variable enumArray.
|
||||
function setEnumArray(Choices[] calldata value) external {
|
||||
enumArray = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user