Skip to content

Commit

Permalink
Merge pull request liftedinit#8 from fmorency/fix-package
Browse files Browse the repository at this point in the history
  • Loading branch information
chalabi2 authored Sep 9, 2024
2 parents 7b8229f + ef733d5 commit 4447f6d
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 481 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install dependencies
run: bun install
- name: Run tests and generate coverage
run: bun run test:coverage
run: bun run test:coverage:lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
Binary file modified bun.lockb
Binary file not shown.
9 changes: 0 additions & 9 deletions components/admins/components/__tests__/adminOptions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ describe('AdminOptions', () => {
expect(within(detailsContainer).getByText('details1')).toBeInTheDocument();
});

test('opens update modal on button click', () => {
renderWithProps();
const updateAdminButtonContainer = screen.getByLabelText('update admin');
fireEvent.click(within(updateAdminButtonContainer).getByText('Update Admin'));
const modal = document.getElementById('update-admin-modal') as HTMLDialogElement;
expect(modal).toBeInTheDocument();
expect(modal.open).toBe(true);
});

test('opens description modal on button click', () => {
renderWithProps();
fireEvent.click(screen.getByLabelText('three-dots'));
Expand Down
89 changes: 3 additions & 86 deletions components/admins/components/adminOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
import React, { useEffect, useState } from 'react';
import { ExtendedGroupType, useFeeEstimation, useTx } from '@/hooks';
import { ParamsSDKType } from '@chalabi/manifestjs/dist/codegen/strangelove_ventures/poa/v1/params';
import { UpdateAdminModal } from '../modals/updateAdminModal';
import React from 'react';
import { ExtendedGroupType } from '@/hooks';

import { BsThreeDots } from 'react-icons/bs';
import { DescriptionModal } from '../modals/descriptionModal';
import ProfileAvatar from '@/utils/identicon';

import { chainName } from '@/config';
import { strangelove_ventures, cosmos } from '@chalabi/manifestjs';
import { MsgUpdateParams } from '@chalabi/manifestjs/dist/codegen/strangelove_ventures/poa/v1/tx';
import { Any } from '@chalabi/manifestjs/dist/codegen/google/protobuf/any';

interface AdminOptionsProps {
poaParams: ParamsSDKType;
group: ExtendedGroupType;
isLoading: boolean;
address: string;
admin: string;
}

export default function AdminOptions({
poaParams,
group,
isLoading,
address,
admin,
}: AdminOptionsProps) {
const exitEnabled = true;

export default function AdminOptions({ group, isLoading }: Readonly<AdminOptionsProps>) {
const handleOpen = () => {
const modal = document.getElementById(`update-admin-modal`) as HTMLDialogElement;
modal?.showModal();
Expand All @@ -39,43 +23,6 @@ export default function AdminOptions({
modal?.showModal();
};

const { estimateFee } = useFeeEstimation(chainName);
const { tx } = useTx(chainName);
const { updateParams } = strangelove_ventures.poa.v1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;

const handleUpdate = async () => {
const msgUpdateAdmin = updateParams({
sender: admin ?? '',
params: {
admins: poaParams.admins,
allowValidatorSelfExit: poaParams.allow_validator_self_exit === true ? false : true,
},
});

const anyMessage = Any.fromPartial({
typeUrl: msgUpdateAdmin.typeUrl,
value: MsgUpdateParams.encode(msgUpdateAdmin.value).finish(),
});

const groupProposalMsg = submitProposal({
groupPolicyAddress: admin,
messages: [anyMessage],
metadata: '',
proposers: [address ?? ''],
title: `Update Self Exit`,
summary: `This proposal will ${
poaParams.allow_validator_self_exit === true ? 'enable' : 'disable'
} the ability to leave the active set.`,
exec: 0,
});

const fee = await estimateFee(address ?? '', [groupProposalMsg]);
await tx([groupProposalMsg], {
fee,
onSuccess: () => {},
});
};
return (
<div className="lg:w-1/2 w-full mx-auto p-4 bg-base-100 rounded-md lg:max-h-[352px]">
<div className="px-4 py-2 border-base-content flex items-center justify-between">
Expand Down Expand Up @@ -110,40 +57,10 @@ export default function AdminOptions({
<button className="btn block lg:hidden btn-primary btn-sm w-2/6" onClick={handleOpen}>
Update
</button>
<button
className="btn hidden lg:block btn-primary btn-sm w-2/6"
onClick={handleOpen}
aria-label="update admin"
>
Update Admin
</button>
<button
onClick={handleUpdate}
className={`btn block lg:hidden ${
exitEnabled ? 'btn-secondary' : 'btn-primary'
} btn-sm w-2/6`}
>
{poaParams.allow_validator_self_exit ? 'Disable ' : 'Enable '}
</button>
<button
onClick={handleUpdate}
className={`btn hidden lg:block ${
exitEnabled ? 'btn-secondary' : 'btn-primary'
} btn-sm w-2/6`}
>
{poaParams.allow_validator_self_exit ? 'Disable Self Exit' : 'Enable Self Exit'}
</button>
</div>
</div>
)}

<UpdateAdminModal
userAddress={address ?? ''}
modalId="update-admin-modal"
admin={admin ?? ''}
allowExit={poaParams.allow_validator_self_exit}
/>

<DescriptionModal
type="group"
modalId="description-modal"
Expand Down
93 changes: 0 additions & 93 deletions components/admins/modals/__tests__/updateAdminModal.test.tsx

This file was deleted.

1 change: 0 additions & 1 deletion components/admins/modals/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './updateAdminModal';
export * from './validatorModal';
export * from './warningModal';
125 changes: 0 additions & 125 deletions components/admins/modals/updateAdminModal.tsx

This file was deleted.

Loading

0 comments on commit 4447f6d

Please sign in to comment.