Skip to content

Commit

Permalink
Merge pull request #87 from Hats-Protocol/develop
Browse files Browse the repository at this point in the history
Deploy v1-beta1
  • Loading branch information
spengrah committed Jan 26, 2023
2 parents 68d7dcd + 36f558b commit 60f07df
Show file tree
Hide file tree
Showing 46 changed files with 2,314 additions and 2,718 deletions.
159 changes: 103 additions & 56 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,56 +1,103 @@
BatchCreateHats:testBatchCreateHatsErrorArrayLength(uint256,uint256,uint256) (runs: 256, μ: 12559014, ~: 9695798)
BatchCreateHats:testBatchCreateHatsSameAdmin(uint256) (runs: 256, μ: 4560900, ~: 593589)
BatchCreateHats:testBatchCreateHatsSkinnyFullBranch() (gas: 8881460)
BatchCreateHats:testBatchCreateOneHat() (gas: 412963)
BatchCreateHats:testBatchCreateTwoHats() (gas: 593518)
BatchCreateHats:testTemp() (gas: 14430)
CreateHatsTest:testHatCreated() (gas: 249889)
CreateHatsTest:testHatsBranchCreated() (gas: 593366)
CreateTopHatTest:testTopHatCreated() (gas: 164948)
CreateTopHatTest:testTopHatMinted() (gas: 183773)
CreateTopHatTest:testTransferTopHat() (gas: 180085)
DeployTest:testDeployWithParams() (gas: 12334)
EligibilityGetHatsTests:testCannotGetHatWearerStandingNoFunctionInEligibilityContract() (gas: 26389)
EligibilityGetHatsTests:testCheckEligibilityAndDoNotRevokeHatFromEligibleWearer() (gas: 60919)
EligibilityGetHatsTests:testCheckEligibilityToRevokeHatFromEligibleWearerInBadStanding() (gas: 72627)
EligibilityGetHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInBadStanding() (gas: 72597)
EligibilityGetHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInGoodStanding() (gas: 52331)
EligibilitySetHatsTests:testCannotRevokeHatAsNonWearer() (gas: 25735)
EligibilitySetHatsTests:testDoNotRevokeHatFromEligibleWearerInGoodStanding() (gas: 54141)
EligibilitySetHatsTests:testRemintAfterRevokeHatFromWearerInGoodStanding() (gas: 88039)
EligibilitySetHatsTests:testRevokeHatFromEligibleWearerInBadStanding() (gas: 67745)
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInBadStanding() (gas: 67711)
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInGoodStanding() (gas: 50103)
ImageURITest:testEmptyHatBranchImageURI() (gas: 895843)
ImageURITest:testEmptyHatImageURI() (gas: 163187)
ImageURITest:testEmptyTopHatImageURI() (gas: 115566)
ImageURITest:testHatImageURI() (gas: 21901)
ImageURITest:testTopHatImageURI() (gas: 21751)
MintHatsTest:testBatchMintHats(uint256) (runs: 256, μ: 2240070, ~: 382866)
MintHatsTest:testBatchMintHatsErrorArrayLength(uint256,uint256) (runs: 256, μ: 10579308, ~: 12202061)
MintHatsTest:testCannotMint2HatsToSameWearer() (gas: 163631)
MintHatsTest:testCannotMintMoreThanMaxSupplyErrorAllHatsWorn() (gas: 210742)
MintHatsTest:testCannotMintNonExistentHat() (gas: 23240)
MintHatsTest:testMintAnotherHat() (gas: 185940)
MintHatsTest:testMintHat() (gas: 125481)
MintHatsTest:testMintHatErrorNotAdmin() (gas: 69875)
MintHatsTest:testMintInactiveHat() (gas: 110370)
OverridesHatTests:testCreateUri() (gas: 156002)
OverridesHatTests:testCreateUriForTopHat() (gas: 153936)
OverridesHatTests:testFailSafeTransferFrom() (gas: 12615)
OverridesHatTests:testFailSetApprovalForAll() (gas: 7773)
RenounceHatsTest:testCannotRenounceHatAsNonWearer() (gas: 34523)
RenounceHatsTest:testRenounceHat() (gas: 44068)
ToggleGetHatsTest:testCannotCheckHatStatusNoFunctionInToggleContract() (gas: 24012)
ToggleGetHatsTest:testCheckToggleToActivateDeactivatedHat() (gas: 50151)
ToggleGetHatsTest:testCheckToggleToDeactivateHat() (gas: 41533)
ToggleSetHatsTest:testActivateDeactivatedHat() (gas: 46029)
ToggleSetHatsTest:testCannotActivateDeactivatedHatAsNonWearer() (gas: 25986)
ToggleSetHatsTest:testCannotDeactivateHatAsNonWearer() (gas: 15614)
ToggleSetHatsTest:testDeactivateHat() (gas: 55730)
TransferHatTests:testCannotTransferHatFromNonAdmin() (gas: 37339)
TransferHatTests:testTransferHat() (gas: 103063)
ViewHatTests:testGetHatLevel() (gas: 11612)
ViewHatTests:testIsAdminOfHat() (gas: 29647)
ViewHatTests:testViewHat() (gas: 32363)
ViewHatTests:testViewHatOfTopHat() (gas: 28580)
BatchCreateHats:testBatchCreateHatsErrorArrayLength(uint256,uint256,uint256) (runs: 256, μ: 11849226, ~: 9193131)
BatchCreateHats:testBatchCreateHatsSameAdmin(uint256) (runs: 256, μ: 5039763, ~: 717488)
BatchCreateHats:testBatchCreateHatsSkinnyFullBranch() (gas: 3989145)
BatchCreateHats:testBatchCreateOneHat() (gas: 445344)
BatchCreateHats:testBatchCreateTwoHats() (gas: 626716)
CreateHatsTest:testHatsBranchCreated() (gas: 431155)
CreateHatsTest:testImmutableHatCreated() (gas: 183092)
CreateHatsTest:testMutableHatCreated() (gas: 188197)
CreateTopHatTest:testTopHatCreated() (gas: 186028)
CreateTopHatTest:testTopHatMinted() (gas: 202080)
CreateTopHatTest:testTransferTopHat() (gas: 201039)
DeployTest:testDeployWithParams() (gas: 12321)
EligibilityCheckHatsTests:testCannotGetHatWearerStandingNoFunctionInEligibilityContract() (gas: 26522)
EligibilityCheckHatsTests:testCheckEligibilityAndDoNotRevokeHatFromEligibleWearer() (gas: 53472)
EligibilityCheckHatsTests:testCheckEligibilityToRevokeHatFromEligibleWearerInBadStanding() (gas: 73263)
EligibilityCheckHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInBadStanding() (gas: 73208)
EligibilityCheckHatsTests:testCheckEligibilityToRevokeHatFromIneligibleWearerInGoodStanding() (gas: 49129)
EligibilityCheckHatsTests:testCheckWearerBackInGoodStanding() (gas: 56655)
EligibilitySetHatsTests:testCannotRevokeHatAsNonWearer() (gas: 25865)
EligibilitySetHatsTests:testDoNotRevokeHatFromEligibleWearerInGoodStanding() (gas: 48680)
EligibilitySetHatsTests:testRemintAfterRevokeHatFromWearerInGoodStanding() (gas: 87132)
EligibilitySetHatsTests:testRevokeHatFromEligibleWearerInBadStanding() (gas: 68367)
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInBadStanding() (gas: 68352)
EligibilitySetHatsTests:testRevokeHatFromIneligibleWearerInGoodStanding() (gas: 46906)
EligibilitySetHatsTests:testSetWearerBackInGoodStanding() (gas: 52732)
ImageURITest:testEmptyHatBranchImageURI() (gas: 775078)
ImageURITest:testEmptyHatImageURI() (gas: 154977)
ImageURITest:testEmptyTopHatImageURI() (gas: 104987)
ImageURITest:testHatImageURI() (gas: 21949)
ImageURITest:testTopHatImageURI() (gas: 21971)
LinkHatsTests:testAdminCanApproveLinkRequest() (gas: 136110)
LinkHatsTests:testAdminCanApproveLinkToLastLevelHat() (gas: 412762)
LinkHatsTests:testAdminCanRelinkTopHatWithinTree() (gas: 154944)
LinkHatsTests:testAdminCanRequestNewLink() (gas: 155132)
LinkHatsTests:testCannotApproveCrossTreeLink() (gas: 269694)
LinkHatsTests:testCannotApproveUnrequestedLink() (gas: 64053)
LinkHatsTests:testCannotCrossTreeRelink() (gas: 249671)
LinkHatsTests:testLinkedTopHatWearerCannotRequestNewLink() (gas: 147814)
LinkHatsTests:testNewAdminAdminCanApproveNewLinkRequest() (gas: 150686)
LinkHatsTests:testNewAdminAdminCanRelinkToLastLevelWithinTree() (gas: 461680)
LinkHatsTests:testNewAdminNonAdminCannotRelinkToLastLevelWithinTree() (gas: 324799)
LinkHatsTests:testNewAdminNonAdminNonWearerCannotRelink() (gas: 155358)
LinkHatsTests:testNewAdminWearerCanRelinkTopHatWithinTree() (gas: 252381)
LinkHatsTests:testNonAdminNonWearerCannotApproveLinktoLastLevelHat() (gas: 421352)
LinkHatsTests:testPreventingCircularLinking() (gas: 184644)
LinkHatsTests:testRelinkingCannotCreateCircularLink() (gas: 378831)
LinkHatsTests:testRequestLinking() (gas: 63092)
LinkHatsTests:testTreeLinkingAndUnlinking() (gas: 172132)
LinkHatsTests:testTreeRootNonAdminCannotRelink() (gas: 222817)
LinkHatsTests:testWearerCanApproveLinkRequest() (gas: 113041)
LinkHatsTests:testWearerCanApproveLinkToLastLevelHat() (gas: 385939)
MintHatsTest:testBatchMintHats(uint256) (runs: 256, μ: 1838853, ~: 320023)
MintHatsTest:testBatchMintHatsErrorArrayLength(uint256,uint256) (runs: 256, μ: 10343041, ~: 11993023)
MintHatsTest:testCannotMint2HatsToSameWearer() (gas: 147875)
MintHatsTest:testCannotMintMoreThanMaxSupplyErrorAllHatsWorn() (gas: 197678)
MintHatsTest:testCannotMintNonExistentHat() (gas: 23375)
MintHatsTest:testMintAnotherHat() (gas: 169666)
MintHatsTest:testMintHat() (gas: 109611)
MintHatsTest:testMintHatErrorNotAdmin() (gas: 71430)
MintHatsTest:testMintInactiveHat() (gas: 96201)
MutabilityTests:testAdminCanChangeMutableHatDetails() (gas: 66403)
MutabilityTests:testAdminCanChangeMutableHatEligibility() (gas: 63145)
MutabilityTests:testAdminCanChangeMutableHatImageURI() (gas: 66457)
MutabilityTests:testAdminCanChangeMutableHatToggle() (gas: 60848)
MutabilityTests:testAdminCanDecreaseMutableHatMaxSupplyToAboveCurrentSupply() (gas: 120154)
MutabilityTests:testAdminCanDecreaseMutableHatMaxSupplyToEqualToCurrentSupply() (gas: 120143)
MutabilityTests:testAdminCanIncreaseMutableHatMaxSupply() (gas: 63303)
MutabilityTests:testAdminCanMakeMutableHatImmutable() (gas: 73888)
MutabilityTests:testAdminCannotChangeImutableHatProperties() (gas: 229106)
MutabilityTests:testAdminCannotDecreaseMutableHatMaxSupplyBelowCurrentSupply() (gas: 151744)
MutabilityTests:testAdminCannotTransferImmutableHat() (gas: 235513)
MutabilityTests:testCannotChangeImmutableHatMutability() (gas: 187790)
MutabilityTests:testNonAdminCannotMakeMutableHatImmutable() (gas: 33944)
MutabilityTests:testTopHatCanChangeOwnDetails() (gas: 52953)
MutabilityTests:testTopHatCanChangeOwnImageURI() (gas: 52943)
MutabilityTests:testTopHatCannotChangeOtherProperties() (gas: 78149)
OverridesHatTests:testCreateUri() (gas: 95376)
OverridesHatTests:testCreateUriForTopHat() (gas: 93902)
OverridesHatTests:testFailSafeTransferFrom() (gas: 12633)
OverridesHatTests:testFailSetApprovalForAll() (gas: 7687)
RenounceHatsTest:testCannotRenounceHatAsNonWearer() (gas: 34646)
RenounceHatsTest:testRenounceHat() (gas: 43499)
ToggleGetHatsTest:testCannotCheckHatStatusNoFunctionInToggleContract() (gas: 24155)
ToggleGetHatsTest:testCheckToggleToActivateDeactivatedHat() (gas: 81623)
ToggleGetHatsTest:testCheckToggleToDeactivateHat() (gas: 51003)
ToggleSetHatsTest:testActivateDeactivatedHat() (gas: 77491)
ToggleSetHatsTest:testCannotActivateDeactivatedHatAsNonWearer() (gas: 32110)
ToggleSetHatsTest:testCannotDeactivateHatAsNonWearer() (gas: 15664)
ToggleSetHatsTest:testDeactivateHat() (gas: 90499)
TransferHatTests:testCannotTransferHatFromNonAdmin() (gas: 40895)
TransferHatTests:testCannotTransferHatToExistingWearer() (gas: 102641)
TransferHatTests:testCannotTransferHatToRevokedWearer() (gas: 111874)
TransferHatTests:testTransferMutableHat() (gas: 103181)
ViewHatTests:testGetHatLevel() (gas: 14166)
ViewHatTests:testIsAdminOfHat() (gas: 32615)
ViewHatTests:testViewHat1() (gas: 97637)
ViewHatTests:testViewHat2() (gas: 72640)
ViewHatTests:testViewHatOfTopHat1() (gas: 73622)
ViewHatTests:testViewHatOfTopHat2() (gas: 72618)
HatIdUtilTests:testBuildHatId() (gas: 87934)
HatIdUtilTests:testTopHatDomain() (gas: 14345)
HatIdUtilTests:testgetHatLevel() (gas: 143322)
LinkedTreeHatIdUtilTests:testLinkedHats() (gas: 90621)
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ jobs:
with:
version: nightly

