Skip to content

Commit 1dc14f0

Browse files
authored
merge PR 477 from 1.0 (#508)
* merge PR 477 from 1.0 * fix text failure * fix test * fix tests * unit test * bump version to .45
1 parent c6383d1 commit 1dc14f0

File tree

7 files changed

+43
-35
lines changed

7 files changed

+43
-35
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

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

src/plugins/fundingRequest/plugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ export class FundingRequest
118118
}
119119

120120
return {
121-
...baseState,
122-
pluginParams: fundingRequestParams
123-
}
121+
...baseState,
122+
pluginParams: fundingRequestParams
123+
}
124124
}
125125

126126
private static fragmentField: { name: string, fragment: DocumentNode } | undefined
@@ -138,7 +138,7 @@ export class FundingRequest
138138
method: 'propose',
139139
args: [
140140
options.beneficiary,
141-
options.amount.toNumber(),
141+
options.amount.toString(),
142142
options.descriptionHash || ''
143143
]
144144
}
@@ -157,7 +157,7 @@ export class FundingRequest
157157
if (err.message.match(/funding is not allowed yet/)) {
158158
const state = await this.fetchState()
159159
const dao = state.dao.entity
160-
const joinAndQuit = (await dao.plugin({where: {name: 'JoinAndQuit'}}))
160+
const joinAndQuit = (await dao.plugin({ where: { name: 'JoinAndQuit' } }))
161161
const joinAndQuitState = await joinAndQuit.fetchState() as IJoinAndQuitState
162162
const deadline = joinAndQuitState.pluginParams.fundingGoalDeadline
163163
const now = new Date()

src/plugins/genericPlugin/plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import BN from 'bn.js'
12
import gql from 'graphql-tag'
23
import {
34
Address,
@@ -27,7 +28,7 @@ export interface IGenericPluginState extends IPluginState {
2728

2829
export interface IProposalCreateOptionsGS extends IProposalBaseCreateOptions {
2930
callData?: string
30-
value?: number
31+
value?: BN
3132
}
3233

3334
export interface IInitParamsGS {
@@ -43,7 +44,7 @@ export class GenericPlugin extends ProposalPlugin<
4344
IGenericPluginState,
4445
IGenericPluginProposalState,
4546
IProposalCreateOptionsGS
46-
> {
47+
> {
4748
public static fragment = {
4849
name: 'GenericpluginParams',
4950
fragment: gql`
@@ -129,7 +130,7 @@ export class GenericPlugin extends ProposalPlugin<
129130
return {
130131
contract: this.context.getContract(options.plugin as string),
131132
method: 'proposeCall',
132-
args: [options.callData, options.value, options.descriptionHash]
133+
args: [options.callData, options.value.toString(), options.descriptionHash]
133134
}
134135
}
135136

src/plugins/genericPlugin/proposal.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import BN from 'bn.js'
12
import gql from 'graphql-tag'
23
import { from, Observable } from 'rxjs'
34
import { concatMap } from 'rxjs/operators'
@@ -25,6 +26,7 @@ export interface IGenericPluginProposalState extends IProposalState {
2526
callData: string
2627
executed: boolean
2728
returnValue: string
29+
value: BN
2830
}
2931

3032
export class GenericPluginProposal extends Proposal<IGenericPluginProposalState> {
@@ -38,6 +40,7 @@ export class GenericPluginProposal extends Proposal<IGenericPluginProposalState>
3840
callData
3941
executed
4042
returnValue
43+
value
4144
}
4245
}
4346
`
@@ -79,7 +82,8 @@ export class GenericPluginProposal extends Proposal<IGenericPluginProposalState>
7982
callData: item.genericScheme.callData,
8083
contractToCall: item.genericScheme.contractToCall,
8184
executed: item.genericScheme.executed,
82-
returnValue: item.genericScheme.returnValue
85+
returnValue: item.genericScheme.returnValue,
86+
value: new BN(item.genericScheme.value)
8387
}
8488
}
8589

test/proposal-claim-reward.spec.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { first } from 'rxjs/operators'
22
import { Arc, DAO, IProposalOutcome, IProposalStage, IProposalState, IProposalCreateOptionsCR, LATEST_ARC_VERSION, GenericPlugin, GenericPluginProposal, IGenericPluginProposalState } from '../src'
33

44
import BN from 'bn.js'
5-
import { createAProposal, firstResult, getTestAddresses, getTestDAO, ITestAddresses, newArc,
6-
toWei, voteToPassProposal, waitUntilTrue, createCRProposal, getTestScheme } from './utils'
5+
import {
6+
createAProposal, firstResult, getTestAddresses, getTestDAO, ITestAddresses, newArc,
7+
toWei, voteToPassProposal, waitUntilTrue, createCRProposal, getTestScheme
8+
} from './utils'
79
import { BigNumber } from 'ethers/utils'
810
import { ethers } from 'ethers'
911
import { ContributionRewardProposal } from '../src'
@@ -29,7 +31,7 @@ describe('Claim rewards', () => {
2931
const states: IProposalState[] = []
3032
const lastState = () => states[states.length - 1]
3133

32-
if(!arc.web3) throw new Error("Web3 provider not set")
34+
if (!arc.web3) throw new Error("Web3 provider not set")
3335

3436
// make sure that the DAO has enough Ether to pay for the reward
3537
await arc.web3.getSigner().sendTransaction({
@@ -98,7 +100,7 @@ describe('Claim rewards', () => {
98100

99101
const gen = arc.GENToken()
100102
await gen.transfer(dao.id, externalTokenReward).send()
101-
const daoBalance = await firstResult(arc.GENToken().balanceOf(dao.id))
103+
const daoBalance = await firstResult(arc.GENToken().balanceOf(dao.id))
102104
expect(Number(daoBalance.toString())).toBeGreaterThanOrEqual(Number(externalTokenReward.toString()))
103105
const options: IProposalCreateOptionsCR = {
104106
beneficiary,
@@ -141,36 +143,36 @@ describe('Claim rewards', () => {
141143
})
142144

143145
it('redeemRewards should also work for expired proposals', async () => {
144-
const proposal = new ContributionRewardProposal(arc, testAddresses.queuedProposalId)
145-
await proposal.redeemRewards().send()
146+
const proposal = new ContributionRewardProposal(arc, testAddresses.queuedProposalId)
147+
await proposal.redeemRewards().send()
146148
})
147149

148150
it('works with non-CR proposal', async () => {
149151

150152
testAddresses = getTestAddresses()
151-
const genericSchemes = await arc.plugins({where: {name: 'GenericScheme' }}).pipe(first()).toPromise()
153+
const genericSchemes = await arc.plugins({ where: { name: 'GenericScheme' } }).pipe(first()).toPromise()
152154
const genericScheme = genericSchemes[0] as GenericPlugin
153155
const genericSchemeState = await genericScheme.state({}).pipe(first()).toPromise()
154156

155-
dao = new DAO(arc, genericSchemeState.dao.id)
157+
dao = new DAO(arc, genericSchemeState.dao.id)
156158

157159
const beneficiary = await arc.getAccount().pipe(first()).toPromise()
158160
const stakeAmount = new BN(123456789)
159161
await arc.GENToken().transfer(dao.id, stakeAmount).send()
160-
const actionMockABI = arc.getABI({abiName: 'ActionMock', version: LATEST_ARC_VERSION})
162+
const actionMockABI = arc.getABI({ abiName: 'ActionMock', version: LATEST_ARC_VERSION })
161163

162-
if(!arc.web3) throw new Error("Web3 provider not set")
164+
if (!arc.web3) throw new Error("Web3 provider not set")
163165

164166
const callData = new ethers.utils.Interface(actionMockABI).functions.test2.encode([dao.id])
165167

166168
const tx = await genericScheme.createProposal({
167169
callData,
168170
dao: dao.id,
169171
plugin: genericSchemeState.address,
170-
value: 0
172+
value: new BN("0")
171173
}).send()
172174

173-
if(!tx.result) throw new Error('Response yielded no result')
175+
if (!tx.result) throw new Error('Response yielded no result')
174176

175177
const proposal = new GenericPluginProposal(arc, tx.result.id)
176178
const proposalStates: IGenericPluginProposalState[] = []
@@ -203,11 +205,11 @@ describe('Claim rewards', () => {
203205
return lastState() && lastState().stage === IProposalStage.Executed
204206
})
205207

206-
if(!beneficiary) throw new Error("Beneficiary not set")
208+
if (!beneficiary) throw new Error("Beneficiary not set")
207209

208-
const prevBalance = await firstResult(arc.GENToken().balanceOf(beneficiary))
210+
const prevBalance = await firstResult(arc.GENToken().balanceOf(beneficiary))
209211
await proposal.redeemRewards(beneficiary).send()
210-
const newBalance = await firstResult(arc.GENToken().balanceOf(beneficiary))
212+
const newBalance = await firstResult(arc.GENToken().balanceOf(beneficiary))
211213
expect(newBalance.sub(prevBalance).toString()).toEqual(stakeAmount.toString())
212214

213215
})

test/proposal-genericscheme.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
GenericPlugin,
88
GenericPluginProposal,
99
LATEST_ARC_VERSION
10-
} from '../src'
11-
import { newArc, voteToPassProposal, waitUntilTrue, getTestScheme } from './utils'
10+
} from '../src'
11+
import { newArc, voteToPassProposal, waitUntilTrue, getTestScheme, BN } from './utils'
1212
import { ethers } from 'ethers'
1313

1414
jest.setTimeout(60000)
@@ -24,31 +24,31 @@ describe('Proposal', () => {
2424
})
2525

2626
it('Check proposal state is correct', async () => {
27-
const daos = await arc.daos({where: { name: 'Nectar DAO'}}).pipe(first()).toPromise()
27+
const daos = await arc.daos({ where: { name: 'Nectar DAO' } }).pipe(first()).toPromise()
2828
const dao = daos[0]
2929
if (dao === undefined) {
3030
throw Error(`Could not find "Nectar DAO"`)
3131
}
3232
const states: IProposalState[] = []
3333
const lastState = (): IProposalState => states[states.length - 1]
3434

35-
const actionMockABI = arc.getABI({abiName: 'ActionMock', version: LATEST_ARC_VERSION})
35+
const actionMockABI = arc.getABI({ abiName: 'ActionMock', version: LATEST_ARC_VERSION })
3636

37-
if(!arc.web3) throw new Error('Web3 provider not set')
37+
if (!arc.web3) throw new Error('Web3 provider not set')
3838

3939
const callData = new ethers.utils.Interface(actionMockABI).functions.test2.encode([dao.id])
4040

41-
const plugins = await dao.plugins({ where: {name: 'GenericScheme' }}).pipe(first()).toPromise() as GenericPlugin[]
41+
const plugins = await dao.plugins({ where: { name: 'GenericScheme' } }).pipe(first()).toPromise() as GenericPlugin[]
4242
const genericScheme = plugins[0]
4343

4444
const tx = await genericScheme.createProposal({
4545
dao: dao.id,
4646
callData,
47-
value: 0,
47+
value: new BN('1'),
4848
plugin: getTestScheme('GenericScheme')
4949
}).send()
5050

51-
if(!tx.result) throw new Error('Create proposal yielded no result')
51+
if (!tx.result) throw new Error('Create proposal yielded no result')
5252

5353
const proposal = new GenericPluginProposal(arc, tx.result.id)
5454

@@ -64,7 +64,8 @@ describe('Proposal', () => {
6464
expect(lastState()).toMatchObject({
6565
callData,
6666
executed: false,
67-
returnValue: null
67+
returnValue: null,
68+
value: new BN('1')
6869
})
6970

7071
// accept the proposal by voting the hell out of it

0 commit comments

Comments
 (0)