From fc9b2198e14781f0e86b87ff0b6f1b50af5ea7e8 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:25:56 -0300 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=A9=B9Fix=20resetNewVault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/DeployVault/ConfirmDelpoyModal.tsx | 4 +++- apps/dapp/src/store/lib/features/vaultStore.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx index eec5324c..616acc00 100644 --- a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx +++ b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx @@ -18,6 +18,7 @@ import { ModalContext, TransactionStatusModalStatus } from "@/contexts"; import { AccordionItems, FormControlInterface, VaultPreview } from "./VaultPreview"; import { DialogBody, DialogCloseTrigger, DialogFooter, DialogHeader, DialogTitle } from "../ui/dialog"; import { Button } from "@chakra-ui/react" +import { resetNewVault } from "@/store/lib/features/vaultStore"; interface Status { isSuccess: boolean, @@ -279,8 +280,9 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo ...newVault, address: parsedResult } - txModal.handleSuccess(result.txHash); + await txModal.handleSuccess(result.txHash); dispatch(pushVault(tempVault)); + dispatch(resetNewVault()); return result; } diff --git a/apps/dapp/src/store/lib/features/vaultStore.ts b/apps/dapp/src/store/lib/features/vaultStore.ts index c09fb6f8..7400031f 100644 --- a/apps/dapp/src/store/lib/features/vaultStore.ts +++ b/apps/dapp/src/store/lib/features/vaultStore.ts @@ -97,7 +97,16 @@ export const newVaultSlice = createSlice({ state.TVL = action.payload.TVL; }), resetNewVault: ((state) => { - state = initialState; + state.address = ""; + state.emergencyManager = ""; + state.feeReceiver = ""; + state.manager = ""; + state.name = ""; + state.symbol = ""; + state.vaultShare = 0; + state.assets = []; + state.amounts = []; + state.TVL = 0; }), } }) From 5c83021f3a305e688a6310fee0d6d31d4e9cac86 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:29:18 -0300 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=90=9BFix=20asset=20symbol=20assign?= =?UTF-8?q?ment=20in=20useVault=20hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/dapp/src/hooks/useVault.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/dapp/src/hooks/useVault.ts b/apps/dapp/src/hooks/useVault.ts index c5d6a1d6..9a363003 100644 --- a/apps/dapp/src/hooks/useVault.ts +++ b/apps/dapp/src/hooks/useVault.ts @@ -80,7 +80,8 @@ export const useVault = (vaultAddress?: string | undefined) => { ]); for (let asset of assets){ const symbol = await getTokenSymbol(asset.address, sorobanContext); - if(symbol === 'native') asset.symbol = 'XLM'; + if(symbol === 'native') asset.symbol = 'XLM' + else asset.symbol = symbol } getInvestedFunds(vaultAddress); const newData: VaultData = { From 27d9b14049b32fa1147e75bcd5f71a19b37a7264 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:26:36 -0300 Subject: [PATCH 03/13] =?UTF-8?q?=F0=9F=A9=B9Remove=20unnecesary=20loading?= =?UTF-8?q?=20on=20select=20strategy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeployVault/AddNewStrategyButton.tsx | 112 ++++++++---------- 1 file changed, 47 insertions(+), 65 deletions(-) diff --git a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx index 86ff3b42..72496720 100644 --- a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx +++ b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx @@ -44,13 +44,34 @@ function AddNewStrategyButton() { const [open, setOpen] = useState(false) const [isLoading, setIsLoading] = useState(false) const [defaultStrategies, setDefaultStrategies] = useState([]) - const [asset, setAsset] = useState({ address: '', strategies: [] }) + const [selectedAsset, setSelectedAsset] = useState({ address: '', strategies: [], symbol: '' }) + const [assets, setAssets] = useState([]) const [amountInput, setAmountInput] = useState({ amount: 0, enabled: false }) + const resetForm = () => { + setSelectedAsset({ address: '', strategies: [], symbol: '' }) + setAmountInput({ amount: 0, enabled: false }) + setOpen(false) + } + + const getSymbol = async (address: string) => { + const symbol = await getTokenSymbol(address, sorobanContext) + if (!symbol) return ''; + return symbol === 'native' ? 'XLM' : symbol + } + useEffect(() => { const fetchStrategies = async () => { const tempStrategies = await getDefaultStrategies(activeChain?.name?.toLowerCase() || 'testnet') - for (const strategy of tempStrategies) { + setDefaultStrategies(tempStrategies) + } + fetchStrategies(); + }, [activeChain?.networkPassphrase]) + + useEffect(() => { + const fetchStrategies = async () => { + const rawDefaultStrategies = await getDefaultStrategies(activeChain?.name?.toLowerCase() || 'testnet') + const defaultStrategiesWithAssets = await Promise.all(rawDefaultStrategies.map(async (strategy) => { const assetAddress = await strategyCallback( strategy.address, StrategyMethod.ASSET, @@ -62,66 +83,39 @@ function AddNewStrategyButton() { return asset; }) const assetSymbol = await getSymbol(assetAddress) - setAsset({ ...asset, address: assetAddress, symbol: assetSymbol! }) + const asset = { address: assetAddress, strategies: [strategy], symbol: assetSymbol! } + return asset } - setDefaultStrategies(tempStrategies) + )) + setAssets(defaultStrategiesWithAssets) } fetchStrategies(); }, [activeChain?.networkPassphrase]) - const resetForm = () => { - setAsset({ address: '', strategies: [] }) - setAmountInput({ amount: 0, enabled: false }) - setOpen(false) - } - - const getSymbol = async (address: string) => { - const symbol = await getTokenSymbol(address, sorobanContext) - if (!symbol) return ''; - return symbol === 'native' ? 'XLM' : symbol + const handleSelectStrategy = (value: boolean, strategy: Strategy) => { + const selectedAsset = assets.find((asset) => asset.strategies.some((str) => str.address === strategy.address)) + if (selectedAsset) { + setSelectedAsset(selectedAsset) + } } - const handleSelectStrategy = (value: boolean, strategy: Strategy) => { - setIsLoading(true) - switch (value) { - case true: - const fetchAssets = async () => { - try { - const asset = await strategyCallback( - strategy.address, - StrategyMethod.ASSET, - undefined, - false - ).then((result) => { - const resultScval = result as xdr.ScVal; - const asset = scValToNative(resultScval); - return asset; - }); - const symbol = await getSymbol(asset); - const newAsset = { address: asset, symbol: symbol!, strategies: [strategy] } - console.log(newAsset) - setAsset({ address: asset, symbol: symbol!, strategies: [strategy] }) - } catch (error) { - console.error(error); - } finally { - setIsLoading(false) - } - }; - fetchAssets(); - break - case false: - setAsset({ ...asset, strategies: asset.strategies.filter(str => str.address !== strategy.address) }) - setIsLoading(false) - break + const handleAmountInput = async (e: any) => { + const input = e.target.value + const decimalRegex = /^(\d+)?(\.\d{0,7})?$/ + if (!decimalRegex.test(input)) return + if (input.startsWith('.')) { + setAmountInput({ amount: 0 + input, enabled: true }); + return } + setAmountInput({ amount: input, enabled: true }); } const addAsset = async () => { const newAsset: Asset = { - address: asset.address, - strategies: asset.strategies, - symbol: asset.symbol + address: selectedAsset.address, + strategies: selectedAsset.strategies, + symbol: selectedAsset.symbol } await dispatch(pushAsset(newAsset)) if (amountInput.enabled && amountInput.amount! > 0) { @@ -130,18 +124,6 @@ function AddNewStrategyButton() { resetForm() } - - - const handleAmountInput = async (e: any) => { - const input = e.target.value - const decimalRegex = /^(\d+)?(\.\d{0,7})?$/ - if (!decimalRegex.test(input)) return - if (input.startsWith('.')) { - setAmountInput({ amount: 0 + input, enabled: true }); - return - } - setAmountInput({ amount: input, enabled: true }); - } return ( { setOpen(e.open) }} placement={'center'}> @@ -161,11 +143,11 @@ function AddNewStrategyButton() { {isLoading && } {!isLoading && str.address === strategy.address)} + checked={selectedAsset.strategies.some((str) => str.address === strategy.address)} onCheckedChange={(e) => handleSelectStrategy(!!e.checked, strategy)} label={strategy.name} />} - {asset.strategies.some((str) => str.address === strategy.address) && + {selectedAsset.strategies.some((str) => str.address === strategy.address) && Initial deposit: @@ -187,7 +169,7 @@ function AddNewStrategyButton() { @@ -204,7 +186,7 @@ function AddNewStrategyButton() { Close Date: Mon, 18 Nov 2024 21:39:28 -0300 Subject: [PATCH 04/13] =?UTF-8?q?=F0=9F=A9=B9Fix=20vault=20tvl=20after=20c?= =?UTF-8?q?reate=20&=20deposit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/InteractWithVault/InteractWithVault.tsx | 2 +- apps/dapp/src/components/ManageVaults/AllVaults.tsx | 6 +++++- apps/dapp/src/store/lib/features/walletStore.ts | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx index 427033be..cb15e024 100644 --- a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx +++ b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx @@ -71,7 +71,7 @@ export const InteractWithVault = () => { ).finally(async () => { const newTVL = await vault.getTVL(selectedVault?.address!) const parsedNewTVL = Number(newTVL) / 10 ** 7 - dispatch(setVaultTVL(parsedNewTVL)) + dispatch(setVaultTVL({ value: parsedNewTVL, address: selectedVault?.address! })) }); } catch (error: any) { diff --git a/apps/dapp/src/components/ManageVaults/AllVaults.tsx b/apps/dapp/src/components/ManageVaults/AllVaults.tsx index 2e63d4b1..6e2d2590 100644 --- a/apps/dapp/src/components/ManageVaults/AllVaults.tsx +++ b/apps/dapp/src/components/ManageVaults/AllVaults.tsx @@ -6,7 +6,7 @@ import { shortenAddress } from '@/helpers/address' import { useVault } from '@/hooks/useVault' import { FactoryMethod, useFactoryCallback } from '@/hooks/useFactory' -import { setIsVaultsLoading, setVaults, setVaultUserBalance } from '@/store/lib/features/walletStore' +import { setIsVaultsLoading, setVaults, setVaultTVL, setVaultUserBalance } from '@/store/lib/features/walletStore' import { useAppDispatch, useAppSelector } from '@/store/lib/storeHooks' import { VaultData } from '@/store/lib/types' @@ -94,6 +94,10 @@ export const AllVaults = ({ if (userBalance) { dispatch(setVaultUserBalance({ address: v.address, vaule: userBalance })) } + const TVL = await vault.getTVL(v.address) + if (TVL) { + dispatch(setVaultTVL({ value: TVL, address: v.address })) + } }) } }, [createdVaults]) diff --git a/apps/dapp/src/store/lib/features/walletStore.ts b/apps/dapp/src/store/lib/features/walletStore.ts index f03bd9be..307a911b 100644 --- a/apps/dapp/src/store/lib/features/walletStore.ts +++ b/apps/dapp/src/store/lib/features/walletStore.ts @@ -88,10 +88,10 @@ export const walletSlice = createSlice({ setVaults: (state, action: PayloadAction) => { state.vaults.createdVaults = action.payload }, - setVaultTVL: (state, action: PayloadAction) => { + setVaultTVL: (state, action: PayloadAction<{address:string, value: number}>) => { state.vaults.createdVaults.forEach(vault => { - if (vault.address === state.vaults.selectedVault?.address) { - vault.TVL = action.payload + if (vault.address === action.payload.address) { + vault.TVL = action.payload.value } }) }, @@ -104,7 +104,7 @@ export const walletSlice = createSlice({ vault.userBalance = action.payload.vaule } }) - } + }, }, extraReducers(builder) { builder.addCase(fetchDefaultAddresses.pending, (state) => { From 98ca74d1dd32254adaa04dffa013add43f6d5434 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:01:03 -0300 Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=90=9BFix=20user=20balance=20retrie?= =?UTF-8?q?val=20logic=20in=20AllVaults=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ManageVaults/AllVaults.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/dapp/src/components/ManageVaults/AllVaults.tsx b/apps/dapp/src/components/ManageVaults/AllVaults.tsx index 6e2d2590..68274157 100644 --- a/apps/dapp/src/components/ManageVaults/AllVaults.tsx +++ b/apps/dapp/src/components/ManageVaults/AllVaults.tsx @@ -85,15 +85,11 @@ export const AllVaults = ({ useEffect(() => { getDefindexVaults() - }, [activeChain?.networkPassphrase, address]) + }, [activeChain?.networkPassphrase]) useEffect(() => { if (address) { createdVaults.forEach(async (v: VaultData) => { - const userBalance = await vault.getUserBalance(v.address, address) - if (userBalance) { - dispatch(setVaultUserBalance({ address: v.address, vaule: userBalance })) - } const TVL = await vault.getTVL(v.address) if (TVL) { dispatch(setVaultTVL({ value: TVL, address: v.address })) @@ -102,6 +98,17 @@ export const AllVaults = ({ } }, [createdVaults]) + useEffect(() => { + if (address) { + createdVaults.forEach(async (v: VaultData) => { + const userBalance = await vault.getUserBalance(v.address, address) + if (userBalance) { + dispatch(setVaultUserBalance({ address: v.address, vaule: userBalance })) + } + }) + } + }, [createdVaults, address]) + return ( {!isMobile ? ( From 3b8d48358d3191b80d904deca9b82279385f3db8 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:27:06 -0300 Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=A9=B9Refactor=20ConfirmDeployModal?= =?UTF-8?q?=20and=20useVault=20hook=20by=20removing=20unused=20code=20and?= =?UTF-8?q?=20console=20logs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeployVault/ConfirmDelpoyModal.tsx | 42 +------------------ apps/dapp/src/hooks/useVault.ts | 2 - 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx index 616acc00..f26ffd8e 100644 --- a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx +++ b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx @@ -41,7 +41,6 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo const { activeChain, address } = sorobanContext; const factory = useFactoryCallback(); const newVault: NewVaultState = useAppSelector(state => state.newVault); - //const strategies: Strategy[] = newVault.strategies; const indexName = useAppSelector(state => state.newVault.name) const indexSymbol = useAppSelector(state => state.newVault.symbol) const indexShare = useAppSelector(state => state.newVault.vaultShare) @@ -50,14 +49,6 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo const feeReceiverString = useAppSelector(state => state.newVault.feeReceiver) const { transactionStatusModal: txModal } = useContext(ModalContext); const dispatch = useAppDispatch(); - const [assets, setAssets] = useState([]); - const [status, setStatus] = useState({ - isSuccess: false, - hasError: false, - network: undefined, - message: undefined, - txHash: undefined - }); const [deployDisabled, setDeployDisabled] = useState(true); @@ -74,35 +65,6 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo } }, [managerString, emergencyManagerString, feeReceiverString]) - - - - /* useEffect(() => { - const newChartData: ChartData[] = strategies.map((strategy: Strategy, index: number) => { - return { - id: index, - label: strategy.name, - address: strategy.address, - value: strategy.share, - } - }); - const total = newChartData.reduce((acc: number, curr: ChartData) => acc + curr.value, 0) - if (total == 100) { - setChartData(newChartData); - return; - } else { - newChartData.push({ - id: newChartData.length, - label: 'Unassigned', - value: 100 - newChartData.reduce((acc: number, curr: ChartData) => acc + curr.value, 0), - address: undefined, - color: '#e0e0e0' - }) - setChartData(newChartData); - return; - } - }, [strategies]); */ - const autoCloseModal = async () => { await new Promise(resolve => setTimeout(resolve, 30000)) txModal.resetModal(); @@ -307,14 +269,12 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo - {(activeStep == 0 && !status.hasError) && ( - )} + diff --git a/apps/dapp/src/hooks/useVault.ts b/apps/dapp/src/hooks/useVault.ts index 9a363003..aab1737c 100644 --- a/apps/dapp/src/hooks/useVault.ts +++ b/apps/dapp/src/hooks/useVault.ts @@ -182,7 +182,6 @@ export const useVault = (vaultAddress?: string | undefined) => { assets.forEach((asset)=>{ idleFunds.push({address: asset, amount: Number(rawIdleFunds[asset]) / 10 ** 7}) }) - console.log(idleFunds); return idleFunds; } catch (error) { console.error(error); @@ -196,7 +195,6 @@ export const useVault = (vaultAddress?: string | undefined) => { assets.forEach((asset)=>{ investedFunds.push({address: asset, amount: Number(rawInvestedFunds[asset]) / 10 ** 7}) }) - console.log(investedFunds); return investedFunds; } catch (error) { console.error(error); From 26c188f919b47d213332233d5a4e7542d23e856d Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:12:20 -0300 Subject: [PATCH 07/13] =?UTF-8?q?=F0=9F=A9=B9Refactor=20AddNewStrategyButt?= =?UTF-8?q?on=20and=20ConfirmDeployModal=20to=20improve=20state=20manageme?= =?UTF-8?q?nt=20and=20add=20setAmountByAddress=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeployVault/AddNewStrategyButton.tsx | 23 +++++++++++-------- .../DeployVault/ConfirmDelpoyModal.tsx | 13 ++++++++--- .../dapp/src/store/lib/features/vaultStore.ts | 9 +++++++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx index 72496720..feef64df 100644 --- a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx +++ b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx @@ -9,8 +9,8 @@ import { } from '@/components/ui/dialog' import { getTokenSymbol } from '@/helpers/getTokenInfo' import { StrategyMethod, useStrategyCallback } from '@/hooks/useStrategy' -import { getDefaultStrategies, pushAmount, pushAsset } from '@/store/lib/features/vaultStore' -import { useAppDispatch } from '@/store/lib/storeHooks' +import { getDefaultStrategies, pushAmount, pushAsset, setAmountByAddress } from '@/store/lib/features/vaultStore' +import { useAppDispatch, useAppSelector } from '@/store/lib/storeHooks' import { Asset, Strategy } from '@/store/lib/types' import { Button, @@ -42,8 +42,8 @@ function AddNewStrategyButton() { const { activeChain } = useSorobanReact() const strategyCallback = useStrategyCallback(); const [open, setOpen] = useState(false) - const [isLoading, setIsLoading] = useState(false) - const [defaultStrategies, setDefaultStrategies] = useState([]) + const newVault = useAppSelector((state) => state.newVault) + const [defaultStrategies, setDefaultStrategies] = useState([]) const [selectedAsset, setSelectedAsset] = useState({ address: '', strategies: [], symbol: '' }) const [assets, setAssets] = useState([]) const [amountInput, setAmountInput] = useState({ amount: 0, enabled: false }) @@ -110,13 +110,19 @@ function AddNewStrategyButton() { } setAmountInput({ amount: input, enabled: true }); } - + const strategyExists = (strategy: Strategy) => { + const exists = newVault.assets.some((asset) => asset.strategies.some((str) => str.address === strategy.address)) + return exists + } const addAsset = async () => { const newAsset: Asset = { address: selectedAsset.address, strategies: selectedAsset.strategies, symbol: selectedAsset.symbol } + if (strategyExists(selectedAsset.strategies[0]!)) { + await dispatch(setAmountByAddress({ address: selectedAsset.address, amount: amountInput.amount })) + } await dispatch(pushAsset(newAsset)) if (amountInput.enabled && amountInput.amount! > 0) { await dispatch(pushAmount(amountInput.amount!)) @@ -141,12 +147,11 @@ function AddNewStrategyButton() { {(strategy, index) => ( - {isLoading && } - {!isLoading && str.address === strategy.address)} + str.address === strategy.address)} onCheckedChange={(e) => handleSelectStrategy(!!e.checked, strategy)} label={strategy.name} - />} + /> {selectedAsset.strategies.some((str) => str.address === strategy.address) && diff --git a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx index f26ffd8e..b2930cca 100644 --- a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx +++ b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx @@ -76,7 +76,6 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo autoCloseModal(); } }, [txModal.status]) - const activeStep: number = 0; const [buttonText, setButtonText] = useState('') const [accordionValue, setAccordionValue] = useState([AccordionItems.STRATEGY_DETAILS]) const [formControl, setFormControl] = useState({ @@ -107,6 +106,7 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo } }, [managerString, emergencyManagerString, feeReceiverString, indexShare]) + const deployDefindex = async () => { if (managerString === '' || emergencyManagerString === '') { console.log('please fill manager config') @@ -170,9 +170,13 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo ]); }); const assetParamsScValVec = xdr.ScVal.scvVec(assetParamsScVal); - const amountsScVal = newVault.amounts.map((amount) => { - return nativeToScVal((amount * Math.pow(10, 7)), { type: "i128" }); + const amountsScVal = newVault.assets.map((asset, index) => { + if (newVault.amounts.length === 0) return nativeToScVal(0, { type: "i128" }); + return nativeToScVal((newVault.amounts[index]!) * 100, { type: "i128" }); }); + /* const amountsScVal = newVault.amounts.map((amount) => { + return nativeToScVal((amount * Math.pow(10, 7)), { type: "i128" }); + }); */ const amountsScValVec = xdr.ScVal.scvVec(amountsScVal); /* fn create_defindex_vault( emergency_manager: address, @@ -185,6 +189,7 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo salt: bytesn<32>) -> result */ let result: any; + if (amountsScVal.length === 0) { const createDefindexParams: xdr.ScVal[] = [ emergencyManager.toScVal(), @@ -205,6 +210,7 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo } catch (e: any) { console.error(e) + dispatch(resetNewVault()); txModal.handleError(e.toString()); return } @@ -232,6 +238,7 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo } catch (e: any) { console.error(e) + dispatch(resetNewVault()); txModal.handleError(e.toString()); return } diff --git a/apps/dapp/src/store/lib/features/vaultStore.ts b/apps/dapp/src/store/lib/features/vaultStore.ts index 7400031f..889aa76c 100644 --- a/apps/dapp/src/store/lib/features/vaultStore.ts +++ b/apps/dapp/src/store/lib/features/vaultStore.ts @@ -85,6 +85,12 @@ export const newVaultSlice = createSlice({ pushAmount: ((state, action: PayloadAction) => { state.amounts?.push(action.payload); }), + setAmountByAddress: ((state, action: PayloadAction<{address:string, amount:number}>) => { + const index = state.assets.findIndex(asset => asset.address === action.payload.address); + if(index !== -1) { + state.amounts[index] = action.payload.amount; + } + }), removeAmountByIndex: ((state, action: PayloadAction) => { state.amounts?.splice(action.payload, 1); }), @@ -124,7 +130,8 @@ export const { removeAmountByIndex, resetAssets, openEditVault, - resetNewVault + resetNewVault, + setAmountByAddress } = newVaultSlice.actions // Other code such as selectors can use the imported `RootState` type From cb98c0cb77c0eb7ab196846637762f4dba891e88 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:09:50 -0300 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=90=9BFix=20amount=20handling=20in?= =?UTF-8?q?=20AddNewStrategyButton=20and=20update=20initial=20deposit=20di?= =?UTF-8?q?splay=20in=20DeployVault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx | 4 ++++ apps/dapp/src/components/DeployVault/DeployVault.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx index feef64df..313f43ce 100644 --- a/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx +++ b/apps/dapp/src/components/DeployVault/AddNewStrategyButton.tsx @@ -121,7 +121,11 @@ function AddNewStrategyButton() { symbol: selectedAsset.symbol } if (strategyExists(selectedAsset.strategies[0]!)) { + if (amountInput.enabled && amountInput.amount! > 0) { await dispatch(setAmountByAddress({ address: selectedAsset.address, amount: amountInput.amount })) + } else if (amountInput.enabled == false || amountInput.amount! == 0) { + await dispatch(setAmountByAddress({ address: selectedAsset.address, amount: 0 })) + } } await dispatch(pushAsset(newAsset)) if (amountInput.enabled && amountInput.amount! > 0) { diff --git a/apps/dapp/src/components/DeployVault/DeployVault.tsx b/apps/dapp/src/components/DeployVault/DeployVault.tsx index 987f13aa..7432b96d 100644 --- a/apps/dapp/src/components/DeployVault/DeployVault.tsx +++ b/apps/dapp/src/components/DeployVault/DeployVault.tsx @@ -103,7 +103,7 @@ export const DeployVault = () => { Strategy Address: {shortenAddress(strategy.address)} - {amounts[j] &&
  • Initial deposit: ${amounts[j]} {asset.symbol}
  • } + {(amounts[j]! > 0) &&
  • Initial deposit: ${amounts[j]} {asset.symbol}
  • }
    )} From 2e94614a65a535c45532ec0c38b3ae6f72813b24 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:58:19 -0300 Subject: [PATCH 09/13] =?UTF-8?q?=F0=9F=A9=B9Refactor=20ConfirmDeployModal?= =?UTF-8?q?=20and=20InteractWithVault=20components=20to=20enhance=20state?= =?UTF-8?q?=20management=20and=20integrate=20vault=20data=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeployVault/ConfirmDelpoyModal.tsx | 28 +++++++++++++++---- .../InteractWithVault/InteractWithVault.tsx | 8 ++++-- .../components/ManageVaults/InspectVault.tsx | 5 ++-- apps/dapp/src/providers/modal-provider.tsx | 13 ++++----- .../src/store/lib/features/walletStore.ts | 25 ++++++++++++++++- 5 files changed, 60 insertions(+), 19 deletions(-) diff --git a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx index b2930cca..6293b532 100644 --- a/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx +++ b/apps/dapp/src/components/DeployVault/ConfirmDelpoyModal.tsx @@ -10,7 +10,7 @@ import { randomBytes } from "crypto"; import { useAppDispatch, useAppSelector } from "@/store/lib/storeHooks" import { pushVault } from '@/store/lib/features/walletStore' -import { Asset, NewVaultState } from "@/store/lib/types"; +import { Asset, NewVaultState, VaultData } from "@/store/lib/types"; import { useFactoryCallback, FactoryMethod } from '@/hooks/useFactory' import { ModalContext, TransactionStatusModalStatus } from "@/contexts"; @@ -19,6 +19,7 @@ import { AccordionItems, FormControlInterface, VaultPreview } from "./VaultPrevi import { DialogBody, DialogCloseTrigger, DialogFooter, DialogHeader, DialogTitle } from "../ui/dialog"; import { Button } from "@chakra-ui/react" import { resetNewVault } from "@/store/lib/features/vaultStore"; +import { useVault } from "@/hooks/useVault"; interface Status { isSuccess: boolean, @@ -47,8 +48,9 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo const managerString = useAppSelector(state => state.newVault.manager) const emergencyManagerString = useAppSelector(state => state.newVault.emergencyManager) const feeReceiverString = useAppSelector(state => state.newVault.feeReceiver) - const { transactionStatusModal: txModal } = useContext(ModalContext); + const { transactionStatusModal: txModal, deployVaultModal: deployModal } = useContext(ModalContext); const dispatch = useAppDispatch(); + const { getIdleFunds, getInvestedFunds, getTVL, getUserBalance } = useVault() const [deployDisabled, setDeployDisabled] = useState(true); @@ -118,6 +120,7 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo setAccordionValue([AccordionItems.FEES_CONFIGS]) return } + deployModal.setIsOpen(false) txModal.initModal(); const vaultName = nativeToScVal(indexName, { type: "string" }) @@ -190,7 +193,8 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo */ let result: any; - if (amountsScVal.length === 0) { + + if (newVault.amounts.length === 0) { const createDefindexParams: xdr.ScVal[] = [ emergencyManager.toScVal(), feeReceiver.toScVal(), @@ -245,10 +249,24 @@ export const ConfirmDelpoyModal = ({ isOpen, onClose }: { isOpen: boolean, onClo } const parsedResult: string = scValToNative(result.returnValue); if (parsedResult.length !== 56) throw new Error('Invalid result') - const tempVault: any = { + const idleFunds = newVault.assets.map((asset, index) => { + return { + address: asset.address, + amount: newVault.amounts[index] || 0 + } + }) + const tempVault: VaultData = { ...newVault, - address: parsedResult + address: parsedResult, + emergencyManager: emergencyManagerString, + feeReceiver: feeReceiverString, + manager: managerString, + TVL: 0, + totalSupply: 0, + idleFunds: idleFunds, + investedFunds: [{ address: '', amount: 0 }], } + console.log(tempVault) await txModal.handleSuccess(result.txHash); dispatch(pushVault(tempVault)); dispatch(resetNewVault()); diff --git a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx index cb15e024..b160c4a9 100644 --- a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx +++ b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx @@ -66,8 +66,11 @@ export const InteractWithVault = () => { selectedVault?.address!, params, true, - ).then((res) => - statusModal.handleSuccess(res.txHash) + ).then((res) => { + interactModal.setIsOpen(false), + inspectModal.setIsOpen(false), + statusModal.handleSuccess(res.txHash) + } ).finally(async () => { const newTVL = await vault.getTVL(selectedVault?.address!) const parsedNewTVL = Number(newTVL) / 10 ** 7 @@ -76,6 +79,7 @@ export const InteractWithVault = () => { } catch (error: any) { console.error('Error:', error) + interactModal.setIsOpen(false) statusModal.handleError(error.toString()) } } diff --git a/apps/dapp/src/components/ManageVaults/InspectVault.tsx b/apps/dapp/src/components/ManageVaults/InspectVault.tsx index 2678d439..81ff6d08 100644 --- a/apps/dapp/src/components/ManageVaults/InspectVault.tsx +++ b/apps/dapp/src/components/ManageVaults/InspectVault.tsx @@ -2,7 +2,7 @@ import { useSorobanReact } from "@soroban-react/core" import { shortenAddress } from "@/helpers/address" -import { VaultMethod } from "@/hooks/useVault" +import { useVault, VaultMethod } from "@/hooks/useVault" import { useAppSelector } from "@/store/lib/storeHooks" import { Asset, AssetAmmount, VaultData } from "@/store/lib/types" @@ -12,7 +12,6 @@ import { DialogBody, DialogContent, DialogFooter, DialogHeader } from "../ui/dia import { FaRegEdit } from "react-icons/fa" import { IoClose } from "react-icons/io5" - export const InspectVault = ({ handleOpenDeployVault, handleOpenInteract, @@ -24,8 +23,8 @@ export const InspectVault = ({ }) => { const selectedVault: VaultData | undefined = useAppSelector(state => state.wallet.vaults.selectedVault) const { address } = useSorobanReact() - if (!selectedVault) return null + if (!selectedVault) return null return ( diff --git a/apps/dapp/src/providers/modal-provider.tsx b/apps/dapp/src/providers/modal-provider.tsx index 8564ab67..3b4beeaf 100644 --- a/apps/dapp/src/providers/modal-provider.tsx +++ b/apps/dapp/src/providers/modal-provider.tsx @@ -26,10 +26,6 @@ export const ModalProvider = ({ const [txHash, setTxHash] = React.useState('') const handleResetModal = () => { - console.log('resetting modal') - setIsDeployVaultModalOpen(false) - setIsInspectVaultModalOpen(false) - setIsInteractWithVaultModalOpen(false) setIsTransactionStatusModalOpen(false) setTransactionStatusModalStep(0) setTransactionStatusModalStatus(TransactionStatusModalStatus.PENDING) @@ -38,23 +34,23 @@ export const ModalProvider = ({ setTxHash('') } + const handleFirstStep = setTimeout(() => setTransactionStatusModalStep(1), 3000) useEffect(() => { - const handleFirstStep = setTimeout(() => setTransactionStatusModalStep(1), 3000) if (isTransactionStatusModalOpen && transactionStatusModalStep === 0 && transactionStatusModalStatus === TransactionStatusModalStatus.PENDING) { - console.log('modal is open') handleFirstStep - } else { + } else if (transactionStatusModalStatus !== TransactionStatusModalStatus.PENDING) { clearTimeout(handleFirstStep) + setTransactionStatusModalStep(2) } }, [isTransactionStatusModalOpen, transactionStatusModalStep, transactionStatusModalStatus]) const handleInitModal = () => { - console.log('init modal') handleResetModal() setIsTransactionStatusModalOpen(true) } const handleError = (error: string) => { + clearTimeout(handleFirstStep) setTransactionStatusModalError(error) setTransactionStatusModalStatus(TransactionStatusModalStatus.ERROR) setTransactionStatusModalStep(2) @@ -62,6 +58,7 @@ export const ModalProvider = ({ } const handleSuccess = (txHash: string) => { + clearTimeout(handleFirstStep) setTxHash(txHash) setTransactionStatusModalStatus(TransactionStatusModalStatus.SUCCESS) setTransactionStatusModalStep(2) diff --git a/apps/dapp/src/store/lib/features/walletStore.ts b/apps/dapp/src/store/lib/features/walletStore.ts index 307a911b..47b7bf83 100644 --- a/apps/dapp/src/store/lib/features/walletStore.ts +++ b/apps/dapp/src/store/lib/features/walletStore.ts @@ -5,6 +5,7 @@ import { ChainMetadata } from '@soroban-react/types' import vaults from '@/constants/constants.json' import { Networks } from '@stellar/stellar-sdk' import { SelectedVault, VaultData, WalletState } from '../types' +import { VaultMethod } from '@/hooks/useVault' const getDefaultVaults = async (network: string) => { const filteredVaults = vaults.filter(vault => { @@ -105,6 +106,27 @@ export const walletSlice = createSlice({ } }) }, + updateVaultData: (state, action: PayloadAction>) => { + state.vaults.createdVaults.forEach(vault => { + if (vault.address === action.payload.address) { + Object.assign(vault, action.payload) + } + }) + state.vaults.selectedVault = { + address: action.payload.address ?? state.vaults.selectedVault?.address ?? '', + name: action.payload.name ?? state.vaults.selectedVault?.name ?? '', + manager: action.payload.manager ?? state.vaults.selectedVault?.manager ?? '', + emergencyManager: action.payload.emergencyManager ?? state.vaults.selectedVault?.emergencyManager ?? '', + feeReceiver: action.payload.feeReceiver ?? state.vaults.selectedVault?.feeReceiver ?? '', + TVL: action.payload.TVL ?? state.vaults.selectedVault?.TVL ?? 0, + userBalance: action.payload.userBalance ?? state.vaults.selectedVault?.userBalance ?? 0, + assets: action.payload.assets ?? state.vaults.selectedVault?.assets ?? [], + idleFunds: action.payload.idleFunds ?? state.vaults.selectedVault?.idleFunds ?? [], + investedFunds: action.payload.investedFunds ?? state.vaults.selectedVault?.investedFunds ?? [], + totalSupply: action.payload.totalSupply ?? state.vaults.selectedVault?.totalSupply ?? 0, + method: state.vaults.selectedVault?.method || VaultMethod.DEPOSIT, + } + }, }, extraReducers(builder) { builder.addCase(fetchDefaultAddresses.pending, (state) => { @@ -131,7 +153,8 @@ export const { setVaults, setVaultTVL, resetSelectedVault, - setVaultUserBalance + setVaultUserBalance, + updateVaultData } = walletSlice.actions // Other code such as selectors can use the imported `RootState` type From b513ec59a538742e02d5faa49496094b3698310f Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:27:58 -0300 Subject: [PATCH 10/13] =?UTF-8?q?=F0=9F=A9=B9Refactor=20InteractWithVault?= =?UTF-8?q?=20component=20to=20enhance=20user=20balance=20handling=20and?= =?UTF-8?q?=20update=20vault=20data=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InteractWithVault/InteractWithVault.tsx | 43 ++++++++++++------- .../src/store/lib/features/walletStore.ts | 14 ------ 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx index b160c4a9..04176201 100644 --- a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx +++ b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx @@ -3,8 +3,8 @@ import { Address, nativeToScVal, xdr } from '@stellar/stellar-sdk' import { useSorobanReact } from '@soroban-react/core' import { useAppDispatch, useAppSelector } from '@/store/lib/storeHooks' -import { setVaultTVL } from '@/store/lib/features/walletStore' -import { Strategy } from '@/store/lib/types' +import { setVaultTVL, setVaultUserBalance, updateVaultData } from '@/store/lib/features/walletStore' +import { Strategy, VaultData } from '@/store/lib/types' import { VaultMethod, useVaultCallback, useVault } from '@/hooks/useVault' import { ModalContext } from '@/contexts' @@ -36,7 +36,7 @@ export const InteractWithVault = () => { const { transactionStatusModal: statusModal, interactWithVaultModal: interactModal, inspectVaultModal: inspectModal } = useContext(ModalContext) const vaultOperation = async () => { - if (!address || !vaultMethod) return; + if (!address || !vaultMethod || !selectedVault.address) return; if (!amount) throw new Error('Amount is required'); const parsedAmount = parseFloat(amount.toString()) const convertedAmount = parsedAmount * Math.pow(10, 7) @@ -52,42 +52,53 @@ export const InteractWithVault = () => { }; if (vaultMethod === VaultMethod.WITHDRAW) { const withdrawAmount = ((amount * selectedVault.totalSupply) / selectedVault.TVL) - const convertedWithdrawAmount = withdrawAmount * Math.pow(10, 7) + const truncatedWithdrawAmount = Math.floor(withdrawAmount * 1e7) / 1e7; + const convertedWithdrawAmount = Number(truncatedWithdrawAmount) * Math.pow(10, 7) const withdrawParams: xdr.ScVal[] = [ - nativeToScVal(convertedWithdrawAmount, { type: "i128" }), + nativeToScVal(Math.ceil(convertedWithdrawAmount), { type: "i128" }), new Address(address).toScVal(), ] params = withdrawParams }; - console.log('Vault method:', vaultMethod) try { const result = await vaultCB( vaultMethod!, selectedVault?.address!, params, true, - ).then((res) => { - interactModal.setIsOpen(false), - inspectModal.setIsOpen(false), - statusModal.handleSuccess(res.txHash) + ).then(async (res) => { + await statusModal.handleSuccess(res.txHash) } ).finally(async () => { + const newBalance = await vault.getUserBalance(selectedVault.address, address) + const newIdleFunds = await vault.getIdleFunds(selectedVault.address!) + const newInvestedFunds = await vault.getInvestedFunds(selectedVault.address) const newTVL = await vault.getTVL(selectedVault?.address!) - const parsedNewTVL = Number(newTVL) / 10 ** 7 - dispatch(setVaultTVL({ value: parsedNewTVL, address: selectedVault?.address! })) + const newVaultData: Partial = { + address: selectedVault.address, + userBalance: newBalance || 0, + idleFunds: newIdleFunds, + investedFunds: newInvestedFunds, + TVL: newTVL + } + dispatch(updateVaultData(newVaultData)) }); } catch (error: any) { console.error('Error:', error) - interactModal.setIsOpen(false) - statusModal.handleError(error.toString()) + await statusModal.handleError(error.toString()) + } finally { + set_amount(0) + await setTimeout(() => { + interactModal.setIsOpen(false) + inspectModal.setIsOpen(false) + }, 3000) } } const setAmount = (input: any) => { if (input < 0 || !selectedVault) return; if (vaultMethod === VaultMethod.WITHDRAW) { - console.log(input, selectedVault?.userBalance) if (input > selectedVault.userBalance!) return; } const decimalRegex = /^(\d+)?(\.\d{0,7})?$/; @@ -122,7 +133,7 @@ export const InteractWithVault = () => {

    Total value locked: ${selectedVault?.TVL} {selectedVault.assets[0]?.symbol}

    -

    User balance in vault: ${selectedVault?.userBalance} {selectedVault.assets[0]?.symbol}

    +

    User balance in vault: ${`${selectedVault.userBalance ?? 0}`} {selectedVault.assets[0]?.symbol}

    {vaultMethod != VaultMethod.EMERGENCY_WITHDRAW && diff --git a/apps/dapp/src/store/lib/features/walletStore.ts b/apps/dapp/src/store/lib/features/walletStore.ts index 47b7bf83..07e7db2c 100644 --- a/apps/dapp/src/store/lib/features/walletStore.ts +++ b/apps/dapp/src/store/lib/features/walletStore.ts @@ -112,20 +112,6 @@ export const walletSlice = createSlice({ Object.assign(vault, action.payload) } }) - state.vaults.selectedVault = { - address: action.payload.address ?? state.vaults.selectedVault?.address ?? '', - name: action.payload.name ?? state.vaults.selectedVault?.name ?? '', - manager: action.payload.manager ?? state.vaults.selectedVault?.manager ?? '', - emergencyManager: action.payload.emergencyManager ?? state.vaults.selectedVault?.emergencyManager ?? '', - feeReceiver: action.payload.feeReceiver ?? state.vaults.selectedVault?.feeReceiver ?? '', - TVL: action.payload.TVL ?? state.vaults.selectedVault?.TVL ?? 0, - userBalance: action.payload.userBalance ?? state.vaults.selectedVault?.userBalance ?? 0, - assets: action.payload.assets ?? state.vaults.selectedVault?.assets ?? [], - idleFunds: action.payload.idleFunds ?? state.vaults.selectedVault?.idleFunds ?? [], - investedFunds: action.payload.investedFunds ?? state.vaults.selectedVault?.investedFunds ?? [], - totalSupply: action.payload.totalSupply ?? state.vaults.selectedVault?.totalSupply ?? 0, - method: state.vaults.selectedVault?.method || VaultMethod.DEPOSIT, - } }, }, extraReducers(builder) { From 788794f13b22f3ad7f3f8b8004f53f458085a7f9 Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:36:28 -0300 Subject: [PATCH 11/13] =?UTF-8?q?=E2=9C=A8Add=20clipboard=20functionality?= =?UTF-8?q?=20for=20vault=20addresses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InteractWithVault/InteractWithVault.tsx | 16 ++++---- .../components/ManageVaults/InspectVault.tsx | 10 ++++- apps/dapp/src/components/ui/clipboard.tsx | 39 ++++++++++--------- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx index 04176201..2fb0431d 100644 --- a/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx +++ b/apps/dapp/src/components/InteractWithVault/InteractWithVault.tsx @@ -23,6 +23,7 @@ import { NativeSelectField, HStack, } from '@chakra-ui/react' +import { ClipboardIconButton, ClipboardRoot } from '../ui/clipboard' export const InteractWithVault = () => { const [amount, set_amount] = useState(0) @@ -121,13 +122,14 @@ export const InteractWithVault = () => {

    Vault address:

    -