templates.self_entrypoint

 1import smartpy as sp
 2
 3
 4@sp.module
 5def main():
 6    class A(sp.Contract):
 7        @sp.entrypoint
 8        def ep1(self, param):
 9            sp.cast(param, sp.unit)
10
11        @sp.entrypoint
12        def ep2(self, param):
13            sp.cast(param, sp.contract[sp.timestamp])
14
15    class B(sp.Contract):
16        def __init__(self, a):
17            self.data.a = a
18
19        @sp.entrypoint
20        def ep3(self, param):
21            sp.cast(param, sp.bool)
22
23            ep2 = sp.contract(
24                sp.contract[sp.timestamp], self.data.a, entrypoint="ep2"
25            ).unwrap_some()
26
27            ep4 = sp.self_entrypoint("ep4")
28            sp.cast(ep4, sp.contract[sp.timestamp])
29
30            sp.transfer(ep4, sp.mutez(0), ep2)
31
32        @sp.entrypoint
33        def ep4(self, result):
34            sp.cast(result, sp.timestamp)
35
36    class Unrelated(sp.Contract):
37        def __init__(self):
38            self.data.x = "abc"
39
40
41@sp.add_test()
42def test():
43    scenario = sp.test_scenario("test", main)
44    a = main.A()
45    scenario += a
46    b = main.B(a=a.address)
47    scenario += b
48    b.ep3(True)
49    scenario += main.Unrelated()