watcher-ts/packages/solidity-mapper/test/contracts/TestDynamicArrays.sol
Ashwin Phatak a7ec3d8da8
Add APGL license and copyright notices (#212)
* Add license & copyright declarations for add-watcher.

* Add copyright declarations for cache.

* Add copyright declarations for erc20-watcher.

* Add copyright declarations for ipld-eth-client.

* Add copyright declarations for tracing-client.

* Add copyright declarations for uni-watcher.

* Add copyright declarations for solidity-mapper.

* Add copyright declarations for uni-info-watcher.

* Add copyright declarations for util.

* Add copyright declarations for lighthouse-watcher.

* Change license identifier in .sol files.

Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
2021-08-12 15:28:13 +05:30

89 lines
2.2 KiB
Solidity

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.7.6;
// https://docs.soliditylang.org/en/v0.8.5/layout-of-source-files.html#abi-coder-pragma
pragma abicoder v2;
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;
bytes[] bytesArray;
string[] stringArray;
struct TestStruct {
uint32 uint1;
int56 int1;
bool bool1;
}
TestStruct[] structArray;
mapping(address => uint)[] mapArray;
// 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;
}
// Set variable bytesArray.
function setBytesArray(bytes[] memory value) external {
bytesArray = value;
}
// Set variable stringArray.
function setStringArray(string[] memory value) external {
stringArray = value;
}
// Set variable structArray.
function addStructArrayElement(TestStruct calldata value) external {
structArray.push(value);
}
// Set variable structArray.
function addMapArrayElement(address key, uint value) external {
mapping(address => uint256) storage element = mapArray.push();
element[key] = value;
}
}