Skip to content

Commit

Permalink
Cargo-fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dfordivam committed Feb 21, 2024
1 parent 17a2cbe commit ba84529
Showing 1 changed file with 120 additions and 18 deletions.
138 changes: 120 additions & 18 deletions rust-app/src/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,25 @@ impl<BS: Clone + Readable> AsyncParser<CallArgSchema, BS> for DefaultInterp {
)
.await;
}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
CallArg::ObjectArg
}
_ => {
trace!("CallArgSchema: Unknown enum: {}", enum_variant);
reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
Expand Down Expand Up @@ -223,7 +235,12 @@ impl<BS: Clone + Readable> AsyncParser<CommandSchema, BS> for DefaultInterp {
}
_ => {
trace!("CommandSchema: Unknown enum: {}", enum_variant);
reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
Expand Down Expand Up @@ -275,7 +292,14 @@ impl<BS: Clone + Readable> AsyncParser<ArgumentSchema, BS> for DefaultInterp {
.await,
)
}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
}
Expand Down Expand Up @@ -316,13 +340,27 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<ProgrammableTransacti
recipient_index = Some(i);
}
// Reject on multiple RecipientAddress(s)
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
},
CallArg::Amount(amt) =>
{
#[allow(clippy::single_match)]
match amounts.try_push((amt, i)) {
Err(_) => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
Err(_) => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
_ => {}
}
}
Expand All @@ -332,7 +370,12 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<ProgrammableTransacti
}

if recipient_index.is_none() || amounts.is_empty() {
reject_on::<()>(core::file!(), core::line!(), SyscallError::NotSupported as u16).await;
reject_on::<()>(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await;
}

let mut verified_recipient = false;
Expand All @@ -352,23 +395,47 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<ProgrammableTransacti
Command::TransferObject(_nested_results, recipient_input) => {
if verified_recipient {
// Reject more than one TransferObject(s)
reject_on::<()>(core::file!(), core::line!(), SyscallError::NotSupported as u16).await;
reject_on::<()>(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await;
}
match recipient_input {
Argument::Input(inp_index) => {
if Some(inp_index as u32) != recipient_index {
trace!("TransferObject recipient mismatch");
reject_on::<()>(core::file!(), core::line!(), SyscallError::NotSupported as u16).await;
reject_on::<()>(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await;
}
verified_recipient = true;
}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
Command::SplitCoins(coin, input_indices) => {
match coin {
Argument::GasCoin => {}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
for arg in &input_indices {
match arg {
Expand All @@ -378,14 +445,25 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<ProgrammableTransacti
match total_amount.checked_add(*amt) {
Some(t) => total_amount = t,
None => {
reject_on(core::file!(), core::line!(), SyscallError::InvalidParameter as u16)
.await
reject_on(
core::file!(),
core::line!(),
SyscallError::InvalidParameter as u16,
)
.await
}
}
}
}
}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
}
Expand All @@ -394,7 +472,12 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<ProgrammableTransacti
}

if !verified_recipient {
reject_on::<()>(core::file!(), core::line!(), SyscallError::NotSupported as u16).await;
reject_on::<()>(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await;
}

if PROMPT
Expand Down Expand Up @@ -444,7 +527,12 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<TransactionKind<PROMP
}
_ => {
trace!("TransactionKind: {}", enum_variant);
reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
Expand Down Expand Up @@ -492,7 +580,14 @@ impl<BS: Clone + Readable> AsyncParser<TransactionExpiration, BS> for DefaultInt
trace!("TransactionExpiration: Epoch");
<DefaultInterp as AsyncParser<EpochId, BS>>::parse(&DefaultInterp, input).await;
}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
}
Expand Down Expand Up @@ -568,7 +663,14 @@ impl<BS: Clone + Readable, const PROMPT: bool> AsyncParser<TransactionData<PROMP
trace!("TransactionData: V1");
transaction_data_v1_parser::<_, PROMPT>().parse(input).await;
}
_ => reject_on(core::file!(), core::line!(), SyscallError::NotSupported as u16).await,
_ => {
reject_on(
core::file!(),
core::line!(),
SyscallError::NotSupported as u16,
)
.await
}
}
}
}
Expand Down

0 comments on commit ba84529

Please sign in to comment.