Skip to content

Commit 820b7ca

Browse files
authored
add value to GenericScheme (#477)
* add `value` to GenericScheme * better test * fix tests * tests * remove BN * tests * another try * nuther try * yet another
1 parent 09294fc commit 820b7ca

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

src/proposal.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export class Proposal implements IStateful<IProposalState> {
173173
callData
174174
executed
175175
returnValue
176+
value
176177
}
177178
genesisProtocolParams {
178179
id
@@ -475,7 +476,8 @@ export class Proposal implements IStateful<IProposalState> {
475476
contractToCall: item.genericScheme.contractToCall,
476477
executed: item.genericScheme.executed,
477478
id: item.genericScheme.id,
478-
returnValue: item.genericScheme.returnValue
479+
returnValue: item.genericScheme.returnValue,
480+
value: new BN(item.genericScheme.value)
479481
}
480482
} else if (item.schemeRegistrar) {
481483
if (item.schemeRegistrar.schemeToRegister) {

src/schemes/genericScheme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import BN = require('bn.js')
12
import { Arc } from '../arc'
23
import { Proposal } from '../proposal'
34
import { Address } from '../types'
@@ -14,6 +15,7 @@ export interface IGenericScheme {
1415
callData: string
1516
executed: boolean
1617
returnValue: string
18+
value: BN
1719
}
1820

1921
export interface IProposalCreateOptionsGS {

test/proposal-genericscheme.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import {
55
IProposalState,
66
ISchemeStaticState,
77
Proposal
8-
} from '../src'
9-
import { createAProposal, getTestAddresses, ITestAddresses, LATEST_ARC_VERSION,
10-
newArc, voteToPassProposal, waitUntilTrue } from './utils'
8+
} from '../src'
9+
import {
10+
createAProposal, getTestAddresses, ITestAddresses, LATEST_ARC_VERSION,
11+
newArc, voteToPassProposal, waitUntilTrue, BN
12+
} from './utils'
1113

1214
jest.setTimeout(60000)
1315

@@ -24,7 +26,7 @@ describe('Proposal', () => {
2426
})
2527

2628
it('Check proposal state is correct', async () => {
27-
const daos = await arc.daos({where: { name: 'Nectar DAO'}}).pipe(first()).toPromise()
29+
const daos = await arc.daos({ where: { name: 'Nectar DAO' } }).pipe(first()).toPromise()
2830
const dao = daos[0]
2931
if (dao === undefined) {
3032
throw Error(`Could not find "Nectar DAO"`)
@@ -36,13 +38,13 @@ describe('Proposal', () => {
3638
const actionMock = new arc.web3.eth.Contract(actionMockABI, testAddresses.test.ActionMock)
3739
const callData = await actionMock.methods.test2(dao.id).encodeABI()
3840

39-
const schemes = await dao.schemes({ where: {name: 'GenericScheme' }}).pipe(first()).toPromise()
41+
const schemes = await dao.schemes({ where: { name: 'GenericScheme' } }).pipe(first()).toPromise()
4042
const genericScheme = schemes[0].staticState as ISchemeStaticState
4143
const proposal = await createAProposal(dao, {
4244
callData,
4345
scheme: genericScheme.address,
4446
schemeToRegister: actionMock.options.address,
45-
value: 0
47+
value: '1'
4648
})
4749
expect(proposal).toBeInstanceOf(Proposal)
4850

@@ -55,7 +57,8 @@ describe('Proposal', () => {
5557
expect(lastState().genericScheme).toMatchObject({
5658
callData,
5759
executed: false,
58-
returnValue: null
60+
returnValue: null,
61+
value: new BN('1')
5962
})
6063

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

test/proposal-ugenericscheme.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import {
55
IProposalStage,
66
IProposalState,
77
Proposal
8-
} from '../src/proposal'
9-
import { IGenericScheme} from '../src/schemes/genericScheme'
10-
import { createAProposal, getTestAddresses, getTestDAO, ITestAddresses, LATEST_ARC_VERSION,
11-
newArc, voteToPassProposal, waitUntilTrue } from './utils'
8+
} from '../src/proposal'
9+
import { IGenericScheme } from '../src/schemes/genericScheme'
10+
import {
11+
createAProposal, getTestAddresses, getTestDAO, ITestAddresses, LATEST_ARC_VERSION,
12+
newArc, voteToPassProposal, waitUntilTrue, BN
13+
} from './utils'
1214

1315
jest.setTimeout(60000)
1416

@@ -34,10 +36,10 @@ describe('Proposal', () => {
3436
const version = '0.0.1-rc.32'
3537
testAddresses = getTestAddresses(arc)
3638
// dao = await getTestDAO()
37-
const ugenericSchemes = await arc.schemes({where: {name: "UGenericScheme", version}}).pipe(first()).toPromise()
39+
const ugenericSchemes = await arc.schemes({ where: { name: "UGenericScheme", version } }).pipe(first()).toPromise()
3840
const ugenericScheme = ugenericSchemes[0]
3941
const ugenericSchemeState = await ugenericScheme.state().pipe(first()).toPromise()
40-
dao = new DAO(ugenericSchemeState.dao, arc)
42+
dao = new DAO(ugenericSchemeState.dao, arc)
4143
const states: IProposalState[] = []
4244
const lastState = (): IProposalState => states[states.length - 1]
4345

@@ -50,7 +52,7 @@ describe('Proposal', () => {
5052
// scheme: testAddresses.base.UGenericScheme,
5153
scheme: ugenericSchemeState.address,
5254
schemeToRegister: actionMock.options.address,
53-
value: 0
55+
value: '1'
5456
})
5557
expect(proposal).toBeInstanceOf(Proposal)
5658

@@ -63,7 +65,8 @@ describe('Proposal', () => {
6365
expect(lastState().genericScheme).toMatchObject({
6466
callData,
6567
executed: false,
66-
returnValue: null
68+
returnValue: null,
69+
value: new BN('1')
6770
})
6871

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

0 commit comments

Comments
 (0)