Skip to content

Commit da6d38d

Browse files
ArvolearHrom131
andauthored
Adjust for 3.0 (#32)
* adjust for 3.0 * fix * fix * Add PlonkVerifierHelper lib description --------- Co-authored-by: Oleh Komendant <[email protected]>
1 parent daca9e3 commit da6d38d

24 files changed

+643
-516
lines changed

docs/getting-started/Overview.md

Lines changed: 83 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,101 @@
22

33
<img src={require("/static/img/docs/solarity.png").default} alt=""/>
44

5-
## Solidity Library for Savvies by Distributed Lab
6-
7-
The library consists of modules and utilities that are built leveraging [Openzeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) (4.9.6) and **go far beyond mediocre solidity**.
5+
## Solarity Solidity Library
6+
7+
Solidity contracts and utilities that **go far beyond mediocre solidity**.
8+
9+
### Contracts
10+
11+
```ml
12+
contracts
13+
├── access
14+
│ ├── AMerkleWhitelisted — "Whitelists via Merkle proofs"
15+
│ ├── AMultiOwnable — "Multiple owners with the equal access level"
16+
│ ├── ARBAC — "A powerful implementation of a true RBAC"
17+
│ └── extensions
18+
│ └── ARBACGroupable — "Groupable extension of ARBAC"
19+
├── contracts—registry
20+
│ ├── AContractsRegistry — "Reference registry implementation of ERC-6224 pattern"
21+
│ ├── ADependant — "Reference dependant implementation of ERC-6224 pattern"
22+
│ └── pools
23+
│ ├── APoolContractsRegistry — "Adaptation of ERC-6224 for factory-like contracts"
24+
│ └── APoolFactory — "Factory implementation for a pooled registry"
25+
├── diamond
26+
│ ├── ADiamondStorage — "The storage part of ERC-2535 diamond"
27+
│ ├── Diamond — "Revised ERC-2535 diamond implementation"
28+
│ └── utils
29+
│ ├── AInitializableStorage — "Initializable logic for diamond facets"
30+
│ └── DiamondERC165 — "ERC-165 introspection for diamond facets"
31+
├── finance
32+
│ ├── compound—rate—keeper
33+
│ │ └── ACompoundRateKeeper — "Complex percentage calculator used in lending protocols"
34+
│ ├── staking
35+
│ │ ├── AStaking — "Flexible rewards staking implementation"
36+
│ │ └── AValueDistributor — "Efficient distribution algorithm implementation"
37+
│ └── vesting
38+
│ └── AVesting — "Linear and exponential vesting implementation"
39+
├── libs
40+
│ ├── arrays
41+
│ │ ├── ArrayHelper — "Common functions to work with arrays"
42+
│ │ ├── Paginator — "Return array slices from view function"
43+
│ │ └── SetHelper — "Array abstraction over sets"
44+
│ ├── bn
45+
│ │ └── U512 — "A hyperoptimized uint512 implementation"
46+
│ ├── crypto
47+
│ │ ├── ECDSA256 — "ECDSA verification over any 256-bit curves"
48+
│ │ ├── ECDSA384 — "ECDSA verification over any 384-bit curves"
49+
│ │ ├── ECDSA512 — "ECDSA verification over any 512-bit curves"
50+
│ │ └── RSASSAPSS — "RSASSA-PSS verification with MGF1"
51+
│ ├── data—structures
52+
│ │ ├── AvlTree — "AVL tree implementation with an iterator traversal"
53+
│ │ ├── CartesianMerkleTree — "CMT reference implementation"
54+
│ │ ├── DynamicSet — "Set for strings and bytes"
55+
│ │ ├── IncrementalMerkleTree — "IMT implementation with flexible tree height"
56+
│ │ ├── PriorityQueue — "Max queue heap implementation"
57+
│ │ ├── SparseMerkleTree — "SMT optimized implementation"
58+
│ │ └── memory
59+
│ │ └── Vector — "A pushable memory array"
60+
│ ├── utils
61+
│ │ ├── DecimalsConverter — "Simplify interaction with ERC-20 decimals"
62+
│ │ ├── MemoryUtils — "Functions for memory manipulation"
63+
│ │ ├── ReturnDataProxy — "Bypass extra returndata copy when returning data"
64+
│ │ └── Typecaster — "Cast between various Solidity types"
65+
│ └── zkp
66+
│ ├── Groth16VerifierHelper — "Simplify integration with Groth16 proofs"
67+
│ └── PlonkVerifierHelper — "Simplify integration with Plonk proofs"
68+
├── oracles
69+
│ ├── AUniswapV2Oracle — "Uniswap V2 oracle with custom TWAP"
70+
│ └── UniswapV3Oracle — "Uniswap V3 oracle with a clean interface"
71+
├── proxy
72+
│ └── adminable
73+
│ ├── AdminableProxy — "A slight modification of a transparent proxy"
74+
│ └── AdminableProxyUpgrader — "A slight modification of a proxy admin"
75+
├── tokens
76+
│ └── ASBT — "A minimal implementation of an SBT"
77+
├── utils
78+
│ ├── ABlockGuard — "Protect against flashloans"
79+
│ └── Globals — "Some commonly used constants"
80+
├── presets — "Presets for the library contracts"
81+
├── interfaces — "Interfaces for the library contracts"
82+
└── mock — "Mocks for testing purposes"
83+
```
884

9-
* Implementation of the [**Contracts Registry**](https://eips.ethereum.org/EIPS/eip-6224) pattern
10-
* State-of-the-art cryptography primitives (**ECDSA over 256-bit and 384-bit curves**, **RSASSA-PSS**)
11-
* Advanced data structures (**Vector**, **DynamicSet**, **PriorityQueue**, **AVLTree**)
12-
* ZK-friendly [**Sparse Merkle Tree**](https://docs.iden3.io/publications/pdfs/Merkle-Tree.pdf) and [**Incremental Merkle Tree**](https://github.com/runtimeverification/deposit-contract-verification/blob/master/deposit-contract-verification.pdf) implementations
13-
* Versatile **RBAC** and **MultiOwnable** smart contracts
14-
* Enhanced and simplified [**Diamond**](https://eips.ethereum.org/EIPS/eip-2535) pattern
15-
* Flexible finance instruments (**Staking**, **Vesting**)
16-
* Novel **ReturnDataProxy** contract
17-
* Robust UniswapV2 and UniswapV3 oracles
18-
* Lightweight **SBT** implementation
19-
* Utilities to ease work with memory, types, ERC20 decimals, arrays, sets, and ZK proofs
85+
Built with courage and aspiration to perfection.
2086

21-
Checkout guides section for detailed explanations with usage examples for each module.
87+
> The library is designed to work cohesively with [hardhat-zkit](https://github.com/dl-solarity/hardhat-zkit) and [circom-lib](https://github.com/dl-solarity/circom-lib) packages.
2288
2389
### Installation
2490

2591
```bash
26-
$ npm install @solarity/solidity-lib
92+
npm install @solarity/solidity-lib
2793
```
2894

2995
The latest stable version is always in the `master` branch.
3096

31-
### Usage
32-
33-
You will find the smart contracts in the `contracts` directory. Feel free to play around and check the source code, it is rather descriptive.
34-
35-
Once the [npm package](https://www.npmjs.com/package/@solarity/solidity-lib) is installed, one can use the library just like that:
36-
37-
```solidity
38-
pragma solidity ^0.8.4;
39-
40-
import "@solarity/solidity-lib/contracts-registry/presets/OwnableContractsRegistry.sol";
41-
42-
contract ContractsRegistry is OwnableContractsRegistry {
43-
. . .
44-
}
45-
```
46-
47-
> It is important to use the library as it is shipped and not copy-paste the code from untrusted sources.
48-
4997
### Contribution
5098

51-
We are open to contributions to our [solidity-lib](https://github.com/dl-solarity/solidity-lib/tree/master) repository. If you're interested in contributing, please visit the [How to contribute](./contribution/how-to-contribute.md) section.
99+
We are open to any mind-blowing ideas! Please take a look at our [contribution guidelines](https://docs.solarity.dev/docs/getting-started/contribution/how-to-contribute) to get involved.
52100

53101
### License
54102

docs/getting-started/contribution/solidity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,13 @@ All our contracts are under the MIT License. This ensures that they can be freel
575575

576576
#### 6.2 Solidity version
577577

578-
Use Solidity version 0.8.4. Exceptions for specific integrations are possible but must be discussed on a case-by-case basis.
578+
Use Solidity version 0.8.21. Exceptions for specific integrations are possible but must be discussed on a case-by-case basis.
579579

580580
<Tabs>
581581
<TabItem value="good" label="Good" default>
582582

583583
```solidity
584-
pragma solidity ^0.8.4;
584+
pragma solidity ^0.8.21;
585585
```
586586

587587
</TabItem>

docs/getting-started/guides/access/merkle-whitelisted.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ The Merkle Whitelisted module is an abstract utility used in modules that requir
1010

1111
The Merkle tree enables efficient validation of huge whitelists due to its logarithmic complexity. Whitelist data or user addresses are stored in the leaves, **with only the tree root saved on-chain**. This approach is cost-effective for large lists but incurs overhead for off-chain Merkle Proof generation and membership verification.
1212

13-
The `MerkleWhitelisted` is an abstract contract that implements whitelisting logic using the Merkle Tree data structure. To validate whitelist membership, the leaf (whitelist element) and the corresponding branch (proof) are passed to the validation function to check for matching roots, indicating whitelist membership.
13+
The `AMerkleWhitelisted` is an abstract contract that implements whitelisting logic using the Merkle Tree data structure. To validate whitelist membership, the leaf (whitelist element) and the corresponding branch (proof) are passed to the validation function to check for matching roots, indicating whitelist membership.
1414

1515
## Example
1616

17-
Start by creating a utility contract that inherits the functionalities of `MerkleWhitelisted`. The contract includes the `protectedFunctionUser` method that is restricted to whitelisted addresses. Alongside this, the contract has the `setMerkleRoot` method for setting and updating Merkle tree roots, access to which is also restricted by the `PermanentOwnable` contract.
17+
Start by creating a utility contract that inherits the functionalities of `AMerkleWhitelisted`. The contract includes the `protectedFunctionUser` method that is restricted to whitelisted addresses. Alongside this, the contract has the `setMerkleRoot` method for setting and updating Merkle tree roots, access to which is also restricted by the `Ownable` contract.
1818

1919
```solidity
20-
import "@solarity/solidity-lib/access-control/MerkleWhitelisted.sol";
21-
import "@solarity/solidity-lib/access-control/PermanentOwnable.sol";
20+
import "@openzeppelin/contracts/access/Ownable.sol";
2221
23-
contract MerkleProtectedContract is MerkleWhitelisted, PermanentOwnable {
24-
constructor() PermanentOwnable(msg.sender) {}
22+
import "@solarity/solidity-lib/access-control/AMerkleWhitelisted.sol";
23+
24+
contract MerkleProtectedContract is AMerkleWhitelisted, Ownable {
25+
constructor() Ownable(msg.sender) {}
2526
2627
function setMerkleRoot(bytes32 merkleRoot_) external onlyOwner {
2728
_setMerkleRoot(merkleRoot_);

docs/getting-started/guides/access/multi-ownable.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
## Introduction
44

5-
The concept of the Multi Owanable module is not different from the [OpenZeppelin's Ownable contract](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable), with the exception that instead of one address as owner, a set of addresses is maintained.
5+
The concept of the Multi Ownable module is not different from the [OpenZeppelin's Ownable contract](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable), with the exception that instead of one address as owner, a set of addresses is maintained.
66

77
## Implementation
88

9-
The `MultiOwnable` contract provides a basic access control mechanism, where a list of owner addresses is granted exclusive access to specific functions. All owners have equal access rights, allowing them to add or remove other owners, including themselves. The one who calls the `__MultiOwnable_init` function (i.e., the contract deployer) will become the initial owner of the contract. This module makes the `onlyOwner` modifier available, which can be applied to functions to restrict their use to the owners.
9+
The `AMultiOwnable` contract provides a basic access control mechanism, where a list of owner addresses is granted exclusive access to specific functions. All owners have equal access rights, allowing them to add or remove other owners, including themselves. The one who calls the `__AMultiOwnable_init` function (i.e., the contract deployer) will become the initial owner of the contract. This module makes the `onlyOwner` modifier available, which can be applied to functions to restrict their use to the owners.
1010

1111
## Example
1212

13-
Begin by creating a protected contract by inheriting it from the `MultiOwnable`.
13+
Begin by creating a protected contract by inheriting it from the `AMultiOwnable`.
1414

1515
```solidity
16-
contract MultiOwnableProtectedContract is MultiOwnable {
16+
import "@solarity/solidity-lib/access-control/AMultiOwnable.sol";
17+
18+
contract MultiOwnableProtectedContract is AMultiOwnable {
1719
function __MultiOwnableProtectedContract_init() external initializer {
18-
__MultiOwnable_init();
20+
__AMultiOwnable_init();
1921
}
2022
2123
function protectedFunction() external onlyOwner { /* ... */ }

docs/getting-started/guides/access/permanent-ownable.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)