Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 Add a pausable Contract Module #297

Merged
merged 10 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 101 additions & 91 deletions .gas-snapshot

Large diffs are not rendered by default.

832 changes: 421 additions & 411 deletions .gas-snapshot-venom

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
with:
check_filenames: true
skip: ./.git,pnpm-lock.yaml
ignore_words_list: pre-emptive

validate-links:
runs-on: ${{ matrix.os }}
Expand All @@ -89,7 +90,7 @@ jobs:
os:
- ubuntu-latest
ruby_version:
- 3.3
- 3.4

steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/halmos-venom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
run: forge config
env:
FOUNDRY_PROFILE: halmos-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Run Halmos ERC-20 symbolic tests
run: halmos --contract ERC20TestHalmos ${{ matrix.halmos }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/halmos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
run: forge config
env:
FOUNDRY_PROFILE: halmos
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Run Halmos ERC-20 symbolic tests
run: halmos --contract ERC20TestHalmos ${{ matrix.halmos }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-contracts-venom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,25 @@ jobs:
run: forge config
env:
FOUNDRY_PROFILE: ci-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Foundry tests
run: forge test
env:
FOUNDRY_PROFILE: ci-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Show the Foundry default config
run: forge config
env:
FOUNDRY_PROFILE: default-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Run snapshot
run: NO_COLOR=1 forge snapshot >> $GITHUB_STEP_SUMMARY
env:
FOUNDRY_PROFILE: default-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Install Homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand All @@ -101,11 +105,13 @@ jobs:
run: forge config
env:
FOUNDRY_PROFILE: echidna-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Compile the Echidna test contracts
run: forge build --build-info
env:
FOUNDRY_PROFILE: echidna-venom
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Run Echidna ERC-20 property tests
run: echidna test/tokens/echidna/ERC20Properties.sol --contract CryticERC20ExternalHarness ${{ matrix.echidna }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,25 @@ jobs:
run: forge config
env:
FOUNDRY_PROFILE: ci
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Foundry tests
run: forge test
env:
FOUNDRY_PROFILE: ci
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Show the Foundry default config
run: forge config
env:
FOUNDRY_PROFILE: default
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Run snapshot
run: NO_COLOR=1 forge snapshot >> $GITHUB_STEP_SUMMARY
env:
FOUNDRY_PROFILE: default
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Install Homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand All @@ -112,11 +116,13 @@ jobs:
run: forge config
env:
FOUNDRY_PROFILE: echidna
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Compile the Echidna test contracts
run: forge build --build-info
env:
FOUNDRY_PROFILE: echidna
FOUNDRY_DISABLE_NIGHTLY_WARNING: "1"

- name: Run Echidna ERC-20 property tests
run: echidna test/tokens/echidna/ERC20Properties.sol --contract CryticERC20ExternalHarness ${{ matrix.echidna }}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [`0.1.1`](https://github.com/pcaversaccio/snekmate/releases/tag/v0.1.1) (Unreleased)

### 💥 New Features

- **Utility Functions**
- [`pausable`](https://github.com/pcaversaccio/snekmate/blob/v0.1.1/src/snekmate/utils/pausable.vy): Add a `pausable` contract module. ([#297](https://github.com/pcaversaccio/snekmate/pull/297))

### ♻️ Refactoring

- **Authentication**
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ src
├── math — "Standard Mathematical Utility Functions"
├── merkle_proof_verification — "Merkle Tree Proof Verification Functions"
├── multicall — "Multicall Functions"
├── pausable — "Pausable Functions"
├── interfaces
│ ├── IERC1271 — "EIP-1271 Interface Definition"
│ └── IERC5267 — "EIP-5267 Interface Definition"
Expand All @@ -98,7 +99,8 @@ src
├── eip712_domain_separator_mock — "`eip712_domain_separator` Module Reference Implementation"
├── math_mock — "`math` Module Reference Implementation"
├── merkle_proof_verification_mock — "`merkle_proof_verification` Module Reference Implementation"
└── multicall_mock — "`multicall` Module Reference Implementation"
├── multicall_mock — "`multicall` Module Reference Implementation"
└── pausable_mock — "`pausable` Module Reference Implementation"
```

## 🎛 Installation
Expand Down Expand Up @@ -191,6 +193,7 @@ This repository contains [Foundry](https://github.com/foundry-rs/foundry)-based
| `math` | ✅ | ✅ | ❌ |
| `merkle_proof_verification` | ✅ | ✅ | ❌ |
| `multicall` | ✅ | ❌ | ❌ |
| `pausable` | ✅ | ✅ | ✅ |

✅ Test Type Implemented   ❌ Test Type Not Implemented

Expand Down
2 changes: 1 addition & 1 deletion lib/create-util
Submodule create-util updated 2 files
+1 −1 package.json
+59 −59 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion lib/forge-std
2 changes: 1 addition & 1 deletion lib/solady
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion scripts/generate_gas_snapshot.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/usr/bin/env bash

# Enable strict error handling:
# -E: Inherit `ERR` traps in functions and subshells.
# -e: Exit immediately if a command exits with a non-zero status.
# -u: Treat unset variables as an error and exit.
# -o pipefail: Return the exit status of the first failed command in a pipeline.
set -Eeuo pipefail

# Enable debug mode if the environment variable `DEBUG` is set to `true`.
if [[ "${DEBUG:-false}" == "true" ]]; then
# Print each command before executing it.
set -x
fi

# Set the default values.
OUTPUT_FILE=".gas-snapshot"
FOUNDRY_PROFILE="default"
Expand All @@ -16,6 +29,16 @@ prepend_to_output() {
echo "$1" >> "$TEMP_FILE"
}

# Utility function to parse the output of `forge --version` and transform it.
forge_version=$(forge --version | awk '
/^forge Version:/ { version = $3 }
/Commit SHA:/ { sha = substr($3, 1, 7) }
/Build Timestamp:/ { timestamp = $3 }
END {
print "forge", version, "(" sha, timestamp ")"
}
')

# Parse the command line arguments.
while [[ "$#" -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -44,7 +67,7 @@ forge snapshot --snap "$OUTPUT_FILE"

# Prepare the content to be prepended.
prepend_to_output "Vyper version: $(vyper --version)"
prepend_to_output "Forge version: $(forge --version)"
prepend_to_output "Forge version: $forge_version"
prepend_to_output "Vyper config:"
forge config --json | jq -r ".vyper" >> "$TEMP_FILE"
prepend_to_output "=========================================="
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/access_control.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Multi-Role-Based Access Control Functions
@custom:contract-name access_control
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/interfaces/IAccessControl.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `access_control` Interface Definition
@custom:contract-name IAccessControl
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/mocks/access_control_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `access_control` Module Reference Implementation
@custom:contract-name access_control_mock
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/mocks/ownable_2step_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `ownable_2step` Module Reference Implementation
@custom:contract-name ownable_2step_mock
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/mocks/ownable_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `ownable` Module Reference Implementation
@custom:contract-name ownable_mock
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/ownable.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Owner-Based Access Control Functions
@custom:contract-name ownable
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/auth/ownable_2step.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title 2-Step Ownership Transfer Functions
@custom:contract-name ownable_2step
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/extensions/erc2981.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title ERC-721 and ERC-1155 Compatible ERC-2981 Reference Implementation
@custom:contract-name erc2981
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/extensions/erc4626.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Modern and Gas-Efficient ERC-4626 Tokenised Vault Implementation
@custom:contract-name erc4626
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/extensions/interfaces/IERC2981.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-2981 Interface Definition
@custom:contract-name IERC2981
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/extensions/mocks/erc2981_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `erc2981` Module Reference Implementation
@custom:contract-name erc2981_mock
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/extensions/mocks/erc4626_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `erc4626` Module Reference Implementation
@custom:contract-name erc4626_mock
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/governance/mocks/timelock_controller_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `timelock_controller` Module Reference Implementation
@custom:contract-name timelock_controller_mock
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/governance/timelock_controller.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Multi-Role-Based Timelock Controller Reference Implementation
@custom:contract-name timelock_controller
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/erc1155.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Modern and Gas-Efficient ERC-1155 Implementation
@custom:contract-name erc1155
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/erc20.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Modern and Gas-Efficient ERC-20 + EIP-2612 Implementation
@custom:contract-name erc20
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/erc721.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title Modern and Gas-Efficient ERC-721 + EIP-4494 Implementation
@custom:contract-name erc721
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC1155.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-1155 Interface Definition
@custom:contract-name IERC1155
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC1155MetadataURI.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-1155 Optional Metadata Interface Definition
@custom:contract-name IERC1155MetadataURI
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC1155Receiver.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-1155 Token Receiver Interface Definition
@custom:contract-name IERC1155Receiver
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC20Permit.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-2612 Interface Definition
@custom:contract-name IERC20Permit
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC4906.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-4906 Interface Definition
@custom:contract-name IERC4906
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC721Enumerable.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-721 Optional Enumeration Interface Definition
@custom:contract-name IERC721Enumerable
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC721Metadata.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-721 Optional Metadata Interface Definition
@custom:contract-name IERC721Metadata
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC721Permit.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-4494 Interface Definition
@custom:contract-name IERC721Permit
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/interfaces/IERC721Receiver.vyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title EIP-721 Token Receiver Interface Definition
@custom:contract-name IERC721Receiver
Expand Down
2 changes: 1 addition & 1 deletion src/snekmate/tokens/mocks/erc1155_mock.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pragma version ~=0.4.1b5
# pragma version ~=0.4.1rc2
"""
@title `erc1155` Module Reference Implementation
@custom:contract-name erc1155_mock
Expand Down
Loading
Loading