-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
244 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Feature } from './types'; | ||
import type { AddressProfileAPIConfig } from 'types/client/addressProfileAPIConfig'; | ||
|
||
import { getEnvValue, parseEnvJson } from '../utils'; | ||
|
||
const value = parseEnvJson<AddressProfileAPIConfig>(getEnvValue('NEXT_PUBLIC_ADDRESS_USERNAME_TAG')); | ||
|
||
function checkApiUrlTemplate(apiUrlTemplate: string): boolean { | ||
try { | ||
const testUrl = apiUrlTemplate.replace('{address}', '0x0000000000000000000000000000000000000000'); | ||
new URL(testUrl).toString(); | ||
return true; | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
|
||
const title = 'User profile API'; | ||
|
||
const config: Feature<{ | ||
apiUrlTemplate: string; | ||
tagLinkTemplate?: string; | ||
tagIcon?: string; | ||
tagBgColor?: string; | ||
tagTextColor?: string; | ||
}> = (() => { | ||
if (value && checkApiUrlTemplate(value.api_url_template)) { | ||
return Object.freeze({ | ||
title, | ||
isEnabled: true, | ||
apiUrlTemplate: value.api_url_template, | ||
tagLinkTemplate: value.tag_link_template, | ||
tagIcon: value.tag_icon, | ||
tagBgColor: value.tag_bg_color, | ||
tagTextColor: value.tag_text_color, | ||
}); | ||
} | ||
|
||
return Object.freeze({ | ||
title, | ||
isEnabled: false, | ||
}); | ||
})(); | ||
|
||
export default config; |
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,60 @@ | ||
# Set of ENVs for Zora Mainnet network explorer | ||
# https://explorer.zora.energy | ||
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=zora" | ||
|
||
# Local ENVs | ||
NEXT_PUBLIC_APP_PROTOCOL=http | ||
NEXT_PUBLIC_APP_HOST=localhost | ||
NEXT_PUBLIC_APP_PORT=3000 | ||
NEXT_PUBLIC_APP_ENV=development | ||
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws | ||
|
||
# Instance ENVs | ||
NEXT_PUBLIC_AD_BANNER_PROVIDER=none | ||
NEXT_PUBLIC_AD_TEXT_PROVIDER=none | ||
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com | ||
NEXT_PUBLIC_API_BASE_PATH=/ | ||
NEXT_PUBLIC_API_HOST=explorer.zora.energy | ||
NEXT_PUBLIC_API_SPEC_URL=https://raw.githubusercontent.com/blockscout/blockscout-api-v2-swagger/main/swagger.yaml | ||
NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.ethereum.org/?address={hash}&blockscout={domain}','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}] | ||
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://contracts-info.services.blockscout.com | ||
NEXT_PUBLIC_DEFI_DROPDOWN_ITEMS=[{'text':'Swap','icon':'swap','dappId':'uniswap'}] | ||
NEXT_PUBLIC_FEATURED_NETWORKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/featured-networks/zora.json | ||
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0x6d54c0226a57f5bc854f8aa589bb15113388f984f318c9e1b2722115e4e35873 | ||
NEXT_PUBLIC_HAS_CONTRACT_AUDIT_REPORTS=true | ||
NEXT_PUBLIC_HAS_USER_OPS=true | ||
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs'] | ||
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND=linear-gradient(89deg, rgb(63, 36, 22) 0.56%, rgb(44, 56, 105) 98.31%) | ||
NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true | ||
NEXT_PUBLIC_LOGOUT_URL=https://zora-blockscout.us.auth0.com/v2/logout | ||
NEXT_PUBLIC_MARKETPLACE_ENABLED=true | ||
NEXT_PUBLIC_MARKETPLACE_RATING_AIRTABLE_API_KEY=patbqG4V2CI998jAq.9810c58c9de973ba2650621c94559088cbdfa1a914498e385621ed035d33c0d0 | ||
NEXT_PUBLIC_MARKETPLACE_RATING_AIRTABLE_BASE_ID=appGkvtmKI7fXE4Vs | ||
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://airtable.com/appiy5yijZpMMSKjT/shr6uMGPKjj1DK7NL | ||
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM=https://airtable.com/appiy5yijZpMMSKjT/pag3t82DUCyhGRZZO/form | ||
NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com | ||
NEXT_PUBLIC_NAME_SERVICE_API_HOST=https://bens.services.blockscout.com | ||
NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES=['/apps'] | ||
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18 | ||
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether | ||
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH | ||
NEXT_PUBLIC_NETWORK_EXPLORERS=[{'title':'GeckoTerminal','logo':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/explorer-logos/geckoterminal.png','baseUrl':'https://www.geckoterminal.com/','paths':{'token':'/zora-network/pools'}}] | ||
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/zora.svg | ||
NEXT_PUBLIC_NETWORK_ICON_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/zora-dark.svg | ||
NEXT_PUBLIC_NETWORK_ID=7777777 | ||
NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/zora.svg | ||
NEXT_PUBLIC_NETWORK_LOGO_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/zora-dark.svg | ||
NEXT_PUBLIC_NETWORK_NAME=Zora Mainnet | ||
NEXT_PUBLIC_NETWORK_RPC_URL=https://rpc.zora.energy | ||
NEXT_PUBLIC_NETWORK_SHORT_NAME=Zora Mainnet | ||
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE=validation | ||
NEXT_PUBLIC_OG_ENHANCED_DATA_ENABLED=true | ||
NEXT_PUBLIC_OG_IMAGE_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/og-images/zora-mainnet.png | ||
NEXT_PUBLIC_ROLLUP_L1_BASE_URL=https://eth.blockscout.com/ | ||
NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL=https://bridge.zora.energy | ||
NEXT_PUBLIC_ROLLUP_TYPE=optimistic | ||
NEXT_PUBLIC_STATS_API_HOST=https://stats-l2-zora-mainnet.k8s-prod-1.blockscout.com | ||
NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER=blockscout | ||
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com | ||
NEXT_PUBLIC_MULTICHAIN_BALANCE_PROVIDER_CONFIG={'name': 'zerion', 'dapp_id': 'zerion', 'url_template': 'https://app.zerion.io/{address}/overview?utm_source=blockscout&utm_medium=address', 'logo': 'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-logos/zerion.svg'} | ||
NEXT_PUBLIC_ADDRESS_USERNAME_TAG={'api_url_template': 'https://api.zora.co/discover/user/{address}', 'tag_link_template': 'httpszora.co/{username}', 'tag_icon': 'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/zora.svg', 'tag_bg_color': 'rgba(0,0,0)', 'tag_text_color': 'rgba(255,255,255)'} |
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,44 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import * as v from 'valibot'; | ||
|
||
import config from 'configs/app'; | ||
import type { ResourceError } from 'lib/api/resources'; | ||
import useFetch from 'lib/hooks/useFetch'; | ||
|
||
const feature = config.features.addressProfileAPI; | ||
|
||
type AddressInfoApiQueryResponse = v.InferOutput<typeof AddressInfoSchema>; | ||
|
||
const AddressInfoSchema = v.object({ | ||
user_profile: v.object({ | ||
username: v.union([ v.string(), v.null() ]), | ||
}), | ||
}); | ||
|
||
const ERROR_NAME = 'Invalid response schema'; | ||
|
||
export default function useAddressProfileApiQuery(hash: string | undefined, isEnabled = true) { | ||
const fetch = useFetch(); | ||
|
||
return useQuery<unknown, ResourceError<unknown>, AddressInfoApiQueryResponse>({ | ||
queryKey: [ 'username_api', hash ], | ||
queryFn: async() => { | ||
if (!feature.isEnabled || !hash) { | ||
return Promise.reject(); | ||
} | ||
|
||
return fetch(feature.apiUrlTemplate.replace('{address}', hash), undefined, { omitSentryErrorLog: true }); | ||
}, | ||
enabled: isEnabled && Boolean(hash), | ||
refetchOnMount: false, | ||
select: (response) => { | ||
const parsedResponse = v.safeParse(AddressInfoSchema, response); | ||
|
||
if (!parsedResponse.success) { | ||
throw Error(ERROR_NAME); | ||
} | ||
|
||
return parsedResponse.output; | ||
}, | ||
}); | ||
} |
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,26 @@ | ||
import type CspDev from 'csp-dev'; | ||
|
||
import config from 'configs/app'; | ||
|
||
const feature = config.features.addressProfileAPI; | ||
|
||
export function usernameApi(): CspDev.DirectiveDescriptor { | ||
if (!feature.isEnabled) { | ||
return {}; | ||
} | ||
|
||
const apiOrigin = (() => { | ||
try { | ||
const url = new URL(feature.apiUrlTemplate); | ||
return url.origin; | ||
} catch (error) { | ||
return ''; | ||
} | ||
})(); | ||
|
||
return { | ||
'connect-src': [ | ||
apiOrigin, | ||
], | ||
}; | ||
} |
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,7 @@ | ||
export type AddressProfileAPIConfig = { | ||
api_url_template: string; | ||
tag_link_template?: string; | ||
tag_icon?: string; | ||
tag_bg_color?: string; | ||
tag_text_color?: string; | ||
}; |
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