mirror of https://github.com/logos-co/open-law.git
fix connect wallet btn
This commit is contained in:
parent
992e2ccca2
commit
b2689ad647
File diff suppressed because one or more lines are too long
|
@ -67,12 +67,14 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not current_user.is_authenticated %}
|
{% if not current_user.is_authenticated %}
|
||||||
<li>
|
<li>
|
||||||
<a
|
|
||||||
href="https://join.status.im/b/{{url_for('main.index', _external=True)}}"
|
<button
|
||||||
class="md:hidden flex justify-center text-white bg-gradient-to-r from-cyan-500 to-blue-500 hover:bg-gradient-to-bl focus:ring-4 focus:outline-none focus:ring-cyan-300 dark:focus:ring-cyan-800 font-medium rounded-lg text-sm px-5 py-2.5"
|
id="connectWalletBtn"
|
||||||
>
|
type="button"
|
||||||
<span>Connect wallet</span>
|
data-is-mobile="true"
|
||||||
</a>
|
class="md:hidden flex justify-center w-full text-white bg-gradient-to-r from-cyan-500 to-blue-500 hover:bg-gradient-to-bl focus:ring-4 focus:outline-none focus:ring-cyan-300 dark:focus:ring-cyan-800 font-medium rounded-lg text-sm px-5 py-2.5">
|
||||||
|
Connect wallet
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -14,21 +14,22 @@ export function initWallet() {
|
||||||
const origin = window.location.origin;
|
const origin = window.location.origin;
|
||||||
// connect to ethereum network and sign transactions with Metamask
|
// connect to ethereum network and sign transactions with Metamask
|
||||||
|
|
||||||
async function signInWithEthereum() {
|
async function signInWithEthereum(isMobile: boolean) {
|
||||||
if (!window.hasOwnProperty('ethereum')) {
|
if (!window.hasOwnProperty('ethereum')) {
|
||||||
let result = confirm(
|
if (isMobile) {
|
||||||
"You don't have needed extension! Do you want to install it?",
|
location.replace(`https://join.status.im/b/https://${domain}`);
|
||||||
);
|
} else {
|
||||||
localStorage.setItem('showExtensionAlert', 'false');
|
let result = confirm(
|
||||||
if (result) {
|
"You don't have needed extension! Do you want to install it?",
|
||||||
window.open('https://metamask.io/', '_blank');
|
);
|
||||||
|
localStorage.setItem('showExtensionAlert', 'false');
|
||||||
|
if (result) {
|
||||||
|
window.open('https://metamask.io/', '_blank');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!window.hasOwnProperty('ethereum')) {
|
|
||||||
console.error('Required extension not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const eOwner: IEthereumOwner = window as any;
|
const eOwner: IEthereumOwner = window as any;
|
||||||
const provider = new ethers.providers.Web3Provider(eOwner.ethereum);
|
const provider = new ethers.providers.Web3Provider(eOwner.ethereum);
|
||||||
const signer = provider.getSigner();
|
const signer = provider.getSigner();
|
||||||
|
@ -69,7 +70,8 @@ export function initWallet() {
|
||||||
if (connectWalletBtns) {
|
if (connectWalletBtns) {
|
||||||
connectWalletBtns.forEach(btn =>
|
connectWalletBtns.forEach(btn =>
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
signInWithEthereum();
|
const isMobile = !!btn.getAttribute('data-is-mobile');
|
||||||
|
signInWithEthereum(isMobile);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue