Skip to content

add value to GenericScheme #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export class Proposal implements IStateful<IProposalState> {
callData
executed
returnValue
value
}
genesisProtocolParams {
id
Expand Down Expand Up @@ -475,7 +476,8 @@ export class Proposal implements IStateful<IProposalState> {
contractToCall: item.genericScheme.contractToCall,
executed: item.genericScheme.executed,
id: item.genericScheme.id,
returnValue: item.genericScheme.returnValue
returnValue: item.genericScheme.returnValue,
value: new BN(item.genericScheme.value)
}
} else if (item.schemeRegistrar) {
if (item.schemeRegistrar.schemeToRegister) {
Expand Down
2 changes: 2 additions & 0 deletions src/schemes/genericScheme.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BN = require('bn.js')
import { Arc } from '../arc'
import { Proposal } from '../proposal'
import { Address } from '../types'
Expand All @@ -14,6 +15,7 @@ export interface IGenericScheme {
callData: string
executed: boolean
returnValue: string
value: BN
}

export interface IProposalCreateOptionsGS {
Expand Down
17 changes: 10 additions & 7 deletions test/proposal-genericscheme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
IProposalState,
ISchemeStaticState,
Proposal
} from '../src'
import { createAProposal, getTestAddresses, ITestAddresses, LATEST_ARC_VERSION,
newArc, voteToPassProposal, waitUntilTrue } from './utils'
} from '../src'
import {
createAProposal, getTestAddresses, ITestAddresses, LATEST_ARC_VERSION,
newArc, voteToPassProposal, waitUntilTrue, BN
} from './utils'

jest.setTimeout(60000)

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

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

const schemes = await dao.schemes({ where: {name: 'GenericScheme' }}).pipe(first()).toPromise()
const schemes = await dao.schemes({ where: { name: 'GenericScheme' } }).pipe(first()).toPromise()
const genericScheme = schemes[0].staticState as ISchemeStaticState
const proposal = await createAProposal(dao, {
callData,
scheme: genericScheme.address,
schemeToRegister: actionMock.options.address,
value: 0
value: '1'
})
expect(proposal).toBeInstanceOf(Proposal)

Expand All @@ -55,7 +57,8 @@ describe('Proposal', () => {
expect(lastState().genericScheme).toMatchObject({
callData,
executed: false,
returnValue: null
returnValue: null,
value: new BN('1')
})

// accept the proposal by voting the hell out of it
Expand Down
19 changes: 11 additions & 8 deletions test/proposal-ugenericscheme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {
IProposalStage,
IProposalState,
Proposal
} from '../src/proposal'
import { IGenericScheme} from '../src/schemes/genericScheme'
import { createAProposal, getTestAddresses, getTestDAO, ITestAddresses, LATEST_ARC_VERSION,
newArc, voteToPassProposal, waitUntilTrue } from './utils'
} from '../src/proposal'
import { IGenericScheme } from '../src/schemes/genericScheme'
import {
createAProposal, getTestAddresses, getTestDAO, ITestAddresses, LATEST_ARC_VERSION,
newArc, voteToPassProposal, waitUntilTrue, BN
} from './utils'

jest.setTimeout(60000)

Expand All @@ -34,10 +36,10 @@ describe('Proposal', () => {
const version = '0.0.1-rc.32'
testAddresses = getTestAddresses(arc)
// dao = await getTestDAO()
const ugenericSchemes = await arc.schemes({where: {name: "UGenericScheme", version}}).pipe(first()).toPromise()
const ugenericSchemes = await arc.schemes({ where: { name: "UGenericScheme", version } }).pipe(first()).toPromise()
const ugenericScheme = ugenericSchemes[0]
const ugenericSchemeState = await ugenericScheme.state().pipe(first()).toPromise()
dao = new DAO(ugenericSchemeState.dao, arc)
dao = new DAO(ugenericSchemeState.dao, arc)
const states: IProposalState[] = []
const lastState = (): IProposalState => states[states.length - 1]

Expand All @@ -50,7 +52,7 @@ describe('Proposal', () => {
// scheme: testAddresses.base.UGenericScheme,
scheme: ugenericSchemeState.address,
schemeToRegister: actionMock.options.address,
value: 0
value: '1'
})
expect(proposal).toBeInstanceOf(Proposal)

Expand All @@ -63,7 +65,8 @@ describe('Proposal', () => {
expect(lastState().genericScheme).toMatchObject({
callData,
executed: false,
returnValue: null
returnValue: null,
value: new BN('1')
})

// accept the proposal by voting the hell out of it
Expand Down