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 endpoints #504

Merged
merged 15 commits into from
Apr 5, 2021
Merged

Add endpoints #504

merged 15 commits into from
Apr 5, 2021

Conversation

emostov
Copy link
Contributor

@emostov emostov commented Apr 5, 2021

Adds endpoints:

  • paras/: list of all registered parachains and their lifecycle stage.
  • /:paraId/lease-info: current and future lease information for a para.
  • /:paraId/crowdloan-info: info on a para's current crowdloan.
  • /leases/current: list of all lease holders for the current lease period and general information about the current lease period.
  • /auctions/current: information on the current auction.

Future PRs:

  • Test for endpoints
  • Docs
  • Maybe merge crowdloan-info & lease-info into a single endpoint that just has all the plo info that is specific to a chain.

@emostov emostov requested a review from TarikGul April 5, 2021 05:16
@emostov emostov marked this pull request as ready for review April 5, 2021 05:16
* }
* @param hash `BlockHash` to make call at
* @param paraId ID of para to get crowdloan info for
* @returns crowdloan information for paradId
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this, We don't document any of the @returns in any other services, we could get rid of this. Up to you though.

* }
* @param hash `BlockHash` to make call at
* @param includeFundInfo wether or not to include `FundInfo` for every crowdloan
* @returns list of all crowdloans
Copy link
Member

Choose a reason for hiding this comment

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

Same as before. Maybe we could remove these @returns and write doc info above the @param notes.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is really that important more so an observation of continuity between all services.

@@ -45,51 +71,44 @@ export class ParasService extends AbstractService {
return {
at,
fundInfo,
// TOOD would it make snese to merge the below derived info into `fundInfo`
Copy link
Member

Choose a reason for hiding this comment

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

Little confused on this could you elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically should we add leasePeriods as a key within the fundInfo object?

blockNumber
).toNumber();

leasesFormatted = leases.reduce((acc, curLeaseOpt, idx) => {
Copy link
Member

Choose a reason for hiding this comment

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

Very Nice!

leasesFormatted = null;
}

let onboardingAs: ParaType | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Could we make an IOption<T> for undefined's?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be open to it, but would want to call it something else.
My only hold up though are that undefined fn params and interface properties already have the ? operator which is normally preferred over having a union type with undefined.

blockNumber = number.unwrap();

currentLeaseHolders = leaseEntries
.filter(([_k, leases]) => leases[0].isSome)
Copy link
Member

Choose a reason for hiding this comment

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

I like the use of isSome, I think it has the ability to also optimize code in a lot of other service, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup - just to clarify though, this is .isSome is a property on the polkadot-js Option enum which extends Codec - which is different than the IOption type alias we have defined within this repo.


const parasPromises = paraLifecycles.map(async ([k, paraLifeCycle]) => {
const paraId = k.args[0];
let onboardingAs: ParaType | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here could we have a Option for undefined.

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.

LGTM, little grammar nit pics.

Also comments about the @returns, up to you if you want them there or not.

emostov and others added 2 commits April 5, 2021 12:15
Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com>
@emostov emostov merged commit b898e3d into feat-experiment-plo-endpoints Apr 5, 2021
@emostov emostov deleted the zeke-experimental-plo branch April 5, 2021 19:18
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