@@ -65,17 +65,18 @@ In the first two lines, we see the usage of two macros:
65
65
point collision.
66
66
67
67
- [ ` contract ` ] ( ../macros/contract ) - Parses every method inside the ` impl ` block marked with the
68
- ` [sv::msg(...)] ` attribute and create proper messages and utilities like helpers for
69
- [ ` MultiTest ` ] ( ../../cw-multi-test ) .
68
+ [ ` [sv::msg(...)] ` ] ( ../attributes/msg ) attribute and create proper messages and utilities like
69
+ helpers for [ ` MultiTest ` ] ( ../../cw-multi-test ) .
70
70
71
- This simple example also has the ` sv::msg(...) ` attributes. Sylvia macros distinguish the if message
72
- should be generated from the marked method and of what type.
71
+ This simple example also has the [ ` sv::msg(...) ` ] ( ../attributes/msg ) attributes. Sylvia macros
72
+ distinguish the if message should be generated from the marked method and of what type.
73
73
74
74
CosmWasm contract requires the ` instantiate ` message, and it is mandatory to specify it for the
75
- ` contract ` macro. We have to provide it with the proper context type:
75
+ [ ` contract ` ] ( ../macros/contract ) macro. We have to provide it with the proper context type:
76
76
[ ` InstantiateCtx ` ] ( https://docs.rs/sylvia/latest/sylvia/types/struct.InstantiateCtx.html ) . Another
77
- mandatory method is the ` new ` , as contract fields are out of scope for the ` contract ` macro, and
78
- otherwise we wouldn't be able to create the contract object in message dispatching.
77
+ mandatory method is the ` new ` , as contract fields are out of scope for the
78
+ [ ` contract ` ] ( ../macros/contract ) macro, and otherwise we wouldn't be able to create the contract
79
+ object in message dispatching.
79
80
80
81
Context gives us access to the blockchain state, information about our contract, and the sender of
81
82
the message. We return the
@@ -85,16 +86,16 @@ standard CosmWasm error
85
86
[ ` Response ` ] ( https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Response.html ) .
86
87
87
88
The template contract also contains a query and an exec messages. Each type of message in CosmWasm
88
- supports different contexts. F.e. the
89
- [ ` QueryCtx ` ] ( https://docs.rs/sylvia/latest/sylvia/types/struct.QueryCtx.html ) exposes to the user an
89
+ supports different contexts. F.e. the [ ` QueryCtx ` ] ( ../types/context ) exposes to the user an
90
90
immutable [ ` Deps ` ] ( https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Deps.html ) as by design,
91
- queries should never mutate the state. This is not the case for the
92
- [ ` ExecCtx ` ] ( https://docs.rs/sylvia/latest/sylvia/types/struct.ExecCtx.html ) and ` InstantiateCtx `
93
- which exposes the [ ` DepsMut ` ] ( https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.DepsMut.html ) .
91
+ queries should never mutate the state. This is not the case for the [ ` ExecCtx ` ] ( ../types/context )
92
+ and ` InstantiateCtx ` which exposes the
93
+ [ ` DepsMut ` ] ( https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.DepsMut.html ) .
94
94
95
95
Fell free expanding the macro now and seeing what Sylvia generates. It might be overwhelming, as
96
96
there will be a lot of things generated that seem not relevant to our code, so for the bare minimum,
97
- check the ` InstantiateMsg ` and its ` impl ` block.
97
+ check the [ ` InstantiateMsg ` ] ( ../macros/generated-types/message-types#contract-messages ) and its
98
+ ` impl ` block.
98
99
99
100
Sylvia doesn't generate anything magical, but regular CosmWasm contract types customized based on
100
101
the provided methods and attributes. This means that the Sylvia contract is fully interoperational
0 commit comments