- name: Run tests
run: forge test -vvv
- name: Check formatting
run: forge fmt --check

- name: Check contract sizes
run: forge build --sizes --skip script

- name: Run tests w/ gas report
run: forge test -vvv --gas-report
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy
on:
push:
branches:
- main

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Setup Pages
uses: actions/configure-pages@v2

- name: Build mdBook
run: forge doc --build

- name: Upload Artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./docs/book
name: github-pages
retention-days: 1

deploy:
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cache/
out/
.vscode/
broadcast/*/31337
broadcast/*/*/dry-run
broadcast/
.env
uri.json
uri.json
docs/
79 changes: 79 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Contributing to Hats Protocol

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.

## Getting Started

1. Fork the Project
2. Install [Foundry](https://book.getfoundry.sh/getting-started/installation)
3. Compile the contracts, run `forge build`, and to test, run `forge test`
4. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
5. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
6. Push to the Branch (`git push origin feature/AmazingFeature`)
7. Open a Pull Request — see the [checklist below](#pull-request-readiness-checklist) for what your PR should include

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):

- Install [Foundry](https://book.getfoundry.sh/getting-started/installation)
- Compile the contracts, run `forge build`, and to test, run `forge test`
- Deploy using the [Hats.s.sol script](script/Hats.s.sol) and follow the [Foundry scripting instructions](https://book.getfoundry.sh/tutorials/solidity-scripting)

## Code and Style Conventions

Hats Protocol follows certain conventions, including:

- Use custom errors (rather than in-line require statement strings), added to [HatsErrors.sol](src/Interfaces/HatsErrors.sol)
- New events should be added to [HatsEvents.sol](src/Interfaces/HatsEvents.sol)
- 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)
- We format all markdown according to the settings in [.markdownlintrc](./.markdownlintrc)
- 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)):

