Skip to content

Commit ca74ef1

Browse files
jaybuteraRobbepop
authored andcommitted
[core] Constrain invoke_runtime parameter (#302)
* Constrain invoke_runtime parameter * Change param to a reference * Dangling type param
1 parent 8bcf381 commit ca74ef1

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

core/src/env2/srml/impls.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,9 @@ where
349349
ext::deposit_event(topics, data);
350350
}
351351

352-
fn invoke_runtime<O, V>(buffer: &mut O, call_data: &V)
352+
fn invoke_runtime<O>(buffer: &mut O, call_data: &<Self as EnvTypes>::Call)
353353
where
354354
O: scale::Output + AsRef<[u8]> + Reset,
355-
V: scale::Encode,
356355
{
357356
buffer.reset();
358357
call_data.encode_to(buffer);

core/src/env2/test/accessor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ use crate::{
6565
},
6666
storage::Key,
6767
};
68+
use scale::Encode;
6869

6970
thread_local! {
7071
/// The single thread-local test environment instance.
@@ -420,10 +421,9 @@ where
420421
})
421422
}
422423

423-
fn invoke_runtime<O, V>(_buffer: &mut O, call_data: &V)
424+
fn invoke_runtime<O>(_buffer: &mut O, call_data: &<Self as EnvTypes>::Call)
424425
where
425426
O: scale::Output + AsRef<[u8]> + Reset,
426-
V: scale::Encode,
427427
{
428428
// With the off-chain test environment we have no means
429429
// to emit an event on the chain since there is no chain.

core/src/env2/traits.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,9 @@ pub trait Env:
147147
Event: Topics<Self> + scale::Encode;
148148

149149
/// Invokes a runtime dispatchable function with the given call data.
150-
fn invoke_runtime<O, V>(buffer: &mut O, call_data: &V)
150+
fn invoke_runtime<O>(buffer: &mut O, call_data: &<Self as EnvTypes>::Call)
151151
where
152-
O: scale::Output + AsRef<[u8]> + Reset,
153-
V: scale::Encode;
152+
O: scale::Output + AsRef<[u8]> + Reset;
154153

155154
/// Restores the contract to the given address.
156155
///

0 commit comments

Comments
 (0)