diff --git a/package.json b/package.json index 5915ddc..db54760 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.5.11", + "version": "0.5.12", "type": "module", "scripts": { "dev": "vite", diff --git a/src/containers/Bond/components/BondInputArea.jsx b/src/containers/Bond/components/BondInputArea.jsx index 9c395bd..9b42a0a 100644 --- a/src/containers/Bond/components/BondInputArea.jsx +++ b/src/containers/Bond/components/BondInputArea.jsx @@ -86,6 +86,8 @@ const BondInputArea = ({ : bond.capacity.inBaseToken ); + console.log(bond.quoteToken.icons) + return ( diff --git a/src/containers/Governance/components/functions/CreateBond.jsx b/src/containers/Governance/components/functions/CreateBond.jsx index 26e2d7c..d6e44c0 100644 --- a/src/containers/Governance/components/functions/CreateBond.jsx +++ b/src/containers/Governance/components/functions/CreateBond.jsx @@ -2,9 +2,12 @@ import { useRef, useMemo, useState, useEffect } from "react"; import { encodeFunctionData } from 'viem'; import { Box, Typography, TableRow, TableCell, useTheme } from "@mui/material"; +import Modal from "../../../../components/Modal/Modal"; import Select from "../../../../components/Select/Select"; import { PrimaryButton, TertiaryButton } from "../../../../components/Button"; import { shorten } from "../../../../helpers"; +import { useTokenSymbol } from "../../../../hooks/tokens"; + import { BooleanTrigger, ArgumentInput, ParsedCell } from "./index"; import { @@ -29,9 +32,26 @@ export const prepareCreateBondCalldata = (chainId, markets, terms, quoteToken, i export const prepareCreateBondDescription = "Create Bond function creates a new bond market by processing pricing, capacity, and term inputs. It initializes and stores the new bond market's complete configuration in the protocol."; export const CreateBondParsed = (props) => { + const [isOpened, setIsOpened] = useState(false); + const { symbol: ftsoSymbol } = useTokenSymbol(props.chainId, "FTSO"); return ( <> - {props.isTable && } + + View Create Bond + + } + open={isOpened} + onClose={() => setIsOpened(false)} + maxWidth="460px" + minHeight="200px" + > + + + + + {props.isTable && } > ) } @@ -40,23 +60,25 @@ const CreateBondParsedCell = (props) => { return } -export const CreateBondSteps = ({ nativeCurrency, ftsoSymbol, chainId, toInitialStep, addCalldata }) => { +export const CreateBondSteps = ({ nativeCurrency, ftsoSymbol, chainId, toInitialStep, addCalldata, args }) => { + const createMode = args === undefined; + const [step, setStep] = useState(1); const [nextDisabled, setNextDisabled] = useState(false); - const [capacity, setCapacity] = useState(); - const [initialPrice, setInitialPrice] = useState(); - const [debtBuffer, setDebtBuffer] = useState(); + const [capacity, setCapacity] = useState(args?.at(0)?.at(0)); + const [initialPrice, setInitialPrice] = useState(args?.at(0)?.at(1)); + const [debtBuffer, setDebtBuffer] = useState(args?.at(0)?.at(2)); - const [depositInterval, setDepositInterval] = useState(); - const [tuneInterval, setTuneInterval] = useState(); + const [depositInterval, setDepositInterval] = useState(args?.at(3)?.at(0)); + const [tuneInterval, setTuneInterval] = useState(args?.at(3)?.at(1)); - const [tokenAddress, setTokenAddress] = useState(); - const [capacityInQuote, setCapacityInQuote] = useState(true); - const [fixedTerm, setFixedTerm] = useState(false); + const [tokenAddress, setTokenAddress] = useState(args?.at(2)); + const [capacityInQuote, setCapacityInQuote] = useState(args?.at(4)?.at(0) ?? true); + const [fixedTerm, setFixedTerm] = useState(args?.at(4)?.at(1) ?? false); - const [vestingLength, setVestingLength] = useState(); - const [conclusionTimestamp, setConclusionTimestamp] = useState(); + const [vestingLength, setVestingLength] = useState(args?.at(1)?.at(0)); + const [conclusionTimestamp, setConclusionTimestamp] = useState(args?.at(1)?.at(1)); const handleProceed = () => { const markets = [capacity, initialPrice, debtBuffer]; @@ -67,6 +89,8 @@ export const CreateBondSteps = ({ nativeCurrency, ftsoSymbol, chainId, toInitial addCalldata(prepareCreateBondCalldata(chainId, markets, terms, tokenAddress, intervals, booleans)) } + const empty = () => {}; + const incrementStep = () => { setStep(prev => prev + 1); } @@ -99,45 +123,47 @@ export const CreateBondSteps = ({ nativeCurrency, ftsoSymbol, chainId, toInitial return ( {step === 1 && } {step === 2 && } {step === 3 && } {step === 4 && } decrementStep()} fullWidth>Back incrementStep()} fullWidth>Next - {step === 4 && handleProceed()} fullWidth>Create Function} + {(step === 4 && createMode) && handleProceed()} fullWidth>Create Function} ); @@ -237,6 +263,8 @@ const TermsAgruments = ({ } const TokenAndBooleansArguments = ({ + createMode, + tokenAddress, possibleTokens, nativeCurrency, ftsoSymbol, @@ -247,11 +275,13 @@ const TokenAndBooleansArguments = ({ setFixedTerm, }) => { const theme = useTheme(); - const [selectedOption, setSelectedOption] = useState(); + const [selectedOption, setSelectedOption] = useState(tokenAddress); const handleChange = (event) => { - setSelectedOption(event.target.value); - setTokenAddress(event.target.value); + if (createMode) { + setSelectedOption(event.target.value); + setTokenAddress(event.target.value); + } }; return ( diff --git a/src/containers/Governance/components/functions/SetAdjustment.jsx b/src/containers/Governance/components/functions/SetAdjustment.jsx index 32102a3..576cb83 100644 --- a/src/containers/Governance/components/functions/SetAdjustment.jsx +++ b/src/containers/Governance/components/functions/SetAdjustment.jsx @@ -2,6 +2,7 @@ import { useState } from "react"; import { encodeFunctionData } from 'viem'; import { Box, Typography, TableRow, TableCell, useTheme } from "@mui/material"; +import Modal from "../../../../components/Modal/Modal"; import { PrimaryButton, TertiaryButton } from "../../../../components/Button"; import { @@ -26,9 +27,25 @@ export const prepareSetAdjustmentCalldata = (chainId, rateChange, targetRate, in export const prepareSetAdjustmentDescription = "Set Adjustment function schedules a gradual change to the staking APY. It increases or decreases the staking APY by a specified rate per epoch until a target rate reached."; export const SetAdjustmentParsed = (props) => { + const [isOpened, setIsOpened] = useState(false); return ( <> - {props.isTable && } + + View Set Adjustment + + } + open={isOpened} + onClose={() => setIsOpened(false)} + maxWidth="460px" + minHeight="200px" + > + + + + + {props.isTable && } > ) } @@ -37,10 +54,12 @@ const SetAdjustmentParsedCell = (props) => { return } -export const SetAdjustmentSteps = ({ chainId, toInitialStep, addCalldata }) => { - const [rate, setRate] = useState(); - const [target, setTarget] = useState(); - const [increase, setIncrease] = useState(false); +export const SetAdjustmentSteps = ({ chainId, toInitialStep, addCalldata, args }) => { + const createMode = args === undefined; + + const [rate, setRate] = useState(args?.at(0)); + const [target, setTarget] = useState(args?.at(1)); + const [increase, setIncrease] = useState(args?.at(1) ?? true); const handleProceed = () => { addCalldata(prepareSetAdjustmentCalldata(chainId, rate, target, increase)); @@ -53,27 +72,29 @@ export const SetAdjustmentSteps = ({ chainId, toInitialStep, addCalldata }) => { value={increase} leftText="Add" rightText="Sub" - setLeftValue={() => setIncrease(true)} - setRightValue={() => setIncrease(false)} + setLeftValue={() => createMode ? setIncrease(true) : {}} + setRightValue={() => createMode ? setIncrease(false) : {}} label="Direction" tooltip="Determines the direction of the adjustment. When Add the parameter value will gradually increase; when Sub, it will decrease toward the target rate" /> {}} tooltip="Each epoch, the current staking reward rate changes by this amount until the target rate is reached" /> {}} tooltip="The final desired value for the reward rate, the adjustment process will continue automatically until this specific level is reached" /> - + {createMode && Back Next @@ -85,7 +106,7 @@ export const SetAdjustmentSteps = ({ chainId, toInitialStep, addCalldata }) => { > Create Function - + } ); } diff --git a/src/containers/Governance/components/functions/index.jsx b/src/containers/Governance/components/functions/index.jsx index c140f9c..4f44cec 100644 --- a/src/containers/Governance/components/functions/index.jsx +++ b/src/containers/Governance/components/functions/index.jsx @@ -67,8 +67,10 @@ export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, remo case "setAdjustment": return { {formatCurrency(props.value, 2, props.nativeCoin)} - {props.remove && + - alert("Do we need it????")}>Edit - props.remove()}>Delete + {props.args && props.setIsOpened(!props.isOpened)}>View} + {props.remove && props.remove()}>Delete} - } + ) }