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

feat(spaceward): key creation in sidebar #728

Merged
merged 4 commits into from
Aug 30, 2024
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
2 changes: 1 addition & 1 deletion spaceward/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"dayjs": "^1.11.10",
"emoji-hash-gen": "^1.0.3",
"esbuild-plugin-polyfill-node": "^0.3.0",
"ethers": "^6.9.2",
"ethers": "6.13.2",
"js-sha256": "^0.10.1",
"jsqr": "^1.4.0",
"libp2p": "^1.0.8",
Expand Down
28 changes: 14 additions & 14 deletions spaceward/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion spaceward/src/components/SendEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ArrowUpRight } from "lucide-react";
import { useEthereumTx } from "@/hooks/useEthereumTx";
import { getProvider } from "@/lib/eth";

const provider = getProvider("sepolia");
const { provider } = getProvider("sepolia");

async function buildEthTransaction(
chainId: string | number,
Expand Down
36 changes: 26 additions & 10 deletions spaceward/src/config/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { env } from "@/env";
import { getProvider } from "../lib/eth";

type ChainName = Parameters<typeof getProvider>[0];
Expand Down Expand Up @@ -222,17 +223,24 @@ Binance Coin native BNB
Ethereum Classic native ETC
Polygon native MATIC
*/
export const ENABLED_ETH_CHAINS: { chainName: ChainName; testnet?: boolean }[] =
[
{ chainName: "arbitrum" },
{ chainName: "base" },
{ chainName: "bsc" },
{ chainName: "mainnet" },
{ chainName: "optimism" },
{ chainName: "sepolia", testnet: true },
];
const _ENABLED_ETH_CHAINS: { chainName: ChainName; testnet?: boolean }[] = [
{ chainName: "arbitrum" },
{ chainName: "base" },
{ chainName: "bsc" },
{ chainName: "mainnet" },
{ chainName: "optimism" },
{ chainName: "sepolia", testnet: true },
];

export const ENABLED_ETH_CHAINS = _ENABLED_ETH_CHAINS.filter(({ testnet }) =>
env.networkVisibility === "all"
? true
: env.networkVisibility === "mainnet"
? !testnet
: Boolean(testnet),
);
Comment on lines +226 to +241
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve the filtering logic for Ethereum chains.

The implementation of the filtering logic based on the networkVisibility environment variable is sound. It enhances the flexibility and security by ensuring that only the appropriate chains are exposed based on the operational environment.

The changes are approved.

It would be beneficial to add unit tests to verify the filtering logic under different networkVisibility settings. Would you like assistance in setting up these tests?


export const COSMOS_CHAINS: {
const _COSMOS_CHAINS: {
chainName: string;
feeAmount?: string;
rpc?: string;
Expand Down Expand Up @@ -272,3 +280,11 @@ export const COSMOS_CHAINS: {
testnet: true,
},
];

export const COSMOS_CHAINS = _COSMOS_CHAINS.filter(({ testnet }) =>
env.networkVisibility === "all"
? true
: env.networkVisibility === "mainnet"
? !testnet
: Boolean(testnet),
);
3 changes: 3 additions & 0 deletions spaceward/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const aminoAnalyzerContract =
const p2pRelayURL =
import.meta.env.VITE_P2P_RELAY_URL ||
"https://relay.devnet.wardenprotocol.org:443";
const networkVisibility: "testnet" | "mainnet" | "all" =
import.meta.env.VITE_WARDEN_NETWORK_VISIBILITY || "testnet";

export const env = {
apiURL,
Expand All @@ -38,4 +40,5 @@ export const env = {
ethereumAnalyzerContract,
aminoAnalyzerContract,
p2pRelayURL,
networkVisibility,
};
Loading
Loading