Skip to content

Commit

Permalink
Merge pull request #20 from jkup/testnet-check
Browse files Browse the repository at this point in the history
Check for user being on the testnet
  • Loading branch information
jkup authored Oct 1, 2021
2 parents 32b7d3a + 72f302b commit 43aa98c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
7 changes: 7 additions & 0 deletions frontend/public/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ main {
text-align: center;
}

.error {
background-color: #b00020;
color: #fff;
padding: 5px 0;
text-align: center;
}

.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
Expand Down
28 changes: 22 additions & 6 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script>
import Contract from "./CFNFT.json";
import { ethers } from "ethers";
import { onMount } from "svelte";
import Contract from "./CFNFT.json";
const CONTRACT_ID = "0x290422EC6eADc2CC12aCd98C50333720382CA86B";
const ethereum = window.ethereum;
let provider, signer, contract, contractWithSigner;
let chain, provider, signer, contract, contractWithSigner;
let maxTokens = -1;
let currentMinted = -1;
Expand All @@ -16,7 +17,11 @@
let ownedTokens = [];
let recentlyMintedTokens = [];
// If Metamask is insalled
onMount(() => {
chain = window.ethereum.networkVersion;
});
// If Metamask is installed
if (ethereum) {
provider = new ethers.providers.Web3Provider(ethereum);
signer = provider.getSigner();
Expand All @@ -28,6 +33,10 @@
account = accounts[0];
});
ethereum.on("chainChanged", function () {
window.location.reload();
});
init();
}
Expand Down Expand Up @@ -117,9 +126,16 @@
</ul>
</header>

<div class="warning">
This marketplace is connected to the Rinkeby test network.
</div>
{#if chain === "4"}
<div class="warning">
This marketplace is connected to the Rinkeby test network.
</div>
{:else}
<div class="error">
This application requires you to be on the Rinkeby network. Use Metamask to
switch networks.
</div>
{/if}

<main>
{#if ethereum}
Expand Down

0 comments on commit 43aa98c

Please sign in to comment.