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 presets page update on release workflow #883

Merged
merged 23 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
aa248b2
feat: add update class hashes workflow
ericnordelo Jan 31, 2024
ea7f92e
fix: input name
ericnordelo Jan 31, 2024
03e2cee
test
ericnordelo Jan 31, 2024
1b40cb2
test
ericnordelo Jan 31, 2024
a0e89bc
feat: test with main
ericnordelo Jan 31, 2024
744a140
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Jan 31, 2024
a18309a
feat: add update class hashes local action
ericnordelo Jan 31, 2024
8d20bd5
test
ericnordelo Jan 31, 2024
4f74499
feat: finish main logic
ericnordelo Jan 31, 2024
1460f69
test
ericnordelo Jan 31, 2024
61d2b74
fix: version
ericnordelo Jan 31, 2024
f3aa10e
refactor: update wording
ericnordelo Jan 31, 2024
3034b12
Merge branch 'main' into feat/class-hash-action
ericnordelo Feb 8, 2024
3c0f9b3
feat: remove javascript action and update preset page on release
ericnordelo Feb 8, 2024
b9c669d
refactor: scarb version input
ericnordelo Feb 8, 2024
856b512
feat: normalize hashes len
ericnordelo Feb 8, 2024
699ecbd
feat: update workflow name
ericnordelo Feb 8, 2024
9a93e71
feat: apply review updates
ericnordelo Feb 9, 2024
90f0d58
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Feb 9, 2024
d5d8fe5
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Feb 13, 2024
b1b724c
feat: rename file to match action
ericnordelo Feb 16, 2024
f82f18c
feat: get scarb version from Scarb.toml
ericnordelo Feb 21, 2024
17b5f62
Update .github/workflows/prepare-release.yml
ericnordelo Feb 23, 2024
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
25 changes: 22 additions & 3 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update version on new release branch
name: Update version and presets page on new release branch

on:
create:
Expand All @@ -12,10 +12,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Extract current version
- name: Extract current versions
run: |
CURRENT_VERSION=$(grep '^version = ' Scarb.toml | sed 's/version = "\(.*\)"/\1/')
SCARB_VERSION=$(grep 'cairo-version = ' Scarb.toml | sed 's/cairo-version = "\(.*\)"/\1/')
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo "SCARB_VERSION=$SCARB_VERSION" >> $GITHUB_ENV
- name: Extract new version number
run: echo "NEW_VERSION=${GITHUB_REF#refs/heads/release-v}" >> $GITHUB_ENV
Expand All @@ -25,7 +27,24 @@ jobs:
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"
ESCAPED_CURRENT_VERSION=$(echo $CURRENT_VERSION | sed 's/\./\\./g')
find . -type f -not -path '*/\.*' -not -path './CHANGELOG.md' -not -path './docs/package-lock.json' -not -path './RELEASING.md' -exec sed -i "s/$ESCAPED_CURRENT_VERSION/$NEW_VERSION/g" {} +
find . -type f -not -path '*/\.*' -not -path './CHANGELOG.md' -not -path './docs/package-lock.json' \
-not -path './RELEASING.md' -exec sed -i "s/$ESCAPED_CURRENT_VERSION/$NEW_VERSION/g" {} +
- name: Setup scarb
uses: software-mansion/setup-scarb@v1
id: setup_scarb
with:
scarb-version: ${{ env.SCARB_VERSION }}

- name: Setup class_hash
uses: ericnordelo/setup-class-hash@c14dd33506c3eb8e1acfe2ade9f82585f5acf28c
with:
version: "0.1.0"

- name: Update presets page
run: |
class_hash get --json | sed -e '1,4d' | python3 scripts/get_hashes_page.py v$SCARB_VERSION \
> ./docs/modules/ROOT/pages/utils/_class_hashes.adoc
- name: Auto-commit changes
uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a #v4.16.0
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/api/account.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ include::../utils/_class_hashes.adoc[]
[.contract-index]
.{presets-page}
--
{account-class-hash}
{Account-class-hash}
--

