Skip to content

Commit

Permalink
Remove PIN_LABELS
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermemntt committed Nov 20, 2020
1 parent 6353455 commit f54ea0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
43 changes: 7 additions & 36 deletions app/components/modals/TrezorModals/TrezorPinModal.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { useState, useMemo, useCallback } from "react";
import { useState, useCallback } from "react";
import { FormattedMessage as T } from "react-intl";
import Modal from "../Modal";
import { PasswordInput } from "inputs";
import { ButtonsToolbar } from "shared";
import { InvisibleButton } from "buttons";
import { PIN_LABELS } from "constants/trezor";
import { classNames } from "pi-ui";
import styles from "./TrezorModals.module.css";

const PinButton = ({ index, onClick }) => (
<div className={styles.pinPadButton} onClick={() => onClick(index)}>
{PIN_LABELS[index - 1]}
</div>
);

const TrezorPinModal = ({
isGetStarted,
device,
Expand All @@ -23,13 +16,6 @@ const TrezorPinModal = ({
}) => {
const [currentPin, setCurrentPin] = useState("");

const onPinButtonClick = useCallback(
(index) => {
setCurrentPin(currentPin + index);
},
[currentPin]
);

const onCancelPinModal = useCallback(() => {
setCurrentPin("");
onCancelModal();
Expand All @@ -43,25 +29,6 @@ const TrezorPinModal = ({
setCurrentPin("");
}, []);

const onChangeCurrentPin = useCallback((e) => {
const txt = (e.target.value || "").toUpperCase().trim();
let pin = "";
for (let i = 0; i < txt.length; i++) {
const idx = PIN_LABELS.indexOf(txt[i]);
if (idx > -1) pin = pin + "" + (idx + 1);
}
setCurrentPin(pin);
}, []);

const currentPinMemo = useMemo(
() =>
currentPin
.split("")
.map((v) => PIN_LABELS[parseInt(v) - 1])
.join(""),
[currentPin]
);

const trezorLabel = device ? deviceLabel : "";

const className = classNames(
Expand All @@ -86,7 +53,11 @@ const TrezorPinModal = ({
<div className={styles.pinPadContainer}>
<div className={styles.pinPad}>
{[7, 8, 9, 4, 5, 6, 1, 2, 3].map((index) => (
<PinButton index={index} onClick={onPinButtonClick} key={index} />
<div
className={styles.pinPadButton}
onClick={() => setCurrentPin(currentPin + index)}>
</div>
))}
</div>
<div>
Expand All @@ -96,7 +67,7 @@ const TrezorPinModal = ({
</div>
</div>
<div className={styles.passwordField}>
<PasswordInput value={currentPinMemo} onChange={onChangeCurrentPin} />
<PasswordInput value={currentPin} disabled={true} />
</div>
<ButtonsToolbar
{...{ onCancelModal: onCancelPinModal, onSubmit }}
Expand Down
2 changes: 0 additions & 2 deletions app/constants/trezor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const PIN_LABELS = "•••••••••";

export const MODEL1_DECRED_HOMESCREEN =
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ffe003ff00000000000000000000007fffc007fe0000000000000000000001ffff800ffc0000000000000000000003ffff001ff8000000000000000000000ffffe003ff0000000000000000000001ffffc007fe0000000000000000000003ffff800ffc0000000000000000000003ffff001ff80000000000000000000007fffe003ff00000000000000000000007ff00007fe0000000000000000000000ffc0000ffc0000000000000000000000ff80001fff0000000000000000000001ff00003fffc000000000000000000001ff00007ffff000000000000000000001fe0000fffff800000000000000000001fe0001fffff800000000000000000001fe0003fffffc00000000000000000001fe0000003ffe00000000000000000001fe00000007fe00000000000000000001fe00000003ff00000000000000000001fe00000001ff00000000000000000001ff00000001ff00000000000000000001ff80000000ff00000000000000000000ffc0000000ff00000000000000000000ffe0000000ff800000000000000000007ffc000000ff800000000000000000007fffff8000ff800000000000000000003fffff0000ff000000000000000000001ffffe0000ff000000000000000000000ffffc0001ff0000000000000000000003fff80001ff0000000000000000000001fff00003ff00000000000000000000007fe00007fe0000000000000000000000ffc0001ffe0000000000000000000001ff800ffffc0000000000000000000003ff001ffff80000000000000000000007fe003ffff8000000000000000000000ffc007ffff0000000000000000000001ff800ffffe0000000000000000000003ff001ffff80000000000000000000007fe003ffff0000000000000000000000ffc007fff80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

Expand Down

0 comments on commit f54ea0b

Please sign in to comment.