-
Notifications
You must be signed in to change notification settings - Fork 157
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: chainSpec based controller config; Types from apps-config #351
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to tinker with this a bit before I leave a proper review.
Co-authored-by: David <dvdplm@gmail.com>
Added a CHAIN_INTEGRATION.md guide that @joepetrowski may be interested in reviewing |
|
||
##### Basic balance transfer support | ||
|
||
In order to support traditional balance transfers the chain's Sidecar endpoints should support account balance lookup, transaction submission, transaction material retrieval, and block queries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Even if we haven't decided the exact token standard, good to start somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be good to link to examples of how each of these look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dvdplm - what exactly do you have in mind for examples? My idea here was essentially to say "make sure to add the relevant controllers for these endpoints".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah maybe it's dumb but my thinking was to link to example implementations of the existing Polkadot/Kusama endpoints; a dev adding sidecar for their chain might want to peek at how you did those endpoints as theirs will likely be fairly similar?
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
|
||
##### Basic balance transfer support | ||
|
||
In order to support traditional balance transfers the chain's Sidecar endpoints should support account balance lookup, transaction submission, transaction material retrieval, and block queries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be good to link to examples of how each of these look like.
acc.push( | ||
new controllers[controllerName](api, config.options.finalizes) | ||
); | ||
acc.push(new controllers[controllerName](api, config.options)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grumbles and comments
boolean | ||
][]; | ||
|
||
return controllersToInclude.reduce((acc, [controllerName, shouldMount]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One day JavaScript will get filterMap
on arrays, one day... :)
Co-authored-by: David <dvdplm@gmail.com>
Responded to all comments. I think it is is looking pretty good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One tiny nit left!
Skip to content | ||
Search or jump to… | ||
|
||
Pull requests | ||
Issues | ||
Marketplace | ||
Explore | ||
|
||
@emostov | ||
paritytech | ||
/ | ||
substrate - api - sidecar | ||
12 | ||
56 | ||
29 | ||
Code | ||
Issues | ||
20 | ||
Pull requests | ||
1 | ||
Actions | ||
Security | ||
4 | ||
Insights | ||
Settings | ||
substrate - api - sidecar / src / services / accounts / AccountsBalanceInfoService.ts / | ||
@emostov | ||
emostov Initial reply david review | ||
Latest commit be66056 6 days ago | ||
History | ||
2 contributors | ||
@emostov @joepetrowski | ||
We found potential security vulnerabilities in your dependencies. | ||
You can see this message because you have been granted access to Dependabot alerts for this repository. | ||
|
||
95 lines(87 sloc) 2.38 KB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting glitch in the matrix here. :D
Co-authored-by: David <dvdplm@gmail.com>
Closes #334
Overview
This PR introduces the foundations of allowing Sidecar to work smoothly with FRAME based chains. It accomplishes this by
@polkadot/apps-config
which are injected into the APIspecName
and hard coded config that aligns with thespecName
.These changes will allow most FRAME chain builders to use Sidecar by just specifying end points their chain supports in the controllers config and keeping there chain types up to date in
@polkadot/apps-config
.In this PR I also include controller configuration for Kulupu since it was requested in an issue (#350) and makes sense to have a live example to try out the setup.
Would be nice to get this through in the near future, since it will be a blocker for meaningful work in this repo.
Changes
Chain types
@polkadot/apps-config
and use the inApiPromise
Controller config
ControllerConfig
insrc/types/chains-config
)getControllersForSpec
andgetControllersFromConfig
fromsrc/chains-config/index.ts
)src/controllers/index.ts
now exports a concretecontrollers
object so we can have better type safety when dynamically creating the controllers withgetControllersFromConfig
insrc/chains-config/index.ts
finalizes
filed that is used to decide if thegetFinalizedHead
should be used in the blocks controllersubstrate-api-sidecar/src/controllers/blocks/BlocksController.ts
Line 94 in 0ac5573
Endpoints (services/ controllers)
Creation ofKulupuBlocksController
which has new/kulupuBlocks/{head, :number}
endpoint. I had to do this because there is no notion of finalized blocks since it is a simple PoW consensus (someone please correct if I am wrong). In the new controller only a couple lines here taken out to remove the?finalized=boolean
query param, but I created an entire other controller with a new endpoint name to keep things simple; However I am certainly open to other ideas, I just don't want the controllers to scale with a huge amount of conditionals as we add more chains.accounts/{accountId}/balance-info
tokenSymbol
field in the response to reduce ambiguity on the token of the balances representedBlocksService
is updated so it does not break when it encounters chains that do not have all the components to supportCalcFee.from_params
Other changes
main
to declutter.Config
=>SidecarConfig
to reduce ambiguity against the new typeControllerConfig
How to try out the PR
Follow the instructions in the README: https://github.com/paritytech/substrate-api-sidecar#source-code-installation-and-usage and then start the service against Kulupu or Mandala by running
SAS_SUBSTRATE_WS_URL=wss://rpc.kulupu.corepaper.org/ws yarn start
. You can then discover the available endpoints by visiting GEThttp://127.0.0.1:8080/
Follow up work