diff --git a/graphql.js b/graphql.js index 2999805..d28538b 100644 --- a/graphql.js +++ b/graphql.js @@ -5,6 +5,7 @@ const { ApolloServer, gql } = require('apollo-server-express'); const { proposalToType } = require('./helpers/utils'); const { getAddressDetails } = require('./dbWrapper/addresses'); +const { getDaoInfo } = require('./dbWrapper/dao'); const { pubsub } = require('./pubsub'); @@ -22,6 +23,9 @@ const queryType = gql` # Get the current user's information. fetchCurrentUser: User! + + # Get the current user's information. + fetchDao: Dao! } `; @@ -53,7 +57,7 @@ const filterByCurrentAddress = f => (payload, _variables, context, _operation) = const resolvers = { Query: { - fetchProposal: async (obj, args, _context, _info) => { + fetchProposal: async (_obj, args, _context, _info) => { const { proposalId } = args; let proposal = await getProposal(proposalId); @@ -66,6 +70,9 @@ const resolvers = { fetchCurrentUser: (_obj, _args, context, _info) => { return context.currentUser; }, + fetchDao: (_obj, _args, _context, _info) => { + return getDaoInfo(); + }, }, Mutation: {}, Subscription: { diff --git a/scripts/watchedFunctions.js b/scripts/watchedFunctions.js index 6dd2e67..af3c7a1 100644 --- a/scripts/watchedFunctions.js +++ b/scripts/watchedFunctions.js @@ -95,8 +95,14 @@ const watchedFunctionsMap = { ([daoInfo, user]) => [daoInfo, user], [broadcastUpdatedDao, broadcastUpdatedUser], )(refreshAddress), - redeemBadge: broadcastUpdatedUser(refreshAddress), - claimRewards: broadcastUpdatedUser(refreshAddress), + redeemBadge: multiBroadcast( + ([_daoInfo, user]) => [user], + [broadcastUpdatedUser], + )(refreshAddress), + claimRewards: multiBroadcast( + ([_daoInfo, user]) => [user], + [broadcastUpdatedUser], + )(refreshAddress), submitPreproposal: broadcastSubmittedProposal(refreshProposalNew), modifyProposal: broadcastUpdatedProposal(refreshProposalDetails), endorseProposal: broadcastUpdatedProposal(refreshProposalEndorseProposal), diff --git a/types/dao.js b/types/dao.js index dcc6c4b..21dd3bc 100644 --- a/types/dao.js +++ b/types/dao.js @@ -5,17 +5,20 @@ const { denominators } = require('../helpers/constants'); const typeDef = gql` type Dao { + # A flag indicating if the global rewards are available + isGlobalRewardsSet: Boolean + # Current quarter number in DigixDAO currentQuarter: BigNumber # Timestamp for start of the current quarter - startOfQuarter: BigNumber + startOfQuarter: Timestamp # Timestamp for start of main phase of current quarter - startOfMainphase: BigNumber + startOfMainphase: Timestamp # Timestamp for start of the next quarter - startOfNextQuarter: BigNumber + startOfNextQuarter: Timestamp # Total number of DGDs locked into DigixDAO by participants totalLockedDgds: BigNumber diff --git a/types/user.js b/types/user.js index 180a421..a72f239 100644 --- a/types/user.js +++ b/types/user.js @@ -35,7 +35,6 @@ const typeDef = gql` `; const dgd = value => (value === null || value === undefined ? null : ofOne(value, denominators.DGD)); - const dgx = value => (value === null || value === undefined ? null : ofOne(value, denominators.DGX)); const reputation = value => (value ? ofOne(value, denominators.REPUTATION_POINT) : null); @@ -44,6 +43,9 @@ const resolvers = { id(user) { return user.address; }, + claimableDgx(user) { + return dgx(user.claimableDgx); + }, lockedDgdStake(user) { return dgd(user.lockedDgdStake); },