Skip to content

Commit

Permalink
fix available version filter for os update
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr2github committed Nov 8, 2023
1 parent 08570d4 commit 4785481
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/components/executionWidget/actions/updateOSCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export const UpdateOSCard: React.FC<{
{decodedAction && (
<div className="space-y-4">
{Object.entries(decodedAction).map(([key, value]) => {
console.log('key', value);

return (
<div key={key}>
<div className="mb-3 text-base font-semibold capitalize leading-normal text-neutral-800">
Expand Down
1 change: 1 addition & 0 deletions src/components/executionWidget/actionsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const ActionsFilter: React.FC<ActionsFilterProps> = ({
);
case 'os_update':
return <UpdateOSCard action={action} dao={dao} />;
case 'plugin_update':
default:
return <></>;
}
Expand Down
15 changes: 11 additions & 4 deletions src/context/createProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,6 +106,11 @@ const CreateProposalWrapper: React.FC<Props> = ({
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});
Expand Down Expand Up @@ -316,12 +322,12 @@ const CreateProposalWrapper: React.FC<Props> = ({
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);
Expand All @@ -340,6 +346,7 @@ const CreateProposalWrapper: React.FC<Props> = ({
getValues,
network,
pluginAddress,
pluginAvailableVersions?.address,
pluginClient,
t,
translatedNetwork,
Expand Down
3 changes: 2 additions & 1 deletion src/context/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
{
Expand All @@ -196,6 +196,7 @@ const UpdateProvider: React.FC<{children: ReactElement}> = ({children}) => {
...(key === 'LATEST' && {isLatest: true}),
} as OSX
);
}

if (key === 'LATEST') {
setValue('osSelectedVersion', {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 4785481

Please sign in to comment.