@@ -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
@@ -101,16 +116,15 @@ export class Scheme implements IStateful<ISchemeState> {
101
116
}`
102
117
const itemMap = ( item : any ) : Scheme | null => {
103
118
if ( ! options . where ) { options . where = { } }
104
- return new Scheme (
105
- {
106
- address : item . address ,
107
- dao : item . dao . id ,
108
- id : item . id ,
109
- name : item . name ,
110
- paramsHash : item . paramsHash
111
- } ,
112
- context
113
- )
119
+
120
+ const scheme = new Scheme ( {
121
+ address : item . address ,
122
+ dao : item . dao . id ,
123
+ id : item . id ,
124
+ name : item . name ,
125
+ paramsHash : item . paramsHash
126
+ } , context )
127
+ return scheme
114
128
}
115
129
116
130
return context . getObservableList (
@@ -121,9 +135,10 @@ export class Scheme implements IStateful<ISchemeState> {
121
135
}
122
136
123
137
public id : Address
124
- public staticState : ISchemeStaticState | null = null
138
+ public staticState : ISchemeStaticState | null = null
139
+ public ReputationFromToken : ReputationFromTokenScheme | null = null
125
140
126
- constructor ( idOrOpts : Address | ISchemeStaticState , public context : Arc ) {
141
+ constructor ( idOrOpts : Address | ISchemeStaticState , public context : Arc ) {
127
142
this . context = context
128
143
if ( typeof idOrOpts === 'string' ) {
129
144
this . id = idOrOpts as string
@@ -142,17 +157,21 @@ export class Scheme implements IStateful<ISchemeState> {
142
157
* fetch the static state from the subgraph
143
158
* @return the statatic state
144
159
*/
145
- public async fetchStaticState ( ) : Promise < ISchemeStaticState > {
160
+ public async fetchStaticState ( ) : Promise < ISchemeStaticState > {
146
161
if ( ! ! this . staticState ) {
147
162
return this . staticState
148
163
} else {
149
164
const state = await this . state ( ) . pipe ( first ( ) ) . toPromise ( )
150
165
this . staticState = state
166
+ if ( this . staticState . name === 'ReputationFromToken' ) {
167
+ this . ReputationFromToken = new ReputationFromTokenScheme ( this )
168
+ }
169
+
151
170
return state
152
171
}
153
172
}
154
173
155
- public state ( ) : Observable < ISchemeState > {
174
+ public state ( ) : Observable < ISchemeState > {
156
175
const query = gql `
157
176
{
158
177
controllerScheme (id: "${ this . id } ") {
@@ -279,7 +298,7 @@ export class Scheme implements IStateful<ISchemeState> {
279
298
* @param options [description ]
280
299
* @return a Proposal instance
281
300
*/
282
- public createProposal ( options : IProposalCreateOptions ) : Operation < Proposal > {
301
+ public createProposal ( options : IProposalCreateOptions ) : Operation < Proposal > {
283
302
const observable = Observable . create ( async ( observer : any ) => {
284
303
let msg : string
285
304
const context = this . context
0 commit comments