-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic client side envs 2 #80
Changes from 4 commits
03179ea
fb644e1
6e8bdf6
5c197bb
a13e384
4a5cd3c
99101c3
6948ae3
11428fa
a3eb862
726c0d0
95871aa
68a0a8e
c9de74a
b014301
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PENUMBRA_GRPC_ENDPOINT= | ||
PENUMBRA_INDEXER_ENDPOINT= | ||
PENUMBRA_INDEXER_CA_CERT= | ||
PENUMBRA_CHAIN_ID= | ||
PENUMBRA_CUILOA_URL= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { Analytics } from "@vercel/analytics/react" | |
import { inject } from '@vercel/analytics'; | ||
import { SpeedInsights } from "@vercel/speed-insights/next" | ||
import { injectSpeedInsights } from '@vercel/speed-insights'; | ||
import { EnvContext } from '@/utils/env/context'; | ||
|
||
function app({ Component, pageProps }: AppProps) { | ||
// Inject the analytics script | ||
|
@@ -31,9 +32,11 @@ function app({ Component, pageProps }: AppProps) { | |
}); | ||
return ( | ||
<ChakraProvider theme={theme}> | ||
<Analytics /> | ||
<SpeedInsights /> | ||
<Component {...pageProps} /> | ||
<EnvContext.Provider value={pageProps.envs}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meant as a placeholder until we have finalized a state manager. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We we anticipate this env context vars to be critical to a number of things in client side code, we should use react-query to fetch and sync its state with a mobx |
||
<Analytics /> | ||
<SpeedInsights /> | ||
<Component {...pageProps} /> | ||
</EnvContext.Provider> | ||
</ChakraProvider> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ import { BlockDetailedSummaryData } from "@/utils/types/block"; | |
import { BlockInfo, LiquidityPositionEvent } from "@/utils/indexer/types/lps"; | ||
import { SwapExecutionWithBlockHeight } from "@/utils/protos/types/DexQueryServiceClientInterface"; | ||
import { LoadingSpinner } from "@/components/util/loadingSpinner"; | ||
import { Constants } from "@/utils/configConstants.ts"; | ||
import { formatTimestampShort } from "@/components/blockTimestamp"; | ||
import { AddIcon, MinusIcon } from "@chakra-ui/icons"; | ||
import { innerToBech32Address } from "@/utils/math/bech32"; | ||
|
@@ -25,9 +24,11 @@ import { | |
SwapExecution_Trace, | ||
} from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb"; | ||
import BigNumber from "bignumber.js"; | ||
import { fetchAllTokenAssets } from "@/utils/token/tokenFetch"; | ||
import { useTokenAssets } from "@/utils/token/tokenFetch"; | ||
import { Token } from "@/utils/types/token"; | ||
import { fromBaseUnit } from "@/utils/math/hiLo"; | ||
import { getClientSideEnvs } from "@/utils/env/getClientSideEnvs"; | ||
import { useEnvContext } from "@/utils/env/context"; | ||
|
||
export const Price = ({ | ||
trace, | ||
|
@@ -438,8 +439,9 @@ export default function Block() { | |
}) => { | ||
// ! Expand default | ||
const [isExpanded, setIsExpanded] = useState(false); // EXPAND | ||
const tokenAssets = fetchAllTokenAssets(); | ||
const tokenAssets = useTokenAssets(); | ||
const metadataByAssetId: Record<string, Token> = {}; | ||
const envs = useEnvContext(); | ||
tokenAssets.forEach((asset) => { | ||
metadataByAssetId[asset.inner] = { | ||
symbol: asset.symbol, | ||
|
@@ -653,7 +655,7 @@ export default function Block() { | |
</Text> | ||
<Text> | ||
<a | ||
href={Constants.cuiloaUrl + "/block/" + blockHeight} | ||
href={envs.PENUMBRA_CUILOA_URL + "/block/" + blockHeight} | ||
target="_blank" | ||
rel="noreferrer" | ||
style={{ | ||
|
@@ -704,3 +706,13 @@ export default function Block() { | |
</Layout> | ||
); | ||
} | ||
|
||
export async function getServerSideProps() { | ||
const envs = getClientSideEnvs(); | ||
|
||
return { | ||
props: { | ||
envs, | ||
}, | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two thoughts:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in react-query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, but let's keep that to another PR (also this is v1 code).