Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bkolad authored Oct 10, 2023
1 parent 30eef6a commit e36522f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions module-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,20 @@ about this distinction.
For more information on `Context` and `Spec`, and to see some example implementations, check out the [`sov_modules_api`](./sov-modules-api/) docs.


### Module CallMessage.
### Module CallMessage and `schemars::JsonSchema`.
Like in the `bank` module the `CallMessage` can be parameterized by `C::Context`. To ensure a smooth wallet experience, we need the `CallMessag`' to implement `schemars::JsonSchema` trait. However, simply adding `derive(schemars::JsonSchema)` to the `CallMessage` definition results in the following error:
`the trait JsonSchema is not implemented for C`.

```
the trait JsonSchema is not implemented for C
```


The reason for this issue is that the standard derive mechanism for `JsonSchema` cannot determine the correct trait bounds for the `Context`. To resolve this, we need to provide the following hint:

`schemars(bound = "C::Address: ::schemars::JsonSchema", rename = "CallMessage")`
```rust
schemars(bound = "C::Address: ::schemars::JsonSchema", rename = "CallMessage")
```

Now, the schemars::derive understands that it is sufficient for only C::Address to implement schemars::JsonSche
Now, the `schemars::derive` understands that it is sufficient for only `C::Address` to implement `schemars::JsonSchema`

I a `CallMessage` in your module uses an associated type from `Context` you might need to provide a similar hint.
If `CallMessage` in your module uses an associated type from `Context` you might need to provide a similar hint.

0 comments on commit e36522f

Please sign in to comment.