From 670e85889b85ba344393ff42deb29d65e02656c5 Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Mon, 2 Mar 2026 14:03:36 +0300 Subject: [PATCH] make parsed calldata adaptive Signed-off-by: Uncle Fatso --- package.json | 2 +- src/containers/Governance/NewProposal.jsx | 50 +++++--- src/containers/Governance/ProposalDetails.jsx | 70 ++++++++---- .../components/functions/AuditReserves.jsx | 8 -- .../components/functions/CreateBond.jsx | 7 +- .../components/functions/SetAdjustment.jsx | 6 +- .../Governance/components/functions/index.jsx | 108 ++++++++++++++---- 7 files changed, 172 insertions(+), 79 deletions(-) diff --git a/package.json b/package.json index df7de01..f345d6e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.5.33", + "version": "0.5.34", "type": "module", "scripts": { "dev": "vite", diff --git a/src/containers/Governance/NewProposal.jsx b/src/containers/Governance/NewProposal.jsx index da2680b..ebafebe 100644 --- a/src/containers/Governance/NewProposal.jsx +++ b/src/containers/Governance/NewProposal.jsx @@ -200,21 +200,41 @@ const NewProposal = ({ config, address, connect, chainId }) => { } > - - - - - Function - Target - Calldata - Value - - - {proposalFunctions.map((metadata, index) => { - return parseFunctionCalldata(metadata, index, chainId, nativeCurrency, removeCalldata); - })} -
-
+ {isSmallScreen + ? + {proposalFunctions?.map((metadata, index) => { + return parseFunctionCalldata({ + metadata, + index, + chainId, + removeCalldata, + nativeCoin: nativeCurrency, + isTable: false, + }); + })} + + : + + + + Function + Target + Calldata + Value + + + {proposalFunctions?.map((metadata, index) => { + return parseFunctionCalldata({ + metadata, + index, + chainId, + removeCalldata, + nativeCoin: nativeCurrency, + }); + })} +
+
+ } } diff --git a/src/containers/Governance/ProposalDetails.jsx b/src/containers/Governance/ProposalDetails.jsx index 0b80804..dc3654e 100644 --- a/src/containers/Governance/ProposalDetails.jsx +++ b/src/containers/Governance/ProposalDetails.jsx @@ -216,15 +216,20 @@ const ProposalDetails = ({ chainId, address, connect, config }) => { }} > - + - + {!isSmallScreen && Progress - + } { disabled={proposalState !== 1 || pastVotes?._value === 0n || isPending} onClick={() => handleVote(1)} > - For + {isPending ? "Voting..." : "For"} handleVote(0)} > - Against + {isPending ? "Voting..." : "Against"} : { } > - - - - - Function - Target - Calldata - Value - - - {proposalDetails?.map((metadata, index) => { - return parseFunctionCalldata(metadata, index, chainId, nativeCurrency); - })} -
-
+ {isSmallScreen + ? + {proposalDetails?.map((metadata, index) => { + return parseFunctionCalldata({ + metadata, + index, + chainId, + nativeCoin: nativeCurrency, + isTable: false, + }); + })} + + : + + + + Function + Target + Calldata + Value + + + {proposalDetails?.map((metadata, index) => { + return parseFunctionCalldata({ + metadata, + index, + chainId, + nativeCoin: nativeCurrency, + }); + })} +
+
+ }
@@ -418,7 +441,12 @@ const VotingTimeline = ({ connect, handleExecute, handleRelease, proposalLocked, disabled={isPending || state !== 4} onClick={() => address === "" ? connect() : handleExecute()} > - {address === "" ? "Connect" : state === 4 ? "Execute" : convertStatusToLabel(state)} + {address === "" + ? "Connect" + : state !== 4 + ? convertStatusToLabel(state) + : isPending ? "Executing..." : "Execute" + }
diff --git a/src/containers/Governance/components/functions/AuditReserves.jsx b/src/containers/Governance/components/functions/AuditReserves.jsx index f7655f8..1c09d46 100644 --- a/src/containers/Governance/components/functions/AuditReserves.jsx +++ b/src/containers/Governance/components/functions/AuditReserves.jsx @@ -27,13 +27,5 @@ export const AuditReservesSteps = () => { } export const AuditReservesParsed = (props) => { - return ( - <> - {props.isTable && } - - ) -} - -const AuditReservesParsedCell = (props) => { return } diff --git a/src/containers/Governance/components/functions/CreateBond.jsx b/src/containers/Governance/components/functions/CreateBond.jsx index 5ebbd95..7a67b35 100644 --- a/src/containers/Governance/components/functions/CreateBond.jsx +++ b/src/containers/Governance/components/functions/CreateBond.jsx @@ -34,6 +34,7 @@ export const prepareCreateBondDescription = "function creates a new bond market export const CreateBondParsed = (props) => { const [isOpened, setIsOpened] = useState(false); const { symbol: ftsoSymbol } = useTokenSymbol(props.chainId, "FTSO"); + console.log(props) return ( <> { - {props.isTable && } + ) } -const CreateBondParsedCell = (props) => { - return -} - export const CreateBondSteps = ({ nativeCurrency, ftsoSymbol, chainId, toInitialStep, addCalldata, args }) => { const createMode = args === undefined; diff --git a/src/containers/Governance/components/functions/SetAdjustment.jsx b/src/containers/Governance/components/functions/SetAdjustment.jsx index 4a02f87..af2411d 100644 --- a/src/containers/Governance/components/functions/SetAdjustment.jsx +++ b/src/containers/Governance/components/functions/SetAdjustment.jsx @@ -45,15 +45,11 @@ export const SetAdjustmentParsed = (props) => { - {props.isTable && } + ) } -const SetAdjustmentParsedCell = (props) => { - return -} - export const SetAdjustmentSteps = ({ chainId, toInitialStep, addCalldata, args }) => { const createMode = args === undefined; diff --git a/src/containers/Governance/components/functions/index.jsx b/src/containers/Governance/components/functions/index.jsx index ca7e58f..7caf7a1 100644 --- a/src/containers/Governance/components/functions/index.jsx +++ b/src/containers/Governance/components/functions/index.jsx @@ -44,7 +44,14 @@ const identifyAction = (calldata) => { return decoded; } -export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, removeCalldata) => { +export const parseFunctionCalldata = ({ + metadata, + index, + chainId, + nativeCoin, + removeCalldata, + isTable = true, +}) => { const { label, calldata, target, value } = metadata; const { functionName, args } = identifyAction(calldata); const labelOrName = label ?? (functionName ?? "Unknown"); @@ -54,7 +61,7 @@ export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, remo switch (functionName) { case "auditReserves": return ; case "setAdjustment": return ; case "create": return ; default: return { const [isCopied, setIsCopied] = useState(false); @@ -275,34 +283,86 @@ export const ParsedCell = (props) => { } }; - return ( - - - {props.label} - + if (props.isTable) { + return ( + + + {props.label} + - + + + {shorten(props.target)} + + + + + + {shorten(props.calldata)} + + + + + {formatCurrency(props.value, 4, props.nativeCoin)} + + + +
+ {props.args && props.setIsOpened(!props.isOpened)}>View} + {props.remove && props.remove()}>Delete} +
+
+
+ ) + } + + return ( + + + {`Function ${props.id + 1}`} + {props.label} + + + + Target {shorten(props.target)} - + - + + Calldata {shorten(props.calldata)} - + - - {formatCurrency(props.value, 4, props.nativeCoin)} - + + Value + + {formatCurrency(props.value, 4, props.nativeCoin)} + + - -
- {props.args && props.setIsOpened(!props.isOpened)}>View} - {props.remove && props.remove()}>Delete} -
-
-
+ {(props.args || props.remove) && + {props.args && props.setIsOpened(!props.isOpened)}>View} + {props.remove && props.remove()}>Delete} + } + +
+ + ) + }