Skip to content

Commit 60f07df

Browse files
authored
Merge pull request #87 from Hats-Protocol/develop
Deploy v1-beta1
2 parents 68d7dcd + 36f558b commit 60f07df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2314
-2718
lines changed

.gas-snapshot

Lines changed: 103 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,103 @@
1-
BatchCreateHats:testBatchCreateHatsErrorArrayLength(uint256,uint256,uint256) (runs: 256, μ: 12559014, ~: 9695798)
2-
BatchCreateHats:testBatchCreateHatsSameAdmin(uint256) (runs: 256, μ: 4560900, ~: 593589)
3-
BatchCreateHats:testBatchCreateHatsSkinnyFullBranch() (gas: 8881460)
4-
BatchCreateHats:testBatchCreateOneHat() (gas: 412963)
5-
BatchCreateHats:testBatchCreateTwoHats() (gas: 593518)
6-
BatchCreateHats:testTemp() (gas: 14430)
7-
CreateHatsTest:testHatCreated() (gas: 249889)
8-
CreateHatsTest:testHatsBranchCreated() (gas: 593366)
9-
CreateTopHatTest:testTopHatCreated() (gas: 164948)
10-
CreateTopHatTest:testTopHatMinted() (gas: 183773)
11-
CreateTopHatTest:testTransferTopHat() (gas: 180085)
12-
DeployTest:testDeployWithParams() (gas: 12334)
13-
EligibilityGetHatsTests:testCannotGetHatWearerStandingNoFunctionInEligibilityContract() (gas: 26389)
14-
EligibilityGetHatsTests:testCheckEligibilityAndDoNotRevokeHatFromEligibleWearer() (gas: 60919)
15-
EligibilityGetHatsTests:testCheckEligibilityToRevokeHatFromEligibleWearerInBadStanding() (gas: 72627)
16-
EligibilityGetHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInBadStanding() (gas: 72597)
17-
EligibilityGetHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInGoodStanding() (gas: 52331)
18-
EligibilitySetHatsTests:testCannotRevokeHatAsNonWearer() (gas: 25735)
19-
EligibilitySetHatsTests:testDoNotRevokeHatFromEligibleWearerInGoodStanding() (gas: 54141)
20-
EligibilitySetHatsTests:testRemintAfterRevokeHatFromWearerInGoodStanding() (gas: 88039)
21-
EligibilitySetHatsTests:testRevokeHatFromEligibleWearerInBadStanding() (gas: 67745)
22-
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInBadStanding() (gas: 67711)
23-
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInGoodStanding() (gas: 50103)
24-
ImageURITest:testEmptyHatBranchImageURI() (gas: 895843)
25-
ImageURITest:testEmptyHatImageURI() (gas: 163187)
26-
ImageURITest:testEmptyTopHatImageURI() (gas: 115566)
27-
ImageURITest:testHatImageURI() (gas: 21901)
28-
ImageURITest:testTopHatImageURI() (gas: 21751)
29-
MintHatsTest:testBatchMintHats(uint256) (runs: 256, μ: 2240070, ~: 382866)
30-
MintHatsTest:testBatchMintHatsErrorArrayLength(uint256,uint256) (runs: 256, μ: 10579308, ~: 12202061)
31-
MintHatsTest:testCannotMint2HatsToSameWearer() (gas: 163631)
32-
MintHatsTest:testCannotMintMoreThanMaxSupplyErrorAllHatsWorn() (gas: 210742)
33-
MintHatsTest:testCannotMintNonExistentHat() (gas: 23240)
34-
MintHatsTest:testMintAnotherHat() (gas: 185940)
35-
MintHatsTest:testMintHat() (gas: 125481)
36-
MintHatsTest:testMintHatErrorNotAdmin() (gas: 69875)
37-
MintHatsTest:testMintInactiveHat() (gas: 110370)
38-
OverridesHatTests:testCreateUri() (gas: 156002)
39-
OverridesHatTests:testCreateUriForTopHat() (gas: 153936)
40-
OverridesHatTests:testFailSafeTransferFrom() (gas: 12615)
41-
OverridesHatTests:testFailSetApprovalForAll() (gas: 7773)
42-
RenounceHatsTest:testCannotRenounceHatAsNonWearer() (gas: 34523)
43-
RenounceHatsTest:testRenounceHat() (gas: 44068)
44-
ToggleGetHatsTest:testCannotCheckHatStatusNoFunctionInToggleContract() (gas: 24012)
45-
ToggleGetHatsTest:testCheckToggleToActivateDeactivatedHat() (gas: 50151)
46-
ToggleGetHatsTest:testCheckToggleToDeactivateHat() (gas: 41533)
47-
ToggleSetHatsTest:testActivateDeactivatedHat() (gas: 46029)
48-
ToggleSetHatsTest:testCannotActivateDeactivatedHatAsNonWearer() (gas: 25986)
49-
ToggleSetHatsTest:testCannotDeactivateHatAsNonWearer() (gas: 15614)
50-
ToggleSetHatsTest:testDeactivateHat() (gas: 55730)
51-
TransferHatTests:testCannotTransferHatFromNonAdmin() (gas: 37339)
52-
TransferHatTests:testTransferHat() (gas: 103063)
53-
ViewHatTests:testGetHatLevel() (gas: 11612)
54-
ViewHatTests:testIsAdminOfHat() (gas: 29647)
55-
ViewHatTests:testViewHat() (gas: 32363)
56-
ViewHatTests:testViewHatOfTopHat() (gas: 28580)
1+
BatchCreateHats:testBatchCreateHatsErrorArrayLength(uint256,uint256,uint256) (runs: 256, μ: 11849226, ~: 9193131)
2+
BatchCreateHats:testBatchCreateHatsSameAdmin(uint256) (runs: 256, μ: 5039763, ~: 717488)
3+
BatchCreateHats:testBatchCreateHatsSkinnyFullBranch() (gas: 3989145)
4+
BatchCreateHats:testBatchCreateOneHat() (gas: 445344)
5+
BatchCreateHats:testBatchCreateTwoHats() (gas: 626716)
6+
CreateHatsTest:testHatsBranchCreated() (gas: 431155)
7+
CreateHatsTest:testImmutableHatCreated() (gas: 183092)
8+
CreateHatsTest:testMutableHatCreated() (gas: 188197)
9+
CreateTopHatTest:testTopHatCreated() (gas: 186028)
10+
CreateTopHatTest:testTopHatMinted() (gas: 202080)
11+
CreateTopHatTest:testTransferTopHat() (gas: 201039)
12+
DeployTest:testDeployWithParams() (gas: 12321)
13+
EligibilityCheckHatsTests:testCannotGetHatWearerStandingNoFunctionInEligibilityContract() (gas: 26522)
14+
EligibilityCheckHatsTests:testCheckEligibilityAndDoNotRevokeHatFromEligibleWearer() (gas: 53472)
15+
EligibilityCheckHatsTests:testCheckEligibilityToRevokeHatFromEligibleWearerInBadStanding() (gas: 73263)
16+
EligibilityCheckHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInBadStanding() (gas: 73208)
17+
EligibilityCheckHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInGoodStanding() (gas: 49129)
18+
EligibilityCheckHatsTests:testCheckWearerBackInGoodStanding() (gas: 56655)
19+
EligibilitySetHatsTests:testCannotRevokeHatAsNonWearer() (gas: 25865)
20+
EligibilitySetHatsTests:testDoNotRevokeHatFromEligibleWearerInGoodStanding() (gas: 48680)
21+
EligibilitySetHatsTests:testRemintAfterRevokeHatFromWearerInGoodStanding() (gas: 87132)
22+
EligibilitySetHatsTests:testRevokeHatFromEligibleWearerInBadStanding() (gas: 68367)
23+
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInBadStanding() (gas: 68352)
24+
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInGoodStanding() (gas: 46906)
25+
EligibilitySetHatsTests:testSetWearerBackInGoodStanding() (gas: 52732)
26+
ImageURITest:testEmptyHatBranchImageURI() (gas: 775078)
27+
ImageURITest:testEmptyHatImageURI() (gas: 154977)
28+
ImageURITest:testEmptyTopHatImageURI() (gas: 104987)
29+
ImageURITest:testHatImageURI() (gas: 21949)
30+
ImageURITest:testTopHatImageURI() (gas: 21971)
31+
LinkHatsTests:testAdminCanApproveLinkRequest() (gas: 136110)
32+
LinkHatsTests:testAdminCanApproveLinkToLastLevelHat() (gas: 412762)
33+
LinkHatsTests:testAdminCanRelinkTopHatWithinTree() (gas: 154944)
34+
LinkHatsTests:testAdminCanRequestNewLink() (gas: 155132)
35+
LinkHatsTests:testCannotApproveCrossTreeLink() (gas: 269694)
36+
LinkHatsTests:testCannotApproveUnrequestedLink() (gas: 64053)
37+
LinkHatsTests:testCannotCrossTreeRelink() (gas: 249671)
38+
LinkHatsTests:testLinkedTopHatWearerCannotRequestNewLink() (gas: 147814)
39+
LinkHatsTests:testNewAdminAdminCanApproveNewLinkRequest() (gas: 150686)
40+
LinkHatsTests:testNewAdminAdminCanRelinkToLastLevelWithinTree() (gas: 461680)
41+
LinkHatsTests:testNewAdminNonAdminCannotRelinkToLastLevelWithinTree() (gas: 324799)
42+
LinkHatsTests:testNewAdminNonAdminNonWearerCannotRelink() (gas: 155358)
43+
LinkHatsTests:testNewAdminWearerCanRelinkTopHatWithinTree() (gas: 252381)
44+
LinkHatsTests:testNonAdminNonWearerCannotApproveLinktoLastLevelHat() (gas: 421352)
45+
LinkHatsTests:testPreventingCircularLinking() (gas: 184644)
46+
LinkHatsTests:testRelinkingCannotCreateCircularLink() (gas: 378831)
47+
LinkHatsTests:testRequestLinking() (gas: 63092)
48+
LinkHatsTests:testTreeLinkingAndUnlinking() (gas: 172132)
49+
LinkHatsTests:testTreeRootNonAdminCannotRelink() (gas: 222817)
50+
LinkHatsTests:testWearerCanApproveLinkRequest() (gas: 113041)
51+
LinkHatsTests:testWearerCanApproveLinkToLastLevelHat() (gas: 385939)
52+
MintHatsTest:testBatchMintHats(uint256) (runs: 256, μ: 1838853, ~: 320023)
53+
MintHatsTest:testBatchMintHatsErrorArrayLength(uint256,uint256) (runs: 256, μ: 10343041, ~: 11993023)
54+
MintHatsTest:testCannotMint2HatsToSameWearer() (gas: 147875)
55+
MintHatsTest:testCannotMintMoreThanMaxSupplyErrorAllHatsWorn() (gas: 197678)
56+
MintHatsTest:testCannotMintNonExistentHat() (gas: 23375)
57+
MintHatsTest:testMintAnotherHat() (gas: 169666)
58+
MintHatsTest:testMintHat() (gas: 109611)
59+
MintHatsTest:testMintHatErrorNotAdmin() (gas: 71430)
60+
MintHatsTest:testMintInactiveHat() (gas: 96201)
61+
MutabilityTests:testAdminCanChangeMutableHatDetails() (gas: 66403)
62+
MutabilityTests:testAdminCanChangeMutableHatEligibility() (gas: 63145)
63+
MutabilityTests:testAdminCanChangeMutableHatImageURI() (gas: 66457)
64+
MutabilityTests:testAdminCanChangeMutableHatToggle() (gas: 60848)
65+
MutabilityTests:testAdminCanDecreaseMutableHatMaxSupplyToAboveCurrentSupply() (gas: 120154)
66+
MutabilityTests:testAdminCanDecreaseMutableHatMaxSupplyToEqualToCurrentSupply() (gas: 120143)
67+
MutabilityTests:testAdminCanIncreaseMutableHatMaxSupply() (gas: 63303)
68+
MutabilityTests:testAdminCanMakeMutableHatImmutable() (gas: 73888)
69+
MutabilityTests:testAdminCannotChangeImutableHatProperties() (gas: 229106)
70+
MutabilityTests:testAdminCannotDecreaseMutableHatMaxSupplyBelowCurrentSupply() (gas: 151744)
71+
MutabilityTests:testAdminCannotTransferImmutableHat() (gas: 235513)
72+
MutabilityTests:testCannotChangeImmutableHatMutability() (gas: 187790)
73+
MutabilityTests:testNonAdminCannotMakeMutableHatImmutable() (gas: 33944)
74+
MutabilityTests:testTopHatCanChangeOwnDetails() (gas: 52953)
75+
MutabilityTests:testTopHatCanChangeOwnImageURI() (gas: 52943)
76+
MutabilityTests:testTopHatCannotChangeOtherProperties() (gas: 78149)
77+
OverridesHatTests:testCreateUri() (gas: 95376)
78+
OverridesHatTests:testCreateUriForTopHat() (gas: 93902)
79+
OverridesHatTests:testFailSafeTransferFrom() (gas: 12633)
80+
OverridesHatTests:testFailSetApprovalForAll() (gas: 7687)
81+
RenounceHatsTest:testCannotRenounceHatAsNonWearer() (gas: 34646)
82+
RenounceHatsTest:testRenounceHat() (gas: 43499)
83+
ToggleGetHatsTest:testCannotCheckHatStatusNoFunctionInToggleContract() (gas: 24155)
84+
ToggleGetHatsTest:testCheckToggleToActivateDeactivatedHat() (gas: 81623)
85+
ToggleGetHatsTest:testCheckToggleToDeactivateHat() (gas: 51003)
86+
ToggleSetHatsTest:testActivateDeactivatedHat() (gas: 77491)
87+
ToggleSetHatsTest:testCannotActivateDeactivatedHatAsNonWearer() (gas: 32110)
88+
ToggleSetHatsTest:testCannotDeactivateHatAsNonWearer() (gas: 15664)
89+
ToggleSetHatsTest:testDeactivateHat() (gas: 90499)
90+
TransferHatTests:testCannotTransferHatFromNonAdmin() (gas: 40895)
91+
TransferHatTests:testCannotTransferHatToExistingWearer() (gas: 102641)
92+
TransferHatTests:testCannotTransferHatToRevokedWearer() (gas: 111874)
93+
TransferHatTests:testTransferMutableHat() (gas: 103181)
94+
ViewHatTests:testGetHatLevel() (gas: 14166)
95+
ViewHatTests:testIsAdminOfHat() (gas: 32615)
96+
ViewHatTests:testViewHat1() (gas: 97637)
97+
ViewHatTests:testViewHat2() (gas: 72640)
98+
ViewHatTests:testViewHatOfTopHat1() (gas: 73622)
99+
ViewHatTests:testViewHatOfTopHat2() (gas: 72618)
100+
HatIdUtilTests:testBuildHatId() (gas: 87934)
101+
HatIdUtilTests:testTopHatDomain() (gas: 14345)
102+
HatIdUtilTests:testgetHatLevel() (gas: 143322)
103+
LinkedTreeHatIdUtilTests:testLinkedHats() (gas: 90621)

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,11 @@ jobs:
3232
with:
3333
version: nightly
3434

