srml-contracts: Deferred actions (#3255)

* Switch to deferred actions

* Make restore_to a deferred action.

* Bump version.

* Review fixes.
This commit is contained in:
Sergei Pepyakin
2019-08-01 09:52:59 +02:00
committed by Gavin Wood
parent 780942192e
commit de02aee156
6 changed files with 337 additions and 171 deletions
+36
View File
@@ -185,6 +185,13 @@ mod tests {
#[derive(Debug, PartialEq, Eq)]
struct DispatchEntry(Call);
#[derive(Debug, PartialEq, Eq)]
struct RestoreEntry {
dest: u64,
code_hash: H256,
rent_allowance: u64,
delta: Vec<StorageKey>,
}
#[derive(Debug, PartialEq, Eq)]
struct CreateEntry {
code_hash: H256,
endowment: u64,
@@ -205,6 +212,7 @@ mod tests {
creates: Vec<CreateEntry>,
transfers: Vec<TransferEntry>,
dispatches: Vec<DispatchEntry>,
restores: Vec<RestoreEntry>,
// (topics, data)
events: Vec<(Vec<H256>, Vec<u8>)>,
next_account_id: u64,
@@ -262,6 +270,20 @@ mod tests {
fn note_dispatch_call(&mut self, call: Call) {
self.dispatches.push(DispatchEntry(call));
}
fn note_restore_to(
&mut self,
dest: u64,
code_hash: H256,
rent_allowance: u64,
delta: Vec<StorageKey>,
) {
self.restores.push(RestoreEntry {
dest,
code_hash,
rent_allowance,
delta,
});
}
fn caller(&self) -> &u64 {
&42
}
@@ -332,6 +354,20 @@ mod tests {
fn note_dispatch_call(&mut self, call: Call) {
(**self).note_dispatch_call(call)
}
fn note_restore_to(
&mut self,
dest: u64,
code_hash: H256,
rent_allowance: u64,
delta: Vec<StorageKey>,
) {
(**self).note_restore_to(
dest,
code_hash,
rent_allowance,
delta,
)
}
fn caller(&self) -> &u64 {
(**self).caller()
}