| `forge fmt` setting | our value |
| -------------------------------- | ----------- |
| line_length | 120 |
| tab_width | 4 |
| bracket_spacing | true |
| int_types | long |
| multiline_func_header | attributes_first |
| quote_style | double |
| number_underscore | thousands |
| override_spacing | true |
| wrap_comments | true |

## Documentation

All code changes should be accompanied by updates to documentation:

- 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)
- The above will be produced in an mdBook via Foundry's [forge doc](https://github.com/foundry-rs/foundry/tree/master/doc) module
- Update the [README](./README.md) and/or developer docs as needed

We also welcome contributions to the project's documentation itself!

## Testing

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:

- Write thorough unit tests for all new code
- Ensure that all tests (existing and new) are passing
- Track test coverage with Foundry's `forge coverage` module
- 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

## Pull Request Readiness Checklist

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)**".

1. Thorough unit tests are written for all new code
2. Update the [test coverage tracker](./lcov.info) — run `forge coverage --report lcov`
3. Update the [gas snapshot tracker](./.gas-snapshot) — run `forge snapshot`
4. Ensure contract sizes are small enough to deploy — run `forge build --sizes` **(ci)**
5. Ensure all existing and new tests are passing — run `forge test` **(ci)**
6. Document all new Solidity code with NatSpec, and generate updated docs — run `forge doc`
7. Update the [README](./README.md) with any new or changed functionality
8. Ensure all markdown is formatted correctly — run `forge fmt` **(ci)**

## Contact Information

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.

Thank you for your contributions!
Loading

0 comments on commit 60f07df

Please sign in to comment.