Skip to content

Commit

Permalink
Cleanup and format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeating committed Dec 18, 2023
1 parent 4f840f2 commit a53054f
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 219 deletions.
14 changes: 8 additions & 6 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: ["https://subgraph.satsuma-prod.com/7ae15f9faae2/scopelift/l2-flexible-voting-governor-goerli/api", "https://subgraph.satsuma-prod.com/7ae15f9faae2/scopelift/l2-flexible-voting-vote-aggregator/api"],
documents: "./graphql/**/(!(*.d)).graphql",
schema: [
'https://subgraph.satsuma-prod.com/7ae15f9faae2/scopelift/l2-flexible-voting-governor-goerli/api',
'https://subgraph.satsuma-prod.com/7ae15f9faae2/scopelift/l2-flexible-voting-vote-aggregator/api',
],
documents: './graphql/**/(!(*.d)).graphql',
generates: {
"./graphql/generated/graphql.tsx": {
plugins: ["typescript", "typescript-operations", "typescript-react-query"]
'./graphql/generated/graphql.tsx': {
plugins: ['typescript', 'typescript-operations', 'typescript-react-query'],
},
}
},
};

export default config;
15 changes: 4 additions & 11 deletions components/ProposalRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ export default function ProposalRow({
const { l2, daoLogo } = useConfig();
const { data: tokenInfo } = useTokenInfo();

console.log(votes.l1)
// const totalVotesL1 = votes.l1.forVotes + votes.l1.againstVotes + votes.l1.abstainVotes;
const totalVotesL1 = BigInt(0)
console.log(votes.l1);
const totalVotesL1 = votes.l1.forVotes + votes.l1.againstVotes + votes.l1.abstainVotes;
const totalVotesNotBridged = votes.l2NotBridged
? votes.l2NotBridged.forVotes +
votes.l2NotBridged.againstVotes +
Expand Down Expand Up @@ -74,10 +73,7 @@ export default function ProposalRow({
></div>
<div
style={{ width: `${Math.floor((100 * Number(bridged)) / Number(totalVotes))}%` }}
className={clsx(
`rounded-r-md float-left h-full w-0`,
`bg-${color}-500`
)}
className={clsx(`rounded-r-md float-left h-full w-0`, `bg-${color}-500`)}
></div>
</div>
<Tooltip anchorSelect="#bridged-vote-explanation">
Expand Down Expand Up @@ -141,10 +137,7 @@ export default function ProposalRow({
<div className="mt-1 h-1 bg-gray-100 relative rounded-md">
<div
style={{ width: `${Math.floor((100 * Number(bridged)) / Number(totalVotes))}%` }}
className={clsx(
`rounded-l-md float-left h-full w-0`,
`bg-${color}-500`,
)}
className={clsx(`rounded-l-md float-left h-full w-0`, `bg-${color}-500`)}
></div>
<div
style={{ width: `${Math.floor((100 * Number(notBridged)) / Number(totalVotes))}%` }}
Expand Down
8 changes: 7 additions & 1 deletion graphql/aggregator.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
query L2Proposals($governor: Bytes!, $pageSize: Int!, $offset: Int!) {
proposals(first: $pageSize, orderBy: blockTimestamp, orderDirection: desc, where: {governorAddress: $governor}, skip: $offset) {
proposals(
first: $pageSize
orderBy: blockTimestamp
orderDirection: desc
where: { governorAddress: $governor }
skip: $offset
) {
id
proposalId
proposer
Expand Down
163 changes: 101 additions & 62 deletions graphql/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };

function fetcher<TData, TVariables>(endpoint: string, requestInit: RequestInit, query: string, variables?: TVariables) {
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
[_ in K]?: never;
};
export type Incremental<T> =
| T
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };

function fetcher<TData, TVariables>(
endpoint: string,
requestInit: RequestInit,
query: string,
variables?: TVariables
) {
return async (): Promise<TData> => {
const res = await fetch(endpoint, {
method: 'POST',
Expand All @@ -24,23 +33,23 @@ function fetcher<TData, TVariables>(endpoint: string, requestInit: RequestInit,
}

return json.data;
}
};
}
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: { input: string; output: string; }
String: { input: string; output: string; }
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
BigDecimal: { input: any; output: any; }
BigInt: { input: any; output: any; }
Bytes: { input: any; output: any; }
ID: { input: string; output: string };
String: { input: string; output: string };
Boolean: { input: boolean; output: boolean };
Int: { input: number; output: number };
Float: { input: number; output: number };
BigDecimal: { input: any; output: any };
BigInt: { input: any; output: any };
Bytes: { input: any; output: any };
/**
* 8 bytes signed integer
*
*/
Int8: { input: any; output: any; }
Int8: { input: any; output: any };
};

export type BlockChangedFilter = {
Expand Down Expand Up @@ -194,13 +203,13 @@ export enum BridgedVote_OrderBy {
TransactionHash = 'transactionHash',
VoteAbstain = 'voteAbstain',
VoteAgainst = 'voteAgainst',
VoteFor = 'voteFor'
VoteFor = 'voteFor',
}

/** Defines the order direction, either ascending or descending */
export enum OrderDirection {
Asc = 'asc',
Desc = 'desc'
Desc = 'desc',
}

export type Proposal = {
Expand Down Expand Up @@ -393,7 +402,7 @@ export enum Proposal_OrderBy {
Signatures = 'signatures',
StartBlock = 'startBlock',
TransactionHash = 'transactionHash',
Values = 'values'
Values = 'values',
}

export type Query = {
Expand All @@ -406,19 +415,16 @@ export type Query = {
proposals: Array<Proposal>;
};


export type Query_MetaArgs = {
block?: InputMaybe<Block_Height>;
};


export type QueryBridgedVoteArgs = {
block?: InputMaybe<Block_Height>;
id: Scalars['ID']['input'];
subgraphError?: _SubgraphErrorPolicy_;
};


export type QueryBridgedVotesArgs = {
block?: InputMaybe<Block_Height>;
first?: InputMaybe<Scalars['Int']['input']>;
Expand All @@ -429,14 +435,12 @@ export type QueryBridgedVotesArgs = {
where?: InputMaybe<BridgedVote_Filter>;
};


export type QueryProposalArgs = {
block?: InputMaybe<Block_Height>;
id: Scalars['ID']['input'];
subgraphError?: _SubgraphErrorPolicy_;
};


export type QueryProposalsArgs = {
block?: InputMaybe<Block_Height>;
first?: InputMaybe<Scalars['Int']['input']>;
Expand All @@ -457,19 +461,16 @@ export type Subscription = {
proposals: Array<Proposal>;
};


export type Subscription_MetaArgs = {
block?: InputMaybe<Block_Height>;
};


export type SubscriptionBridgedVoteArgs = {
block?: InputMaybe<Block_Height>;
id: Scalars['ID']['input'];
subgraphError?: _SubgraphErrorPolicy_;
};


export type SubscriptionBridgedVotesArgs = {
block?: InputMaybe<Block_Height>;
first?: InputMaybe<Scalars['Int']['input']>;
Expand All @@ -480,14 +481,12 @@ export type SubscriptionBridgedVotesArgs = {
where?: InputMaybe<BridgedVote_Filter>;
};


export type SubscriptionProposalArgs = {
block?: InputMaybe<Block_Height>;
id: Scalars['ID']['input'];
subgraphError?: _SubgraphErrorPolicy_;
};


export type SubscriptionProposalsArgs = {
block?: InputMaybe<Block_Height>;
first?: InputMaybe<Scalars['Int']['input']>;
Expand Down Expand Up @@ -529,7 +528,7 @@ export enum _SubgraphErrorPolicy_ {
/** Data will be returned even if the subgraph has indexing errors */
Allow = 'allow',
/** If the subgraph has indexing errors, data will be omitted. The default. */
Deny = 'deny'
Deny = 'deny',
}

export type L2ProposalsQueryVariables = Exact<{
Expand All @@ -538,19 +537,55 @@ export type L2ProposalsQueryVariables = Exact<{
offset: Scalars['Int']['input'];
}>;


export type L2ProposalsQuery = { __typename?: 'Query', proposals: Array<{ __typename?: 'Proposal', id: string, proposalId: any, proposer: any, startBlock: any, endBlock: any, description: string, governorAddress: any, canceled: boolean, transactionHash: any, blockNumber: any, blockTimestamp: any, bridgedVote?: { __typename?: 'BridgedVote', voteAgainst: any, voteFor: any, voteAbstain: any, blockNumber: any, blockTimestamp: any } | null }> };
export type L2ProposalsQuery = {
__typename?: 'Query';
proposals: Array<{
__typename?: 'Proposal';
id: string;
proposalId: any;
proposer: any;
startBlock: any;
endBlock: any;
description: string;
governorAddress: any;
canceled: boolean;
transactionHash: any;
blockNumber: any;
blockTimestamp: any;
bridgedVote?: {
__typename?: 'BridgedVote';
voteAgainst: any;
voteFor: any;
voteAbstain: any;
blockNumber: any;
blockTimestamp: any;
} | null;
}>;
};

export type ProposalsQueryVariables = Exact<{
governor: Scalars['Bytes']['input'];
pageSize: Scalars['Int']['input'];
offset: Scalars['Int']['input'];
}>;


export type ProposalsQuery = { __typename?: 'Query', proposals: Array<{ __typename?: 'Proposal', id: string, proposalId: any, proposer: any, startBlock: any, endBlock: any, description: string, governorAddress: any, canceled: boolean, transactionHash: any, blockNumber: any, blockTimestamp: any }> };


export type ProposalsQuery = {
__typename?: 'Query';
proposals: Array<{
__typename?: 'Proposal';
id: string;
proposalId: any;
proposer: any;
startBlock: any;
endBlock: any;
description: string;
governorAddress: any;
canceled: boolean;
transactionHash: any;
blockNumber: any;
blockTimestamp: any;
}>;
};

export const L2ProposalsDocument = `
query L2Proposals($governor: Bytes!, $pageSize: Int!, $offset: Int!) {
Expand Down Expand Up @@ -583,20 +618,22 @@ export const L2ProposalsDocument = `
}
`;

export const useL2ProposalsQuery = <
TData = L2ProposalsQuery,
TError = unknown
>(
dataSource: { endpoint: string, fetchParams?: RequestInit },
variables: L2ProposalsQueryVariables,
options?: UseQueryOptions<L2ProposalsQuery, TError, TData>
) => {

return useQuery<L2ProposalsQuery, TError, TData>(
['L2Proposals', variables],
fetcher<L2ProposalsQuery, L2ProposalsQueryVariables>(dataSource.endpoint, dataSource.fetchParams || {}, L2ProposalsDocument, variables),
options
)};
export const useL2ProposalsQuery = <TData = L2ProposalsQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables: L2ProposalsQueryVariables,
options?: UseQueryOptions<L2ProposalsQuery, TError, TData>
) => {
return useQuery<L2ProposalsQuery, TError, TData>(
['L2Proposals', variables],
fetcher<L2ProposalsQuery, L2ProposalsQueryVariables>(
dataSource.endpoint,
dataSource.fetchParams || {},
L2ProposalsDocument,
variables
),
options
);
};

export const ProposalsDocument = `
query Proposals($governor: Bytes!, $pageSize: Int!, $offset: Int!) {
Expand All @@ -622,17 +659,19 @@ export const ProposalsDocument = `
}
`;

export const useProposalsQuery = <
TData = ProposalsQuery,
TError = unknown
>(
dataSource: { endpoint: string, fetchParams?: RequestInit },
variables: ProposalsQueryVariables,
options?: UseQueryOptions<ProposalsQuery, TError, TData>
) => {

return useQuery<ProposalsQuery, TError, TData>(
['Proposals', variables],
fetcher<ProposalsQuery, ProposalsQueryVariables>(dataSource.endpoint, dataSource.fetchParams || {}, ProposalsDocument, variables),
options
)};
export const useProposalsQuery = <TData = ProposalsQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables: ProposalsQueryVariables,
options?: UseQueryOptions<ProposalsQuery, TError, TData>
) => {
return useQuery<ProposalsQuery, TError, TData>(
['Proposals', variables],
fetcher<ProposalsQuery, ProposalsQueryVariables>(
dataSource.endpoint,
dataSource.fetchParams || {},
ProposalsDocument,
variables
),
options
);
};
8 changes: 7 additions & 1 deletion graphql/governor.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
query Proposals($governor: Bytes!, $pageSize: Int!, $offset: Int!) {
proposals(first: $pageSize, orderBy: blockTimestamp, orderDirection: desc, where: {governorAddress: $governor}, skip: $offset) {
proposals(
first: $pageSize
orderBy: blockTimestamp
orderDirection: desc
where: { governorAddress: $governor }
skip: $offset
) {
id
proposalId
proposer
Expand Down
Loading

0 comments on commit a53054f

Please sign in to comment.