@aztec/entrypoints 1.2.0 → 2.0.0-nightly.20250813

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.
package/dest/index.d.ts CHANGED
@@ -6,7 +6,6 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  export * from './account_entrypoint.js';
9
- export * from './dapp_entrypoint.js';
10
9
  export * from './interfaces.js';
11
10
  export * from './default_entrypoint.js';
12
11
  export * from './encoding.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,oCAAoC,CAAC"}
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 CHANGED
@@ -5,7 +5,6 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */ export * from './account_entrypoint.js';
8
- export * from './dapp_entrypoint.js';
9
8
  export * from './interfaces.js';
10
9
  export * from './default_entrypoint.js';
11
10
  export * from './encoding.js';
package/package.json CHANGED
@@ -2,10 +2,9 @@
2
2
  "name": "@aztec/entrypoints",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/entrypoints",
4
4
  "description": "Implementation of sample contract entrypoints for the Aztec Network",
5
- "version": "1.2.0",
5
+ "version": "2.0.0-nightly.20250813",
6
6
  "type": "module",
7
7
  "exports": {
8
- "./dapp": "./dest/dapp_entrypoint.js",
9
8
  "./account": "./dest/account_entrypoint.js",
10
9
  "./default": "./dest/default_entrypoint.js",
11
10
  "./multicall": "./dest/default_multi_call_entrypoint.js",
@@ -68,10 +67,10 @@
68
67
  ]
69
68
  },
70
69
  "dependencies": {
71
- "@aztec/constants": "1.2.0",
72
- "@aztec/foundation": "1.2.0",
73
- "@aztec/protocol-contracts": "1.2.0",
74
- "@aztec/stdlib": "1.2.0",
70
+ "@aztec/constants": "2.0.0-nightly.20250813",
71
+ "@aztec/foundation": "2.0.0-nightly.20250813",
72
+ "@aztec/protocol-contracts": "2.0.0-nightly.20250813",
73
+ "@aztec/stdlib": "2.0.0-nightly.20250813",
75
74
  "tslib": "^2.4.0"
76
75
  },
