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 raw RPC calls #1458

Merged
merged 16 commits into from
Jan 31, 2024
Merged

Add raw RPC calls #1458

merged 16 commits into from
Jan 31, 2024

Conversation

smiasojed
Copy link
Collaborator

@smiasojed smiasojed commented Jan 12, 2024

Summary

Closes #987

  • y/n | Does it introduce breaking changes?
  • y/n | Is it dependent on the specific version of ink or pallet-contracts?

Add raw RPC calls

Description

Invoke an RPC call to the node in the format:
cargo contract rpc [Options] METHOD [PARAMS]

e.g.

cargo contract rpc author_insertKey '"sr25"' '"//ALICE"' \
      5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@smiasojed smiasojed marked this pull request as ready for review January 18, 2024 14:24
or in hex:
`0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d`

Some of the commands require SS58 address in the string format:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to automatically convert it to string to make it consistent? I see this as a source of user errors in future.

Copy link
Collaborator Author

@smiasojed smiasojed Jan 30, 2024

Choose a reason for hiding this comment

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

Is there a way to automatically convert it to string to make it consistent? I see this as a source of user errors in future.

You would need to know for which command it is required. In this case, it means hardcoding the command name and matching agains it.

One idea could be to create metadata for RPC methods and, based on this, convert the input. However, we are currently in a transition period between legacy RPC and the new implementation, which is not finished yet. Therefore, I decided not to create the metadata now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, then I would create an issue for this, so we can pick it up later

Copy link
Contributor

@SkymanOne SkymanOne left a comment

Choose a reason for hiding this comment

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

LGTM, just few nits

@smiasojed smiasojed merged commit 6ef21d3 into master Jan 31, 2024
11 checks passed
@smiasojed smiasojed deleted the sm/rpc branch January 31, 2024 11:33
@smiasojed smiasojed mentioned this pull request Feb 8, 2024
@smiasojed smiasojed mentioned this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow raw RPC calls via cargo contract rpc
2 participants