Skip to content

Commit 00812fc

Browse files
committed
Rebase master
1 parent cfc3878 commit 00812fc

File tree

142 files changed

+5470
-2559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+5470
-2559
lines changed

.github/workflows/ci.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ env:
1919
REGISTRY: ghcr.io
2020

2121
jobs:
22+
rustfmt:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Install latest nightly
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
toolchain: nightly
30+
override: true
31+
components: rustfmt
32+
33+
- name: Rustfmt check
34+
run: cargo +nightly fmt --all -- --check
35+
2236
lint-toml-files:
2337
runs-on: ubuntu-latest
2438
steps:
@@ -75,8 +89,6 @@ jobs:
7589
strategy:
7690
matrix:
7791
include:
78-
- command: fmt
79-
args: --all --verbose -- --check
8092
- command: clippy
8193
args: --all-targets --all-features
8294
- command: check

.rustfmt.toml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
max_width = 90 # changed
2+
hard_tabs = false
3+
tab_spaces = 4
4+
newline_style = "Auto"
5+
use_small_heuristics = "Default"
6+
indent_style = "Block"
7+
wrap_comments = false
8+
format_code_in_doc_comments = false
9+
comment_width = 80
10+
normalize_comments = true # changed
11+
normalize_doc_attributes = false
12+
format_strings = false
13+
format_macro_matchers = false
14+
format_macro_bodies = true
15+
empty_item_single_line = true
16+
struct_lit_single_line = true
17+
fn_single_line = false
18+
where_single_line = false
19+
imports_indent = "Block"
20+
imports_layout = "Vertical" # changed
21+
imports_granularity = "Crate" # changed
22+
reorder_imports = true
23+
reorder_modules = true
24+
reorder_impl_items = false
25+
type_punctuation_density = "Wide"
26+
space_before_colon = false
27+
space_after_colon = true
28+
spaces_around_ranges = false
29+
binop_separator = "Front"
30+
remove_nested_parens = true
31+
combine_control_expr = false # changed
32+
overflow_delimited_expr = false
33+
struct_field_align_threshold = 0
34+
enum_discrim_align_threshold = 0
35+
match_arm_blocks = true
36+
force_multiline_blocks = true # changed
37+
fn_args_layout = "Tall"
38+
brace_style = "SameLineWhere"
39+
control_brace_style = "AlwaysSameLine"
40+
trailing_semicolon = false # changed
41+
trailing_comma = "Vertical"
42+
match_block_trailing_comma = false
43+
blank_lines_upper_bound = 1
44+
blank_lines_lower_bound = 0
45+
edition = "2021" # changed
46+
version = "One"
47+
merge_derives = true
48+
use_try_shorthand = true # changed
49+
use_field_init_shorthand = true # changed
50+
force_explicit_abi = true
51+
condense_wildcard_suffixes = false
52+
color = "Auto"
53+
unstable_features = false
54+
disable_all_formatting = false
55+
skip_children = false
56+
hide_parse_errors = false
57+
error_on_line_overflow = false
58+
error_on_unformatted = false
59+
ignore = []
60+
61+
# Below are `rustfmt` internal settings
62+
#
63+
# emit_mode = "Files"
64+
# make_backup = false

fuel-block-importer/src/service.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
use crate::Config;
2-
use fuel_core_interfaces::block_importer::{ImportBlockBroadcast, ImportBlockMpsc};
2+
use fuel_core_interfaces::block_importer::{
3+
ImportBlockBroadcast,
4+
ImportBlockMpsc,
5+
};
36
use parking_lot::Mutex;
47
use tokio::{
5-
sync::{broadcast, mpsc},
8+
sync::{
9+
broadcast,
10+
mpsc,
11+
},
612
task::JoinHandle,
713
};
814

fuel-block-producer/src/service.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
use crate::Config;
2-
use fuel_core_interfaces::{block_producer::BlockProducerMpsc, txpool};
2+
use fuel_core_interfaces::{
3+
block_producer::BlockProducerMpsc,
4+
txpool,
5+
};
36
use parking_lot::Mutex;
4-
use tokio::{sync::mpsc, task::JoinHandle};
7+
use tokio::{
8+
sync::mpsc,
9+
task::JoinHandle,
10+
};
511

612
pub struct Service {
713
join: Mutex<Option<JoinHandle<()>>>,

fuel-client/build.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
use schemafy_lib::{Expander, Schema};
2-
use std::env;
3-
use std::fs::{self, File};
4-
use std::io::prelude::*;
5-
use std::path::PathBuf;
1+
use schemafy_lib::{
2+
Expander,
3+
Schema,
4+
};
5+
use std::{
6+
env,
7+
fs::{
8+
self,
9+
File,
10+
},
11+
io::prelude::*,
12+
path::PathBuf,
13+
};
614

715
fn main() {
816
println!("cargo:rerun-if-changed=./assets/debugAdapterProtocol.json");
@@ -13,7 +21,8 @@ fn main() {
1321
.expect("Failed to fetch JSON schema");
1422

1523
let json = fs::read_to_string(&path).expect("Failed to parse JSON from schema");
16-
let schema: Schema = serde_json::from_str(&json).expect("Failed to parse Schema from JSON");
24+
let schema: Schema =
25+
serde_json::from_str(&json).expect("Failed to parse Schema from JSON");
1726
let root_name = schema.title.clone().unwrap_or_else(|| "Root".to_owned());
1827

1928
let path = path.into_os_string();

fuel-client/src/client.rs

+90-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,71 @@
11
use crate::client::schema::contract::ContractBalanceQueryArgs;
22
use anyhow::Context;
3-
use cynic::{http::SurfExt, Id, MutationBuilder, Operation, QueryBuilder};
3+
use cynic::{
4+
http::SurfExt,
5+
Id,
6+
MutationBuilder,
7+
Operation,
8+
QueryBuilder,
9+
};
410
use fuel_vm::prelude::*;
511
use itertools::Itertools;
612
use schema::{
713
balance::BalanceArgs,
814
block::BlockByIdArgs,
9-
coin::{Coin, CoinByIdArgs, SpendQueryElementInput},
10-
contract::{Contract, ContractByIdArgs},
11-
tx::{TxArg, TxIdArgs},
12-
Bytes, ContinueTx, ContinueTxArgs, ConversionError, HexString, IdArg, MemoryArgs, RegisterArgs,
13-
RunResult, SetBreakpoint, SetBreakpointArgs, SetSingleStepping, SetSingleSteppingArgs, StartTx,
14-
StartTxArgs, TransactionId, U64,
15+
coin::{
16+
Coin,
17+
CoinByIdArgs,
18+
SpendQueryElementInput,
19+
},
20+
contract::{
21+
Contract,
22+
ContractByIdArgs,
23+
},
24+
tx::{
25+
TxArg,
26+
TxIdArgs,
27+
},
28+
Bytes,
29+
ContinueTx,
30+
ContinueTxArgs,
31+
ConversionError,
32+
HexString,
33+
IdArg,
34+
MemoryArgs,
35+
RegisterArgs,
36+
RunResult,
37+
SetBreakpoint,
38+
SetBreakpointArgs,
39+
SetSingleStepping,
40+
SetSingleSteppingArgs,
41+
StartTx,
42+
StartTxArgs,
43+
TransactionId,
44+
U64,
1545
};
1646
use std::{
1747
convert::TryInto,
18-
io::{self, ErrorKind},
48+
io::{
49+
self,
50+
ErrorKind,
51+
},
1952
net,
20-
str::{self, FromStr},
53+
str::{
54+
self,
55+
FromStr,
56+
},
57+
};
58+
use types::{
59+
TransactionResponse,
60+
TransactionStatus,
2161
};
22-
use types::{TransactionResponse, TransactionStatus};
2362

2463
use crate::client::schema::tx::DryRunArg;
25-
pub use schema::{PageDirection, PaginatedResult, PaginationRequest};
64+
pub use schema::{
65+
PageDirection,
66+
PaginatedResult,
67+
PaginationRequest,
68+
};
2669

2770
use self::schema::block::ProduceBlockArgs;
2871

@@ -175,7 +218,12 @@ impl FuelClient {
175218
Ok(self.query(query).await?.register.0 as Word)
176219
}
177220

178-
pub async fn memory(&self, id: &str, start: usize, size: usize) -> io::Result<Vec<u8>> {
221+
pub async fn memory(
222+
&self,
223+
id: &str,
224+
start: usize,
225+
size: usize,
226+
) -> io::Result<Vec<u8>> {
179227
let query = schema::Memory::build(&MemoryArgs {
180228
id: id.into(),
181229
start: start.into(),
@@ -209,7 +257,11 @@ impl FuelClient {
209257
Ok(())
210258
}
211259

212-
pub async fn set_single_stepping(&self, session_id: &str, enable: bool) -> io::Result<()> {
260+
pub async fn set_single_stepping(
261+
&self,
262+
session_id: &str,
263+
enable: bool,
264+
) -> io::Result<()> {
213265
let operation = SetSingleStepping::build(SetSingleSteppingArgs {
214266
id: Id::new(session_id),
215267
enable,
@@ -218,7 +270,11 @@ impl FuelClient {
218270
Ok(())
219271
}
220272

221-
pub async fn start_tx(&self, session_id: &str, tx: &Transaction) -> io::Result<RunResult> {
273+
pub async fn start_tx(
274+
&self,
275+
session_id: &str,
276+
tx: &Transaction,
277+
) -> io::Result<RunResult> {
222278
let operation = StartTx::build(StartTxArgs {
223279
id: Id::new(session_id),
224280
tx: serde_json::to_string(tx).expect("Couldn't serialize tx to json"),
@@ -314,7 +370,8 @@ impl FuelClient {
314370
}
315371

316372
pub async fn block(&self, id: &str) -> io::Result<Option<schema::block::Block>> {
317-
let query = schema::block::BlockByIdQuery::build(&BlockByIdArgs { id: id.parse()? });
373+
let query =
374+
schema::block::BlockByIdQuery::build(&BlockByIdArgs { id: id.parse()? });
318375

319376
let block = self.query(query).await?.block;
320377

@@ -389,22 +446,28 @@ impl FuelClient {
389446
}
390447

391448
pub async fn contract(&self, id: &str) -> io::Result<Option<Contract>> {
392-
let query =
393-
schema::contract::ContractByIdQuery::build(ContractByIdArgs { id: id.parse()? });
449+
let query = schema::contract::ContractByIdQuery::build(ContractByIdArgs {
450+
id: id.parse()?,
451+
});
394452
let contract = self.query(query).await?.contract;
395453
Ok(contract)
396454
}
397455

398-
pub async fn contract_balance(&self, id: &str, asset: Option<&str>) -> io::Result<u64> {
456+
pub async fn contract_balance(
457+
&self,
458+
id: &str,
459+
asset: Option<&str>,
460+
) -> io::Result<u64> {
399461
let asset_id: schema::AssetId = match asset {
400462
Some(asset) => asset.parse()?,
401463
None => schema::AssetId::default(),
402464
};
403465

404-
let query = schema::contract::ContractBalanceQuery::build(ContractBalanceQueryArgs {
405-
id: id.parse()?,
406-
asset: asset_id,
407-
});
466+
let query =
467+
schema::contract::ContractBalanceQuery::build(ContractBalanceQueryArgs {
468+
id: id.parse()?,
469+
asset: asset_id,
470+
});
408471

409472
let balance = self.query(query).await.unwrap().contract_balance.amount;
410473
Ok(balance.into())
@@ -440,7 +503,9 @@ impl FuelClient {
440503
request: PaginationRequest<String>,
441504
) -> io::Result<PaginatedResult<schema::contract::ContractBalance, String>> {
442505
let contract_id: schema::ContractId = contract.parse()?;
443-
let query = schema::contract::ContractBalancesQuery::build(&(contract_id, request).into());
506+
let query = schema::contract::ContractBalancesQuery::build(
507+
&(contract_id, request).into(),
508+
);
444509

445510
let balances = self.query(query).await?.contract_balances.into();
446511

@@ -452,7 +517,8 @@ impl FuelClient {
452517
owner: Option<&str>,
453518
request: PaginationRequest<String>,
454519
) -> io::Result<PaginatedResult<schema::message::Message, String>> {
455-
let owner: Option<schema::Address> = owner.map(|owner| owner.parse()).transpose()?;
520+
let owner: Option<schema::Address> =
521+
owner.map(|owner| owner.parse()).transpose()?;
456522
let query = schema::message::OwnedMessageQuery::build(&(owner, request).into());
457523

458524
let messages = self.query(query).await?.messages.into();

0 commit comments

Comments
 (0)