Skip to content

Commit

Permalink
Fix: Add missing SubscriptionCallback types (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xGabi authored Aug 25, 2020
1 parent 4fd868f commit cabb5be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
17 changes: 13 additions & 4 deletions packages/connect-voting-disputable/src/models/Vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import CastVote from './CastVote'
import DisputableVoting from './DisputableVoting'
import CollateralRequirement from './CollateralRequirement'
import { IDisputableVotingConnector, VoteData } from '../types'
import { toMilliseconds, bn, formatBn, PCT_BASE, PCT_DECIMALS } from '../helpers'
import {
toMilliseconds,
bn,
formatBn,
PCT_BASE,
PCT_DECIMALS,
} from '../helpers'

export default class Vote {
#connector: IDisputableVotingConnector
Expand Down Expand Up @@ -72,8 +78,11 @@ export default class Vote {
}

get hasEnded(): boolean {
return this.voteStatus !== 'Challenged' && this.voteStatus !== 'Disputed' &&
Date.now() >= toMilliseconds(this.endDate)
return (
this.voteStatus !== 'Challenged' &&
this.voteStatus !== 'Disputed' &&
Date.now() >= toMilliseconds(this.endDate)
)
}

get endDate(): string {
Expand Down Expand Up @@ -157,7 +166,7 @@ export default class Vote {
return this.#connector.setting(this.settingId)
}

onSetting(callback: Function): SubscriptionHandler {
onSetting(callback: SubscriptionCallback<Setting>): SubscriptionHandler {
return this.#connector.onSetting(this.settingId, callback)
}

Expand Down
7 changes: 5 additions & 2 deletions packages/connect-voting-disputable/src/thegraph/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,11 @@ export default class DisputableVotingConnectorTheGraph
)
}

onERC20(tokenAddress: string, callback: Function): SubscriptionHandler {
return this.#gql.subscribeToQueryWithParser(
onERC20(
tokenAddress: string,
callback: SubscriptionCallback<ERC20>
): SubscriptionHandler {
return this.#gql.subscribeToQueryWithParser<ERC20>(
queries.GET_ERC20('subscription'),
{ tokenAddress },
callback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function parseCollateralRequirement(
{
id: collateralRequirement.id,
voteId: collateralRequirement.vote.id,
token: collateralRequirement.token.id,
tokenId: collateralRequirement.token.id,
actionAmount: collateralRequirement.actionAmount,
challengeAmount: collateralRequirement.challengeAmount,
challengeDuration: collateralRequirement.challengeDuration,
Expand Down

0 comments on commit cabb5be

Please sign in to comment.