11import { useState , useEffect , useRef } from 'react' ;
22import { hardhat , polygonZkEvmTestnet } from 'viem/chains' ;
3- import { Client , ClientOptions , createClient , storage } from '../../../src/index.js' ; // @windingtree /sdk
4- import { RequestQuery , OfferOptions , contractsConfig , serverAddress } from '../../shared/index.js' ;
3+ import {
4+ Client ,
5+ ClientOptions ,
6+ createClient ,
7+ storage ,
8+ } from '../../../src/index.js' ; // @windingtree /sdk
9+ import {
10+ RequestQuery ,
11+ OfferOptions ,
12+ contractsConfig ,
13+ serverAddress ,
14+ } from '../../shared/index.js' ;
515import { OfferData } from '../../../src/shared/types.js' ;
616import { useWallet } from './providers/WalletProvider/WalletProviderContext.js' ;
717import { AccountWidget } from './providers/WalletProvider/AccountWidget.js' ;
@@ -13,7 +23,8 @@ import { Offers } from './components/Offers.js';
1323import { Deals , DealsRegistryRecord } from './components/Deals.js' ;
1424
1525/** Target chain config */
16- const chain = import . meta. env . LOCAL_NODE === 'true' ? hardhat : polygonZkEvmTestnet ;
26+ const chain =
27+ import . meta. env . LOCAL_NODE === 'true' ? hardhat : polygonZkEvmTestnet ;
1728
1829/** Default request expiration time */
1930const defaultExpire = '30s' ;
@@ -31,8 +42,12 @@ export const App = () => {
3142 const [ selectedTab , setSelectedTab ] = useState < number > ( 0 ) ;
3243 const [ requests , setRequests ] = useState < RequestsRegistryRecord [ ] > ( [ ] ) ;
3344 const [ deals , setDeals ] = useState < DealsRegistryRecord [ ] > ( [ ] ) ;
34- const [ offers , setOffers ] = useState < OfferData < RequestQuery , OfferOptions > [ ] | undefined > ( ) ;
35- const [ offer , setOffer ] = useState < OfferData < RequestQuery , OfferOptions > | undefined > ( ) ;
45+ const [ offers , setOffers ] = useState <
46+ OfferData < RequestQuery , OfferOptions > [ ] | undefined
47+ > ( ) ;
48+ const [ offer , setOffer ] = useState <
49+ OfferData < RequestQuery , OfferOptions > | undefined
50+ > ( ) ;
3651 const [ error , setError ] = useState < string | undefined > ( ) ;
3752
3853 /** This hook starts the client that will be available via `client.current` */
@@ -60,9 +75,12 @@ export const App = () => {
6075
6176 const updateDeals = ( ) => {
6277 if ( client . current ) {
63- client . current . deals . getAll ( ) . then ( ( newDeals ) => {
64- setDeals ( newDeals ) ;
65- } ) . catch ( console . error ) ;
78+ client . current . deals
79+ . getAll ( )
80+ . then ( ( newDeals ) => {
81+ setDeals ( newDeals ) ;
82+ } )
83+ . catch ( console . error ) ;
6684 }
6785 } ;
6886
@@ -80,12 +98,18 @@ export const App = () => {
8098
8199 client . current . addEventListener ( 'connected' , ( ) => {
82100 setConnected ( true ) ;
83- console . log ( '🔗 Client connected to server at:' , new Date ( ) . toISOString ( ) ) ;
101+ console . log (
102+ '🔗 Client connected to server at:' ,
103+ new Date ( ) . toISOString ( ) ,
104+ ) ;
84105 } ) ;
85106
86107 client . current . addEventListener ( 'disconnected' , ( ) => {
87108 setConnected ( false ) ;
88- console . log ( '🔌 Client disconnected from server at:' , new Date ( ) . toISOString ( ) ) ;
109+ console . log (
110+ '🔌 Client disconnected from server at:' ,
111+ new Date ( ) . toISOString ( ) ,
112+ ) ;
89113 } ) ;
90114
91115 /** Listening for requests events and update tables */
@@ -137,15 +161,21 @@ export const App = () => {
137161
138162 return (
139163 < >
140- < div style = { { display : 'flex' , flexDirection : 'row' , alignItems : 'center' } } >
164+ < div
165+ style = { { display : 'flex' , flexDirection : 'row' , alignItems : 'center' } }
166+ >
141167 < div style = { { flex : 1 } } >
142168 < h1 > Client</ h1 >
143169 </ div >
144170 < AccountWidget />
145171 </ div >
146172 { client . current && < div > ✅ Client started</ div > }
147173 { connected && < div > ✅ Connected to the coordination server</ div > }
148- < RequestForm connected = { connected } onSubmit = { sendRequest } defaultTopic = { defaultTopic } />
174+ < RequestForm
175+ connected = { connected }
176+ onSubmit = { sendRequest }
177+ defaultTopic = { defaultTopic }
178+ />
149179 < Tabs
150180 tabs = { [
151181 {
0 commit comments