Contracts: apply rustfmt to the contract module

cargo fmt --all -- --check is now clean across the workspace.
This commit is contained in:
jwinterm
2026-07-26 07:50:25 -04:00
parent 894023a863
commit fb10280165
8 changed files with 17 additions and 18 deletions
+1 -1
View File
@@ -14,6 +14,7 @@
//! Implementation of contract new
use crate::backend::WalletBackend;
use crate::contract;
use crate::contract::actions::setup;
use crate::contract::types::ContractSetupArgsAPI;
@@ -22,7 +23,6 @@ use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
use crate::slate::Slate;
use crate::types::{Context, NodeClient};
use crate::backend::WalletBackend;
use uuid::Uuid;
/// Create a new contract with initial setup done by the initiator. `slate_id`, when
+7 -7
View File
@@ -13,6 +13,8 @@
// limitations under the License.
//! Implementation of contract revoke
use crate::backend::WalletBackend;
use crate::blake2::blake2b::blake2b;
use crate::contract::types::{ContractRevokeArgsAPI, ContractSetupArgsAPI, OutputSelectionArgs};
use crate::contract::{new, sign};
use crate::error::Error;
@@ -21,8 +23,6 @@ use crate::grin_util::secp::key::SecretKey;
use crate::internal::tx;
use crate::slate::Slate;
use crate::types::{NodeClient, OutputData, OutputStatus, TxLogEntryType};
use crate::backend::WalletBackend;
use crate::blake2::blake2b::blake2b;
use uuid::Uuid;
/// Deterministic slate id for the self-spend that revokes a given contract slate.
@@ -97,8 +97,7 @@ where
// Drop the canceled slate's private context if one still exists (signing already
// deletes it).
if let Some(slate_id) = revoked_slate_id {
if w
.get_private_context(keychain_mask, slate_id.as_bytes())
if w.get_private_context(keychain_mask, slate_id.as_bytes())
.is_ok()
{
let mut batch = w.batch(keychain_mask)?;
@@ -113,9 +112,10 @@ where
if my_contributed_inputs.is_empty() {
return Ok(None);
}
let input_commit = my_contributed_inputs[0].commit.as_ref().ok_or_else(|| {
Error::GenericError("Locked input has no cached commitment".to_string())
})?;
let input_commit = my_contributed_inputs[0]
.commit
.as_ref()
.ok_or_else(|| Error::GenericError("Locked input has no cached commitment".to_string()))?;
// Account label for the self-spend, so recovered funds return to the inputs' account.
let src_acct_name = w
.acct_path_iter()?
+1 -1
View File
@@ -15,6 +15,7 @@
//! Implementation of contract setup
use crate::api_impl::owner::check_ttl;
use crate::backend::WalletBackend;
use crate::contract;
use crate::contract::types::ContractSetupArgsAPI;
use crate::error::Error;
@@ -22,7 +23,6 @@ use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
use crate::slate::Slate;
use crate::types::{Context, NodeClient};
use crate::backend::WalletBackend;
/// Perform a contract setup
pub fn setup<C, K>(
+1 -1
View File
@@ -14,6 +14,7 @@
//! Implementation of contract sign
use crate::backend::WalletBackend;
use crate::contract;
use crate::contract::actions::setup;
use crate::contract::types::ContractSetupArgsAPI;
@@ -22,7 +23,6 @@ use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
use crate::slate::Slate;
use crate::types::{Context, NodeClient};
use crate::backend::WalletBackend;
/// Sign a contract
pub fn sign<C, K>(
+2 -2
View File
@@ -14,13 +14,13 @@
//! Implementation of contract view
use crate::backend::WalletBackend;
use crate::contract::types::ContractView;
use crate::error::Error;
use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
use crate::slate::{Slate, SlateState};
use crate::types::{NodeClient};
use crate::backend::WalletBackend;
use crate::types::NodeClient;
/// View contract
pub fn view<C, K>(
+1 -1
View File
@@ -14,6 +14,7 @@
//! Contract functions on the Context
use crate::backend::WalletBackend;
use crate::contract::selection::prepare_outputs;
use crate::contract::types::ContractSetupArgsAPI;
use crate::contract::utils as contract_utils;
@@ -22,7 +23,6 @@ use crate::grin_util::secp::key::SecretKey;
use crate::internal::updater;
use crate::slate::Slate;
use crate::types::{Context, NodeClient};
use crate::backend::WalletBackend;
use crate::{Error, OutputData};
use grin_core::core::FeeFields;
+2 -2
View File
@@ -14,12 +14,12 @@
//! Contract coin selection functions
use crate::backend::WalletBackend;
use crate::contract::types::{ContractSetupArgsAPI, OutputSelectionArgs};
use crate::contract::utils::my_fee_contribution;
use crate::grin_core::core::amount_to_hr_string;
use crate::grin_keychain::{Identifier, Keychain};
use crate::types::{NodeClient};
use crate::backend::WalletBackend;
use crate::types::NodeClient;
use crate::{Error, OutputData};
use grin_core::core::FeeFields;
+2 -3
View File
@@ -14,6 +14,7 @@
//! Contract building utility functions
use crate::backend::WalletBackend;
use crate::contract::selection::verify_selection_consistency;
use crate::contract::types::ContractSetupArgsAPI;
use crate::grin_core::libtx::tx_fee;
@@ -21,7 +22,6 @@ use crate::grin_keychain::{Identifier, Keychain};
use crate::grin_util::secp::key::SecretKey;
use crate::slate::Slate;
use crate::types::{Context, NodeClient, StoredProofInfo, TxLogEntryType};
use crate::backend::WalletBackend;
use crate::util::OnionV3Address;
use crate::{address, Error, OutputData, OutputStatus, TxLogEntry};
use grin_core::core::FeeFields;
@@ -288,8 +288,7 @@ where
// gone so the nonce can never be reused. It is deleted in the is_signed && !is_step2
// branch above; verify the deletion actually took effect.
if is_signed && !is_step2 {
if w
.get_private_context(keychain_mask, slate.id.as_bytes())
if w.get_private_context(keychain_mask, slate.id.as_bytes())
.is_ok()
{
return Err(Error::GenericError(