Skip to content

Commit 7e4ef4e

Browse files
committed
Reformatting
1 parent fe2cb0c commit 7e4ef4e

35 files changed

+78
-85
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ The Cacti frontend is a web-based interface where users can seamlessly interact
2929

3030
**Widget Commands**: Central to Cacti's extensible design are the Widget Commands. These commands act as functions that an LLM can call to display an interaction dialogue box, allowing users to engage in web3 actions or access data seamlessly. The Widget Commands can be expanded upon, allowing for a broad array of functions catered to the user's needs.
3131

32-
**Eval**: Cacti employs a flexible evaluation framework that is crucial for developers wishing to assess the performance of added widgets. This includes features like hard-coded testing, automatic evaluations, and evaluations via manually annotated test samples that can be input via a CSV file.
32+
**Eval**: Cacti employs a flexible evaluation framework that is crucial for developers wishing to assess the performance of added widgets. This includes features like hard-coded testing, automatic evaluations, and evaluations via manually annotated test samples that can be input via a CSV file.
3333

3434
**Chat Context**: All dialog boxes can add information to the chat context, enabling the LLM use context added by previous widget commands to execute a later command effectively, enhancing the overall user experience.
3535

36-
**Configurable Chat Modules**: Chat modules can be configured to permit the use of alternative LLMs, fine-tuned LLMs, alternate prompts to LLMs, etc. Different chat modules can be used just by using a modified URL. This allows for easy testing of potential improvements to the chat modes and new features.
36+
**Configurable Chat Modules**: Chat modules can be configured to permit the use of alternative LLMs, fine-tuned LLMs, alternate prompts to LLMs, etc. Different chat modules can be used just by using a modified URL. This allows for easy testing of potential improvements to the chat modes and new features.
3737

3838
**Streaming Support**: Cacti supports streaming from LLM models, providing users with real-time updates. The system can sensibly handle widget commands included in the LLM stream, ensuring smooth and intuitive interactions.
3939

@@ -45,7 +45,6 @@ The Cacti frontend is a web-based interface where users can seamlessly interact
4545

4646
**Transaction Handling**: Cacti is designed to handle web3 transactions on Ethereum or Layer 2 solutions (L2s). It abstracts away the complexity of transaction handling from the integrator. All the integrator needs to do is pass the transaction details, and Cacti takes care of the rest, ensuring a user-friendly experience for those engaging with web3 protocols.
4747

48-
4948
## Getting Started
5049

5150
First, run the development server:

