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

Support BTreeMap and fix rpc optional #9911

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Neopallium
Copy link
Contributor

Closes issue #1723

@TarikGul
Copy link
Member

@Neopallium I have this on my list to review, and will do it as soon as possible so we can get this in.

@@ -61,9 +60,9 @@ function Vector ({ className = '', defaultValue, isDisabled = false, label, onCh
useEffect((): void => {
inputParams.length &&
setParams((prev) =>
getParams(inputParams, prev, isDisabled ? (defaultValue.value as RawParam[] || []).length : count)
getParams(inputParams, prev, isDisabled ? values.length : count)
Copy link
Member

Choose a reason for hiding this comment

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

Ahh nice catch here 👍!

@@ -72,7 +72,7 @@ function Selection ({ queueRpc }: Props): React.ReactElement<Props> {
(): void => queueRpc({
rpc,
values: values
.filter(({ value }) => !isNull(value))
.filter(({ value }, idx) => !rpc.params[idx].isOptional || !isNull(value))
Copy link
Member

Choose a reason for hiding this comment

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

Apologies but can you give a brief explanation as to what this is fixing? Thanks again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The isOptional setting only really works for last parameters, not for a mix of Option and non-Option parameters. So the fix keeps null values for isOptional=false parameters.

We are using this fix here: https://mainnet-app.polymesh.network/#/rpc
Open the asset.canTransferGranular endpoint and just click the submit button (don't need to fill in values).

To see the error try the same endpoint using the Polkadot.js.org app without the fix: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet-rpc.polymesh.network#/rpc

The error is:

1: asset.canTransferGranular: CanTransferGranularReturn
Expected 7 parameters (1 optional), 4 found instead

Copy link
Member

Choose a reason for hiding this comment

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

Ahh okay, thanks so much for the explanation. Makes sense

Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

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

Overall, looks super solid Thanks so much for the PR! The BTreeMap Component is spot on, and the vector fix is awesome.

Just a small nit with the console, and a quick question about the rpc optional fix. Other than that it should be ready to go.

@TarikGul
Copy link
Member

Just needs a yarn lint

@Neopallium Neopallium force-pushed the support_btreemap_fix_rpc_optional branch from b478f4a to 24f3f99 Compare March 25, 2024 17:35
@Neopallium
Copy link
Contributor Author

lint applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants