@@ -3,38 +3,30 @@ import InputLabel from "@mui/material/InputLabel";
3
3
import MenuItem from "@mui/material/MenuItem" ;
4
4
import FormControl from "@mui/material/FormControl" ;
5
5
import Select , { SelectChangeEvent } from "@mui/material/Select" ;
6
- import { AztecEnv , AztecContext } from "../../aztecEnv" ;
6
+ import { AztecEnv , AztecContext , WebLogger } from "../../aztecEnv" ;
7
7
import { createStore } from "@aztec/kv-store/indexeddb" ;
8
- import {
9
- AccountWalletWithSecretKey ,
10
- Fr ,
11
- TxHash ,
12
- createLogger ,
13
- AztecAddress ,
14
- } from "@aztec/aztec.js" ;
8
+ import { AccountWalletWithSecretKey , Fr , AztecAddress } from "@aztec/aztec.js" ;
15
9
import { WalletDB } from "../../utils/storage" ;
16
10
import { useContext , useEffect , useState } from "react" ;
17
11
import { CreateAccountDialog } from "./components/createAccountDialog" ;
18
12
import { getSchnorrAccount } from "@aztec/accounts/schnorr" ;
19
13
import AddIcon from "@mui/icons-material/Add" ;
20
- import logoURL from "../../assets/Aztec_logo.png" ;
21
14
import { Button , Divider , Typography } from "@mui/material" ;
22
15
import {
23
16
formatFrAsString ,
24
17
parseAliasedBuffersAsString ,
25
18
} from "../../utils/conversion" ;
26
- import { convertFromUTF8BufferAsString } from "../../utils/conversion" ;
27
- import { ContractFunctionInteractionTx } from "../../utils/txs" ;
28
19
import ContactsIcon from "@mui/icons-material/Contacts" ;
29
20
import { CopyToClipboardButton } from "../common/copyToClipboardButton" ;
30
21
import { AddSendersDialog } from "./components/addSenderDialog" ;
31
22
import { deriveSigningKey } from "@aztec/circuits.js/keys" ;
23
+ import { TxsPanel } from "./components/txsPanel" ;
32
24
33
25
const container = css ( {
34
26
display : "flex" ,
35
27
flexDirection : "column" ,
36
28
height : "100%" ,
37
- width : "25vw " ,
29
+ width : "100% " ,
38
30
backgroundColor : "var(--mui-palette-primary-light)" ,
39
31
overflow : "hidden" ,
40
32
padding : "0 0.5rem" ,
@@ -57,30 +49,6 @@ const header = css({
57
49
marginBottom : "1rem" ,
58
50
} ) ;
59
51
60
- const logo = css ( {
61
- height : "90%" ,
62
- margin : "0.5rem 1rem 0rem 0rem" ,
63
- } ) ;
64
-
65
- const txPanel = css ( {
66
- marginBottom : "0.5rem" ,
67
- width : "100%" ,
68
- backgroundColor : "var(--mui-palette-primary-main)" ,
69
- maxHeight : "30vh" ,
70
- overflowY : "auto" ,
71
- borderRadius : "0.5rem" ,
72
- } ) ;
73
-
74
- const txData = css ( {
75
- display : "flex" ,
76
- flexDirection : "column" ,
77
- alignItems : "center" ,
78
- padding : "0.5rem" ,
79
- backgroundColor : "var(--mui-palette-primary-light)" ,
80
- borderRadius : "0.5rem" ,
81
- margin : "0.5rem" ,
82
- } ) ;
83
-
84
52
const NETWORKS = [
85
53
{
86
54
nodeURL : "http://localhost:8080" ,
@@ -99,17 +67,17 @@ export function SidebarComponent() {
99
67
setWallet,
100
68
setCurrentContractAddress,
101
69
setAztecNode,
102
- currentTx ,
70
+ setLogs ,
103
71
currentContractAddress,
104
72
wallet,
105
73
walletDB,
106
74
nodeURL,
107
75
isPXEInitialized,
108
76
pxe,
109
77
} = useContext ( AztecContext ) ;
78
+ const [ changingNetworks , setChangingNetworks ] = useState ( false ) ;
110
79
const [ accounts , setAccounts ] = useState ( [ ] ) ;
111
80
const [ contracts , setContracts ] = useState ( [ ] ) ;
112
- const [ transactions , setTransactions ] = useState ( [ ] ) ;
113
81
const [ openCreateAccountDialog , setOpenCreateAccountDialog ] = useState ( false ) ;
114
82
const [ openAddSendersDialog , setOpenAddSendersDialog ] = useState ( false ) ;
115
83
@@ -134,15 +102,17 @@ export function SidebarComponent() {
134
102
} ;
135
103
136
104
const handleNetworkChange = async ( event : SelectChangeEvent ) => {
105
+ setChangingNetworks ( true ) ;
137
106
setPXEInitialized ( false ) ;
138
107
const nodeURL = event . target . value ;
139
108
setNodeURL ( nodeURL ) ;
140
109
const node = await AztecEnv . connectToNode ( nodeURL ) ;
141
110
setAztecNode ( node ) ;
142
- const pxe = await AztecEnv . initPXE ( node ) ;
111
+ const pxe = await AztecEnv . initPXE ( node , setLogs ) ;
143
112
const rollupAddress = ( await pxe . getNodeInfo ( ) ) . l1ContractAddresses
144
113
. rollupAddress ;
145
- const walletLogger = createLogger ( "wallet:data:indexeddb" ) ;
114
+ const walletLogger =
115
+ WebLogger . getInstance ( ) . createLogger ( "wallet:data:idb" ) ;
146
116
const walletDBStore = await createStore (
147
117
`wallet-${ rollupAddress } ` ,
148
118
{ dataDirectory : "wallet" , dataStoreMapSizeKB : 2e10 } ,
@@ -153,6 +123,7 @@ export function SidebarComponent() {
153
123
setPXE ( pxe ) ;
154
124
setWalletDB ( walletDB ) ;
155
125
setPXEInitialized ( true ) ;
126
+ setChangingNetworks ( false ) ;
156
127
} ;
157
128
158
129
useEffect ( ( ) => {
@@ -175,44 +146,6 @@ export function SidebarComponent() {
175
146
}
176
147
} , [ wallet , walletDB , pxe ] ) ;
177
148
178
- useEffect ( ( ) => {
179
- const refreshTransactions = async ( ) => {
180
- const txsPerContract = await walletDB . retrieveTxsPerContract (
181
- currentContractAddress
182
- ) ;
183
- const txHashes = txsPerContract . map ( ( txHash ) =>
184
- TxHash . fromString ( convertFromUTF8BufferAsString ( txHash ) )
185
- ) ;
186
- const txs : ContractFunctionInteractionTx [ ] = await Promise . all (
187
- txHashes . map ( async ( txHash ) => {
188
- const txData = await walletDB . retrieveTxData ( txHash ) ;
189
- return {
190
- contractAddress : currentContractAddress ,
191
- txHash : txData . txHash ,
192
- status : convertFromUTF8BufferAsString ( txData . status ) ,
193
- fnName : convertFromUTF8BufferAsString ( txData . fnName ) ,
194
- date : parseInt ( convertFromUTF8BufferAsString ( txData . date ) ) ,
195
- } as ContractFunctionInteractionTx ;
196
- } )
197
- ) ;
198
- txs . sort ( ( a , b ) => ( b . date >= a . date ? - 1 : 1 ) ) ;
199
- if (
200
- currentTx &&
201
- currentTx . contractAddress === currentContractAddress &&
202
- ( ! currentTx . txHash ||
203
- ! txs . find ( ( tx ) => tx . txHash . equals ( currentTx . txHash ) ) )
204
- ) {
205
- txs . unshift ( currentTx ) ;
206
- }
207
- setTransactions ( txs ) ;
208
- } ;
209
- if ( currentContractAddress && walletDB ) {
210
- refreshTransactions ( ) ;
211
- } else {
212
- setTransactions ( [ ] ) ;
213
- }
214
- } , [ currentContractAddress , currentTx ] ) ;
215
-
216
149
const handleAccountChange = async ( event : SelectChangeEvent ) => {
217
150
if ( event . target . value == "" ) {
218
151
return ;
@@ -273,7 +206,6 @@ export function SidebarComponent() {
273
206
return (
274
207
< div css = { container } >
275
208
< div css = { header } >
276
- < img css = { logo } src = { logoURL } />
277
209
< Typography
278
210
variant = "h1"
279
211
sx = { { fontSize : "65px" , padding : 0 , marginTop : "0.5rem" } }
@@ -288,6 +220,7 @@ export function SidebarComponent() {
288
220
fullWidth
289
221
value = { nodeURL }
290
222
label = "Network"
223
+ disabled = { changingNetworks }
291
224
onChange = { handleNetworkChange }
292
225
>
293
226
{ NETWORKS . map ( ( network ) => (
@@ -373,30 +306,7 @@ export function SidebarComponent() {
373
306
< div css = { { flex : "1 0 auto" , margin : "auto" } } />
374
307
< Typography variant = "overline" > Transactions</ Typography >
375
308
< Divider />
376
- < div css = { txPanel } >
377
- { transactions . map ( ( tx ) => (
378
- < div css = { txData } key = { tx . txHash ?? "" } >
379
- < div css = { { display : "flex" } } >
380
- < Typography variant = "body2" >
381
- { tx . txHash ? formatFrAsString ( tx . txHash . toString ( ) ) : "()" }
382
- -
383
- </ Typography >
384
- < Typography variant = "subtitle2" sx = { { fontWeight : 800 } } >
385
- { tx . receipt
386
- ? tx . receipt . status . toUpperCase ( )
387
- : tx . status . toUpperCase ( ) }
388
-
389
- { tx . receipt && tx . receipt . status === "error"
390
- ? tx . receipt . error
391
- : tx . error }
392
- </ Typography >
393
- </ div >
394
- < Typography variant = "body2" >
395
- { tx . fnName } @{ formatFrAsString ( tx . contractAddress . toString ( ) ) }
396
- </ Typography >
397
- </ div >
398
- ) ) }
399
- </ div >
309
+ < TxsPanel />
400
310
< CreateAccountDialog
401
311
open = { openCreateAccountDialog }
402
312
onClose = { handleAccountCreation }
0 commit comments