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

feat: new runtime API for unique linking #787

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

ntn-x2
Copy link
Member

@ntn-x2 ntn-x2 commented Nov 5, 2024

Part of https://github.com/KILTprotocol/ticket/issues/3650, based on top of #784. Last bit of required functionality.

Features

  • Since it's not possible to batch multiple runtime API calls, I introduced a batch_ version for our old did runtime API, which allows to do batching instead of firing one request per lookup
  • Similarly to that, I introduced a new runtime API (since it's not possible to implement the same API twice for the same runtime), which resolves an account given a name, or a name given an account. This new API also provides a batched version to resolve multiple names or addresses at once. This was one of the requirements we got from Parity to make the solution easier to integrate in the mobile app

How to test

Polkadot Apps support new runtime APIs out of the box. So just compile Peregrine or Spiritnet runtime and spin up a network with Chopsticks. Then:

  1. Create a new account-controlled DID. For the Sudo key, use this call 0x401003921cbc0ffe09a865dbf4ae1d0410aa17c656881fe86666da0f97939e3701b674
  2. Claim a new dotname. For the Sudo key, use this call 0x400f921cbc0ffe09a865dbf4ae1d0410aa17c656881fe86666da0f97939e3701b674490020746573742e646f74
  3. Link the Sudo account to the DID. Use this call 0x400f921cbc0ffe09a865dbf4ae1d0410aa17c656881fe86666da0f97939e3701b6744a01
  4. Call the runtime API uniqueLinking.addressForName("test.dot") which should return
{
  Ok: {
    address: {
      AccountId32: 4rDeMGr3Hi4NfxRUp8qVyhvgW3BSUBLneQisGa9ASkhh2sXB
    }
    extra: 4rDeMGr3Hi4NfxRUp8qVyhvgW3BSUBLneQisGa9ASkhh2sXB
  }
}
  1. Call the runtime API uniqueLinking.nameForAddress({AccountId32: "4rDeMGr3Hi4NfxRUp8qVyhvgW3BSUBLneQisGa9ASkhh2sXB"}) which should return
{
  Ok: {
    name: test.dot
    extra: 4rDeMGr3Hi4NfxRUp8qVyhvgW3BSUBLneQisGa9ASkhh2sXB
  }
}

@ntn-x2
Copy link
Member Author

ntn-x2 commented Nov 6, 2024

@rflechtner perhaps you want to review this PR as well? The new runtime APIs are a result of addressing Parity's requirements. I acknowledge it could be confusing now to have two separate linking features and user-friendly name stuff, as well as two separate runtime API for resolution of those, but I am aiming to discuss about this in next week's tech board.

@ntn-x2 ntn-x2 force-pushed the aa/unique-linking-runtime-api branch 2 times, most recently from a1cf59c to 9288da6 Compare November 6, 2024 10:11
Base automatically changed from aa/new-pallets-runtime to develop November 6, 2024 12:12
@ntn-x2 ntn-x2 force-pushed the aa/unique-linking-runtime-api branch from 9288da6 to 6c51b9e Compare November 6, 2024 12:12
@ntn-x2 ntn-x2 mentioned this pull request Nov 6, 2024
@ntn-x2
Copy link
Member Author

ntn-x2 commented Nov 7, 2024

@Ad96el I'm going to merge this since Parity needs it. Please provide any feedback here and I will address them in a separate PR, thank you!

@ntn-x2 ntn-x2 merged commit bb72504 into develop Nov 7, 2024
7 of 8 checks passed
@ntn-x2 ntn-x2 deleted the aa/unique-linking-runtime-api branch November 7, 2024 10:59
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.

2 participants