watcher-ts/packages/solidity-mapper/test/contracts/TestNestedMapping.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

49 lines
2.0 KiB
Solidity

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.7.0;
contract TestNestedMapping {
// Mapping type variable occupies one single slot but the actual elements are stored at a different storage slot that is computed using a Keccak-256 hash.
// https://docs.soliditylang.org/en/v0.8.4/internals/layout_in_storage.html#mappings-and-dynamic-arrays
mapping (address => mapping (address => uint)) private nestedAddressUintMap;
mapping (int => mapping (address => bool)) private intAddressBoolMap;
mapping (uint => mapping (string => int)) private uintStringIntMap;
mapping (bytes => mapping (int => address)) private bytesIntAddressMap;
mapping (string => mapping (address => int)) private stringAddressIntMap;
mapping (address => mapping (address => mapping (uint24 => address))) public doubleNestedAddressMap;
// Set variable nestedAddressUintMap.
function setNestedAddressUintMap(address nestedKey, uint value) external {
nestedAddressUintMap[msg.sender][nestedKey] = value;
}
// Set variable intAddressBoolMap.
function setIntAddressBoolMap(int key, address nestedKey, bool value) external {
intAddressBoolMap[key][nestedKey] = value;
}
// Set variable uintStringIntMap.
function setUintStringIntMap(uint key, string calldata nestedKey, int value) external {
uintStringIntMap[key][nestedKey] = value;
}
// Set variable bytesIntAddressMap.
function setBytesIntAddressMap(bytes calldata key, int nestedKey, address value) external {
bytesIntAddressMap[key][nestedKey] = value;
}
// Set variable stringAddressIntMap.
function setStringAddressIntMap(string calldata key, address nestedKey, int value) external {
stringAddressIntMap[key][nestedKey] = value;
}
// Set variable doubleNestedAddressMap.
function setDoubleNestedAddressMap(address key, address nestedKey, uint24 doubleNestedKey, address value) external {
doubleNestedAddressMap[key][nestedKey][doubleNestedKey] = value;
}
}