Check dapp url before metamask login (#191)
This commit is contained in:
parent
7581693fe6
commit
c6c81e1ea2
|
@ -78,6 +78,7 @@ function DragDiv() {
|
||||||
config={{
|
config={{
|
||||||
communityKey: process.env.COMMUNITY_KEY ?? "",
|
communityKey: process.env.COMMUNITY_KEY ?? "",
|
||||||
environment: process.env.ENV ?? "",
|
environment: process.env.ENV ?? "",
|
||||||
|
dappUrl: "https://0.0.0.0:8080",
|
||||||
}}
|
}}
|
||||||
fetchMetadata={fetchMetadata}
|
fetchMetadata={fetchMetadata}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { genPrivateKeyWithEntropy } from "@waku/status-communities/dist/cjs/util
|
||||||
import React, { useCallback } from "react";
|
import React, { useCallback } from "react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
import { useConfig } from "../../contexts/configProvider";
|
||||||
import {
|
import {
|
||||||
useSetIdentity,
|
useSetIdentity,
|
||||||
useSetWalletIdentity,
|
useSetWalletIdentity,
|
||||||
|
@ -29,9 +30,14 @@ export function WalletModal() {
|
||||||
const { setModal: setWalleConnectModal } = useModal(WalletConnectModalName);
|
const { setModal: setWalleConnectModal } = useModal(WalletConnectModalName);
|
||||||
const { setModal: setCoinbaseModal } = useModal(CoinbaseModalName);
|
const { setModal: setCoinbaseModal } = useModal(CoinbaseModalName);
|
||||||
const { messenger } = useMessengerContext();
|
const { messenger } = useMessengerContext();
|
||||||
|
const { dappUrl } = useConfig();
|
||||||
|
|
||||||
const handleMetamaskClick = useCallback(async () => {
|
const handleMetamaskClick = useCallback(async () => {
|
||||||
const ethereum = (window as any)?.ethereum as any | undefined;
|
const ethereum = (window as any)?.ethereum as any | undefined;
|
||||||
|
if (document.location.origin !== dappUrl) {
|
||||||
|
alert("You are not signing in from correct url!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ethereum && messenger) {
|
if (ethereum && messenger) {
|
||||||
try {
|
try {
|
||||||
if (ethereum?.isMetaMask) {
|
if (ethereum?.isMetaMask) {
|
||||||
|
@ -47,7 +53,7 @@ export function WalletModal() {
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
action: "Status Chat Key",
|
action: "Status Chat Key",
|
||||||
onlySignOn: "https://auth.status.im/",
|
onlySignOn: dappUrl,
|
||||||
message:
|
message:
|
||||||
"I'm aware that i am signing message that creates a private chat key for status communicator. And I have double checked everything is fine.",
|
"I'm aware that i am signing message that creates a private chat key for status communicator. And I have double checked everything is fine.",
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,11 +3,13 @@ import React, { createContext, useContext } from "react";
|
||||||
export type ConfigType = {
|
export type ConfigType = {
|
||||||
communityKey: string;
|
communityKey: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
|
dappUrl: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ConfigContext = createContext<ConfigType>({
|
const ConfigContext = createContext<ConfigType>({
|
||||||
communityKey: "",
|
communityKey: "",
|
||||||
environment: "production",
|
environment: "production",
|
||||||
|
dappUrl: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
export function useConfig() {
|
export function useConfig() {
|
||||||
|
|
Loading…
Reference in New Issue