pub struct SmartContractInputs {
pub version: i32,
pub account_info: AccountInfo,
pub protocol_input: ProtocolInputs,
pub contract_input: ContractInputs,
}Expand description
SmartContractInputs represents the entire bundle of inputs sent into a Versatus smart contract. It is a collection of input data from a variety of locations, including the contract caller, and the protocol accounts database.
Fields§
§version: i32Version of the compute stack and API/ABI
account_info: AccountInfoAccount info as provided by the protocol
protocol_input: ProtocolInputsProtocol inputs as provided by the protocol
contract_input: ContractInputsApplication inputs as provided by the application via the protocol
Implementations§
Source§impl SmartContractInputs
impl SmartContractInputs
Sourcepub fn gather() -> Result<Self>
pub fn gather() -> Result<Self>
Read JSON data on stdin and deserialise it to a set of Rust data structures.
Sourcepub fn account_info(&self) -> AccountInfo
pub fn account_info(&self) -> AccountInfo
Returns a copy of the associated account information
Sourcepub fn account_addr(&self) -> Address
pub fn account_addr(&self) -> Address
Returns the address of the associated account
Examples found in repository?
examples/erc20.rs (line 48)
45 fn transfer(&self, to: Address, value: U256) -> Result<Erc20TransferEvent> {
46 let addr: Address;
47 if let Some(input) = &self.inputs {
48 addr = input.account_addr();
49 } else {
50 // Shouldn't be reachable.
51 return Err(anyhow!("Input data missing"));
52 }
53 Ok(Erc20TransferEvent {
54 from: addr,
55 to,
56 value,
57 })
58 }
59
60 fn transfer_from(&self, from: Address, to: Address, value: U256) -> Result<Erc20TransferEvent> {
61 Ok(Erc20TransferEvent { from, to, value })
62 }
63
64 fn approve(&self, spender: Address, value: U256) -> Result<Erc20ApprovalEvent> {
65 let owner: Address;
66 if let Some(input) = &self.inputs {
67 owner = input.account_addr();
68 } else {
69 // Shouldn't be reachable.
70 return Err(anyhow!("Input data missing"));
71 }
72 Ok(Erc20ApprovalEvent {
73 owner,
74 spender,
75 value,
76 })
77 }Trait Implementations§
Source§impl Clone for SmartContractInputs
impl Clone for SmartContractInputs
Source§fn clone(&self) -> SmartContractInputs
fn clone(&self) -> SmartContractInputs
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SmartContractInputs
impl Debug for SmartContractInputs
Source§impl<'de> Deserialize<'de> for SmartContractInputs
impl<'de> Deserialize<'de> for SmartContractInputs
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SmartContractInputs
impl RefUnwindSafe for SmartContractInputs
impl Send for SmartContractInputs
impl Sync for SmartContractInputs
impl Unpin for SmartContractInputs
impl UnwindSafe for SmartContractInputs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more