Skip to content

Commit

Permalink
refactor: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvolek committed Dec 12, 2023
1 parent ef6ae12 commit e57f49f
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 221 deletions.
44 changes: 7 additions & 37 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
# General
hard_tabs = false
tab_spaces = 4
newline_style = "Unix"
width = 80
# Sets the maximum line length. Code will be wrapped beyond this length.
max_width = 100
error_on_line_overflow = true
error_on_unformatted = true

# Comments
wrap_comments = true
format_code_in_doc_comments = true

# Control Flow
fn_call_width = 60
brace_style = "SameLineWhere"
control_brace_style = "AlwaysSameLine"

# Indentation
indent_style = "Block"
match_block_trailing_comma = true

# Imports
imports_indent = "Block"
imports_layout = "Vertical"
merge_imports = true

# Ordering
reorder_imports = true
reorder_modules = true
# Use spaces for indentation rather than tabs.
hard_tabs = false

# Spaces
spaces_around_ranges = true
spaces_within_angle_brackets = true
spaces_within_parens_and_brackets = true
# Configure the visual indentation of arguments and parameters.
fn_params_layout = "Compressed"

# Misc
use_try_shorthand = true
use_field_init_shorthand = true
normalize_comments = true
normalize_doc_attributes = true
# Controls whether to put `else` on a new line.
newline_style = "Auto"
35 changes: 9 additions & 26 deletions src/api/endpoints/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ impl BlockfrostAPI {

/// Reward history of a specific account.
pub async fn accounts_rewards(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountRewardContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/rewards", stake_address).as_str(),
Expand All @@ -32,9 +30,7 @@ impl BlockfrostAPI {

/// History of a specific account.
pub async fn accounts_history(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountHistoryContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/history", stake_address).as_str(),
Expand All @@ -44,9 +40,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_delegations(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountDelegationContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/delegations", stake_address).as_str(),
Expand All @@ -56,9 +50,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_registrations(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountRegistrationContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/registrations", stake_address).as_str(),
Expand All @@ -68,9 +60,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_withdrawals(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountWithdrawalContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/withdrawals", stake_address).as_str(),
Expand All @@ -80,9 +70,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_mirs(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountMirContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/mirs", stake_address).as_str(),
Expand All @@ -92,9 +80,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_addresses(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountAddressesContentInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/addresses", stake_address).as_str(),
Expand All @@ -104,9 +90,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_addresses_assets(
&self,
stake_address: &str,
pagination: Pagination,
&self, stake_address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AccountAddressesAssetsInner>> {
self.call_paged_endpoint(
format!("/accounts/{}/addresses/assets", stake_address).as_str(),
Expand All @@ -116,8 +100,7 @@ impl BlockfrostAPI {
}

pub async fn accounts_addresses_total(
&self,
stake_address: &str,
&self, stake_address: &str,
) -> BlockfrostResult<AccountAddressesTotal> {
self.call_endpoint(format!("/accounts/{}/addresses/total", stake_address).as_str())
.await
Expand Down
16 changes: 4 additions & 12 deletions src/api/endpoints/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ impl BlockfrostAPI {
}

pub async fn addresses_extended(
&self,
address: &str,
&self, address: &str,
) -> BlockfrostResult<AddressContentExtended> {
self.call_endpoint(format!("/addresses/{}/extended", address).as_str())
.await
Expand All @@ -27,19 +26,14 @@ impl BlockfrostAPI {
}

pub async fn addresses_utxos(
&self,
address: &str,
pagination: Pagination,
&self, address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AddressUtxoContentInner>> {
self.call_paged_endpoint(format!("/addresses/{}/utxos", address).as_str(), pagination)
.await
}

pub async fn addresses_utxos_asset(
&self,
address: &str,
asset: &str,
pagination: Pagination,
&self, address: &str, asset: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AddressUtxoContentInner>> {
self.call_paged_endpoint(
format!("/addresses/{}/utxos/{}", address, asset).as_str(),
Expand All @@ -49,9 +43,7 @@ impl BlockfrostAPI {
}

pub async fn addresses_transactions(
&self,
address: &str,
pagination: Pagination,
&self, address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AddressTransactionsContentInner>> {
self.call_paged_endpoint(
format!("/addresses/{}/transactions", address).as_str(),
Expand Down
16 changes: 4 additions & 12 deletions src/api/endpoints/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ impl BlockfrostAPI {
}

pub async fn assets_history(
&self,
asset: &str,
pagination: Pagination,
&self, asset: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AssetHistoryInner>> {
self.call_paged_endpoint(format!("/assets/{}/history", asset).as_str(), pagination)
.await
}

pub async fn assets_transactions(
&self,
asset: &str,
pagination: Pagination,
&self, asset: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AssetTransactionsInner>> {
self.call_paged_endpoint(
format!("/assets/{}/transactions", asset).as_str(),
Expand All @@ -37,18 +33,14 @@ impl BlockfrostAPI {
}

pub async fn assets_addresses(
&self,
asset: &str,
pagination: Pagination,
&self, asset: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AssetAddressesInner>> {
self.call_paged_endpoint(format!("/assets/{}/addresses", asset).as_str(), pagination)
.await
}

pub async fn assets_policy_by_id(
&self,
policy_id: &str,
pagination: Pagination,
&self, policy_id: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<AssetPolicyInner>> {
self.call_paged_endpoint(format!("/assets/policy/{}", policy_id).as_str(), pagination)
.await
Expand Down
20 changes: 5 additions & 15 deletions src/api/endpoints/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ impl BlockfrostAPI {
}

pub async fn blocks_by_epoch_and_slot(
&self,
epoch_number: i32,
slot_number: i64,
&self, epoch_number: i32, slot_number: i64,
) -> BlockfrostResult<BlockContent> {
self.call_endpoint(format!("/blocks/epoch/{}/slot/{}", epoch_number, slot_number).as_str())
.await
Expand All @@ -33,9 +31,7 @@ impl BlockfrostAPI {
}

pub async fn blocks_next(
&self,
hash_or_number: &str,
pagination: Pagination,
&self, hash_or_number: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<BlockContent>> {
self.call_paged_endpoint(
format!("/blocks/{}/next", hash_or_number).as_str(),
Expand All @@ -45,9 +41,7 @@ impl BlockfrostAPI {
}

pub async fn blocks_previous(
&self,
hash_or_number: &str,
pagination: Pagination,
&self, hash_or_number: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<BlockContent>> {
self.call_paged_endpoint(
format!("/blocks/{}/previous", hash_or_number).as_str(),
Expand All @@ -57,9 +51,7 @@ impl BlockfrostAPI {
}

pub async fn blocks_txs(
&self,
hash_or_number: &str,
pagination: Pagination,
&self, hash_or_number: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<String>> {
self.call_paged_endpoint(
format!("/blocks/{}/txs", hash_or_number).as_str(),
Expand All @@ -69,9 +61,7 @@ impl BlockfrostAPI {
}

pub async fn blocks_affected_addresses(
&self,
hash_or_number: &str,
pagination: Pagination,
&self, hash_or_number: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<BlockContentAddressesInner>> {
self.call_paged_endpoint(
format!("/blocks/{}/addresses", hash_or_number).as_str(),
Expand Down
21 changes: 5 additions & 16 deletions src/api/endpoints/epochs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,28 @@ impl BlockfrostAPI {
}

pub async fn epochs_next(
&self,
number: i32,
pagination: Pagination,
&self, number: i32, pagination: Pagination,
) -> BlockfrostResult<Vec<EpochContent>> {
self.call_paged_endpoint(format!("/epochs/{}/next", number).as_str(), pagination)
.await
}

pub async fn epochs_previous(
&self,
number: i32,
pagination: Pagination,
&self, number: i32, pagination: Pagination,
) -> BlockfrostResult<Vec<EpochContent>> {
self.call_paged_endpoint(format!("/epochs/{}/previous", number).as_str(), pagination)
.await
}

pub async fn epochs_stakes(
&self,
number: i32,
pagination: Pagination,
&self, number: i32, pagination: Pagination,
) -> BlockfrostResult<Vec<EpochStakeContentInner>> {
self.call_paged_endpoint(format!("/epochs/{}/stakes", number).as_str(), pagination)
.await
}

pub async fn epochs_stakes_by_pool(
&self,
number: i32,
pool_id: &str,
pagination: Pagination,
&self, number: i32, pool_id: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<EpochStakePoolContentInner>> {
self.call_paged_endpoint(
format!("/epochs/{}/stakes/{}", number, pool_id).as_str(),
Expand All @@ -71,9 +62,7 @@ impl BlockfrostAPI {
}

pub async fn epochs_blocks_by_pool(
&self,
number: i32,
pool_id: &str,
&self, number: i32, pool_id: &str,
) -> BlockfrostResult<Vec<String>> {
self.call_endpoint(format!("/epochs/{}/blocks/{}", number, pool_id).as_str())
.await
Expand Down
7 changes: 2 additions & 5 deletions src/api/endpoints/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use blockfrost_openapi::models::{

impl BlockfrostAPI {
pub async fn mempool(
&self,
pagination: Pagination,
&self, pagination: Pagination,
) -> BlockfrostResult<Vec<MempoolContentInner>> {
self.call_paged_endpoint("/mempool", pagination).await
}
Expand All @@ -16,9 +15,7 @@ impl BlockfrostAPI {
.await
}
pub async fn mempool_addresses_address(
&self,
address: &str,
pagination: Pagination,
&self, address: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<MempoolContentInner>> {
self.call_paged_endpoint(
format!("/mempool/addresses/{}", address).as_str(),
Expand Down
11 changes: 3 additions & 8 deletions src/api/endpoints/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ use blockfrost_openapi::models::{
impl BlockfrostAPI {
/// List of all used transaction metadata labels.
pub async fn metadata_txs_labels(
&self,
pagination: Pagination,
&self, pagination: Pagination,
) -> BlockfrostResult<Vec<TxMetadataLabelsInner>> {
self.call_paged_endpoint("/metadata/txs/labels", pagination)
.await
}

/// Transaction metadata per label (json).
pub async fn metadata_txs_by_label(
&self,
label: &str,
pagination: Pagination,
&self, label: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<TxMetadataLabelJsonInner>> {
self.call_paged_endpoint(
format!("/metadata/txs/labels/{}", label).as_str(),
Expand All @@ -30,9 +27,7 @@ impl BlockfrostAPI {

/// Transaction metadata per label (cbor).
pub async fn metadata_txs_by_label_cbor(
&self,
label: &str,
pagination: Pagination,
&self, label: &str, pagination: Pagination,
) -> BlockfrostResult<Vec<TxMetadataLabelCborInner>> {
self.call_paged_endpoint(
format!("/metadata/txs/labels/{}/cbor", label).as_str(),
Expand Down
Loading

0 comments on commit e57f49f

Please sign in to comment.