Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused state to clean code #837

Open
wants to merge 1 commit into
base: testnet3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions website/src/tabs/record/DecryptRecord.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const DecryptRecord = () => {
const [ciphertext, setCiphertext] = useState(null);
const [viewKey, setViewKey] = useState(null);
const [plaintext, setPlaintext] = useState(null);
const [_isOwner, setIsOwner] = useState(null);
const [aleo] = useAleoWASM();

const onCiphertextChange = (event) => {
Expand Down Expand Up @@ -36,17 +35,14 @@ export const DecryptRecord = () => {
setPlaintext(
aleo.ViewKey.from_string(viewKey).decrypt(ciphertext),
);
setIsOwner(true);
}
} catch (error) {
console.warn(error);
try {
// If the ciphertext is valid, but the view key is not, then we can still display the info about ownership
aleo.RecordCiphertext.fromString(ciphertext);
setIsOwner(false);
} catch (error) {
// If the ciphertext is invalid, then we can't display any info about ownership or the plaintext content
setIsOwner(null);
console.warn(error);
}
if (plaintext !== null) {
Expand All @@ -67,7 +63,6 @@ export const DecryptRecord = () => {
setCiphertext(null);
setViewKey(null);
setPlaintext(null);
setIsOwner(null);
};

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 21 } };
Expand All @@ -87,7 +82,7 @@ export const DecryptRecord = () => {
extra={
<Button
type="primary"

size="middle"
onClick={populateForm}
>
Expand Down Expand Up @@ -121,7 +116,7 @@ export const DecryptRecord = () => {
<Row justify="center">
<Col>
<Button

size="middle"
onClick={clearForm}
>
Expand Down