77
76
  "devDependencies": {
package/src/index.ts CHANGED
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  export * from './account_entrypoint.js';
10
- export * from './dapp_entrypoint.js';
11
10
  export * from './interfaces.js';
12
11
  export * from './default_entrypoint.js';
13
12
  export * from './encoding.js';
@@ -1,19 +0,0 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import { TxExecutionRequest } from '@aztec/stdlib/tx';
3
- import type { AuthWitnessProvider, EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
4
- import { ExecutionPayload } from './payload.js';
5
- /**
6
- * Implementation for an entrypoint interface that follows the default entrypoint signature
7
- * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
8
- */
9
- export declare class DefaultDappEntrypoint implements EntrypointInterface {
10
- private userAddress;
11
- private userAuthWitnessProvider;
12
- private dappEntrypointAddress;
13
- private chainId;
14
- private version;
15
- constructor(userAddress: AztecAddress, userAuthWitnessProvider: AuthWitnessProvider, dappEntrypointAddress: AztecAddress, chainId?: number, version?: number);
16
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
17
- private getEntrypointAbi;
18
- }
19
- //# sourceMappingURL=dapp_entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dapp_entrypoint.d.ts","sourceRoot":"","sources":["../src/dapp_entrypoint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,mBAAmB;IAE7D,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,uBAAuB;IAC/B,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAJP,WAAW,EAAE,YAAY,EACzB,uBAAuB,EAAE,mBAAmB,EAC5C,qBAAqB,EAAE,YAAY,EACnC,OAAO,GAAE,MAAyB,EAClC,OAAO,GAAE,MAAwB;IAGrC,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IAkD9B,OAAO,CAAC,gBAAgB;CAiEzB"}
@@ -1,179 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { FunctionSelector, FunctionType, encodeArguments } from '@aztec/stdlib/abi';
3
- import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
4
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
5
- import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
6
- import { EncodedCallsForEntrypoint } from './encoding.js';
7
- /**
8
- * Implementation for an entrypoint interface that follows the default entrypoint signature
9
- * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
10
- */ export class DefaultDappEntrypoint {
11
- userAddress;
12
- userAuthWitnessProvider;
13
- dappEntrypointAddress;
14
- chainId;
15
- version;
16
- constructor(userAddress, userAuthWitnessProvider, dappEntrypointAddress, chainId = DEFAULT_CHAIN_ID, version = DEFAULT_VERSION){
17
- this.userAddress = userAddress;
18
- this.userAuthWitnessProvider = userAuthWitnessProvider;
19
- this.dappEntrypointAddress = dappEntrypointAddress;
20
- this.chainId = chainId;
21
- this.version = version;
22
- }
23
- async createTxExecutionRequest(exec, fee, options) {
24
- if (options.txNonce || options.cancellable !== undefined) {
25
- throw new Error('TxExecutionOptions are not supported in DappEntrypoint');
26
- }
27
- // Initial request with calls, authWitnesses and capsules
28
- const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
29
- if (calls.length !== 1) {
30
- throw new Error(`Expected exactly 1 function call, got ${calls.length}`);
31
- }
32
- // Encode the function call the dapp is ultimately going to invoke
33
- const encodedCalls = await EncodedCallsForEntrypoint.fromFunctionCalls(calls);
34
- // Obtain the entrypoint hashed args, built from the function call and the user's address
35
- const abi = this.getEntrypointAbi();
36
- const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [
37
- encodedCalls,
38
- this.userAddress
39
- ]));
40
- // Construct an auth witness for the entrypoint, by signing the hash of the action to perform
41
- // (the dapp calls a function on the user's behalf)
42
- const functionSelector = await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters);
43
- // Default msg_sender for entrypoints is now Fr.max_value rather than 0 addr (see #7190 & #7404)
44
- const innerHash = await computeInnerAuthWitHash([
45
- Fr.MAX_FIELD_VALUE,
46
- functionSelector.toField(),
47
- entrypointHashedArgs.hash
48
- ]);
49
- const outerHash = await computeOuterAuthWitHash(this.dappEntrypointAddress, new Fr(this.chainId), new Fr(this.version), innerHash);
50
- const entypointAuthwitness = await this.userAuthWitnessProvider.createAuthWit(outerHash);
51
- // Assemble the tx request
52
- const txRequest = TxExecutionRequest.from({
53
- firstCallArgsHash: entrypointHashedArgs.hash,
54
- origin: this.dappEntrypointAddress,
55
- functionSelector,
56
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
57
- argsOfCalls: [
58
- ...encodedCalls.hashedArguments,
59
- entrypointHashedArgs,
60
- ...extraHashedArgs
61
- ],
62
- authWitnesses: [
63
- entypointAuthwitness,
64
- ...authWitnesses
65
- ],
66
- capsules,
67
- salt: Fr.random()
68
- });
69
- return txRequest;
70
- }
71
- getEntrypointAbi() {
72
- return {
73
- name: 'entrypoint',
74
- isInitializer: false,
75
- functionType: FunctionType.PRIVATE,
76
- isInternal: false,
77
- isStatic: false,
78
- parameters: [
79
- {
80
- name: 'payload',
81
- type: {
82
- kind: 'struct',
83
- path: 'dapp_payload::DAppPayload',
84
- fields: [
85
- {
86
- name: 'function_calls',
87
- type: {
88
- kind: 'array',
89
- length: 1,
90
- type: {
91
- kind: 'struct',
92
- path: 'authwit::entrypoint::function_call::FunctionCall',
93
- fields: [
94
- {
95
- name: 'args_hash',
96
- type: {
97
- kind: 'field'
98
- }
99
- },
100
- {
101
- name: 'function_selector',
102
- type: {
103
- kind: 'struct',
104
- path: 'authwit::aztec::protocol_types::abis::function_selector::FunctionSelector',
105
- fields: [
106
- {
107
- name: 'inner',
108
- type: {
109
- kind: 'integer',
110
- sign: 'unsigned',
111
- width: 32
112
- }
113
- }
114
- ]
115
- }
116
- },
117
- {
118
- name: 'target_address',
119
- type: {
120
- kind: 'struct',
121
- path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
122
- fields: [
123
- {
124
- name: 'inner',
125
- type: {
126
- kind: 'field'
127
- }
128
- }
129
- ]
130
- }
131
- },
132
- {
133
- name: 'is_public',
134
- type: {
135
- kind: 'boolean'
136
- }
137
- },
138
- {
139
- name: 'is_static',
140
- type: {
141
- kind: 'boolean'
142
- }
143
- }
144
- ]
145
- }
146
- }
147
- },
148
- {
149
- name: 'tx_nonce',
150
- type: {
151
- kind: 'field'
152
- }
153
- }
154
- ]
155
- },
156
- visibility: 'public'
157
- },
158
- {
159
- name: 'user_address',
160
- type: {
161
- kind: 'struct',
162
- path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
163
- fields: [
164
- {
165
- name: 'inner',
166
- type: {
167
- kind: 'field'
168
- }
169
- }
170
- ]
171
- },
172
- visibility: 'public'
173
- }
174
- ],
175
- returnTypes: [],
176
- errorTypes: {}
177
- };
178
- }
179
- }
@@ -1,144 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { type FunctionAbi, FunctionSelector, FunctionType, encodeArguments } from '@aztec/stdlib/abi';
3
- import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
6
-
7
- import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
8
- import { EncodedCallsForEntrypoint } from './encoding.js';
9
- import type { AuthWitnessProvider, EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
10
- import { ExecutionPayload } from './payload.js';
11
-
12
- /**
13
- * Implementation for an entrypoint interface that follows the default entrypoint signature
14
- * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
15
- */
16
- export class DefaultDappEntrypoint implements EntrypointInterface {
17
- constructor(
18
- private userAddress: AztecAddress,
19
- private userAuthWitnessProvider: AuthWitnessProvider,
20
- private dappEntrypointAddress: AztecAddress,
21
- private chainId: number = DEFAULT_CHAIN_ID,
22
- private version: number = DEFAULT_VERSION,
23
- ) {}
24
-
25
- async createTxExecutionRequest(
26
- exec: ExecutionPayload,
27
- fee: FeeOptions,
28
- options: TxExecutionOptions,
29
- ): Promise<TxExecutionRequest> {
30
- if (options.txNonce || options.cancellable !== undefined) {
31
- throw new Error('TxExecutionOptions are not supported in DappEntrypoint');
32
- }
33
- // Initial request with calls, authWitnesses and capsules
34
- const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
35
- if (calls.length !== 1) {
36
- throw new Error(`Expected exactly 1 function call, got ${calls.length}`);
37
- }
38
-
39
- // Encode the function call the dapp is ultimately going to invoke
40
- const encodedCalls = await EncodedCallsForEntrypoint.fromFunctionCalls(calls);
41
-
42
- // Obtain the entrypoint hashed args, built from the function call and the user's address
43
- const abi = this.getEntrypointAbi();
44
- const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [encodedCalls, this.userAddress]));
45
-
46
- // Construct an auth witness for the entrypoint, by signing the hash of the action to perform
47
- // (the dapp calls a function on the user's behalf)
48
- const functionSelector = await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters);
49
- // Default msg_sender for entrypoints is now Fr.max_value rather than 0 addr (see #7190 & #7404)
50
- const innerHash = await computeInnerAuthWitHash([
51
- Fr.MAX_FIELD_VALUE,
52
- functionSelector.toField(),
53
- entrypointHashedArgs.hash,
54
- ]);
55
- const outerHash = await computeOuterAuthWitHash(
56
- this.dappEntrypointAddress,
57
- new Fr(this.chainId),
58
- new Fr(this.version),
59
- innerHash,
60
- );
61
-
62
- const entypointAuthwitness = await this.userAuthWitnessProvider.createAuthWit(outerHash);
63
-
64
- // Assemble the tx request
65
- const txRequest = TxExecutionRequest.from({
66
- firstCallArgsHash: entrypointHashedArgs.hash,
67
- origin: this.dappEntrypointAddress,
68
- functionSelector,
69
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
70
- argsOfCalls: [...encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs],
71
- authWitnesses: [entypointAuthwitness, ...authWitnesses],
72
- capsules,
73
- salt: Fr.random(),
74
- });
75
-
76
- return txRequest;
77
- }
78
-
79
- private getEntrypointAbi(): FunctionAbi {
80
- return {
81
- name: 'entrypoint',
82
- isInitializer: false,
83
- functionType: FunctionType.PRIVATE,
84
- isInternal: false,
85
- isStatic: false,
86
- parameters: [
87
- {
88
- name: 'payload',
89
- type: {
90
- kind: 'struct',
91
- path: 'dapp_payload::DAppPayload',
92
- fields: [
93
- {
94
- name: 'function_calls',
95
- type: {
96
- kind: 'array',
97
- length: 1,
98
- type: {
99
- kind: 'struct',
100
- path: 'authwit::entrypoint::function_call::FunctionCall',
101
- fields: [
102
- { name: 'args_hash', type: { kind: 'field' } },
103
- {
104
- name: 'function_selector',
105
- type: {
106
- kind: 'struct',
107
- path: 'authwit::aztec::protocol_types::abis::function_selector::FunctionSelector',
108
- fields: [{ name: 'inner', type: { kind: 'integer', sign: 'unsigned', width: 32 } }],
109
- },
110
- },
111
- {
112
- name: 'target_address',
113
- type: {
114
- kind: 'struct',
115
- path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
116
- fields: [{ name: 'inner', type: { kind: 'field' } }],
117
- },
118
- },
119
- { name: 'is_public', type: { kind: 'boolean' } },
120
- { name: 'is_static', type: { kind: 'boolean' } },
121
- ],
122
- },
123
- },
124
- },
125
- { name: 'tx_nonce', type: { kind: 'field' } },
126
- ],
127
- },
128
- visibility: 'public',
129
- },
130
- {
131
- name: 'user_address',
132
- type: {
133
- kind: 'struct',
134
- path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
135
- fields: [{ name: 'inner', type: { kind: 'field' } }],
136
- },
137
- visibility: 'public',
138
- },
139
- ],
140
- returnTypes: [],
141
- errorTypes: {},
142
- } as const;
143
- }
144
- }