Skip to content

Commit

Permalink
Revert to standard formatting (#794)
Browse files Browse the repository at this point in the history
* rustfmt.toml considered harmful

* reenable fmt check in CI

* fmt
  • Loading branch information
Dzejkop authored Oct 17, 2024
1 parent 45019a5 commit f30275b
Show file tree
Hide file tree
Showing 32 changed files with 263 additions and 276 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ jobs:
target/
key: ${{ env.RUST_VERSION }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ env.RUST_VERSION }}-cargo-lint-
# - name: Check formatting
# uses: actions-rs/cargo@v1
# with:
# command: fmt
# args: --all -- --check
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions crates/cognitoauth/src/cognito_srp_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use cognito_srp::SrpClient;
use crate::error::CognitoSrpAuthError;

pub struct CognitoAuthInput {
pub client_id: String,
pub pool_id: String,
pub username: String,
pub password: String,
pub mfa: Option<String>,
pub client_id: String,
pub pool_id: String,
pub username: String,
pub password: String,
pub mfa: Option<String>,
pub client_secret: Option<String>, // not yet supported
}

Expand Down
22 changes: 11 additions & 11 deletions crates/micro-oz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub struct Pinhead {
}

struct PinheadInner {
signer: Arc<PinheadSigner>,
is_running: AtomicBool,
tx_id_counter: AtomicU64,
signer: Arc<PinheadSigner>,
is_running: AtomicBool,
tx_id_counter: AtomicU64,
txs_to_execute: mpsc::Sender<String>,
txs: Mutex<HashMap<String, Arc<Mutex<RelayerTransactionBase>>>>,
txs: Mutex<HashMap<String, Arc<Mutex<RelayerTransactionBase>>>>,
}

