ink_env/engine/off_chain/
types.rs1use super::{
19 AccountError,
20 Error,
21 OffChainError,
22 test_api::EmittedEvent,
23};
24
25impl From<ink_engine::test_api::EmittedEvent> for EmittedEvent {
26 fn from(evt: ink_engine::test_api::EmittedEvent) -> Self {
27 EmittedEvent {
28 topics: evt.topics,
29 data: evt.data,
30 }
31 }
32}
33
34impl From<ink_engine::Error> for Error {
35 fn from(err: ink_engine::Error) -> Self {
36 let e = match err {
37 ink_engine::Error::Account(acc) => OffChainError::Account(acc.into()),
38 ink_engine::Error::UninitializedBlocks => OffChainError::UninitializedBlocks,
39 ink_engine::Error::UninitializedExecutionContext => {
40 OffChainError::UninitializedExecutionContext
41 }
42 };
43 Error::OffChain(e)
44 }
45}
46
47impl From<ink_engine::AccountError> for AccountError {
48 fn from(err: ink_engine::AccountError) -> Self {
49 match err {
50 ink_engine::AccountError::Decoding(e) => AccountError::Decoding(e),
51 ink_engine::AccountError::UnexpectedUserAccount => {
52 AccountError::UnexpectedUserAccount
53 }
54 ink_engine::AccountError::NoAccountForId(acc) => {
55 AccountError::NoAccountForId(acc)
56 }
57 ink_engine::AccountError::NoContractForId(addr) => {
58 AccountError::NoContractForId(addr)
59 }
60 }
61 }
62}
63
64impl From<ink_engine::AccountError> for Error {
65 fn from(account_error: ink_engine::AccountError) -> Self {
66 Error::OffChain(OffChainError::Account(account_error.into()))
67 }
68}