mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-20 04:46:20 +00:00
3815853f7b
Co-authored-by: nikugogoi <95nikass@gmail.com>
90 lines
2.6 KiB
Solidity
90 lines
2.6 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.7.6;
|
|
pragma abicoder v2;
|
|
|
|
contract TestReferenceStructs {
|
|
struct FixedArrayStruct {
|
|
int8 int1;
|
|
uint16[4] uintArray;
|
|
address[3] addressArray;
|
|
}
|
|
|
|
FixedArrayStruct fixedArrayStruct;
|
|
|
|
struct BytesStruct {
|
|
bytes byteArray;
|
|
address address1;
|
|
uint256 uint1;
|
|
}
|
|
|
|
BytesStruct bytesStruct;
|
|
|
|
struct StringStruct {
|
|
string string1;
|
|
uint24 uint1;
|
|
string string2;
|
|
address address1;
|
|
bool bool1;
|
|
int24 int1;
|
|
}
|
|
|
|
StringStruct stringStruct;
|
|
|
|
struct ValueMappingStruct {
|
|
mapping(uint => address) uintAddressMap;
|
|
uint32 uint1;
|
|
mapping(address => int) addressIntMap;
|
|
}
|
|
|
|
ValueMappingStruct public valueMappingStruct;
|
|
|
|
struct ReferenceMappingStruct {
|
|
mapping(bytes => address) bytesAddressMap;
|
|
mapping(string => uint) stringUintMap;
|
|
}
|
|
|
|
ReferenceMappingStruct referenceMappingStruct;
|
|
|
|
struct NestedStruct {
|
|
BytesStruct bytesStruct;
|
|
address address1;
|
|
}
|
|
|
|
NestedStruct nestedStruct;
|
|
|
|
// Set variable fixedArrayStruct.
|
|
function setFixedArrayStruct(int8 int1Value, uint16[4] calldata uintArrayValue, address[3] calldata addressArrayValue) external {
|
|
fixedArrayStruct.int1 = int1Value;
|
|
fixedArrayStruct.uintArray = uintArrayValue;
|
|
fixedArrayStruct.addressArray = addressArrayValue;
|
|
}
|
|
|
|
// Set variable bytesStruct.
|
|
function setBytesStruct(BytesStruct calldata value) external {
|
|
bytesStruct = value;
|
|
}
|
|
|
|
// Set variable stringStruct.
|
|
function setStringStruct(StringStruct calldata value) external {
|
|
stringStruct = value;
|
|
}
|
|
|
|
// Set variable valueMappingStruct.
|
|
function setValueMappingStruct(uint uintAddressKey, address uintAddressValue, uint32 uint1Value, address addressIntKey, int addressIntValue) external {
|
|
valueMappingStruct.uintAddressMap[uintAddressKey] = uintAddressValue;
|
|
valueMappingStruct.uint1 = uint1Value;
|
|
valueMappingStruct.addressIntMap[addressIntKey] = addressIntValue;
|
|
}
|
|
|
|
// Set variable referenceMappingStruct.
|
|
function setReferenceMappingStruct(bytes calldata bytesAddressKey, address bytesAddressValue, string calldata stringUintKey, uint stringUintValue) external {
|
|
referenceMappingStruct.bytesAddressMap[bytesAddressKey] = bytesAddressValue;
|
|
referenceMappingStruct.stringUintMap[stringUintKey] = stringUintValue;
|
|
}
|
|
|
|
// Set variable nestedStruct.
|
|
function setNestedStruct(NestedStruct calldata value) external {
|
|
nestedStruct = value;
|
|
}
|
|
}
|