[.contract-index]
Expand Down Expand Up @@ -534,7 +534,7 @@ include::../utils/_class_hashes.adoc[]
[.contract-index]
.{presets-page}
--
{eth-account-upgradeable-class-hash}
{EthAccountUpgradeable-class-hash}
--

[.contract-index]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/api/erc20.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ include::../utils/_class_hashes.adoc[]
[.contract-index]
.{presets-page}
--
{erc20-class-hash}
{ERC20-class-hash}
--

[.contract-index]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/api/erc721.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ include::../utils/_class_hashes.adoc[]
[.contract-index]
.{presets-page}
--
{erc721-class-hash}
{ERC721-class-hash}
--

[.contract-index]
Expand Down
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/presets.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ NOTE: Class hashes were computed using {class-hash-cairo-version}.
| Name | Sierra Class Hash

| `{account}`
| `{account-class-hash}`
| `{Account-class-hash}`

| `{eth-account-upgradeable}`
| `{eth-account-upgradeable-class-hash}`
| `{EthAccountUpgradeable-class-hash}`

| `{erc20}`
| `{erc20-class-hash}`
| `{ERC20-class-hash}`

| `{erc721}`
| `{erc721-class-hash}`
| `{ERC721-class-hash}`
|===

TIP: {starkli} class-hash command can be used to compute the class hash from a Sierra artifact.
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/utils/_class_hashes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
:class-hash-cairo-version: https://crates.io/crates/cairo-lang-compiler/2.5.3[cairo 2.5.3]

// Class Hashes
:account-class-hash: 0x01148c31dfa5c4708a4e9cf1eb0fd3d4d8ad9ccf09d0232cd6b56bee64a7de9d
:eth-account-upgradeable-class-hash: 0x023e416842ca96b1f7067693892ed00881d97a4b0d9a4c793b75cb887944d98d
:erc20-class-hash: 0x7d94f28156c0dc3bfd9a07ca79b15b8da2b5b32093db79000fcd0f6f625d213
:erc721-class-hash: 0x06b7c9efc5467c621f58d87995302d940a39b7217b5c5a7a55555c97cabf5cd8
:Account-class-hash: 0x01148c31dfa5c4708a4e9cf1eb0fd3d4d8ad9ccf09d0232cd6b56bee64a7de9d
:ERC20-class-hash: 0x07d94f28156c0dc3bfd9a07ca79b15b8da2b5b32093db79000fcd0f6f625d213
:ERC721-class-hash: 0x06b7c9efc5467c621f58d87995302d940a39b7217b5c5a7a55555c97cabf5cd8
:EthAccountUpgradeable-class-hash: 0x0580fe510cf07255540abda6f9d29aa07cb8944db444bca59e1573904c269844
martriay marked this conversation as resolved.
Show resolved Hide resolved

// Presets page
:presets-page: xref:presets.adoc[Sierra class hash]
36 changes: 36 additions & 0 deletions scripts/get_hashes_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import sys
import json


def main():
# Required compiler version argument
cmp_version = sys.argv[1]

# Read class hashes from stdin
contracts = json.load(sys.stdin)

print(generate_doc_file(cmp_version, contracts))


def generate_doc_file(cmp_version, contracts):
header = f"""// Version
:class-hash-cairo-version: \
https://crates.io/crates/cairo-lang-compiler/{cmp_version}[cairo {cmp_version}]
"""
hashes = "// Class Hashes\n"
for contract in contracts['contracts']:
# The [13:] is to remove the "openzeppelin_" prefix from the contract name
hashes += f":{contract['name'][13:]}-class-hash: {normalize_len(contract['sierra'])}\n"

footer = """// Presets page
:presets-page: xref:presets.adoc[Sierra class hash]"""

return f"{header}\n{hashes}\n{footer}\n"


def normalize_len(sierra_hash):
return "0x" + "0" * (66 - len(sierra_hash)) + sierra_hash[2:]


if __name__ == '__main__':
main()
Loading