From 6f3eebf8da0dc17ef05d3c326534c8f7fbb1e86b Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Tue, 19 Mar 2024 10:08:30 +0000 Subject: [PATCH] refactor!: move entrypoints back to aztec.js --- yarn-project/accounts/package.json | 1 - .../src/defaults/account_interface.ts | 2 +- yarn-project/accounts/tsconfig.json | 3 - yarn-project/aztec.js/package.json | 1 + yarn-project/aztec.js/src/api/entrypoint.ts | 1 + .../src/entrypoint}/account_entrypoint.ts | 2 +- .../src/entrypoint}/constants.ts | 0 .../src/entrypoint}/dapp_entrypoint.ts | 4 +- .../src/entrypoint}/entrypoint_payload.ts | 3 +- yarn-project/aztec.js/src/entrypoint/index.ts | 2 + yarn-project/deploy_npm.sh | 1 - yarn-project/end-to-end/package.json | 1 - .../src/e2e_dapp_subscription.test.ts | 2 +- yarn-project/end-to-end/tsconfig.json | 3 - yarn-project/entrypoints/.eslintrc.cjs | 1 - yarn-project/entrypoints/README.md | 8 --- yarn-project/entrypoints/package.json | 61 ------------------- yarn-project/entrypoints/src/index.ts | 10 --- yarn-project/entrypoints/tsconfig.dest.json | 18 ------ yarn-project/entrypoints/tsconfig.json | 23 ------- yarn-project/package.json | 1 - yarn-project/tsconfig.json | 3 +- yarn-project/yarn.lock | 20 ------ 23 files changed, 12 insertions(+), 159 deletions(-) create mode 100644 yarn-project/aztec.js/src/api/entrypoint.ts rename yarn-project/{entrypoints/src => aztec.js/src/entrypoint}/account_entrypoint.ts (99%) rename yarn-project/{entrypoints/src => aztec.js/src/entrypoint}/constants.ts (100%) rename yarn-project/{entrypoints/src => aztec.js/src/entrypoint}/dapp_entrypoint.ts (97%) rename yarn-project/{entrypoints/src => aztec.js/src/entrypoint}/entrypoint_payload.ts (98%) create mode 100644 yarn-project/aztec.js/src/entrypoint/index.ts delete mode 100644 yarn-project/entrypoints/.eslintrc.cjs delete mode 100644 yarn-project/entrypoints/README.md delete mode 100644 yarn-project/entrypoints/package.json delete mode 100644 yarn-project/entrypoints/src/index.ts delete mode 100644 yarn-project/entrypoints/tsconfig.dest.json delete mode 100644 yarn-project/entrypoints/tsconfig.json diff --git a/yarn-project/accounts/package.json b/yarn-project/accounts/package.json index 4888de8dbf2..59b68de7197 100644 --- a/yarn-project/accounts/package.json +++ b/yarn-project/accounts/package.json @@ -49,7 +49,6 @@ "@aztec/aztec.js": "workspace:^", "@aztec/circuit-types": "workspace:^", "@aztec/circuits.js": "workspace:^", - "@aztec/entrypoints": "workspace:^", "@aztec/ethereum": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/types": "workspace:^", diff --git a/yarn-project/accounts/src/defaults/account_interface.ts b/yarn-project/accounts/src/defaults/account_interface.ts index f37833ea9a7..e9b2a774ead 100644 --- a/yarn-project/accounts/src/defaults/account_interface.ts +++ b/yarn-project/accounts/src/defaults/account_interface.ts @@ -1,7 +1,7 @@ import { AccountInterface, AuthWitnessProvider, EntrypointInterface, FeeOptions } from '@aztec/aztec.js/account'; +import { DefaultAccountEntrypoint } from '@aztec/aztec.js/entrypoint'; import { AuthWitness, FunctionCall, TxExecutionRequest } from '@aztec/circuit-types'; import { AztecAddress, CompleteAddress, Fr } from '@aztec/circuits.js'; -import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account'; import { NodeInfo } from '@aztec/types/interfaces'; /** diff --git a/yarn-project/accounts/tsconfig.json b/yarn-project/accounts/tsconfig.json index 0b48acf92f7..2adb9ec62d7 100644 --- a/yarn-project/accounts/tsconfig.json +++ b/yarn-project/accounts/tsconfig.json @@ -15,9 +15,6 @@ { "path": "../circuits.js" }, - { - "path": "../entrypoints" - }, { "path": "../ethereum" }, diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 3bb05214e85..985547d638d 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -8,6 +8,7 @@ "./interfaces/pxe": "./dest/api/interfaces/pxe.js", "./abi": "./dest/api/abi.js", "./account": "./dest/api/account.js", + "./entrypoint": "./dest/api/entrypoint.js", "./aztec_address": "./dest/api/aztec_address.js", "./deployment": "./dest/api/deployment.js", "./eth_address": "./dest/api/eth_address.js", diff --git a/yarn-project/aztec.js/src/api/entrypoint.ts b/yarn-project/aztec.js/src/api/entrypoint.ts new file mode 100644 index 00000000000..1008dd00941 --- /dev/null +++ b/yarn-project/aztec.js/src/api/entrypoint.ts @@ -0,0 +1 @@ +export * from '../entrypoint/index.js'; diff --git a/yarn-project/entrypoints/src/account_entrypoint.ts b/yarn-project/aztec.js/src/entrypoint/account_entrypoint.ts similarity index 99% rename from yarn-project/entrypoints/src/account_entrypoint.ts rename to yarn-project/aztec.js/src/entrypoint/account_entrypoint.ts index c0c20c8089e..416d3a065f2 100644 --- a/yarn-project/entrypoints/src/account_entrypoint.ts +++ b/yarn-project/aztec.js/src/entrypoint/account_entrypoint.ts @@ -1,8 +1,8 @@ -import { AuthWitnessProvider, EntrypointInterface, FeeOptions } from '@aztec/aztec.js/account'; import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; import { AztecAddress, FunctionData, GeneratorIndex, TxContext } from '@aztec/circuits.js'; import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; +import { AuthWitnessProvider, EntrypointInterface, FeeOptions } from '../account/interface.js'; import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js'; import { buildAppPayload, buildFeePayload, hashPayload } from './entrypoint_payload.js'; diff --git a/yarn-project/entrypoints/src/constants.ts b/yarn-project/aztec.js/src/entrypoint/constants.ts similarity index 100% rename from yarn-project/entrypoints/src/constants.ts rename to yarn-project/aztec.js/src/entrypoint/constants.ts diff --git a/yarn-project/entrypoints/src/dapp_entrypoint.ts b/yarn-project/aztec.js/src/entrypoint/dapp_entrypoint.ts similarity index 97% rename from yarn-project/entrypoints/src/dapp_entrypoint.ts rename to yarn-project/aztec.js/src/entrypoint/dapp_entrypoint.ts index 877ba2a4a3d..25b3cf01dd9 100644 --- a/yarn-project/entrypoints/src/dapp_entrypoint.ts +++ b/yarn-project/aztec.js/src/entrypoint/dapp_entrypoint.ts @@ -1,9 +1,9 @@ -import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/aztec.js'; -import { AuthWitnessProvider, EntrypointInterface } from '@aztec/aztec.js/account'; import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; import { AztecAddress, Fr, FunctionData, TxContext } from '@aztec/circuits.js'; import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; +import { AuthWitnessProvider, EntrypointInterface } from '../account/interface.js'; +import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '../utils/authwit.js'; import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js'; import { buildDappPayload } from './entrypoint_payload.js'; diff --git a/yarn-project/entrypoints/src/entrypoint_payload.ts b/yarn-project/aztec.js/src/entrypoint/entrypoint_payload.ts similarity index 98% rename from yarn-project/entrypoints/src/entrypoint_payload.ts rename to yarn-project/aztec.js/src/entrypoint/entrypoint_payload.ts index 654694847e3..aeccff59a8f 100644 --- a/yarn-project/entrypoints/src/entrypoint_payload.ts +++ b/yarn-project/aztec.js/src/entrypoint/entrypoint_payload.ts @@ -1,10 +1,11 @@ -import { FeeOptions } from '@aztec/aztec.js/account'; import { Fr } from '@aztec/aztec.js/fields'; import { FunctionCall, PackedArguments, emptyFunctionCall } from '@aztec/circuit-types'; import { AztecAddress } from '@aztec/circuits.js'; import { padArrayEnd } from '@aztec/foundation/collection'; import { pedersenHash } from '@aztec/foundation/crypto'; +import { FeeOptions } from '../account/interface.js'; + // These must match the values defined in: // - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr const ACCOUNT_MAX_CALLS = 4; diff --git a/yarn-project/aztec.js/src/entrypoint/index.ts b/yarn-project/aztec.js/src/entrypoint/index.ts new file mode 100644 index 00000000000..5b3edcc7152 --- /dev/null +++ b/yarn-project/aztec.js/src/entrypoint/index.ts @@ -0,0 +1,2 @@ +export * from './account_entrypoint.js'; +export * from './dapp_entrypoint.js'; diff --git a/yarn-project/deploy_npm.sh b/yarn-project/deploy_npm.sh index 3a08cec3846..65ea41a7edd 100755 --- a/yarn-project/deploy_npm.sh +++ b/yarn-project/deploy_npm.sh @@ -86,7 +86,6 @@ deploy_package circuits.js deploy_package circuit-types deploy_package protocol-contracts deploy_package aztec.js -deploy_package entrypoints deploy_package accounts deploy_package l1-artifacts deploy_package ethereum diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index a5aedd32dcd..b3782d197d6 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -23,7 +23,6 @@ "@aztec/circuit-types": "workspace:^", "@aztec/circuits.js": "workspace:^", "@aztec/cli": "workspace:^", - "@aztec/entrypoints": "workspace:^", "@aztec/ethereum": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/kv-store": "workspace:^", diff --git a/yarn-project/end-to-end/src/e2e_dapp_subscription.test.ts b/yarn-project/end-to-end/src/e2e_dapp_subscription.test.ts index 37ed31610a7..a9bb9d3780c 100644 --- a/yarn-project/end-to-end/src/e2e_dapp_subscription.test.ts +++ b/yarn-project/end-to-end/src/e2e_dapp_subscription.test.ts @@ -7,7 +7,7 @@ import { PublicFeePaymentMethod, SentTx, } from '@aztec/aztec.js'; -import { DefaultDappEntrypoint } from '@aztec/entrypoints/dapp'; +import { DefaultDappEntrypoint } from '@aztec/aztec.js/entrypoint'; import { AppSubscriptionContract, TokenContract as BananaCoin, diff --git a/yarn-project/end-to-end/tsconfig.json b/yarn-project/end-to-end/tsconfig.json index 1b1651c944b..62b11720085 100644 --- a/yarn-project/end-to-end/tsconfig.json +++ b/yarn-project/end-to-end/tsconfig.json @@ -27,9 +27,6 @@ { "path": "../cli" }, - { - "path": "../entrypoints" - }, { "path": "../ethereum" }, diff --git a/yarn-project/entrypoints/.eslintrc.cjs b/yarn-project/entrypoints/.eslintrc.cjs deleted file mode 100644 index ec1dd3e14de..00000000000 --- a/yarn-project/entrypoints/.eslintrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@aztec/foundation/eslint.docs'); diff --git a/yarn-project/entrypoints/README.md b/yarn-project/entrypoints/README.md deleted file mode 100644 index fc303dadae7..00000000000 --- a/yarn-project/entrypoints/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Account Entrypoints - -This package contains different transaction entrypoints for the Aztec Network. - -## Available entrypoints - -- **Account entrypoint**: this entrypoint encodes the payload to start an interaction through an Account Contract. It is meant to be used with accounts implementing the interface defined by `@aztec/accounts`. -- **DApp entrypoint**: this encodes the payload so that it may run a dapp directly, instead of going through an account contract. diff --git a/yarn-project/entrypoints/package.json b/yarn-project/entrypoints/package.json deleted file mode 100644 index 7d904b8700b..00000000000 --- a/yarn-project/entrypoints/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@aztec/entrypoints", - "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/entrypoints", - "description": "Implementation of sample contract entrypoints for the Aztec Network", - "version": "0.1.0", - "type": "module", - "exports": { - "./dapp": "./dest/dapp_entrypoint.js", - "./account": "./dest/account_entrypoint.js" - }, - "typedocOptions": { - "entryPoints": [ - "./src/index.ts" - ], - "name": "Entrypoints", - "tsconfig": "./tsconfig.json" - }, - "scripts": { - "build": "yarn clean && tsc -b", - "build:dev": "tsc -b --watch", - "build:ts": "tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo", - "formatting": "run -T prettier --check ./src && run -T eslint ./src", - "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests" - }, - "inherits": [ - "../package.common.json" - ], - "jest": { - "preset": "ts-jest/presets/default-esm", - "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.[cm]?js$": "$1" - }, - "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", - "rootDir": "./src" - }, - "dependencies": { - "@aztec/aztec.js": "workspace:^", - "@aztec/circuit-types": "workspace:^", - "@aztec/circuits.js": "workspace:^", - "@aztec/foundation": "workspace:^", - "tslib": "^2.4.0" - }, - "devDependencies": { - "@jest/globals": "^29.5.0", - "@types/jest": "^29.5.0", - "jest": "^29.5.0", - "ts-jest": "^29.1.0", - "ts-node": "^10.9.1", - "typescript": "^5.0.4" - }, - "files": [ - "dest", - "src", - "!*.test.*" - ], - "engines": { - "node": ">=18" - } -} diff --git a/yarn-project/entrypoints/src/index.ts b/yarn-project/entrypoints/src/index.ts deleted file mode 100644 index dd22b64cc9f..00000000000 --- a/yarn-project/entrypoints/src/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * The `@aztec/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module. - * - * Read more in {@link https://docs.aztec.network/developers/wallets/writing_an_account_contract | Writing an account contract}. - * - * @packageDocumentation - */ - -export * from './account_entrypoint.js'; -export * from './dapp_entrypoint.js'; diff --git a/yarn-project/entrypoints/tsconfig.dest.json b/yarn-project/entrypoints/tsconfig.dest.json deleted file mode 100644 index 5997e69d530..00000000000 --- a/yarn-project/entrypoints/tsconfig.dest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ".", - "references": [ - { - "path": "../aztec.js/tsconfig.dest.json" - }, - { - "path": "../circuits.js/tsconfig.dest.json" - }, - { - "path": "../foundation/tsconfig.dest.json" - }, - { - "path": "../circuit-types/tsconfig.dest.json" - } - ], - "exclude": ["src/**/*.test.ts"] -} diff --git a/yarn-project/entrypoints/tsconfig.json b/yarn-project/entrypoints/tsconfig.json deleted file mode 100644 index 63d75e05aa8..00000000000 --- a/yarn-project/entrypoints/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "..", - "compilerOptions": { - "outDir": "dest", - "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo" - }, - "references": [ - { - "path": "../aztec.js" - }, - { - "path": "../circuit-types" - }, - { - "path": "../circuits.js" - }, - { - "path": "../foundation" - } - ], - "include": ["src", "src/**/*.json"] -} diff --git a/yarn-project/package.json b/yarn-project/package.json index 5e5fbfb0a68..f2a0ee95b7c 100644 --- a/yarn-project/package.json +++ b/yarn-project/package.json @@ -19,7 +19,6 @@ }, "workspaces": [ "accounts", - "entrypoints", "simulator", "archiver", "aztec-faucet", diff --git a/yarn-project/tsconfig.json b/yarn-project/tsconfig.json index 887a5e3c4eb..8b77a73c92c 100644 --- a/yarn-project/tsconfig.json +++ b/yarn-project/tsconfig.json @@ -44,8 +44,7 @@ { "path": "sequencer-client/tsconfig.json" }, { "path": "types/tsconfig.json" }, { "path": "world-state/tsconfig.json" }, - { "path": "scripts/tsconfig.json" }, - { "path": "entrypoints/tsconfig.json" } + { "path": "scripts/tsconfig.json" } ], "files": ["./@types/jest/index.d.ts"] } diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 83d063e6450..057af4f922b 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -64,7 +64,6 @@ __metadata: "@aztec/aztec.js": "workspace:^" "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" - "@aztec/entrypoints": "workspace:^" "@aztec/ethereum": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/types": "workspace:^" @@ -375,7 +374,6 @@ __metadata: "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" "@aztec/cli": "workspace:^" - "@aztec/entrypoints": "workspace:^" "@aztec/ethereum": "workspace:^" "@aztec/foundation": "workspace:^" "@aztec/kv-store": "workspace:^" @@ -428,24 +426,6 @@ __metadata: languageName: unknown linkType: soft -"@aztec/entrypoints@workspace:^, @aztec/entrypoints@workspace:entrypoints": - version: 0.0.0-use.local - resolution: "@aztec/entrypoints@workspace:entrypoints" - dependencies: - "@aztec/aztec.js": "workspace:^" - "@aztec/circuit-types": "workspace:^" - "@aztec/circuits.js": "workspace:^" - "@aztec/foundation": "workspace:^" - "@jest/globals": ^29.5.0 - "@types/jest": ^29.5.0 - jest: ^29.5.0 - ts-jest: ^29.1.0 - ts-node: ^10.9.1 - tslib: ^2.4.0 - typescript: ^5.0.4 - languageName: unknown - linkType: soft - "@aztec/ethereum@workspace:^, @aztec/ethereum@workspace:ethereum": version: 0.0.0-use.local resolution: "@aztec/ethereum@workspace:ethereum"