From 4f8f63463c0f54a4021280f66d7e319cdb6af951 Mon Sep 17 00:00:00 2001 From: ChiaChi Tsai Date: Thu, 6 Jul 2023 17:01:22 +0800 Subject: [PATCH] another bugs --- components/ProposalCard.tsx | 31 +++++++++++++++++++------------ components/proposalSignForm.tsx | 25 ++++++++++++++++++++----- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/components/ProposalCard.tsx b/components/ProposalCard.tsx index 7b3ef65c..ba539e93 100644 --- a/components/ProposalCard.tsx +++ b/components/ProposalCard.tsx @@ -1,5 +1,6 @@ import { InfoCircledIcon, TriangleDownIcon } from "@radix-ui/react-icons"; -import { useContext, useState } from "react"; +import { useContext, useState, useMemo } from "react"; +import { render } from "react-dom"; import { AppStateContext } from "../context/state"; import { proposalContent } from "../types/display"; import { walletToken } from "../utils/useWalletTokens"; @@ -7,6 +8,7 @@ import { signers } from "../versioned/apis"; import Alias from "./Alias"; import RenderProposalContentLambda, { labelOfProposalContentLambda, + contentToData, } from "./RenderProposalContentLambda"; import RenderProposalContentMetadata, { labelOfProposalContentMetadata, @@ -51,6 +53,21 @@ const ProposalCard = ({ const resolveDate = new Date(resolver?.timestamp ?? 0); const allSigners = signers(state.contracts[currentContract]); + const rows = useMemo( + () => content.map(v => contentToData(v, walletTokens)), + content + ); + const renderRow = () => { + const tmp = []; + for (let i = 0; i < rows.length; i++) { + metadataRender + ? tmp.push( + + ) + : tmp.push(); + } + return tmp; + }; return (
Params/Tokens
- {content.map((v, i) => - metadataRender ? ( - - ) : ( - - ) - )} + {renderRow().map(v => v)}
diff --git a/components/proposalSignForm.tsx b/components/proposalSignForm.tsx index d9513e20..19bc5c84 100644 --- a/components/proposalSignForm.tsx +++ b/components/proposalSignForm.tsx @@ -2,7 +2,7 @@ import { NetworkType } from "@airgap/beacon-sdk"; import { InfoCircledIcon } from "@radix-ui/react-icons"; import { Field, Form, Formik } from "formik"; import { useRouter } from "next/router"; -import React, { useContext, useState } from "react"; +import React, { useContext, useState, useMemo } from "react"; import { MODAL_TIMEOUT, PREFERED_NETWORK } from "../context/config"; import { AppStateContext } from "../context/state"; import { version, proposal } from "../types/display"; @@ -160,7 +160,10 @@ function ProposalSignForm({ threshold, signers(state.contracts[currentContract]).length ); - const rows = proposal.ui.content.map(v => contentToData(v, walletTokens)); + const rows = useMemo( + () => proposal.ui.content.map(v => contentToData(v, walletTokens)), + proposal.ui.content + ); return ( Params/Tokens
- {rows.map((v, i) => ( - - ))} + {rows.length > 0 + ? rows.map((v, i) => ( + + )) + : []}
{!!proposal.ui.content.find( v => @@ -227,6 +232,16 @@ function ProposalSignForm({ proposals )} + {!!rows.find(v => v.label == "Execute lambda") && ( + + We strongly advise that refrain from signing this proposal + unless you have a complete understanding of the potential + consequences. Please be aware that the "Metadata" may not + accurately reflect the actual behavior of the "Execute Lambda" + function. It is crucial to verify the behavior on the + "Param/Token." + + )}

Action:{" "}