Skip to content

Commit

Permalink
Merge pull request #234 from hackdays-io/feature/subgraph
Browse files Browse the repository at this point in the history
Add subgraph for fraction token history
  • Loading branch information
yu23ki14 authored Jan 6, 2025
2 parents cee4568 + 42f4020 commit dccef7e
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 17 deletions.
38 changes: 38 additions & 0 deletions pkgs/frontend/app/routes/$treeId_.assistcredit-history.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Box, Heading, List, Text } from "@chakra-ui/react";
import { useParams } from "@remix-run/react";
import { useGetTransferFractionTokens } from "hooks/useFractionToken";
import { FC } from "react";
import { abbreviateAddress } from "utils/wallet";
import { StickyNav } from "~/components/StickyNav";

const WorkspaceMember: FC = () => {
const { treeId } = useParams();

const { data } = useGetTransferFractionTokens({
where: {
workspaceId: treeId,
},
});

return (
<>
{/* Members */}
<Box mb={4}>
<Heading pb={4}>Transaction History</Heading>
<List.Root>
{data?.transferFractionTokens.map((token) => (
<List.Item>
<Text>
{abbreviateAddress(token.from)}{abbreviateAddress(token.to)}{" "}
: {token.amount}
</Text>
</List.Item>
))}
</List.Root>
</Box>
<StickyNav />
</>
);
};