35-
- name: Run tests
36-
run: forge test -vvv
35+
- name: Check formatting
36+
run: forge fmt --check
37+
38+
- name: Check contract sizes
39+
run: forge build --sizes --skip script
40+
41+
- name: Run tests w/ gas report
42+
run: forge test -vvv --gas-report

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
with:
15+
submodules: recursive
16+
17+
- name: Install Foundry
18+
uses: foundry-rs/foundry-toolchain@v1
19+
with:
20+
version: nightly
21+
22+
- name: Setup Pages
23+
uses: actions/configure-pages@v2
24+
25+
- name: Build mdBook
26+
run: forge doc --build
27+
28+
- name: Upload Artifact
29+
uses: actions/upload-pages-artifact@v1
30+
with:
31+
path: ./docs/book
32+
name: github-pages
33+
retention-days: 1
34+
35+
deploy:
36+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
37+
permissions:
38+
pages: write # to deploy to Pages
39+
id-token: write # to verify the deployment originates from an appropriate source
40+
environment:
41+
name: github-pages
42+
url: ${{ steps.deployment.outputs.page_url }}
43+
runs-on: ubuntu-latest
44+
needs: build
45+
steps:
46+
- name: Deploy to GitHub Pages
47+
id: deployment
48+
uses: actions/deploy-pages@v1

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cache/
22
out/
33
.vscode/
4-
broadcast/*/31337
5-
broadcast/*/*/dry-run
4+
broadcast/
65
.env
7-
uri.json
6+
uri.json
7+
docs/

