2021-05-31 05:37:11 +00:00
# solidity-mapper
Get value of state variable from storage for a solidity contract.
## Pre-requisites
* NodeJS and NPM
https://nodejs.org/en/ or use https://github.com/nvm-sh/nvm
## Instructions
2021-06-18 12:39:50 +00:00
* Create environment variable file
```bash
$ cp .env.example .env
```
* Run the tests using the following command
```bash
$ yarn test
# For testing on private network using RPC getStorageAt.
# Set ETH_RPC_URL in .env
$ yarn test:geth-rpc
# For testing on private network using ipld-eth-client getStorageAt.
# Set GQL_ENDPOINT in .env
$ yarn test:ipld-gql
```
2021-05-31 05:37:11 +00:00
## Different Types
2021-06-03 09:33:39 +00:00
* [ ] Value Types
* [x] Booleans
* [x] Integers
* [ ] Fixed Point Numbers
* [x] Address
* [x] Contract Types
* [x] Fixed-size byte arrays
* [x] Enums
* [ ] Function Types
2021-06-18 12:39:50 +00:00
* [ ] Reference Types
2021-06-17 06:29:53 +00:00
* [x] Arrays
2021-06-11 05:46:02 +00:00
* [x] Get all elements in array
2021-06-11 09:22:03 +00:00
* [x] Get element in array by index
2021-06-17 06:29:53 +00:00
* [x] Fixed size arrays
2021-06-03 09:33:39 +00:00
* [x] Integer Type
* [x] Boolean Type
2021-06-11 05:46:02 +00:00
* [x] Address Type
2021-06-17 06:29:53 +00:00
* [x] Fixed-size byte arrays
2021-06-16 06:41:44 +00:00
* [x] Enum type
* [x] Dynamically-sized byte array
2021-06-14 10:53:41 +00:00
* [x] Struct Type
2021-06-16 06:41:44 +00:00
* [x] Mapping Type
2021-06-17 06:29:53 +00:00
* [x] Dynamically-sized arrays
2021-06-15 12:50:12 +00:00
* [x] Integer Type
* [x] Boolean Type
* [x] Address Type
2021-06-17 06:29:53 +00:00
* [x] Fixed-size byte arrays
2021-06-15 12:50:12 +00:00
* [x] Enum Type
2021-06-16 04:38:39 +00:00
* [x] Dynamically-sized byte array
* [x] Struct Type
* [x] Mapping Type
2021-06-16 12:12:51 +00:00
* [x] Nested Arrays
2021-06-15 10:16:39 +00:00
* [x] Fixed size arrays
2021-06-16 12:12:51 +00:00
* [x] Dynamically-sized arrays
2021-06-16 09:59:04 +00:00
* [x] Dynamically-sized byte array
* [x] Bytes
2021-06-03 09:33:39 +00:00
* [x] String
2021-06-17 06:29:53 +00:00
* [x] Structs
2021-06-11 10:27:09 +00:00
* [x] Get struct value with all members
* [x] Value Types
* [x] Get value of a single member in struct
2021-06-17 06:29:53 +00:00
* [x] Reference Types
2021-06-14 14:27:29 +00:00
* [x] Struct type members (nested)
2021-06-16 06:41:44 +00:00
* [x] Fixed size Array members
2021-06-17 06:29:53 +00:00
* [x] Dynamically sized Array members
2021-06-16 06:41:44 +00:00
* [x] Bytes and string type members
* [x] Mapping type members
2021-06-03 09:33:39 +00:00
* [ ] Mapping Types
2021-06-10 05:52:03 +00:00
* [x] Value Type keys
* [ ] Fixed-size byte array keys
* [x] Dynamically-sized byte array keys
2021-06-16 12:46:55 +00:00
* [x] Reference Type Mapping values
2021-06-14 10:53:41 +00:00
* [x] Struct type values
2021-06-16 12:46:55 +00:00
* [x] Array type values
* [x] Dynamically sized Bytes and string type values
2021-06-10 05:52:03 +00:00
* [x] Nested Mapping
2021-05-31 05:37:11 +00:00
## Observations
* The storage layouts are formed according to the rules in https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#layout-of-state-variables-in-storage
* Structs can occupy multiple slots depending on the size required by its members.
* Fixed arrays can occupy multiple slots according to the size of the array and the type of array.