From f4f32a2b7d056e76ef7513c83a0143c62789b362 Mon Sep 17 00:00:00 2001 From: thunkar Date: Wed, 18 Dec 2024 10:48:15 +0000 Subject: [PATCH 1/6] better granular api --- yarn-project/archiver/package.json | 2 +- yarn-project/aztec-faucet/package.json | 2 +- yarn-project/aztec-node/package.json | 2 +- yarn-project/aztec.js/package.json | 5 ++-- .../api/{aztec_address.ts => addresses.ts} | 1 + yarn-project/aztec.js/src/contract/index.ts | 16 ++++++++----- yarn-project/aztec.js/src/index.ts | 23 ++++--------------- yarn-project/bb-prover/package.json | 2 +- yarn-project/bot/package.json | 2 +- yarn-project/circuit-types/package.json | 2 +- yarn-project/cli/package.json | 2 +- yarn-project/cli/src/utils/commands.ts | 2 +- yarn-project/end-to-end/src/web/main.ts | 16 +++++++++---- yarn-project/l1-artifacts/package.json | 2 +- yarn-project/p2p/package.json | 2 +- yarn-project/proof-verifier/package.json | 2 +- yarn-project/protocol-contracts/package.json | 2 +- yarn-project/prover-client/package.json | 2 +- yarn-project/prover-node/package.json | 2 +- yarn-project/sequencer-client/package.json | 2 +- yarn-project/validator-client/package.json | 2 +- yarn-project/world-state/package.json | 2 +- 22 files changed, 47 insertions(+), 48 deletions(-) rename yarn-project/aztec.js/src/api/{aztec_address.ts => addresses.ts} (54%) diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index c802f7aaf33..c773e74ca99 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -110,4 +110,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/aztec-faucet/package.json b/yarn-project/aztec-faucet/package.json index 64290005c93..5c0c9a01b91 100644 --- a/yarn-project/aztec-faucet/package.json +++ b/yarn-project/aztec-faucet/package.json @@ -94,4 +94,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/aztec-node/package.json b/yarn-project/aztec-node/package.json index ad55b09fe21..6ace5e54c53 100644 --- a/yarn-project/aztec-node/package.json +++ b/yarn-project/aztec-node/package.json @@ -106,4 +106,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 830f8f697d5..e20be6e9e4f 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -8,7 +8,8 @@ "./interfaces/pxe": "./dest/api/interfaces/pxe.js", "./abi": "./dest/api/abi.js", "./account": "./dest/api/account.js", - "./aztec_address": "./dest/api/aztec_address.js", + "./addresses": "./dest/api/addresses.js", + "./contracts": "./dest/contracts/index.js", "./deployment": "./dest/api/deployment.js", "./entrypoint": "./dest/api/entrypoint.js", "./eth_address": "./dest/api/eth_address.js", @@ -119,4 +120,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/aztec.js/src/api/aztec_address.ts b/yarn-project/aztec.js/src/api/addresses.ts similarity index 54% rename from yarn-project/aztec.js/src/api/aztec_address.ts rename to yarn-project/aztec.js/src/api/addresses.ts index c6cece77dae..5b7111416c9 100644 --- a/yarn-project/aztec.js/src/api/aztec_address.ts +++ b/yarn-project/aztec.js/src/api/addresses.ts @@ -1 +1,2 @@ export { AztecAddress } from '@aztec/foundation/aztec-address'; +export { CompleteAddress } from '@aztec/circuits.js'; diff --git a/yarn-project/aztec.js/src/contract/index.ts b/yarn-project/aztec.js/src/contract/index.ts index dcf7b9a2dd5..b69395de86e 100644 --- a/yarn-project/aztec.js/src/contract/index.ts +++ b/yarn-project/aztec.js/src/contract/index.ts @@ -35,10 +35,14 @@ * * @packageDocumentation */ -export * from './contract.js'; -export * from './contract_function_interaction.js'; -export * from './sent_tx.js'; -export * from './contract_base.js'; -export * from './batch_call.js'; +export { Contract } from './contract.js'; +export { + ContractFunctionInteraction, + type ProfileResult, + type SendMethodOptions, +} from './contract_function_interaction.js'; +export { DefaultWaitOpts, SentTx, type WaitOpts } from './sent_tx.js'; +export { ContractBase, type ContractMethod, type ContractNotes, type ContractStorageLayout } from './contract_base.js'; +export { BatchCall } from './batch_call.js'; export { type DeployOptions, DeployMethod } from './deploy_method.js'; -export * from './deploy_sent_tx.js'; +export { DeploySentTx } from './deploy_sent_tx.js'; diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index c4a15950273..09993cbc71b 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -13,29 +13,12 @@ * ```typescript * import { TxHash } from '@aztec.js/tx_hash' * import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/aztec.js/abi'; - * import { AztecAddress } from '@aztec/aztec.js/aztec_address'; + * import { AztecAddress } from '@aztec/aztec.js/addresses'; * import { EthAddress } from '@aztec/aztec.js/eth_address'; * ``` * * TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it). */ -export { - BatchCall, - Contract, - ContractBase, - ContractFunctionInteraction, - DefaultWaitOpts, - DeployMethod, - DeploySentTx, - SentTx, - type ContractMethod, - type ContractNotes, - type ContractStorageLayout, - type DeployOptions, - type ProfileResult, - type SendMethodOptions, - type WaitOpts, -} from './contract/index.js'; export { ContractDeployer } from './deployment/index.js'; @@ -110,7 +93,6 @@ export { AuthWitness, Body, Comparator, - CompleteAddress, ContractClass2BlockL2Logs, EncryptedLogPayload, EpochProofQuote, @@ -174,3 +156,6 @@ export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contra export * from './api/abi.js'; export * from './api/fee.js'; export * from './api/init.js'; +// Granular export, even if not in the api folder +export * from './api/addresses.js'; +export * from './api/addresses.js'; diff --git a/yarn-project/bb-prover/package.json b/yarn-project/bb-prover/package.json index d32a9343fb1..1c109743f2c 100644 --- a/yarn-project/bb-prover/package.json +++ b/yarn-project/bb-prover/package.json @@ -111,4 +111,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/bot/package.json b/yarn-project/bot/package.json index fcd38c0be00..e44cad7a4a2 100644 --- a/yarn-project/bot/package.json +++ b/yarn-project/bot/package.json @@ -91,4 +91,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/circuit-types/package.json b/yarn-project/circuit-types/package.json index 94e6136a449..ea574a81948 100644 --- a/yarn-project/circuit-types/package.json +++ b/yarn-project/circuit-types/package.json @@ -106,4 +106,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index 31dcf1da552..7a9d39d31f8 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -127,4 +127,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/cli/src/utils/commands.ts b/yarn-project/cli/src/utils/commands.ts index 4065c8fa84a..af672916438 100644 --- a/yarn-project/cli/src/utils/commands.ts +++ b/yarn-project/cli/src/utils/commands.ts @@ -1,5 +1,5 @@ import { FunctionSelector } from '@aztec/aztec.js/abi'; -import { AztecAddress } from '@aztec/aztec.js/aztec_address'; +import { AztecAddress } from '@aztec/aztec.js/addresses'; import { EthAddress } from '@aztec/aztec.js/eth_address'; import { Fr } from '@aztec/aztec.js/fields'; import { LogId } from '@aztec/aztec.js/log_id'; diff --git a/yarn-project/end-to-end/src/web/main.ts b/yarn-project/end-to-end/src/web/main.ts index 3e65f0760e9..885323bebbf 100644 --- a/yarn-project/end-to-end/src/web/main.ts +++ b/yarn-project/end-to-end/src/web/main.ts @@ -1,6 +1,14 @@ -export * from '@aztec/aztec.js'; -export * from '@aztec/accounts/testing'; -export * from '@aztec/accounts/single_key'; -export * from '@aztec/accounts/schnorr'; +export { Fr } from '@aztec/aztec.js/fields'; +export { createPXEClient } from '@aztec/aztec.js/rpc'; +export { getUnsafeSchnorrAccount } from '@aztec/accounts/single_key'; +export { + getDeployedTestAccountsWallets, + INITIAL_TEST_SECRET_KEYS, + INITIAL_TEST_SIGNING_KEYS, + INITIAL_TEST_ACCOUNT_SALTS, +} from '@aztec/accounts/testing'; +export { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses'; +export { Contract } from '@aztec/aztec.js/contracts'; +export { contractArtifactFromBuffer } from '@aztec/aztec.js/abi'; export { Buffer } from 'buffer/'; diff --git a/yarn-project/l1-artifacts/package.json b/yarn-project/l1-artifacts/package.json index f5469172c8e..6963e95d3cd 100644 --- a/yarn-project/l1-artifacts/package.json +++ b/yarn-project/l1-artifacts/package.json @@ -32,4 +32,4 @@ "generated" ], "types": "./dest/index.d.ts" -} \ No newline at end of file +} diff --git a/yarn-project/p2p/package.json b/yarn-project/p2p/package.json index a24e71fbc38..5be467e88f8 100644 --- a/yarn-project/p2p/package.json +++ b/yarn-project/p2p/package.json @@ -123,4 +123,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/proof-verifier/package.json b/yarn-project/proof-verifier/package.json index 1af22444af1..9a1fed2dba8 100644 --- a/yarn-project/proof-verifier/package.json +++ b/yarn-project/proof-verifier/package.json @@ -81,4 +81,4 @@ "../../foundation/src/jest/setup.mjs" ] } -} \ No newline at end of file +} diff --git a/yarn-project/protocol-contracts/package.json b/yarn-project/protocol-contracts/package.json index aab9d4b37e3..b63606a7f63 100644 --- a/yarn-project/protocol-contracts/package.json +++ b/yarn-project/protocol-contracts/package.json @@ -101,4 +101,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/prover-client/package.json b/yarn-project/prover-client/package.json index c395650e41e..9278090708f 100644 --- a/yarn-project/prover-client/package.json +++ b/yarn-project/prover-client/package.json @@ -109,4 +109,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/prover-node/package.json b/yarn-project/prover-node/package.json index 53fa2943cc4..4d0fc44fd24 100644 --- a/yarn-project/prover-node/package.json +++ b/yarn-project/prover-node/package.json @@ -96,4 +96,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index 1fcf01f6a85..d373ef337b5 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -118,4 +118,4 @@ "../../foundation/src/jest/setup.mjs" ] } -} \ No newline at end of file +} diff --git a/yarn-project/validator-client/package.json b/yarn-project/validator-client/package.json index e14fc7e52c3..b760d9aedb6 100644 --- a/yarn-project/validator-client/package.json +++ b/yarn-project/validator-client/package.json @@ -97,4 +97,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/world-state/package.json b/yarn-project/world-state/package.json index b3cc7dadddd..ec920a94cfc 100644 --- a/yarn-project/world-state/package.json +++ b/yarn-project/world-state/package.json @@ -102,4 +102,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} From 1be3f298f6e70ca5f451be96d49f93f1efc289c9 Mon Sep 17 00:00:00 2001 From: thunkar Date: Wed, 18 Dec 2024 12:03:46 +0000 Subject: [PATCH 2/6] attempt to fix e2e --- yarn-project/Earthfile | 3 ++- yarn-project/aztec.js/package.json | 5 +++-- yarn-project/aztec.js/src/index.ts | 2 +- .../end-to-end/src/composed/e2e_aztec_js_browser.test.ts | 7 +++---- yarn-project/end-to-end/src/web/main.ts | 4 +++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index adf74380994..e957a4b326a 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -55,7 +55,6 @@ build: ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true RUN ./bootstrap.sh - build-dev: FROM +build SAVE ARTIFACT /usr/src /usr/src @@ -197,6 +196,8 @@ end-to-end-prod: BUILD ../spartan/+charts FROM +cli-base RUN yarn workspaces focus @aztec/end-to-end @aztec/cli-wallet --production && yarn cache clean + # A fast build is not enough for the end-to-end tests, we still need to run webpack + RUN cd end-to-end && yarn build:web COPY --dir +rollup-verifier-contract/usr/src/bb /usr/src COPY --dir +build-dev/usr/src/noir-projects/noir-contracts /usr/src/noir-projects/noir-contracts COPY --dir ../spartan/+charts/usr/src/spartan /usr/src/spartan diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index e20be6e9e4f..5ebdafd8895 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -9,7 +9,7 @@ "./abi": "./dest/api/abi.js", "./account": "./dest/api/account.js", "./addresses": "./dest/api/addresses.js", - "./contracts": "./dest/contracts/index.js", + "./contracts": "./dest/contract/index.js", "./deployment": "./dest/api/deployment.js", "./entrypoint": "./dest/api/entrypoint.js", "./eth_address": "./dest/api/eth_address.js", @@ -20,7 +20,8 @@ "./log_id": "./dest/api/log_id.js", "./rpc": "./dest/rpc_clients/index.js", "./tx_hash": "./dest/api/tx_hash.js", - "./wallet": "./dest/api/wallet.js" + "./wallet": "./dest/api/wallet.js", + "./utils": "./dest/utils/index.js" }, "typedocOptions": { "entryPoints": [ diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index 09993cbc71b..55a4a4f3052 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -157,5 +157,5 @@ export * from './api/abi.js'; export * from './api/fee.js'; export * from './api/init.js'; // Granular export, even if not in the api folder -export * from './api/addresses.js'; +export * from './contract/index.js'; export * from './api/addresses.js'; diff --git a/yarn-project/end-to-end/src/composed/e2e_aztec_js_browser.test.ts b/yarn-project/end-to-end/src/composed/e2e_aztec_js_browser.test.ts index 51c7d8eab45..03ff98223ca 100644 --- a/yarn-project/end-to-end/src/composed/e2e_aztec_js_browser.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_aztec_js_browser.test.ts @@ -23,11 +23,10 @@ const pageLogger = createLogger('e2e:aztec_browser.js:web:page'); * To run the test, do the following: * 1) Build the whole repository, * 2) go to `yarn-project/end-to-end` and build the web packed package with `yarn build:web`, - * 3) start anvil: `anvil`, - * 4) if you intend to use a remotely running environment then export the URL of your PXE e.g. + * 3) if you intend to use a remotely running environment then export the URL of your PXE e.g. * `export PXE_URL='http://localhost:8080'` - * 5) go to `yarn-project/end-to-end` and run the test: `yarn test aztec_js_browser` - * 6) If you get dependency error run `apt install libnss3 libatk1.0-0t64 libatk-bridge2.0-0t64 libcups2t64 libxdamage1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2t64`. + * 4) go to `yarn-project/end-to-end` and run the test: `yarn test aztec_js_browser` + * 5) If you get dependency error run `apt install libnss3 libatk1.0-0t64 libatk-bridge2.0-0t64 libcups2t64 libxdamage1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2t64`. * * NOTE 1: If you see the logs spammed with unexpected logs there is probably a chrome process with a webpage * unexpectedly running in the background. Kill it with `killall chrome` diff --git a/yarn-project/end-to-end/src/web/main.ts b/yarn-project/end-to-end/src/web/main.ts index 885323bebbf..bc44adf8fea 100644 --- a/yarn-project/end-to-end/src/web/main.ts +++ b/yarn-project/end-to-end/src/web/main.ts @@ -1,5 +1,6 @@ export { Fr } from '@aztec/aztec.js/fields'; export { createPXEClient } from '@aztec/aztec.js/rpc'; +export { getSchnorrAccount } from '@aztec/accounts/schnorr'; export { getUnsafeSchnorrAccount } from '@aztec/accounts/single_key'; export { getDeployedTestAccountsWallets, @@ -8,7 +9,8 @@ export { INITIAL_TEST_ACCOUNT_SALTS, } from '@aztec/accounts/testing'; export { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses'; -export { Contract } from '@aztec/aztec.js/contracts'; +export { Contract, DeployMethod } from '@aztec/aztec.js/contracts'; export { contractArtifactFromBuffer } from '@aztec/aztec.js/abi'; +export { generatePublicKey } from '@aztec/aztec.js/utils'; export { Buffer } from 'buffer/'; From 04325c505614b93e9bbd3a3f66335ad5c9ef9db1 Mon Sep 17 00:00:00 2001 From: thunkar Date: Wed, 18 Dec 2024 12:21:43 +0000 Subject: [PATCH 3/6] test --- yarn-project/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index e957a4b326a..20fc5583cc4 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -195,9 +195,9 @@ export-aztec-faucet: end-to-end-prod: BUILD ../spartan/+charts FROM +cli-base - RUN yarn workspaces focus @aztec/end-to-end @aztec/cli-wallet --production && yarn cache clean # A fast build is not enough for the end-to-end tests, we still need to run webpack RUN cd end-to-end && yarn build:web + RUN yarn workspaces focus @aztec/end-to-end @aztec/cli-wallet --production && yarn cache clean COPY --dir +rollup-verifier-contract/usr/src/bb /usr/src COPY --dir +build-dev/usr/src/noir-projects/noir-contracts /usr/src/noir-projects/noir-contracts COPY --dir ../spartan/+charts/usr/src/spartan /usr/src/spartan From 28275521d184f51c61446257c0e8904a6b6df65a Mon Sep 17 00:00:00 2001 From: thunkar Date: Wed, 18 Dec 2024 13:03:23 +0000 Subject: [PATCH 4/6] earthly fix --- yarn-project/Earthfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 20fc5583cc4..7e1e39f1253 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -194,9 +194,17 @@ export-aztec-faucet: # We care about creating a slimmed down e2e image because we have to serialize it from earthly to docker for running. end-to-end-prod: BUILD ../spartan/+charts - FROM +cli-base + FROM +build # A fast build is not enough for the end-to-end tests, we still need to run webpack RUN cd end-to-end && yarn build:web + # Now that the web is compiled, we can trim down the image further + RUN rm -rf \ + ../noir-projects \ + ../l1-contracts + ../barretenberg/ts/src \ + ../barretenberg/ts/dest/node-cjs \ + ../barretenberg/ts/dest/browser + RUN yarn workspaces focus @aztec/end-to-end @aztec/cli-wallet --production && yarn cache clean COPY --dir +rollup-verifier-contract/usr/src/bb /usr/src COPY --dir +build-dev/usr/src/noir-projects/noir-contracts /usr/src/noir-projects/noir-contracts From 143d444da0fb793a2362188407fb2aef6ddc81ac Mon Sep 17 00:00:00 2001 From: thunkar Date: Wed, 18 Dec 2024 13:09:02 +0000 Subject: [PATCH 5/6] whoops typo --- yarn-project/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 7e1e39f1253..50e81f006cc 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -200,7 +200,7 @@ end-to-end-prod: # Now that the web is compiled, we can trim down the image further RUN rm -rf \ ../noir-projects \ - ../l1-contracts + ../l1-contracts \ ../barretenberg/ts/src \ ../barretenberg/ts/dest/node-cjs \ ../barretenberg/ts/dest/browser From e0735a03d485e1ca1103f5b16863d626faca9050 Mon Sep 17 00:00:00 2001 From: thunkar Date: Wed, 18 Dec 2024 13:41:19 +0000 Subject: [PATCH 6/6] fmt --- yarn-project/aztec.js/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index 55a4a4f3052..4164b5000a8 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -62,7 +62,6 @@ export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, type Walle // // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed // // here once the issue is resolved. export { - AztecAddress, ContractClassWithId, ContractInstanceWithAddress, EthAddress,