mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 00:41:04 +00:00
runner: CodeUpload specs action
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -31,6 +31,15 @@ pub enum SpecsAction {
|
|||||||
#[serde(default, with = "hex::serde")]
|
#[serde(default, with = "hex::serde")]
|
||||||
salt: OptionalHex<[u8; 32]>,
|
salt: OptionalHex<[u8; 32]>,
|
||||||
},
|
},
|
||||||
|
/// Upload contract code without calling the constructor
|
||||||
|
Upload {
|
||||||
|
#[serde(default)]
|
||||||
|
origin: TestAddress,
|
||||||
|
#[serde(default)]
|
||||||
|
code: Code,
|
||||||
|
#[serde(default)]
|
||||||
|
storage_deposit_limit: Option<Balance>,
|
||||||
|
},
|
||||||
/// Call a contract
|
/// Call a contract
|
||||||
Call {
|
Call {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -204,8 +213,9 @@ impl Specs {
|
|||||||
/// - Replace `Code::Solidity{ path, ..}` if `path` is not provided: replace `path` with `contract_file`
|
/// - Replace `Code::Solidity{ path, ..}` if `path` is not provided: replace `path` with `contract_file`
|
||||||
pub fn replace_empty_code(&mut self, contract_name: &str, contract_path: &str) {
|
pub fn replace_empty_code(&mut self, contract_name: &str, contract_path: &str) {
|
||||||
for action in self.actions.iter_mut() {
|
for action in self.actions.iter_mut() {
|
||||||
let SpecsAction::Instantiate { code, .. } = action else {
|
let code = match action {
|
||||||
continue;
|
SpecsAction::Instantiate { code, .. } | SpecsAction::Upload { code, .. } => code,
|
||||||
|
_ => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
match code {
|
match code {
|
||||||
@@ -371,6 +381,19 @@ impl Specs {
|
|||||||
wall_time: time_start.elapsed(),
|
wall_time: time_start.elapsed(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Upload {
|
||||||
|
origin,
|
||||||
|
code,
|
||||||
|
storage_deposit_limit,
|
||||||
|
} => Contracts::upload_code(
|
||||||
|
RuntimeOrigin::signed(origin.to_account_id(&results)),
|
||||||
|
match pallet_revive::Code::from(code) {
|
||||||
|
pallet_revive::Code::Existing(_) => continue,
|
||||||
|
pallet_revive::Code::Upload(bytes) => bytes,
|
||||||
|
},
|
||||||
|
storage_deposit_limit.unwrap_or_default(),
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|error| panic!("code upload failed: {error:?}")),
|
||||||
Call {
|
Call {
|
||||||
origin,
|
origin,
|
||||||
dest,
|
dest,
|
||||||
|
|||||||
Reference in New Issue
Block a user