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: add pallets/on-going-referenda endpoint #1471

Merged
merged 6 commits into from
Aug 14, 2024
Merged

feat: add pallets/on-going-referenda endpoint #1471

merged 6 commits into from
Aug 14, 2024

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Aug 11, 2024

Description

Closes #1431

This PR adds the pallets/on-going-referenda endpoint which returns a list of all on-going referenda and their associated info.

Query Params

  • at: Which block to query, it will default to the latest finalized block. Accepts a hash or blocknumber

Sample Response

Sidecar request while connected to Kusama chain :

http://127.0.0.1:8080/pallets/on-going-referenda?at=22652724

returns

{
  "at": {
    "hash": "0xb57617ca12ccf589b0c5e1d34489198ceca6aa4f99ad0aef41f3b364baeb29a7",
    "height": "22652724"
  },
  "referenda": [
    {
      "id": "372",
      "decisionDeposit": {
        "who": "D9qBj8WnniECUWJxtbsu6ncUN24gKSi3KKp5ZPJjfG2GmaM",
        "amount": "333333333330000"
      },
      "enactment": {
        "after": "100"
      },
      "submitted": "22580366",
      "deciding": {
        "since": "22587442",
        "confirming": null
      }
    },
    {
      "id": "368",
      ...
      ...
    },
    {
      "id": "374",
      ...
      ...
      }
    },
    {
      "id": "375",
      ...
      ...
      }
    },
    {
      "id": "371",
      ...
      ...
      }
    },
    {
      "id": "370",
      ...
      ...
      }
    },
    {
      "id": "373",
      "decisionDeposit": {
        "who": "D9qBj8WnniECUWJxtbsu6ncUN24gKSi3KKp5ZPJjfG2GmaM",
        "amount": "333333333330000"
      },
      "enactment": {
        "at": "22790000"
      },
      "submitted": "22580499",
      "deciding": {
        "since": "22587439",
        "confirming": null
      }
    }
  ]
}

Then we can check the referendum id 373 in Polkassembly and can verify that it corresponds to a runtime upgrade: "#373 Upgrade Kusama v1.2.0". To streamline the process and avoid extra checks, we can directly run only this script. The script queries both Sidecar's on-going-referenda endpoint and Polkassembly API and tells us which referendum is a runtime upgrade.

Example Use

An example use of this endpoint can be found in this script runtime-upgrades-checker.

Todos

  • Update docs
  • Add test when call api.query.referenda is not available and throws an error
  • Add test when call api.query.referenda is available and returns a list of referenda

@Imod7 Imod7 marked this pull request as ready for review August 12, 2024 17:12
@Imod7 Imod7 requested a review from a team as a code owner August 12, 2024 17:12
@filvecchiato filvecchiato self-requested a review August 13, 2024 08:04
Copy link
Contributor

@filvecchiato filvecchiato left a comment

Choose a reason for hiding this comment

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

Looking good! Nice work!

One minor thing in the pallet service where I left the comment. I think once that is resolved it can get merged!

src/services/pallets/PalletsOnGoingReferendaService.ts Outdated Show resolved Hide resolved
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.

Great Job overall looks good, just one little nit.

Copy link
Contributor

@filvecchiato filvecchiato left a comment

Choose a reason for hiding this comment

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

All looking good! Nice work, not sure if you want to integrate my last comment

src/services/pallets/PalletsOnGoingReferendaService.ts Outdated Show resolved Hide resolved
- added block height in the error msg (Tarik's review)
- added a Promise.all (Filippo's review)
@Imod7 Imod7 merged commit 386fbb3 into master Aug 14, 2024
15 checks passed
@Imod7 Imod7 deleted the domi-referenda branch August 14, 2024 09:38
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.

New endpoint to query ongoing referenda from root and whitelisted caller and their timeline.
3 participants