Skip to content

Commit 46a3e85

Browse files
Thunkarthunkar
and
thunkar
authoredFeb 3, 2025··
chore: improve boxes (#11656)
Ensure compilation outside of the monorepo, improve webapp and bundling --------- Co-authored-by: thunkar <gregjquiros@gmail.com>
1 parent e84a81a commit 46a3e85

28 files changed

+1132
-649
lines changed
 

‎boxes/bootstrap.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function test {
3535

3636
function test_cmds {
3737
for browser in chromium webkit; do
38-
for box in vanilla react; do
38+
for box in vanilla react vite; do
3939
echo "boxes/scripts/run_test.sh $box $browser"
4040
done
4141
done

‎boxes/boxes/react/webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import CopyPlugin from 'copy-webpack-plugin';
22
import { createRequire } from 'module';
33
import webpack from 'webpack';
44
import HtmlWebpackPlugin from 'html-webpack-plugin';
5+
import { resolve } from 'path';
6+
57
const require = createRequire(import.meta.url);
68

79
export default (_, argv) => ({
@@ -31,7 +33,7 @@ export default (_, argv) => ({
3133
new CopyPlugin({
3234
patterns: [
3335
{
34-
context: '../../../barretenberg/ts/dest/browser',
36+
context: resolve(require.resolve('@aztec/aztec.js'), '../'),
3537
from: '*.gz',
3638
},
3739
],

‎boxes/boxes/vite/.env

-1
This file was deleted.

‎boxes/boxes/vite/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ dist-ssr
2525

2626
artifacts/*
2727
codegenCache.json
28+
test-results/

‎boxes/boxes/vite/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "vite",
2+
"name": "@aztec/vite",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
@@ -8,9 +8,11 @@
88
"codegen": "${AZTEC_BUILDER:-aztec} codegen src/contracts/target -o artifacts",
99
"clean": "rm -rf ./dist .tsbuildinfo ./artifacts ./src/contracts/target",
1010
"prep": "yarn clean && yarn compile && yarn codegen",
11-
"dev": "vite",
1211
"build": "yarn prep && tsc -b && vite build",
13-
"lint": "eslint .",
12+
"serve": "vite",
13+
"test": "npx playwright test",
14+
"formatting": "prettier --check ./src && eslint ./src",
15+
"formatting:fix": "prettier -w ./src",
1416
"preview": "vite preview"
1517
},
1618
"dependencies": {

‎boxes/boxes/vite/playwright.config.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { defineConfig, devices } from "@playwright/test";
2+
3+
export default defineConfig({
4+
testDir: "./tests",
5+
testMatch: "**.spec.ts",
6+
fullyParallel: true,
7+
retries: 3,
8+
workers: process.env.CI ? 1 : 3,
9+
reporter: "list",
10+
use: {
11+
baseURL: "http://127.0.0.1:5173",
12+
trace: "on-first-retry",
13+
screenshot: "only-on-failure",
14+
video: "on-first-retry",
15+
},
16+
expect: {
17+
timeout: 90000,
18+
},
19+
projects: [
20+
{
21+
name: "chromium",
22+
use: { ...devices["Desktop Chrome"] },
23+
},
24+
{
25+
name: "firefox",
26+
use: { ...devices["Desktop Firefox"] },
27+
},
28+
{
29+
name: "webkit",
30+
use: { ...devices["Desktop Safari"] },
31+
},
32+
],
33+
webServer: {
34+
command: "yarn serve --host",
35+
port: 5173,
36+
},
37+
});

‎boxes/boxes/vite/src/config.ts

+6-16
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,21 @@ import { createStore } from "@aztec/kv-store/indexeddb";
1616
import { BBWASMLazyPrivateKernelProver } from "@aztec/bb-prover/wasm/lazy";
1717
import { WASMSimulator } from "@aztec/simulator/client";
1818

19-
process.env = Object.keys(import.meta.env).reduce((acc, key) => {
20-
acc[key.replace("VITE_", "")] = import.meta.env[key];
21-
return acc;
22-
}, {});
23-
2419
const SECRET_KEY = Fr.random();
2520

2621
export class PrivateEnv {
2722
pxe;
2823
accountContract;
2924
accountManager: AccountManager;
3025

31-
constructor(
32-
private secretKey: Fr,
33-
private nodeURL: string,
34-
) {}
26+
constructor(private secretKey: Fr) {}
3527

3628
async init() {
29+
const nodeURL = process.env.AZTEC_NODE_URL ?? "http://localhost:8080";
30+
3731
const config = getPXEServiceConfig();
3832
config.dataDirectory = "pxe";
39-
config.proverEnabled = true;
40-
const aztecNode = await createAztecNodeClient(this.nodeURL);
33+
const aztecNode = await createAztecNodeClient(nodeURL);
4134
const simulationProvider = new WASMSimulator();
4235
const proofCreator = new BBWASMLazyPrivateKernelProver(
4336
simulationProvider,
@@ -52,7 +45,7 @@ export class PrivateEnv {
5245
const store = await createStore(
5346
"pxe_data",
5447
configWithContracts,
55-
createLogger("pxe:data:indexeddb"),
48+
createLogger("pxe:data:idb"),
5649
);
5750

5851
const keyStore = new KeyStore(store);
@@ -87,10 +80,7 @@ export class PrivateEnv {
8780
}
8881
}
8982

90-
export const deployerEnv = new PrivateEnv(
91-
SECRET_KEY,
92-
process.env.AZTEC_NODE_URL,
93-
);
83+
export const deployerEnv = new PrivateEnv(SECRET_KEY);
9484

9585
const IGNORE_FUNCTIONS = [
9686
"constructor",

‎boxes/boxes/vite/src/main.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { createRoot } from "react-dom/client";
33
import "./index.css";
44
import App from "./App.tsx";
55

6+
process.env = Object.keys(import.meta.env).reduce((acc, key) => {
7+
acc[key.replace("VITE_", "")] = import.meta.env[key];
8+
return acc;
9+
}, {});
10+
611
createRoot(document.getElementById("root")!).render(
712
<StrictMode>
813
<App />
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('test', async ({ page }) => {
4+
test.slow();
5+
await page.goto('/');
6+
7+
// Deploy contract
8+
await page.getByRole('button', { name: 'Deploy dummy contract' }).click();
9+
await expect(page.getByText('Deploying contract...')).toBeVisible();
10+
await expect(page.getByText('Address:')).toBeVisible();
11+
12+
// Read number
13+
await page.getByRole('button', { name: 'Read' }).click();
14+
await expect(page.getByText('Number is:')).toBeVisible();
15+
16+
// Set number
17+
await page.locator('#numberToSet').fill('1');
18+
await page.getByRole('button', { name: 'Write' }).click();
19+
await expect(page.getByText('Setting number...')).toBeVisible();
20+
await expect(page.getByText('Number set to: 1')).toBeVisible();
21+
22+
// Read number
23+
await page.getByRole('button', { name: 'Read' }).click();
24+
await expect(page.getByText('Number is: 1')).toBeVisible();
25+
});

‎boxes/boxes/vite/tests/node.test.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { AccountWallet, CompleteAddress, Contract, Fr, createLogger } from '@aztec/aztec.js';
2+
import { BoxReactContract } from '../artifacts/BoxReact.js';
3+
import { deployerEnv } from '../src/config.js';
4+
5+
const logger = createLogger('aztec:http-pxe-client');
6+
7+
describe('BoxReact Contract Tests', () => {
8+
let wallet: AccountWallet;
9+
let contract: Contract;
10+
const numberToSet = Fr.random();
11+
let accountCompleteAddress: CompleteAddress;
12+
13+
beforeAll(async () => {
14+
wallet = await deployerEnv.getWallet();
15+
accountCompleteAddress = wallet.getCompleteAddress();
16+
const salt = Fr.random();
17+
18+
contract = await BoxReactContract.deploy(
19+
wallet,
20+
Fr.random(),
21+
accountCompleteAddress.address
22+
)
23+
.send({ contractAddressSalt: salt })
24+
.deployed();
25+
26+
logger.info(`L2 contract deployed at ${contract.address}`);
27+
}, 60000);
28+
29+
test('Can set a number', async () => {
30+
logger.info(`${await wallet.getRegisteredAccounts()}`);
31+
32+
await contract.methods
33+
.setNumber(
34+
numberToSet,
35+
accountCompleteAddress.address
36+
)
37+
.send()
38+
.wait();
39+
}, 40000);
40+
41+
test('Can read a number', async () => {
42+
const viewTxReceipt = await contract.methods.getNumber(accountCompleteAddress.address).simulate();
43+
expect(numberToSet.toBigInt()).toEqual(viewTxReceipt.value);
44+
}, 40000);
45+
});

‎boxes/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ services:
4949
ETHEREUM_HOST: http://ethereum:8545
5050
L1_CHAIN_ID: 31337
5151
PXE_URL: http://aztec:8080
52+
VITE_AZTEC_NODE_URL: http://aztec:8080
5253
BOX: ${BOX:-vanilla}
5354
CI: ${CI:-}
5455
BROWSER: ${BROWSER:-chromium}

‎boxes/yarn.lock

+31-31
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,37 @@ __metadata:
134134
languageName: unknown
135135
linkType: soft
136136

137+
"@aztec/vite@workspace:boxes/vite":
138+
version: 0.0.0-use.local
139+
resolution: "@aztec/vite@workspace:boxes/vite"
140+
dependencies:
141+
"@aztec/accounts": "npm:latest"
142+
"@aztec/aztec.js": "npm:latest"
143+
"@aztec/bb-prover": "npm:latest"
144+
"@aztec/circuit-types": "npm:latest"
145+
"@aztec/key-store": "npm:latest"
146+
"@aztec/kv-store": "npm:latest"
147+
"@aztec/pxe": "npm:latest"
148+
"@aztec/simulator": "npm:latest"
149+
"@eslint/js": "npm:^9.13.0"
150+
"@types/react": "npm:^18.3.12"
151+
"@types/react-dom": "npm:^18.3.1"
152+
"@vitejs/plugin-react-swc": "npm:^3.7.2"
153+
eslint: "npm:^9.13.0"
154+
eslint-plugin-react-hooks: "npm:^5.1.0"
155+
eslint-plugin-react-refresh: "npm:^0.4.16"
156+
globals: "npm:^15.11.0"
157+
react: "npm:^18.3.1"
158+
react-dom: "npm:^18.3.1"
159+
react-toastify: "npm:^10.0.6"
160+
typescript: "npm:~5.6.2"
161+
typescript-eslint: "npm:^8.11.0"
162+
vite: "npm:^6.0.3"
163+
vite-plugin-node-polyfills: "npm:^0.23.0"
164+
vite-plugin-static-copy: "npm:^2.2.0"
165+
languageName: unknown
166+
linkType: soft
167+
137168
"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.25.9":
138169
version: 7.26.2
139170
resolution: "@babel/code-frame@npm:7.26.2"
@@ -12292,37 +12323,6 @@ __metadata:
1229212323
languageName: node
1229312324
linkType: hard
1229412325

12295-
"vite@workspace:boxes/vite":
12296-
version: 0.0.0-use.local
12297-
resolution: "vite@workspace:boxes/vite"
12298-
dependencies:
12299-
"@aztec/accounts": "npm:latest"
12300-
"@aztec/aztec.js": "npm:latest"
12301-
"@aztec/bb-prover": "npm:latest"
12302-
"@aztec/circuit-types": "npm:latest"
12303-
"@aztec/key-store": "npm:latest"
12304-
"@aztec/kv-store": "npm:latest"
12305-
"@aztec/pxe": "npm:latest"
12306-
"@aztec/simulator": "npm:latest"
12307-
"@eslint/js": "npm:^9.13.0"
12308-
"@types/react": "npm:^18.3.12"
12309-
"@types/react-dom": "npm:^18.3.1"
12310-
"@vitejs/plugin-react-swc": "npm:^3.7.2"
12311-
eslint: "npm:^9.13.0"
12312-
eslint-plugin-react-hooks: "npm:^5.1.0"
12313-
eslint-plugin-react-refresh: "npm:^0.4.16"
12314-
globals: "npm:^15.11.0"
12315-
react: "npm:^18.3.1"
12316-
react-dom: "npm:^18.3.1"
12317-
react-toastify: "npm:^10.0.6"
12318-
typescript: "npm:~5.6.2"
12319-
typescript-eslint: "npm:^8.11.0"
12320-
vite: "npm:^6.0.3"
12321-
vite-plugin-node-polyfills: "npm:^0.23.0"
12322-
vite-plugin-static-copy: "npm:^2.2.0"
12323-
languageName: unknown
12324-
linkType: soft
12325-
1232612326
"vitest@npm:^2.0.5":
1232712327
version: 2.0.5
1232812328
resolution: "vitest@npm:2.0.5"

‎gaztec/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"name": "vite",
2+
"name": "gaztec",
3+
"packageManager": "yarn@4.5.2",
34
"private": true,
45
"version": "0.0.0",
56
"type": "module",
@@ -26,6 +27,7 @@
2627
"@mui/icons-material": "^6.3.1",
2728
"@mui/material": "^6.3.1",
2829
"@mui/styles": "^6.3.1",
30+
"nosleep.js": "^0.12.0",
2931
"react": "^18.3.1",
3032
"react-dom": "^18.3.1",
3133
"react-dropzone": "^14.3.5"
@@ -42,8 +44,8 @@
4244
"globals": "^15.14.0",
4345
"typescript": "~5.7.3",
4446
"typescript-eslint": "^8.11.0",
45-
"vite": "^6.0.7",
46-
"vite-plugin-node-polyfills": "^0.22.0",
47+
"vite": "^6.0.11",
48+
"vite-plugin-node-polyfills": "^0.23.0",
4749
"vite-plugin-static-copy": "^2.2.0"
4850
}
4951
}

‎gaztec/src/aztecEnv.ts

+86-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
AccountWalletWithSecretKey,
77
AztecAddress,
88
Contract,
9+
Logger,
910
} from "@aztec/aztec.js";
1011
import { PXEService } from "@aztec/pxe/service";
1112
import { PXEServiceConfig, getPXEServiceConfig } from "@aztec/pxe/config";
@@ -27,6 +28,68 @@ process.env = Object.keys(import.meta.env).reduce((acc, key) => {
2728

2829
debug.enable("*");
2930

31+
const logLevel = [
32+
"silent",
33+
"fatal",
34+
"error",
35+
"warn",
36+
"info",
37+
"verbose",
38+
"debug",
39+
"trace",
40+
] as const;
41+
42+
type Log = {
43+
type: (typeof logLevel)[number];
44+
timestamp: number;
45+
prefix: string;
46+
message: string;
47+
data: any;
48+
};
49+
50+
export class WebLogger {
51+
private static instance: WebLogger;
52+
private logs: Log[] = [];
53+
54+
private constructor(private setLogs: (logs: Log[]) => void) {}
55+
56+
static create(setLogs: (logs: Log[]) => void) {
57+
WebLogger.instance = new WebLogger(setLogs);
58+
}
59+
60+
static getInstance() {
61+
return WebLogger.instance;
62+
}
63+
64+
createLogger(prefix: string): Logger {
65+
return new Proxy(createLogger(prefix), {
66+
get: (target, prop, receiver) => {
67+
if (logLevel.includes(prop as (typeof logLevel)[number])) {
68+
return function () {
69+
const args = [prop, prefix, ...arguments] as Parameters<
70+
WebLogger["handleLog"]
71+
>;
72+
WebLogger.getInstance().handleLog(...args);
73+
target[prop].apply(this, arguments);
74+
};
75+
} else {
76+
return target[prop];
77+
}
78+
},
79+
});
80+
}
81+
82+
private handleLog(
83+
type: (typeof logLevel)[number],
84+
prefix: string,
85+
message: string,
86+
data: any
87+
) {
88+
this.logs.unshift({ type, prefix, message, data, timestamp: Date.now() });
89+
this.setLogs([...this.logs]);
90+
}
91+
}
92+
3093
export const AztecContext = createContext<{
3194
pxe: PXE | null;
3295
nodeURL: string;
@@ -37,6 +100,12 @@ export const AztecContext = createContext<{
37100
currentContractAddress: AztecAddress;
38101
currentContract: Contract;
39102
currentTx: ContractFunctionInteractionTx;
103+
logs: Log[];
104+
logsOpen: boolean;
105+
drawerOpen: boolean;
106+
setDrawerOpen: (drawerOpen: boolean) => void;
107+
setLogsOpen: (logsOpen: boolean) => void;
108+
setLogs: (logs: Log[]) => void;
40109
setWalletDB: (walletDB: WalletDB) => void;
41110
setPXEInitialized: (isPXEInitialized: boolean) => void;
42111
setWallet: (wallet: AccountWalletWithSecretKey) => void;
@@ -56,6 +125,12 @@ export const AztecContext = createContext<{
56125
currentContract: null,
57126
currentContractAddress: null,
58127
currentTx: null,
128+
logs: [],
129+
logsOpen: false,
130+
drawerOpen: false,
131+
setDrawerOpen: (drawerOpen: boolean) => {},
132+
setLogsOpen: (logsOpen: boolean) => {},
133+
setLogs: (logs: Log[]) => {},
59134
setWalletDB: (walletDB: WalletDB) => {},
60135
setPXEInitialized: (isPXEInitialized: boolean) => {},
61136
setWallet: (wallet: AccountWalletWithSecretKey) => {},
@@ -73,15 +148,21 @@ export class AztecEnv {
73148
return aztecNode;
74149
}
75150

76-
static async initPXE(aztecNode: AztecNode): Promise<PXE> {
151+
static async initPXE(
152+
aztecNode: AztecNode,
153+
setLogs: (logs: Log[]) => void
154+
): Promise<PXE> {
155+
WebLogger.create(setLogs);
156+
77157
const config = getPXEServiceConfig();
78158
config.dataDirectory = "pxe";
79159
config.proverEnabled = true;
80160

81161
const simulationProvider = new WASMSimulator();
82162
const proofCreator = new BBWASMLazyPrivateKernelProver(
83163
simulationProvider,
84-
16
164+
16,
165+
WebLogger.getInstance().createLogger("bb:wasm:lazy")
85166
);
86167
const l1Contracts = await aztecNode.getL1ContractAddresses();
87168
const configWithContracts = {
@@ -92,7 +173,7 @@ export class AztecEnv {
92173
const store = await createStore(
93174
"pxe_data",
94175
configWithContracts,
95-
createLogger("pxe:data:indexeddb")
176+
WebLogger.getInstance().createLogger("pxe:data:indexeddb")
96177
);
97178

98179
const keyStore = new KeyStore(store);
@@ -107,7 +188,8 @@ export class AztecEnv {
107188
tips,
108189
proofCreator,
109190
simulationProvider,
110-
config
191+
config,
192+
WebLogger.getInstance().createLogger("pxe:service")
111193
);
112194
await pxe.init();
113195
return pxe;

‎gaztec/src/components/contract/components/deployContractDialog.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export function DeployContractDialog({
5151
const [initializer, setInitializer] = useState<FunctionArtifact>(null);
5252
const [parameters, setParameters] = useState([]);
5353
const [deploying, setDeploying] = useState(false);
54-
const [aliasedAddresses, setAliasedAddresses] = useState([]);
55-
const { walletDB, wallet } = useContext(AztecContext);
54+
const [_aliasedAddresses, setAliasedAddresses] = useState([]);
55+
const { walletDB, wallet, setLogsOpen, setDrawerOpen } =
56+
useContext(AztecContext);
5657

5758
useEffect(() => {
5859
const defaultInitializer = getDefaultInitializer(contractArtifact);
@@ -78,6 +79,7 @@ export function DeployContractDialog({
7879

7980
const deploy = async () => {
8081
setDeploying(true);
82+
setLogsOpen(true);
8183

8284
const nodeInfo = await wallet.getNodeInfo();
8385
const expectedAztecNrVersion = `${GITHUB_TAG_PREFIX}-v${nodeInfo.nodeVersion}`;

‎gaztec/src/components/contract/contract.tsx

+161-117
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { CreateAuthwitDialog } from "./components/createAuthwitDialog";
4242
const container = css({
4343
display: "flex",
4444
height: "100vh",
45-
width: "75vw",
45+
width: "100%",
4646
overflow: "hidden",
4747
justifyContent: "center",
4848
alignItems: "center",
@@ -53,9 +53,9 @@ const dropZoneContainer = css({
5353
flexDirection: "column",
5454
width: "100%",
5555
height: "80%",
56-
border: "5px dashed black",
56+
border: "3px dashed black",
5757
borderRadius: "15px",
58-
margin: "5rem",
58+
margin: "0rem 2rem 2rem 2rem",
5959
});
6060

6161
const contractFnContainer = css({
@@ -66,11 +66,40 @@ const contractFnContainer = css({
6666
height: "100%",
6767
});
6868

69+
const headerContainer = css({
70+
display: "flex",
71+
flexDirection: "column",
72+
flexGrow: 1,
73+
flexWrap: "wrap",
74+
margin: "0 0.5rem",
75+
padding: "0.1rem",
76+
overflow: "hidden",
77+
justifyContent: "stretch",
78+
marginBottom: "0.5rem",
79+
});
80+
6981
const header = css({
7082
display: "flex",
83+
width: "100%",
84+
alignItems: "center",
85+
justifyContent: "space-between",
86+
});
87+
88+
const search = css({
89+
display: "flex",
90+
overflow: "hidden",
91+
"@media (width <= 800px)": {
92+
width: "100%",
93+
},
94+
"@media (width > 800px)": {
95+
maxWidth: "500px",
96+
},
97+
});
98+
99+
const contractActions = css({
100+
display: "flex",
101+
flexDirection: "row",
71102
alignItems: "center",
72-
margin: "0 1rem",
73-
padding: "1rem",
74103
});
75104

76105
const simulationContainer = css({
@@ -81,6 +110,7 @@ const simulationContainer = css({
81110

82111
const checkBoxLabel = css({
83112
height: "1.5rem",
113+
marginLeft: "-10px",
84114
});
85115

86116
const loadingArtifactContainer = css({
@@ -323,125 +353,135 @@ export function ContractComponent() {
323353
)
324354
) : (
325355
<div css={contractFnContainer}>
326-
<div css={header}>
327-
<Typography variant="h2" css={{ marginRight: "4rem" }}>
328-
{contractArtifact.name}
329-
</Typography>
330-
331-
<FormGroup>
332-
<Input
333-
type="text"
334-
placeholder="Search function"
335-
value={filters.searchTerm}
336-
onChange={(e) =>
337-
setFilters({ ...filters, searchTerm: e.target.value })
338-
}
339-
endAdornment={
340-
<InputAdornment position="end">
341-
<FindInPageIcon />
342-
</InputAdornment>
343-
}
344-
/>
345-
<div
346-
css={{
347-
display: "flex",
348-
flexDirection: "row",
349-
marginTop: "0.5rem",
350-
}}
351-
>
352-
<FormControlLabel
353-
css={checkBoxLabel}
354-
control={
355-
<Checkbox
356-
checked={filters.private}
357-
onChange={(e) =>
358-
setFilters({ ...filters, private: e.target.checked })
359-
}
360-
/>
361-
}
362-
label="Private"
363-
/>
364-
<FormControlLabel
365-
css={checkBoxLabel}
366-
control={
367-
<Checkbox
368-
checked={filters.public}
369-
onChange={(e) =>
370-
setFilters({ ...filters, public: e.target.checked })
371-
}
372-
/>
356+
<div css={headerContainer}>
357+
<div css={header}>
358+
<Typography variant="h3" css={{ marginRight: "0.5rem" }}>
359+
{contractArtifact.name}
360+
</Typography>
361+
{!currentContract && wallet && (
362+
<div css={contractActions}>
363+
<Button
364+
variant="contained"
365+
size="small"
366+
css={{ marginRight: "0.5rem" }}
367+
onClick={() => setOpenDeployContractDialog(true)}
368+
>
369+
Deploy
370+
</Button>
371+
<Button
372+
size="small"
373+
variant="contained"
374+
onClick={() => setOpenRegisterContractDialog(true)}
375+
>
376+
Register
377+
</Button>
378+
<DeployContractDialog
379+
contractArtifact={contractArtifact}
380+
open={openDeployContractDialog}
381+
onClose={handleContractCreation}
382+
/>
383+
<RegisterContractDialog
384+
contractArtifact={contractArtifact}
385+
open={openRegisterContractDialog}
386+
onClose={handleContractCreation}
387+
/>
388+
</div>
389+
)}
390+
{currentContract && (
391+
<div css={contractActions}>
392+
<Typography color="text.secondary">
393+
{formatFrAsString(currentContract.address.toString())}
394+
</Typography>
395+
<CopyToClipboardButton
396+
disabled={false}
397+
data={currentContract.address.toString()}
398+
/>
399+
<IconButton
400+
onClick={(e) => {
401+
setCurrentContractAddress(null);
402+
setCurrentContract(null);
403+
setContractArtifact(null);
404+
}}
405+
>
406+
<ClearIcon />
407+
</IconButton>
408+
</div>
409+
)}
410+
</div>
411+
<div css={search}>
412+
<FormGroup sx={{ width: "100%" }}>
413+
<Input
414+
type="text"
415+
fullWidth
416+
placeholder="Search function"
417+
value={filters.searchTerm}
418+
onChange={(e) =>
419+
setFilters({ ...filters, searchTerm: e.target.value })
373420
}
374-
label="Public"
375-
/>
376-
<FormControlLabel
377-
css={checkBoxLabel}
378-
control={
379-
<Checkbox
380-
checked={filters.unconstrained}
381-
onChange={(e) =>
382-
setFilters({
383-
...filters,
384-
unconstrained: e.target.checked,
385-
})
386-
}
387-
/>
421+
endAdornment={
422+
<InputAdornment position="end">
423+
<FindInPageIcon />
424+
</InputAdornment>
388425
}
389-
label="Unconstrained"
390-
/>
391-
</div>
392-
</FormGroup>
393-
<div css={{ flexGrow: 1 }}></div>
394-
{!currentContract && wallet && (
395-
<>
396-
<Button
397-
variant="contained"
398-
css={{ marginRight: "1rem" }}
399-
onClick={() => setOpenDeployContractDialog(true)}
400-
>
401-
Deploy
402-
</Button>
403-
<Button
404-
variant="contained"
405-
onClick={() => setOpenRegisterContractDialog(true)}
406-
>
407-
Register
408-
</Button>
409-
<DeployContractDialog
410-
contractArtifact={contractArtifact}
411-
open={openDeployContractDialog}
412-
onClose={handleContractCreation}
413-
/>
414-
<RegisterContractDialog
415-
contractArtifact={contractArtifact}
416-
open={openRegisterContractDialog}
417-
onClose={handleContractCreation}
418426
/>
419-
</>
420-
)}
421-
{currentContract && (
422-
<>
423-
<Typography color="text.secondary">
424-
{formatFrAsString(currentContract.address.toString())}
425-
</Typography>
426-
<CopyToClipboardButton
427-
disabled={false}
428-
data={currentContract.address.toString()}
429-
/>
430-
<IconButton
431-
onClick={(e) => {
432-
setCurrentContractAddress(null);
433-
setCurrentContract(null);
434-
setContractArtifact(null);
427+
<div
428+
css={{
429+
display: "flex",
430+
flexDirection: "row",
431+
marginTop: "0.5rem",
432+
width: "100%",
435433
}}
436434
>
437-
<ClearIcon />
438-
</IconButton>
439-
</>
440-
)}
435+
<FormControlLabel
436+
css={checkBoxLabel}
437+
control={
438+
<Checkbox
439+
sx={{ paddingRight: 0 }}
440+
checked={filters.private}
441+
onChange={(e) =>
442+
setFilters({ ...filters, private: e.target.checked })
443+
}
444+
/>
445+
}
446+
label="Private"
447+
/>
448+
<FormControlLabel
449+
css={checkBoxLabel}
450+
control={
451+
<Checkbox
452+
sx={{ padding: 0 }}
453+
checked={filters.public}
454+
onChange={(e) =>
455+
setFilters({ ...filters, public: e.target.checked })
456+
}
457+
/>
458+
}
459+
label="Public"
460+
/>
461+
<FormControlLabel
462+
css={checkBoxLabel}
463+
control={
464+
<Checkbox
465+
sx={{ padding: 0 }}
466+
checked={filters.unconstrained}
467+
onChange={(e) =>
468+
setFilters({
469+
...filters,
470+
unconstrained: e.target.checked,
471+
})
472+
}
473+
/>
474+
}
475+
label="Unconstrained"
476+
/>
477+
</div>
478+
</FormGroup>
479+
</div>
441480
</div>
442481
{contractArtifact.functions
443482
.filter(
444483
(fn) =>
484+
!fn.isInternal &&
445485
!FORBIDDEN_FUNCTIONS.includes(fn.name) &&
446486
((filters.private && fn.functionType === "private") ||
447487
(filters.public && fn.functionType === "public") ||
@@ -456,7 +496,8 @@ export function ContractComponent() {
456496
variant="outlined"
457497
sx={{
458498
backgroundColor: "primary.light",
459-
margin: "1rem",
499+
margin: "0.5rem",
500+
overflow: "hidden",
460501
}}
461502
>
462503
<CardContent sx={{ textAlign: "left" }}>
@@ -520,6 +561,7 @@ export function ContractComponent() {
520561
disabled={!wallet || !currentContract || isWorking}
521562
color="secondary"
522563
variant="contained"
564+
size="small"
523565
onClick={() => simulate(fn.name)}
524566
endIcon={<PsychologyIcon />}
525567
>
@@ -532,6 +574,7 @@ export function ContractComponent() {
532574
isWorking ||
533575
fn.functionType === "unconstrained"
534576
}
577+
size="small"
535578
color="secondary"
536579
variant="contained"
537580
onClick={() => send(fn.name)}
@@ -546,6 +589,7 @@ export function ContractComponent() {
546589
isWorking ||
547590
fn.functionType === "unconstrained"
548591
}
592+
size="small"
549593
color="secondary"
550594
variant="contained"
551595
onClick={() =>
@@ -557,7 +601,7 @@ export function ContractComponent() {
557601
}
558602
endIcon={<VpnKeyIcon />}
559603
>
560-
Create authwit
604+
Authwit
561605
</Button>
562606
</CardActions>
563607
</Card>
+9-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.dropzone {
2-
color: black;
3-
width: 100%;
4-
height: 100%;
5-
display: flex;
6-
justify-content: center;
7-
align-items: center;
8-
}
2+
color: black;
3+
width: 100%;
4+
height: 100%;
5+
display: flex;
6+
justify-content: center;
7+
align-items: center;
8+
padding: 2rem;
9+
text-align: center;
10+
}

‎gaztec/src/components/home/home.tsx

+53-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,40 @@ import { ContractComponent } from "../contract/contract";
33
import { SidebarComponent } from "../sidebar/sidebar";
44
import { useState } from "react";
55
import { AztecContext } from "../../aztecEnv";
6+
import NoSleep from "nosleep.js";
7+
import { LogPanel } from "../logPanel/logPanel";
8+
import logoURL from "../../assets/Aztec_logo.png";
9+
import { Box, Drawer } from "@mui/material";
610

711
const layout = css({
812
display: "flex",
913
flexDirection: "row",
1014
height: "100%",
1115
});
1216

17+
const logo = css({
18+
width: "100%",
19+
padding: "0.5rem",
20+
});
21+
22+
const collapsedDrawer = css({
23+
height: "100%",
24+
width: "4rem",
25+
backgroundColor: "var(--mui-palette-primary-light)",
26+
overflow: "hidden",
27+
});
28+
29+
const noSleep = new NoSleep();
30+
31+
function enableNoSleep() {
32+
noSleep.enable();
33+
document.removeEventListener("touchstart", enableNoSleep, false);
34+
}
35+
36+
// Enable wake lock.
37+
// (must be wrapped in a user input event handler e.g. a mouse or touch handler)
38+
document.addEventListener("touchstart", enableNoSleep, false);
39+
1340
export default function Home() {
1441
const [pxe, setPXE] = useState(null);
1542
const [wallet, setWallet] = useState(null);
@@ -21,6 +48,9 @@ export default function Home() {
2148
const [currentContract, setCurrentContract] = useState(null);
2249
const [currentTx, setCurrentTx] = useState(null);
2350
const [currentContractAddress, setCurrentContractAddress] = useState(null);
51+
const [logs, setLogs] = useState([]);
52+
const [logsOpen, setLogsOpen] = useState(false);
53+
const [drawerOpen, setDrawerOpen] = useState(false);
2454

2555
const AztecContextInitialValue = {
2656
pxe,
@@ -33,6 +63,12 @@ export default function Home() {
3363
currentTx,
3464
node,
3565
currentContractAddress,
66+
logs,
67+
logsOpen,
68+
drawerOpen,
69+
setDrawerOpen,
70+
setLogsOpen,
71+
setLogs,
3672
setAztecNode,
3773
setCurrentTx,
3874
setWalletDB,
@@ -48,7 +84,23 @@ export default function Home() {
4884
return (
4985
<div css={layout}>
5086
<AztecContext.Provider value={AztecContextInitialValue}>
51-
<SidebarComponent />
87+
<div css={collapsedDrawer} onClick={() => setDrawerOpen(!drawerOpen)}>
88+
<img css={logo} src={logoURL} />
89+
</div>
90+
<Drawer
91+
sx={{
92+
"& .MuiDrawer-paper": {
93+
height: "100%",
94+
width: "340px",
95+
},
96+
}}
97+
onClose={() => setDrawerOpen(false)}
98+
variant="temporary"
99+
open={drawerOpen}
100+
>
101+
<SidebarComponent />
102+
</Drawer>
103+
<LogPanel />
52104
<ContractComponent />
53105
</AztecContext.Provider>
54106
</div>
+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import { css, Global } from "@emotion/react";
2+
import { AztecContext } from "../../aztecEnv";
3+
import { useContext, useState } from "react";
4+
import {
5+
CircularProgress,
6+
CssBaseline,
7+
Fab,
8+
styled,
9+
SwipeableDrawer,
10+
Typography,
11+
} from "@mui/material";
12+
import ArticleIcon from "@mui/icons-material/Article";
13+
14+
const Root = styled("div")(({ theme }) => ({
15+
height: "100%",
16+
...theme.applyStyles("dark", {
17+
backgroundColor: theme.palette.background.default,
18+
}),
19+
}));
20+
21+
const StyledBox = styled("div")(({ theme }) => ({
22+
backgroundColor: "#fff",
23+
...theme.applyStyles("dark", {
24+
backgroundColor: "var(--mui-palette-primary)",
25+
}),
26+
}));
27+
28+
const Puller = styled("div")(({ theme }) => ({
29+
width: 30,
30+
height: 6,
31+
backgroundColor: "var(--mui-palette-primary-light)",
32+
borderRadius: 3,
33+
position: "absolute",
34+
top: 8,
35+
left: "calc(50% - 20px)",
36+
...theme.applyStyles("dark", {
37+
backgroundColor: "var(--mui-palette-primary-dark)",
38+
}),
39+
}));
40+
41+
const logContainer = css({
42+
display: "flex",
43+
flexDirection: "row",
44+
backgroundColor: "var(--mui-palette-primary-light)",
45+
margin: "0.1rem",
46+
padding: "0.1rem 0.25rem",
47+
borderRadius: "0.5rem",
48+
});
49+
50+
const logPrefix = css({
51+
width: "8rem",
52+
minWidth: "8rem",
53+
overflow: "hidden",
54+
});
55+
56+
const logContent = css({
57+
whiteSpace: "nowrap",
58+
textOverflow: "ellipsis",
59+
flexGrow: 1,
60+
overflow: "hidden",
61+
":hover": css({
62+
whiteSpace: "unset",
63+
textOverflow: "unset",
64+
wordWrap: "break-word",
65+
}),
66+
});
67+
68+
const logTimestamp = css({});
69+
70+
const safeStringify = (obj: any) =>
71+
JSON.stringify(obj, (_, v) => (typeof v === "bigint" ? v.toString() : v));
72+
73+
const drawerBleeding = 56;
74+
75+
export function LogPanel() {
76+
const { logs, logsOpen, setLogsOpen } = useContext(AztecContext);
77+
78+
const toggleDrawer = (newOpen: boolean) => () => {
79+
setLogsOpen(newOpen);
80+
};
81+
return (
82+
<>
83+
<Root>
84+
<CssBaseline />
85+
<Global
86+
styles={{
87+
".MuiDrawer-root > .MuiPaper-root": {
88+
height: `calc(50% - ${drawerBleeding}px)`,
89+
overflow: "visible",
90+
},
91+
}}
92+
/>
93+
<SwipeableDrawer
94+
anchor="bottom"
95+
open={logsOpen}
96+
onClose={toggleDrawer(false)}
97+
onOpen={toggleDrawer(true)}
98+
swipeAreaWidth={drawerBleeding}
99+
disableSwipeToOpen={false}
100+
ModalProps={{
101+
keepMounted: true,
102+
}}
103+
>
104+
<StyledBox
105+
sx={{
106+
display: "flex",
107+
flexDirection: "row",
108+
position: "absolute",
109+
top: -drawerBleeding,
110+
borderTopLeftRadius: 8,
111+
borderTopRightRadius: 8,
112+
visibility: "visible",
113+
right: 0,
114+
left: 0,
115+
alignItems: "center",
116+
}}
117+
>
118+
<Puller />
119+
<Typography sx={{ p: 2, color: "text.secondary" }}>
120+
{logs.length}&nbsp;logs
121+
</Typography>
122+
</StyledBox>
123+
<StyledBox sx={{ px: 0.5, height: "100%", overflow: "auto" }}>
124+
{logs.map((log, index) => (
125+
<div key={`${log.timestamp}-${log.message}`} css={logContainer}>
126+
<div css={logPrefix}>
127+
<Typography variant="subtitle2">
128+
{log.prefix}:&nbsp;
129+
</Typography>
130+
</div>
131+
<div css={logContent}>
132+
<Typography variant="body2" sx={{ fontSize: "0.85rem" }}>
133+
{log.message}&nbsp;
134+
<span css={{ fontStyle: "italic", fontSize: "0.75rem" }}>
135+
{safeStringify(log.data)}
136+
</span>
137+
</Typography>
138+
</div>
139+
<div css={logTimestamp}>
140+
<Typography sx={{ marginLeft: "1rem" }} variant="body2">
141+
+
142+
{log.timestamp -
143+
(logs[index + 1]?.timestamp ?? log.timestamp)}
144+
ms
145+
</Typography>
146+
</div>
147+
</div>
148+
))}
149+
</StyledBox>
150+
</SwipeableDrawer>
151+
</Root>
152+
<Fab
153+
sx={{
154+
position: "absolute",
155+
bottom: "5rem",
156+
right: "1rem",
157+
"@media (width <= 800px)": {
158+
visibility: "hidden",
159+
},
160+
}}
161+
color="secondary"
162+
onClick={toggleDrawer(true)}
163+
>
164+
<ArticleIcon />
165+
</Fab>
166+
</>
167+
);
168+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { css } from "@emotion/react";
2+
import { useContext, useEffect, useState } from "react";
3+
import { AztecContext } from "../../../aztecEnv";
4+
import { Typography } from "@mui/material";
5+
import {
6+
convertFromUTF8BufferAsString,
7+
formatFrAsString,
8+
} from "../../../utils/conversion";
9+
import { ContractFunctionInteractionTx } from "../../../utils/txs";
10+
import { TxHash } from "@aztec/aztec.js";
11+
12+
const txPanel = css({
13+
width: "100%",
14+
backgroundColor: "var(--mui-palette-primary-main)",
15+
maxHeight: "30vh",
16+
overflowY: "auto",
17+
borderRadius: "0.5rem",
18+
});
19+
20+
const txData = css({
21+
display: "flex",
22+
flexDirection: "column",
23+
alignItems: "center",
24+
padding: "0.5rem",
25+
backgroundColor: "var(--mui-palette-primary-light)",
26+
borderRadius: "0.5rem",
27+
margin: "0.5rem",
28+
});
29+
30+
export function TxsPanel() {
31+
const [transactions, setTransactions] = useState([]);
32+
33+
const { currentTx, currentContractAddress, walletDB } =
34+
useContext(AztecContext);
35+
36+
useEffect(() => {
37+
const refreshTransactions = async () => {
38+
const txsPerContract = await walletDB.retrieveTxsPerContract(
39+
currentContractAddress
40+
);
41+
const txHashes = txsPerContract.map((txHash) =>
42+
TxHash.fromString(convertFromUTF8BufferAsString(txHash))
43+
);
44+
const txs: ContractFunctionInteractionTx[] = await Promise.all(
45+
txHashes.map(async (txHash) => {
46+
const txData = await walletDB.retrieveTxData(txHash);
47+
return {
48+
contractAddress: currentContractAddress,
49+
txHash: txData.txHash,
50+
status: convertFromUTF8BufferAsString(txData.status),
51+
fnName: convertFromUTF8BufferAsString(txData.fnName),
52+
date: parseInt(convertFromUTF8BufferAsString(txData.date)),
53+
} as ContractFunctionInteractionTx;
54+
})
55+
);
56+
txs.sort((a, b) => (b.date >= a.date ? -1 : 1));
57+
if (
58+
currentTx &&
59+
currentTx.contractAddress === currentContractAddress &&
60+
(!currentTx.txHash ||
61+
!txs.find((tx) => tx.txHash.equals(currentTx.txHash)))
62+
) {
63+
txs.unshift(currentTx);
64+
}
65+
setTransactions(txs);
66+
};
67+
if (currentContractAddress && walletDB) {
68+
refreshTransactions();
69+
} else {
70+
setTransactions([]);
71+
}
72+
}, [currentContractAddress, currentTx]);
73+
74+
return (
75+
<div css={txPanel}>
76+
{transactions.map((tx) => (
77+
<div css={txData} key={tx.txHash ?? ""}>
78+
<div css={{ display: "flex" }}>
79+
<Typography variant="body2">
80+
{tx.txHash ? formatFrAsString(tx.txHash.toString()) : "()"}
81+
&nbsp;-&nbsp;
82+
</Typography>
83+
<Typography variant="subtitle2" sx={{ fontWeight: 800 }}>
84+
{tx.receipt
85+
? tx.receipt.status.toUpperCase()
86+
: tx.status.toUpperCase()}
87+
&nbsp;
88+
{tx.receipt && tx.receipt.status === "error"
89+
? tx.receipt.error
90+
: tx.error}
91+
</Typography>
92+
</div>
93+
<Typography variant="body2">
94+
{tx.fnName}@{formatFrAsString(tx.contractAddress.toString())}
95+
</Typography>
96+
</div>
97+
))}
98+
</div>
99+
);
100+
}

‎gaztec/src/components/sidebar/sidebar.tsx

+13-103
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,30 @@ import InputLabel from "@mui/material/InputLabel";
33
import MenuItem from "@mui/material/MenuItem";
44
import FormControl from "@mui/material/FormControl";
55
import Select, { SelectChangeEvent } from "@mui/material/Select";
6-
import { AztecEnv, AztecContext } from "../../aztecEnv";
6+
import { AztecEnv, AztecContext, WebLogger } from "../../aztecEnv";
77
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";
159
import { WalletDB } from "../../utils/storage";
1610
import { useContext, useEffect, useState } from "react";
1711
import { CreateAccountDialog } from "./components/createAccountDialog";
1812
import { getSchnorrAccount } from "@aztec/accounts/schnorr";
1913
import AddIcon from "@mui/icons-material/Add";
20-
import logoURL from "../../assets/Aztec_logo.png";
2114
import { Button, Divider, Typography } from "@mui/material";
2215
import {
2316
formatFrAsString,
2417
parseAliasedBuffersAsString,
2518
} from "../../utils/conversion";
26-
import { convertFromUTF8BufferAsString } from "../../utils/conversion";
27-
import { ContractFunctionInteractionTx } from "../../utils/txs";
2819
import ContactsIcon from "@mui/icons-material/Contacts";
2920
import { CopyToClipboardButton } from "../common/copyToClipboardButton";
3021
import { AddSendersDialog } from "./components/addSenderDialog";
3122
import { deriveSigningKey } from "@aztec/circuits.js/keys";
23+
import { TxsPanel } from "./components/txsPanel";
3224

3325
const container = css({
3426
display: "flex",
3527
flexDirection: "column",
3628
height: "100%",
37-
width: "25vw",
29+
width: "100%",
3830
backgroundColor: "var(--mui-palette-primary-light)",
3931
overflow: "hidden",
4032
padding: "0 0.5rem",
@@ -57,30 +49,6 @@ const header = css({
5749
marginBottom: "1rem",
5850
});
5951

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-
8452
const NETWORKS = [
8553
{
8654
nodeURL: "http://localhost:8080",
@@ -99,17 +67,17 @@ export function SidebarComponent() {
9967
setWallet,
10068
setCurrentContractAddress,
10169
setAztecNode,
102-
currentTx,
70+
setLogs,
10371
currentContractAddress,
10472
wallet,
10573
walletDB,
10674
nodeURL,
10775
isPXEInitialized,
10876
pxe,
10977
} = useContext(AztecContext);
78+
const [changingNetworks, setChangingNetworks] = useState(false);
11079
const [accounts, setAccounts] = useState([]);
11180
const [contracts, setContracts] = useState([]);
112-
const [transactions, setTransactions] = useState([]);
11381
const [openCreateAccountDialog, setOpenCreateAccountDialog] = useState(false);
11482
const [openAddSendersDialog, setOpenAddSendersDialog] = useState(false);
11583

@@ -134,15 +102,17 @@ export function SidebarComponent() {
134102
};
135103

136104
const handleNetworkChange = async (event: SelectChangeEvent) => {
105+
setChangingNetworks(true);
137106
setPXEInitialized(false);
138107
const nodeURL = event.target.value;
139108
setNodeURL(nodeURL);
140109
const node = await AztecEnv.connectToNode(nodeURL);
141110
setAztecNode(node);
142-
const pxe = await AztecEnv.initPXE(node);
111+
const pxe = await AztecEnv.initPXE(node, setLogs);
143112
const rollupAddress = (await pxe.getNodeInfo()).l1ContractAddresses
144113
.rollupAddress;
145-
const walletLogger = createLogger("wallet:data:indexeddb");
114+
const walletLogger =
115+
WebLogger.getInstance().createLogger("wallet:data:idb");
146116
const walletDBStore = await createStore(
147117
`wallet-${rollupAddress}`,
148118
{ dataDirectory: "wallet", dataStoreMapSizeKB: 2e10 },
@@ -153,6 +123,7 @@ export function SidebarComponent() {
153123
setPXE(pxe);
154124
setWalletDB(walletDB);
155125
setPXEInitialized(true);
126+
setChangingNetworks(false);
156127
};
157128

158129
useEffect(() => {
@@ -175,44 +146,6 @@ export function SidebarComponent() {
175146
}
176147
}, [wallet, walletDB, pxe]);
177148

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-
216149
const handleAccountChange = async (event: SelectChangeEvent) => {
217150
if (event.target.value == "") {
218151
return;
@@ -273,7 +206,6 @@ export function SidebarComponent() {
273206
return (
274207
<div css={container}>
275208
<div css={header}>
276-
<img css={logo} src={logoURL} />
277209
<Typography
278210
variant="h1"
279211
sx={{ fontSize: "65px", padding: 0, marginTop: "0.5rem" }}
@@ -288,6 +220,7 @@ export function SidebarComponent() {
288220
fullWidth
289221
value={nodeURL}
290222
label="Network"
223+
disabled={changingNetworks}
291224
onChange={handleNetworkChange}
292225
>
293226
{NETWORKS.map((network) => (
@@ -373,30 +306,7 @@ export function SidebarComponent() {
373306
<div css={{ flex: "1 0 auto", margin: "auto" }} />
374307
<Typography variant="overline">Transactions</Typography>
375308
<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-
&nbsp;-&nbsp;
383-
</Typography>
384-
<Typography variant="subtitle2" sx={{ fontWeight: 800 }}>
385-
{tx.receipt
386-
? tx.receipt.status.toUpperCase()
387-
: tx.status.toUpperCase()}
388-
&nbsp;
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 />
400310
<CreateAccountDialog
401311
open={openCreateAccountDialog}
402312
onClose={handleAccountCreation}

‎gaztec/yarn.lock

+357-349
Large diffs are not rendered by default.

‎yarn-project/aztec.js/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export default {
5252
new CopyPlugin({
5353
patterns: [
5454
{
55-
context: '../../barretenberg/ts/dest/browser',
55+
// createRequire resolves the cjs version, so we need to go up one level
56+
context: resolve(require.resolve('@aztec/bb.js'), '../../browser'),
5657
from: '*.gz',
5758
},
5859
],

‎yarn-project/bootstrap.sh

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function build {
3838
fi
3939
esac
4040

41+
denoise 'cd aztec.js && yarn build:web'
4142
denoise 'cd end-to-end && yarn build:web'
4243

4344
# Upload common patterns for artifacts: dest, fixtures, build, artifacts, generated

‎yarn-project/noir-protocol-circuits-types/src/scripts/generate_client_artifacts_helper.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ function generateImportFunction() {
4646
})
4747
.map(artifactName => {
4848
return `case '${artifactName}': {
49-
const { default: compiledCircuit } = await import(\`../artifacts/${artifactName}.json\`, {
50-
assert: { type: 'json' },
51-
});
49+
const { default: compiledCircuit } = await import(\"../artifacts/${artifactName}.json\");
5250
return compiledCircuit as NoirCompiledCircuit;
5351
}`;
5452
});

‎yarn-project/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"format": "yarn prettier --cache -w .",
1313
"test": "RAYON_NUM_THREADS=4 FORCE_COLOR=true yarn workspaces foreach -A --exclude @aztec/aztec3-packages --exclude @aztec/prover-client -p -v run test --config=../jest.root.config.js",
1414
"build": "FORCE_COLOR=true yarn workspaces foreach -A --parallel --topological-dev --verbose --exclude @aztec/aztec3-packages --exclude @aztec/docs run build",
15-
"build:fast": "cd foundation && yarn build && cd ../l1-artifacts && yarn build && cd ../circuits.js && yarn build && cd ../aztec.js && yarn build && cd .. && yarn generate && tsc -b",
15+
"build:fast": "cd foundation && yarn build && cd ../l1-artifacts && yarn build && cd ../circuits.js && yarn build && cd .. && yarn generate && tsc -b",
1616
"build:dev": "./watch.sh",
1717
"generate": "FORCE_COLOR=true yarn workspaces foreach -A --parallel --topological-dev --verbose run generate",
1818
"clean": "yarn workspaces foreach -A -p -v run clean"

‎yarn-project/pxe/src/pxe_service/pxe_service.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ export class PXEService implements PXE {
100100
private proofCreator: PrivateKernelProver,
101101
private simulationProvider: SimulationProvider,
102102
config: PXEServiceConfig,
103-
logSuffix?: string,
103+
loggerOrSuffix?: string | Logger,
104104
) {
105-
this.log = createLogger(logSuffix ? `pxe:service:${logSuffix}` : `pxe:service`);
106-
this.synchronizer = new Synchronizer(node, db, tipsStore, config, logSuffix);
105+
this.log =
106+
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
107+
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
108+
: loggerOrSuffix;
109+
this.synchronizer = new Synchronizer(node, db, tipsStore, config, loggerOrSuffix);
107110
this.contractDataOracle = new ContractDataOracle(db);
108111
this.simulator = getAcirSimulator(db, node, keyStore, this.simulationProvider, this.contractDataOracle);
109112
this.packageVersion = getPackageInfo().version;

‎yarn-project/pxe/src/synchronizer/synchronizer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ export class Synchronizer implements L2BlockStreamEventHandler {
2727
private db: PxeDatabase,
2828
private l2TipsStore: L2TipsStore,
2929
config: Partial<Pick<PXEConfig, 'l2StartingBlock'>> = {},
30-
logSuffix?: string,
30+
loggerOrSuffix?: string | Logger,
3131
) {
32-
this.log = createLogger(logSuffix ? `pxe:synchronizer:${logSuffix}` : 'pxe:synchronizer');
32+
this.log =
33+
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
34+
? createLogger(loggerOrSuffix ? `pxe:synchronizer:${loggerOrSuffix}` : `pxe:synchronizer`)
35+
: loggerOrSuffix;
3336
this.blockStream = this.createBlockStream(config);
3437
}
3538

0 commit comments

Comments
 (0)
Please sign in to comment.