Skip to content

Commit

Permalink
readme and natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Oct 2, 2024
1 parent 19601b8 commit 1a819dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 63 deletions.
70 changes: 7 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,10 @@
## Foundry
# Libraries for ERC-4337 compatible dynamic arrays in storage.

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
## Motivation
Dynamic array are not easily compatible with ERC-4337 [associated storage](https://eips.ethereum.org/EIPS/eip-7562#validation-rules) access rules. Even if they are a value in a mapping, where the Smart Account address is the key, the final keccak won't be `keccak(A||x)+n` as it would be for a static array, but `keccak(keccak(A||x))+n` instead.

Foundry consists of:
## What's included
- AssociatedArrayLib.sol: Library for dynamic arrays that are associated with an address as per [ERC-7562](https://eips.ethereum.org/EIPS/eip-7562). It is achieved by using `keccak(A||x)` as the starting slot for the array.
- EnumerableSet4337.sol: Fork of OZ's EnumerableSet that makes all storage access ERC-4337 compliant via associated storage. Stores indexes in a mapping making access to a given value easier.
- EnumerableMap4337.sol: Library for managing an enumerable variant of Solidity's [`mapping`](https://solidity.readthedocs.io/en/latest/types.html#mapping-types) type.

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Documentation

https://book.getfoundry.sh/

## Usage

### Build

```shell
$ forge build
```

### Test

```shell
$ forge test
```

### Format

```shell
$ forge fmt
```

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil

```shell
$ anvil
```

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```
4 changes: 4 additions & 0 deletions src/AssociatedArrayLib.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
* Dynamic arrays associated with an account address as per ERC-7562/ERC-4337
* @author filio.eth (Biconomy), zeroknots.eth (rhinestone)
*/
library AssociatedArrayLib {
using AssociatedArrayLib for *;

Expand Down

0 comments on commit 1a819dc

Please sign in to comment.