diff --git a/.github/workflows/ci-pre-commit.yml b/.github/workflows/ci-pre-commit.yml index 79db5d6..21c8ace 100644 --- a/.github/workflows/ci-pre-commit.yml +++ b/.github/workflows/ci-pre-commit.yml @@ -31,7 +31,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2024-12-03 + toolchain: 1.87.0 components: rustfmt - name: Run pre-commit on all files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f9a773d..d73997a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: cargo-fmt-workspace name: Cargo format for workspace language: "rust" - entry: cargo +nightly-2024-12-03 fmt --manifest-path ./Cargo.toml --all -- --config-path rustfmt.toml + entry: cargo +1.87.0 fmt --manifest-path ./Cargo.toml --all pass_filenames: false types_or: ["rust", "cargo", "cargo-lock"] files: . diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 793e0a9..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1,19 +0,0 @@ -edition = "2021" - -# Merge all imports into a clean vertical list of module imports. -imports_granularity = "One" -group_imports = "One" -imports_layout = "Vertical" - -# Better grep-ability. -empty_item_single_line = false - -# Consistent pipe layout. -match_arm_leading_pipes = "Preserve" - -# Align Fields -enum_discrim_align_threshold = 80 -struct_field_align_threshold = 80 - -# Allow up to two blank lines for visual grouping. -blank_lines_upper_bound = 2 diff --git a/src/config.rs b/src/config.rs index 910a0c1..8879c64 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,7 +4,7 @@ use clap::Parser; pub struct RunOptions { /// The API key to use for auction server authentication. #[arg(long = "pythnet-url", env = "PYTHNET_URL")] - pub pythnet_url: String, + pub pythnet_url: String, /// Path to the file containing the secret key. #[arg(long = "secret-key", env = "SECRET_KEY")] pub secret_key_path: String, @@ -14,5 +14,5 @@ pub struct RunOptions { env = "WORMHOLE_PID", default_value = "H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU" )] - pub wormhole_pid: String, + pub wormhole_pid: String, } diff --git a/src/main.rs b/src/main.rs index 9c5e8f8..e522c06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,28 +8,14 @@ use { solana_client::{ nonblocking::pubsub_client::PubsubClient, pubsub_client::PubsubClientError, - rpc_config::{ - RpcAccountInfoConfig, - RpcProgramAccountsConfig, - }, - rpc_filter::{ - Memcmp, - RpcFilterType, - }, + rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, + rpc_filter::{Memcmp, RpcFilterType}, }, solana_sdk::pubkey::Pubkey, - std::{ - fs, - str::FromStr, - time::Duration, - }, + std::{fs, str::FromStr, time::Duration}, tokio::time::sleep, tokio_stream::StreamExt, - wormhole_sdk::{ - vaa::Body, - Address, - Chain, - }, + wormhole_sdk::{vaa::Body, Address, Chain}, }; mod config; @@ -37,9 +23,9 @@ mod posted_message; mod signed_body; struct ListenerConfig { - ws_url: String, - secret_key: SecretKey, - wormhole_pid: Pubkey, + ws_url: String, + secret_key: SecretKey, + wormhole_pid: Pubkey, accumulator_address: Pubkey, } @@ -58,20 +44,18 @@ async fn run_listener(config: ListenerConfig) -> Result<(), PubsubClientError> { .program_subscribe( &config.wormhole_pid, Some(RpcProgramAccountsConfig { - filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new( + filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new( 0, solana_client::rpc_filter::MemcmpEncodedBytes::Bytes(b"msu".to_vec()), ))]), account_config: RpcAccountInfoConfig { - encoding: Some(UiAccountEncoding::Base64), - data_slice: None, - commitment: Some( - solana_sdk::commitment_config::CommitmentConfig::confirmed(), - ), + encoding: Some(UiAccountEncoding::Base64), + data_slice: None, + commitment: Some(solana_sdk::commitment_config::CommitmentConfig::confirmed()), min_context_slot: None, }, - with_context: None, - sort_results: None, + with_context: None, + sort_results: None, }), ) .await?; @@ -109,13 +93,13 @@ async fn run_listener(config: ListenerConfig) -> Result<(), PubsubClientError> { } let body = Body { - timestamp: unreliable_data.submission_time, - nonce: unreliable_data.nonce, - emitter_chain: unreliable_data.emitter_chain.into(), - emitter_address: Address(unreliable_data.emitter_address), - sequence: unreliable_data.sequence, + timestamp: unreliable_data.submission_time, + nonce: unreliable_data.nonce, + emitter_chain: unreliable_data.emitter_chain.into(), + emitter_address: Address(unreliable_data.emitter_address), + sequence: unreliable_data.sequence, consistency_level: unreliable_data.consistency_level, - payload: unreliable_data.payload.clone(), + payload: unreliable_data.payload.clone(), }; match SignedBody::try_new(body, config.secret_key) { diff --git a/src/posted_message.rs b/src/posted_message.rs index 79e2820..899bb16 100644 --- a/src/posted_message.rs +++ b/src/posted_message.rs @@ -1,22 +1,9 @@ use { - borsh::{ - BorshDeserialize, - BorshSerialize, - }, - serde::{ - Deserialize, - Serialize, - }, + borsh::{BorshDeserialize, BorshSerialize}, + serde::{Deserialize, Serialize}, std::{ - io::{ - Error, - ErrorKind::InvalidData, - Write, - }, - ops::{ - Deref, - DerefMut, - }, + io::{Error, ErrorKind::InvalidData, Write}, + ops::{Deref, DerefMut}, }, }; diff --git a/src/signed_body.rs b/src/signed_body.rs index 3dce617..d51534c 100644 --- a/src/signed_body.rs +++ b/src/signed_body.rs @@ -1,18 +1,14 @@ use { - secp256k1::{ - Message, - Secp256k1, - SecretKey, - }, + secp256k1::{Message, Secp256k1, SecretKey}, serde::Serialize, wormhole_sdk::vaa::Body, }; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct SignedBody

{ - pub version: u8, + pub version: u8, pub signature: [u8; 65], - pub body: Body

, + pub body: Body

, } impl SignedBody

{