Skip to content

Commit

Permalink
fix(ui-ux): modified network from testnet to changi (#333)
Browse files Browse the repository at this point in the history
* fix(ui-ux): modified network from testnet to changi

* chore(package): update eslint to 6.6.0

* update network

* fix

---------

Co-authored-by: pierregee <pierre@cakedefi.com>
  • Loading branch information
chloezxyy and pierregee authored Sep 6, 2023
1 parent d2240b4 commit df67960
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 179 deletions.
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
NEXT_PUBLIC_RPC_URL_MAINNET="https://changi.ocean.jellyfishsdk.com"
NEXT_PUBLIC_RPC_URL_TESTNET="https://changi.ocean.jellyfishsdk.com"
NEXT_PUBLIC_RPC_URL_MAINNET="https://blockscout.changi.ocean.jellyfishsdk.com"
NEXT_PUBLIC_RPC_URL_TESTNET="https://blockscout.changi.ocean.jellyfishsdk.com"
NEXT_PUBLIC_RPC_URL_CHANGI="https://blockscout.changi.ocean.jellyfishsdk.com"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@floating-ui/react-dom": "^1.3.0",
"@headlessui/react": "^1.7.15",
"@reduxjs/toolkit": "^1.9.5",
"@waveshq/standard-defichain-jellyfishsdk": "^1.0.4",
"@waveshq/standard-defichain-jellyfishsdk": "^2.4.1",
"@waveshq/standard-web": "^1.0.4",
"bignumber.js": "^9.1.1",
"clsx": "^1.2.1",
Expand All @@ -42,6 +42,7 @@
"@types/node": "18.16.3",
"@types/recharts": "^1.8.24",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.6.0",
"@waveshq/standard-web-linter": "^1.0.4",
"autoprefixer": "^10.4.14",
"babel-plugin-istanbul": "^6.1.1",
Expand Down
347 changes: 179 additions & 168 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ export const V1_TRANSACTION_URL =
"api?module=transaction&action=gettxinfo&txhash=";

export const getBaseUrl = (network: NetworkConnection) => {
if (network === NetworkConnection.Changi) {
return process.env.NEXT_PUBLIC_RPC_URL_CHANGI;
}
if (network === NetworkConnection.TestNet) {
return process.env.NEXT_PUBLIC_RPC_URL_TESTNET;
}
return process.env.NEXT_PUBLIC_RPC_URL_TESTNET; // TODO: Replace with NEXT_PUBLIC_RPC_URL_MAINNET when MainNet is enabled

return process.env.NEXT_PUBLIC_RPC_URL_MAINNET;
};

export function filterParams(params: { key: string; value }[]): string {
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PropsWithChildren, useEffect, useState } from "react";
import { ConnectKitProvider, getDefaultConfig } from "connectkit";
import { createConfig, WagmiConfig } from "wagmi";
import { MetaMaskConnector } from "wagmi/connectors/metaMask";
import { metachain, metachainTestnet } from "shared/Chains";
import { metachain, metachainChangi, metachainTestnet } from "shared/Chains";

import { NetworkProvider } from "@contexts/NetworkContext";
import { StoreProvider } from "@contexts/StoreProvider";
Expand All @@ -19,13 +19,13 @@ const description =
const website = "https://meta.defiscan.live";

const metamask = new MetaMaskConnector({
chains: [metachain, metachainTestnet],
chains: [metachain, metachainTestnet, metachainChangi],
});

const config = createConfig(
getDefaultConfig({
autoConnect: true,
chains: [metachain, metachainTestnet],
chains: [metachain, metachainTestnet, metachainChangi],
appName,
connectors: [metamask],
walletConnectProjectId: "",
Expand Down
11 changes: 7 additions & 4 deletions src/layouts/contexts/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export enum NetworkConnection {
MainNet = "MainNet",
TestNet = "TestNet",
Changi = "Changi",
}
class Environment {
constructor(
Expand Down Expand Up @@ -41,14 +42,16 @@ export function getEnvironment(): Environment {
switch (type) {
case "production":
return new Environment("Production", false, [
// NetworkConnection.MainNet, // TODO: Enable MainNet
NetworkConnection.TestNet,
// NetworkConnection.MainNet,
// NetworkConnection.TestNet,
NetworkConnection.Changi,
]);
case "development":
default:
return new Environment("Development", true, [
// NetworkConnection.MainNet, // TODO: Enable MainNet
NetworkConnection.TestNet,
// NetworkConnection.MainNet,
// NetworkConnection.TestNet,
NetworkConnection.Changi,
]);
}
}
2 changes: 2 additions & 0 deletions src/layouts/contexts/NetworkContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function mapNetworkObject(connection: NetworkConnection): NetworkContextObject {
return { connection, ...getNetwork("mainnet") };
case NetworkConnection.TestNet:
return { connection, ...getNetwork("testnet") };
case NetworkConnection.Changi:
return { connection, ...getNetwork("changi") };
default:
throw new Error(`${connection as string} network not found`);
}
Expand Down
19 changes: 19 additions & 0 deletions src/shared/Chains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import { Chain } from "viem";

export const metachainChangi = {
id: 1133,
name: "MetaChain Changi",
network: "metachainChangi",
nativeCurrency: {
decimals: 18,
name: "MetaChain Changi",
symbol: "DFI",
},
rpcUrls: {
// TODO: Replace RPC URLs
public: { http: ["https://changi.dfi.team"] },
default: { http: ["https://changi.dfi.team"] },
},
blockExplorers: {
default: { name: "MetaScan", url: "https://meta.defiscan.live" },
},
} as const satisfies Chain;

export const metachainTestnet = {
id: 1133,
name: "MetaChain Testnet",
Expand Down

0 comments on commit df67960

Please sign in to comment.