Skip to content

Commit f4109ec

Browse files
style(onchain): apply correct cargo fmt formatting
Revert add_to_status_totals calls to single-line format. Map init in helper now two lines as preferred by rustfmt.
1 parent 687a25d commit f4109ec

1 file changed

Lines changed: 14 additions & 73 deletions

File tree

  • app/onchain/contracts/aid_escrow/src

app/onchain/contracts/aid_escrow/src/lib.rs

Lines changed: 14 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,7 @@ impl AidEscrow {
670670
env.storage().persistent().set(&key, &package);
671671

672672
// Increment running committed total for the token
673-
Self::add_to_status_totals(
674-
&env,
675-
&token,
676-
PackageStatus::Created,
677-
amount,
678-
);
673+
Self::add_to_status_totals(&env, &token, PackageStatus::Created, amount);
679674

680675
let counter: u64 = env.storage().instance().get(&KEY_PKG_COUNTER).unwrap_or(0);
681676
if id >= counter {
@@ -804,12 +799,7 @@ impl AidEscrow {
804799
env.storage().persistent().set(&key, &package);
805800

806801
// Track running committed total
807-
Self::add_to_status_totals(
808-
&env,
809-
&token,
810-
PackageStatus::Created,
811-
amount,
812-
);
802+
Self::add_to_status_totals(&env, &token, PackageStatus::Created, amount);
813803

814804
// Track package index for aggregation
815805
let idx_key = (symbol_short!("pidx"), idx);
@@ -984,18 +974,8 @@ impl AidEscrow {
984974
Self::decrement_locked(&env, &package.token, package.amount);
985975

986976
// Transition aggregate totals: Created → Claimed
987-
Self::add_to_status_totals(
988-
&env,
989-
&package.token,
990-
PackageStatus::Created,
991-
-package.amount,
992-
);
993-
Self::add_to_status_totals(
994-
&env,
995-
&package.token,
996-
PackageStatus::Claimed,
997-
package.amount,
998-
);
977+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Created, -package.amount);
978+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Claimed, package.amount);
999979

1000980
let timestamp = env.ledger().timestamp();
1001981
PackageDisbursed {
@@ -1034,18 +1014,8 @@ impl AidEscrow {
10341014
Self::decrement_locked(&env, &package.token, package.amount);
10351015

10361016
// Transition aggregate totals: Created → Cancelled (counts as expired/cancelled)
1037-
Self::add_to_status_totals(
1038-
&env,
1039-
&package.token,
1040-
PackageStatus::Created,
1041-
-package.amount,
1042-
);
1043-
Self::add_to_status_totals(
1044-
&env,
1045-
&package.token,
1046-
PackageStatus::Cancelled,
1047-
package.amount,
1048-
);
1017+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Created, -package.amount);
1018+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Cancelled, package.amount);
10491019

10501020
let timestamp = env.ledger().timestamp();
10511021
PackageRevoked {
@@ -1117,18 +1087,8 @@ impl AidEscrow {
11171087

11181088
// Transition aggregate totals: if the package was Committed, move it to expired/cancelled.
11191089
if was_committed {
1120-
Self::add_to_status_totals(
1121-
&env,
1122-
&package.token,
1123-
PackageStatus::Created,
1124-
-package.amount,
1125-
);
1126-
Self::add_to_status_totals(
1127-
&env,
1128-
&package.token,
1129-
PackageStatus::Refunded,
1130-
package.amount,
1131-
);
1090+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Created, -package.amount);
1091+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Refunded, package.amount);
11321092
}
11331093

11341094
let timestamp = env.ledger().timestamp();
@@ -1177,18 +1137,8 @@ impl AidEscrow {
11771137
Self::decrement_locked(&env, &package.token, package.amount);
11781138

11791139
// Transition aggregate totals: Created → Cancelled (counts as expired/cancelled)
1180-
Self::add_to_status_totals(
1181-
&env,
1182-
&package.token,
1183-
PackageStatus::Created,
1184-
-package.amount,
1185-
);
1186-
Self::add_to_status_totals(
1187-
&env,
1188-
&package.token,
1189-
PackageStatus::Cancelled,
1190-
package.amount,
1191-
);
1140+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Created, -package.amount);
1141+
Self::add_to_status_totals(&env, &package.token, PackageStatus::Cancelled, package.amount);
11921142

11931143
let timestamp = env.ledger().timestamp();
11941144
PackageRevoked {
@@ -1465,18 +1415,8 @@ impl AidEscrow {
14651415
Self::decrement_locked(env, &package.token, package.amount);
14661416

14671417
// Transition aggregate totals: Created → Claimed
1468-
Self::add_to_status_totals(
1469-
env,
1470-
&package.token,
1471-
PackageStatus::Created,
1472-
-package.amount,
1473-
);
1474-
Self::add_to_status_totals(
1475-
env,
1476-
&package.token,
1477-
PackageStatus::Claimed,
1478-
package.amount,
1479-
);
1418+
Self::add_to_status_totals(env, &package.token, PackageStatus::Created, -package.amount);
1419+
Self::add_to_status_totals(env, &package.token, PackageStatus::Claimed, package.amount);
14801420

14811421
PackageClaimed {
14821422
package_id,
@@ -1629,7 +1569,8 @@ impl AidEscrow {
16291569
return;
16301570
}
16311571

1632-
let mut map: Map<Address, i128> = env.storage().instance().get(&key).unwrap_or(Map::new(env));
1572+
let mut map: Map<Address, i128> =
1573+
env.storage().instance().get(&key).unwrap_or(Map::new(env));
16331574

16341575
let current = map.get(token.clone()).unwrap_or(0);
16351576

0 commit comments

Comments
 (0)