Skip to content

Commit

Permalink
another bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rueshyna committed Jul 6, 2023
1 parent 0da4420 commit 4f8f634
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
31 changes: 19 additions & 12 deletions components/ProposalCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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";
import { signers } from "../versioned/apis";
import Alias from "./Alias";
import RenderProposalContentLambda, {
labelOfProposalContentLambda,
contentToData,
} from "./RenderProposalContentLambda";
import RenderProposalContentMetadata, {
labelOfProposalContentMetadata,
Expand Down Expand Up @@ -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(
<RenderProposalContentMetadata key={i} content={content[i]} />
)
: tmp.push(<RenderProposalContentLambda key={i} data={rows[i]} />);
}
return tmp;
};

return (
<div
Expand Down Expand Up @@ -170,17 +187,7 @@ const ProposalCard = ({
<span className="justify-self-end">Params/Tokens</span>
</div>
<div className="mt-2 space-y-4 font-light lg:space-y-2">
{content.map((v, i) =>
metadataRender ? (
<RenderProposalContentMetadata key={i} content={v} />
) : (
<RenderProposalContentLambda
key={i}
content={v}
walletTokens={walletTokens}
/>
)
)}
{renderRow().map(v => v)}
</div>
</section>
<section className="text-xs md:text-base">
Expand Down
25 changes: 20 additions & 5 deletions components/proposalSignForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 (
<Formik
Expand Down Expand Up @@ -211,9 +214,11 @@ function ProposalSignForm({
<span className="justify-self-end">Params/Tokens</span>
</div>
<div className="mt-2 space-y-4 font-light lg:space-y-2">
{rows.map((v, i) => (
<RenderProposalContentLambda data={v} key={i} />
))}
{rows.length > 0
? rows.map((v, i) => (
<RenderProposalContentLambda data={v} key={i} />
))
: []}
</div>
{!!proposal.ui.content.find(
v =>
Expand All @@ -227,6 +232,16 @@ function ProposalSignForm({
proposals
</span>
)}
{!!rows.find(v => v.label == "Execute lambda") && (
<span className="mt-2 text-xs font-light text-yellow-500">
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."
</span>
)}
</section>
<p className="mt-8 text-lg font-medium text-white">
Action:{" "}
Expand Down

0 comments on commit 4f8f634

Please sign in to comment.