Skip to content
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

Add override api endpoint #411

Merged
merged 4 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#411](https://github.com/alleslabs/celatone-frontend/pull/411) Add override api endpoint
- [#385](https://github.com/alleslabs/celatone-frontend/pull/385) Upgrade cosmos kit major version and replace hooks
- [#380](https://github.com/alleslabs/celatone-frontend/pull/380) Support local network
- [#363](https://github.com/alleslabs/celatone-frontend/pull/363) Add config not found page and rewrite network logic
Expand Down
3 changes: 3 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const DEFAULT_SUPPORTED_CHAIN_ID = SUPPORTED_CHAIN_IDS[0];

export const DUMMY_MNEMONIC = process.env.NEXT_PUBLIC_DUMMY_MNEMONIC;

export const CELATONE_API_OVERRIDE =
process.env.NEXT_PUBLIC_CELATONE_API_OVERRIDE;

// CURRENT THEME CONFIG
export const CURR_THEME = (() => {
switch (process.env.NEXT_PUBLIC_THEME) {
Expand Down
9 changes: 7 additions & 2 deletions src/lib/app-provider/hooks/useBaseApiRoute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCelatoneApp } from "../contexts";
import { CELATONE_API_OVERRIDE } from "env";

export const useBaseApiRoute = (
type:
Expand All @@ -12,13 +13,17 @@ export const useBaseApiRoute = (
| "rest"
): string => {
const {
chainConfig: { chain, api },
chainConfig: { chain, api: configApi },
currentChainId,
} = useCelatoneApp();
if (!chain || !api || !currentChainId)

if (!chain || !currentChainId || !configApi)
throw new Error(
"Error retrieving chain, api, or currentChainId from chain config."
);

const api = CELATONE_API_OVERRIDE || configApi;

switch (type) {
case "txs":
return `${api}/txs/${chain}/${currentChainId}`;
Expand Down
Loading