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 %}
|
||||
{% if not current_user.is_authenticated %}
|
||||
<li>
|
||||
<a
|
||||
href="https://join.status.im/b/{{url_for('main.index', _external=True)}}"
|
||||
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"
|
||||
>
|
||||
<span>Connect wallet</span>
|
||||
</a>
|
||||
|
||||
<button
|
||||
id="connectWalletBtn"
|
||||
type="button"
|
||||
data-is-mobile="true"
|
||||
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>
|
||||
{% endif %}
|
||||
<li>
|
||||
|
|
|
@ -14,21 +14,22 @@ export function initWallet() {
|
|||
const origin = window.location.origin;
|
||||
// connect to ethereum network and sign transactions with Metamask
|
||||
|
||||
async function signInWithEthereum() {
|
||||
async function signInWithEthereum(isMobile: boolean) {
|
||||
if (!window.hasOwnProperty('ethereum')) {
|
||||
let result = confirm(
|
||||
"You don't have needed extension! Do you want to install it?",
|
||||
);
|
||||
localStorage.setItem('showExtensionAlert', 'false');
|
||||
if (result) {
|
||||
window.open('https://metamask.io/', '_blank');
|
||||
if (isMobile) {
|
||||
location.replace(`https://join.status.im/b/https://${domain}`);
|
||||
} else {
|
||||
let result = confirm(
|
||||
"You don't have needed extension! Do you want to install it?",
|
||||
);
|
||||
localStorage.setItem('showExtensionAlert', 'false');
|
||||
if (result) {
|
||||
window.open('https://metamask.io/', '_blank');
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!window.hasOwnProperty('ethereum')) {
|
||||
console.error('Required extension not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const eOwner: IEthereumOwner = window as any;
|
||||
const provider = new ethers.providers.Web3Provider(eOwner.ethereum);
|
||||
const signer = provider.getSigner();
|
||||
|
@ -69,7 +70,8 @@ export function initWallet() {
|
|||
if (connectWalletBtns) {
|
||||
connectWalletBtns.forEach(btn =>
|
||||
btn.addEventListener('click', () => {
|
||||
signInWithEthereum();
|
||||
const isMobile = !!btn.getAttribute('data-is-mobile');
|
||||
signInWithEthereum(isMobile);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue