Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add README FAQ #682

Merged
merged 9 commits into from
Dec 7, 2023
Merged

Add README FAQ #682

merged 9 commits into from
Dec 7, 2023

Conversation

haerdib
Copy link
Contributor

@haerdib haerdib commented Dec 5, 2023

closes #561

@haerdib haerdib requested a review from masapr December 5, 2023 07:53
@haerdib haerdib self-assigned this Dec 5, 2023
@haerdib haerdib marked this pull request as ready for review December 5, 2023 07:53
@haerdib haerdib added F4-documentation Updates the documentation E0-silent Will not be mentioned in the release labels Dec 5, 2023
@haerdib haerdib changed the title Add readme FAQ Add README FAQ Dec 5, 2023
Copy link
Collaborator

@masapr masapr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

README.md Outdated


## FAQ
1. Q: Everything compiles but my Substrate node does not accept my extrinsic or returns an error even if the extrinsic should be correct.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try to avoid the usage of words like "my" (especially the substrate node could also not be "mine").

README.md Outdated

3. Q: I want to retrieve a state from my node via the api-client, but I do not get the expected value respective the decoding fails. How come?

A: When specifying your own state query, you must provide the return type of the state you're trying to retrieve. This is because the api-client only gets bytes from the node and must be able to deserialize these properly. That is not possible without knowing the type to decode to. This type may be for example a simple `u64` for retrieving the `Balance` of an account. But careful: Often, but depending on the pallet configuration, the node returns an additional `Option`. So it's rather an `Option<u64>` than a simple `u64`. Possible pallet configurations are `OptionQuery`, `ResultQuery` and `ValueQuery` (see the [substrate docs "Handling query return values"](https://docs.substrate.io/build/runtime-storage/) for more information). Please check your pallet configuration and adapt the expected return type accordingly in the api-client. And always remember to match the type to your Runtime! If you're fetching events for example, ensure it's the event type provided by your node runtime, not by any other.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's necessary to go into pallet development here. Isn't it also visible in Polkadot-JS what type is returned? ... I wouldn't assume, that the person using the api-client is also writing the pallets of the node ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. But I think it is still noteworthy because this has already led to confusion in the past. I adapted the text - what do you think?

README.md Outdated

Ensure you're using a matching config. If you do not use default parameters as configured in one of the provided configs, you must provide your own config that implements the [Config trait](https://github.com/scs/substrate-api-client/blob/master/primitives/src/config/mod.rs).

3. Q: I want to retrieve a state from my node via the api-client, but I do not get the expected value respective the decoding fails. How come?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, I would not assume, that the person asking the question has their own node (instead of "my" I would write "a substrate node"

README.md Outdated

3. Q: I want to retrieve a state from my node via the api-client, but I do not get the expected value respective the decoding fails. How come?

A: When specifying your own state query, you must provide the return type of the state you're trying to retrieve. This is because the api-client only gets bytes from the node and must be able to deserialize these properly. That is not possible without knowing the type to decode to. This type may be for example a simple `u64` for retrieving the `Balance` of an account. But careful: Often, but depending on the pallet configuration, the node returns an additional `Option`. So it's rather an `Option<u64>` than a simple `u64`. Possible pallet configurations are `OptionQuery`, `ResultQuery` and `ValueQuery` (see the [substrate docs "Handling query return values"](https://docs.substrate.io/build/runtime-storage/) for more information). Please check your pallet configuration and adapt the expected return type accordingly in the api-client. And always remember to match the type to your Runtime! If you're fetching events for example, ensure it's the event type provided by your node runtime, not by any other.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence
"But careful: Often, but depending on the pallet configuration, the node returns an additional Option."
has a complicated structure. I would write:
"But careful: Depending on the pallet configuration, the node might return an Option."

@haerdib haerdib requested a review from masapr December 5, 2023 12:13
Copy link
Collaborator

@masapr masapr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one minor remark. Apart from that 👍

README.md Outdated
@@ -175,7 +175,7 @@ _In alphabetical order_


## FAQ
1. Q: Everything compiles but my Substrate node does not accept my extrinsic or returns an error even if the extrinsic should be correct.
1. Q: Everything compiles but the Substrate node does not accept my extrinsic or returns an error even if the extrinsic should be correct.

A: First, ensure the api-client and the Substrate node have a matching version. E.g. if you're running your node on `release-polkadot-v1.2.0`, checkout and compile a matching branch of the api-client. We are using the same naming scheme as Parity does. Please note: Not all Polkadot releases are published for all api-client releases. Which Polkadot releases are supported by which api-client release are noted in the [release notes](https://github.com/scs/substrate-api-client/releases). Don't find the release-match you're looking for? Feel free to request it via an issue.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... same as above "your node"

README.md Outdated
@@ -187,6 +187,7 @@ _In alphabetical order_

Ensure you're using a matching config. If you do not use default parameters as configured in one of the provided configs, you must provide your own config that implements the [Config trait](https://github.com/scs/substrate-api-client/blob/master/primitives/src/config/mod.rs).

3. Q: I want to retrieve a state from my node via the api-client, but I do not get the expected value respective the decoding fails. How come?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, the whole paragraph is much more understandable now! 🎉

@haerdib haerdib requested a review from masapr December 5, 2023 16:29
Copy link
Collaborator

@masapr masapr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, thanks!

@haerdib haerdib merged commit bee68b5 into master Dec 7, 2023
51 checks passed
@haerdib haerdib deleted the bh/561-add-readme-faq branch December 7, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E0-silent Will not be mentioned in the release F4-documentation Updates the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an FAQ / Check List
2 participants