Skip to content

Commit

Permalink
fix wallet connect, use just 1 unpkg script
Browse files Browse the repository at this point in the history
  • Loading branch information
KatunaNorbert committed Oct 31, 2022
1 parent 77d7879 commit 7a4abc2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
4 changes: 0 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
<link rel='icon' type='image/png' href='/logo-ocean-svg.svg'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<script src="https://unpkg.com/web3@latest/dist/web3.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/web3modal"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/umd/index.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@walletconnect/web3-provider"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/fortmatic.js"></script>
<script defer src='/build/bundle.js'></script>
</head>
<body>
Expand Down
4 changes: 0 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ const htmlOptions = {
<link rel='icon' type='image/png' href='/logo-ocean-svg.svg'>
<link rel='stylesheet' href='/global.css'>
${css ? css : "<link rel='stylesheet' href='/build/bundle.css'>"}
<script src="https://unpkg.com/web3@latest/dist/web3.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/web3modal"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/umd/index.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@walletconnect/web3-provider"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/fortmatic.js"></script>
${script}
</head>
<body>
Expand Down
10 changes: 2 additions & 8 deletions src/stores/web3.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { writable } from "svelte/store";
import { ethers, BigNumber } from "ethers";
import Web3Modal from "web3modal"
import * as networksDataArray from "../networks-metadata.json";

export let web3 = writable("")
export let userAddress = writable("");
export let poolContracts = writable("");
export let web3Provider = writable("");
Expand All @@ -14,13 +14,11 @@ export let isWalletConnectModalOpen = writable(false)

export const GASLIMIT_DEFAULT = 1000000;

const Web3 = window.Web3
const Web3Modal = window.Web3Modal.default;
const WalletConnectProvider = window.WalletConnectProvider.default;

const providerOptions = {
walletconnect: {
provider: WalletConnectProvider,
package: WalletConnectProvider,
options: {
// Mikko's test key - don't copy as your mileage may vary
infuraId: process.env.INFURA_KEY,
Expand Down Expand Up @@ -63,7 +61,6 @@ export const setValuesAfterConnection = async (instance) => {
const provider = new ethers.providers.Web3Provider(instance);
const signer = provider.getSigner();
networkSigner.set(signer);
web3.set(new Web3(instance))
const signerAddress = await signer.getAddress();
const chainId= (await provider.getNetwork()).chainId;

Expand Down Expand Up @@ -171,9 +168,6 @@ export const connectWallet = async () => {

export const disconnect = async () => {
await web3Modal?.clearCachedProvider();
if (web3 && web3.currentProvider && web3.currentProvider.close) {
await web3.currentProvider.close();
}
userAddress.set(undefined);
networkSigner.set(undefined);
localStorage.removeItem("walletconnect");
Expand Down

0 comments on commit 7a4abc2

Please sign in to comment.