-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from AElfProject/feature/aelf-scan-tmrwdao
feat: use aelf scan and tmrwdao
- Loading branch information
Showing
10 changed files
with
363 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use client"; | ||
// ^ this file needs the "use client" pragma | ||
// https://github.com/apollographql/apollo-client-nextjs/tree/main?tab=readme-ov-file#in-client-components-and-streaming-ssr | ||
|
||
import { HttpLink } from "@apollo/client"; | ||
import { | ||
ApolloNextAppProvider, | ||
ApolloClient, | ||
InMemoryCache, | ||
} from "@apollo/experimental-nextjs-app-support"; | ||
import { env } from 'next-runtime-env'; | ||
|
||
// have a function to create a client for you | ||
function makeClient() { | ||
const httpLink = new HttpLink({ | ||
// this needs to be an absolute url, as relative urls cannot be used in SSR | ||
uri: env("NEXT_PUBLIC_INDEXER_GRAPHQL_ENDPOINT"), | ||
// you can disable result caching here if you want to | ||
// (this does not work if you are rendering your page with `export const dynamic = "force-static"`) | ||
fetchOptions: { cache: "no-store" }, | ||
// you can override the default `fetchOptions` on a per query basis | ||
// via the `context` property on the options passed as a second argument | ||
// to an Apollo Client data fetching hook, e.g.: | ||
// const { data } = useSuspenseQuery(MY_QUERY, { context: { fetchOptions: { cache: "force-cache" }}}); | ||
}); | ||
|
||
// use the `ApolloClient` from "@apollo/experimental-nextjs-app-support" | ||
return new ApolloClient({ | ||
// use the `InMemoryCache` from "@apollo/experimental-nextjs-app-support" | ||
cache: new InMemoryCache(), | ||
link: httpLink, | ||
}); | ||
} | ||
|
||
// you need to create a component to wrap your app in | ||
export function ApolloWrapper({ children }: React.PropsWithChildren) { | ||
return ( | ||
<ApolloNextAppProvider makeClient={makeClient}> | ||
{children} | ||
</ApolloNextAppProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useQuery, gql } from '@apollo/client'; | ||
|
||
interface GetNetworkDaoProposalReleasedIndexResponse { | ||
getNetworkDaoProposalReleasedIndex: { | ||
data: Array<{ | ||
proposalId: string | ||
orgType: string | ||
transactionInfo: { | ||
transactionId: string | ||
} | ||
}> | ||
} | ||
} | ||
|
||
export const useProposalReleaseInfo = (proposalIds: string[] = [], pollInterval: number = 0) => { | ||
|
||
return useQuery<GetNetworkDaoProposalReleasedIndexResponse>(gql` | ||
query GetNetworkDaoProposalReleasedIndex($input: GetNetworkDaoProposalReleasedIndexInput!) { | ||
getNetworkDaoProposalReleasedIndex(input: $input) { | ||
data { | ||
proposalId | ||
orgType | ||
transactionInfo { | ||
transactionId | ||
} | ||
} | ||
} | ||
} | ||
`, { | ||
variables: { | ||
"input": { | ||
"startBlockHeight": 1, | ||
"endBlockHeight": 4000000000, | ||
"orgType": "PARLIAMENT", | ||
"skipCount": 0, | ||
"maxResultCount": 1, | ||
"proposalIds": proposalIds | ||
}, | ||
}, | ||
pollInterval, | ||
skip: proposalIds.length === 0 | ||
}) | ||
} |
Oops, something went wrong.