Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 72c8f83

Browse files
Cargo fmt
1 parent f29884b commit 72c8f83

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

frame/contracts/src/exec.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ pub trait Ext: sealing::Sealed {
243243
/// Sets new code hash for existing contract.
244244
fn set_code_hash(&mut self, hash: CodeHash<Self::T>) -> Result<(), DispatchError>;
245245

246-
/// Returns then number of times currently executing contract exists on the call stack in addition
247-
/// to the calling instance. A value of 0 means no reentrancy.
246+
/// Returns then number of times currently executing contract exists on the call stack in
247+
/// addition to the calling instance. A value of 0 means no reentrancy.
248248
fn reentrant_count(&self) -> u32;
249249

250-
/// Returns the number of times specified contract exists on the call stack. Delegated calls are not
251-
/// calculated as separate entrance.
250+
/// Returns the number of times specified contract exists on the call stack. Delegated calls are
251+
/// not calculated as separate entrance.
252252
/// A value of 0 means it does not exist on the call stack.
253253
fn account_entrance_count(&self, account_id: &AccountIdOf<Self::T>) -> u32;
254254
}
@@ -1243,7 +1243,11 @@ where
12431243
}
12441244

12451245
fn account_entrance_count(&self, account_id: &AccountIdOf<Self::T>) -> u32 {
1246-
self.frames().filter_map(|f| (f.delegate_caller.is_none() && &f.account_id == account_id).then(|| true)).count() as u32
1246+
self.frames()
1247+
.filter_map(|f| {
1248+
(f.delegate_caller.is_none() && &f.account_id == account_id).then(|| true)
1249+
})
1250+
.count() as u32
12471251
}
12481252
}
12491253

frame/contracts/src/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,8 +3257,8 @@ fn reentrant_count_works() {
32573257
AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(),
32583258
true,
32593259
)
3260-
.result
3261-
.unwrap();
3260+
.result
3261+
.unwrap();
32623262
});
32633263
}
32643264
#[test]
@@ -3289,7 +3289,7 @@ fn account_entrance_count_works() {
32893289
AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(),
32903290
true,
32913291
)
3292-
.result
3293-
.unwrap();
3292+
.result
3293+
.unwrap();
32943294
});
32953295
}

frame/contracts/src/wasm/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,12 @@ mod tests {
523523
fn ecdsa_to_eth_address(&self, _pk: &[u8; 33]) -> Result<[u8; 20], ()> {
524524
Ok([2u8; 20])
525525
}
526-
fn reentrant_count(&self) -> u32 { 12 }
527-
fn account_entrance_count(&self, _account_id: &AccountIdOf<Self::T>) -> u32 { unimplemented!() }
526+
fn reentrant_count(&self) -> u32 {
527+
12
528+
}
529+
fn account_entrance_count(&self, _account_id: &AccountIdOf<Self::T>) -> u32 {
530+
unimplemented!()
531+
}
528532
}
529533

530534
fn execute<E: BorrowMut<MockExt>>(wat: &str, input_data: Vec<u8>, mut ext: E) -> ExecResult {

frame/contracts/src/wasm/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ define_env!(Env, <E: Ext>,
21102110
// Returns 0 when the contract does not exist on the call stack.
21112111
[__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => {
21122112
ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?;
2113-
let account_id: &<<E as Ext>::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?;
2113+
let account_id: <<E as Ext>::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?;
21142114
Ok(ctx.ext.account_entrance_count(&account_id) as u32)
21152115
},
21162116
);

0 commit comments

Comments
 (0)