From 478548132a7760ef15a57d50b88ccc7d6c169bfc Mon Sep 17 00:00:00 2001 From: sepehr sanaee Date: Wed, 8 Nov 2023 12:32:20 +0330 Subject: [PATCH] fix available version filter for os update --- .../executionWidget/actions/updateOSCard.tsx | 2 -- src/components/executionWidget/actionsFilter.tsx | 1 + src/context/createProposal.tsx | 15 +++++++++++---- src/context/update.tsx | 3 ++- src/utils/library.ts | 10 +++++----- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/executionWidget/actions/updateOSCard.tsx b/src/components/executionWidget/actions/updateOSCard.tsx index 7fe6cd977..dc7536da4 100644 --- a/src/components/executionWidget/actions/updateOSCard.tsx +++ b/src/components/executionWidget/actions/updateOSCard.tsx @@ -74,8 +74,6 @@ export const UpdateOSCard: React.FC<{ {decodedAction && (
{Object.entries(decodedAction).map(([key, value]) => { - console.log('key', value); - return (
diff --git a/src/components/executionWidget/actionsFilter.tsx b/src/components/executionWidget/actionsFilter.tsx index 2883f6441..d8c5ef837 100644 --- a/src/components/executionWidget/actionsFilter.tsx +++ b/src/components/executionWidget/actionsFilter.tsx @@ -50,6 +50,7 @@ export const ActionsFilter: React.FC = ({ ); case 'os_update': return ; + case 'plugin_update': default: return <>; } diff --git a/src/context/createProposal.tsx b/src/context/createProposal.tsx index 0d5f1e71d..b1c22a8e3 100644 --- a/src/context/createProposal.tsx +++ b/src/context/createProposal.tsx @@ -77,6 +77,7 @@ import {useGlobalModalContext} from './globalModals'; import {useNetwork} from './network'; import {useProviders} from './providers'; import {useProtocolVersions} from 'hooks/useDaoVersions'; +import {usePluginAvailableVersions} from 'hooks/usePluginAvailableVersions'; type Props = { showTxModal: boolean; @@ -105,6 +106,11 @@ const CreateProposalWrapper: React.FC = ({ const pluginAddress = daoDetails?.plugins?.[0]?.instanceAddress as string; const pluginType = daoDetails?.plugins?.[0]?.id as PluginTypes; + const {data: pluginAvailableVersions} = usePluginAvailableVersions( + pluginType, + daoDetails?.address as string + ); + const {data: daoToken} = useDaoToken(pluginAddress); const {data: tokenSupply} = useTokenSupply(daoToken?.address || ''); const {data: votingSettings} = useVotingSettings({pluginAddress, pluginType}); @@ -316,12 +322,12 @@ const CreateProposalWrapper: React.FC = ({ const daoActionsArray = client.encoding.applyUpdateAction( daoDetails?.address as string, { - permissions: [], + permissions: action.inputs.permissions, initData: new Uint8Array([]), - helpers: [], + helpers: action.inputs.helpers, versionTag: action.inputs.versionTag, - pluginRepo: '0x2c4690b8be39adad4f15a69340d5035ac6e53eef', - pluginAddress: '0xf2205ed1dd3b28c44c9dfc3dc4855fa879fb2ea4', + pluginRepo: pluginAvailableVersions?.address as string, + pluginAddress: pluginAddress, } ); console.log('view', daoActionsArray); @@ -340,6 +346,7 @@ const CreateProposalWrapper: React.FC = ({ getValues, network, pluginAddress, + pluginAvailableVersions?.address, pluginClient, t, translatedNetwork, diff --git a/src/context/update.tsx b/src/context/update.tsx index cad1338ce..96101f7cd 100644 --- a/src/context/update.tsx +++ b/src/context/update.tsx @@ -186,7 +186,7 @@ const UpdateProvider: React.FC<{children: ReactElement}> = ({children}) => { SupportedVersion[key as keyof typeof SupportedVersion], versions?.join('.') as string ) - ) + ) { OSXVersions.set( SupportedVersion[key as keyof typeof SupportedVersion], { @@ -196,6 +196,7 @@ const UpdateProvider: React.FC<{children: ReactElement}> = ({children}) => { ...(key === 'LATEST' && {isLatest: true}), } as OSX ); + } if (key === 'LATEST') { setValue('osSelectedVersion', { diff --git a/src/utils/library.ts b/src/utils/library.ts index 272a03d47..50584b884 100644 --- a/src/utils/library.ts +++ b/src/utils/library.ts @@ -1021,19 +1021,19 @@ export function clearWagmiCache(): void { * - -1 if version1 is less than version2 * - 0 if version1 is equal to version2 */ -export function compareVersions(version1: string, version2: string): number { - if (!version1 || !version2) return 0; +export function compareVersions(version1: string, version2: string): boolean { + if (!version1 || !version2) return false; const v1 = version1.split('.').map(Number); const v2 = version2.split('.').map(Number); for (let i = 0; i < v1.length; i++) { if (v1[i] > v2[i]) { - return 1; + return true; } else if (v1[i] < v2[i]) { - return -1; + return false; } } - return 0; + return false; }