-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/sdk alpha1 hardening #26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||||||||
| name: Rust | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| push: | ||||||||||
| branches: [main] | ||||||||||
| pull_request: | ||||||||||
| workflow_dispatch: | ||||||||||
|
|
||||||||||
| permissions: | ||||||||||
| contents: read | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| checks: | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
| steps: | ||||||||||
| - name: Checkout | ||||||||||
| uses: actions/checkout@v4 | ||||||||||
|
|
||||||||||
| - name: Install Rust | ||||||||||
| uses: dtolnay/rust-toolchain@stable | ||||||||||
| with: | ||||||||||
| components: rustfmt, clippy | ||||||||||
|
|
||||||||||
| - name: Cache Rust dependencies | ||||||||||
| uses: Swatinem/rust-cache@v2 | ||||||||||
|
|
||||||||||
| - name: Install protobuf compiler | ||||||||||
| run: sudo apt-get update && sudo apt-get install -y protobuf-compiler | ||||||||||
|
|
||||||||||
| - name: cargo fmt | ||||||||||
| run: cargo fmt --check | ||||||||||
|
|
||||||||||
| - name: cargo clippy | ||||||||||
| run: cargo clippy --all-features -- -D warnings | ||||||||||
|
|
||||||||||
| - name: cargo check default | ||||||||||
| run: cargo check | ||||||||||
|
|
||||||||||
| - name: cargo check no default features | ||||||||||
| run: cargo check --no-default-features | ||||||||||
|
|
||||||||||
| - name: cargo check native | ||||||||||
| run: cargo check --no-default-features --features native | ||||||||||
|
|
||||||||||
| - name: cargo check wallet | ||||||||||
| run: cargo check --no-default-features --features wallet | ||||||||||
|
|
||||||||||
| - name: cargo check evm | ||||||||||
| run: cargo check --no-default-features --features evm | ||||||||||
|
|
||||||||||
| - name: cargo check grpc | ||||||||||
| run: cargo check --no-default-features --features grpc | ||||||||||
|
|
||||||||||
| - name: cargo check bft | ||||||||||
| run: cargo check --no-default-features --features bft | ||||||||||
|
|
||||||||||
| - name: cargo check native,wallet | ||||||||||
| run: cargo check --no-default-features --features native,wallet | ||||||||||
|
|
||||||||||
| - name: cargo check evm,grpc | ||||||||||
| run: cargo check --no-default-features --features evm,grpc | ||||||||||
|
|
||||||||||
| - name: cargo check all features | ||||||||||
| run: cargo check --all-features | ||||||||||
|
|
||||||||||
| - name: cargo check examples all features | ||||||||||
| run: cargo check --examples --all-features | ||||||||||
|
|
||||||||||
| - name: cargo test wallet | ||||||||||
| run: cargo test --no-default-features --features wallet | ||||||||||
|
|
||||||||||
| - name: cargo test evm | ||||||||||
| run: cargo test --no-default-features --features evm | ||||||||||
|
|
||||||||||
| - name: cargo test all features | ||||||||||
| run: cargo test --all-features | ||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||
|
|
||||||||||
| - name: cargo doc all features | ||||||||||
| run: cargo doc --all-features --no-deps | ||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Comment on lines
+78
to
+79
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. 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win Consider enforcing documentation warnings. The 📚 Suggested enhancement - name: cargo doc all features
- run: cargo doc --all-features --no-deps
+ run: cargo doc --all-features --no-deps -- -D warnings📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| use sentrix_chain::{NativeClient, Network}; | ||
|
|
||
| fn network_from_env() -> Network { | ||
| match std::env::var("SENTRIX_NETWORK").as_deref() { | ||
| Ok("testnet") => Network::Testnet, | ||
| _ => Network::Mainnet, | ||
| } | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let network = network_from_env(); | ||
| let client = NativeClient::new(network); | ||
| let info = client.chain_info().await?; | ||
|
|
||
| println!("network={}", client.spec().name); | ||
| println!("chain_id={}", client.spec().chain_id); | ||
| println!("height={}", info.height); | ||
| println!("active_validators={}", info.active_validators); | ||
| println!("mempool_size={}", info.mempool_size); | ||
| println!("total_minted_srx={}", info.total_minted_srx); | ||
| println!("total_burned_srx={}", info.total_burned_srx); | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use alloy::providers::Provider; | ||
| use sentrix_chain::{evm, Network}; | ||
|
|
||
| fn network_from_env() -> Network { | ||
| match std::env::var("SENTRIX_NETWORK").as_deref() { | ||
| Ok("testnet") => Network::Testnet, | ||
| _ => Network::Mainnet, | ||
| } | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let network = network_from_env(); | ||
| let provider = evm::http_provider(network)?; | ||
| let block_number = provider.get_block_number().await?; | ||
|
|
||
| println!("latest_evm_block={block_number}"); | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use sentrix_chain::{grpc::SentrixGrpcClient, Network}; | ||
|
|
||
| fn network_from_env() -> Network { | ||
| match std::env::var("SENTRIX_NETWORK").as_deref() { | ||
| Ok("testnet") => Network::Testnet, | ||
| _ => Network::Mainnet, | ||
| } | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let network = network_from_env(); | ||
| let mut client = SentrixGrpcClient::connect(network).await?; | ||
| let block = client.get_latest_block().await?; | ||
|
|
||
| println!("latest_block_height={}", block.index); | ||
| println!("transactions={}", block.transactions.len()); | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| use sentrix_chain::{NativeClient, Network, SentrixWallet}; | ||
|
|
||
| fn network_from_env() -> Network { | ||
| match std::env::var("SENTRIX_NETWORK").as_deref() { | ||
| Ok("testnet") => Network::Testnet, | ||
| _ => Network::Mainnet, | ||
| } | ||
| } | ||
|
|
||
| fn parse_u64_env(name: &str, default: u64) -> Result<u64, Box<dyn std::error::Error>> { | ||
| match std::env::var(name) { | ||
| Ok(value) => Ok(value.parse()?), | ||
| Err(_) => Ok(default), | ||
| } | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let private_key = match std::env::var("SENTRIX_PRIVATE_KEY") { | ||
| Ok(value) => value, | ||
| Err(_) => { | ||
| println!("set SENTRIX_PRIVATE_KEY and SENTRIX_TO to build a signed transfer"); | ||
| return Ok(()); | ||
| } | ||
| }; | ||
| let to = match std::env::var("SENTRIX_TO") { | ||
| Ok(value) => value, | ||
| Err(_) => { | ||
| println!("set SENTRIX_TO to the 0x recipient address"); | ||
| return Ok(()); | ||
| } | ||
| }; | ||
|
|
||
| let network = network_from_env(); | ||
| let client = NativeClient::new(network); | ||
| let wallet = SentrixWallet::from_private_key_hex(&private_key)?; | ||
| let nonce = match std::env::var("SENTRIX_NONCE") { | ||
| Ok(value) => value.parse()?, | ||
| Err(_) => client.next_nonce(&wallet.address).await?, | ||
| }; | ||
|
|
||
| let tx = wallet.build_and_sign_transfer( | ||
| &to, | ||
| parse_u64_env("SENTRIX_AMOUNT_SENTRI", 100_000_000)?, | ||
| parse_u64_env("SENTRIX_FEE_SENTRI", 10_000)?, | ||
| nonce, | ||
| client.spec().chain_id, | ||
| )?; | ||
|
|
||
| println!("{}", serde_json::to_string_pretty(&tx)?); | ||
| println!("not broadcast; submit with NativeClient::broadcast after review"); | ||
|
|
||
| Ok(()) | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.