Skip to content

Commit

Permalink
use subgraph v36-4 (#346)
Browse files Browse the repository at this point in the history
* use subgraph v36-4
* bump package version to 0.2.35
  • Loading branch information
jellegerbrandy authored Dec 17, 2019
1 parent 875cde3 commit 8c86700
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 40 deletions.
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
version: "3"
services:
graph-node:
image: 'graphprotocol/graph-node@sha256:8af6adc44d6c55eaed7f6d3ac2b96af0823044e94ffee380288f07e96d5ff30b'
image: 'graphprotocol/graph-node:v0.16.1'
ports:
- 8000:8000
- 8001:8001
Expand All @@ -21,21 +21,23 @@ services:
ipfs: ipfs:5001
ethereum: private:http://ganache:8545
GRAPH_LOG: "graph.log"
GRAPH_GRAPHQL_MAX_FIRST: 1000
GRAPH_IPFS_TIMEOUT: '2'
GRAPH_MAX_IPFS_FILE_BYTES: '990000'
GRAPH_GRAPHQL_MAX_FIRST: '1000'

ipfs:
image: daostack/subgraph-ipfs:0.0.1-rc.33-v1-3.0.17
image: daostack/subgraph-ipfs:0.0.1-rc.36-v1-3.0.19
ports:
- 5001:5001

postgres:
image: daostack/subgraph-postgres:0.0.1-rc.33-v1-3.0.17
image: daostack/subgraph-postgres:0.0.1-rc.36-v1-3.0.19
ports:
- 9432:5432
environment:
POSTGRES_PASSWORD: 'letmein'

ganache:
image: daostack/test-env:0.0.1-rc.33-v1-3.0.17
image: daostack/test-env:0.0.1-rc.36-v1-3.0.19
ports:
- 8545:8545
38 changes: 23 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/client",
"version": "0.2.34",
"version": "0.2.35",
"description": "",
"keywords": [],
"main": "dist/lib/index.js",
Expand Down Expand Up @@ -65,7 +65,7 @@
]
},
"devDependencies": {
"@daostack/migration": "0.0.1-rc.33-v1",
"@daostack/migration": "0.0.1-rc.36-v1",
"@types/graphql": "^14.2.2",
"@types/isomorphic-fetch": "^0.0.34",
"@types/jest": "^24.0.15",
Expand Down
2 changes: 2 additions & 0 deletions src/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ISchemeState } from './scheme'
import * as ContributionReward from './schemes/contributionReward'
import * as GenericScheme from './schemes/genericScheme'
import * as SchemeRegistrar from './schemes/schemeRegistrar'
// import * as Competition from './schemes/competition'
import { LATEST_ARC_VERSION, REDEEMER_CONTRACT_VERSION } from './settings'
import { IStakeQueryOptions, Stake } from './stake'
import { Address, Date, ICommonQueryOptions, IStateful } from './types'
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface IProposalState extends IProposalStaticState {
accountsWithUnclaimedRewards: Address[],
boostedAt: Date
contributionReward: ContributionReward.IContributionReward|null
// competition: Competition.ICompetitionProposal|null
confidenceThreshold: number
closingAt: Date
createdAt: Date
Expand Down
6 changes: 4 additions & 2 deletions src/scheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ export class Scheme implements IStateful<ISchemeState> {
voteParams: mapGenesisProtocolParams(item.genericSchemeParams.voteParams),
votingMachine: item.genericSchemeParams.votingMachine
}

const schemeParams = (
uGenericSchemeParams || contributionRewardParams || schemeRegistrarParams || genericSchemeParams
)
return {
address: item.address,
canDelegateCall: item.canDelegateCall,
Expand All @@ -365,7 +367,7 @@ export class Scheme implements IStateful<ISchemeState> {
numberOfPreBoostedProposals: Number(item.numberOfPreBoostedProposals),
numberOfQueuedProposals: Number(item.numberOfQueuedProposals),
paramsHash: item.paramsHash,
schemeParams: uGenericSchemeParams || contributionRewardParams || schemeRegistrarParams || genericSchemeParams,
schemeParams,
schemeRegistrarParams,
uGenericSchemeParams,
version: item.version
Expand Down
13 changes: 12 additions & 1 deletion test/proposal-claim-reward.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { first } from 'rxjs/operators'
import { Arc } from '../src/arc'
import { DAO } from '../src/dao'
import { IProposalOutcome, IProposalStage, IProposalState, Proposal } from '../src/proposal'

import BN = require('bn.js')
import { createAProposal, firstResult, getTestAddresses, getTestDAO, ITestAddresses, LATEST_ARC_VERSION, newArc,
toWei, voteToPassProposal, waitUntilTrue } from './utils'
Expand Down Expand Up @@ -136,6 +138,15 @@ describe('Claim rewards', () => {
})

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

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 ugenericScheme = ugenericSchemes[0]
const ugenericSchemeState = await ugenericScheme.state().pipe(first()).toPromise()
dao = new DAO(ugenericSchemeState.dao, arc)

const beneficiary = arc.web3.eth.defaultAccount
const stakeAmount = new BN(123456789)
await arc.GENToken().transfer(dao.id, stakeAmount).send()
Expand All @@ -145,7 +156,7 @@ describe('Claim rewards', () => {

const proposal = await createAProposal(dao, {
callData,
scheme: testAddresses.base.UGenericScheme,
scheme: ugenericSchemeState.address,
schemeToRegister: actionMock.options.address,
value: 0
})
Expand Down
15 changes: 11 additions & 4 deletions test/proposal-ugenericscheme.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { first } from 'rxjs/operators'
import { DAO } from '../src//dao'
import { Arc } from '../src/arc'
import {
Expand Down Expand Up @@ -29,19 +30,25 @@ describe('Proposal', () => {
})).rejects.toThrow(/missing argument "callData"/i)
})

it('proposal flow works for LATEST_ARC_VERSION', async () => {
it('proposal flow works for rc.32', async () => {
const version = '0.0.1-rc.32'
testAddresses = getTestAddresses(arc)
dao = await getTestDAO()
// dao = await getTestDAO()
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)
const states: IProposalState[] = []
const lastState = (): IProposalState => states[states.length - 1]

const actionMockABI = arc.getABI(undefined, 'ActionMock', LATEST_ARC_VERSION)
const actionMockABI = arc.getABI(undefined, 'ActionMock', version)
const actionMock = new arc.web3.eth.Contract(actionMockABI, testAddresses.test.ActionMock)
const callData = await actionMock.methods.test2(dao.id).encodeABI()

const proposal = await createAProposal(dao, {
callData,
scheme: testAddresses.base.UGenericScheme,
// scheme: testAddresses.base.UGenericScheme,
scheme: ugenericSchemeState.address,
schemeToRegister: actionMock.options.address,
value: 0
})
Expand Down
4 changes: 2 additions & 2 deletions test/proposal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('Proposal', () => {

expect(pState).toMatchObject({
boostedAt: 0,
description: null,
description: '',
descriptionHash: '0x000000000000000000000000000000000000000000000000000000000000efgh',
// downStakeNeededToQueue: new BN(0),
executedAt: 0,
Expand All @@ -218,7 +218,7 @@ describe('Proposal', () => {
resolvedAt: 0,
// stage: IProposalStage.Queued,
title: '',
url: null,
url: '',
winningOutcome: IProposalOutcome.Fail
})
expect(pState.contributionReward).toMatchObject({
Expand Down
13 changes: 6 additions & 7 deletions test/scheme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ describe('Scheme', () => {
schemeStates.push(state)
}))
expect((schemeStates.map((r) => r.name)).sort()).toEqual([
'UGenericScheme',
'ContributionReward',
'SchemeRegistrar'
'ControllerCreator',
'SchemeRegistrar',
'UGenericScheme'

].sort())
result = await Scheme.search(arc, {where: {dao: dao.id, name: 'ContributionReward'}})
.pipe(first()).toPromise()
Expand Down Expand Up @@ -106,15 +108,12 @@ describe('Scheme', () => {
})

it('Scheme.state() is working for UGenericScheme schemes', async () => {
const dao = await getTestDAO()
const result = await Scheme
.search(arc, {where: {dao: dao.id, name: 'UGenericScheme'}})
.search(arc, {where: {name: 'UGenericScheme'}})
.pipe(first()).toPromise()

const scheme = result[0]
const state = await scheme.state().pipe(first()).toPromise()
expect(state).toMatchObject({
address: testAddresses.base.UGenericScheme.toLowerCase(),
id: scheme.id,
name: 'UGenericScheme'
})
Expand All @@ -135,7 +134,7 @@ describe('Scheme', () => {
})

// the subgraph is a bit weird here, popoulating uGenericSchemeParams instead of the expected schemeParams
expect(state.uGenericSchemeParams).toEqual(state.schemeParams)
expect(state.genericSchemeParams).toEqual(state.schemeParams)
})

it('state() should be equal to proposal.state().scheme', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const graphqlWsProvider: string = 'http://127.0.0.1:8001/subgraphs/name/d
export const web3Provider: string = 'ws://127.0.0.1:8545'
export const ipfsProvider: string = '/ip4/127.0.0.1/tcp/5001'

export const LATEST_ARC_VERSION = '0.0.1-rc.33'
export const LATEST_ARC_VERSION = '0.0.1-rc.32'

export { BN }

Expand Down Expand Up @@ -64,7 +64,7 @@ export function getTestAddresses(arc: Arc, version: string = LATEST_ARC_VERSION)
const migration = require(migrationFile).private
let UGenericScheme: string = ''
try {
UGenericScheme = arc.getContractInfoByName('UGenericScheme', version).address
UGenericScheme = arc.getContractInfoByName('GenericScheme', version).address
} catch (err) {
if (err.message.match(/no contract/i)) {
// pass
Expand Down

0 comments on commit 8c86700

Please sign in to comment.