src/components/cactiComponents/ActionResponse.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect, useMemo, useState } from 'react';
22
import Skeleton from 'react-loading-skeleton';
3+
import { TransactionReceipt } from '@ethersproject/abstract-provider';
34
import { AddressZero } from '@ethersproject/constants';
45
import { CheckCircleIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline';
56
import { ConnectButton } from '@rainbow-me/rainbowkit';
@@ -13,7 +14,6 @@ import { ActionStepper } from './ActionStepper';
1314
import useApproval, { ApprovalBasicParams } from './hooks/useApproval';
1415
import useBalance from './hooks/useBalance';
1516
import useSubmitTx, { TxBasicParams } from './hooks/useSubmitTx';
16-
import { TransactionReceipt } from '@ethersproject/abstract-provider';
1717

1818
export enum ActionResponseState {
1919
LOADING = 'LOADING', // background async checks
@@ -58,7 +58,7 @@ export type ActionResponseProps = {
5858
disabled?: boolean;
5959
skipBalanceCheck?: boolean;
6060
stepper?: boolean;
61-
onSuccess?: (receipt?: TransactionReceipt ) => void;
61+
onSuccess?: (receipt?: TransactionReceipt) => void;
6262
onError?: (receipt?: TransactionReceipt) => void;
6363
};
6464

@@ -78,7 +78,6 @@ export const ActionResponse = ({
7878
onSuccess,
7979
onError,
8080
}: ActionResponseProps) => {
81-
8281
const { address } = useAccount();
8382
const _approvalParams = useMemo<ApprovalBasicParams>(
8483
() =>
@@ -153,7 +152,6 @@ export const ActionResponse = ({
153152
* Update all the local states on tx/approval status changes.
154153
**/
155154
useEffect(() => {
156-
157155
if (disabled) {
158156
setButtonLabel(label ?? 'Disabled');
159157
return setState(ActionResponseState.DISABLED);

src/components/cactiComponents/DoubleLineResponse.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useMemo, useState } from 'react';
22
import { findTokenBySymbol } from '@/utils';
3+
import SkeletonWrap from '../shared/SkeletonWrap';
34
import { InlineChip } from './InlineChip';
45
import { ResponseWrap } from './helpers/layout';
5-
import SkeletonWrap from '../shared/SkeletonWrap';
66

77
/**
88
* Dual Line Response Elements are generally used for swap, trading etc. interfaces where user wants to get addtional information about a market, or token.

src/components/cactiComponents/ErrorResponse.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import { ResponseTitle, ResponseWrap } from './helpers/layout';
1010

1111
const textStyle = 'text-base text-white text-opacity-70 gap-1 ';
1212

13-
1413
export interface ErrorResponseProps {
15-
text: string,
16-
error: string,
14+
text: string;
15+
error: string;
1716
}
1817
/**
1918
* Error response element
@@ -31,7 +30,7 @@ export const ErrorResponse = (props: ErrorResponseProps): JSX.Element => {
3130
<Disclosure.Button as="div">
3231
<ResponseTitle>
3332
<div className="flex items-center gap-4 text-base">
34-
<div className="w-[16px]">
33+
<div className="w-[16px]">
3534
<ExclamationTriangleIcon />
3635
</div>
3736
{props.text}

src/components/cactiComponents/ImageResponse.tsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ const TagItem = (props: { tag: string }) => {
4040

4141
const Image = (props: { src?: string; alt?: string }) => {
4242
return (
43-
<div className="w-full h-[250px] gap-2 space-y-2 overflow-auto rounded-xl bg-white bg-opacity-5 p-2 ">
43+
<div className="h-[250px] w-full gap-2 space-y-2 overflow-auto rounded-xl bg-white bg-opacity-5 p-2 ">
4444
{props.src ? (
45-
<img className="rounded-xl object-cover w-full h-full" src={props.src} alt={props.alt} />
45+
<img className="h-full w-full rounded-xl object-cover" src={props.src} alt={props.alt} />
4646
) : (
47-
<div className="flex p-16 h-full items-center justify-center rounded-xl bg-white bg-opacity-10 text-lg text-white/50">
48-
<div className='font-thin' > <CameraIcon />No Image</div>
47+
<div className="flex h-full items-center justify-center rounded-xl bg-white bg-opacity-10 p-16 text-lg text-white/50">
48+
<div className="font-thin">
49+
{' '}
50+
<CameraIcon />
51+
No Image
52+
</div>
4953
</div>
5054
)}
5155
</div>
@@ -68,8 +72,10 @@ export const ImageResponse = ({
6872
const Title = () => (
6973
<ResponseTitle>
7074
<div>
71-
<div className={variant_ === ImageVariant.SHOWCASE ? 'text-lg': ''}> {title} </div>
72-
<div className={`text-white/50 ${variant_ === ImageVariant.SHOWCASE ? '': 'text-xs'}`}>{subTitle}</div>
75+
<div className={variant_ === ImageVariant.SHOWCASE ? 'text-lg' : ''}> {title} </div>
76+
<div className={`text-white/50 ${variant_ === ImageVariant.SHOWCASE ? '' : 'text-xs'}`}>
77+
{subTitle}
78+
</div>
7379
</div>
7480
{imageLink && ( // if has external link
7581
<div onClick={() => navigateToExternalUrl(imageLink!)}>

src/components/cactiComponents/SingleLineResponse.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ReactNode } from 'react';
22
import useToken from '@/hooks/useToken';
33
import { Token } from '@/types';
4+
import SkeletonWrap from '../shared/SkeletonWrap';
45
import { InlineChip } from './InlineChip';
56
import { ResponseWrap } from './helpers/layout';
6-
import SkeletonWrap from '../shared/SkeletonWrap';
77

88
/**
99
* Header Response Elements are indicating with what app, service, or contract a user is about to interact. User have the option to leave the service and open in a new window a direct link to the app or service if they want to interact through their UI rather through our interface.

src/components/cactiComponents/hooks/useSubmitTx.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { useEffect, useState } from 'react';
22
import { toast } from 'react-toastify';
33
import { TransactionReceipt } from '@ethersproject/abstract-provider';
44
import { useAddRecentTransaction } from '@rainbow-me/rainbowkit';
5-
import {
6-
CallOverrides,
7-
Overrides,
8-
PayableOverrides,
9-
UnsignedTransaction,
10-
} from 'ethers';
5+
import { CallOverrides, Overrides, PayableOverrides, UnsignedTransaction } from 'ethers';
116
import {
127
usePrepareContractWrite,
138
usePrepareSendTransaction,
@@ -77,7 +72,7 @@ const useSubmitTx = (
7772
isLoading: isPending,
7873
isError,
7974
isSuccess,
80-
status
75+
status,
8176
} = useWaitForTransaction({
8277
hash: data?.hash,
8378
onSuccess: () => {
@@ -120,7 +115,7 @@ const useSubmitTx = (
120115
isPending,
121116
isSuccess,
122117
error,
123-
status
118+
status,
124119
};
125120
};
126121

src/components/cactiComponents/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { FunctionComponent, ReactNode } from 'react';
22
import { ActionResponse, ActionResponseProps } from './ActionResponse';
33
import { DoubleLineResponse } from './DoubleLineResponse';
4+
import { ErrorResponse } from './ErrorResponse';
45
import { HeaderResponse } from './HeaderResponse';
56
import { IconResponse } from './IconResponse';
67
import { ImageResponse, ImageResponseProps } from './ImageResponse';
78
import { ListResponse } from './ListResponse';
89
import { SingleLineResponse } from './SingleLineResponse';
910
import { TextResponse } from './TextResponse';
10-
import { ErrorResponse } from './ErrorResponse';
1111

1212
export enum CactiResponse {
1313
TextResponse = 'TextResponse',
@@ -46,5 +46,5 @@ export {
4646
ListResponse,
4747
ActionResponse,
4848
ImageResponse,
49-
ErrorResponse
49+
ErrorResponse,
5050
};

src/components/current/BotThinking.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { ResponseWrap } from '../cactiComponents/helpers/layout';
32
import Avatar from '../shared/Avatar';
43

src/components/current/ChatHeader.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useMutationDeleteChat } from '@/api/chats/mutations';
55
import { useMutationDeleteSharedSession } from '@/api/shares/mutations';
66
import { useChatContext } from '@/contexts/ChatContext';
77
import useThread from '@/hooks/useThread';
8-
import InputWrap from './InputWrap';
98
import SkeletonWrap from '../shared/SkeletonWrap';
9+
import InputWrap from './InputWrap';
1010

1111
interface TooltipProps {
1212
children: ReactNode;

src/components/current/CustomConnectButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { PowerIcon } from '@heroicons/react/24/outline';
22
import { ConnectButton } from '@rainbow-me/rainbowkit';
33
import { formatEther } from 'ethers/lib/utils.js';
44
import { abbreviateHash, cleanValue } from '@/utils';
5-
import Avatar from '../shared/Avatar';
65
import useBalance from '../cactiComponents/hooks/useBalance';
76
import useEnsName from '../cactiComponents/hooks/useEnsName';
8-
import { buttonStyle } from './layout/sidebar/NewChatButton';
7+
import Avatar from '../shared/Avatar';
98
import SkeletonWrap from '../shared/SkeletonWrap';
9+
import { buttonStyle } from './layout/sidebar/NewChatButton';
1010

1111
const CustomConnectButton = () => {
1212
const { data: balance } = useBalance();

src/components/current/MessageInput.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ const MessageInput = () => {
141141
<CustomConnectButton />
142142
</div>
143143
) : (
144-
<div className="flex w-full justify-center animate-pulse text-sm text-white/30">Waiting for Cacti connection ...</div>
144+
<div className="flex w-full animate-pulse justify-center text-sm text-white/30">
145+
Waiting for Cacti connection ...
146+
</div>
145147
)}
146148
</>
147149
);

src/components/current/MessageTranslator.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { Fragment, useEffect, useMemo, useState } from 'react';
22
import { Message } from '@/contexts/ChatContext';
33
import { SharedStateContextProvider } from '@/contexts/SharedStateContext';
44
import { parseMessage } from '@/utils/parse-message';
5-
import Avatar from '../shared/Avatar';
6-
import { Widgetize } from '../legacy/legacyComponents/MessageTranslator';
75
import { ErrorResponse, TextResponse } from '../cactiComponents';
86
import { ImageVariant } from '../cactiComponents/ImageResponse';
97
import { TableResponse } from '../cactiComponents/TableResponse';
8+
import { Widgetize } from '../legacy/legacyComponents/MessageTranslator';
9+
import Avatar from '../shared/Avatar';
1010
import { FeedbackButton } from './FeedbackButton';
1111
import { MessageWrap } from './MessageWrap';
1212
import ListContainer from './containers/ListContainer';

src/components/current/MultiStepProgressIndicator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Spinner } from '../../utils';
2-
import Avatar from '../shared/Avatar';
32
import { ResponseWrap } from '../cactiComponents/helpers/layout';
3+
import Avatar from '../shared/Avatar';
44

55
export const MultiStepProgressIndicator = () => {
66
return (

src/components/current/WelcomeMessage.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const WelcomeBox = ({ onClick, children }: { onClick?: () => void; children: Rea
1919
text-white text-opacity-70 md:p-2 ${onClickClasses} center w-full`}
2020
onClick={onClick}
2121
>
22-
<p className="m-0 flex min-h-[48px] items-center justify-center font-light text-base ">&rdquo;{children}&rdquo;</p>
22+
<p className="m-0 flex min-h-[48px] items-center justify-center text-base font-light ">
23+
&rdquo;{children}&rdquo;
24+
</p>
2325
</div>
2426
);
2527
};
@@ -32,9 +34,7 @@ const WelcomeMessage = () => {
3234
const { sendMessage } = useChatContext();
3335
return (
3436
<div className="h-full place-items-center ">
35-
3637
<div className="mx-auto w-full max-w-4xl space-y-20">
37-
3838
<Image src={cactiImage} alt="CactiChat" className="mx-auto" width={400} height={300} />
3939

4040
<div className="grid grid-cols-1 gap-20 p-4 sm:grid-cols-3">
@@ -58,7 +58,9 @@ const WelcomeMessage = () => {
5858
<WelcomeBox onClick={() => sendMessage('Swap 0.1 ETH for DAI on Uniswap')}>
5959
Swap 0.1 ETH for DAI on Uniswap
6060
</WelcomeBox>
61-
<WelcomeBox onClick={() => sendMessage('Borrow 1000 USDC on yield Protocol with ETH collateral')}>
61+
<WelcomeBox
62+
onClick={() => sendMessage('Borrow 1000 USDC on yield Protocol with ETH collateral')}
63+
>
6264
Borrow 1000 USDC on yield Protocol with ETH collateral
6365
</WelcomeBox>
6466
<WelcomeBox onClick={() => sendMessage('Register the name [domain-name].eth on ENS')}>

src/components/current/containers/MultiStepContainer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react';
2-
import { UnsignedTransaction } from 'ethers';
32
import { TransactionReceipt } from '@ethersproject/abstract-provider';
3+
import { UnsignedTransaction } from 'ethers';
44
import { useChatContext } from '@/contexts/ChatContext';
55
import { ActionResponse, HeaderResponse } from '../../cactiComponents';
66
import { WidgetError } from '../widgets/helpers';

src/components/current/layout/sidebar/index.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import dynamic from 'next/dynamic';
22
import SidebarContainer from './SidebarContainer';
33

4-
const SidebarInnerDynamic = dynamic(
5-
() => import('@/components/current/layout/sidebar/SideBar'),
6-
{
7-
ssr: false,
8-
}
9-
);
4+
const SidebarInnerDynamic = dynamic(() => import('@/components/current/layout/sidebar/SideBar'), {
5+
ssr: false,
6+
});
107

118
const Sidebar = ({
129
isOpen,

src/components/current/widgets/nft/NftAsset.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ export interface NftAssetProps {
1313
previewImageUrl?: string;
1414
variant?: ImageVariant; // widget variant
1515
price?: string;
16-
attributes?: {trait_type: string, value: string}[];
16+
attributes?: { trait_type: string; value: string }[];
1717
}
1818

19-
const TraitList = ({ attributes }: { attributes: {trait_type: string, value: string}[] }) => {
19+
const TraitList = ({ attributes }: { attributes: { trait_type: string; value: string }[] }) => {
2020
return (
2121
<div className="">
2222
{attributes.map((attribute, index) => (
23-
<div key={index} className="text-xs mr-2 mb-2">
23+
<div key={index} className="mb-2 mr-2 text-xs">
2424
<span className="font-bold">{attribute.trait_type}</span>: {attribute.value}
2525
</div>
2626
))}
2727
</div>
28-
)
29-
30-
}
28+
);
29+
};
3130

3231
export const NftAsset = ({
3332
network,
@@ -38,16 +37,15 @@ export const NftAsset = ({
3837
previewImageUrl,
3938
variant,
4039
price,
41-
attributes
40+
attributes,
4241
}: NftAssetProps) => {
43-
4442
return (
4543
<ImageResponse
4644
image={previewImageUrl}
4745
imageTags={
4846
variant === ImageVariant.SHOWCASE
4947
? [`Token Id: ${tokenId}`, `${network.replace('-mainnet', '')}`]
50-
: [`Token Id: ${tokenId}`] // always show the token id
48+
: [`Token Id: ${tokenId}`] // always show the token id
5149
}
5250
title={name}
5351
subTitle={collectionName}

src/components/current/widgets/nft/NftCollection.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Network, useCollection } from '@center-inc/react';
22
import { Address } from 'wagmi';
33
import { ImageResponse } from '@/components/cactiComponents';
44
import { ImageVariant } from '@/components/cactiComponents/ImageResponse';
5+
import { abbreviateHash } from '@/utils';
56
import { Widget } from '../../MessageTranslator';
67
import ListContainer from '../../containers/ListContainer';
78
import { NftAsset } from './NftAsset';
8-
import { abbreviateHash } from '@/utils';
99

1010
interface NftCollectionContainerProps {
1111
network: Network;
@@ -28,7 +28,6 @@ export const NftCollection = ({
2828
variant,
2929
assetsToShow = [],
3030
}: NftCollectionContainerProps) => {
31-
3231
/**
3332
* Get the array of the asset ids to show:
3433
* */
@@ -53,9 +52,9 @@ export const NftCollection = ({
5352
items={[
5453
<ImageResponse
5554
image={previewImageUrl}
56-
imageTags={[`${(numAssets || 'Unknown')!.toString()} Assets`, network.split("-")[0] ]}
55+
imageTags={[`${(numAssets || 'Unknown')!.toString()} Assets`, network.split('-')[0]]}
5756
title={name}
58-
subTitle={abbreviateHash(address,8)}
57+
subTitle={abbreviateHash(address, 8)}
5958
imageLink={`https://center.app/${network}/collections/${address}`}
6059
key={address}
6160
variant={variant}

0 commit comments

Comments
 (0)