Skip to content

Commit

Permalink
Update subgraph format
Browse files Browse the repository at this point in the history
  • Loading branch information
samuveth committed Jan 19, 2024
1 parent fe40388 commit 4ee7ff1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/components/SpaceProposalBoost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const isActive = computed(() => props.proposal.state === 'active');
const isFinal = computed(() => props.proposal.scores_state === 'final');
function isEligible(boost: BoostSubgraphResult) {
const choice = boost.strategy.params.eligibility.choice;
const choice = boost.strategy.eligibility.choice;
if (!web3Account.value) return false;
if (props.proposal.privacy === 'shutter' && !isFinal.value) return false;
Expand Down Expand Up @@ -92,7 +92,7 @@ async function loadBoosts() {
const responses = await Promise.all(requests);
boosts.value = responses
.map(response => response.proposal?.boosts)
.map(response => response.boosts)
.filter(boost => boost)
.flat();
} catch (e) {
Expand Down
10 changes: 3 additions & 7 deletions src/components/SpaceProposalBoostItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ const claimedAmount = computed(() => {
>
<div class="pr-4">
<div class="text-skin-heading">
<template v-if="boost.strategy.params.eligibility?.choice !== null">
<template v-if="boost.strategy.eligibility.choice !== null">
Who votes
<TuneTag
:label="
proposal.choices[boost.strategy.params.eligibility.choice - 1]
"
:label="proposal.choices[boost.strategy.eligibility.choice - 1]"
class="text-skin-heading"
/>
</template>
Expand All @@ -80,9 +78,7 @@ const claimedAmount = computed(() => {
:label="`${boostBalanceFormatted} ${boost.token.symbol}`"
class="text-skin-heading"
/>
<template
v-if="boost.strategy.params.distribution?.type === 'weighted'"
>
<template v-if="boost.strategy.distribution.type === 'weighted'">
based on
<TuneTag label="Voting power" class="text-skin-heading" />
</template>
Expand Down
53 changes: 25 additions & 28 deletions src/helpers/boost/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,35 @@ export function getClaims(recipient: string, chainId: string) {

export function getBoosts(proposalId: string, chainId: string) {
return subgraphRequest(SUBGRAPH_URLS[chainId], {
proposal: {
boosts: {
__args: {
id: proposalId
where: { strategy_: { proposal: proposalId } }
},

boosts: {
id: true,
strategyURI: true,
poolSize: true,
guard: true,
start: true,
end: true,
owner: true,
chainId: true,
token: {
id: true,
name: true,
symbol: true,
decimals: true
},
strategy: {
id: true,
strategyURI: true,
poolSize: true,
guard: true,
start: true,
end: true,
owner: true,
chainId: true,
token: {
id: true,
name: true,
symbol: true,
decimals: true
name: true,
version: true,
proposal: true,
eligibility: {
type: true,
choice: true
},
strategy: {
name: true,
params: {
version: true,
proposal: true,
eligibility: {
choice: true
},
distribution: {
type: true
}
}
distribution: {
type: true
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/helpers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,14 @@ export type BoostSubgraphResult = {
};
strategy: {
name: string;
params: {
proposal: string;
eligibility: {
choice: number | null;
};
distribution: {
type: 'even' | 'weighted';
limit?: number;
};
proposal: string;
eligibility: {
type: 'incentive' | 'bribe';
choice: number | null;
};
distribution: {
type: 'even' | 'weighted';
limit?: number;
};
};
};

0 comments on commit 4ee7ff1

Please sign in to comment.