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
83
84
85
86
87
88
89
90
91
92
use crate::{
    dharitri_sc::{
        codec::{CodecFrom, TopEncodeMulti},
        types::Address,
    },
    ScenarioWorld,
};
use dharitri_chain_vm::scenario::model::*;

impl StepHandler for ScenarioWorld {
    fn set_state_step(&mut self, step: SetStateStep) -> &mut Self {
        self.blockchain_mock.set_state_step(step);
        self
    }

    /// Adds a SC call step, as specified in the `sc_call_step` argument, then executes it.
    fn sc_call_step(&mut self, step: ScCallStep) -> &mut Self {
        self.blockchain_mock.sc_call_step(step);
        self
    }

    /// Adds a SC query step, as specified in the `sc_query_step` argument, then executes it.
    fn sc_query_step(&mut self, step: ScQueryStep) -> &mut Self {
        self.blockchain_mock.sc_query_step(step);
        self
    }

    /// Adds a SC deploy step, as specified in the `sc_deploy_step` argument, then executes it.
    fn sc_deploy_step(&mut self, step: ScDeployStep) -> &mut Self {
        self.blockchain_mock.sc_deploy_step(step);
        self
    }

    fn transfer_step(&mut self, step: TransferStep) -> &mut Self {
        self.blockchain_mock.transfer_step(step);
        self
    }

    fn validator_reward_step(&mut self, step: ValidatorRewardStep) -> &mut Self {
        self.blockchain_mock.validator_reward_step(step);
        self
    }

    fn check_state_step(&mut self, step: CheckStateStep) -> &mut Self {
        self.blockchain_mock.check_state_step(step);
        self
    }

    fn dump_state_step(&mut self) -> &mut Self {
        self.blockchain_mock.dump_state_step();
        self
    }
}

impl TypedScCallExecutor for ScenarioWorld {
    fn execute_typed_sc_call<OriginalResult, RequestedResult>(
        &mut self,
        typed_sc_call: TypedScCall<OriginalResult>,
    ) -> RequestedResult
    where
        OriginalResult: TopEncodeMulti,
        RequestedResult: CodecFrom<OriginalResult>,
    {
        self.blockchain_mock.execute_typed_sc_call(typed_sc_call)
    }
}

impl TypedScDeployExecutor for ScenarioWorld {
    fn execute_typed_sc_deploy<OriginalResult, RequestedResult>(
        &mut self,
        typed_sc_call: TypedScDeploy<OriginalResult>,
    ) -> (Address, RequestedResult)
    where
        OriginalResult: TopEncodeMulti,
        RequestedResult: CodecFrom<OriginalResult>,
    {
        self.blockchain_mock.execute_typed_sc_deploy(typed_sc_call)
    }
}

impl TypedScQueryExecutor for ScenarioWorld {
    fn execute_typed_sc_query<OriginalResult, RequestedResult>(
        &mut self,
        typed_sc_call: TypedScQuery<OriginalResult>,
    ) -> RequestedResult
    where
        OriginalResult: TopEncodeMulti,
        RequestedResult: CodecFrom<OriginalResult>,
    {
        self.blockchain_mock.execute_typed_sc_query(typed_sc_call)
    }
}