Skip to content

Commit

Permalink
Merge branch 'feat-token-extensions' into feat-token-erc721-uristorage
Browse files Browse the repository at this point in the history
  • Loading branch information
Realkayzee committed Sep 14, 2024
2 parents d7cdcb9 + 53adaea commit 75e7e8c
Show file tree
Hide file tree
Showing 10 changed files with 1,017 additions and 8 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/label-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Label PRs for feat-token-extensions

on:
pull_request:
branches:
- feat-token-extensions

jobs:
tag-and-label:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up GitHub CLI
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install GitHub CLI
run: |
npm install -g @actions/github-script
- name: Add label to PR
uses: actions/github-script@v7
with:
script: |
github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['feat-token-extensions']
})
- name: Add Tag to PR Title
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "feat-token-extensions"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scripts/node_modules
scripts/.env
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,23 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!


## 🪛 Deployment

This section details the steps to deploy Hyperlane contracts on Starknet. Note that the deployment script will set a basic configuration for all the required contracts. Further configuration process might be required based on the use case. Constructors parameters can be specified in the `contract_config.json`.
Firstly, set the following environment variables, important for the deployment process:
```bash
STARKNET_RPC_URL=
ACCOUNT_ADDRESS=
BENEFICIARY_ADDRESS=
NETWORK=
PRIVATE_KEY=
```
The beneficiary address is the account that will be used to recover funds from the protocol fee.
Once set, the contracts can be deployed using this command( assuming `ts-node` is installed):

```bash
ts-node deploy.ts
```
40 changes: 34 additions & 6 deletions rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
use std::{collections::HashMap, env::current_dir, path::PathBuf};

use std::{collections::HashMap, env::current_dir, path::{PathBuf, Path}, fs};
use ethers::prelude::Abigen;

fn check_path_exists(path: &Path) {
if !path.exists() {
panic!("Path does not exist: {:?}", path);
}
}

