Skip to content

Commit

Permalink
Added Fuji Network Support
Browse files Browse the repository at this point in the history
  • Loading branch information
flashburst committed Jun 21, 2022
1 parent 2f4457d commit 8d6477b
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 510 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NEXT_PUBLIC_ROPSTEN_STORE=
NEXT_PUBLIC_KOVAN_STORE=
NEXT_PUBLIC_MUMBAI_STORE=
NEXT_PUBLIC_MUMBAI_STORE=
NEXT_PUBLIC_FUJI_STORE=
22 changes: 22 additions & 0 deletions lib/connect-wallet/components/logos/AvaxLogo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from "react";

const AvaxLogo = (props) => (
<svg
width="46"
height="46"
viewBox="0 0 46 46"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<circle cx="23" cy="23" r="20" fill="#fff" />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M22.5655 0C10.1031 0 0 10.1031 0 22.5655C0 35.0279 10.1031 45.131 22.5655 45.131C35.0279 45.131 45.131 35.0279 45.131 22.5655C45.131 10.1031 35.0279 0 22.5655 0ZM20.6454 28.9553L20.6308 28.9821C20.1306 29.858 19.8769 30.3021 19.5255 30.6363C19.1425 31.0023 18.6838 31.2682 18.1788 31.417C17.7177 31.5439 17.2029 31.5439 16.1709 31.5439H11.7915C10.8717 31.5439 10.4154 31.5439 10.1397 31.3658C9.83963 31.1706 9.65664 30.851 9.63469 30.4948C9.61761 30.1679 9.84451 29.7677 10.3007 28.9699L21.1138 9.91282C21.575 9.10281 21.8067 8.69781 22.0995 8.54898C22.4142 8.38796 22.7924 8.38796 23.1096 8.54898C23.4024 8.69781 23.6366 9.10281 24.0953 9.91282L26.3179 13.7921L26.3301 13.8116C26.8278 14.6801 27.0791 15.1193 27.1889 15.5829C27.3109 16.0879 27.3109 16.6198 27.1889 17.1248C27.0791 17.5908 26.8278 18.0348 26.3228 18.9156L20.643 28.9553H20.6454ZM35.1743 31.3609C34.8962 31.5439 34.4326 31.5439 33.5055 31.5439H27.2304C26.3057 31.5439 25.8397 31.5439 25.5664 31.3658C25.2663 31.1706 25.0834 30.8437 25.0614 30.4899C25.0443 30.1654 25.2737 29.7702 25.7323 28.9772L25.7421 28.9577L28.8748 23.5805C29.3359 22.7875 29.5677 22.3947 29.8556 22.2435C30.1727 22.0824 30.5436 22.0824 30.8583 22.2435C31.1438 22.3898 31.3682 22.7656 31.8098 23.5146L31.8464 23.5756L34.9889 28.9529C35.0035 28.9797 35.0206 29.0041 35.0352 29.0309C35.4719 29.7824 35.694 30.1654 35.6769 30.4826C35.6598 30.8364 35.4719 31.1633 35.1718 31.3585L35.1743 31.3609Z"
fill="#e84142"
/>
</svg>
);

