@aztec/entrypoints 3.0.0-canary.a9708bd → 3.0.0-devnet.2

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.
@@ -1,7 +1,49 @@
1
+ import { Fr } from '@aztec/foundation/fields';
1
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { GasSettings } from '@aztec/stdlib/gas';
2
4
  import { TxExecutionRequest } from '@aztec/stdlib/tx';
3
- import type { AuthWitnessProvider, EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
5
+ import type { AuthWitnessProvider, EntrypointInterface } from './interfaces.js';
4
6
  import { ExecutionPayload } from './payload.js';
7
+ /**
8
+ * The mechanism via which an account contract will pay for a transaction in which it gets invoked.
9
+ */
10
+ export declare enum AccountFeePaymentMethodOptions {
11
+ /**
12
+ * Signals that some other contract is in charge of paying the fee, nothing needs to be done.
13
+ */
14
+ EXTERNAL = 0,
15
+ /**
16
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance,
17
+ * **which it must already have prior to this transaction**.
18
+ *
19
+ * The contract will set itself as the fee payer and end the setup phase.
20
+ */
21
+ PREEXISTING_FEE_JUICE = 1,
22
+ /**
23
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance
24
+ * **which is being claimed in the same transaction**.
25
+ *
26
+ * The contract will set itself as the fee payer but not end setup phase - this is done by the Fee Juice
27
+ * contract after enqueuing a public call, which unlike most public calls is whitelisted by the nodes
28
+ * to be executable during the setup phase.
29
+ */
30
+ FEE_JUICE_WITH_CLAIM = 2
31
+ }
32
+ /**
33
+ * General options for the tx execution.
34
+ */
35
+ export type DefaultAccountEntrypointOptions = {
36
+ /** Whether the transaction can be cancelled. */
37
+ cancellable?: boolean;
38
+ /**
39
+ * A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
40
+ * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
41
+ * but higher fee. The nullifier ensures only one transaction can succeed.
42
+ */
43
+ txNonce?: Fr;
44
+ /** Options that configure how the account contract behaves depending on the fee payment method of the tx */
45
+ feePaymentMethodOptions: AccountFeePaymentMethodOptions;
46
+ };
5
47
  /**
6
48
  * Implementation for an entrypoint interface that follows the default entrypoint signature
7
49
  * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
@@ -12,7 +54,7 @@ export declare class DefaultAccountEntrypoint implements EntrypointInterface {
12
54
  private chainId;
13
55
  private version;
14
56
  constructor(address: AztecAddress, auth: AuthWitnessProvider, chainId?: number, version?: number);
15
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
57
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options: DefaultAccountEntrypointOptions): Promise<TxExecutionRequest>;
16
58
  private getEntrypointAbi;
17
59
  }
18
60
  //# sourceMappingURL=account_entrypoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account_entrypoint.d.ts","sourceRoot":"","sources":["../src/account_entrypoint.ts"],"names":[],"mappings":"AAEA,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,wBAAyB,YAAW,mBAAmB;IAEhE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAHP,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,mBAAmB,EACzB,OAAO,GAAE,MAAyB,EAClC,OAAO,GAAE,MAAwB;IAGrC,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB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,+BAA+B,GACvC,OAAO,CAAC,kBAAkB,CAAC;IAgC9B,OAAO,CAAC,gBAAgB;CA2DzB"}
@@ -2,7 +2,29 @@ import { Fr } from '@aztec/foundation/fields';
2
2
  import { FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
3
3
  import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
4
4
  import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
5
- import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encoding.js';
5
+ import { EncodedAppEntrypointCalls } from './encoding.js';
6
+ /**
7
+ * The mechanism via which an account contract will pay for a transaction in which it gets invoked.
8
+ */ export var AccountFeePaymentMethodOptions = /*#__PURE__*/ function(AccountFeePaymentMethodOptions) {
9
+ /**
10
+ * Signals that some other contract is in charge of paying the fee, nothing needs to be done.
11
+ */ AccountFeePaymentMethodOptions[AccountFeePaymentMethodOptions["EXTERNAL"] = 0] = "EXTERNAL";
12
+ /**
13
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance,
14
+ * **which it must already have prior to this transaction**.
15
+ *
16
+ * The contract will set itself as the fee payer and end the setup phase.
17
+ */ AccountFeePaymentMethodOptions[AccountFeePaymentMethodOptions["PREEXISTING_FEE_JUICE"] = 1] = "PREEXISTING_FEE_JUICE";
18
+ /**
19
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance
20
+ * **which is being claimed in the same transaction**.
21
+ *
22
+ * The contract will set itself as the fee payer but not end setup phase - this is done by the Fee Juice
23
+ * contract after enqueuing a public call, which unlike most public calls is whitelisted by the nodes
24
+ * to be executable during the setup phase.
25
+ */ AccountFeePaymentMethodOptions[AccountFeePaymentMethodOptions["FEE_JUICE_WITH_CLAIM"] = 2] = "FEE_JUICE_WITH_CLAIM";
26
+ return AccountFeePaymentMethodOptions;
27
+ }({});
6
28
  /**
7
29
  * Implementation for an entrypoint interface that follows the default entrypoint signature
8
30
  * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
@@ -17,44 +39,36 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
17
39
  this.chainId = chainId;
18
40
  this.version = version;
19
41
  }
20
- async createTxExecutionRequest(exec, fee, options) {
42
+ async createTxExecutionRequest(exec, gasSettings, options) {
21
43
  // Initial request with calls, authWitnesses and capsules
22
44
  const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
23
45
  // Global tx options
24
- const { cancellable, txNonce } = options;
46
+ const { cancellable, txNonce, feePaymentMethodOptions } = options;
25
47
  // Encode the calls for the app
26
- const appEncodedCalls = await EncodedCallsForEntrypoint.fromAppExecution(calls, txNonce);
27
- // Get the execution payload for the fee, it includes the calls and potentially authWitnesses
28
- const { calls: feeCalls, authWitnesses: feeAuthwitnesses } = await fee.paymentMethod.getExecutionPayload(fee.gasSettings);
29
- // Encode the calls for the fee
30
- const feePayer = await fee.paymentMethod.getFeePayer(fee.gasSettings);
31
- const isFeePayer = feePayer.equals(this.address);
32
- const feeEncodedCalls = await EncodedCallsForEntrypoint.fromFeeCalls(feeCalls, isFeePayer);
33
- // Obtain the entrypoint hashed args, built from the app and fee encoded calls
48
+ const encodedCalls = await EncodedAppEntrypointCalls.create(calls, txNonce);
49
+ // Obtain the entrypoint hashed args, built from the app encoded calls and global options
34
50
  const abi = this.getEntrypointAbi();
35
51
  const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [
36
- appEncodedCalls,
37
- feeEncodedCalls,
52
+ encodedCalls,
53
+ feePaymentMethodOptions,
38
54
  !!cancellable
39
55
  ]));
40
- // Generate the combined payload auth witness, by signing the hash of the combined payload
41
- const combinedPayloadAuthWitness = await this.auth.createAuthWit(await computeCombinedPayloadHash(appEncodedCalls, feeEncodedCalls));
56
+ // Generate the payload auth witness, by signing the hash of the payload
57
+ const appPayloadAuthwitness = await this.auth.createAuthWit(await encodedCalls.hash());
42
58
  // Assemble the tx request
43
59
  const txRequest = TxExecutionRequest.from({
44
60
  firstCallArgsHash: entrypointHashedArgs.hash,
45
61
  origin: this.address,
46
62
  functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
47
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
63
+ txContext: new TxContext(this.chainId, this.version, gasSettings),
48
64
  argsOfCalls: [
49
- ...appEncodedCalls.hashedArguments,
50
- ...feeEncodedCalls.hashedArguments,
65
+ ...encodedCalls.hashedArguments,
51
66
  entrypointHashedArgs,
52
67
  ...extraHashedArgs
53
68
  ],
54
69
  authWitnesses: [
55
70
  ...authWitnesses,
56
- ...feeAuthwitnesses,
57
- combinedPayloadAuthWitness
71
+ appPayloadAuthwitness
58
72
  ],
59
73
  capsules,
60
74
  salt: Fr.random()
@@ -79,7 +93,7 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
79
93
  name: 'function_calls',
80
94
  type: {
81
95
  kind: 'array',
82
- length: 4,
96
+ length: 5,
83
97
  type: {
84
98
  kind: 'struct',
85
99
  path: 'authwit::entrypoint::function_call::FunctionCall',
@@ -129,80 +143,7 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
129
143
  }
130
144
  },
131
145
  {
132
- name: 'is_static',
133
- type: {
134
- kind: 'boolean'
135
- }
136
- }
137
- ]
138
- }
139
- }
140
- },
141
- {
142
- name: 'tx_nonce',
143
- type: {
144
- kind: 'field'
145
- }
146
- }
147
- ]
148
- },
149
- visibility: 'public'
150
- },
151
- {
152
- name: 'fee_payload',
153
- type: {
154
- kind: 'struct',
155
- path: 'authwit::entrypoint::fee::FeePayload',
156
- fields: [
157
- {
158
- name: 'function_calls',
159
- type: {
160
- kind: 'array',
161
- length: 2,
162
- type: {
163
- kind: 'struct',
164
- path: 'authwit::entrypoint::function_call::FunctionCall',
165
- fields: [
166
- {
167
- name: 'args_hash',
168
- type: {
169
- kind: 'field'
170
- }
171
- },
172
- {
173
- name: 'function_selector',
174
- type: {
175
- kind: 'struct',
176
- path: 'authwit::aztec::protocol_types::abis::function_selector::FunctionSelector',
177
- fields: [
178
- {
179
- name: 'inner',
180
- type: {
181
- kind: 'integer',
182
- sign: 'unsigned',
183
- width: 32
184
- }
185
- }
186
- ]
187
- }
188
- },
189
- {
190
- name: 'target_address',
191
- type: {
192
- kind: 'struct',
193
- path: 'authwit::aztec::protocol_types::address::AztecAddress',
194
- fields: [
195
- {
196
- name: 'inner',
197
- type: {
198
- kind: 'field'
199
- }
200
- }
201
- ]
202
- }
203
- },
204
- {
205
- name: 'is_public',
146
+ name: 'hide_msg_sender',
206
147
  type: {
207
148
  kind: 'boolean'
208
149
  }
@@ -222,17 +163,19 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
222
163
  type: {
223
164
  kind: 'field'
224
165
  }
225
- },
226
- {
227
- name: 'is_fee_payer',
228
- type: {
229
- kind: 'boolean'
230
- }
231
166
  }
232
167
  ]
233
168
  },
234
169
  visibility: 'public'
235
170
  },
171
+ {
172
+ name: 'fee_payment_method',
173
+ type: {
174
+ kind: 'integer',
175
+ sign: 'unsigned',
176
+ width: 8
177
+ }
178
+ },
236
179
  {
237
180
  name: 'cancellable',
238
181
  type: {
@@ -1,5 +1,6 @@
1
+ import type { GasSettings } from '@aztec/stdlib/gas';
1
2
  import { TxExecutionRequest } from '@aztec/stdlib/tx';
2
- import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
3
+ import type { EntrypointInterface } from './interfaces.js';
3
4
  import type { ExecutionPayload } from './payload.js';
4
5
  /**
5
6
  * Default implementation of the entrypoint interface. It calls a function on a contract directly
@@ -8,6 +9,6 @@ export declare class DefaultEntrypoint implements EntrypointInterface {
8
9
  private chainId;
9
10
  private rollupVersion;
10
11
  constructor(chainId: number, rollupVersion: number);
11
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
12
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest>;
12
13
  }
13
14
  //# sourceMappingURL=default_entrypoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default_entrypoint.d.ts","sourceRoot":"","sources":["../src/default_entrypoint.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,mBAAmB;IAEzD,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,aAAa;gBADb,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM;IAGzB,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;CA+B/B"}
1
+ {"version":3,"file":"default_entrypoint.d.ts","sourceRoot":"","sources":["../src/default_entrypoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,mBAAmB;IAEzD,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,aAAa;gBADb,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM;IAGzB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4B9G"}
@@ -9,10 +9,7 @@ import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
9
9
  this.chainId = chainId;
10
10
  this.rollupVersion = rollupVersion;
11
11
  }
12
- async createTxExecutionRequest(exec, fee, options) {
13
- if (options.txNonce || options.cancellable !== undefined) {
14
- throw new Error('TxExecutionOptions are not supported in DefaultEntrypoint');
15
- }
12
+ async createTxExecutionRequest(exec, gasSettings) {
16
13
  // Initial request with calls, authWitnesses and capsules
17
14
  const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
18
15
  if (calls.length > 1) {
@@ -27,7 +24,7 @@ import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
27
24
  throw new Error('Public entrypoints are not allowed');
28
25
  }
29
26
  // Assemble the tx request
30
- return new TxExecutionRequest(call.to, call.selector, hashedArguments[0].hash, new TxContext(this.chainId, this.rollupVersion, fee.gasSettings), [
27
+ return new TxExecutionRequest(call.to, call.selector, hashedArguments[0].hash, new TxContext(this.chainId, this.rollupVersion, gasSettings), [
31
28
  ...hashedArguments,
32
29
  ...extraHashedArgs
33
30
  ], authWitnesses, capsules);
@@ -1,6 +1,7 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { GasSettings } from '@aztec/stdlib/gas';
2
3
  import { TxExecutionRequest } from '@aztec/stdlib/tx';
3
- import type { EntrypointInterface, FeeOptions } from './interfaces.js';
4
+ import type { EntrypointInterface } from './interfaces.js';
4
5
  import type { ExecutionPayload } from './payload.js';
5
6
  /**
6
7
  * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
@@ -10,7 +11,7 @@ export declare class DefaultMultiCallEntrypoint implements EntrypointInterface {
10
11
  private version;
11
12
  private address;
12
13
  constructor(chainId: number, version: number, address?: AztecAddress);
13
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions): Promise<TxExecutionRequest>;
14
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest>;
14
15
  private getEntrypointAbi;
15
16
  }
16
17
  //# sourceMappingURL=default_multi_call_entrypoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default_multi_call_entrypoint.d.ts","sourceRoot":"","sources":["../src/default_multi_call_entrypoint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAElE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAFP,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAA0D;IAGvE,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkCpG,OAAO,CAAC,gBAAgB;CAwDzB"}
1
+ {"version":3,"file":"default_multi_call_entrypoint.d.ts","sourceRoot":"","sources":["../src/default_multi_call_entrypoint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAElE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAFP,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAA0D;IAGvE,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0B7G,OAAO,CAAC,gBAAgB;CAyDzB"}
@@ -2,7 +2,7 @@ import { Fr } from '@aztec/foundation/fields';
2
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
3
  import { FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
4
4
  import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
5
- import { EncodedCallsForEntrypoint } from './encoding.js';
5
+ import { EncodedAppEntrypointCalls } from './encoding.js';
6
6
  /**
7
7
  * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
8
8
  */ export class DefaultMultiCallEntrypoint {
@@ -14,14 +14,11 @@ import { EncodedCallsForEntrypoint } from './encoding.js';
14
14
  this.version = version;
15
15
  this.address = address;
16
16
  }
17
- async createTxExecutionRequest(exec, fee) {
17
+ async createTxExecutionRequest(exec, gasSettings) {
18
18
  // Initial request with calls, authWitnesses and capsules
19
19
  const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
20
- // Get the execution payload for the fee, it includes the calls and potentially authWitnesses
21
- const { calls: feeCalls, authWitnesses: feeAuthwitnesses, extraHashedArgs: feeExtraHashedArgs } = await fee.paymentMethod.getExecutionPayload(fee.gasSettings);
22
- // Encode the calls, including the fee calls
23
- // (since this entrypoint does not distinguish between app and fee calls)
24
- const encodedCalls = await EncodedCallsForEntrypoint.fromAppExecution(calls.concat(feeCalls));
20
+ // Encode the calls for the app
21
+ const encodedCalls = await EncodedAppEntrypointCalls.create(calls);
25
22
  // Obtain the entrypoint hashed args, built from the encoded calls
26
23
  const abi = this.getEntrypointAbi();
27
24
  const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [
@@ -32,17 +29,13 @@ import { EncodedCallsForEntrypoint } from './encoding.js';
32
29
  firstCallArgsHash: entrypointHashedArgs.hash,
33
30
  origin: this.address,
34
31
  functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
35
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
32
+ txContext: new TxContext(this.chainId, this.version, gasSettings),
36
33
  argsOfCalls: [
37
34
  ...encodedCalls.hashedArguments,
38
35
  entrypointHashedArgs,
39
- ...extraHashedArgs,
40
- ...feeExtraHashedArgs
41
- ],
42
- authWitnesses: [
43
- ...feeAuthwitnesses,
44
- ...authWitnesses
36
+ ...extraHashedArgs
45
37
  ],
38
+ authWitnesses,
46
39
  capsules,
47
40
  salt: Fr.random()
48
41
  });
@@ -66,7 +59,7 @@ import { EncodedCallsForEntrypoint } from './encoding.js';
66
59
  name: 'function_calls',
67
60
  type: {
68
61
  kind: 'array',
69
- length: 4,
62
+ length: 5,
70
63
  type: {
71
64
  kind: 'struct',
72
65
  path: 'authwit::entrypoint::function_call::FunctionCall',
@@ -115,6 +108,12 @@ import { EncodedCallsForEntrypoint } from './encoding.js';
115
108
  kind: 'boolean'
116
109
  }
117
110
  },
111
+ {
112
+ name: 'hide_msg_sender',
113
+ type: {
114
+ kind: 'boolean'
115
+ }
116
+ },
118
117
  {
119
118
  name: 'is_static',
120
119
  type: {
@@ -2,8 +2,7 @@ import { Fr } from '@aztec/foundation/fields';
2
2
  import type { Tuple } from '@aztec/foundation/serialize';
3
3
  import { FunctionCall } from '@aztec/stdlib/abi';
4
4
  import { HashedValues } from '@aztec/stdlib/tx';
5
- declare const APP_MAX_CALLS = 4;
6
- declare const FEE_MAX_CALLS = 2;
5
+ declare const APP_MAX_CALLS = 5;
7
6
  /** Encoded function call for an Aztec entrypoint */
8
7
  export type EncodedFunctionCall = {
9
8
  /** Arguments hash for the call. */
@@ -15,6 +14,8 @@ export type EncodedFunctionCall = {
15
14
  target_address: Fr;
16
15
  /** Whether the function is public or private */
17
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;
18
19
  /** Whether the function can alter state */
19
20
  is_static: boolean;
20
21
  };
@@ -30,7 +31,7 @@ export type EncodedCalls = {
30
31
  * This utility class helps in creating the payload for the entrypoint by taking into
31
32
  * account how the calls are encoded and hashed.
32
33
  * */
33
- export declare abstract class EncodedCallsForEntrypoint implements EncodedCalls {
34
+ export declare class EncodedAppEntrypointCalls implements EncodedCalls {
34
35
  /** Function calls in the expected format (Noir's convention) */
35
36
  encodedFunctionCalls: EncodedFunctionCall[];
36
37
  /** The hashed args for the call, ready to be injected in the execution cache */
@@ -65,7 +66,7 @@ export declare abstract class EncodedCallsForEntrypoint implements EncodedCalls
65
66
  * Serializes the payload to an array of fields
66
67
  * @returns The fields of the payload
67
68
  */
68
- abstract toFields(): Fr[];
69
+ toFields(): Fr[];
69
70
  /**
70
71
  * Hashes the payload
71
72
  * @returns The hash of the payload
@@ -73,12 +74,6 @@ export declare abstract class EncodedCallsForEntrypoint implements EncodedCalls
73
74
  hash(): Promise<Fr>;
74
75
  /** Serializes the function calls to an array of fields. */
75
76
  protected functionCallsToFields(): Fr[];
76
- /**
77
- * Encodes a set of function calls for a dapp entrypoint
78
- * @param functionCalls - The function calls to execute
79
- * @returns The encoded calls
80
- */
81
- static fromFunctionCalls(functionCalls: FunctionCall[]): Promise<EncodedAppEntrypointCalls>;
82
77
  /**
83
78
  * Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
84
79
  * @param functionCalls - The function calls to execute
@@ -86,35 +81,8 @@ export declare abstract class EncodedCallsForEntrypoint implements EncodedCalls
86
81
  * nonce can be replaced by submitting a new one with a higher fee.
87
82
  * @returns The encoded calls
88
83
  */
89
- static fromAppExecution(functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof APP_MAX_CALLS>, txNonce?: Fr): Promise<EncodedAppEntrypointCalls>;
90
- /**
91
- * Creates an encoded set of functions to pay the fee for a transaction
92
- * @param functionCalls - The calls generated by the payment method
93
- * @param isFeePayer - Whether the sender should be appointed as fee payer
94
- * @returns The encoded calls
95
- */
96
- static fromFeeCalls(functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof FEE_MAX_CALLS>, isFeePayer: boolean): Promise<EncodedFeeEntrypointCalls>;
97
- }
98
- /** Encoded calls for app phase execution. */
99
- export declare class EncodedAppEntrypointCalls extends EncodedCallsForEntrypoint {
100
- constructor(encodedFunctionCalls: EncodedFunctionCall[], hashedArguments: HashedValues[], generatorIndex: number, txNonce: Fr);
101
- toFields(): Fr[];
84
+ static create(functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof APP_MAX_CALLS>, txNonce?: Fr): Promise<EncodedAppEntrypointCalls>;
102
85
  }
103
- /** Encoded calls for fee payment */
104
- export declare class EncodedFeeEntrypointCalls extends EncodedCallsForEntrypoint {
105
- #private;
106
- constructor(encodedFunctionCalls: EncodedFunctionCall[], hashedArguments: HashedValues[], generatorIndex: number, txNonce: Fr, isFeePayer: boolean);
107
- toFields(): Fr[];
108
- /** Whether the sender should be appointed as fee payer. */
109
- get is_fee_payer(): boolean;
110
- }
111
- /**
112
- * Computes a hash of a combined set of app and fee calls.
113
- * @param appCalls - A set of app calls.
114
- * @param feeCalls - A set of calls used to pay fees.
115
- * @returns A hash of a combined call set.
116
- */
117
- export declare function computeCombinedPayloadHash(appPayload: EncodedAppEntrypointCalls, feePayload: EncodedFeeEntrypointCalls): Promise<Fr>;
118
86
  /** Encodes FunctionCalls for execution, following Noir's convention */
119
87
  export declare function encode(calls: FunctionCall[]): Promise<EncodedCalls>;
120
88
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,QAAA,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K,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAwBzE"}
package/dest/encoding.js CHANGED
@@ -6,14 +6,12 @@ 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 = 4;
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 EncodedCallsForEntrypoint {
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 fromAppExecution(functionCalls, txNonce = Fr.random()) {
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 {