Skip to content

Commit 52ecd6e

Browse files
authored
Sylvia: Move attributes to macro dir (#125)
2 parents 53fddff + be9e9da commit 52ecd6e

18 files changed

+59
-61
lines changed

src/pages/sylvia/_meta.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"basics": "Basics",
33
"macros": "Macros",
4-
"attributes": "Attributes",
54
"types": "Types"
65
}

src/pages/sylvia/basics/contract-structure.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ In the first two lines, we see the usage of two macros:
151151
point collision.
152152

153153
- [`contract`](../macros/contract) - Parses every method inside the `impl` block marked with the
154-
[`[sv::msg(...)]`](../attributes/msg) attribute and create proper messages and utilities like
155-
helpers for [`MultiTest`](../../cw-multi-test).
154+
[`[sv::msg(...)]`](../macros/attributes/msg) attribute and create proper messages and utilities
155+
like helpers for [`MultiTest`](../../cw-multi-test).
156156

157-
This simple example also has the [`sv::msg(...)`](../attributes/msg) attributes. Sylvia macros
158-
distinguish the if message should be generated from the marked method and of what type.
157+
This simple example also has the [`sv::msg(...)`](../macros/attributes/msg) attributes. Sylvia
158+
macros distinguish the if message should be generated from the marked method and of what type.
159159

160160
CosmWasm contract requires the `instantiate` message, and it is mandatory to specify it for the
161161
[`contract`](../macros/contract) macro. We have to provide it with the proper context type:

src/pages/sylvia/macros/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"interface": "Interface",
33
"contract": "Contract",
44
"entry-points": "Entry points",
5+
"attributes": "Attributes",
56
"generated-types": "Generated types"
67
}

src/pages/sylvia/attributes/attr.mdx renamed to src/pages/sylvia/macros/attributes/attr.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Use `sv::attr` to forward an external attribute to the generated message variant
1212

1313
List of macros supporting the `sv::attr` attribute:
1414

15-
- [`contract`](../macros/contract)
16-
- [`interface`](../macros/interface)
15+
- [`contract`](../contract)
16+
- [`interface`](../interface)
1717

1818
## Usage
1919

20-
Use the `sv::attr` above any of the methods marked with
21-
[`#[sv::msg(exec|sudo|query)]`](../attributes/msg) attribute.
20+
Use the `sv::attr` above any of the methods marked with [`#[sv::msg(exec|sudo|query)]`](msg)
21+
attribute.
2222

2323
```rust {19}
2424
use sylvia::contract;
@@ -46,8 +46,8 @@ impl Contract {
4646
}
4747
```
4848

49-
The [`contract`](../macros/contract) and [`interface`](../macros/interface) macros will decorate the
50-
message variant with the attribute provided in `sv::attr`.
49+
The [`contract`](../contract) and [`interface`](../interface) macros will decorate the message
50+
variant with the attribute provided in `sv::attr`.
5151

5252
```rust {2}
5353
pub enum ExecMsg {

src/pages/sylvia/attributes/custom.mdx renamed to src/pages/sylvia/macros/attributes/custom.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Use `sv::custom` if you want to use a custom message and/or query in your contra
1212

1313
List of macros supporting the `sv::custom` attribute:
1414

15-
- [`contract`](../macros/contract)
16-
- [`interface`](../macros/interface)
17-
- [`entry_points`](../macros/entry-points)
15+
- [`contract`](../contract)
16+
- [`interface`](../interface)
17+
- [`entry_points`](../entry-points)
1818

1919
## Usage
2020

@@ -64,7 +64,7 @@ impl CounterContract {
6464
respectively.
6565
</Callout>
6666

67-
`sv::custom` works the same in the case of the `interface` macro.
67+
`sv::custom` works the same in the case of the [`interface`](../interface) macro.
6868

6969
```rust
7070
use cosmwasm_schema::cw_serde;
@@ -98,5 +98,5 @@ pub trait SomeInterface {
9898

9999
<Callout>
100100
It's also possible to define custom types for the interface using associated types. We cover it in
101-
the [`interface`](../macros/interface) macro section.
101+
the [`interface`](../interface) macro section.
102102
</Callout>

src/pages/sylvia/attributes/error.mdx renamed to src/pages/sylvia/macros/attributes/error.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ You can quickly provide this logic using, for example, [`thiserror`](https://doc
1717

1818
List of macros supporting the `sv::error` attribute:
1919

20-
- [`contract`](../macros/contract)
21-
- [`entry_points`](../macros/entry-points)
20+
- [`contract`](../contract)
21+
- [`entry_points`](../entry-points)
2222

2323
<Callout>
24-
The `interface` macro supports custom error types via the `Error` associated type.
24+
The [`interface`](../interface) macro supports custom error types via the `Error` associated type.
2525
</Callout>
2626

2727
## Usage

src/pages/sylvia/attributes/message.mdx renamed to src/pages/sylvia/macros/attributes/message.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Use `sv::messages` to expand your contract functionality with the Sylvia interfa
1616

1717
List of macros supporting the `sv::messages` attribute:
1818

19-
- [`contract`](../macros/contract)
20-
- [`entry_points`](../macros/entry-points)
19+
- [`contract`](../contract)
20+
- [`entry_points`](../entry-points)
2121

2222
## Usage
2323

src/pages/sylvia/attributes/msg.mdx renamed to src/pages/sylvia/macros/attributes/msg.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Use the `sv::msg` attribute to mark methods as specific message types.
1212

1313
List of macros supporting the `sv::msg` attribute:
1414

15-
- [`contract`](..//macros/contract)
16-
- [`interface`](../macros/interface)
17-
- [`entry_points`](../macros/entry-points)
15+
- [`contract`](../contract)
16+
- [`interface`](../interface)
17+
- [`entry_points`](../entry-points)
1818

1919
<Callout>
20-
[`interface`](../macros/interface) macro supports the `sv::msg` attribute only with `exec`,
21-
`query` or `sudo` value.
20+
[`interface`](../interface) macro supports the `sv::msg` attribute only with `exec`, `query` or
21+
`sudo` value.
2222
</Callout>
2323

2424
## Usage

src/pages/sylvia/attributes/msg_attr.mdx renamed to src/pages/sylvia/macros/attributes/msg_attr.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ Use `sv::msg_attr` to forward an external attribute to the generated message.
1212

1313
List of macros supporting the `sv::msg_attr` attribute:
1414

15-
- [`contract`](../macros/contract)
16-
- [`interface`](../macros/interface)
15+
- [`contract`](../contract)
16+
- [`interface`](../interface)
1717

1818
## Usage
1919

20-
Use the `sv::msg_attr` above any of the methods marked with [`#[sv::msg(..)]`](../attributes/msg)
21-
attribute.
20+
Use the `sv::msg_attr` above any of the methods marked with [`#[sv::msg(..)]`](msg) attribute.
2221

2322
```rust {19}
2423
use sylvia::contract;
@@ -43,8 +42,8 @@ impl MyContract {
4342
}
4443
```
4544

46-
The [`contract`](../macros/contract) and [`interface`](../macros/interface) macros will decorate the
47-
message with the attributes/macros provided in `sv::msg_attr`.
45+
The [`contract`](../contract) and [`interface`](../interface) macros will decorate the message with
46+
the attributes/macros provided in `sv::msg_attr`.
4847

4948
```rust {8, 10-11}
5049
#[derive(

src/pages/sylvia/attributes/override-entry-point.mdx renamed to src/pages/sylvia/macros/attributes/override-entry-point.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ import { Callout } from "nextra/components";
77
# `sv::override_entry_point` attribute
88

99
Use `sv::override_entry_point` if you want to define an entry point of your contract yourself. This
10-
way, the [`sv::entry_points`](../macros/entry-points) macro won't generate it for you. The entry
11-
point will also be used as a dispatch method in the `MultiTest` helpers generated by the `contract`
12-
macro.
10+
way, the [`sv::entry_points`](../entry-points) macro won't generate it for you. The entry point will
11+
also be used as a dispatch method in the `MultiTest` helpers generated by the `contract` macro.
1312

1413
<Callout>
1514
Use this attribute if you provide some custom logic in the entry points. Otherwise, the
16-
[`MultiTest`](../../cw-multi-test) helpers won't cover that logic, and thus you will miss the
15+
[`MultiTest`](../../../cw-multi-test) helpers won't cover that logic, and thus you will miss the
1716
coverage.
1817
</Callout>
1918

2019
## Macros
2120

2221
List of macros supporting the `sv::override_entry_point` attribute:
2322

24-
- [`contract`](../macros/contract)
25-
- [`entry_points`](../macros/entry-points)
23+
- [`contract`](../contract)
24+
- [`entry_points`](../entry-points)
2625

2726
## Usage
2827

src/pages/sylvia/macros/contract.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ contract messages
1919
List of attributes supported by
2020
[`contract`](https://docs.rs/sylvia/latest/sylvia/attr.contract.html) macro:
2121

22-
- [`custom`](../attributes/custom)
23-
- [`error`](../attributes/error)
24-
- [`message`](../attributes/message)
25-
- [`msg`](../attributes/msg)
26-
- [`override_entry_point`](../attributes/override-entry-point)
22+
- [`custom`](attributes/custom)
23+
- [`error`](attributes/error)
24+
- [`message`](attributes/message)
25+
- [`msg`](attributes/msg)
26+
- [`override_entry_point`](attributes/override-entry-point)
2727

2828
## Usage
2929

@@ -78,15 +78,15 @@ impl CounterContract {
7878
```
7979

8080
We define our messages signatures by marking the appropriate methods with the
81-
[`sv::msg`](../attributes/msg) attribute.
81+
[`sv::msg`](attributes/msg) attribute.
8282

8383
The `impl` block must contain the attributeless `new` method for the generated `dispatch` to work
8484
properly.
8585

8686
## Custom types
8787

8888
You can construct your contract to work with some specific custom types with the
89-
[`sv::custom`](../attributes/custom).
89+
[`sv::custom`](attributes/custom).
9090

9191
## Generic types
9292

@@ -176,9 +176,9 @@ pub struct InstantiateMsg {
176176

177177
### Prefer generic custom types
178178

179-
The [`sv::custom`](../attributes/custom) attribute is not mandatory, as by default contract macro
180-
will use [`Empty`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Empty.html) type in place
181-
of custom types. It has a downside that the contract always expects the
179+
The [`sv::custom`](attributes/custom) attribute is not mandatory, as by default contract macro will
180+
use [`Empty`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Empty.html) type in place of
181+
custom types. It has a downside that the contract always expects the
182182
[`Empty`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Empty.html) custom messages, and
183183
it makes testing it in the [MultiTest](../../cw-multi-test) environment with different custom
184184
messages tricky. We recommend that if your contract is meant to be chain agnostic, define it with a

src/pages/sylvia/macros/entry-points.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Use the `entry_points` macro to generate entry points of your contract.
1818

1919
List of attributes supported by `entry_points` macro:
2020

21-
- [`custom`](../attributes/custom)
22-
- [`error`](../attributes/error)
23-
- [`msg`](../attributes/msg)
24-
- [`override_entry_point`](../attributes/override-entry-point)
21+
- [`custom`](attributes/custom)
22+
- [`error`](attributes/error)
23+
- [`msg`](attributes/msg)
24+
- [`override_entry_point`](attributes/override-entry-point)
2525

2626
## Usage
2727

@@ -59,13 +59,13 @@ impl CounterContract {
5959
}
6060
```
6161

62-
The `entry_points` macro scans for [`sv::msg`](../attributes/msg) attributes. By default it
63-
generates: instantiate, exec, and query entry points.
62+
The `entry_points` macro scans for [`sv::msg`](attributes/msg) attributes. By default it generates:
63+
instantiate, exec, and query entry points.
6464

6565
## Custom types
6666

6767
You can construct your entry points to work with some specific custom types with the
68-
[`sv::custom`](../attributes/custom).
68+
[`sv::custom`](attributes/custom).
6969

7070
## Generic types
7171

src/pages/sylvia/macros/generated-types/communication.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl CounterContract {
4343
## Query helpers
4444

4545
Sylvia macros generate a `Querier` trait that mirrors all of the methods marked with the
46-
[`sv::msg(query)`](../../attributes/msg.mdx) attribute. This trait is then implemented on the
46+
[`sv::msg(query)`](../attributes/msg.mdx) attribute. This trait is then implemented on the
4747
[`BoundQuerier`](../../types/communication#boundquerier) type. Implementation of each method
4848
constructs the appropriate message and sends it to the contract.
4949

@@ -64,7 +64,7 @@ impl<'a, C: sylvia::cw_std::CustomQuery> Querier
6464
## Executor helpers
6565

6666
Sylvia macros generate an `Executor` trait that mirrors all of the methods marked with the
67-
[`sv::msg(exec)`](../../attributes/msg.mdx) attribute. This trait is then implemented on the
67+
[`sv::msg(exec)`](../attributes/msg.mdx) attribute. This trait is then implemented on the
6868
[`ExecutorBuilder`](../../types/communication#executorbuilder) type. Implementation of each method
6969
constructs the appropriate message and returns the
7070
[`ExecutorBuilder`](../../types/communication#executorbuilder) generic over

src/pages/sylvia/macros/generated-types/message-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Callout, Tabs } from "nextra/components";
66

77
# Generated message types
88

9-
Sylvia macros generate CosmWasm messages from methods marked with [`sv::msg`](../../attributes/msg)
9+
Sylvia macros generate CosmWasm messages from methods marked with [`sv::msg`](../attributes/msg)
1010
attributes.
1111

1212
Messages are generated either as struct, for instantiate and migrate, or enum in case of the rest of

src/pages/sylvia/macros/generated-types/multitest.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ the reference to the [`App`](../../types/multitest#app).
364364
}
365365
```
366366

367-
The proxy trait declares methods marked with the [`sv::msg`](../../attributes/msg) attribute, and found in the contract impl block
367+
The proxy trait declares methods marked with the [`sv::msg`](../attributes/msg) attribute, and found in the contract impl block
368368

369369
The trait is then implemented on the [`Proxy`](../../types/multitest#proxy) generic over the contract type. Implementation of the methods instantiates appropriate messages and sends them to the [`App`](../../types/multitest#app)
370370
so that we don't have to do it manually.

src/pages/sylvia/macros/interface.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ will be able to assign their error type to it and have wider range of errors tha
4747
</Callout>
4848

4949
Then we can define our messages signatures. We do that by marking the methods with the
50-
[`sv::msg`](../attributes/msg) attribute.
50+
[`sv::msg`](attributes/msg) attribute.
5151

5252
## Custom types
5353

5454
You can construct your interface to work with some specific custom types with the
55-
[`sv::custom`](../attributes/custom) attribute. Use of `sv::custom` restricts the interface to work
55+
[`sv::custom`](attributes/custom) attribute. Use of `sv::custom` restricts the interface to work
5656
with the predefined custom types.
5757

5858
If you want to allow the users to use the interface with their own specified custom types, you can

0 commit comments

Comments
 (0)