@aztec/entrypoints 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/account_entrypoint.d.ts +46 -4
- package/dest/account_entrypoint.d.ts.map +1 -1
- package/dest/account_entrypoint.js +46 -103
- package/dest/constants.d.ts +1 -1
- package/dest/default_entrypoint.d.ts +5 -5
- package/dest/default_entrypoint.d.ts.map +1 -1
- package/dest/default_entrypoint.js +2 -5
- package/dest/default_multi_call_entrypoint.d.ts +5 -4
- package/dest/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/default_multi_call_entrypoint.js +16 -17
- package/dest/encoding.d.ts +8 -48
- package/dest/encoding.d.ts.map +1 -1
- package/dest/encoding.js +16 -64
- package/dest/index.d.ts +1 -1
- package/dest/interfaces.d.ts +27 -60
- package/dest/interfaces.d.ts.map +1 -1
- package/dest/interfaces.js +8 -2
- package/package.json +11 -9
- package/src/account_entrypoint.ts +62 -76
- package/src/default_entrypoint.ts +5 -12
- package/src/default_multi_call_entrypoint.ts +14 -20
- package/src/encoding.ts +12 -98
- package/src/interfaces.ts +22 -65
- package/dest/payload.d.ts +0 -32
- package/dest/payload.d.ts.map +0 -1
- package/dest/payload.js +0 -27
- package/src/payload.ts +0 -35
package/dest/encoding.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { GeneratorIndex } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
4
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
6
6
|
import { HashedValues } from '@aztec/stdlib/tx';
|
|
7
7
|
// These must match the values defined in:
|
|
8
8
|
// - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
|
|
9
|
-
const APP_MAX_CALLS =
|
|
10
|
-
// - and noir-projects/aztec-nr/aztec/src/entrypoint/fee.nr
|
|
11
|
-
const FEE_MAX_CALLS = 2;
|
|
9
|
+
const APP_MAX_CALLS = 5;
|
|
12
10
|
/**
|
|
13
11
|
* Entrypoints derive their arguments from the calls that they'll ultimate make.
|
|
14
12
|
* This utility class helps in creating the payload for the entrypoint by taking into
|
|
15
13
|
* account how the calls are encoded and hashed.
|
|
16
|
-
* */ export class
|
|
14
|
+
* */ export class EncodedAppEntrypointCalls {
|
|
17
15
|
encodedFunctionCalls;
|
|
18
16
|
hashedArguments;
|
|
19
17
|
generatorIndex;
|
|
@@ -35,6 +33,15 @@ const FEE_MAX_CALLS = 2;
|
|
|
35
33
|
*/ get function_calls() {
|
|
36
34
|
return this.encodedFunctionCalls;
|
|
37
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
|
+
}
|
|
38
45
|
/**
|
|
39
46
|
* Hashes the payload
|
|
40
47
|
* @returns The hash of the payload
|
|
@@ -47,24 +54,17 @@ const FEE_MAX_CALLS = 2;
|
|
|
47
54
|
call.function_selector,
|
|
48
55
|
call.target_address,
|
|
49
56
|
new Fr(call.is_public),
|
|
57
|
+
new Fr(call.hide_msg_sender),
|
|
50
58
|
new Fr(call.is_static)
|
|
51
59
|
]);
|
|
52
60
|
}
|
|
53
61
|
/**
|
|
54
|
-
* Encodes a set of function calls for a dapp entrypoint
|
|
55
|
-
* @param functionCalls - The function calls to execute
|
|
56
|
-
* @returns The encoded calls
|
|
57
|
-
*/ static async fromFunctionCalls(functionCalls) {
|
|
58
|
-
const encoded = await encode(functionCalls);
|
|
59
|
-
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, 0, Fr.random());
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
62
|
* Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
|
|
63
63
|
* @param functionCalls - The function calls to execute
|
|
64
64
|
* @param txNonce - A nonce used to enable transaction cancellation when cancellable=true. Transactions with the same
|
|
65
65
|
* nonce can be replaced by submitting a new one with a higher fee.
|
|
66
66
|
* @returns The encoded calls
|
|
67
|
-
*/ static async
|
|
67
|
+
*/ static async create(functionCalls, txNonce = Fr.random()) {
|
|
68
68
|
if (functionCalls.length > APP_MAX_CALLS) {
|
|
69
69
|
throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
|
|
70
70
|
}
|
|
@@ -72,55 +72,6 @@ const FEE_MAX_CALLS = 2;
|
|
|
72
72
|
const encoded = await encode(paddedCalls);
|
|
73
73
|
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, GeneratorIndex.SIGNATURE_PAYLOAD, txNonce);
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Creates an encoded set of functions to pay the fee for a transaction
|
|
77
|
-
* @param functionCalls - The calls generated by the payment method
|
|
78
|
-
* @param isFeePayer - Whether the sender should be appointed as fee payer
|
|
79
|
-
* @returns The encoded calls
|
|
80
|
-
*/ static async fromFeeCalls(functionCalls, isFeePayer) {
|
|
81
|
-
const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), FEE_MAX_CALLS);
|
|
82
|
-
const encoded = await encode(paddedCalls);
|
|
83
|
-
return new EncodedFeeEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, GeneratorIndex.FEE_PAYLOAD, Fr.random(), isFeePayer);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/** Encoded calls for app phase execution. */ export class EncodedAppEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
87
|
-
constructor(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce){
|
|
88
|
-
super(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce);
|
|
89
|
-
}
|
|
90
|
-
toFields() {
|
|
91
|
-
return [
|
|
92
|
-
...this.functionCallsToFields(),
|
|
93
|
-
this.tx_nonce
|
|
94
|
-
];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/** Encoded calls for fee payment */ export class EncodedFeeEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
98
|
-
#isFeePayer;
|
|
99
|
-
constructor(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce, isFeePayer){
|
|
100
|
-
super(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce);
|
|
101
|
-
this.#isFeePayer = isFeePayer;
|
|
102
|
-
}
|
|
103
|
-
toFields() {
|
|
104
|
-
return [
|
|
105
|
-
...this.functionCallsToFields(),
|
|
106
|
-
this.tx_nonce,
|
|
107
|
-
new Fr(this.#isFeePayer)
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
|
-
/* eslint-disable camelcase */ /** Whether the sender should be appointed as fee payer. */ get is_fee_payer() {
|
|
111
|
-
return this.#isFeePayer;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Computes a hash of a combined set of app and fee calls.
|
|
116
|
-
* @param appCalls - A set of app calls.
|
|
117
|
-
* @param feeCalls - A set of calls used to pay fees.
|
|
118
|
-
* @returns A hash of a combined call set.
|
|
119
|
-
*/ export async function computeCombinedPayloadHash(appPayload, feePayload) {
|
|
120
|
-
return poseidon2HashWithSeparator([
|
|
121
|
-
await appPayload.hash(),
|
|
122
|
-
await feePayload.hash()
|
|
123
|
-
], GeneratorIndex.COMBINED_PAYLOAD);
|
|
124
75
|
}
|
|
125
76
|
/** Encodes FunctionCalls for execution, following Noir's convention */ export async function encode(calls) {
|
|
126
77
|
const hashedArguments = [];
|
|
@@ -136,6 +87,7 @@ const FEE_MAX_CALLS = 2;
|
|
|
136
87
|
function_selector: call.selector.toField(),
|
|
137
88
|
target_address: call.to.toField(),
|
|
138
89
|
is_public: call.type == FunctionType.PUBLIC,
|
|
90
|
+
hide_msg_sender: call.hideMsgSender,
|
|
139
91
|
is_static: call.isStatic
|
|
140
92
|
}));
|
|
141
93
|
return {
|
package/dest/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export * from './interfaces.js';
|
|
|
10
10
|
export * from './default_entrypoint.js';
|
|
11
11
|
export * from './encoding.js';
|
|
12
12
|
export * from './default_multi_call_entrypoint.js';
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxjQUFjLHlCQUF5QixDQUFDO0FBQ3hDLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLG9DQUFvQyxDQUFDIn0=
|
package/dest/interfaces.d.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
3
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
7
|
-
import
|
|
4
|
+
import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
|
+
import { z } from 'zod';
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
7
|
+
* Information on the connected chain. Used by wallets when constructing transactions to protect against replay
|
|
8
|
+
* attacks.
|
|
10
9
|
*/
|
|
11
|
-
export type
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
17
|
-
* but higher fee. The nullifier ensures only one transaction can succeed.
|
|
18
|
-
*/
|
|
19
|
-
txNonce?: Fr;
|
|
10
|
+
export type ChainInfo = {
|
|
11
|
+
/** The L1 chain id */
|
|
12
|
+
chainId: Fr;
|
|
13
|
+
/** The version of the rollup */
|
|
14
|
+
version: Fr;
|
|
20
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Zod schema for ChainInfo
|
|
18
|
+
*/
|
|
19
|
+
export declare const ChainInfoSchema: z.ZodObject<{
|
|
20
|
+
chainId: z.ZodType<Fr, any, string>;
|
|
21
|
+
version: z.ZodType<Fr, any, string>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
chainId: Fr;
|
|
24
|
+
version: Fr;
|
|
25
|
+
}, {
|
|
26
|
+
chainId: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}>;
|
|
21
29
|
/**
|
|
22
30
|
* Creates transaction execution requests out of a set of function calls, a fee payment method and
|
|
23
31
|
* general options for the transaction
|
|
@@ -26,11 +34,11 @@ export interface EntrypointInterface {
|
|
|
26
34
|
/**
|
|
27
35
|
* Generates an execution request out of set of function calls.
|
|
28
36
|
* @param exec - The execution intents to be run.
|
|
29
|
-
* @param
|
|
30
|
-
* @param options -
|
|
37
|
+
* @param gasSettings - The gas settings for the transaction.
|
|
38
|
+
* @param options - Miscellaneous tx options that enable/disable features of the entrypoint
|
|
31
39
|
* @returns The authenticated transaction execution request.
|
|
32
40
|
*/
|
|
33
|
-
createTxExecutionRequest(exec: ExecutionPayload,
|
|
41
|
+
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options?: any): Promise<TxExecutionRequest>;
|
|
34
42
|
}
|
|
35
43
|
/** Creates authorization witnesses. */
|
|
36
44
|
export interface AuthWitnessProvider {
|
|
@@ -41,45 +49,4 @@ export interface AuthWitnessProvider {
|
|
|
41
49
|
*/
|
|
42
50
|
createAuthWit(messageHash: Fr | Buffer): Promise<AuthWitness>;
|
|
43
51
|
}
|
|
44
|
-
|
|
45
|
-
* Holds information about how the fee for a transaction is to be paid.
|
|
46
|
-
*/
|
|
47
|
-
export interface FeePaymentMethod {
|
|
48
|
-
/** The asset used to pay the fee. */
|
|
49
|
-
getAsset(): Promise<AztecAddress>;
|
|
50
|
-
/**
|
|
51
|
-
* Returns the data to be added to the final execution request
|
|
52
|
-
* to pay the fee in the given asset
|
|
53
|
-
* @param gasSettings - The gas limits and max fees.
|
|
54
|
-
* @returns The function calls to pay the fee.
|
|
55
|
-
*/
|
|
56
|
-
getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
|
|
57
|
-
/**
|
|
58
|
-
* The expected fee payer for this tx.
|
|
59
|
-
* @param gasSettings - The gas limits and max fees.
|
|
60
|
-
*/
|
|
61
|
-
getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Fee payment options for a transaction.
|
|
65
|
-
*/
|
|
66
|
-
export type FeeOptions = {
|
|
67
|
-
/** The fee payment method to use */
|
|
68
|
-
paymentMethod: FeePaymentMethod;
|
|
69
|
-
/** The gas settings */
|
|
70
|
-
gasSettings: GasSettings;
|
|
71
|
-
};
|
|
72
|
-
/** Fee options as set by a user. */
|
|
73
|
-
export type UserFeeOptions = {
|
|
74
|
-
/** The fee payment method to use */
|
|
75
|
-
paymentMethod?: FeePaymentMethod;
|
|
76
|
-
/** The gas settings */
|
|
77
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
78
|
-
/** Percentage to pad the base fee by, if empty, defaults to 0.5 */
|
|
79
|
-
baseFeePadding?: number;
|
|
80
|
-
/** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
|
|
81
|
-
estimateGas?: boolean;
|
|
82
|
-
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
83
|
-
estimatedGasPadding?: number;
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=interfaces.d.ts.map
|
|
52
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3JELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLGtCQUFrQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFN0UsT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUV4Qjs7O0dBR0c7QUFDSCxNQUFNLE1BQU0sU0FBUyxHQUFHO0lBQ3RCLHNCQUFzQjtJQUN0QixPQUFPLEVBQUUsRUFBRSxDQUFDO0lBQ1osaUNBQWlDO0lBQ2pDLE9BQU8sRUFBRSxFQUFFLENBQUM7Q0FDYixDQUFDO0FBRUY7O0dBRUc7QUFDSCxlQUFPLE1BQU0sZUFBZTs7Ozs7Ozs7O0VBRzFCLENBQUM7QUFFSDs7O0dBR0c7QUFDSCxNQUFNLFdBQVcsbUJBQW1CO0lBQ2xDOzs7Ozs7T0FNRztJQUNILHdCQUF3QixDQUN0QixJQUFJLEVBQUUsZ0JBQWdCLEVBQ3RCLFdBQVcsRUFBRSxXQUFXLEVBQ3hCLE9BQU8sQ0FBQyxFQUFFLEdBQUcsR0FDWixPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztDQUNoQztBQUVELHVDQUF1QztBQUN2QyxNQUFNLFdBQVcsbUJBQW1CO0lBQ2xDOzs7O09BSUc7SUFDSCxhQUFhLENBQUMsV0FBVyxFQUFFLEVBQUUsR0FBRyxNQUFNLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0NBQy9EIn0=
|
package/dest/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,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;;;;;;;;;EAG1B,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,wBAAwB,CACtB,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChC;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/D"}
|
package/dest/interfaces.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Fr } from '@aztec/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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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": "4.0.0-nightly.
|
|
5
|
+
"version": "4.0.0-nightly.20260107",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./account": "./dest/account_entrypoint.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"tsconfig": "./tsconfig.json"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "yarn clean && tsc
|
|
24
|
-
"build:dev": "tsc
|
|
25
|
-
"build:ts": "
|
|
23
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
24
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
25
|
+
"build:ts": "tsgo -b",
|
|
26
26
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
27
27
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
28
28
|
},
|
|
@@ -67,15 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "4.0.0-nightly.
|
|
71
|
-
"@aztec/foundation": "4.0.0-nightly.
|
|
72
|
-
"@aztec/protocol-contracts": "4.0.0-nightly.
|
|
73
|
-
"@aztec/stdlib": "4.0.0-nightly.
|
|
74
|
-
"tslib": "^2.4.0"
|
|
70
|
+
"@aztec/constants": "4.0.0-nightly.20260107",
|
|
71
|
+
"@aztec/foundation": "4.0.0-nightly.20260107",
|
|
72
|
+
"@aztec/protocol-contracts": "4.0.0-nightly.20260107",
|
|
73
|
+
"@aztec/stdlib": "4.0.0-nightly.20260107",
|
|
74
|
+
"tslib": "^2.4.0",
|
|
75
|
+
"zod": "^3.23.8"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
78
|
"@jest/globals": "^30.0.0",
|
|
78
79
|
"@types/jest": "^30.0.0",
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
79
81
|
"jest": "^30.0.0",
|
|
80
82
|
"ts-node": "^10.9.1",
|
|
81
83
|
"typescript": "^5.3.3"
|
|
@@ -1,12 +1,55 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
5
|
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
5
7
|
|
|
6
8
|
import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
7
|
-
import {
|
|
8
|
-
import type { AuthWitnessProvider, EntrypointInterface
|
|
9
|
-
|
|
9
|
+
import { EncodedAppEntrypointCalls } from './encoding.js';
|
|
10
|
+
import type { AuthWitnessProvider, EntrypointInterface } from './interfaces.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The mechanism via which an account contract will pay for a transaction in which it gets invoked.
|
|
14
|
+
*/
|
|
15
|
+
export enum AccountFeePaymentMethodOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Signals that some other contract is in charge of paying the fee, nothing needs to be done.
|
|
18
|
+
*/
|
|
19
|
+
EXTERNAL = 0,
|
|
20
|
+
/**
|
|
21
|
+
* Used to make the account contract publicly pay for the transaction with its own fee juice balance,
|
|
22
|
+
* **which it must already have prior to this transaction**.
|
|
23
|
+
*
|
|
24
|
+
* The contract will set itself as the fee payer and end the setup phase.
|
|
25
|
+
*/
|
|
26
|
+
PREEXISTING_FEE_JUICE = 1,
|
|
27
|
+
/**
|
|
28
|
+
* Used to make the account contract publicly pay for the transaction with its own fee juice balance
|
|
29
|
+
* **which is being claimed in the same transaction**.
|
|
30
|
+
*
|
|
31
|
+
* The contract will set itself as the fee payer but not end setup phase - this is done by the Fee Juice
|
|
32
|
+
* contract after enqueuing a public call, which unlike most public calls is whitelisted by the nodes
|
|
33
|
+
* to be executable during the setup phase.
|
|
34
|
+
*/
|
|
35
|
+
FEE_JUICE_WITH_CLAIM = 2,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* General options for the tx execution.
|
|
40
|
+
*/
|
|
41
|
+
export type DefaultAccountEntrypointOptions = {
|
|
42
|
+
/** Whether the transaction can be cancelled. */
|
|
43
|
+
cancellable?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
|
|
46
|
+
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
47
|
+
* but higher fee. The nullifier ensures only one transaction can succeed.
|
|
48
|
+
*/
|
|
49
|
+
txNonce?: Fr;
|
|
50
|
+
/** Options that configure how the account contract behaves depending on the fee payment method of the tx */
|
|
51
|
+
feePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
52
|
+
};
|
|
10
53
|
|
|
11
54
|
/**
|
|
12
55
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
@@ -22,48 +65,33 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
22
65
|
|
|
23
66
|
async createTxExecutionRequest(
|
|
24
67
|
exec: ExecutionPayload,
|
|
25
|
-
|
|
26
|
-
options:
|
|
68
|
+
gasSettings: GasSettings,
|
|
69
|
+
options: DefaultAccountEntrypointOptions,
|
|
27
70
|
): Promise<TxExecutionRequest> {
|
|
28
71
|
// Initial request with calls, authWitnesses and capsules
|
|
29
72
|
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
30
73
|
// Global tx options
|
|
31
|
-
const { cancellable, txNonce } = options;
|
|
74
|
+
const { cancellable, txNonce, feePaymentMethodOptions } = options;
|
|
32
75
|
// Encode the calls for the app
|
|
33
|
-
const
|
|
34
|
-
// Get the execution payload for the fee, it includes the calls and potentially authWitnesses
|
|
35
|
-
const { calls: feeCalls, authWitnesses: feeAuthwitnesses } = await fee.paymentMethod.getExecutionPayload(
|
|
36
|
-
fee.gasSettings,
|
|
37
|
-
);
|
|
38
|
-
// Encode the calls for the fee
|
|
39
|
-
const feePayer = await fee.paymentMethod.getFeePayer(fee.gasSettings);
|
|
40
|
-
const isFeePayer = feePayer.equals(this.address);
|
|
41
|
-
const feeEncodedCalls = await EncodedCallsForEntrypoint.fromFeeCalls(feeCalls, isFeePayer);
|
|
76
|
+
const encodedCalls = await EncodedAppEntrypointCalls.create(calls, txNonce);
|
|
42
77
|
|
|
43
|
-
// Obtain the entrypoint hashed args, built from the app and
|
|
78
|
+
// Obtain the entrypoint hashed args, built from the app encoded calls and global options
|
|
44
79
|
const abi = this.getEntrypointAbi();
|
|
45
80
|
const entrypointHashedArgs = await HashedValues.fromArgs(
|
|
46
|
-
encodeArguments(abi, [
|
|
81
|
+
encodeArguments(abi, [encodedCalls, feePaymentMethodOptions, !!cancellable]),
|
|
47
82
|
);
|
|
48
83
|
|
|
49
|
-
// Generate the
|
|
50
|
-
const
|
|
51
|
-
await computeCombinedPayloadHash(appEncodedCalls, feeEncodedCalls),
|
|
52
|
-
);
|
|
84
|
+
// Generate the payload auth witness, by signing the hash of the payload
|
|
85
|
+
const appPayloadAuthwitness = await this.auth.createAuthWit(await encodedCalls.hash());
|
|
53
86
|
|
|
54
87
|
// Assemble the tx request
|
|
55
88
|
const txRequest = TxExecutionRequest.from({
|
|
56
89
|
firstCallArgsHash: entrypointHashedArgs.hash,
|
|
57
90
|
origin: this.address,
|
|
58
91
|
functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
|
|
59
|
-
txContext: new TxContext(this.chainId, this.version,
|
|
60
|
-
argsOfCalls: [
|
|
61
|
-
|
|
62
|
-
...feeEncodedCalls.hashedArguments,
|
|
63
|
-
entrypointHashedArgs,
|
|
64
|
-
...extraHashedArgs,
|
|
65
|
-
],
|
|
66
|
-
authWitnesses: [...authWitnesses, ...feeAuthwitnesses, combinedPayloadAuthWitness],
|
|
92
|
+
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
93
|
+
argsOfCalls: [...encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs],
|
|
94
|
+
authWitnesses: [...authWitnesses, appPayloadAuthwitness],
|
|
67
95
|
capsules,
|
|
68
96
|
salt: Fr.random(),
|
|
69
97
|
});
|
|
@@ -76,7 +104,7 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
76
104
|
name: 'entrypoint',
|
|
77
105
|
isInitializer: false,
|
|
78
106
|
functionType: 'private',
|
|
79
|
-
|
|
107
|
+
isOnlySelf: false,
|
|
80
108
|
isStatic: false,
|
|
81
109
|
parameters: [
|
|
82
110
|
{
|
|
@@ -89,50 +117,7 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
89
117
|
name: 'function_calls',
|
|
90
118
|
type: {
|
|
91
119
|
kind: 'array',
|
|
92
|
-
length:
|
|
93
|
-
type: {
|
|
94
|
-
kind: 'struct',
|
|
95
|
-
path: 'authwit::entrypoint::function_call::FunctionCall',
|
|
96
|
-
fields: [
|
|
97
|
-
{ name: 'args_hash', type: { kind: 'field' } },
|
|
98
|
-
{
|
|
99
|
-
name: 'function_selector',
|
|
100
|
-
type: {
|
|
101
|
-
kind: 'struct',
|
|
102
|
-
path: 'authwit::aztec::protocol_types::abis::function_selector::FunctionSelector',
|
|
103
|
-
fields: [{ name: 'inner', type: { kind: 'integer', sign: 'unsigned', width: 32 } }],
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: 'target_address',
|
|
108
|
-
type: {
|
|
109
|
-
kind: 'struct',
|
|
110
|
-
path: 'authwit::aztec::protocol_types::address::AztecAddress',
|
|
111
|
-
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
{ name: 'is_public', type: { kind: 'boolean' } },
|
|
115
|
-
{ name: 'is_static', type: { kind: 'boolean' } },
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
{ name: 'tx_nonce', type: { kind: 'field' } },
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
visibility: 'public',
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: 'fee_payload',
|
|
127
|
-
type: {
|
|
128
|
-
kind: 'struct',
|
|
129
|
-
path: 'authwit::entrypoint::fee::FeePayload',
|
|
130
|
-
fields: [
|
|
131
|
-
{
|
|
132
|
-
name: 'function_calls',
|
|
133
|
-
type: {
|
|
134
|
-
kind: 'array',
|
|
135
|
-
length: 2,
|
|
120
|
+
length: 5,
|
|
136
121
|
type: {
|
|
137
122
|
kind: 'struct',
|
|
138
123
|
path: 'authwit::entrypoint::function_call::FunctionCall',
|
|
@@ -155,17 +140,18 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
155
140
|
},
|
|
156
141
|
},
|
|
157
142
|
{ name: 'is_public', type: { kind: 'boolean' } },
|
|
143
|
+
{ name: 'hide_msg_sender', type: { kind: 'boolean' } },
|
|
158
144
|
{ name: 'is_static', type: { kind: 'boolean' } },
|
|
159
145
|
],
|
|
160
146
|
},
|
|
161
147
|
},
|
|
162
148
|
},
|
|
163
149
|
{ name: 'tx_nonce', type: { kind: 'field' } },
|
|
164
|
-
{ name: 'is_fee_payer', type: { kind: 'boolean' } },
|
|
165
150
|
],
|
|
166
151
|
},
|
|
167
152
|
visibility: 'public',
|
|
168
153
|
},
|
|
154
|
+
{ name: 'fee_payment_method', type: { kind: 'integer', sign: 'unsigned', width: 8 } },
|
|
169
155
|
{ name: 'cancellable', type: { kind: 'boolean' } },
|
|
170
156
|
],
|
|
171
157
|
returnTypes: [],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
-
import {
|
|
2
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
3
|
+
import { type ExecutionPayload, HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
4
|
-
import type { EntrypointInterface
|
|
5
|
-
import type { ExecutionPayload } from './payload.js';
|
|
5
|
+
import type { EntrypointInterface } from './interfaces.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Default implementation of the entrypoint interface. It calls a function on a contract directly
|
|
@@ -13,14 +13,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
|
|
|
13
13
|
private rollupVersion: number,
|
|
14
14
|
) {}
|
|
15
15
|
|
|
16
|
-
async createTxExecutionRequest(
|
|
17
|
-
exec: ExecutionPayload,
|
|
18
|
-
fee: FeeOptions,
|
|
19
|
-
options: TxExecutionOptions,
|
|
20
|
-
): Promise<TxExecutionRequest> {
|
|
21
|
-
if (options.txNonce || options.cancellable !== undefined) {
|
|
22
|
-
throw new Error('TxExecutionOptions are not supported in DefaultEntrypoint');
|
|
23
|
-
}
|
|
16
|
+
async createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest> {
|
|
24
17
|
// Initial request with calls, authWitnesses and capsules
|
|
25
18
|
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
26
19
|
|
|
@@ -42,7 +35,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
|
|
|
42
35
|
call.to,
|
|
43
36
|
call.selector,
|
|
44
37
|
hashedArguments[0].hash,
|
|
45
|
-
new TxContext(this.chainId, this.rollupVersion,
|
|
38
|
+
new TxContext(this.chainId, this.rollupVersion, gasSettings),
|
|
46
39
|
[...hashedArguments, ...extraHashedArgs],
|
|
47
40
|
authWitnesses,
|
|
48
41
|
capsules,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
3
|
import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
6
|
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
7
|
+
import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
8
|
|
|
7
|
-
import {
|
|
8
|
-
import type { EntrypointInterface
|
|
9
|
-
import type { ExecutionPayload } from './payload.js';
|
|
9
|
+
import { EncodedAppEntrypointCalls } from './encoding.js';
|
|
10
|
+
import type { EntrypointInterface } from './interfaces.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
|
|
@@ -18,20 +19,12 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
18
19
|
private address: AztecAddress = ProtocolContractAddress.MultiCallEntrypoint,
|
|
19
20
|
) {}
|
|
20
21
|
|
|
21
|
-
async createTxExecutionRequest(exec: ExecutionPayload,
|
|
22
|
+
async createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest> {
|
|
22
23
|
// Initial request with calls, authWitnesses and capsules
|
|
23
24
|
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
-
const
|
|
27
|
-
calls: feeCalls,
|
|
28
|
-
authWitnesses: feeAuthwitnesses,
|
|
29
|
-
extraHashedArgs: feeExtraHashedArgs,
|
|
30
|
-
} = await fee.paymentMethod.getExecutionPayload(fee.gasSettings);
|
|
31
|
-
|
|
32
|
-
// Encode the calls, including the fee calls
|
|
33
|
-
// (since this entrypoint does not distinguish between app and fee calls)
|
|
34
|
-
const encodedCalls = await EncodedCallsForEntrypoint.fromAppExecution(calls.concat(feeCalls));
|
|
26
|
+
// Encode the calls for the app
|
|
27
|
+
const encodedCalls = await EncodedAppEntrypointCalls.create(calls);
|
|
35
28
|
|
|
36
29
|
// Obtain the entrypoint hashed args, built from the encoded calls
|
|
37
30
|
const abi = this.getEntrypointAbi();
|
|
@@ -42,9 +35,9 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
42
35
|
firstCallArgsHash: entrypointHashedArgs.hash,
|
|
43
36
|
origin: this.address,
|
|
44
37
|
functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
|
|
45
|
-
txContext: new TxContext(this.chainId, this.version,
|
|
46
|
-
argsOfCalls: [...encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs
|
|
47
|
-
authWitnesses
|
|
38
|
+
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
39
|
+
argsOfCalls: [...encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs],
|
|
40
|
+
authWitnesses,
|
|
48
41
|
capsules,
|
|
49
42
|
salt: Fr.random(),
|
|
50
43
|
});
|
|
@@ -57,7 +50,7 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
57
50
|
name: 'entrypoint',
|
|
58
51
|
isInitializer: false,
|
|
59
52
|
functionType: 'private',
|
|
60
|
-
|
|
53
|
+
isOnlySelf: false,
|
|
61
54
|
isStatic: false,
|
|
62
55
|
parameters: [
|
|
63
56
|
{
|
|
@@ -70,7 +63,7 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
70
63
|
name: 'function_calls',
|
|
71
64
|
type: {
|
|
72
65
|
kind: 'array',
|
|
73
|
-
length:
|
|
66
|
+
length: 5,
|
|
74
67
|
type: {
|
|
75
68
|
kind: 'struct',
|
|
76
69
|
path: 'authwit::entrypoint::function_call::FunctionCall',
|
|
@@ -93,6 +86,7 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
93
86
|
},
|
|
94
87
|
},
|
|
95
88
|
{ name: 'is_public', type: { kind: 'boolean' } },
|
|
89
|
+
{ name: 'hide_msg_sender', type: { kind: 'boolean' } },
|
|
96
90
|
{ name: 'is_static', type: { kind: 'boolean' } },
|
|
97
91
|
],
|
|
98
92
|
},
|