1import React, { useCallback } from 'react';
2import { Grid, Text, LinkButton, H5 } from 'indigo-react';
3import { Just } from 'folktale/maybe';
5import { useWallet } from 'store/wallet';
7import { WALLET_TYPES } from 'lib/wallet';
8import { MetamaskWallet } from 'lib/metamask';
9import useLoginView from 'lib/useLoginView';
11import SubmitButton from 'form/SubmitButton';
12import BridgeForm from 'form/BridgeForm';
14export default function Metamask({ className, goHome }) {
15 useLoginView(WALLET_TYPES.METAMASK);
16 const { setWallet, setWalletType } = useWallet();
18 const onSubmit = useCallback(async () => {
19 const accounts = await window.ethereum.enable();
20 const wallet = new MetamaskWallet(accounts[0]);
21 setWallet(Just(wallet));
22 setWalletType(WALLET_TYPES.METAMASK);
23 }, [setWallet, setWalletType]);
26 <Grid className={className}>
27 {(window.ethereum && Login({ onSubmit, goHome })) || Unsupported()}
32function Unsupported() {
35 <Grid.Item full as={H5}>
38 <Grid.Item full as={Text} className="f6 mb3">
39 Metamask is not installed on this browser. <br />
40 <LinkButton href="https://metamask.io" as={LinkButton}>
47function Login({ onSubmit, goHome }) {
50 <Grid.Item full as={H5}>
51 Authenticate with Metamask
53 <Grid.Item full as={Text} className="f6 mb3">
54 If you wish to login with a different wallet, please change it in the
57 <BridgeForm onSubmit={onSubmit} afterSubmit={goHome}>
58 {({ handleSubmit }) => (
59 <Grid.Item full as={SubmitButton} handleSubmit={handleSubmit}>
61 {window.ethereum.selectedAddress &&
62 ' as ' + window.ethereum.selectedAddress}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list