export default AvaxLogo;
17 changes: 17 additions & 0 deletions lib/connect-wallet/config/chains.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AvaxLogo from "@/lib/connect-wallet/components/logos/AvaxLogo";
import KovanLogo from "@/lib/connect-wallet/components/logos/KovanLogo";
import RopstenLogo from "@/lib/connect-wallet/components/logos/RopstenLogo";
import BSCLogo from "../components/logos/BSCLogo";
Expand Down Expand Up @@ -68,6 +69,17 @@ export const chains = [
rpcUrls: rpcUrls[80001],
blockExplorerUrls: ["https://mumbai.polygonscan.com/"],
},
{
chainId: `0x${(43113).toString(16)}`,
chainName: "Fuji",
nativeCurrency: {
name: "AVAX",
symbol: "AVAX",
decimals: 18,
},
rpcUrls: rpcUrls[43113],
blockExplorerUrls: ["https://testnet.snowtrace.io/"],
},
{
chainId: `0x${(1).toString(16)}`,
chainName: "Ethereum Mainnet",
Expand Down Expand Up @@ -108,6 +120,7 @@ export const NetworkNames = {
97: "BSC Testnet",
137: "Polygon Mainnet",
80001: "Polygon Testnet Mumbai",
43113: "Fuji (Avalance C-Chain)",
1: "Ethereum Mainnet",
3: "Ropsten Testnet",
42: "Kovan Testnet",
Expand All @@ -117,6 +130,7 @@ export const ChainLogos = {
56: BSCLogo,
97: BSCLogo,
80001: PolygonLogo,
43113: AvaxLogo,
137: PolygonLogo,
1: EthLogo,
3: RopstenLogo,
Expand All @@ -134,6 +148,7 @@ export const explorer = {
42: "https://kovan.etherscan.io/address/%s",
1: "https://etherscan.io/address/%s",
80001: "https://mumbai.polygonscan.com/address/%s",
43113: "https://testnet.snowtrace.io/address/%s",
137: "https://polygonscan.com/address/%s",
},
tx: {
Expand All @@ -143,6 +158,7 @@ export const explorer = {
42: "https://kovan.etherscan.io/tx/%s",
1: "https://etherscan.io/tx/%s",
80001: "https://mumbai.polygonscan.com/tx/%s",
43113: "https://testnet.snowtrace.io/tx/%s",
137: "https://polygonscan.com/tx/%s",
},
block: {
Expand All @@ -152,6 +168,7 @@ export const explorer = {
42: "https://kovan.etherscan.io/block/%s",
1: "https://etherscan.io/block/%s",
80001: "https://mumbai.polygonscan.com/block/%s",
43113: "https://testnet.snowtrace.io/block/%s",
137: "https://polygonscan.com/block/%s",
},
};
1 change: 1 addition & 0 deletions lib/connect-wallet/config/rpcUrls.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const rpcUrls = {
// "https://matic-mumbai.chainstacklabs.com",
// "https://matic-testnet-archive-rpc.bwarelabs.com",
],
43113: ["https://api.avax-test.network/ext/bc/C/rpc"],
137: ["https://polygon-rpc.com/"],
1: [
"https://mainnet.infura.io/v3/04f673a8619b4e3f89a49232d453f6f2",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@fontsource/poppins": "4.5.0",
"@fontsource/sora": "4.5.0",
"@headlessui/react": "^1.4.2",
"@neptunemutual/sdk": "^0.4.5-beta",
"@neptunemutual/sdk": "^0.4.6-beta",
"@web3-react/core": "^6.1.9",
"@web3-react/injected-connector": "^6.0.7",
"bignumber.js": "^9.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Balances/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MintableToken } from "@/components/Balances/MintableToken";
import { useNetwork } from "@/src/context/network";
import { useWeb3React } from "@web3-react/core";
import { config } from "@neptunemutual/sdk";
import { Contract, Provider } from "ethers-multicall";
import { config, multicall } from "@neptunemutual/sdk";
const { Contract, Provider } = multicall;
import { chunk } from "@/src/utils/arrays";
import { useEffect, useState } from "react";
import { getProviderOrSigner } from "@/lib/connect-wallet/utils/web3";
Expand Down
23 changes: 20 additions & 3 deletions src/components/SelectNetwork.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { useNetwork } from "../context/network";

const Network_IDs = ["3", "42", "80001"];
const Network_IDs = ["3", "42", "80001", "43113"];
export const SelectNetwork = () => {
const { network, setNetwork } = useNetwork();

Expand Down Expand Up @@ -31,7 +31,7 @@ export const SelectNetwork = () => {
Select a Network
</h3>
<div className="flex items-center justify-between sm:justify-start sm:space-x-5">
<div className="flex items-center justify-center">
{/* <div className="flex items-center justify-center">
<input
type="radio"
className="w-4 h-4 accent-36309D"
Expand Down Expand Up @@ -65,7 +65,7 @@ export const SelectNetwork = () => {
>
Kovan
</label>
</div>
</div> */}

{/* <div className="flex items-center justify-center">
<input
Expand Down Expand Up @@ -102,6 +102,23 @@ export const SelectNetwork = () => {
Mumbai
</label>
</div>
<div className="flex items-center justify-center">
<input
type="radio"
className="w-4 h-4 accent-36309D"
id="networkChoice2"
name="network"
value="43113"
onChange={handleChange}
checked={"43113" === network}
/>
<label
htmlFor="networkChoice2"
className="ml-1 text-sm text-gray-800 font-inter"
>
Fuji
</label>
</div>
</div>
</form>
</>
Expand Down
Loading

0 comments on commit 8d6477b

Please sign in to comment.