Skip to content

Commit

Permalink
fix(spaceward): env variables names (#10)
Browse files Browse the repository at this point in the history
* fix(spaceward): centralize all env variables in a single file

This helps us finding them quickly.

* fix(spaceward): name of env variables mismatch

* chore(web): use Warden icon in WalletConnect sessions

* chore(spaceward): delete dead code
  • Loading branch information
Pitasi authored Feb 15, 2024
1 parent 005f38e commit 34d63c2
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 226 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ COPY . .
ENV VITE_FAUCET_URL=%FAUCET_URL%
ENV VITE_WARDEN_RPC_URL=%WARDEN_RPC_URL%
ENV VITE_WARDEN_REST_URL=%WARDEN_REST_URL%
ENV VITE_WARDEN_CHAIN_ID_NUM=%WARDEN_CHAIN_ID_NUM%
ENV VITE_WARDEN_CHAIN_ID=%WARDEN_CHAIN_ID%
ENV VITE_WARDEN_CHAIN_NAME=%WARDEN_CHAIN_NAME%

RUN cd spaceward && pnpm run build
Expand Down
7 changes: 2 additions & 5 deletions spaceward/src/components/faucet-button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useState } from "react";
import { env } from "@/env";
import { useAddressContext } from "@/def-hooks/addressContext";
import { Button } from "@/components/ui/button";

const FAUCET_URL = import.meta.env.VITE_FAUCET_URL || "/api/faucet";

async function getFaucetTokens(addr: string) {
await fetch(FAUCET_URL, {
await fetch(env.faucetURL, {
method: "POST",
body: JSON.stringify({ address: addr }),
});
Expand All @@ -15,8 +14,6 @@ function FaucetButton() {
const [loading, setLoading] = useState(false);
const { address } = useAddressContext();

console.log("FaucetButton", address);

const getTokens = async () => {
setLoading(true);
await getFaucetTokens(address);
Expand Down
3 changes: 2 additions & 1 deletion spaceward/src/def-hooks/walletContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createContext, ReactNode, useContext, useState } from "react";
import { env } from "@/env";
import { useClient } from "../hooks/useClient";
import type { Wallet, Nullable, EncodedWallet } from "../utils/interfaces";

Expand Down Expand Up @@ -39,7 +40,7 @@ export default function WalletProvider({ children }: Props) {
accounts: [],
};
await client.useKeplr({
chainName: import.meta.env.VITE_WARDEN_CHAIN_NAME || "Warden Protocol",
chainName: env.chainName,
bip44: {
coinType: 118,
},
Expand Down
8 changes: 6 additions & 2 deletions spaceward/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const apiURL = import.meta.env.VITE_API_COSMOS ?? "http://127.0.0.1:1317";
const rpcURL = import.meta.env.VITE_WS_TENDERMINT ?? "http://127.0.0.1:26657";
const apiURL = import.meta.env.VITE_WARDEN_REST_URL ?? "http://127.0.0.1:1317";
const rpcURL = import.meta.env.VITE_WARDEN_RPC_URL ?? "http://127.0.0.1:26657";
const prefix = import.meta.env.VITE_ADDRESS_PREFIX ?? "warden";
const faucetURL = import.meta.env.VITE_FAUCET_URL ?? "/api/faucet";
const chainName = import.meta.env.VITE_WARDEN_CHAIN_NAME || "Warden Protocol (local)";

export const env = {
apiURL,
rpcURL,
prefix,
faucetURL,
chainName,
};
160 changes: 0 additions & 160 deletions spaceward/src/newclient/ethermint.ts

This file was deleted.

2 changes: 0 additions & 2 deletions spaceward/src/newclient/index.ts

This file was deleted.

53 changes: 0 additions & 53 deletions spaceward/src/newclient/keplr.ts

This file was deleted.

2 changes: 1 addition & 1 deletion spaceward/src/routes/walletconnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function useWeb3Wallet(relayUrl: string) {
name: 'Warden Protocol wallets',
description: 'Warden Protocol WalletConnect',
url: 'https://wardenprotocol.org/',
icons: ['https://avatars.githubusercontent.com/u/37784886'],
icons: ['https://avatars.githubusercontent.com/u/158038121'],
}
}).then(async wallet => {
try {
Expand Down

0 comments on commit 34d63c2

Please sign in to comment.