Skip to content

Commit

Permalink
♻️ Implement src Layout (#206)
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Marco Caversaccio <[email protected]>
  • Loading branch information
pcaversaccio authored Feb 14, 2024
1 parent bae6869 commit 32ce0fd
Show file tree
Hide file tree
Showing 58 changed files with 270 additions and 247 deletions.
248 changes: 124 additions & 124 deletions .gas-snapshot

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ jobs:

- name: Validate URLs
run: |
awesome_bot ./*.md src/**/*.vy src/**/interfaces/*.vy \
awesome_bot ./*.md src/snekmate/**/*.vy src/snekmate/**/interfaces/*.vy \
test/**/*.sol test/**/interfaces/*.sol test/**/mocks/*.sol \
test/**/scripts/*.js scripts/*.py --allow-dupe --allow-redirect \
--request-delay 0.4 \
--white-list https://www.wagmi.xyz,https://twitter.com,https://github.com/pcaversaccio/snekmate/releases/tag/v0.0.5,https://github.com/pcaversaccio/snekmate/blob/v0.0.5,https://github.com/pcaversaccio/snekmate/compare/v0.0.4...v0.0.5
--white-list https://www.wagmi.xyz,https://twitter.com,https://github.com/pcaversaccio/snekmate.git@,https://github.com/pcaversaccio/snekmate/releases/tag/v0.0.5,https://github.com/pcaversaccio/snekmate/blob/v0.0.5,https://github.com/pcaversaccio/snekmate/compare/v0.0.4...v0.0.5
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
--user
- name: Build a binary wheel and a source tarball
run: python scripts/build.py
run: python -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
--user
- name: Build a binary wheel and a source tarball
run: python scripts/build.py
run: python -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### 🔖 Release Management

- Implement `snekmate`-namespaced distribution package building for TestPyPI and PyPI. ([#204](https://github.com/pcaversaccio/snekmate/pull/204))
- Implement [`src` layout](https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#src-layout) to enable an enhanced local `pip install git+https://github.com/pcaversaccio/snekmate.git@<branch>` building. ([#206](https://github.com/pcaversaccio/snekmate/pull/206))

### 👀 Full Changelog

Expand Down
84 changes: 44 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,47 @@

```ml
src
├── auth
│ ├── Ownable — "Owner-Based Access Control Functions"
│ ├── Ownable2Step — "2-Step Ownership Transfer Functions"
│ ├── AccessControl — "Multi-Role-Based Access Control Functions"
│ └── interfaces
│ └── IAccessControl — "AccessControl Interface Definition"
├── extensions
│ ├── ERC2981 — "ERC-721 and ERC-1155 Compatible ERC-2981 Reference Implementation"
│ ├── ERC4626 — "Modern and Gas-Efficient ERC-4626 Tokenised Vault Implementation"
│ └── interfaces
│ └── IERC2981 — "EIP-2981 Interface Definition"
├── governance
│ └── TimelockController — "Multi-Role-Based Timelock Controller Reference Implementation"
├── tokens
│ ├── ERC20 — "Modern and Gas-Efficient ERC-20 + EIP-2612 Implementation"
│ ├── ERC721 — "Modern and Gas-Efficient ERC-721 + EIP-4494 Implementation"
│ ├── ERC1155 — "Modern and Gas-Efficient ERC-1155 Implementation"
│ └── interfaces
│ ├── IERC20Permit — "EIP-2612 Interface Definition"
│ ├── IERC721Enumerable — "EIP-721 Optional Enumeration Interface Definition"
│ ├── IERC721Metadata — "EIP-721 Optional Metadata Interface Definition"
│ ├── IERC721Permit — "EIP-4494 Interface Definition"
│ ├── IERC721Receiver — "EIP-721 Token Receiver Interface Definition"
│ ├── IERC1155 — "EIP-1155 Interface Definition"
│ ├── IERC1155MetadataURI — "EIP-1155 Optional Metadata Interface Definition"
│ ├── IERC1155Receiver — "EIP-1155 Token Receiver Interface Definition"
│ └── IERC4906 — "EIP-4906 Interface Definition"
└── utils
├── Base64 — "Base64 Encoding and Decoding Functions"
├── BatchDistributor — "Batch Sending Both Native and ERC-20 Tokens"
├── CreateAddress — "`CREATE` EVM Opcode Utility Function for Address Calculation"
├── Create2Address — "`CREATE2` EVM Opcode Utility Functions for Address Calculations"
├── ECDSA — "Elliptic Curve Digital Signature Algorithm (ECDSA) Functions"
├── SignatureChecker — "ECDSA and EIP-1271 Signature Verification Functions"
├── EIP712DomainSeparator — "EIP-712 Domain Separator"
├── Math — "Standard Mathematical Utility Functions"
├── MerkleProofVerification — "Merkle Tree Proof Verification Functions"
├── Multicall — "Multicall Functions"
└── interfaces
└── IERC5267 — "EIP-5267 Interface Definition"
└── snekmate
├── auth
│ ├── Ownable — "Owner-Based Access Control Functions"
│ ├── Ownable2Step — "2-Step Ownership Transfer Functions"
│ ├── AccessControl — "Multi-Role-Based Access Control Functions"
│ └── interfaces
│ └── IAccessControl — "AccessControl Interface Definition"
├── extensions
│ ├── ERC2981 — "ERC-721 and ERC-1155 Compatible ERC-2981 Reference Implementation"
│ ├── ERC4626 — "Modern and Gas-Efficient ERC-4626 Tokenised Vault Implementation"
│ └── interfaces
│ └── IERC2981 — "EIP-2981 Interface Definition"
├── governance
│ └── TimelockController — "Multi-Role-Based Timelock Controller Reference Implementation"
├── tokens
│ ├── ERC20 — "Modern and Gas-Efficient ERC-20 + EIP-2612 Implementation"
│ ├── ERC721 — "Modern and Gas-Efficient ERC-721 + EIP-4494 Implementation"
│ ├── ERC1155 — "Modern and Gas-Efficient ERC-1155 Implementation"
│ └── interfaces
│ ├── IERC20Permit — "EIP-2612 Interface Definition"
│ ├── IERC721Enumerable — "EIP-721 Optional Enumeration Interface Definition"
│ ├── IERC721Metadata — "EIP-721 Optional Metadata Interface Definition"
│ ├── IERC721Permit — "EIP-4494 Interface Definition"
│ ├── IERC721Receiver — "EIP-721 Token Receiver Interface Definition"
│ ├── IERC1155 — "EIP-1155 Interface Definition"
│ ├── IERC1155MetadataURI — "EIP-1155 Optional Metadata Interface Definition"
│ ├── IERC1155Receiver — "EIP-1155 Token Receiver Interface Definition"
│ └── IERC4906 — "EIP-4906 Interface Definition"
└── utils
├── Base64 — "Base64 Encoding and Decoding Functions"
├── BatchDistributor — "Batch Sending Both Native and ERC-20 Tokens"
├── CreateAddress — "`CREATE` EVM Opcode Utility Function for Address Calculation"
├── Create2Address — "`CREATE2` EVM Opcode Utility Functions for Address Calculations"
├── ECDSA — "Elliptic Curve Digital Signature Algorithm (ECDSA) Functions"
├── SignatureChecker — "ECDSA and EIP-1271 Signature Verification Functions"
├── EIP712DomainSeparator — "EIP-712 Domain Separator"
├── Math — "Standard Mathematical Utility Functions"
├── MerkleProofVerification — "Merkle Tree Proof Verification Functions"
├── Multicall — "Multicall Functions"
└── interfaces
└── IERC5267 — "EIP-5267 Interface Definition"
```

## 🎛 Installation
Expand Down Expand Up @@ -101,6 +102,9 @@ In case you are using [pnpm](https://pnpm.io), invoke:
pnpm add --save-dev snekmate
```

> [!CAUTION]
> It is possible to install the latest versions of `main` or any other branch locally via `pip install git+https://github.com/pcaversaccio/snekmate.git@<branch>` or `forge install pcaversaccio/snekmate && forge update`. Each branch, **including the `main` branch**, must be understood as a development branch that should be avoided in favour of tagged releases. The release process includes security measures that the repository branches do not guarantee.
## 👩🏼‍⚖️ Tests

This repository contains [Foundry](https://github.com/foundry-rs/foundry)-based unit tests, property-based tests (i.e. fuzzing), and invariant tests for all contracts, if applicable. All tests are run as part of the CI pipeline [`test-contracts`](./.github/workflows/test-contracts.yml).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"lint:fix": "pnpm prettier:fix && pnpm solhint:fix && npx eslint . --fix"
},
"files": [
"src/**/*.vy",
"src/snekmate/**/*.vy",
"LICENSE",
"README.md",
"CHANGELOG.md"
Expand Down
28 changes: 0 additions & 28 deletions scripts/build.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/auth/AccessControl.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract AccessControlTest is Test {

function setUp() public {
accessControl = IAccessControlExtended(
vyperDeployer.deployContract("src/auth/", "AccessControl")
vyperDeployer.deployContract("src/snekmate/auth/", "AccessControl")
);
}

Expand Down Expand Up @@ -54,7 +54,7 @@ contract AccessControlTest is Test {
vm.expectEmit(true, true, true, false);
emit IAccessControl.RoleGranted(ADDITIONAL_ROLE_2, deployer, deployer);
accessControlInitialEvent = IAccessControlExtended(
vyperDeployer.deployContract("src/auth/", "AccessControl")
vyperDeployer.deployContract("src/snekmate/auth/", "AccessControl")
);
assertEq(
accessControlInitialEvent.DEFAULT_ADMIN_ROLE(),
Expand Down Expand Up @@ -645,7 +645,7 @@ contract AccessControlInvariants is Test {

function setUp() public {
accessControl = IAccessControlExtended(
vyperDeployer.deployContract("src/auth/", "AccessControl")
vyperDeployer.deployContract("src/snekmate/auth/", "AccessControl")
);
accessControlHandler = new AccessControlHandler(
accessControl,
Expand Down
6 changes: 3 additions & 3 deletions test/auth/Ownable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract OwnableTest is Test {

function setUp() public {
ownable = IOwnable(
vyperDeployer.deployContract("src/auth/", "Ownable")
vyperDeployer.deployContract("src/snekmate/auth/", "Ownable")
);
}

Expand All @@ -27,7 +27,7 @@ contract OwnableTest is Test {
vm.expectEmit(true, true, false, false);
emit IOwnable.OwnershipTransferred(zeroAddress, deployer);
ownableInitialEvent = IOwnable(
vyperDeployer.deployContract("src/auth/", "Ownable")
vyperDeployer.deployContract("src/snekmate/auth/", "Ownable")
);
assertEq(ownableInitialEvent.owner(), deployer);
}
Expand Down Expand Up @@ -142,7 +142,7 @@ contract OwnableInvariants is Test {

function setUp() public {
ownable = IOwnable(
vyperDeployer.deployContract("src/auth/", "Ownable")
vyperDeployer.deployContract("src/snekmate/auth/", "Ownable")
);
ownerHandler = new OwnerHandler(ownable, deployer);
targetContract(address(ownerHandler));
Expand Down
6 changes: 3 additions & 3 deletions test/auth/Ownable2Step.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract Ownable2StepTest is Test {

function setUp() public {
ownable2Step = IOwnable2Step(
vyperDeployer.deployContract("src/auth/", "Ownable2Step")
vyperDeployer.deployContract("src/snekmate/auth/", "Ownable2Step")
);
}

Expand All @@ -28,7 +28,7 @@ contract Ownable2StepTest is Test {
vm.expectEmit(true, true, false, false);
emit IOwnable2Step.OwnershipTransferred(zeroAddress, deployer);
ownable2StepInitialEvent = IOwnable2Step(
vyperDeployer.deployContract("src/auth/", "Ownable2Step")
vyperDeployer.deployContract("src/snekmate/auth/", "Ownable2Step")
);
assertEq(ownable2StepInitialEvent.owner(), deployer);
assertEq(ownable2StepInitialEvent.pending_owner(), zeroAddress);
Expand Down Expand Up @@ -285,7 +285,7 @@ contract Ownable2StepInvariants is Test {

function setUp() public {
ownable2Step = IOwnable2Step(
vyperDeployer.deployContract("src/auth/", "Ownable2Step")
vyperDeployer.deployContract("src/snekmate/auth/", "Ownable2Step")
);
owner2StepHandler = new Owner2StepHandler(
ownable2Step,
Expand Down
6 changes: 3 additions & 3 deletions test/extensions/ERC2981.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract ERC2981Test is Test {

function setUp() public {
ERC2981Extended = IERC2981Extended(
vyperDeployer.deployContract("src/extensions/", "ERC2981")
vyperDeployer.deployContract("src/snekmate/extensions/", "ERC2981")
);
}

Expand All @@ -40,7 +40,7 @@ contract ERC2981Test is Test {
vm.expectEmit(true, true, false, false);
emit IERC2981Extended.OwnershipTransferred(zeroAddress, deployer);
ERC2981ExtendedInitialEvent = IERC2981Extended(
vyperDeployer.deployContract("src/extensions/", "ERC2981")
vyperDeployer.deployContract("src/snekmate/extensions/", "ERC2981")
);
(
address receiverInitialSetup,
Expand Down Expand Up @@ -775,7 +775,7 @@ contract ERC2981Invariants is Test {

function setUp() public {
ERC2981Extended = IERC2981Extended(
vyperDeployer.deployContract("src/extensions/", "ERC2981")
vyperDeployer.deployContract("src/snekmate/extensions/", "ERC2981")
);
erc2981Handler = new ERC2981Handler(ERC2981Extended, deployer);
targetContract(address(erc2981Handler));
Expand Down
22 changes: 13 additions & 9 deletions test/extensions/ERC4626.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract ERC4626VaultTest is ERC4626Test {
);
ERC4626ExtendedDecimalsOffset0 = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffset0
)
Expand Down Expand Up @@ -104,7 +104,7 @@ contract ERC4626VaultTest is ERC4626Test {
);
ERC4626ExtendedDecimalsOffset6 = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffset6
)
Expand All @@ -123,7 +123,7 @@ contract ERC4626VaultTest is ERC4626Test {
);
ERC4626ExtendedDecimalsOffset12 = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffset12
)
Expand All @@ -142,7 +142,7 @@ contract ERC4626VaultTest is ERC4626Test {
);
ERC4626ExtendedDecimalsOffset18 = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffset18
)
Expand Down Expand Up @@ -196,7 +196,7 @@ contract ERC4626VaultTest is ERC4626Test {
// solhint-disable-next-line var-name-mixedcase
IERC4626Extended ERC4626ExtendedDecimalsOffsetEOA = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffsetEOA
)
Expand All @@ -223,7 +223,7 @@ contract ERC4626VaultTest is ERC4626Test {
// solhint-disable-next-line var-name-mixedcase
IERC4626Extended ERC4626ExtendedDecimalsOffsetNoDecimals = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffsetNoDecimals
)
Expand Down Expand Up @@ -251,7 +251,7 @@ contract ERC4626VaultTest is ERC4626Test {
// solhint-disable-next-line var-name-mixedcase
IERC4626Extended ERC4626ExtendedDecimalsOffsetTooHighDecimals = IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffsetTooHighDecimals
)
Expand Down Expand Up @@ -285,7 +285,7 @@ contract ERC4626VaultTest is ERC4626Test {
vm.expectRevert();
IERC4626Extended(
vyperDeployer.deployContract(
"src/extensions/",
"src/snekmate/extensions/",
"ERC4626",
argsDecimalsOffsetOverflow
)
Expand Down Expand Up @@ -2089,7 +2089,11 @@ contract ERC4626VaultInvariants is Test {
_VERSION_EIP712
);
ERC4626Extended = IERC4626Extended(
vyperDeployer.deployContract("src/extensions/", "ERC4626", args)
vyperDeployer.deployContract(
"src/snekmate/extensions/",
"ERC4626",
args
)
);
erc4626VaultHandler = new ERC4626VaultHandler(ERC4626Extended);
targetContract(address(erc4626VaultHandler));
Expand Down
Loading

0 comments on commit 32ce0fd

Please sign in to comment.