mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 12:51:01 +00:00
Contract calls (#19)
This commit is contained in:
@@ -135,6 +135,19 @@ sol!(
|
||||
}
|
||||
);
|
||||
|
||||
sol!(
|
||||
contract Call {
|
||||
function value_transfer(address payable destination) public payable;
|
||||
|
||||
function echo(bytes memory payload) public payable returns (bytes memory);
|
||||
|
||||
function call(
|
||||
address callee,
|
||||
bytes memory payload
|
||||
) public payable returns (bytes memory);
|
||||
}
|
||||
);
|
||||
|
||||
impl Contract {
|
||||
/// Execute the contract.
|
||||
///
|
||||
@@ -441,6 +454,42 @@ impl Contract {
|
||||
calldata: MCopy::memcpyCall::new((payload,)).abi_encode(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_value_transfer(destination: Address) -> Self {
|
||||
let code = include_str!("../contracts/Call.sol");
|
||||
let name = "Call";
|
||||
|
||||
Self {
|
||||
name,
|
||||
evm_runtime: crate::compile_evm_bin_runtime(name, code),
|
||||
pvm_runtime: crate::compile_blob(name, code),
|
||||
calldata: Call::value_transferCall::new((destination,)).abi_encode(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_call(callee: Address, payload: Vec<u8>) -> Self {
|
||||
let code = include_str!("../contracts/Call.sol");
|
||||
let name = "Call";
|
||||
|
||||
Self {
|
||||
name,
|
||||
evm_runtime: crate::compile_evm_bin_runtime(name, code),
|
||||
pvm_runtime: crate::compile_blob(name, code),
|
||||
calldata: Call::callCall::new((callee, payload)).abi_encode(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_constructor() -> Self {
|
||||
let code = include_str!("../contracts/Call.sol");
|
||||
let name = "Call";
|
||||
|
||||
Self {
|
||||
name,
|
||||
evm_runtime: crate::compile_evm_bin_runtime(name, code),
|
||||
pvm_runtime: crate::compile_blob(name, code),
|
||||
calldata: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user