Check dapp url before metamask login (#191)
This commit is contained in:
parent
7581693fe6
commit
c6c81e1ea2
|
@ -78,6 +78,7 @@ function DragDiv() {
|
|||
config={{
|
||||
communityKey: process.env.COMMUNITY_KEY ?? "",
|
||||
environment: process.env.ENV ?? "",
|
||||
dappUrl: "https://0.0.0.0:8080",
|
||||
}}
|
||||
fetchMetadata={fetchMetadata}
|
||||
/>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { genPrivateKeyWithEntropy } from "@waku/status-communities/dist/cjs/util
|
|||
import React, { useCallback } from "react";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { useConfig } from "../../contexts/configProvider";
|
||||
import {
|
||||
useSetIdentity,
|
||||
useSetWalletIdentity,
|
||||
|
@ -29,9 +30,14 @@ export function WalletModal() {
|
|||
const { setModal: setWalleConnectModal } = useModal(WalletConnectModalName);
|
||||
const { setModal: setCoinbaseModal } = useModal(CoinbaseModalName);
|
||||
const { messenger } = useMessengerContext();
|
||||
const { dappUrl } = useConfig();
|
||||
|
||||
const handleMetamaskClick = useCallback(async () => {
|
||||
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) {
|
||||
try {
|
||||
if (ethereum?.isMetaMask) {
|
||||
|
@ -47,7 +53,7 @@ export function WalletModal() {
|
|||
},
|
||||
message: {
|
||||
action: "Status Chat Key",
|
||||
onlySignOn: "https://auth.status.im/",
|
||||
onlySignOn: dappUrl,
|
||||
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.",
|
||||
},
|
||||
|
|
|
@ -3,11 +3,13 @@ import React, { createContext, useContext } from "react";
|
|||
export type ConfigType = {
|
||||
communityKey: string;
|
||||
environment: string;
|
||||
dappUrl: string;
|
||||
};
|
||||
|
||||
const ConfigContext = createContext<ConfigType>({
|
||||
communityKey: "",
|
||||
environment: "production",
|
||||
dappUrl: "",
|
||||
});
|
||||
|
||||
export function useConfig() {
|
||||
|
|
Loading…
Reference in New Issue