CONTRIBUTING.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Contributing to Hats Protocol
2+
3+
Thank you for considering contributing to Hats Protocol. We welcome any contributions that can help improve the project, including bug reports, feature requests, and code changes.
4+
5+
## Getting Started
6+
7+
1. Fork the Project
8+
2. Install [Foundry](https://book.getfoundry.sh/getting-started/installation)
9+
3. Compile the contracts, run `forge build`, and to test, run `forge test`
10+
4. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
11+
5. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
12+
6. Push to the Branch (`git push origin feature/AmazingFeature`)
13+
7. Open a Pull Request — see the [checklist below](#pull-request-readiness-checklist) for what your PR should include
14+
15+
Existing deployments of Hats Protocol can be found in [Releases](https://github.com/Hats-Protocol/hats-protocol/releases). To deploy Hats Protocol yourself (e.g., for testing):
16+
17+
- Install [Foundry](https://book.getfoundry.sh/getting-started/installation)
18+
- Compile the contracts, run `forge build`, and to test, run `forge test`
19+
- Deploy using the [Hats.s.sol script](script/Hats.s.sol) and follow the [Foundry scripting instructions](https://book.getfoundry.sh/tutorials/solidity-scripting)
20+
21+
## Code and Style Conventions
22+
23+
Hats Protocol follows certain conventions, including:
24+
25+
- Use custom errors (rather than in-line require statement strings), added to [HatsErrors.sol](src/Interfaces/HatsErrors.sol)
26+
- New events should be added to [HatsEvents.sol](src/Interfaces/HatsEvents.sol)
27+
- All new public or external functions should be added to the appropriate interface file, such as [IHats.sol](src/Interfaces/IHats.sol) or [IHatsIdUtilities.sol](src/Interfaces/IHatsIdUtilities.sol)
28+
- We format all markdown according to the settings in [.markdownlintrc](./.markdownlintrc)
29+
- All Solidity is formatted using Foundry's native formatter [forge fmt](https://github.com/foundry-rs/foundry/tree/master/fmt), currently using the following settings (also viewable in [foundry.toml](./foundry.toml)):
30+
31+
| `forge fmt` setting | our value |
32+
| -------------------------------- | ----------- |
33+
| line_length | 120 |
34+
| tab_width | 4 |
35+
| bracket_spacing | true |
36+
| int_types | long |
37+
| multiline_func_header | attributes_first |
38+
| quote_style | double |
39+
| number_underscore | thousands |
40+
| override_spacing | true |
41+
| wrap_comments | true |
42+
43+
## Documentation
44+
45+
All code changes should be accompanied by updates to documentation:
46+
47+
- Document all new functions (external and internal), data models, and state variables with [Solidity NatSpec](https://docs.soliditylang.org/en/v0.8.17/natspec-format.html)
48+
- The above will be produced in an mdBook via Foundry's [forge doc](https://github.com/foundry-rs/foundry/tree/master/doc) module
49+
- Update the [README](./README.md) and/or developer docs as needed
50+
51+
We also welcome contributions to the project's documentation itself!
52+
53+
## Testing
54+
55+
We require that all new code changes are thoroughly tested to ensure that the project remains stable and reliable. When submitting a pull request, please make sure to:
56+
57+
- Write thorough unit tests for all new code
58+
- Ensure that all tests (existing and new) are passing
59+
- Track test coverage with Foundry's `forge coverage` module
60+
- Verify that contract sizes are under the [EIP-170 limit](https://eips.ethereum.org/EIPS/eip-170) when compiled with the optimizer set to at least `10_000` runs
61+
62+
## Pull Request Readiness Checklist
63+
64+
In summary, before submitting a PR, please complete each of the following items. Items that are explicitly checked in our [CI workflow](./.github/workflows/ci.yml) are flagged with "**(ci)**".
65+
66+
1. Thorough unit tests are written for all new code
67+
2. Update the [test coverage tracker](./lcov.info) — run `forge coverage --report lcov`
68+
3. Update the [gas snapshot tracker](./.gas-snapshot) — run `forge snapshot`
69+
4. Ensure contract sizes are small enough to deploy — run `forge build --sizes` **(ci)**
70+
5. Ensure all existing and new tests are passing — run `forge test` **(ci)**
71+
6. Document all new Solidity code with NatSpec, and generate updated docs — run `forge doc`
72+
7. Update the [README](./README.md) with any new or changed functionality
73+
8. Ensure all markdown is formatted correctly — run `forge fmt` **(ci)**
74+
75+
## Contact Information
76+
77+
If you have any questions or need assistance with contributing to the Hats Protocol, please feel free to reach out to the project maintainers. Contact information can be found in the [README](./README.md#contact) file.
78+
79+
Thank you for your contributions!

0 commit comments

Comments
 (0)