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
#![feature(
bind_by_move_pattern_guards,
non_exhaustive,
proc_macro_hygiene,
trait_alias
)]
#![cfg_attr(target_os = "wasi", feature(wasi_ext))]
#[macro_use]
pub extern crate serde;
extern crate mantle_macros;
pub mod backend;
pub mod exe;
pub mod reexports {
pub use serde;
pub use serde_cbor;
pub use tiny_keccak;
}
pub use mantle_macros::{default, Event, Service};
pub use mantle_types::Address;
pub use crate::exe::*;
#[macro_export]
macro_rules! service {
($svc:path) => {};
}
pub trait AddressExt {
fn transfer(&self, value: u64) -> Result<(), crate::backend::Error>;
fn balance(&self) -> u64;
fn code(&self) -> Vec<u8>;
}
impl AddressExt for Address {
fn transfer(&self, value: u64) -> Result<(), crate::backend::Error> {
crate::backend::transact(self, value, &[]).map(|_| ())
}
fn balance(&self) -> u64 {
crate::backend::balance(self).unwrap()
}
fn code(&self) -> Vec<u8> {
crate::backend::code(self).unwrap()
}
}