ink_env/engine/off_chain/
types.rs1use super::{
19 test_api::EmittedEvent,
20 AccountError,
21 Error,
22 OffChainError,
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 ink_engine::Error::UnregisteredChainExtension => {
43 OffChainError::UnregisteredChainExtension
44 }
45 };
46 Error::OffChain(e)
47 }
48}
49
50impl From<ink_engine::AccountError> for AccountError {
51 fn from(err: ink_engine::AccountError) -> Self {
52 match err {
53 ink_engine::AccountError::Decoding(e) => AccountError::Decoding(e),
54 ink_engine::AccountError::UnexpectedUserAccount => {
55 AccountError::UnexpectedUserAccount
56 }
57 ink_engine::AccountError::NoAccountForId(acc) => {
58 AccountError::NoAccountForId(acc)
59 }
60 ink_engine::AccountError::NoContractForId(addr) => {
61 AccountError::NoContractForId(addr)
62 }
63 }
64 }
65}
66
67impl From<ink_engine::AccountError> for Error {
68 fn from(account_error: ink_engine::AccountError) -> Self {
69 Error::OffChain(OffChainError::Account(account_error.into()))
70 }
71}