Skip to content

Commit 24f1879

Browse files
authored
Merge branch 'client-2-0' into gh-issue-512
2 parents 2d14eb5 + e3040cc commit 24f1879

File tree

8 files changed

+77
-230
lines changed

8 files changed

+77
-230
lines changed

release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package_version=$(cat package.json | jq -r '.version')
66

77
# tag on github
88
echo "create tag ${package_version}"
9-
git ci -a -m "Package version ${package_version}" --allow-empty
9+
git commit -a -m "Package version ${package_version}" --allow-empty
1010
git tag -a $package_version -m "Release of version $package_version"
1111
git push --tags
1212

src/dao.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface IDAOState {
5050
numberOfBoostedProposals: number
5151
metadata: string
5252
metadataHash: string
53+
ethBalance: BN
5354
}
5455

5556
export interface IDAOQueryOptions extends ICommonQueryOptions {
@@ -84,6 +85,7 @@ export class DAO extends Entity<IDAOState> {
8485
reputationHoldersCount
8586
metadata
8687
metadataHash
88+
ethBalance
8789
}
8890
`
8991
}
@@ -165,7 +167,8 @@ export class DAO extends Entity<IDAOState> {
165167
},
166168
tokenName: item.nativeToken.name,
167169
tokenSymbol: item.nativeToken.symbol,
168-
tokenTotalSupply: item.nativeToken.totalSupply
170+
tokenTotalSupply: item.nativeToken.totalSupply,
171+
ethBalance: item.ethBalance
169172
}
170173
}
171174

src/plugins/competition/proposal.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import {
1818
ITransaction,
1919
ITransactionReceipt,
2020
Logger,
21-
NULL_ADDRESS,
2221
Operation,
2322
Plugin,
2423
Proposal,
25-
REDEEMER_CONTRACT_VERSIONS,
2624
secondSinceEpochToDate,
2725
toIOperationObservable
2826
} from '../../index'
@@ -162,23 +160,6 @@ export class CompetitionProposal extends Proposal<ICompetitionProposalState> {
162160
return result
163161
}
164162

165-
public redeemerContract() {
166-
for (const version of REDEEMER_CONTRACT_VERSIONS) {
167-
try {
168-
const contractInfo = this.context.getContractInfoByName('Redeemer', version)
169-
return this.context.getContract(contractInfo.address)
170-
} catch (err) {
171-
if (!err.message.match(/no contract/i)) {
172-
// if the contract cannot be found, try the next one
173-
throw err
174-
}
175-
}
176-
}
177-
throw Error(
178-
`No Redeemer contract could be found (search for versions ${REDEEMER_CONTRACT_VERSIONS})`
179-
)
180-
}
181-
182163
public suggestions(
183164
options: ICompetitionSuggestionQueryOptions = {},
184165
apolloQueryOptions: IApolloQueryOptions = {}
@@ -201,35 +182,6 @@ export class CompetitionProposal extends Proposal<ICompetitionProposalState> {
201182
return CompetitionVote.search(this.context, options, apolloQueryOptions)
202183
}
203184

204-
public redeemRewards(beneficiary?: Address): Operation<boolean> {
205-
const mapReceipt = (receipt: ITransactionReceipt) => true
206-
207-
const createTransaction = async (): Promise<ITransaction> => {
208-
if (!beneficiary) {
209-
beneficiary = NULL_ADDRESS
210-
}
211-
212-
const state = await this.fetchState()
213-
const pluginAddress = (await state.plugin.entity.fetchState()).address
214-
const method = 'redeemFromCRExt'
215-
const args = [pluginAddress, state.votingMachine, this.id, beneficiary]
216-
217-
return {
218-
contract: this.redeemerContract(),
219-
method,
220-
args
221-
}
222-
}
223-
224-
const observable = from(createTransaction()).pipe(
225-
concatMap((transaction) => {
226-
return this.context.sendTransaction(transaction, mapReceipt)
227-
})
228-
)
229-
230-
return toIOperationObservable(observable)
231-
}
232-
233185
public createSuggestion(options: {
234186
title: string
235187
description: string

src/plugins/contributionReward/proposal.ts

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
import BN from 'bn.js'
22
import { DocumentNode } from 'graphql'
33
import gql from 'graphql-tag'
4-
import { from, Observable } from 'rxjs'
5-
import { concatMap } from 'rxjs/operators'
4+
import { Observable } from 'rxjs'
65
import {
76
Address,
87
Arc,
98
ContributionRewardPlugin,
109
IApolloQueryOptions,
1110
IProposalState,
12-
ITransaction,
13-
ITransactionReceipt,
1411
Logger,
15-
NULL_ADDRESS,
16-
Operation,
1712
Plugin,
18-
Proposal,
19-
REDEEMER_CONTRACT_VERSIONS,
20-
toIOperationObservable
13+
Proposal
2114
} from '../../index'
2215

2316
export interface IContributionRewardProposalState extends IProposalState {
@@ -181,51 +174,4 @@ export class ContributionRewardProposal extends Proposal<IContributionRewardProp
181174
) as Observable<IContributionRewardProposalState>
182175
return result
183176
}
184-
185-
public redeemerContract() {
186-
for (const version of REDEEMER_CONTRACT_VERSIONS) {
187-
try {
188-
const contractInfo = this.context.getContractInfoByName('Redeemer', version)
189-
return this.context.getContract(contractInfo.address)
190-
} catch (err) {
191-
if (!err.message.match(/no contract/i)) {
192-
// if the contract cannot be found, try the next one
193-
throw err
194-
}
195-
}
196-
}
197-
throw Error(
198-
`No Redeemer contract could be found (search for versions ${REDEEMER_CONTRACT_VERSIONS})`
199-
)
200-
}
201-
202-
public redeemRewards(beneficiary?: Address): Operation<boolean> {
203-
const mapReceipt = (receipt: ITransactionReceipt) => true
204-
205-
const createTransaction = async (): Promise<ITransaction> => {
206-
if (!beneficiary) {
207-
beneficiary = NULL_ADDRESS
208-
}
209-
210-
const state = await this.fetchState()
211-
const pluginState = await state.plugin.entity.fetchState()
212-
const pluginAddress = pluginState.address
213-
const method = 'redeem'
214-
const args = [pluginAddress, state.votingMachine, this.id, beneficiary]
215-
216-
return {
217-
contract: this.redeemerContract(),
218-
method,
219-
args
220-
}
221-
}
222-
223-
const observable = from(createTransaction()).pipe(
224-
concatMap((transaction) => {
225-
return this.context.sendTransaction(transaction, mapReceipt)
226-
})
227-
)
228-
229-
return toIOperationObservable(observable)
230-
}
231177
}

src/plugins/contributionRewardExt/proposal.ts

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
import BN from 'bn.js'
22
import gql from 'graphql-tag'
3-
import { from, Observable } from 'rxjs'
4-
import { concatMap } from 'rxjs/operators'
3+
import { Observable } from 'rxjs'
54
import {
65
Address,
76
Arc,
8-
CONTRIBUTION_REWARD_DUMMY_VERSION,
97
ContributionRewardExtPlugin,
108
IApolloQueryOptions,
119
IProposalState,
12-
ITransaction,
13-
ITransactionReceipt,
1410
Logger,
15-
NULL_ADDRESS,
16-
Operation,
1711
Plugin,
18-
Proposal,
19-
REDEEMER_CONTRACT_VERSIONS,
20-
toIOperationObservable
12+
Proposal
2113
} from '../../index'
2214

2315
export interface IContributionRewardExtProposalState extends IProposalState {
@@ -146,53 +138,4 @@ export class ContributionRewardExtProposal extends Proposal<IContributionRewardE
146138
) as Observable<IContributionRewardExtProposalState>
147139
return result
148140
}
149-
150-
public redeemerContract() {
151-
for (const version of REDEEMER_CONTRACT_VERSIONS) {
152-
try {
153-
const contractInfo = this.context.getContractInfoByName('Redeemer', version)
154-
return this.context.getContract(contractInfo.address)
155-
} catch (err) {
156-
if (!err.message.match(/no contract/i)) {
157-
// if the contract cannot be found, try the next one
158-
throw err
159-
}
160-
}
161-
}
162-
throw Error(
163-
`No Redeemer contract could be found (search for versions ${REDEEMER_CONTRACT_VERSIONS})`
164-
)
165-
}
166-
167-
public redeemRewards(beneficiary?: Address): Operation<boolean> {
168-
const mapReceipt = (receipt: ITransactionReceipt) => true
169-
170-
const createTransaction = async (): Promise<ITransaction> => {
171-
if (!beneficiary) {
172-
beneficiary = NULL_ADDRESS
173-
}
174-
175-
const state = await this.fetchState()
176-
const pluginAddress = this.context.getContractInfoByName(
177-
'ContributionReward',
178-
CONTRIBUTION_REWARD_DUMMY_VERSION
179-
).address
180-
const method = 'redeemFromCRExt'
181-
const args = [pluginAddress, state.votingMachine, this.id, beneficiary]
182-
183-
return {
184-
contract: this.redeemerContract(),
185-
method,
186-
args
187-
}
188-
}
189-
190-
const observable = from(createTransaction()).pipe(
191-
concatMap((transaction) => {
192-
return this.context.sendTransaction(transaction, mapReceipt)
193-
})
194-
)
195-
196-
return toIOperationObservable(observable)
197-
}
198141
}

src/plugins/genericPlugin/proposal.ts

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
import BN from 'bn.js'
22
import gql from 'graphql-tag'
3-
import { from, Observable } from 'rxjs'
4-
import { concatMap } from 'rxjs/operators'
3+
import { Observable } from 'rxjs'
54
import {
65
Address,
76
Arc,
8-
CONTRIBUTION_REWARD_DUMMY_VERSION,
97
GenericPlugin,
108
IApolloQueryOptions,
119
IProposalState,
12-
ITransaction,
13-
ITransactionReceipt,
1410
Logger,
15-
NULL_ADDRESS,
16-
Operation,
1711
Plugin,
18-
Proposal,
19-
REDEEMER_CONTRACT_VERSIONS,
20-
toIOperationObservable
12+
Proposal
2113
} from '../../index'
2214

2315
export interface IGenericPluginProposalState extends IProposalState {
@@ -113,53 +105,4 @@ export class GenericPluginProposal extends Proposal<IGenericPluginProposalState>
113105
) as Observable<IGenericPluginProposalState>
114106
return result
115107
}
116-
117-
public redeemerContract() {
118-
for (const version of REDEEMER_CONTRACT_VERSIONS) {
119-
try {
120-
const contractInfo = this.context.getContractInfoByName('Redeemer', version)
121-
return this.context.getContract(contractInfo.address)
122-
} catch (err) {
123-
if (!err.message.match(/no contract/i)) {
124-
// if the contract cannot be found, try the next one
125-
throw err
126-
}
127-
}
128-
}
129-
throw Error(
130-
`No Redeemer contract could be found (search for versions ${REDEEMER_CONTRACT_VERSIONS})`
131-
)
132-
}
133-
134-
public redeemRewards(beneficiary?: Address): Operation<boolean> {
135-
const mapReceipt = (receipt: ITransactionReceipt) => true
136-
137-
const createTransaction = async (): Promise<ITransaction> => {
138-
if (!beneficiary) {
139-
beneficiary = NULL_ADDRESS
140-
}
141-
142-
const state = await this.fetchState()
143-
const pluginAddress = this.context.getContractInfoByName(
144-
'ContributionReward',
145-
CONTRIBUTION_REWARD_DUMMY_VERSION
146-
).address
147-
const method = 'redeem'
148-
const args = [pluginAddress, state.votingMachine, this.id, beneficiary]
149-
150-
return {
151-
contract: this.redeemerContract(),
152-
method,
153-
args
154-
}
155-
}
156-
157-
const observable = from(createTransaction()).pipe(
158-
concatMap((transaction) => {
159-
return this.context.sendTransaction(transaction, mapReceipt)
160-
})
161-
)
162-
163-
return toIOperationObservable(observable)
164-
}
165108
}

0 commit comments

Comments
 (0)