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
kosu.js: implement a go-kosu JSONRPC client (the NodeClient) #229
Merged
+1,389
−717
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ba893b7
initial node RPC client implementation
hrharder 8a93ad6
missing await on promise
hrharder f040e2f
fixing validators balance conversion
hrharder 11b9cc0
adding func to convert from public key to node ID
hrharder 6f2e797
kosu.js: implement kosu node jsonrpc client
hrharder b7f6706
kosu.js: running prettier
hrharder 4048650
kosu.js: regenerating docs
hrharder 884b6c7
kosu.js: don't generate docs for private methods
hrharder 32ee5b8
Merge branch 'master' into feature/kosu.js/node-rpc
hrharder fc105a5
kosu.js: add lint:fix script
hrharder d63dab4
kosu.js: fixing linter errors
hrharder 723d4cc
Merge branch 'feature/kosu.js/node-rpc' of github.com:ParadigmFoundat…
hrharder b6bc830
kosu.js: applying prettier fixes
hrharder 1965401
use BigNumber for validator balance
hrharder a88cd29
parse number out of poster queries as well
hrharder 67be855
Merge branch 'master' into feature/kosu.js/node-rpc
hrharder e49427a
update validator and poster types to use BigNumber
hrharder 725d0ba
Merge branch 'feature/kosu.js/node-rpc' of github.com:ParadigmFoundat…
hrharder File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
fixing validators balance conversion
- Loading branch information
hrharder
committed
Aug 22, 2019
hrharder
Henry Harder
commit f040e2f903bdf0c08aa11a2557d1d8355454f842
Verified
This commit was signed with a verified signature.
GPG key ID: 3E4EB305434EC58E
Learn about signing commits
| @@ -8,10 +8,10 @@ export class NodeClient { | ||
| private readonly _heartbeatInterval: number; | ||
| private readonly _subscriptionIdMap: { [uuid: string]: string }; | ||
|
|
||
| private static _convertValidatorData(rawValidators: any[]): Validator[] { | ||
| private static _convertValidatorData(...rawValidators: any[]): Validator[] { | ||
| const validators = []; | ||
| for (const validator of rawValidators) { | ||
| const balance = parseInt(validator.balance.split(": ")); | ||
| const balance = parseInt(validator.balance.split(": ")[1]); | ||
|
This conversation was marked as resolved
by hrharder
hrharder
Author
Member
|
||
| validators.push({ ...validator, balance }); | ||
| } | ||
| return validators; | ||
| @@ -42,14 +42,13 @@ export class NodeClient { | ||
| } | ||
|
|
||
| public async queryValidator(nodeId: string): Promise<Validator> { | ||
| if (/^[a-fA-F0-9]{40}$/.test(nodeId)) { | ||
| if (!/^[a-fA-F0-9]{40}$/.test(nodeId)) { | ||
| throw new Error("invalid validator node ID string"); | ||
| } | ||
|
|
||
| // hack: dealing with protobuf decoding issues | ||
| const raw = await this._call("kosu_queryValidator", nodeId); | ||
| const balance = parseInt(raw.balance.split(": ")); | ||
| return { ...raw, balance }; | ||
| return NodeClient._convertValidatorData(raw)[0]; | ||
| } | ||
|
|
||
| public async remainingLimit(): Promise<number> { | ||
| @@ -72,7 +71,7 @@ export class NodeClient { | ||
|
|
||
| public async validators(): Promise<Validator[]> { | ||
| const rawValidators = await this._call("kosu_validators"); | ||
| return NodeClient._convertValidatorData(rawValidators as unknown as any[]); | ||
| return NodeClient._convertValidatorData(...rawValidators); | ||
| } | ||
|
|
||
| public async subscribeToOrders(cb: (orders: any[]) => void): Promise<string> { | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Should this be stored as a BigNumber? I am under the impression this is tokens not power. The minimum right now 5e20.