@aztec-labs/entrypoints 6.0.0-nightly.20260829

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { Tuple } from '@aztec-labs/foundation/serialize';
3
+ import { FunctionCall } from '@aztec-labs/stdlib/abi';
4
+ import { HashedValues } from '@aztec-labs/stdlib/tx';
5
+ export declare const APP_MAX_CALLS = 5;
6
+ /** Encoded function call for an Aztec entrypoint */
7
+ export type EncodedFunctionCall = {
8
+ /** Arguments hash for the call. */
9
+ /** This should be the calldata hash `hash([function_selector, ...args])` if `is_public` is true. */
10
+ args_hash: Fr;
11
+ /** Selector of the function to call */
12
+ function_selector: Fr;
13
+ /** Address of the contract to call */
14
+ target_address: Fr;
15
+ /** Whether the function is public or private */
16
+ is_public: boolean;
17
+ /** Only applicable for enqueued public function calls. Whether the msg_sender will be set to "null". */
18
+ hide_msg_sender: boolean;
19
+ /** Whether the function can alter state */
20
+ is_static: boolean;
21
+ };
22
+ /** Type that represents function calls ready to be sent to a circuit for execution */
23
+ export type EncodedCalls = {
24
+ /** Function calls in the expected format (Noir's convention) */
25
+ encodedFunctionCalls: EncodedFunctionCall[];
26
+ /** The hashed args for the call, ready to be injected in the execution cache */
27
+ hashedArguments: HashedValues[];
28
+ };
29
+ /**
30
+ * Entrypoints derive their arguments from the calls that they'll ultimate make.
31
+ * This utility class helps in creating the payload for the entrypoint by taking into
32
+ * account how the calls are encoded and hashed.
33
+ * */
34
+ export declare class EncodedAppEntrypointCalls implements EncodedCalls {
35
+ /** Function calls in the expected format (Noir's convention) */
36
+ encodedFunctionCalls: EncodedFunctionCall[];
37
+ /** The hashed args for the call, ready to be injected in the execution cache */
38
+ hashedArguments: HashedValues[];
39
+ /** The index of the generator to use for hashing */
40
+ domainSeparator: number;
41
+ /**
42
+ * A nonce to inject into the payload of the transaction. When used with cancellable=true, this nonce will be
43
+ * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
44
+ * but higher fee. The nullifier ensures only one transaction can succeed.
45
+ */
46
+ tx_nonce: Fr;
47
+ constructor(
48
+ /** Function calls in the expected format (Noir's convention) */
49
+ encodedFunctionCalls: EncodedFunctionCall[],
50
+ /** The hashed args for the call, ready to be injected in the execution cache */
51
+ hashedArguments: HashedValues[],
52
+ /** The index of the generator to use for hashing */
53
+ domainSeparator: number,
54
+ /**
55
+ * A nonce to inject into the payload of the transaction. When used with cancellable=true, this nonce will be
56
+ * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
57
+ * but higher fee. The nullifier ensures only one transaction can succeed.
58
+ */
59
+ tx_nonce: Fr);
60
+ /**
61
+ * The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
62
+ * @internal
63
+ */
64
+ get function_calls(): EncodedFunctionCall[];
65
+ /**
66
+ * Serializes the payload to an array of fields
67
+ * @returns The fields of the payload
68
+ */
69
+ toFields(): Fr[];
70
+ /**
71
+ * Hashes the payload
72
+ * @returns The hash of the payload
73
+ */
74
+ hash(): Promise<Fr>;
75
+ /** Serializes the function calls to an array of fields. */
76
+ protected functionCallsToFields(): Fr[];
77
+ /**
78
+ * Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
79
+ * @param functionCalls - The function calls to execute
80
+ * @param txNonce - A nonce used to enable transaction cancellation when cancellable=true. Transactions with the same
81
+ * nonce can be replaced by submitting a new one with a higher fee.
82
+ * @returns The encoded calls
83
+ */
84
+ static create(functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof APP_MAX_CALLS>, txNonce?: Fr): Promise<EncodedAppEntrypointCalls>;
85
+ }
86
+ /** Encodes FunctionCalls for execution, following Noir's convention */
87
+ export declare function encode(calls: FunctionCall[]): Promise<EncodedCalls>;
88
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2RpbmcuZC50cyIsInNvdXJjZVJvb3QiOiIiL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a,MAAM,CACjB,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,EAAE,OAAO,aAAa,CAAC,EACzE,OAAO,KAAc,sCAatB;CACF;AAED,uEAAuE;AACvE,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAwBzE"}
@@ -0,0 +1,97 @@
1
+ import { DomainSeparator } from '@aztec-labs/constants';
2
+ import { padArrayEnd } from '@aztec-labs/foundation/collection';
3
+ import { poseidon2HashWithSeparator } from '@aztec-labs/foundation/crypto/poseidon';
4
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
5
+ import { FunctionCall, FunctionType } from '@aztec-labs/stdlib/abi';
6
+ import { HashedValues } from '@aztec-labs/stdlib/tx';
7
+ // These must match the values defined in:
8
+ // - noir-projects/aztec-nr/aztec/src/authwit/entrypoint/app.nr
9
+ export const APP_MAX_CALLS = 5;
10
+ /**
11
+ * Entrypoints derive their arguments from the calls that they'll ultimate make.
12
+ * This utility class helps in creating the payload for the entrypoint by taking into
13
+ * account how the calls are encoded and hashed.
14
+ * */ export class EncodedAppEntrypointCalls {
15
+ encodedFunctionCalls;
16
+ hashedArguments;
17
+ domainSeparator;
18
+ tx_nonce;
19
+ constructor(/** Function calls in the expected format (Noir's convention) */ encodedFunctionCalls, /** The hashed args for the call, ready to be injected in the execution cache */ hashedArguments, /** The index of the generator to use for hashing */ domainSeparator, /**
20
+ * A nonce to inject into the payload of the transaction. When used with cancellable=true, this nonce will be
21
+ * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
22
+ * but higher fee. The nullifier ensures only one transaction can succeed.
23
+ */ // eslint-disable-next-line camelcase
24
+ tx_nonce){
25
+ this.encodedFunctionCalls = encodedFunctionCalls;
26
+ this.hashedArguments = hashedArguments;
27
+ this.domainSeparator = domainSeparator;
28
+ this.tx_nonce = tx_nonce;
29
+ }
30
+ /* eslint-disable camelcase */ /**
31
+ * The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
32
+ * @internal
33
+ */ get function_calls() {
34
+ return this.encodedFunctionCalls;
35
+ }
36
+ /* eslint-enable camelcase */ /**
37
+ * Serializes the payload to an array of fields
38
+ * @returns The fields of the payload
39
+ */ toFields() {
40
+ return [
41
+ ...this.functionCallsToFields(),
42
+ this.tx_nonce
43
+ ];
44
+ }
45
+ /**
46
+ * Hashes the payload
47
+ * @returns The hash of the payload
48
+ */ hash() {
49
+ return poseidon2HashWithSeparator(this.toFields(), this.domainSeparator);
50
+ }
51
+ /** Serializes the function calls to an array of fields. */ functionCallsToFields() {
52
+ return this.encodedFunctionCalls.flatMap((call)=>[
53
+ call.args_hash,
54
+ call.function_selector,
55
+ call.target_address,
56
+ new Fr(call.is_public),
57
+ new Fr(call.hide_msg_sender),
58
+ new Fr(call.is_static)
59
+ ]);
60
+ }
61
+ /**
62
+ * Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
63
+ * @param functionCalls - The function calls to execute
64
+ * @param txNonce - A nonce used to enable transaction cancellation when cancellable=true. Transactions with the same
65
+ * nonce can be replaced by submitting a new one with a higher fee.
66
+ * @returns The encoded calls
67
+ */ static async create(functionCalls, txNonce = Fr.random()) {
68
+ if (functionCalls.length > APP_MAX_CALLS) {
69
+ throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
70
+ }
71
+ const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), APP_MAX_CALLS);
72
+ const encoded = await encode(paddedCalls);
73
+ return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, DomainSeparator.SIGNATURE_PAYLOAD, txNonce);
74
+ }
75
+ }
76
+ /** Encodes FunctionCalls for execution, following Noir's convention */ export async function encode(calls) {
77
+ const hashedArguments = [];
78
+ for (const call of calls){
79
+ const hashed = call.type === FunctionType.PUBLIC ? await HashedValues.fromCalldata([
80
+ call.selector.toField(),
81
+ ...call.args
82
+ ]) : await HashedValues.fromArgs(call.args);
83
+ hashedArguments.push(hashed);
84
+ }
85
+ /* eslint-disable camelcase */ const encodedFunctionCalls = calls.map((call, index)=>({
86
+ args_hash: hashedArguments[index].hash,
87
+ function_selector: call.selector.toField(),
88
+ target_address: call.to.toField(),
89
+ is_public: call.type == FunctionType.PUBLIC,
90
+ hide_msg_sender: call.hideMsgSender,
91
+ is_static: call.isStatic
92
+ }));
93
+ return {
94
+ encodedFunctionCalls,
95
+ hashedArguments
96
+ };
97
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The `@aztec-labs/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module.
3
+ *
4
+ * Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export * from './account_entrypoint.js';
9
+ export * from './interfaces.js';
10
+ export * from './default_entrypoint.js';
11
+ export * from './encoding.js';
12
+ export * from './default_multi_call_entrypoint.js';
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxjQUFjLHlCQUF5QixDQUFDO0FBQ3hDLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLG9DQUFvQyxDQUFDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,oCAAoC,CAAC"}
package/dest/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The `@aztec-labs/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module.
3
+ *
4
+ * Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}.
5
+ *
6
+ * @packageDocumentation
7
+ */ export * from './account_entrypoint.js';
8
+ export * from './interfaces.js';
9
+ export * from './default_entrypoint.js';
10
+ export * from './encoding.js';
11
+ export * from './default_multi_call_entrypoint.js';
@@ -0,0 +1,60 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import type { AuthWitness } from '@aztec-labs/stdlib/auth-witness';
3
+ import type { GasSettings } from '@aztec-labs/stdlib/gas';
4
+ import type { ExecutionPayload, TxExecutionRequest } from '@aztec-labs/stdlib/tx';
5
+ import { z } from 'zod';
6
+ /**
7
+ * Information on the connected chain. Used by wallets when constructing transactions to protect against replay
8
+ * attacks.
9
+ */
10
+ export type ChainInfo = {
11
+ /** The L1 chain id */
12
+ chainId: Fr;
13
+ /** The version of the rollup */
14
+ version: Fr;
15
+ };
16
+ /**
17
+ * Zod schema for ChainInfo
18
+ */
19
+ export declare const ChainInfoSchema: z.ZodObject<{
20
+ chainId: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
21
+ version: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
22
+ }, z.core.$strip>;
23
+ /**
24
+ * Creates transaction execution requests out of a set of function calls, a fee payment method and
25
+ * general options for the transaction
26
+ */
27
+ export interface EntrypointInterface {
28
+ /**
29
+ * Generates an execution request out of set of function calls.
30
+ * @param exec - The execution intents to be run.
31
+ * @param gasSettings - The gas settings for the transaction.
32
+ * @param chainInfo - Chain information (chainId and version) for replay protection.
33
+ * @param options - Miscellaneous tx options that enable/disable features of the entrypoint
34
+ * @returns The authenticated transaction execution request.
35
+ */
36
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, chainInfo: ChainInfo, options?: any): Promise<TxExecutionRequest>;
37
+ /**
38
+ * Wraps an execution payload such that it is executed *via* this entrypoint.
39
+ * This returns an ExecutionPayload with the entrypoint as the caller for the wrapped payload.
40
+ * Useful for account self-funding deployments and batching calls beyond the limit
41
+ * of a single entrypoint call.
42
+ *
43
+ * @param exec - The execution payload to wrap
44
+ * @param chainInfo - Chain information (chainId and version) for replay protection
45
+ * @param options - Implementation-specific options
46
+ * @returns A new execution payload with a single call to this entrypoint
47
+ * @throws Error if the payload cannot be wrapped (e.g., exceeds call limit)
48
+ */
49
+ wrapExecutionPayload(exec: ExecutionPayload, chainInfo: ChainInfo, options?: any): Promise<ExecutionPayload>;
50
+ }
51
+ /** Creates authorization witnesses. */
52
+ export interface AuthWitnessProvider {
53
+ /**
54
+ * Computes an authentication witness from either a message hash
55
+ * @param messageHash - The message hash to approve
56
+ * @returns The authentication witness
57
+ */
58
+ createAuthWit(messageHash: Fr | Buffer): Promise<AuthWitness>;
59
+ }
60
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ25FLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLGtCQUFrQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbEYsT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUV4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M,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,sBAAsB;IACtB,OAAO,EAAE,EAAE,CAAC;IACZ,iCAAiC;IACjC,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;iBAG1B,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,wBAAwB,CACtB,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE/B;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9G;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/D"}
@@ -0,0 +1,8 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Zod schema for ChainInfo
5
+ */ export const ChainInfoSchema = z.object({
6
+ chainId: Fr.schema,
7
+ version: Fr.schema
8
+ });
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@aztec-labs/entrypoints",
3
+ "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/entrypoints",
4
+ "description": "Implementation of sample contract entrypoints for the Aztec Network",
5
+ "version": "6.0.0-nightly.20260829",
6
+ "type": "module",
7
+ "exports": {
8
+ "./account": "./dest/account_entrypoint.js",
9
+ "./default": "./dest/default_entrypoint.js",
10
+ "./multicall": "./dest/default_multi_call_entrypoint.js",
11
+ "./interfaces": "./dest/interfaces.js",
12
+ "./payload": "./dest/payload.js",
13
+ "./encoding": "./dest/encoding.js"
14
+ },
15
+ "typedocOptions": {
16
+ "entryPoints": [
17
+ "./src/index.ts"
18
+ ],
19
+ "name": "Entrypoints",
20
+ "tsconfig": "./tsconfig.json"
21
+ },
22
+ "scripts": {
23
+ "build": "yarn clean && ../scripts/tsc.sh",
24
+ "build:dev": "../scripts/tsc.sh --watch",
25
+ "build:ts": "../scripts/tsc.sh",
26
+ "clean": "rm -rf ./dest .tsbuildinfo",
27
+ "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
28
+ },
29
+ "inherits": [
30
+ "../package.common.json"
31
+ ],
32
+ "jest": {
33
+ "moduleNameMapper": {
34
+ "^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
35
+ },
36
+ "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
37
+ "rootDir": "./src",
38
+ "transform": {
39
+ "^.+\\.tsx?$": [
40
+ "@swc/jest",
41
+ {
42
+ "jsc": {
43
+ "parser": {
44
+ "syntax": "typescript",
45
+ "decorators": true
46
+ },
47
+ "transform": {
48
+ "decoratorVersion": "2022-03"
49
+ }
50
+ }
51
+ }
52
+ ]
53
+ },
54
+ "extensionsToTreatAsEsm": [
55
+ ".ts"
56
+ ],
57
+ "reporters": [
58
+ "default"
59
+ ],
60
+ "testTimeout": 120000,
61
+ "setupFiles": [
62
+ "../../foundation/src/jest/setup.mjs"
63
+ ],
64
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
65
+ "setupFilesAfterEnv": [
66
+ "../../foundation/src/jest/setupAfterEnv.mjs"
67
+ ]
68
+ },
69
+ "dependencies": {
70
+ "@aztec-labs/constants": "6.0.0-nightly.20260829",
71
+ "@aztec-labs/foundation": "6.0.0-nightly.20260829",
72
+ "@aztec-labs/standard-contracts": "6.0.0-nightly.20260829",
73
+ "@aztec-labs/stdlib": "6.0.0-nightly.20260829",
74
+ "tslib": "^2.4.0",
75
+ "zod": "^4"
76
+ },
77
+ "devDependencies": {
78
+ "@jest/globals": "^30.0.0",
79
+ "@types/jest": "^30.0.0",
80
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
81
+ "jest": "^30.0.0",
82
+ "ts-node": "^10.9.1",
83
+ "typescript": "^5.3.3"
84
+ },
85
+ "files": [
86
+ "dest",
87
+ "src",
88
+ "!*.test.*"
89
+ ],
90
+ "engines": {
91
+ "node": ">=20.10"
92
+ }
93
+ }
@@ -0,0 +1,216 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import {
3
+ type FunctionAbi,
4
+ FunctionCall,
5
+ FunctionSelector,
6
+ encodeArguments,
7
+ getFunctionReturnType,
8
+ } from '@aztec-labs/stdlib/abi';
9
+ import { computeOuterAuthWitHash } from '@aztec-labs/stdlib/auth-witness';
10
+ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
11
+ import type { GasSettings } from '@aztec-labs/stdlib/gas';
12
+ import { ExecutionPayload, HashedValues, TxContext, TxExecutionRequest } from '@aztec-labs/stdlib/tx';
13
+
14
+ import { EncodedAppEntrypointCalls } from './encoding.js';
15
+ import type { AuthWitnessProvider, ChainInfo, EntrypointInterface } from './interfaces.js';
16
+
17
+ /**
18
+ * The mechanism via which an account contract will pay for a transaction in which it gets invoked.
19
+ */
20
+ export enum AccountFeePaymentMethodOptions {
21
+ /**
22
+ * Signals that some other contract is in charge of paying the fee, nothing needs to be done.
23
+ */
24
+ EXTERNAL = 0,
25
+ /**
26
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance,
27
+ * **which it must already have prior to this transaction**.
28
+ *
29
+ * The contract will set itself as the fee payer and end the setup phase.
30
+ */
31
+ PREEXISTING_FEE_JUICE = 1,
32
+ /**
33
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance
34
+ * **which is being claimed in the same transaction**.
35
+ *
36
+ * The contract will set itself as the fee payer but not end setup phase - this is done by the Fee Juice
37
+ * contract after enqueuing a public call, which unlike most public calls is whitelisted by the nodes
38
+ * to be executable during the setup phase.
39
+ */
40
+ FEE_JUICE_WITH_CLAIM = 2,
41
+ }
42
+
43
+ /**
44
+ * General options for the tx execution.
45
+ */
46
+ export type DefaultAccountEntrypointOptions = {
47
+ /** Whether the transaction can be cancelled. */
48
+ cancellable?: boolean;
49
+ /**
50
+ * A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
51
+ * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
52
+ * but higher fee. The nullifier ensures only one transaction can succeed.
53
+ */
54
+ txNonce?: Fr;
55
+ /** Options that configure how the account contract behaves depending on the fee payment method of the tx */
56
+ feePaymentMethodOptions: AccountFeePaymentMethodOptions;
57
+ };
58
+
59
+ /**
60
+ * Implementation for an entrypoint interface that follows the default entrypoint signature
61
+ * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
62
+ */
63
+ export class DefaultAccountEntrypoint implements EntrypointInterface {
64
+ constructor(
65
+ private address: AztecAddress,
66
+ private auth: AuthWitnessProvider,
67
+ ) {}
68
+
69
+ async createTxExecutionRequest(
70
+ exec: ExecutionPayload,
71
+ gasSettings: GasSettings,
72
+ chainInfo: ChainInfo,
73
+ options: DefaultAccountEntrypointOptions,
74
+ ): Promise<TxExecutionRequest> {
75
+ const { authWitnesses, capsules, extraHashedArgs } = exec;
76
+ const callData = await this.#buildEntrypointCallData(exec, chainInfo, options);
77
+ const entrypointHashedArgs = await HashedValues.fromArgs(callData.encodedArgs);
78
+ const txRequest = TxExecutionRequest.from({
79
+ firstCallArgsHash: entrypointHashedArgs.hash,
80
+ origin: this.address,
81
+ functionSelector: callData.functionSelector,
82
+ txContext: new TxContext(chainInfo.chainId.toNumber(), chainInfo.version.toNumber(), gasSettings),
83
+ argsOfCalls: [...callData.encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs],
84
+ authWitnesses: [...authWitnesses, callData.payloadAuthWitness],
85
+ capsules,
86
+ salt: Fr.random(),
87
+ });
88
+
89
+ return txRequest;
90
+ }
91
+
92
+ async wrapExecutionPayload(
93
+ exec: ExecutionPayload,
94
+ chainInfo: ChainInfo,
95
+ options: DefaultAccountEntrypointOptions,
96
+ ): Promise<ExecutionPayload> {
97
+ const { authWitnesses, capsules, extraHashedArgs, feePayer } = exec;
98
+ const callData = await this.#buildEntrypointCallData(exec, chainInfo, options);
99
+
100
+ // Build the entrypoint function call
101
+ const entrypointCall = FunctionCall.from({
102
+ name: callData.abi.name,
103
+ to: this.address,
104
+ selector: callData.functionSelector,
105
+ type: callData.abi.functionType,
106
+ hideMsgSender: false,
107
+ isStatic: callData.abi.isStatic,
108
+ args: callData.encodedArgs,
109
+ returnType: getFunctionReturnType(callData.abi),
110
+ });
111
+
112
+ return new ExecutionPayload(
113
+ [entrypointCall],
114
+ [callData.payloadAuthWitness, ...authWitnesses],
115
+ capsules,
116
+ [...callData.encodedCalls.hashedArguments, ...extraHashedArgs],
117
+ feePayer ?? this.address,
118
+ );
119
+ }
120
+
121
+ /**
122
+ * Builds the shared data needed for both creating a tx execution request and wrapping an execution payload.
123
+ * This includes encoding calls, building entrypoint arguments, and creating the authwitness.
124
+ * @param exec - The execution payload containing calls to encode
125
+ * @param chainInfo - Chain information (chainId and version) for replay protection
126
+ * @param options - Account entrypoint options including tx nonce and fee payment method
127
+ * @returns Encoded call data, ABI, function selector, and auth witness
128
+ */
129
+ async #buildEntrypointCallData(
130
+ exec: ExecutionPayload,
131
+ chainInfo: ChainInfo,
132
+ options: DefaultAccountEntrypointOptions,
133
+ ) {
134
+ const { calls } = exec;
135
+ const { cancellable, txNonce, feePaymentMethodOptions } = options;
136
+
137
+ const encodedCalls = await EncodedAppEntrypointCalls.create(calls, txNonce);
138
+
139
+ const abi = this.getEntrypointAbi();
140
+ const args = [encodedCalls, feePaymentMethodOptions, !!cancellable];
141
+ const encodedArgs = encodeArguments(abi, args);
142
+
143
+ const functionSelector = await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters);
144
+
145
+ const payloadHash = await encodedCalls.hash();
146
+ const messageHash = await computeOuterAuthWitHash(this.address, chainInfo.chainId, chainInfo.version, payloadHash);
147
+ const payloadAuthWitness = await this.auth.createAuthWit(messageHash);
148
+
149
+ return {
150
+ encodedCalls,
151
+ abi,
152
+ encodedArgs,
153
+ functionSelector,
154
+ payloadAuthWitness,
155
+ };
156
+ }
157
+
158
+ private getEntrypointAbi() {
159
+ return {
160
+ name: 'entrypoint',
161
+ isInitializer: false,
162
+ functionType: 'private',
163
+ isOnlySelf: false,
164
+ isStatic: false,
165
+ parameters: [
166
+ {
167
+ name: 'app_payload',
168
+ type: {
169
+ kind: 'struct',
170
+ path: 'authwit::entrypoint::app::AppPayload',
171
+ fields: [
172
+ {
173
+ name: 'function_calls',
174
+ type: {
175
+ kind: 'array',
176
+ length: 5,
177
+ type: {
178
+ kind: 'struct',
179
+ path: 'authwit::entrypoint::function_call::FunctionCall',
180
+ fields: [
181
+ { name: 'args_hash', type: { kind: 'field' } },
182
+ {
183
+ name: 'function_selector',
184
+ type: {
185
+ kind: 'struct',
186
+ path: 'authwit::aztec::protocol_types::abis::function_selector::FunctionSelector',
187
+ fields: [{ name: 'inner', type: { kind: 'integer', sign: 'unsigned', width: 32 } }],
188
+ },
189
+ },
190
+ {
191
+ name: 'target_address',
192
+ type: {
193
+ kind: 'struct',
194
+ path: 'authwit::aztec::protocol_types::address::AztecAddress',
195
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
196
+ },
197
+ },
198
+ { name: 'is_public', type: { kind: 'boolean' } },
199
+ { name: 'hide_msg_sender', type: { kind: 'boolean' } },
200
+ { name: 'is_static', type: { kind: 'boolean' } },
201
+ ],
202
+ },
203
+ },
204
+ },
205
+ { name: 'tx_nonce', type: { kind: 'field' } },
206
+ ],
207
+ },
208
+ visibility: 'public',
209
+ },
210
+ { name: 'fee_payment_method', type: { kind: 'integer', sign: 'unsigned', width: 8 } },
211
+ { name: 'cancellable', type: { kind: 'boolean' } },
212
+ ],
213
+ errorTypes: {},
214
+ } as FunctionAbi;
215
+ }
216
+ }
@@ -0,0 +1,4 @@
1
+ /** Default L1 chain ID to use when constructing txs (matches hardhat and anvil's default). */
2
+ export const DEFAULT_CHAIN_ID = 31337;
3
+ /** Default protocol version to use. */
4
+ export const DEFAULT_VERSION = 1;