Skip to content

Commit

Permalink
Merge pull request #23 from fluencelabs/add-btn-for-wallet
Browse files Browse the repository at this point in the history
Add wallet button on proof page
  • Loading branch information
Akim authored Mar 18, 2024
2 parents a279b01 + 4f29b19 commit 16180a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions web/src/context/web3Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const defaultProvider = new providers.JsonRpcProvider(
export const Web3Context = createContext(null);

export const Web3ContextProvider = ({ children }) => {
const { open, close } = useWeb3Modal()
const { open } = useWeb3Modal()
const [provider, setProvider] = useState(defaultProvider);
const { walletProvider } = useWeb3ModalProvider();
const { address, chainId, isConnected } = useWeb3ModalAccount();
const { address } = useWeb3ModalAccount();
const { disconnect: disconnectWallet } = useDisconnect();

const connect = useCallback(async () => {
Expand Down
19 changes: 7 additions & 12 deletions web/src/pages/proof-page/proof-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import styles from "./proof-page.module.css";
import { hideString } from "../../utils";

import { checkHasClaimed, storeProof } from "../../store/actions/governance";
import { ROUTE_CLAIMED, ROUTE_DONE } from "../../constants/routes";
import { ROUTE_CLAIMED, ROUTE_DONE, ROUTE_WALLET } from "../../constants/routes";
import { toast } from "react-toastify";
import { Buffer } from "buffer";
import { findEthereumSig } from "../../utils/asn1";
Expand All @@ -27,8 +27,6 @@ import abis from "../../contracts";

const ProofPage = () => {
const { address, provider, network } = useWeb3Connection();
const { proof } = useSelector((state) => state.governance.values);
const [haveProof, setHaveProof] = useState(!!proof);
const { hasClaimed } = useSelector((state) => state.governance);
console.log("address", address);

Expand All @@ -46,17 +44,14 @@ const ProofPage = () => {
}
}, [hasClaimed]);

function fromHex(str) {
if (str.startsWith("0x")) {
return Buffer.from(str.slice(2), "hex");
} else {
return Buffer.from(str, "hex");
}
}

const handleForm = async (e) => {
e.preventDefault();

if (!address) {
navigate(ROUTE_WALLET);
return;
}

try {
// TODO: validate data better
let [userId, tmpEthAddrNoPrefix, signatureHex, merkleProofHex] =
Expand Down Expand Up @@ -292,7 +287,7 @@ const ProofPage = () => {
</ul>

<div className={styles.dashboard__button}>
<Button type="large" text="Submit proof" />
<Button type="large" text={address ? "Submit proof" : "Connect wallet"} />
</div>
<p className={styles.dashboard__paragraph}>
If you are not comfortable submiting the proof via web UI, you
Expand Down

0 comments on commit 16180a7

Please sign in to comment.