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

kosu.js: implement a go-kosu JSONRPC client (the NodeClient) #229

Merged
merged 18 commits into from Aug 23, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

parse number out of poster queries as well

  • Loading branch information
hrharder committed Aug 23, 2019
commit a88cd29ff9906ccba8c317a72b09e422910e8d72
@@ -1,5 +1,5 @@
import { WebsocketProvider, WebsocketProviderOptions } from "@0x/web3-providers-fork";
import { BigNumber } from "@0x/utils";
import { WebsocketProvider, WebsocketProviderOptions } from "@0x/web3-providers-fork";
import assert from "assert";
import { createHash } from "crypto";
import { isFunction, isString } from "lodash";
@@ -134,7 +134,11 @@ export class NodeClient {
*/
public async queryPoster(address: string): Promise<Poster> {
assert(/^0x[a-fA-F0-9]{40}$/.test(address), "invalid Ethereum address string");
return this._call("kosu_queryPoster", address.toLowerCase());
const raw = await this._call("kosu_queryPoster", address.toLowerCase());

// HACK: dealing with protobuf `balance: 'value: N'` encoding
const balance = new BigNumber(raw.balance.split(": ")[1]);
return { ...raw, balance };
}

/**
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.