-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add presets page update on release workflow (#883)
* feat: add update class hashes workflow * fix: input name * test * test * feat: test with main * feat: add update class hashes local action * test * feat: finish main logic * test * fix: version * refactor: update wording * feat: remove javascript action and update preset page on release * refactor: scarb version input * feat: normalize hashes len * feat: update workflow name * feat: apply review updates * feat: rename file to match action * feat: get scarb version from Scarb.toml * Update .github/workflows/prepare-release.yml Co-authored-by: Martín Triay <[email protected]> --------- Co-authored-by: Martín Triay <[email protected]>
- Loading branch information
1 parent
7684fb0
commit e0e888c
Showing
7 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |