Skip to content

Update fmt #4

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

Merged
merged 1 commit into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand Down
19 changes: 0 additions & 19 deletions rustfmt.toml

This file was deleted.

4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -14,5 +14,5 @@ pub struct RunOptions {
env = "WORMHOLE_PID",
default_value = "H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"
)]
pub wormhole_pid: String,
pub wormhole_pid: String,
}
54 changes: 19 additions & 35 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,24 @@ 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;
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,
}

Expand All @@ -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?;
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 4 additions & 17 deletions src/posted_message.rs
Original file line number Diff line number Diff line change
@@ -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},
},
};

Expand Down
10 changes: 3 additions & 7 deletions src/signed_body.rs
Original file line number Diff line number Diff line change
@@ -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<P> {
pub version: u8,
pub version: u8,
pub signature: [u8; 65],
pub body: Body<P>,
pub body: Body<P>,
}

impl<P: Serialize> SignedBody<P> {
Expand Down
Loading