diff --git a/components/ProposalCard.tsx b/components/ProposalCard.tsx index af44c48b..cc35d1a0 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, @@ -42,6 +44,10 @@ const ProposalCard = ({ shouldResolve = false, metadataRender = false, }: ProposalCardProps) => { + const rows = useMemo( + () => content.map(v => contentToData(v, walletTokens)), + content + ); const state = useContext(AppStateContext)!; const currentContract = state.currentContract ?? ""; @@ -52,6 +58,18 @@ const ProposalCard = ({ const allSigners = signers(state.contracts[currentContract]); + const renderRow = () => { + const tmp = []; + for (let i = 0; i < rows.length; i++) { + metadataRender + ? tmp.push( + + ) + : tmp.push(); + } + return tmp; + }; + return (
Amount Address Entrypoint - Params/Token + Params/Tokens
- {content.map((v, i) => - metadataRender ? ( - - ) : ( - - ) - )} + {renderRow().map(v => v)}
diff --git a/components/RenderProposalContentLambda.tsx b/components/RenderProposalContentLambda.tsx index 9b41b69d..f57e2a64 100644 --- a/components/RenderProposalContentLambda.tsx +++ b/components/RenderProposalContentLambda.tsx @@ -19,15 +19,10 @@ type data = { params: undefined | string; }; -const RenderProposalContentLambda = ({ - content, - walletTokens, -}: { - content: proposalContent; - walletTokens: walletToken[]; -}) => { - const [hasParam, setHasParam] = useState(false); - +export const contentToData = ( + content: proposalContent, + walletTokens: walletToken[] +): data => { let data: data = { label: undefined, metadata: undefined, @@ -233,6 +228,12 @@ const RenderProposalContentLambda = ({ }; } } + return data; +}; + +const RenderProposalContentLambda = ({ data }: { data: data }) => { + const [hasParam, setHasParam] = useState(false); + console.log("data", data); return (
@@ -308,7 +309,7 @@ const RenderProposalContentLambda = ({ !data.params ? "text-zinc-500" : "" } justify-self-end text-right`} > -

Params/Token

+

Params/Tokens

{!!data.params ? `${ diff --git a/components/proposalSignForm.tsx b/components/proposalSignForm.tsx index 879d842b..b803328b 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"; @@ -10,7 +10,9 @@ import { canExecute, canReject } from "../utils/proposals"; import { walletToken } from "../utils/useWalletTokens"; import { VersionedApi, signers } from "../versioned/apis"; import ErrorMessage from "./ErrorMessage"; -import RenderProposalContentLambda from "./RenderProposalContentLambda"; +import RenderProposalContentLambda, { + contentToData, +} from "./RenderProposalContentLambda"; import Tooltip from "./Tooltip"; import ContractLoader from "./contractLoader"; @@ -35,6 +37,10 @@ function ProposalSignForm({ walletTokens: walletToken[]; onSuccess?: () => void; }) { + const rows = useMemo( + () => proposal.ui.content.map(v => contentToData(v, walletTokens)), + proposal.ui.content + ); const state = useContext(AppStateContext)!; const currentContract = state.currentContract ?? ""; @@ -158,6 +164,9 @@ function ProposalSignForm({ threshold, signers(state.contracts[currentContract]).length ); + const isSignOrResolve = + (typeof modalState === "boolean" && modalState) || + (typeof modalState !== "boolean" && isExecutable); return ( Amount Address Entrypoint - Parameters + Params/Tokens
- {proposal.ui.content.map((v, i) => ( - - ))} + {rows.length > 0 + ? rows.map((v, i) => ( + + )) + : []}
- {!!proposal.ui.content.find( - v => - "addOwners" in v || - "removeOwners" in v || - "changeThreshold" in v || - "adjustEffectivePeriod" in v - ) && ( - - This proposal will update the settings for all the active - proposals - - )} + {isSignOrResolve && + !!proposal.ui.content.find( + v => + "addOwners" in v || + "removeOwners" in v || + "changeThreshold" in v || + "adjustEffectivePeriod" in v + ) && ( + + This proposal will update the settings for all the active + proposals + + )} + {isSignOrResolve && + !!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:{" "}