mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Get value for array of integer and boolean types in solidity mapper (#30)
* Implement getting value for array type. * Add subtypes in solidit mapper readme. Co-authored-by: nikugogoi <95nikass@gmail.com>
This commit is contained in:
co-authored by
nikugogoi
parent
00eb129536
commit
23f9a9db41
@@ -5,28 +5,33 @@ contract TestFixedArrays {
|
||||
// Fixed size array variable will use 5 consecutive slots as size of 1 element is 32 bytes.
|
||||
uint[5] uintArray;
|
||||
|
||||
// Fixed size array variable will use 10 consecutive slots as size of 1 element is 32 bytes.
|
||||
int[10] intArray;
|
||||
// Fixed size array variable will use 3 slots as size of 1 element is 16 bytes.
|
||||
int128[5] int128Array;
|
||||
|
||||
// Fixed size array variable will use 1 slot as size of one element is 1 byte.
|
||||
int8[2] int8Array;
|
||||
bool[2] boolArray;
|
||||
|
||||
// Fixed size array variable will use the next consecutive slot as it is of array type.
|
||||
// Fixed size array variable will use the next slot as it is of array type.
|
||||
// https://docs.soliditylang.org/en/v0.7.4/internals/layout_in_storage.html#layout-of-state-variables-in-storage
|
||||
uint128[5] uint128Array;
|
||||
uint16[5] uint16Array;
|
||||
|
||||
// Set varaible boolArray.
|
||||
function setBoolArray(bool[2] calldata value) external {
|
||||
boolArray = value;
|
||||
}
|
||||
|
||||
// Set varaible uintArray.
|
||||
function setUintArray(uint[5] calldata value) external {
|
||||
uintArray = value;
|
||||
}
|
||||
|
||||
// Set varaible int8Array.
|
||||
function setInt8Array(int8[2] calldata value) external {
|
||||
int8Array = value;
|
||||
// Set varaible uint16Array.
|
||||
function setUint16Array(uint16[5] calldata value) external {
|
||||
uint16Array = value;
|
||||
}
|
||||
|
||||
// Set varaible uint128Array.
|
||||
function setUint128Array(uint128[5] calldata value) external {
|
||||
uint128Array = value;
|
||||
function setInt128Array(int128[5] calldata value) external {
|
||||
int128Array = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export const getStorageAt: GetStorageAt = async ({ blockHash, contract, slot })
|
||||
// TODO: Fix use of blockHash as hex string in getStorageAt.
|
||||
// Using blockHash in getStorageAt throws error.
|
||||
// https://github.com/ethers-io/ethers.js/pull/1550#issuecomment-841746994
|
||||
// Using latest tag for temporary fix.
|
||||
// Using latest tag for temporary fix in test scenario.
|
||||
blockHash = 'latest';
|
||||
const value = await ethers.provider.getStorageAt(contract, slot, blockHash);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user