-
Notifications
You must be signed in to change notification settings - Fork 84
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
ApiHandler / ChainData refactoring #2951
Conversation
761966e
to
bc312a9
Compare
|
||
const chainType = await chaindata?.api?.rpc.system.chain(); | ||
const chainType = await api.rpc.system.chain(); | ||
if (!chainType) { | ||
return null; | ||
} | ||
const denom = | ||
chainType.toString() == "Polkadot" ? 10000000000 : 1000000000000; |
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 this be fetched dynamically from the api ?
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.
api.registry.getChainProperties()
should return tokenDecimals
, where denom = 10 ** tokenDecimals
@@ -200,8 +197,9 @@ export default class Nominator extends EventEmitter { | |||
|
|||
public async stash(): Promise<string> { | |||
try { | |||
const api = this.handler.getApi(); | |||
const ledger = await api?.query.staking.ledger(this.bondedAddress); | |||
// TODO: chain interaction should be performed exclusively in ChainData |
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.
what about this series of TODOs ?
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.
It's better to tackle it separately: https://github.com/w3f/1k-validators-be-PRIVATE/issues/85
This changeset has already gotten too big
Removed a lot of retry/reconnect logic from ApiHandler and ChainData, as it was spawning a lot of PJS instances, which also handling reconnects on its own. This change also properly adpots the idea of talking both to relay chain and to parachains, depending on queried data. With new logic, each ApiHandler instance governs an interface to a single chain, where it can switch endpoints and do reconnects on its own. `ApiHandler.getApi()` returns a PJS instance that should work, and will block in case we're reconnecting. PeopleApi endpoints now live in configs, instead of being hardcoded. Instead of passing around ApiHandlers, passing a ChainData instance now, as it contains both ApiHandlers instance now, and as it is an intended abstraction for it
bc312a9
to
5ad0ab4
Compare
apiPeopleEndpoints in kusama configs
ca8fb57
to
8c2ae30
Compare
Removed a lot of retry/reconnect logic from ApiHandler and ChainData, as it was spawning a lot of PJS instances, which also handling reconnects on its own.
This change also properly adpots the idea of talking both to relay chain and to parachains, depending on queried data.
With new logic, each ApiHandler instance governs an interface to a single chain, where it can switch endpoints and do reconnects on its own.
ApiHandler.getApi()
returns a PJS instance that should work, and will block in case we're reconnecting.PeopleApi endpoints now live in configs, instead of being hardcoded.
Instead of passing around ApiHandlers, passing a ChainData instance now, as it contains both ApiHandlers instance now, and as it is an intended abstraction for it
Fixes https://github.com/w3f/1k-validators-be-PRIVATE/issues/14