export default WorkspaceMember;
2 changes: 1 addition & 1 deletion pkgs/frontend/app/routes/$treeId_.member.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const WorkspaceMember: FC = () => {
<Heading py={4}>All Contributors</Heading>
<VStack width="full" alignItems="start" gap={3}>
{assistantMembers.map((m, i) => (
<HStack key={i} width="full">
<HStack key={`assistant_${i}`} width="full">
<UserIcon
userImageUrl={ipfs2https(m.text_records?.avatar)}
size={10}
Expand Down
13 changes: 9 additions & 4 deletions pkgs/frontend/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\n query GetWorkspaces($where: Workspace_filter) {\n workspaces(where: $where) {\n topHatId\n splitCreator\n id\n hatterHatId\n hatsTimeFrameModule\n creator\n }\n }\n": types.GetWorkspacesDocument,
"\n query GetWorkspace($workspaceId: ID!) {\n workspace(id: $workspaceId) {\n creator\n hatsTimeFrameModule\n hatterHatId\n id\n splitCreator\n topHatId\n }\n}\n \n": types.GetWorkspaceDocument,
"\n query GetTransferFractionTokens($where: TransferFractionToken_filter = {}) {\n transferFractionTokens(where: $where) {\n amount\n from\n to\n tokenId\n blockNumber\n blockTimestamp\n hatId\n id\n wearer\n workspaceId\n }\n }\n": types.GetTransferFractionTokensDocument,
"\n query GetWorkspaces($where: Workspace_filter) {\n workspaces(where: $where) {\n creator\n topHatId\n splitCreator\n id\n hatterHatId\n hatsTimeFrameModule\n blockTimestamp\n blockNumber\n }\n }\n": types.GetWorkspacesDocument,
"\n query GetWorkspace($workspaceId: ID!) {\n workspace(id: $workspaceId) {\n creator\n hatsTimeFrameModule\n hatterHatId\n id\n splitCreator\n topHatId\n blockTimestamp\n blockNumber\n }\n }\n": types.GetWorkspaceDocument,
};

/**
Expand All @@ -35,11 +36,15 @@ export function graphql(source: string): unknown;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query GetWorkspaces($where: Workspace_filter) {\n workspaces(where: $where) {\n topHatId\n splitCreator\n id\n hatterHatId\n hatsTimeFrameModule\n creator\n }\n }\n"): (typeof documents)["\n query GetWorkspaces($where: Workspace_filter) {\n workspaces(where: $where) {\n topHatId\n splitCreator\n id\n hatterHatId\n hatsTimeFrameModule\n creator\n }\n }\n"];
export function graphql(source: "\n query GetTransferFractionTokens($where: TransferFractionToken_filter = {}) {\n transferFractionTokens(where: $where) {\n amount\n from\n to\n tokenId\n blockNumber\n blockTimestamp\n hatId\n id\n wearer\n workspaceId\n }\n }\n"): (typeof documents)["\n query GetTransferFractionTokens($where: TransferFractionToken_filter = {}) {\n transferFractionTokens(where: $where) {\n amount\n from\n to\n tokenId\n blockNumber\n blockTimestamp\n hatId\n id\n wearer\n workspaceId\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query GetWorkspace($workspaceId: ID!) {\n workspace(id: $workspaceId) {\n creator\n hatsTimeFrameModule\n hatterHatId\n id\n splitCreator\n topHatId\n }\n}\n \n"): (typeof documents)["\n query GetWorkspace($workspaceId: ID!) {\n workspace(id: $workspaceId) {\n creator\n hatsTimeFrameModule\n hatterHatId\n id\n splitCreator\n topHatId\n }\n}\n \n"];
export function graphql(source: "\n query GetWorkspaces($where: Workspace_filter) {\n workspaces(where: $where) {\n creator\n topHatId\n splitCreator\n id\n hatterHatId\n hatsTimeFrameModule\n blockTimestamp\n blockNumber\n }\n }\n"): (typeof documents)["\n query GetWorkspaces($where: Workspace_filter) {\n workspaces(where: $where) {\n creator\n topHatId\n splitCreator\n id\n hatterHatId\n hatsTimeFrameModule\n blockTimestamp\n blockNumber\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query GetWorkspace($workspaceId: ID!) {\n workspace(id: $workspaceId) {\n creator\n hatsTimeFrameModule\n hatterHatId\n id\n splitCreator\n topHatId\n blockTimestamp\n blockNumber\n }\n }\n"): (typeof documents)["\n query GetWorkspace($workspaceId: ID!) {\n workspace(id: $workspaceId) {\n creator\n hatsTimeFrameModule\n hatterHatId\n id\n splitCreator\n topHatId\n blockTimestamp\n blockNumber\n }\n }\n"];

export function graphql(source: string) {
return (documents as any)[source] ?? {};
Expand Down
76 changes: 72 additions & 4 deletions pkgs/frontend/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type Block_Height = {

export type InitializedFractionToken = {
__typename?: 'InitializedFractionToken';
blockNumber: Scalars['BigInt']['output'];
blockTimestamp: Scalars['BigInt']['output'];
hatId: Scalars['BigInt']['output'];
id: Scalars['ID']['output'];
wearer: Scalars['String']['output'];
Expand All @@ -56,6 +58,22 @@ export type InitializedFractionToken_Filter = {
/** Filter for the block changed event. */
_change_block?: InputMaybe<BlockChangedFilter>;
and?: InputMaybe<Array<InputMaybe<InitializedFractionToken_Filter>>>;
blockNumber?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_gt?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_gte?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockNumber_lt?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_lte?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_not?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockTimestamp?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_gt?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_gte?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockTimestamp_lt?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_lte?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_not?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
hatId?: InputMaybe<Scalars['BigInt']['input']>;
hatId_gt?: InputMaybe<Scalars['BigInt']['input']>;
hatId_gte?: InputMaybe<Scalars['BigInt']['input']>;
Expand Down Expand Up @@ -104,6 +122,8 @@ export type InitializedFractionToken_Filter = {
};

export enum InitializedFractionToken_OrderBy {
BlockNumber = 'blockNumber',
BlockTimestamp = 'blockTimestamp',
HatId = 'hatId',
Id = 'id',
Wearer = 'wearer',
Expand Down Expand Up @@ -261,6 +281,8 @@ export type SubscriptionWorkspacesArgs = {
export type TransferFractionToken = {
__typename?: 'TransferFractionToken';
amount: Scalars['BigInt']['output'];
blockNumber: Scalars['BigInt']['output'];
blockTimestamp: Scalars['BigInt']['output'];
from: Scalars['String']['output'];
hatId: Scalars['BigInt']['output'];
id: Scalars['ID']['output'];
Expand All @@ -282,6 +304,22 @@ export type TransferFractionToken_Filter = {
amount_not?: InputMaybe<Scalars['BigInt']['input']>;
amount_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
and?: InputMaybe<Array<InputMaybe<TransferFractionToken_Filter>>>;
blockNumber?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_gt?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_gte?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockNumber_lt?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_lte?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_not?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockTimestamp?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_gt?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_gte?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockTimestamp_lt?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_lte?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_not?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
from?: InputMaybe<Scalars['String']['input']>;
from_contains?: InputMaybe<Scalars['String']['input']>;
from_contains_nocase?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -379,6 +417,8 @@ export type TransferFractionToken_Filter = {

export enum TransferFractionToken_OrderBy {
Amount = 'amount',
BlockNumber = 'blockNumber',
BlockTimestamp = 'blockTimestamp',
From = 'from',
HatId = 'hatId',
Id = 'id',
Expand All @@ -390,6 +430,8 @@ export enum TransferFractionToken_OrderBy {

export type Workspace = {
__typename?: 'Workspace';
blockNumber: Scalars['BigInt']['output'];
blockTimestamp: Scalars['BigInt']['output'];
creator: Scalars['String']['output'];
hatsTimeFrameModule: Scalars['String']['output'];
hatterHatId: Scalars['BigInt']['output'];
Expand All @@ -402,6 +444,22 @@ export type Workspace_Filter = {
/** Filter for the block changed event. */
_change_block?: InputMaybe<BlockChangedFilter>;
and?: InputMaybe<Array<InputMaybe<Workspace_Filter>>>;
blockNumber?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_gt?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_gte?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockNumber_lt?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_lte?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_not?: InputMaybe<Scalars['BigInt']['input']>;
blockNumber_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockTimestamp?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_gt?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_gte?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
blockTimestamp_lt?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_lte?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_not?: InputMaybe<Scalars['BigInt']['input']>;
blockTimestamp_not_in?: InputMaybe<Array<Scalars['BigInt']['input']>>;
creator?: InputMaybe<Scalars['String']['input']>;
creator_contains?: InputMaybe<Scalars['String']['input']>;
creator_contains_nocase?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -490,6 +548,8 @@ export type Workspace_Filter = {
};

export enum Workspace_OrderBy {
BlockNumber = 'blockNumber',
BlockTimestamp = 'blockTimestamp',
Creator = 'creator',
HatsTimeFrameModule = 'hatsTimeFrameModule',
HatterHatId = 'hatterHatId',
Expand Down Expand Up @@ -534,20 +594,28 @@ export enum _SubgraphErrorPolicy_ {
Deny = 'deny'
}

export type GetTransferFractionTokensQueryVariables = Exact<{
where?: InputMaybe<TransferFractionToken_Filter>;
}>;


export type GetTransferFractionTokensQuery = { __typename?: 'Query', transferFractionTokens: Array<{ __typename?: 'TransferFractionToken', amount: any, from: string, to: string, tokenId: any, blockNumber: any, blockTimestamp: any, hatId: any, id: string, wearer: string, workspaceId: string }> };

export type GetWorkspacesQueryVariables = Exact<{
where?: InputMaybe<Workspace_Filter>;
}>;


export type GetWorkspacesQuery = { __typename?: 'Query', workspaces: Array<{ __typename?: 'Workspace', topHatId: any, splitCreator: string, id: string, hatterHatId: any, hatsTimeFrameModule: string, creator: string }> };
export type GetWorkspacesQuery = { __typename?: 'Query', workspaces: Array<{ __typename?: 'Workspace', creator: string, topHatId: any, splitCreator: string, id: string, hatterHatId: any, hatsTimeFrameModule: string, blockTimestamp: any, blockNumber: any }> };

export type GetWorkspaceQueryVariables = Exact<{
workspaceId: Scalars['ID']['input'];
}>;


export type GetWorkspaceQuery = { __typename?: 'Query', workspace?: { __typename?: 'Workspace', creator: string, hatsTimeFrameModule: string, hatterHatId: any, id: string, splitCreator: string, topHatId: any } | null };
export type GetWorkspaceQuery = { __typename?: 'Query', workspace?: { __typename?: 'Workspace', creator: string, hatsTimeFrameModule: string, hatterHatId: any, id: string, splitCreator: string, topHatId: any, blockTimestamp: any, blockNumber: any } | null };


export const GetWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaces"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"where"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace_filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"Variable","name":{"kind":"Name","value":"where"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"topHatId"}},{"kind":"Field","name":{"kind":"Name","value":"splitCreator"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hatterHatId"}},{"kind":"Field","name":{"kind":"Name","value":"hatsTimeFrameModule"}},{"kind":"Field","name":{"kind":"Name","value":"creator"}}]}}]}}]} as unknown as DocumentNode<GetWorkspacesQuery, GetWorkspacesQueryVariables>;
export const GetWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"creator"}},{"kind":"Field","name":{"kind":"Name","value":"hatsTimeFrameModule"}},{"kind":"Field","name":{"kind":"Name","value":"hatterHatId"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"splitCreator"}},{"kind":"Field","name":{"kind":"Name","value":"topHatId"}}]}}]}}]} as unknown as DocumentNode<GetWorkspaceQuery, GetWorkspaceQueryVariables>;
export const GetTransferFractionTokensDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTransferFractionTokens"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"where"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"TransferFractionToken_filter"}},"defaultValue":{"kind":"ObjectValue","fields":[]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transferFractionTokens"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"Variable","name":{"kind":"Name","value":"where"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"from"}},{"kind":"Field","name":{"kind":"Name","value":"to"}},{"kind":"Field","name":{"kind":"Name","value":"tokenId"}},{"kind":"Field","name":{"kind":"Name","value":"blockNumber"}},{"kind":"Field","name":{"kind":"Name","value":"blockTimestamp"}},{"kind":"Field","name":{"kind":"Name","value":"hatId"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"wearer"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]}}]} as unknown as DocumentNode<GetTransferFractionTokensQuery, GetTransferFractionTokensQueryVariables>;
export const GetWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaces"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"where"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace_filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"Variable","name":{"kind":"Name","value":"where"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"creator"}},{"kind":"Field","name":{"kind":"Name","value":"topHatId"}},{"kind":"Field","name":{"kind":"Name","value":"splitCreator"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hatterHatId"}},{"kind":"Field","name":{"kind":"Name","value":"hatsTimeFrameModule"}},{"kind":"Field","name":{"kind":"Name","value":"blockTimestamp"}},{"kind":"Field","name":{"kind":"Name","value":"blockNumber"}}]}}]}}]} as unknown as DocumentNode<GetWorkspacesQuery, GetWorkspacesQueryVariables>;
export const GetWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"creator"}},{"kind":"Field","name":{"kind":"Name","value":"hatsTimeFrameModule"}},{"kind":"Field","name":{"kind":"Name","value":"hatterHatId"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"splitCreator"}},{"kind":"Field","name":{"kind":"Name","value":"topHatId"}},{"kind":"Field","name":{"kind":"Name","value":"blockTimestamp"}},{"kind":"Field","name":{"kind":"Name","value":"blockNumber"}}]}}]}}]} as unknown as DocumentNode<GetWorkspaceQuery, GetWorkspaceQueryVariables>;
Loading

0 comments on commit dccef7e

Please sign in to comment.