Skip to content

Commit

Permalink
Polytone NFT Support and miscellaneous UX improvements (#1358)
Browse files Browse the repository at this point in the history
* Made NFT actions support polytone and display polytone NFTs in treasury.

* Hide chain picker for Mint and Display NFT actions once created.

* Only count as pending the proposals that the wallet has voting power in.

* Redirect to DAO if polytone address in URL.

* Load accent color of DAO from items instead of static props and hardcode accent for chains.

* Add accent item to suggested keys list in manage storage items action.

* Batch indexer requests.

* Fixed type.
  • Loading branch information
NoahSaso authored Sep 3, 2023
1 parent b54b7b0 commit aeece73
Show file tree
Hide file tree
Showing 76 changed files with 1,816 additions and 812 deletions.
1 change: 1 addition & 0 deletions apps/dapp/pages/dao/[address]/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoStaticProps({
appMode: DaoPageMode.Dapp,
getProps: async ({ coreAddress }) => ({
url: SITE_URL + getDaoPath(DaoPageMode.Dapp, coreAddress),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/pages/dao/[address]/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoStaticProps({
appMode: DaoPageMode.Dapp,
getProps: async ({ t, coreAddress }) => ({
url: SITE_URL + getDaoPath(DaoPageMode.Dapp, coreAddress, 'create'),
followingTitle: t('title.createASubDao'),
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/pages/dao/[address]/proposals/[proposalId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoProposalStaticProps({
appMode: DaoPageMode.Dapp,
getProposalUrlPrefix: ({ address }) =>
SITE_URL +
getDaoProposalPath(
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/pages/dao/[address]/proposals/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoStaticProps({
appMode: DaoPageMode.Dapp,
getProps: ({ t, coreAddress }) => ({
url: SITE_URL + getDaoProposalPath(DaoPageMode.Dapp, coreAddress, 'create'),
followingTitle: t('title.createAProposal'),
Expand Down
Binary file removed apps/dapp/public/stargaze.png
Binary file not shown.
1 change: 1 addition & 0 deletions apps/sda/pages/[address]/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoStaticProps({
appMode: DaoPageMode.Sda,
getProps: async ({ coreAddress }) => ({
url: SITE_URL + getDaoPath(DaoPageMode.Sda, coreAddress),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/sda/pages/[address]/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoStaticProps({
appMode: DaoPageMode.Sda,
getProps: async ({ t, coreAddress }) => ({
url: SITE_URL + getDaoPath(DaoPageMode.Sda, coreAddress, 'create'),
followingTitle: t('title.createASubDao'),
Expand Down
1 change: 1 addition & 0 deletions apps/sda/pages/[address]/proposals/[proposalId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoProposalStaticProps({
appMode: DaoPageMode.Sda,
getProposalUrlPrefix: ({ address }) =>
SITE_URL +
getDaoProposalPath(
Expand Down
1 change: 1 addition & 0 deletions apps/sda/pages/[address]/proposals/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const getStaticPaths: GetStaticPaths = () => ({
})

export const getStaticProps = makeGetDaoStaticProps({
appMode: DaoPageMode.Sda,
getProps: ({ t, coreAddress }) => ({
url: SITE_URL + getDaoProposalPath(DaoPageMode.Sda, coreAddress, 'create'),
followingTitle: t('title.createAProposal'),
Expand Down
Binary file removed apps/sda/public/stargaze.png
Binary file not shown.
24 changes: 13 additions & 11 deletions packages/state/indexer/query.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IndexerFormulaType, WithChainId } from '@dao-dao/types'
import {
BatchClient,
CommonError,
INDEXER_DISABLED,
INDEXER_URL,
fetchWithTimeout,
} from '@dao-dao/utils'

export type QueryIndexerOptions = WithChainId<
Expand Down Expand Up @@ -31,6 +31,8 @@ export type QueryIndexerOptions = WithChainId<
)
>

const indexerBatchClient = new BatchClient(INDEXER_URL + '/batch')

export const queryIndexer = async <T = any>({
type,
address = '_',
Expand Down Expand Up @@ -59,22 +61,22 @@ export const queryIndexer = async <T = any>({
...(block ? { block: `${block.height}:${block.timeUnixMs ?? 1}` } : {}),
})

const response = await fetchWithTimeout(
// Timeout after 10 seconds.
10 * 1000,
`${INDEXER_URL}/${chainId}/${type}/${address}/${formula}?${params.toString()}`
)
const url = `/${chainId}/${type}/${address}/${formula}?${params.toString()}`
const { status, body } = await indexerBatchClient.execute({
url,
})

if (!response.ok) {
const errorResponse = await response.text().catch(() => undefined)
if (status >= 300) {
throw new Error(
`Error querying indexer for ${type}/${address}/${formula}: ${response.status} ${errorResponse}`.trim()
`Error querying indexer for ${type}/${address}/${formula}: ${status} ${body}`.trim()
)
} else if (response.status === 204) {
}

if (status === 204) {
// If no content is returned, return undefined. This will happen if the
// formula computed succesfully and outputted nothing (undefined or null).
return undefined
}

return response.json()
return JSON.parse(body)
}
Loading

2 comments on commit aeece73

@vercel
Copy link

@vercel vercel bot commented on aeece73 Sep 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on aeece73 Sep 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.