templates.toto

 1import smartpy as sp
 2
 3
 4@sp.module
 5def main():
 6    class C(sp.Contract):
 7        @sp.entrypoint
 8        def ep(self, params):
 9            sp.cast(
10                params,
11                sp.list[
12                    sp.variant(
13                        V1=sp.record(b=sp.string, a=sp.bool).layout(("b", "a")),
14                        V2=sp.nat,
15                    ).layout(("V2", "V1"))
16                ],
17            )
18
19
20@sp.add_test()
21def test():
22    scenario = sp.test_scenario("C", main)
23    scenario.h1("Toto")
24    c = main.C()
25    scenario += c
26    c.ep([sp.variant("V1", sp.record(a=False, b="BBB"))])