@@ -7,6 +7,7 @@ import { Operation, toIOperationObservable } from './operation'
7
7
import { IProposalCreateOptions , IProposalQueryOptions , Proposal } from './proposal'
8
8
import * as ContributionReward from './schemes/contributionReward'
9
9
import * as GenericScheme from './schemes/genericScheme'
10
+ import { ReputationFromTokenScheme } from './schemes/reputationFromToken'
10
11
import * as SchemeRegistrar from './schemes/schemeRegistrar'
11
12
import { Address , ICommonQueryOptions , IStateful } from './types'
12
13
import { createGraphQlQuery , isAddress } from './utils'
@@ -57,11 +58,25 @@ export interface ISchemeQueryOptions extends ICommonQueryOptions {
57
58
}
58
59
}
59
60
61
+ export interface ISchemeQueryOptions extends ICommonQueryOptions {
62
+ where ?: {
63
+ address ?: Address
64
+ canDelegateCall ?: boolean
65
+ canRegisterSchemes ?: boolean
66
+ canUpgradeController ?: boolean
67
+ canManageGlobalConstraints ?: boolean
68
+ dao ?: Address
69
+ id ?: string
70
+ name ?: string
71
+ paramsHash ?: string
72
+ [ key : string ] : any
73
+ }
74
+ }
75
+
60
76
/**
61
77
* A Scheme represents a scheme instance that is registered at a DAO
62
78
*/
63
79
export class Scheme implements IStateful < ISchemeState > {
64
-
65
80
/**
66
81
* Scheme.search(context, options) searches for scheme entities
67
82
* @param context an Arc instance that provides connection information
@@ -106,16 +121,15 @@ export class Scheme implements IStateful<ISchemeState> {
106
121
} `
107
122
const itemMap = ( item : any ) : Scheme | null => {
108
123
if ( ! options . where ) { options . where = { } }
109
- return new Scheme (
110
- {
111
- address : item . address ,
112
- dao : item . dao . id ,
113
- id : item . id ,
114
- name : item . name ,
115
- paramsHash : item . paramsHash
116
- } ,
117
- context
118
- )
124
+
125
+ const scheme = new Scheme ( {
126
+ address : item . address ,
127
+ dao : item . dao . id ,
128
+ id : item . id ,
129
+ name : item . name ,
130
+ paramsHash : item . paramsHash
131
+ } , context )
132
+ return scheme
119
133
}
120
134
121
135
return context . getObservableList (
@@ -126,9 +140,10 @@ export class Scheme implements IStateful<ISchemeState> {
126
140
}
127
141
128
142
public id : Address
129
- public staticState : ISchemeStaticState | null = null
143
+ public staticState : ISchemeStaticState | null = null
144
+ public ReputationFromToken : ReputationFromTokenScheme | null = null
130
145
131
- constructor ( idOrOpts : Address | ISchemeStaticState , public context : Arc ) {
146
+ constructor ( idOrOpts : Address | ISchemeStaticState , public context : Arc ) {
132
147
this . context = context
133
148
if ( typeof idOrOpts === 'string' ) {
134
149
this . id = idOrOpts as string
@@ -147,17 +162,21 @@ export class Scheme implements IStateful<ISchemeState> {
147
162
* fetch the static state from the subgraph
148
163
* @return the statatic state
149
164
*/
150
- public async fetchStaticState ( ) : Promise < ISchemeStaticState > {
165
+ public async fetchStaticState ( ) : Promise < ISchemeStaticState > {
151
166
if ( ! ! this . staticState ) {
152
167
return this . staticState
153
168
} else {
154
169
const state = await this . state ( ) . pipe ( first ( ) ) . toPromise ( )
155
170
this . staticState = state
171
+ if ( this . staticState . name === 'ReputationFromToken' ) {
172
+ this . ReputationFromToken = new ReputationFromTokenScheme ( this )
173
+ }
174
+
156
175
return state
157
176
}
158
177
}
159
178
160
- public state ( ) : Observable < ISchemeState > {
179
+ public state ( ) : Observable < ISchemeState > {
161
180
const query = gql `
162
181
{
163
182
controllerScheme (id: "${ this . id } ") {
@@ -284,7 +303,7 @@ export class Scheme implements IStateful<ISchemeState> {
284
303
* @param options [description ]
285
304
* @return a Proposal instance
286
305
*/
287
- public createProposal ( options : IProposalCreateOptions ) : Operation < Proposal > {
306
+ public createProposal ( options : IProposalCreateOptions ) : Operation < Proposal > {
288
307
const observable = Observable . create ( async ( observer : any ) => {
289
308
let msg : string
290
309
const context = this . context
0 commit comments