Skip to content

Commit 83e9470

Browse files
authored
Update rust fmt to standard (#4)
1 parent ce24ac1 commit 83e9470

File tree

7 files changed

+30
-82
lines changed

7 files changed

+30
-82
lines changed

.github/workflows/ci-pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions-rs/toolchain@v1
3232
with:
3333
profile: minimal
34-
toolchain: nightly-2024-12-03
34+
toolchain: 1.87.0
3535
components: rustfmt
3636

3737
- name: Run pre-commit on all files

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
- id: cargo-fmt-workspace
66
name: Cargo format for workspace
77
language: "rust"
8-
entry: cargo +nightly-2024-12-03 fmt --manifest-path ./Cargo.toml --all -- --config-path rustfmt.toml
8+
entry: cargo +1.87.0 fmt --manifest-path ./Cargo.toml --all
99
pass_filenames: false
1010
types_or: ["rust", "cargo", "cargo-lock"]
1111
files: .

rustfmt.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clap::Parser;
44
pub struct RunOptions {
55
/// The API key to use for auction server authentication.
66
#[arg(long = "pythnet-url", env = "PYTHNET_URL")]
7-
pub pythnet_url: String,
7+
pub pythnet_url: String,
88
/// Path to the file containing the secret key.
99
#[arg(long = "secret-key", env = "SECRET_KEY")]
1010
pub secret_key_path: String,
@@ -14,5 +14,5 @@ pub struct RunOptions {
1414
env = "WORMHOLE_PID",
1515
default_value = "H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"
1616
)]
17-
pub wormhole_pid: String,
17+
pub wormhole_pid: String,
1818
}

src/main.rs

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,24 @@ use {
88
solana_client::{
99
nonblocking::pubsub_client::PubsubClient,
1010
pubsub_client::PubsubClientError,
11-
rpc_config::{
12-
RpcAccountInfoConfig,
13-
RpcProgramAccountsConfig,
14-
},
15-
rpc_filter::{
16-
Memcmp,
17-
RpcFilterType,
18-
},
11+
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
12+
rpc_filter::{Memcmp, RpcFilterType},
1913
},
2014
solana_sdk::pubkey::Pubkey,
21-
std::{
22-
fs,
23-
str::FromStr,
24-
time::Duration,
25-
},
15+
std::{fs, str::FromStr, time::Duration},
2616
tokio::time::sleep,
2717
tokio_stream::StreamExt,
28-
wormhole_sdk::{
29-
vaa::Body,
30-
Address,
31-
Chain,
32-
},
18+
wormhole_sdk::{vaa::Body, Address, Chain},
3319
};
3420

3521
mod config;
3622
mod posted_message;
3723
mod signed_body;
3824

3925
struct ListenerConfig {
40-
ws_url: String,
41-
secret_key: SecretKey,
42-
wormhole_pid: Pubkey,
26+
ws_url: String,
27+
secret_key: SecretKey,
28+
wormhole_pid: Pubkey,
4329
accumulator_address: Pubkey,
4430
}
4531

@@ -58,20 +44,18 @@ async fn run_listener(config: ListenerConfig) -> Result<(), PubsubClientError> {
5844
.program_subscribe(
5945
&config.wormhole_pid,
6046
Some(RpcProgramAccountsConfig {
61-
filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new(
47+
filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new(
6248
0,
6349
solana_client::rpc_filter::MemcmpEncodedBytes::Bytes(b"msu".to_vec()),
6450
))]),
6551
account_config: RpcAccountInfoConfig {
66-
encoding: Some(UiAccountEncoding::Base64),
67-
data_slice: None,
68-
commitment: Some(
69-
solana_sdk::commitment_config::CommitmentConfig::confirmed(),
70-
),
52+
encoding: Some(UiAccountEncoding::Base64),
53+
data_slice: None,
54+
commitment: Some(solana_sdk::commitment_config::CommitmentConfig::confirmed()),
7155
min_context_slot: None,
7256
},
73-
with_context: None,
74-
sort_results: None,
57+
with_context: None,
58+
sort_results: None,
7559
}),
7660
)
7761
.await?;
@@ -109,13 +93,13 @@ async fn run_listener(config: ListenerConfig) -> Result<(), PubsubClientError> {
10993
}
11094

11195
let body = Body {
112-
timestamp: unreliable_data.submission_time,
113-
nonce: unreliable_data.nonce,
114-
emitter_chain: unreliable_data.emitter_chain.into(),
115-
emitter_address: Address(unreliable_data.emitter_address),
116-
sequence: unreliable_data.sequence,
96+
timestamp: unreliable_data.submission_time,
97+
nonce: unreliable_data.nonce,
98+
emitter_chain: unreliable_data.emitter_chain.into(),
99+
emitter_address: Address(unreliable_data.emitter_address),
100+
sequence: unreliable_data.sequence,
117101
consistency_level: unreliable_data.consistency_level,
118-
payload: unreliable_data.payload.clone(),
102+
payload: unreliable_data.payload.clone(),
119103
};
120104

121105
match SignedBody::try_new(body, config.secret_key) {

src/posted_message.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
use {
2-
borsh::{
3-
BorshDeserialize,
4-
BorshSerialize,
5-
},
6-
serde::{
7-
Deserialize,
8-
Serialize,
9-
},
2+
borsh::{BorshDeserialize, BorshSerialize},
3+
serde::{Deserialize, Serialize},
104
std::{
11-
io::{
12-
Error,
13-
ErrorKind::InvalidData,
14-
Write,
15-
},
16-
ops::{
17-
Deref,
18-
DerefMut,
19-
},
5+
io::{Error, ErrorKind::InvalidData, Write},
6+
ops::{Deref, DerefMut},
207
},
218
};
229

src/signed_body.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
use {
2-
secp256k1::{
3-
Message,
4-
Secp256k1,
5-
SecretKey,
6-
},
2+
secp256k1::{Message, Secp256k1, SecretKey},
73
serde::Serialize,
84
wormhole_sdk::vaa::Body,
95
};
106

117
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
128
pub struct SignedBody<P> {
13-
pub version: u8,
9+
pub version: u8,
1410
pub signature: [u8; 65],
15-
pub body: Body<P>,
11+
pub body: Body<P>,
1612
}
1713

1814
impl<P: Serialize> SignedBody<P> {

0 commit comments

Comments
 (0)