Skip to content

Commit

Permalink
integrate yaci
Browse files Browse the repository at this point in the history
  • Loading branch information
chalabi2 committed Nov 5, 2024
1 parent eea0ef5 commit 31083b1
Show file tree
Hide file tree
Showing 19 changed files with 766 additions and 563 deletions.
Binary file modified bun.lockb
Binary file not shown.
125 changes: 65 additions & 60 deletions components/admins/components/validatorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,53 +73,6 @@ export default function ValidatorList({
setModalId(`validator-modal-${validator.operator_address}-${Date.now()}`);
};

const renderTableContent = () => {
return (
<tbody>
{filteredValidators.map(validator => (
<tr
key={validator.operator_address}
className="bg-[#FFFFFFCC] dark:bg-[#FFFFFF0F] hover:bg-[#FFFFFF66] dark:hover:bg-[#FFFFFF1A] text-black dark:text-white rounded-lg cursor-pointer"
onClick={() => handleRowClick(validator)}
>
<td className="rounded-l-[12px] py-4">
<div className="flex items-center space-x-3">
{validator.logo_url ? (
<Image
height={32}
width={32}
src={validator.logo_url}
alt=""
className="w-8 h-8 rounded-full"
/>
) : (
<ProfileAvatar walletAddress={validator.operator_address} size={32} />
)}
<span className="font-medium">{validator.description.moniker}</span>
</div>
</td>

<td className="py-4">
<TruncatedAddressWithCopy slice={10} address={validator.operator_address} />
</td>
<td className="py-4">{validator.consensus_power?.toString() ?? 'N/A'}</td>
<td className="rounded-r-[12px] py-4 text-right">
<button
onClick={e => {
e.stopPropagation();
handleRemove(validator);
}}
className="btn btn-error btn-sm text-white "
>
<TrashIcon className="w-5 h-5" />
</button>
</td>
</tr>
))}
</tbody>
);
};

return (
<div className="w-full max-w-screen mx-auto">
<div className="">
Expand Down Expand Up @@ -164,20 +117,72 @@ export default function ValidatorList({
</button>
</div>
<div className="overflow-x-auto overflow-y-auto max-h-[calc(100vh-300px)]">
<table className="table w-full border-separate border-spacing-y-3">
<thead>
<tr className="text-sm font-medium text-[#808080]">
<th className="bg-transparent text-left sticky top-0 bg-base-100 z-10">Moniker</th>
{filteredValidators.length === 0 ? (
<div className="text-center py-8 text-[#808080]">
{active ? 'No active validators found' : 'No pending validators'}
</div>
) : (
<table className="table w-full border-separate border-spacing-y-3">
<thead>
<tr className="text-sm font-medium text-[#808080]">
<th className="bg-transparent text-left sticky top-0 bg-base-100 z-10">
Moniker
</th>
<th className="bg-transparent text-left sticky top-0 bg-base-100 z-10">
Address
</th>
<th className="bg-transparent text-left sticky top-0 bg-base-100 z-10">
Consensus Power
</th>
<th className="bg-transparent text-right sticky top-0 bg-base-100 z-10">
Remove
</th>
</tr>
</thead>
<tbody>
{filteredValidators.map(validator => (
<tr
key={validator.operator_address}
className="bg-[#FFFFFFCC] dark:bg-[#FFFFFF0F] hover:bg-[#FFFFFF66] dark:hover:bg-[#FFFFFF1A] text-black dark:text-white rounded-lg cursor-pointer"
onClick={() => handleRowClick(validator)}
>
<td className="rounded-l-[12px] py-4">
<div className="flex items-center space-x-3">
{validator.logo_url ? (
<Image
height={32}
width={32}
src={validator.logo_url}
alt=""
className="w-8 h-8 rounded-full"
/>
) : (
<ProfileAvatar walletAddress={validator.operator_address} size={32} />
)}
<span className="font-medium">{validator.description.moniker}</span>
</div>
</td>

<th className="bg-transparent text-left sticky top-0 bg-base-100 z-10">Address</th>
<th className="bg-transparent text-left sticky top-0 bg-base-100 z-10">
Consensus Power
</th>
<th className="bg-transparent text-right sticky top-0 bg-base-100 z-10">Remove</th>
</tr>
</thead>
{renderTableContent()}
</table>
<td className="py-4">
<TruncatedAddressWithCopy slice={10} address={validator.operator_address} />
</td>
<td className="py-4">{validator.consensus_power?.toString() ?? 'N/A'}</td>
<td className="rounded-r-[12px] py-4 text-right">
<button
onClick={e => {
e.stopPropagation();
handleRemove(validator);
}}
className="btn btn-error btn-sm text-white "
>
<TrashIcon className="w-5 h-5" />
</button>
</td>
</tr>
))}
</tbody>
</table>
)}
</div>
</div>

Expand Down
32 changes: 18 additions & 14 deletions components/groups/components/groupProposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ export default function GroupProposals({
};

return (
<div className="space-y-4 w-full pt-4 text-black dark:text-white">
<div className="flex items-center justify-between mb-12">
<div className="h-full flex flex-col p-4">
{/* Header section */}
<div className="flex items-center justify-between mb-8">
<div className="flex items-center space-x-6">
<button
onClick={onBack}
Expand All @@ -264,6 +265,7 @@ export default function GroupProposals({
</div>
</div>

{/* Search and New Proposal section */}
<div className="flex justify-between items-center mb-6">
<h2 className="text-xl font-semibold">Proposals</h2>
<div className="flex items-center space-x-4">
Expand All @@ -285,14 +287,15 @@ export default function GroupProposals({
</div>
</div>

{isProposalsLoading ? (
<div className="flex justify-center items-center h-64">
<span className="loading loading-spinner loading-lg"></span>
</div>
) : isProposalsError ? (
<div className="text-center text-error">Error loading proposals</div>
) : filteredProposals.length > 0 ? (
<div className="overflow-x-auto w-full">
{/* Table section - will fill remaining space */}
<div className="flex-1 overflow-auto">
{isProposalsLoading ? (
<div className="flex justify-center items-center h-64">
<span className="loading loading-spinner loading-lg"></span>
</div>
) : isProposalsError ? (
<div className="text-center text-error">Error loading proposals</div>
) : filteredProposals.length > 0 ? (
<table className="table w-full border-separate border-spacing-y-3">
<thead>
<tr className="text-sm font-medium">
Expand Down Expand Up @@ -375,11 +378,12 @@ export default function GroupProposals({
})}
</tbody>
</table>
</div>
) : (
<div className="text-center py-8 text-gray-500">No proposals found</div>
)}
) : (
<div className="text-center py-8 text-gray-500">No proposals found</div>
)}
</div>

{/* Modals */}
<VoteDetailsModal
key={selectedProposal?.id.toString() ?? ''}
tallies={tally ?? ({} as QueryTallyResultResponseSDKType)}
Expand Down
16 changes: 9 additions & 7 deletions components/groups/components/myGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ export function YourGroups({
};

return (
<div className="relative w-full overflow-hidden">
<div className="relative w-full h-screen overflow-hidden">
<div
className={`transition-transform duration-300 ${selectedGroup ? '-translate-x-full' : 'translate-x-0'}`}
className={`absolute inset-0 transition-transform duration-300 ${
selectedGroup ? '-translate-x-full' : 'translate-x-0'
}`}
>
<div className="space-y-4 w-full pt-4">
<div className="h-full flex flex-col p-4">
<div className="flex justify-between items-center mb-4">
<div className="flex items-center space-x-4">
<h1
Expand Down Expand Up @@ -104,10 +106,8 @@ export function YourGroups({
</Link>
</div>
</div>
<div className="overflow-x-auto max-h-[87vh] w-full">
<div className="flex-1 overflow-auto">
<div className="max-w-8xl mx-auto">
{' '}
{/* table */}
<table className="table w-full border-separate border-spacing-y-3">
<thead className="sticky top-0 bg-[#F0F0FF] dark:bg-[#0E0A1F]">
<tr className="text-sm font-medium">
Expand Down Expand Up @@ -172,7 +172,9 @@ export function YourGroups({
</div>
</div>
<div
className={`absolute top-0 left-0 w-full h-full transition-transform duration-300 ${selectedGroup ? 'translate-x-0' : 'translate-x-full'}`}
className={`absolute inset-0 transition-transform duration-300 ${
selectedGroup ? 'translate-x-0' : 'translate-x-full'
}`}
>
{selectedGroup && (
<GroupProposals
Expand Down
8 changes: 5 additions & 3 deletions components/groups/forms/proposals/ConfirmationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useFeeEstimation } from '@/hooks/useFeeEstimation';
import { uploadJsonToIPFS } from '@/hooks/useIpfs';
import { useTx } from '@/hooks/useTx';
import { manifest, strangelove_ventures, cosmos, liftedinit } from '@chalabi/manifestjs';
import { strangelove_ventures, cosmos, liftedinit } from '@chalabi/manifestjs';
import { Any } from '@chalabi/manifestjs/dist/codegen/google/protobuf/any';

import { TruncatedAddressWithCopy } from '@/components/react/addressCopy';
Expand Down Expand Up @@ -127,8 +127,9 @@ export default function ConfirmationForm({
if (messageData.amount && !Array.isArray(messageData.amount)) {
messageData.amount = [messageData.amount];
}
console.log({ messageData });
const composedMessage = composer(messageData as MessageTypeMap[typeof message.type]);

console.log({ composedMessage });
if (!composedMessage || !composedMessage.value) {
console.error('Composed message or its value is undefined:', composedMessage);
throw new Error(`Failed to compose message for type: ${message.type}`);
Expand Down Expand Up @@ -183,6 +184,7 @@ export default function ConfirmationForm({

const messages: Any[] = formData.messages.map(message => getMessageObject(message));
console.log(formData.messages);
console.log({ messages });
const msg = cosmos.group.v1.MessageComposer.fromPartial.submitProposal({
groupPolicyAddress: policyAddress,
messages: messages,
Expand All @@ -192,7 +194,7 @@ export default function ConfirmationForm({
summary: formData.metadata.summary,
exec: 0,
});

console.log({ msg });
const fee = await estimateFee(address ?? '', [msg]);
await tx([msg], {
fee,
Expand Down
Loading

0 comments on commit 31083b1

Please sign in to comment.