Skip to content

Commit

Permalink
fix: verify simulations (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
ganchoradkov authored Nov 4, 2024
1 parent 0ccd5f9 commit 5aa7b75
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ const SelectOption = styled.option`
`;

const OriginSimulationDropdown = (props: OriginSimulationProps) => {
const { origin, show } = props;
const { show } = props;
const [selectedOrigin, setSelectedOrigin] = React.useState(props.origin);
React.useEffect(() => {
if (!show) {
return;
}

setSelectedOrigin(
localStorage.getItem("wallet_connect_dapp_origin") || props.origin
);
}, [show]);

const setOrigin = React.useCallback((origin: string) => {
localStorage.setItem("wallet_connect_dapp_origin", origin);
location.reload();
Expand All @@ -36,13 +47,15 @@ const OriginSimulationDropdown = (props: OriginSimulationProps) => {
<div>
{show && (
<SelectContainer
value={origin}
value={selectedOrigin}
onChange={(e) => setOrigin(e?.target?.value)}
>
<option disabled>Origin Url:</option>
{ORIGIN_OPTIONS.map((e, i) => {
const seleted = e.value === selectedOrigin;
console.log("selected", seleted, e.value);
return (
<SelectOption key={i} value={e.value}>
<SelectOption key={i} value={e.value} selected={seleted}>
{e.label}
</SelectOption>
);
Expand Down
13 changes: 12 additions & 1 deletion advanced/dapps/react-dapp-v2/src/contexts/ClientContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,18 @@ export function ClientContextProvider({
logger: DEFAULT_LOGGER,
relayUrl: relayerRegion,
projectId: DEFAULT_PROJECT_ID,
metadata: {
name: "React App",
description: "App to test WalletConnect network",
url: claimedOrigin,
icons: [],
},
});

if (claimedOrigin === "unknown") {
//@ts-expect-error - private property
_client.core.verify.verifyUrlV3 = "0xdeafbeef";
console.log("verify", _client.core.verify);
}
setClient(_client);
setOrigin(_client.metadata.url);
console.log("metadata url:", _client.metadata);
Expand All @@ -323,6 +333,7 @@ export function ClientContextProvider({
useEffect(() => {
const claimedOrigin =
localStorage.getItem("wallet_connect_dapp_origin") || origin;
console.log("claimedOrigin:", claimedOrigin);
let interval: NodeJS.Timer;
// simulates `UNKNOWN` validation by removing the verify iframe thus preventing POST message
if (claimedOrigin === "unknown") {
Expand Down

0 comments on commit 5aa7b75

Please sign in to comment.