impl Drop for PinheadInner {
Expand Down Expand Up @@ -154,16 +154,16 @@ impl Pinhead {

let tx = RelayerTransactionBase {
transaction_id: tx_id.clone(),
to: tx_request.to.context("Missing to")?,
value: tx_request.value,
gas_limit: tx_request
to: tx_request.to.context("Missing to")?,
value: tx_request.value,
gas_limit: tx_request
.gas_limit
.map(|gas_limit| gas_limit.as_u32())
.unwrap_or(DEFAULT_GAS_LIMIT),
data: tx_request.data,
status: Status::Pending,
hash: None,
valid_until: tx_request
data: tx_request.data,
status: Status::Pending,
hash: None,
valid_until: tx_request
.valid_until
.unwrap_or(Utc::now() + chrono::Duration::hours(24)),
};
Expand Down
8 changes: 4 additions & 4 deletions crates/micro-oz/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct ListTransactionsQuery {
#[serde(default)]
status: Option<Status>,
#[serde(default)]
limit: Option<usize>,
limit: Option<usize>,
}

async fn list_transactions(
Expand Down Expand Up @@ -72,9 +72,9 @@ async fn query_transaction(
}

pub struct ServerHandle {
pinhead: Pinhead,
addr: SocketAddr,
shutdown_notify: Arc<Notify>,
pinhead: Pinhead,
addr: SocketAddr,
shutdown_notify: Arc<Notify>,
server_join_handle: JoinHandle<Result<(), hyper::Error>>,
}

Expand Down
14 changes: 7 additions & 7 deletions crates/oz-api/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const POOL_ID: &str = "us-west-2_iLmIggsiy";

#[derive(Clone, Debug)]
pub struct ExpiringHeaders {
pub headers: HeaderMap,
pub headers: HeaderMap,
/// The timestamp at which the headers will expire in seconds
pub expiration_time: Instant,
}

impl ExpiringHeaders {
pub fn empty() -> Self {
Self {
headers: HeaderMap::new(),
headers: HeaderMap::new(),
expiration_time: Instant::now(),
}
}
Expand All @@ -29,11 +29,11 @@ impl ExpiringHeaders {
let now = Instant::now();

let input = CognitoAuthInput {
client_id: CLIENT_ID.to_string(),
pool_id: POOL_ID.to_string(),
username: api_key.to_string(),
password: api_secret.to_string(),
mfa: None,
client_id: CLIENT_ID.to_string(),
pool_id: POOL_ID.to_string(),
username: api_key.to_string(),
password: api_secret.to_string(),
mfa: None,
client_secret: None,
};

Expand Down
30 changes: 15 additions & 15 deletions crates/oz-api/src/data/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ impl fmt::Display for Status {
#[serde(rename_all = "camelCase")]
pub struct SendBaseTransactionRequest<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub to: Option<&'a NameOrAddress>,
pub to: Option<&'a NameOrAddress>,
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<&'a U256>,
pub value: Option<&'a U256>,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<&'a Bytes>,
pub data: Option<&'a Bytes>,
#[serde(skip_serializing_if = "Option::is_none")]
pub gas_limit: Option<&'a U256>,
pub gas_limit: Option<&'a U256>,
#[serde(skip_serializing_if = "Option::is_none")]
pub valid_until: Option<DateTime<Utc>>,
}
Expand All @@ -63,16 +63,16 @@ pub struct SendBaseTransactionRequest<'a> {
pub struct SendBaseTransactionRequestOwned {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub to: Option<NameOrAddress>,
pub to: Option<NameOrAddress>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub value: Option<U256>,
pub value: Option<U256>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub data: Option<Bytes>,
pub data: Option<Bytes>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub gas_limit: Option<U256>,
pub gas_limit: Option<U256>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub valid_until: Option<DateTime<Utc>>,
Expand All @@ -87,16 +87,16 @@ pub struct SendBaseTransactionRequestOwned {
pub struct RelayerTransactionBase {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub hash: Option<H256>,
pub hash: Option<H256>,
pub transaction_id: String,
pub to: NameOrAddress,
pub to: NameOrAddress,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub value: Option<U256>,
pub gas_limit: u32,
pub value: Option<U256>,
pub gas_limit: u32,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub data: Option<Bytes>,
pub valid_until: DateTime<Utc>,
pub status: Status,
pub data: Option<Bytes>,
pub valid_until: DateTime<Utc>,
pub status: Status,
}
10 changes: 5 additions & 5 deletions crates/oz-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ pub type Result<T> = std::result::Result<T, error::Error>;

#[derive(Debug)]
pub struct OzApi {
client: reqwest::Client,
api_url: Url,
client: reqwest::Client,
api_url: Url,
expiring_headers: Mutex<ExpiringHeaders>,
api_key: String,
api_secret: String,
auth_disabled: bool,
api_key: String,
api_secret: String,
auth_disabled: bool,
}

impl OzApi {
Expand Down
26 changes: 13 additions & 13 deletions crates/tx-sitter-client/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ mod decimal_u256;
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SendTxRequest {
pub to: Address,
pub to: Address,
#[serde(with = "decimal_u256")]
pub value: U256,
pub value: U256,
#[serde(default)]
pub data: Option<Bytes>,
pub data: Option<Bytes>,
#[serde(with = "decimal_u256")]
pub gas_limit: U256,
#[serde(default)]
pub priority: TransactionPriority,
pub priority: TransactionPriority,
#[serde(default)]
pub tx_id: Option<String>,
pub tx_id: Option<String>,
}

#[derive(Deserialize, Serialize, Debug, Clone, Copy, Default)]
Expand All @@ -26,12 +26,12 @@ pub enum TransactionPriority {
// 5th percentile
Slowest = 0,
// 25th percentile
Slow = 1,
Slow = 1,
// 50th percentile
#[default]
Regular = 2,
// 75th percentile
Fast = 3,
Fast = 3,
// 95th percentile
Fastest = 4,
}
Expand All @@ -45,21 +45,21 @@ pub struct SendTxResponse {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetTxResponse {
pub tx_id: String,
pub to: Address,
pub tx_id: String,
pub to: Address,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub data: Option<Bytes>,
pub data: Option<Bytes>,
#[serde(with = "decimal_u256")]
pub value: U256,
pub value: U256,
#[serde(with = "decimal_u256")]
pub gas_limit: U256,
pub nonce: u64,
pub nonce: u64,

// Sent tx data
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tx_hash: Option<H256>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status: Option<TxStatus>,
pub status: Option<TxStatus>,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, Display, PartialEq, Eq)]
Expand Down
4 changes: 2 additions & 2 deletions e2e_tests/scenarios/tests/common/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::common::prelude::StatusCode;

pub struct RawResponse {
pub status_code: StatusCode,
pub body: String,
pub body: String,
}

pub async fn insert_identity(
Expand Down Expand Up @@ -118,7 +118,7 @@ pub async fn inclusion_proof_raw(

Ok(RawResponse {
status_code: response.status(),
body: result,
body: result,
})
}

Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/scenarios/tests/common/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type SpecialisedFactory = ContractFactory<SpecialisedClient>;
pub type SpecialisedContract = Contract<SpecialisedClient>;

pub struct Chain {
pub private_key: SigningKey,
pub private_key: SigningKey,
pub identity_manager: IWorldIDIdentityManager<SpecialisedClient>,
}

Expand Down
19 changes: 0 additions & 19 deletions rustfmt.toml

This file was deleted.

18 changes: 9 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ use crate::server::data::{
use crate::server::error::Error as ServerError;

pub struct App {
pub database: Arc<Database>,
pub database: Arc<Database>,
pub identity_processor: Arc<dyn IdentityProcessor>,
pub prover_repository: Arc<ProverRepository>,
tree_state: OnceLock<TreeState>,
pub config: Config,
pub prover_repository: Arc<ProverRepository>,
tree_state: OnceLock<TreeState>,
pub config: Config,

pub identity_validator: IdentityValidator,
}
Expand Down Expand Up @@ -293,9 +293,9 @@ impl App {
.iter()
.cloned()
.map(|opt| ProverConfig {
url: opt.url,
batch_size: opt.batch_size,
timeout_s: opt.timeout_s,
url: opt.url,
batch_size: opt.batch_size,
timeout_s: opt.timeout_s,
prover_type: opt.prover_type,
})
.collect();
Expand Down Expand Up @@ -375,8 +375,8 @@ impl App {

if let Some(error_message) = self.database.get_unprocessed_error(commitment).await? {
return Ok(InclusionProof {
root: None,
proof: None,
root: None,
proof: None,
message: error_message
.or_else(|| Some("identity exists but has not yet been processed".to_string())),
}
Expand Down
6 changes: 3 additions & 3 deletions src/bin/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async fn main() -> anyhow::Result<()> {
#[derive(Debug, Clone, Serialize, Deserialize)]
struct SerializedIdentity {
nullifier: Field,
trapdoor: Field,
trapdoor: Field,
}

async fn load_identity(path: impl AsRef<Path>) -> anyhow::Result<Identity> {
Expand All @@ -275,14 +275,14 @@ async fn load_identity(path: impl AsRef<Path>) -> anyhow::Result<Identity> {

Ok(Identity {
nullifier: identity.nullifier,
trapdoor: identity.trapdoor,
trapdoor: identity.trapdoor,
})
}

async fn save_identity(path: impl AsRef<Path>, identity: &Identity) -> anyhow::Result<()> {
let identity = SerializedIdentity {
nullifier: identity.nullifier,
trapdoor: identity.trapdoor,
trapdoor: identity.trapdoor,
};

let identity = serde_json::to_string_pretty(&identity)?;
Expand Down
Loading

0 comments on commit f30275b

Please sign in to comment.