Skip to content

Commit

Permalink
upgrade subgraph endpoint + create query getProposalSupporters + fe…
Browse files Browse the repository at this point in the history
…tch query in `proposalId` page
  • Loading branch information
Mati0x committed Dec 6, 2024
1 parent e4305a1 commit fe1e369
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { useAccount, useToken } from "wagmi";
import {
getProposalDataDocument,
getProposalDataQuery,
getProposalSupportersQuery,
getProposalSupportersDocument,
isMemberDocument,
isMemberQuery,
} from "#/subgraph/.graphclient";
Expand Down Expand Up @@ -74,6 +76,16 @@ export default function Page({
},
});

//query to get proposal supporters
const { data: supportersData } = useSubgraphQuery<getProposalSupportersQuery>(
{
query: getProposalSupportersDocument,
variables: {
proposalId: proposalId.toLowerCase(),
},
},
);

//query to get member registry in community
const { data: memberData } = useSubgraphQuery<isMemberQuery>({
query: isMemberDocument,
Expand All @@ -89,6 +101,7 @@ export default function Page({
//

const proposalData = data?.cvproposal;
const proposalSupporters = supportersData?.members;
const proposalIdNumber =
proposalData?.proposalNumber ?
BigInt(proposalData.proposalNumber)
Expand All @@ -107,6 +120,8 @@ export default function Page({
const isProposerConnected =
proposalData?.submitter === address?.toLowerCase();

console.log(proposalSupporters);

const proposalType = proposalData?.strategy.config?.proposalType;
const isSignalingType = PoolTypes[proposalType] === "signaling";
const requestedAmount = proposalData?.requestedAmount;
Expand Down Expand Up @@ -204,6 +219,7 @@ export default function Page({

if (
!proposalData ||
!supportersData ||
!metadata ||
proposalIdNumber == null ||
updatedConviction == null
Expand Down Expand Up @@ -345,7 +361,7 @@ export default function Page({
}
disabled={currentConvictionPct < thresholdPct || !isConnected}
tooltip={
tooltipMessage ?? currentConvictionPct < thresholdPct ?
(tooltipMessage ?? currentConvictionPct < thresholdPct) ?
"Proposal not executable"
: undefined
}
Expand Down
35 changes: 28 additions & 7 deletions pkg/subgraph/.graphclient/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export type ArbitrableConfig_filter = {
and?: InputMaybe<Array<InputMaybe<ArbitrableConfig_filter>>>;
or?: InputMaybe<Array<InputMaybe<ArbitrableConfig_filter>>>;
};
export type ArbitrableConfig_orderBy = 'id' | 'version' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'arbitrator' | 'tribunalSafe' | 'challengerCollateralAmount' | 'submitterCollateralAmount' | 'defaultRuling' | 'defaultRulingTimeout' | 'allowlist';
export type ArbitrableConfig_orderBy = 'id' | 'version' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'strategy__archived' | 'arbitrator' | 'tribunalSafe' | 'challengerCollateralAmount' | 'submitterCollateralAmount' | 'defaultRuling' | 'defaultRulingTimeout' | 'allowlist';
export type BlockChangedFilter = {
number_gte: Scalars['Int']['input'];
};
Expand Down Expand Up @@ -529,7 +529,7 @@ export type CVProposal_filter = {
and?: InputMaybe<Array<InputMaybe<CVProposal_filter>>>;
or?: InputMaybe<Array<InputMaybe<CVProposal_filter>>>;
};
export type CVProposal_orderBy = 'id' | 'proposalNumber' | 'metadata' | 'metadata__id' | 'metadata__title' | 'metadata__description' | 'metadataHash' | 'version' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'beneficiary' | 'requestedAmount' | 'requestedToken' | 'proposalStatus' | 'blockLast' | 'convictionLast' | 'threshold' | 'maxCVStaked' | 'stakedAmount' | 'submitter' | 'createdAt' | 'updatedAt' | 'arbitrableConfig' | 'arbitrableConfig__id' | 'arbitrableConfig__version' | 'arbitrableConfig__arbitrator' | 'arbitrableConfig__tribunalSafe' | 'arbitrableConfig__challengerCollateralAmount' | 'arbitrableConfig__submitterCollateralAmount' | 'arbitrableConfig__defaultRuling' | 'arbitrableConfig__defaultRulingTimeout';
export type CVProposal_orderBy = 'id' | 'proposalNumber' | 'metadata' | 'metadata__id' | 'metadata__title' | 'metadata__description' | 'metadataHash' | 'version' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'strategy__archived' | 'beneficiary' | 'requestedAmount' | 'requestedToken' | 'proposalStatus' | 'blockLast' | 'convictionLast' | 'threshold' | 'maxCVStaked' | 'stakedAmount' | 'submitter' | 'createdAt' | 'updatedAt' | 'arbitrableConfig' | 'arbitrableConfig__id' | 'arbitrableConfig__version' | 'arbitrableConfig__arbitrator' | 'arbitrableConfig__tribunalSafe' | 'arbitrableConfig__challengerCollateralAmount' | 'arbitrableConfig__submitterCollateralAmount' | 'arbitrableConfig__defaultRuling' | 'arbitrableConfig__defaultRulingTimeout';
export type CVStrategy = {
id: Scalars['ID']['output'];
poolId: Scalars['BigInt']['output'];
Expand All @@ -544,6 +544,7 @@ export type CVStrategy = {
isEnabled: Scalars['Boolean']['output'];
token: Scalars['String']['output'];
sybilScorer?: Maybe<PassportScorer>;
archived: Scalars['Boolean']['output'];
};
export type CVStrategyproposalsArgs = {
skip?: InputMaybe<Scalars['Int']['input']>;
Expand Down Expand Up @@ -657,7 +658,7 @@ export type CVStrategyConfig_filter = {
and?: InputMaybe<Array<InputMaybe<CVStrategyConfig_filter>>>;
or?: InputMaybe<Array<InputMaybe<CVStrategyConfig_filter>>>;
};
export type CVStrategyConfig_orderBy = 'id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'D' | 'decay' | 'maxRatio' | 'minThresholdPoints' | 'weight' | 'proposalType' | 'pointSystem' | 'maxAmount' | 'allowlist';
export type CVStrategyConfig_orderBy = 'id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'strategy__archived' | 'D' | 'decay' | 'maxRatio' | 'minThresholdPoints' | 'weight' | 'proposalType' | 'pointSystem' | 'maxAmount' | 'allowlist';
export type CVStrategy_filter = {
id?: InputMaybe<Scalars['ID']['input']>;
id_not?: InputMaybe<Scalars['ID']['input']>;
Expand Down Expand Up @@ -814,12 +815,16 @@ export type CVStrategy_filter = {
sybilScorer_not_ends_with?: InputMaybe<Scalars['String']['input']>;
sybilScorer_not_ends_with_nocase?: InputMaybe<Scalars['String']['input']>;
sybilScorer_?: InputMaybe<PassportScorer_filter>;
archived?: InputMaybe<Scalars['Boolean']['input']>;
archived_not?: InputMaybe<Scalars['Boolean']['input']>;
archived_in?: InputMaybe<Array<Scalars['Boolean']['input']>>;
archived_not_in?: InputMaybe<Array<Scalars['Boolean']['input']>>;
/** Filter for the block changed event. */
_change_block?: InputMaybe<BlockChangedFilter>;
and?: InputMaybe<Array<InputMaybe<CVStrategy_filter>>>;
or?: InputMaybe<Array<InputMaybe<CVStrategy_filter>>>;
};
export type CVStrategy_orderBy = 'id' | 'poolId' | 'poolAmount' | 'metadata' | 'registryCommunity' | 'registryCommunity__id' | 'registryCommunity__chainId' | 'registryCommunity__strategyTemplate' | 'registryCommunity__profileId' | 'registryCommunity__communityFee' | 'registryCommunity__protocolFee' | 'registryCommunity__protocolFeeReceiver' | 'registryCommunity__communityName' | 'registryCommunity__covenantIpfsHash' | 'registryCommunity__councilSafe' | 'registryCommunity__pendingNewCouncilSafe' | 'registryCommunity__isKickEnabled' | 'registryCommunity__registerStakeAmount' | 'registryCommunity__registerToken' | 'registryCommunity__alloAddress' | 'registryCommunity__isValid' | 'config' | 'config__id' | 'config__D' | 'config__decay' | 'config__maxRatio' | 'config__minThresholdPoints' | 'config__weight' | 'config__proposalType' | 'config__pointSystem' | 'config__maxAmount' | 'proposals' | 'memberActive' | 'maxCVSupply' | 'totalEffectiveActivePoints' | 'isEnabled' | 'token' | 'sybilScorer' | 'sybilScorer__id';
export type CVStrategy_orderBy = 'id' | 'poolId' | 'poolAmount' | 'metadata' | 'registryCommunity' | 'registryCommunity__id' | 'registryCommunity__chainId' | 'registryCommunity__strategyTemplate' | 'registryCommunity__profileId' | 'registryCommunity__communityFee' | 'registryCommunity__protocolFee' | 'registryCommunity__protocolFeeReceiver' | 'registryCommunity__communityName' | 'registryCommunity__covenantIpfsHash' | 'registryCommunity__councilSafe' | 'registryCommunity__pendingNewCouncilSafe' | 'registryCommunity__isKickEnabled' | 'registryCommunity__registerStakeAmount' | 'registryCommunity__registerToken' | 'registryCommunity__alloAddress' | 'registryCommunity__isValid' | 'config' | 'config__id' | 'config__D' | 'config__decay' | 'config__maxRatio' | 'config__minThresholdPoints' | 'config__weight' | 'config__proposalType' | 'config__pointSystem' | 'config__maxAmount' | 'proposals' | 'memberActive' | 'maxCVSupply' | 'totalEffectiveActivePoints' | 'isEnabled' | 'token' | 'sybilScorer' | 'sybilScorer__id' | 'archived';
export type CollateralVault = {
id: Scalars['ID']['output'];
strategy: CVStrategy;
Expand Down Expand Up @@ -966,7 +971,7 @@ export type CollateralVault_filter = {
and?: InputMaybe<Array<InputMaybe<CollateralVault_filter>>>;
or?: InputMaybe<Array<InputMaybe<CollateralVault_filter>>>;
};
export type CollateralVault_orderBy = 'id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'collaterals';
export type CollateralVault_orderBy = 'id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'strategy__archived' | 'collaterals';
export type Member = {
id: Scalars['ID']['output'];
memberCommunity?: Maybe<Array<MemberCommunity>>;
Expand Down Expand Up @@ -1183,7 +1188,7 @@ export type MemberStrategy_filter = {
and?: InputMaybe<Array<InputMaybe<MemberStrategy_filter>>>;
or?: InputMaybe<Array<InputMaybe<MemberStrategy_filter>>>;
};
export type MemberStrategy_orderBy = 'id' | 'member' | 'member__id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'totalStakedPoints' | 'activatedPoints';
export type MemberStrategy_orderBy = 'id' | 'member' | 'member__id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'strategy__archived' | 'totalStakedPoints' | 'activatedPoints';
export type Member_filter = {
id?: InputMaybe<Scalars['ID']['input']>;
id_not?: InputMaybe<Scalars['ID']['input']>;
Expand Down Expand Up @@ -1335,7 +1340,7 @@ export type PassportStrategy_filter = {
and?: InputMaybe<Array<InputMaybe<PassportStrategy_filter>>>;
or?: InputMaybe<Array<InputMaybe<PassportStrategy_filter>>>;
};
export type PassportStrategy_orderBy = 'id' | 'passportScorer' | 'passportScorer__id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'threshold' | 'councilSafe' | 'active';
export type PassportStrategy_orderBy = 'id' | 'passportScorer' | 'passportScorer__id' | 'strategy' | 'strategy__id' | 'strategy__poolId' | 'strategy__poolAmount' | 'strategy__metadata' | 'strategy__maxCVSupply' | 'strategy__totalEffectiveActivePoints' | 'strategy__isEnabled' | 'strategy__token' | 'strategy__archived' | 'threshold' | 'councilSafe' | 'active';
export type PassportUser = {
id: Scalars['ID']['output'];
passportScorer: PassportScorer;
Expand Down Expand Up @@ -3198,6 +3203,7 @@ export type CVStrategyResolvers<ContextType = MeshContext, ParentType extends Re
isEnabled?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
token?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
sybilScorer?: Resolver<Maybe<ResolversTypes['PassportScorer']>, ParentType, ContextType>;
archived?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
}>;
export type CVStrategyConfigResolvers<ContextType = MeshContext, ParentType extends ResolversParentTypes['CVStrategyConfig'] = ResolversParentTypes['CVStrategyConfig']> = ResolversObject<{
Expand Down Expand Up @@ -3523,6 +3529,9 @@ export declare function getBuiltGraphSDK<TGlobalContext = any, TOperationContext
communityAddr: Scalars["ID"]["input"];
tokenAddr: Scalars["ID"]["input"];
}>, options?: TOperationContext): Promise<getPoolCreationDataQuery>;
getProposalSupporters(variables: Exact<{
proposalId: Scalars["String"]["input"];
}>, options?: TOperationContext): Promise<getProposalSupportersQuery>;
getGardenCommunities(variables: Exact<{
chainId: Scalars["BigInt"]["input"];
tokenGarden: Scalars["ID"]["input"];
Expand Down Expand Up @@ -3654,6 +3663,16 @@ export type getPoolCreationDataQuery = {
allos: Array<Pick<Allo, 'id'>>;
registryCommunity?: Maybe<Pick<RegistryCommunity, 'communityName' | 'isValid'>>;
};
export type getProposalSupportersQueryVariables = Exact<{
proposalId: Scalars['String']['input'];
}>;
export type getProposalSupportersQuery = {
members: Array<(Pick<Member, 'id'> & {
stakes?: Maybe<Array<(Pick<Stake, 'amount'> & {
proposal: Pick<CVProposal, 'proposalNumber' | 'id'>;
})>>;
})>;
};
export type getGardenCommunitiesQueryVariables = Exact<{
chainId: Scalars['BigInt']['input'];
tokenGarden: Scalars['ID']['input'];
Expand Down Expand Up @@ -3833,6 +3852,7 @@ export declare const getMemberStrategyDocument: DocumentNode<getMemberStrategyQu
export declare const isMemberDocument: DocumentNode<isMemberQuery, isMemberQueryVariables>;
export declare const getMemberDocument: DocumentNode<getMemberQuery, getMemberQueryVariables>;
export declare const getPoolCreationDataDocument: DocumentNode<getPoolCreationDataQuery, getPoolCreationDataQueryVariables>;
export declare const getProposalSupportersDocument: DocumentNode<getProposalSupportersQuery, getProposalSupportersQueryVariables>;
export declare const getGardenCommunitiesDocument: DocumentNode<getGardenCommunitiesQuery, getGardenCommunitiesQueryVariables>;
export declare const getCommunityDocument: DocumentNode<getCommunityQuery, getCommunityQueryVariables>;
export declare const getCommunityCreationDataDocument: DocumentNode<getCommunityCreationDataQuery, getCommunityCreationDataQueryVariables>;
Expand All @@ -3858,6 +3878,7 @@ export declare function getSdk<C, E>(requester: Requester<C, E>): {
isMember(variables: isMemberQueryVariables, options?: C): Promise<isMemberQuery>;
getMember(variables: getMemberQueryVariables, options?: C): Promise<getMemberQuery>;
getPoolCreationData(variables: getPoolCreationDataQueryVariables, options?: C): Promise<getPoolCreationDataQuery>;
getProposalSupporters(variables: getProposalSupportersQueryVariables, options?: C): Promise<getProposalSupportersQuery>;
getGardenCommunities(variables: getGardenCommunitiesQueryVariables, options?: C): Promise<getGardenCommunitiesQuery>;
getCommunity(variables: getCommunityQueryVariables, options?: C): Promise<getCommunityQuery>;
getCommunityCreationData(variables?: getCommunityCreationDataQueryVariables, options?: C): Promise<getCommunityCreationDataQuery>;
Expand Down
Loading

0 comments on commit fe1e369

Please sign in to comment.