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

[SPE-336] Allow override api endpoint from env vars #80

Merged
merged 5 commits into from
Nov 2, 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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# production api
NEXT_PUBLIC_API_URL=https://api.skip.money

# development API
# NEXT_PUBLIC_API_URL=https://solve-dev.skip.money
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.env*
!.env.example

src/chains/
tests/downloads/

Expand Down
2 changes: 1 addition & 1 deletion chain-registry
Submodule chain-registry updated 61 files
+31 −0 _IBC/celestia-injective.json
+2 −1 agoric/chain.json
+1 −0 akash/chain.json
+2 −1 archway/chain.json
+3 −1 assetmantle/chain.json
+ assetmantle/images/mntl.png
+ assetmantle/mntl.png
+1 −0 axelar/chain.json
+1 −0 bandchain/chain.json
+1 −0 bitsong/chain.json
+2 −1 celestia/assetlist.json
+32 −3 celestia/chain.json
+2 −1 cerberus/chain.json
+1 −0 composable/chain.json
+1 −0 cosmoshub/chain.json
+13 −21 cronos/chain.json
+11 −9 cryptoorgchain/chain.json
+1 −0 dydx/chain.json
+1 −0 evmos/chain.json
+33 −0 furya/assetlist.json
+103 −0 furya/chain.json
+ furya/images/chain.png
+16 −0 furya/images/chain.svg
+ furya/images/ufury.png
+16 −0 furya/images/ufury.svg
+1 −0 gitopia/chain.json
+10 −7 gravitybridge/chain.json
+1 −0 injective/chain.json
+1 −1 juno/assetlist.json
+1 −0 juno/chain.json
+1 −0 kava/chain.json
+2 −1 konstellation/chain.json
+19 −3 kujira/chain.json
+1 −0 kyve/chain.json
+13 −3 lumnetwork/chain.json
+1 −0 mars/chain.json
+2 −1 medasdigital/chain.json
+2 −1 microtick/chain.json
+18 −4 migaloo/chain.json
+71 −1 neutron/assetlist.json
+14 −0 neutron/chain.json
+1 −0 noble/chain.json
+1 −0 nolus/chain.json
+1 −0 nomic/chain.json
+1 −1 odin/assetlist.json
+2 −1 omniflixhub/chain.json
+1 −1 osmosis/chain.json
+33 −5 persistence/chain.json
+1 −0 quasar/chain.json
+1 −0 quicksilver/chain.json
+1 −0 regen/chain.json
+1 −0 secretnetwork/chain.json
+1 −0 sei/chain.json
+1 −0 sentinel/chain.json
+2 −1 sifchain/chain.json
+1 −0 sommelier/chain.json
+1 −0 stargaze/chain.json
+1 −0 starname/chain.json
+1 −0 stride/chain.json
+1 −0 terra2/chain.json
+1 −1 testnets/temporaltestnet/chain.json
5 changes: 5 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace NodeJS {
interface ProcessEnv {
readonly NEXT_PUBLIC_API_URL?: string;
}
}
5 changes: 0 additions & 5 deletions example.env

This file was deleted.

60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/components/__tests__/SwapWidget.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { SKIP_API_URL } from "@skip-router/core";
import { rest } from "msw";
import { setupServer } from "msw/node";

import { API_URL } from "@/constants/api";
import { act, fireEvent, render, screen, waitFor, within } from "@/test";

import { ASSETS_RESPONSE } from "../../../fixtures/assets";
import { CHAINS_RESPONSE } from "../../../fixtures/chains";
import { SwapWidget } from "../SwapWidget";
import { LAST_SOURCE_CHAIN_KEY } from "../SwapWidget/useSwapWidget";

const API_URL = SKIP_API_URL;

const handlers = [
rest.get(`${API_URL}/v1/info/chains`, (_, res, ctx) => {
return res(ctx.status(200), ctx.json(CHAINS_RESPONSE));
Expand Down
3 changes: 3 additions & 0 deletions src/constants/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { SKIP_API_URL } from "@skip-router/core";

export const API_URL = process.env.NEXT_PUBLIC_API_URL || SKIP_API_URL;
5 changes: 3 additions & 2 deletions src/solve/context.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useWalletClient } from "@cosmos-kit/react";
import { SKIP_API_URL, SkipRouter } from "@skip-router/core";
import { SkipRouter } from "@skip-router/core";
import { getWalletClient } from "@wagmi/core";
import { createContext, FC, PropsWithChildren } from "react";
import { useNetwork } from "wagmi";

import { API_URL } from "@/constants/api";
import {
getOfflineSigner,
getOfflineSignerOnlyAmino,
Expand All @@ -22,7 +23,7 @@ export const SkipProvider: FC<PropsWithChildren> = ({ children }) => {
const { chains } = useNetwork();

const skipClient = new SkipRouter({
apiURL: SKIP_API_URL,
apiURL: API_URL,
getCosmosSigner: async (chainID) => {
if (!walletClient) {
throw new Error("No offline signer available");
Expand Down