Skip to content

Commit 8998443

Browse files
Add isRegistered to schemes (#435)
* Include isRegistered field in scheme queries * Make sure that boolean fields can be included in where queries * Lint fixes * fix test * remove async cache manipulation * Skip not working competition tests * Skip one more test Co-authored-by: dOrgJelli <[email protected]>
1 parent 56a00cd commit 8998443

File tree

9 files changed

+132
-223
lines changed

9 files changed

+132
-223
lines changed

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ services:
2626
GRAPH_GRAPHQL_MAX_FIRST: '1000'
2727

2828
ipfs:
29-
image: daostack/test-env-ipfs:3.0.31
29+
image: daostack/test-env-ipfs:3.0.32
3030
ports:
3131
- 5001:5001
3232

3333
postgres:
34-
image: daostack/test-env-postgres:3.0.31
34+
image: daostack/test-env-postgres:3.0.32
3535
ports:
3636
- 9432:5432
3737
environment:
3838
POSTGRES_PASSWORD: 'letmein'
3939

4040
ganache:
41-
image: daostack/test-env-ganache:3.0.31
41+
image: daostack/test-env-ganache:3.0.32
4242
ports:
4343
- 8545:8545

documentation/development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ npm run test -- --watch
3939
### Commands
4040

4141
- `npm run build`: Generate bundles and typings, create docs
42+
- `npm run build:watch`: Generate bundles and typings, create docs, watches for files to change and rebuilds when they do
4243
- `npm run lint`: Lints code
4344
- `npm run test`: run all tests

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/client",
3-
"version": "0.2.64",
3+
"version": "0.2.65",
44
"description": "",
55
"keywords": [],
66
"main": "dist/lib/index.js",

src/scheme.ts

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import gql from 'graphql-tag'
22
import { Observable } from 'rxjs'
33
import { first } from 'rxjs/operators'
44
import { Arc, IApolloQueryOptions } from './arc'
5-
import { IGenesisProtocolParams, mapGenesisProtocolParams } from './genesisProtocol'
5+
import { mapGenesisProtocolParams } from './genesisProtocol'
66
import { Operation, toIOperationObservable } from './operation'
77
import { IProposalCreateOptions, IProposalQueryOptions, Proposal } from './proposal'
8-
import { SchemeBase } from './schemes/base'
8+
import { ISchemeQueryOptions, ISchemeState, ISchemeStaticState, SchemeBase } from './schemes/base'
99
import { CompetitionScheme, isCompetitionScheme } from './schemes/competition'
1010
import * as Competition from './schemes/competition'
1111
import * as ContributionReward from './schemes/contributionReward'
@@ -14,93 +14,10 @@ import * as GenericScheme from './schemes/genericScheme'
1414
import { ReputationFromTokenScheme } from './schemes/reputationFromToken'
1515
import * as SchemeRegistrar from './schemes/schemeRegistrar'
1616
import * as UGenericScheme from './schemes/uGenericScheme'
17-
// import { DAO } from './dao'
18-
// import { IStateful } from './types'
19-
import { Address, ICommonQueryOptions } from './types'
17+
import { Address } from './types'
2018
import { createGraphQlQuery } from './utils'
2119

22-
export interface ISchemeStaticState {
23-
id: string
24-
address: Address
25-
dao: Address
26-
name: string
27-
paramsHash: string
28-
version: string
29-
}
30-
31-
export interface ISchemeState extends ISchemeStaticState {
32-
canDelegateCall: boolean
33-
canRegisterSchemes: boolean
34-
canUpgradeController: boolean
35-
canManageGlobalConstraints: boolean
36-
dao: Address
37-
paramsHash: string
38-
contributionRewardParams?: IContributionRewardParams
39-
contributionRewardExtParams?: IContributionRewardExtParams
40-
genericSchemeParams?: IGenericSchemeParams
41-
schemeRegistrarParams?: {
42-
votingMachine: Address
43-
voteRemoveParams: IGenesisProtocolParams
44-
voteRegisterParams: IGenesisProtocolParams
45-
} | null
46-
numberOfQueuedProposals: number
47-
numberOfPreBoostedProposals: number
48-
numberOfBoostedProposals: number
49-
uGenericSchemeParams?: IGenericSchemeParams
50-
schemeParams?: IGenericSchemeParams | IContributionRewardParams | IContributionRewardExtParams | ISchemeRegisterParams
51-
}
52-
53-
export interface IGenericSchemeParams {
54-
votingMachine: Address
55-
contractToCall: Address
56-
voteParams: IGenesisProtocolParams
57-
}
58-
59-
export interface IContributionRewardParams {
60-
votingMachine: Address
61-
voteParams: IGenesisProtocolParams
62-
}
63-
export interface IContributionRewardExtParams {
64-
votingMachine: Address
65-
voteParams: IGenesisProtocolParams
66-
rewarder: Address
67-
}
68-
69-
export interface ISchemeRegisterParams {
70-
votingMachine: Address
71-
contractToCall: Address
72-
voteParams: IGenesisProtocolParams
73-
}
74-
75-
export interface ISchemeQueryOptions extends ICommonQueryOptions {
76-
where?: {
77-
address?: Address
78-
canDelegateCall?: boolean
79-
canRegisterSchemes?: boolean
80-
canUpgradeController?: boolean
81-
canManageGlobalConstraints?: boolean
82-
dao?: Address
83-
id?: string
84-
name?: string
85-
paramsHash?: string
86-
[key: string]: any
87-
}
88-
}
89-
90-
export interface ISchemeQueryOptions extends ICommonQueryOptions {
91-
where?: {
92-
address?: Address
93-
canDelegateCall?: boolean
94-
canRegisterSchemes?: boolean
95-
canUpgradeController?: boolean
96-
canManageGlobalConstraints?: boolean
97-
dao?: Address
98-
id?: string
99-
name?: string
100-
paramsHash?: string
101-
[key: string]: any
102-
}
103-
}
20+
export { ISchemeQueryOptions, ISchemeState, ISchemeStaticState } from './schemes/base'
10421

10522
/**
10623
* A Scheme represents a scheme instance that is registered at a DAO
@@ -242,6 +159,7 @@ export class Scheme extends SchemeBase {
242159
dao: item.dao.id,
243160
genericSchemeParams,
244161
id: item.id,
162+
isRegistered: item.isRegistered,
245163
name,
246164
numberOfBoostedProposals: Number(item.numberOfBoostedProposals),
247165
numberOfPreBoostedProposals: Number(item.numberOfPreBoostedProposals),

src/schemes/base.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@ import gql from 'graphql-tag'
22
import { Observable } from 'rxjs'
33
import { first } from 'rxjs/operators'
44
import { Arc, IApolloQueryOptions } from '../arc'
5-
// import { DAO } from './dao'
65
import { IGenesisProtocolParams } from '../genesisProtocol'
76
import { Operation, toIOperationObservable } from '../operation'
87
import {
98
IProposalCreateOptions,
109
IProposalQueryOptions, Proposal } from '../proposal'
1110
import { Address, ICommonQueryOptions, IStateful } from '../types'
12-
// import * as ContributionReward from './contributionReward'
13-
// import * as ContributionRewardExt from './schemes/contributionRewardExt'
14-
// import * as GenericScheme from './genericScheme'
1511
import { ReputationFromTokenScheme } from './reputationFromToken'
16-
// import * as SchemeRegistrar from './schemeRegistrar'
17-
// import * as UGenericScheme from './uGenericScheme'
1812

1913
export interface ISchemeStaticState {
2014
id: string
@@ -31,6 +25,7 @@ export interface ISchemeState extends ISchemeStaticState {
3125
canUpgradeController: boolean
3226
canManageGlobalConstraints: boolean
3327
dao: Address
28+
isRegistered: boolean
3429
paramsHash: string
3530
contributionRewardParams?: IContributionRewardParams
3631
contributionRewardExtParams?: IContributionRewardExtParams
@@ -78,21 +73,7 @@ export interface ISchemeQueryOptions extends ICommonQueryOptions {
7873
canManageGlobalConstraints?: boolean
7974
dao?: Address
8075
id?: string
81-
name?: string
82-
paramsHash?: string
83-
[key: string]: any
84-
}
85-
}
86-
87-
export interface ISchemeQueryOptions extends ICommonQueryOptions {
88-
where?: {
89-
address?: Address
90-
canDelegateCall?: boolean
91-
canRegisterSchemes?: boolean
92-
canUpgradeController?: boolean
93-
canManageGlobalConstraints?: boolean
94-
dao?: Address
95-
id?: string
76+
isRegistered?: boolean
9677
name?: string
9778
paramsHash?: string
9879
[key: string]: any
@@ -114,6 +95,7 @@ export abstract class SchemeBase implements IStateful<ISchemeState> {
11495
canRegisterSchemes
11596
canUpgradeController
11697
canManageGlobalConstraints
98+
isRegistered
11799
paramsHash
118100
contributionRewardParams {
119101
id

src/schemes/competition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export class CompetitionScheme extends SchemeBase {
154154
dao: item.dao.id,
155155
genericSchemeParams,
156156
id: item.id,
157+
isRegistered: item.isRegistered,
157158
name,
158159
numberOfBoostedProposals: Number(item.numberOfBoostedProposals),
159160
numberOfPreBoostedProposals: Number(item.numberOfPreBoostedProposals),

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function createGraphQlWhereQuery(where?: {[key: string]: string|string[]|
145145
}
146146

147147
let value = where[key]
148-
if (value === null) {
148+
if (value === null || typeof(value) === 'boolean') {
149149
result += `${key}: ${value}\n`
150150
} else if (key === 'dao' || key === 'address') {
151151
isAddress(value as string)

0 commit comments

Comments
 (0)