forked from astraly-labs/hyperlane_starknet
-
Notifications
You must be signed in to change notification settings - Fork 4
feat(cairo): change mailbox fee token at compile time #21
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,46 @@ | ||
| # Makefile for Hyperlane Starknet Cairo | ||
|
|
||
| .PHONY: build clean rebuild help | ||
|
|
||
| # Default target | ||
| help: | ||
| @echo "Available targets:" | ||
| @echo " build [FEE_TOKEN_ADDRESS] - Build project, optionally setting fee token first" | ||
| @echo " clean - Clean the project with scarb" | ||
| @echo " rebuild [FEE_TOKEN_ADDRESS] - Clean and build, optionally setting fee token" | ||
| @echo "" | ||
| @echo "Examples:" | ||
| @echo " make build # Build with current fee token" | ||
| @echo " make build 0x1234567890abcdef... # Set fee token and build" | ||
| @echo " make rebuild 0x1234567890abcdef... # Set fee token, clean and build" | ||
|
|
||
| # Build the project (with optional fee token address as first argument) | ||
| build: | ||
| ifneq ($(word 2,$(MAKECMDGOALS)),) | ||
| @echo "Cleaning project before fee token update..." | ||
| scarb clean | ||
| @echo "Updating fee token to $(word 2,$(MAKECMDGOALS))..." | ||
| ./feeToken $(word 2,$(MAKECMDGOALS)) | ||
| endif | ||
| @echo "Building project..." | ||
| scarb build | ||
|
|
||
| # Clean the project | ||
| clean: | ||
| @echo "Cleaning project..." | ||
| scarb clean | ||
|
|
||
| # Clean and build (with optional fee token address) | ||
| rebuild: | ||
| @echo "Cleaning project..." | ||
| scarb clean | ||
| ifneq ($(word 2,$(MAKECMDGOALS)),) | ||
| @echo "Updating fee token to $(word 2,$(MAKECMDGOALS))..." | ||
| ./feeToken $(word 2,$(MAKECMDGOALS)) | ||
| endif | ||
| @echo "Building project..." | ||
| scarb build | ||
|
|
||
| # Prevent make from treating the address argument as a target | ||
| %: | ||
| @: |
This file contains hidden or 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,5 @@ | ||
| use starknet::ContractAddress; | ||
|
|
||
| pub fn FEE_TOKEN() -> ContractAddress { | ||
| 0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D.try_into().unwrap() | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| pub mod fee_token; | ||
| pub mod interfaces; | ||
| pub mod mailbox; | ||
| pub mod libs { | ||
|
|
||
This file contains hidden or 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,38 @@ | ||
| #!/bin/bash | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we name this file with a |
||
|
|
||
| # Script to update the FEE_TOKEN address dynamically | ||
| # Usage: ./feeToken 0x1234567890abcdef... | ||
|
|
||
| if [ $# -eq 0 ]; then | ||
| echo "Usage: $0 <fee_token_address>" | ||
| echo "Example: $0 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" | ||
| exit 1 | ||
| fi | ||
|
|
||
| NEW_ADDRESS="$1" | ||
|
|
||
| # Validate the address format (basic check for 0x prefix and length) | ||
| if [[ ! "$NEW_ADDRESS" =~ ^0x[0-9a-fA-F]{63,64}$ ]]; then | ||
| echo "Error: Invalid address format. Expected hex string starting with 0x" | ||
| exit 1 | ||
| fi | ||
|
|
||
| FEE_TOKEN_FILE="crates/contracts/src/fee_token.cairo" | ||
|
|
||
| if [ ! -f "$FEE_TOKEN_FILE" ]; then | ||
| echo "Error: Fee token file not found at $FEE_TOKEN_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Updating FEE_TOKEN address to: $NEW_ADDRESS" | ||
|
|
||
| # Update the fee token address in the file | ||
| sed -i.bak "s/0x[0-9a-fA-F]\\{63,64\\}/$NEW_ADDRESS/g" "$FEE_TOKEN_FILE" | ||
|
|
||
| if [ $? -eq 0 ]; then | ||
| echo "Successfully updated FEE_TOKEN address in $FEE_TOKEN_FILE" | ||
| rm -f "${FEE_TOKEN_FILE}.bak" # Remove backup file | ||
| else | ||
| echo "Error: Failed to update fee token address" | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change usage of ETH_ADDRESS to FEE_TOKEN to avoid this (improperly named) indirection?