Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add RegistryInfo to store
  • Loading branch information
samajammin committed May 19, 2021
commit b85648e517dc820ae89791bcb7af33873c942d35
1 change: 1 addition & 0 deletions vue-app/src/store/action-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const SELECT_ROUND = 'SELECT_ROUND'
export const LOAD_ROUND_INFO = 'LOAD_ROUND_INFO'
export const LOAD_RECIPIENT_REGISTRY_INFO = 'LOAD_RECIPIENT_REGISTRY_INFO'
export const LOAD_USER_INFO = 'LOAD_USER_INFO'
export const SAVE_CART = 'SAVE_CART'
export const LOAD_CART = 'LOAD_CART'
Expand Down
19 changes: 19 additions & 0 deletions vue-app/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ import {
getContributionAmount,
isContributionWithdrawn,
} from '@/api/contributions'
import { recipientRegistryType } from '@/api/core'
import { loginUser, logoutUser } from '@/api/gun'
import { getRegistryInfo, RegistryInfo } from '@/api/recipient-registry-optimistic'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other types of registries (such as Kleros adapter) can have registry info too, but of different type.
There should be a wrapper function in api/projects.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked out api/projects.ts but I'm only seeing wrapper functions around getting/registering projects. I'm not seeing anything around registry info in api/recipient-registry-kleros but please let me know if I'm missing something you'd like me to add here (or if there's a wrapper function you'd like me to create).

import { RoundInfo, RoundStatus, getRoundInfo } from '@/api/round'
import { storage } from '@/api/storage'
import { Tally, getTally } from '@/api/tally'
import { User, isVerifiedUser, getTokenBalance } from '@/api/user'
import {
SELECT_ROUND,
LOAD_ROUND_INFO,
LOAD_RECIPIENT_REGISTRY_INFO,
LOAD_USER_INFO,
SAVE_CART,
LOAD_CART,
Expand All @@ -35,6 +38,7 @@ import {
} from './action-types'
import {
SET_RECIPIENT_REGISTRY_ADDRESS,
SET_RECIPIENT_REGISTRY_INFO,
SET_CURRENT_USER,
SET_CURRENT_ROUND_ADDRESS,
SET_CURRENT_ROUND,
Expand All @@ -51,6 +55,7 @@ Vue.use(Vuex)

interface RootState {
recipientRegistryAddress: string | null;
recipientRegistryInfo: RegistryInfo | null;
currentUser: User | null;
currentRoundAddress: string | null;
currentRound: RoundInfo | null;
Expand All @@ -62,6 +67,7 @@ interface RootState {

const state: RootState = {
recipientRegistryAddress: null,
recipientRegistryInfo: null,
currentUser: null,
currentRoundAddress: null,
currentRound: null,
Expand All @@ -75,6 +81,9 @@ export const mutations = {
[SET_RECIPIENT_REGISTRY_ADDRESS](state, address: string) {
state.recipientRegistryAddress = address
},
[SET_RECIPIENT_REGISTRY_INFO](state, info: RegistryInfo) {
state.recipientRegistryInfo = info
},
[SET_CURRENT_USER](state, user: User | null) {
state.currentUser = user
},
Expand Down Expand Up @@ -155,6 +164,7 @@ const actions = {
commit(SET_CONTRIBUTOR, null)
commit(CLEAR_CART)
commit(SET_RECIPIENT_REGISTRY_ADDRESS, null)
commit(SET_RECIPIENT_REGISTRY_INFO, null)
commit(SET_CURRENT_ROUND, null)
}
commit(SET_CURRENT_ROUND_ADDRESS, roundAddress)
Expand All @@ -172,6 +182,15 @@ const actions = {
commit(SET_TALLY, tally)
}
},
async [LOAD_RECIPIENT_REGISTRY_INFO]({ commit, state }) {
const recipientRegistryAddress = state.recipientRegistryAddress
if (recipientRegistryAddress === null || recipientRegistryType !== 'optimistic') {
commit(SET_RECIPIENT_REGISTRY_INFO, null)
return
}
const info = await getRegistryInfo(recipientRegistryAddress)
commit(SET_RECIPIENT_REGISTRY_INFO, info)
},
async [LOAD_USER_INFO]({ commit, state }) {
if (state.currentRound && state.currentUser) {
let isVerified = state.currentUser.isVerified
Expand Down
1 change: 1 addition & 0 deletions vue-app/src/store/mutation-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const SET_RECIPIENT_REGISTRY_ADDRESS = 'SET_RECIPIENT_REGISTRY_ADDRESS'
export const SET_RECIPIENT_REGISTRY_INFO = 'SET_RECIPIENT_REGISTRY_INFO'
export const SET_CURRENT_USER = 'SET_CURRENT_USER'
export const SET_CURRENT_ROUND_ADDRESS = 'SET_CURRENT_ROUND_ADDRESS'
export const SET_CURRENT_ROUND = 'SET_CURRENT_ROUND'
Expand Down