fn generate_eth_bind(name: &str, abi_file: &str, bind_out: PathBuf) {
// Check if the ABI file exists
let abi_file_path = Path::new(abi_file);
check_path_exists(abi_file_path);

// Remove output file if it exists
if bind_out.exists() {
std::fs::remove_file(&bind_out).unwrap();
fs::remove_file(&bind_out).unwrap();
}

// Generate Ethereum bindings
Abigen::new(name, abi_file)
.unwrap()
.generate()
Expand All @@ -16,8 +27,13 @@ fn generate_eth_bind(name: &str, abi_file: &str, bind_out: PathBuf) {
}

fn generate_strk_bind(name: &str, abi_file: &str, bind_out: PathBuf) {
// Check if the ABI file exists
let abi_file_path = Path::new(abi_file);
check_path_exists(abi_file_path);

// Remove output file if it exists
if bind_out.exists() {
std::fs::remove_file(&bind_out).unwrap();
fs::remove_file(&bind_out).unwrap();
}

let mut aliases = HashMap::new();
Expand Down Expand Up @@ -50,6 +66,11 @@ fn main() {
.unwrap()
.join("tests")
.join("contracts/eth/bind");

// Check if the Ethereum ABI directory exists
check_path_exists(&eth_abi_base);
check_path_exists(&eth_bind_base);

let eth_deployments = [
("Mailbox", "mailbox"),
("FastHypERC20", "fast_hyp_erc20"),
Expand All @@ -73,13 +94,20 @@ fn main() {
// Generate Starknet bindings
let strk_abi_base = current_dir()
.unwrap()
.parent()
.parent() // Move one directory up to source directory
.unwrap()
.join("contracts/target/dev");
.join("cairo")
.join("target")
.join("dev");
let strk_bind_base = current_dir()
.unwrap()
.join("tests")
.join("contracts/strk/bind");

// Check if the Starknet ABI directory exists
check_path_exists(&strk_abi_base);
check_path_exists(&strk_bind_base);

let strk_deployments = [
("mailbox", "mailbox"),
("domain_routing_ism", "routing"),
Expand Down
2 changes: 1 addition & 1 deletion rust/tests/contracts/strk/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use starknet::{

use super::{types::Codes, StarknetAccount};

const BUILD_PATH_PREFIX: &str = "../contracts/target/dev/hyperlane_starknet_";
const BUILD_PATH_PREFIX: &str = "../cairo/target/dev/hyperlane_starknet_";

const KATANA_RPC_URL: &str = "http://localhost:5050";

Expand Down
5 changes: 5 additions & 0 deletions scripts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
STARKNET_RPC_URL=
ACCOUNT_ADDRESS=
BENEFICIARY_ADDRESS=
NETWORK=
PRIVATE_KEY=
216 changes: 216 additions & 0 deletions scripts/contract_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"contracts": {
"merkleroot_multisig_ism": {
"name": "merkleroot_multisig_ism",
"constructor": {
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
},
"validators": {
"type": "Span<felt252>",
"value": [
"0x0000000000000000000000000000000000000000000000000000000000000002"
]
},
"threshold": {
"type": "u32",
"value": "1"
}
}
},
"protocol_fee": {
"name": "protocol_fee",
"constructor": {
"max_protocol_fee_low": {
"type": "u128",
"value": "1000000000000000000"
},
"max_protocol_fee_high": {
"type": "u128",
"value": "0"
},
"protocol_fee_low": {
"type": "u128",
"value": "10000000000000000"
},
"protocol_fee_high": {
"type": "u128",
"value": "0"
},
"beneficiary": {
"type": "ContractAddress",
"value": "$BENEFICIARY_ADDRESS"
},
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
},
"token_address": {
"type": "ContractAddress",
"value": "0x049D36570D4e46f48e99674bd3fcc84644DdD6b96F7C741B1562B82f9e004dC7"
}
}
},
"merkle_tree_hook" : {
"name": "merkle_tree_hook",
"constructor": {
"mailbox": {
"type": "ContractAddress",
"value": "$mailbox"
},
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
}
}
},
"noop_ism": {
"name": "noop_ism",
"constructor": {

}
},
"hook": {
"name": "hook",
"constructor": {

}
},
"pausable_ism": {
"name": "pausable_ism",
"constructor": {
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
}
}
},
"trusted_relayer_ism": {
"name": "trusted_relayer_ism",
"constructor": {
"mailbox":{
"type": "ContractAddress",
"value": "$mailbox"
},
"trusted_relayer": {
"type": "ContractAddress",
"value": "0x0000000000000000000000000000000000000000000000000000000000000001"
}
}
},
"mailbox": {
"name": "mailbox",
"constructor": {
"local_domain": {
"type": "u32",
"value": "100"
},
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
},
"default_ism": {
"type": "ContractAddress",
"value": "$merkleroot_multisig_ism"
},
"default_hook":{
"type": "ContractAddress",
"value": "$hook"
},
"required_hook": {
"type": "ContractAddress",
"value": "$protocol_fee"
}
}
},
"validator_announce": {
"name": "validator_announce",
"constructor": {
"mailbox": {
"type": "ContractAddress",
"value": "$mailbox"
},
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
}
}
},
"aggregation": {
"name": "aggregation",
"constructor": {
"owner":{
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
},
"modules": {
"type": "Span<felt252>",
"value": [
"0x0000000000000000000000000000000000000000000000000000000000000002"
]
},
"threshold": {
"type": "u32",
"value": "1"
}
}
},
"messageid_multisig_ism": {
"name": "messageid_multisig_ism",
"constructor": {
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
},
"validators": {
"type": "Span<felt252>",
"value": [
"0x0000000000000000000000000000000000000000000000000000000000000003"
]
},
"threshold": {
"type": "u32",
"value": "1"
}
}
},
"default_fallback_routing_ism": {
"name": "default_fallback_routing_ism",
"constructor": {
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
},
"mailbox": {
"type": "ContractAddress",
"value": "$mailbox"
}
}
},
"domain_routing_ism": {
"name": "domain_routing_ism",
"constructor": {
"owner": {
"type": "ContractAddress",
"value": "$OWNER_ADDRESS"
}
}
}
},
"deploymentOrder": [
"merkleroot_multisig_ism",
"messageid_multisig_ism",
"domain_routing_ism",
"noop_ism",
"pausable_ism",
"aggregation",
"protocol_fee",
"hook",
"mailbox",
"merkle_tree_hook",
"default_fallback_routing_ism",
"trusted_relayer_ism",
"validator_announce"
]
}
Loading

0 comments on commit 75e7e8c

Please sign in to comment.