-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabi.rs
82 lines (66 loc) · 2.11 KB
/
abi.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Contract ABI helpers.
use ethabi::{Bytes, RawLog, TopicFilter};
use ethereum_types::Address;
use failure::Error;
use linker::Linker;
use std::collections::HashMap;
use std::path::PathBuf;
use {call, evm};
#[derive(Debug)]
pub struct FileSource {
pub ast: &'static str,
}
/// Context for all loaded contracts.
#[derive(Debug)]
pub struct ContractContext {
/// List of sources, as indexed by a source map.
pub source_list: Option<Vec<PathBuf>>,
/// AST of sources.
pub sources: HashMap<&'static str, FileSource>,
}
/// Contract functions generated by parables_build.
pub trait ContractFunction {
/// Output types of the function.
type Output;
/// Encodes the input for the function.
fn encoded(&self, linker: &Linker) -> Result<Bytes, Error>;
/// Decodes the given bytes output for the contract function.
fn output(&self, output_bytes: Bytes) -> Result<Self::Output, Error>;
}
/// Helpers for building log filters.
pub trait LogFilter {
fn wildcard_filter(&self) -> TopicFilter;
}
/// Log parsing implementation.
pub trait ParseLog {
/// Type of the parsed log.
type Log;
/// Function to parse log.
fn parse_log(&self, log: RawLog) -> Result<Self::Log, Error>;
}
pub trait Constructor {
/// Name of the constructor item, used for linking.
const ITEM: &'static str;
/// Path that this contract belongs to.
const PATH: &'static str;
/// Access the code to deploy for this constructor.
const BIN: &'static str;
/// Access the source map for the type this constructor is associated with.
const SOURCE_MAP: Option<&'static str>;
/// Access the runtime code being deployed.
const RUNTIME_BIN: Option<&'static str>;
/// Access the runtime source map for the type this constructor is associated with.
const RUNTIME_SOURCE_MAP: Option<&'static str>;
}
/// Virtual machine abstraction.
pub trait Vm {
/// Perform a call against the given contract function.
fn call<F>(
&self,
address: Address,
f: F,
call: call::Call,
) -> Result<evm::Call<F::Output>, Error>
where
F: ContractFunction;
}