@aztec/entrypoints 2.1.0-rc.9 → 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,22 +1,17 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
- import type { FieldsOf } from '@aztec/foundation/types';
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
4
  import type { TxExecutionRequest } from '@aztec/stdlib/tx';
7
5
  import type { ExecutionPayload } from './payload.js';
8
6
  /**
9
- * General options for the tx execution.
7
+ * Information on the connected chain. Used by wallets when constructing transactions to protect against replay
8
+ * attacks.
10
9
  */
11
- export type TxExecutionOptions = {
12
- /** Whether the transaction can be cancelled. */
13
- cancellable?: boolean;
14
- /**
15
- * A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
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
  };
21
16
  /**
22
17
  * Creates transaction execution requests out of a set of function calls, a fee payment method and
@@ -26,11 +21,11 @@ export interface EntrypointInterface {
26
21
  /**
27
22
  * Generates an execution request out of set of function calls.
28
23
  * @param exec - The execution intents to be run.
29
- * @param fee - The fee options for the transaction.
30
- * @param options - Transaction nonce and whether the transaction is cancellable.
24
+ * @param gasSettings - The gas settings for the transaction.
25
+ * @param options - Miscellaneous tx options that enable/disable features of the entrypoint
31
26
  * @returns The authenticated transaction execution request.
32
27
  */
33
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
28
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options?: any): Promise<TxExecutionRequest>;
34
29
  }
35
30
  /** Creates authorization witnesses. */
36
31
  export interface AuthWitnessProvider {
@@ -41,45 +36,4 @@ export interface AuthWitnessProvider {
41
36
  */
42
37
  createAuthWit(messageHash: Fr | Buffer): Promise<AuthWitness>;
43
38
  }
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
39
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAA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,2 +1 @@
1
- // docs:start:user_fee_options
2
- /** Fee options as set by a user. */ export { }; // docs:end:user_fee_options
1
+ /** Creates authorization witnesses. */ export { };
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": "2.1.0-rc.9",
5
+ "version": "3.0.0-devnet.2",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  "./account": "./dest/account_entrypoint.js",
@@ -67,10 +67,10 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/constants": "2.1.0-rc.9",
71
- "@aztec/foundation": "2.1.0-rc.9",
72
- "@aztec/protocol-contracts": "2.1.0-rc.9",
73
- "@aztec/stdlib": "2.1.0-rc.9",
70
+ "@aztec/constants": "3.0.0-devnet.2",
71
+ "@aztec/foundation": "3.0.0-devnet.2",
72
+ "@aztec/protocol-contracts": "3.0.0-devnet.2",
73
+ "@aztec/stdlib": "3.0.0-devnet.2",
74
74
  "tslib": "^2.4.0"
75
75
  },
76
76
  "devDependencies": {
@@ -1,13 +1,56 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
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';
5
6
 
6
7
  import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
7
- import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encoding.js';
8
- import type { AuthWitnessProvider, EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
8
+ import { EncodedAppEntrypointCalls } from './encoding.js';
9
+ import type { AuthWitnessProvider, EntrypointInterface } from './interfaces.js';
9
10
  import { ExecutionPayload } from './payload.js';
10
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
+ };
53
+
11
54
  /**
12
55
  * Implementation for an entrypoint interface that follows the default entrypoint signature
13
56
  * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
@@ -22,48 +65,33 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
22
65
 
23
66
  async createTxExecutionRequest(
24
67
  exec: ExecutionPayload,
25
- fee: FeeOptions,
26
- options: TxExecutionOptions,
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 appEncodedCalls = await EncodedCallsForEntrypoint.fromAppExecution(calls, txNonce);
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 fee encoded calls
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, [appEncodedCalls, feeEncodedCalls, !!cancellable]),
81
+ encodeArguments(abi, [encodedCalls, feePaymentMethodOptions, !!cancellable]),
47
82
  );
48
83
 
49
- // Generate the combined payload auth witness, by signing the hash of the combined payload
50
- const combinedPayloadAuthWitness = await this.auth.createAuthWit(
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, fee.gasSettings),
60
- argsOfCalls: [
61
- ...appEncodedCalls.hashedArguments,
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
  });
@@ -89,50 +117,7 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
89
117
  name: 'function_calls',
90
118
  type: {
91
119
  kind: 'array',
92
- length: 4,
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,7 +1,8 @@
1
1
  import { FunctionType } from '@aztec/stdlib/abi';
2
+ import type { GasSettings } from '@aztec/stdlib/gas';
2
3
  import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
3
4
 
4
- import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
5
+ import type { EntrypointInterface } from './interfaces.js';
5
6
  import type { ExecutionPayload } from './payload.js';
6
7
 
7
8
  /**
@@ -13,14 +14,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
13
14
  private rollupVersion: number,
14
15
  ) {}
15
16
 
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
- }
17
+ async createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest> {
24
18
  // Initial request with calls, authWitnesses and capsules
25
19
  const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
26
20
 
@@ -42,7 +36,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
42
36
  call.to,
43
37
  call.selector,
44
38
  hashedArguments[0].hash,
45
- new TxContext(this.chainId, this.rollupVersion, fee.gasSettings),
39
+ new TxContext(this.chainId, this.rollupVersion, gasSettings),
46
40
  [...hashedArguments, ...extraHashedArgs],
47
41
  authWitnesses,
48
42
  capsules,
@@ -2,10 +2,11 @@ import { Fr } from '@aztec/foundation/fields';
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';
6
7
 
7
- import { EncodedCallsForEntrypoint } from './encoding.js';
8
- import type { EntrypointInterface, FeeOptions } from './interfaces.js';
8
+ import { EncodedAppEntrypointCalls } from './encoding.js';
9
+ import type { EntrypointInterface } from './interfaces.js';
9
10
  import type { ExecutionPayload } from './payload.js';
10
11
 
11
12
  /**
@@ -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, fee: FeeOptions): Promise<TxExecutionRequest> {
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
- // Get the execution payload for the fee, it includes the calls and potentially authWitnesses
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, fee.gasSettings),
46
- argsOfCalls: [...encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs, ...feeExtraHashedArgs],
47
- authWitnesses: [...feeAuthwitnesses, ...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
  });
@@ -70,7 +63,7 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
70
63
  name: 'function_calls',
71
64
  type: {
72
65
  kind: 'array',
73
- length: 4,
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
  },
package/src/encoding.ts CHANGED
@@ -8,9 +8,7 @@ import { HashedValues } from '@aztec/stdlib/tx';
8
8
 
9
9
  // These must match the values defined in:
10
10
  // - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
11
- const APP_MAX_CALLS = 4;
12
- // - and noir-projects/aztec-nr/aztec/src/entrypoint/fee.nr
13
- const FEE_MAX_CALLS = 2;
11
+ const APP_MAX_CALLS = 5;
14
12
 
15
13
  /** Encoded function call for an Aztec entrypoint */
16
14
  export type EncodedFunctionCall = {
@@ -23,6 +21,8 @@ export type EncodedFunctionCall = {
23
21
  target_address: Fr;
24
22
  /** Whether the function is public or private */
25
23
  is_public: boolean;
24
+ /** Only applicable for enqueued public function calls. Whether the msg_sender will be set to "null". */
25
+ hide_msg_sender: boolean;
26
26
  /** Whether the function can alter state */
27
27
  is_static: boolean;
28
28
  };
@@ -40,7 +40,7 @@ export type EncodedCalls = {
40
40
  * This utility class helps in creating the payload for the entrypoint by taking into
41
41
  * account how the calls are encoded and hashed.
42
42
  * */
43
- export abstract class EncodedCallsForEntrypoint implements EncodedCalls {
43
+ export class EncodedAppEntrypointCalls implements EncodedCalls {
44
44
  constructor(
45
45
  /** Function calls in the expected format (Noir's convention) */
46
46
  public encodedFunctionCalls: EncodedFunctionCall[],
@@ -71,7 +71,9 @@ export abstract class EncodedCallsForEntrypoint implements EncodedCalls {
71
71
  * Serializes the payload to an array of fields
72
72
  * @returns The fields of the payload
73
73
  */
74
- abstract toFields(): Fr[];
74
+ toFields(): Fr[] {
75
+ return [...this.functionCallsToFields(), this.tx_nonce];
76
+ }
75
77
 
76
78
  /**
77
79
  * Hashes the payload
@@ -88,20 +90,11 @@ export abstract class EncodedCallsForEntrypoint implements EncodedCalls {
88
90
  call.function_selector,
89
91
  call.target_address,
90
92
  new Fr(call.is_public),
93
+ new Fr(call.hide_msg_sender),
91
94
  new Fr(call.is_static),
92
95
  ]);
93
96
  }
94
97
 
95
- /**
96
- * Encodes a set of function calls for a dapp entrypoint
97
- * @param functionCalls - The function calls to execute
98
- * @returns The encoded calls
99
- */
100
- static async fromFunctionCalls(functionCalls: FunctionCall[]) {
101
- const encoded = await encode(functionCalls);
102
- return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, 0, Fr.random());
103
- }
104
-
105
98
  /**
106
99
  * Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
107
100
  * @param functionCalls - The function calls to execute
@@ -109,7 +102,7 @@ export abstract class EncodedCallsForEntrypoint implements EncodedCalls {
109
102
  * nonce can be replaced by submitting a new one with a higher fee.
110
103
  * @returns The encoded calls
111
104
  */
112
- static async fromAppExecution(
105
+ static async create(
113
106
  functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof APP_MAX_CALLS>,
114
107
  txNonce = Fr.random(),
115
108
  ) {
@@ -125,86 +118,6 @@ export abstract class EncodedCallsForEntrypoint implements EncodedCalls {
125
118
  txNonce,
126
119
  );
127
120
  }
128
-
129
- /**
130
- * Creates an encoded set of functions to pay the fee for a transaction
131
- * @param functionCalls - The calls generated by the payment method
132
- * @param isFeePayer - Whether the sender should be appointed as fee payer
133
- * @returns The encoded calls
134
- */
135
- static async fromFeeCalls(
136
- functionCalls: FunctionCall[] | Tuple<FunctionCall, typeof FEE_MAX_CALLS>,
137
- isFeePayer: boolean,
138
- ) {
139
- const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), FEE_MAX_CALLS);
140
- const encoded = await encode(paddedCalls);
141
- return new EncodedFeeEntrypointCalls(
142
- encoded.encodedFunctionCalls,
143
- encoded.hashedArguments,
144
- GeneratorIndex.FEE_PAYLOAD,
145
- Fr.random(),
146
- isFeePayer,
147
- );
148
- }
149
- }
150
-
151
- /** Encoded calls for app phase execution. */
152
- export class EncodedAppEntrypointCalls extends EncodedCallsForEntrypoint {
153
- constructor(
154
- encodedFunctionCalls: EncodedFunctionCall[],
155
- hashedArguments: HashedValues[],
156
- generatorIndex: number,
157
- txNonce: Fr,
158
- ) {
159
- super(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce);
160
- }
161
-
162
- override toFields(): Fr[] {
163
- return [...this.functionCallsToFields(), this.tx_nonce];
164
- }
165
- }
166
-
167
- /** Encoded calls for fee payment */
168
- export class EncodedFeeEntrypointCalls extends EncodedCallsForEntrypoint {
169
- #isFeePayer: boolean;
170
-
171
- constructor(
172
- encodedFunctionCalls: EncodedFunctionCall[],
173
- hashedArguments: HashedValues[],
174
- generatorIndex: number,
175
- txNonce: Fr,
176
- isFeePayer: boolean,
177
- ) {
178
- super(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce);
179
- this.#isFeePayer = isFeePayer;
180
- }
181
-
182
- override toFields(): Fr[] {
183
- return [...this.functionCallsToFields(), this.tx_nonce, new Fr(this.#isFeePayer)];
184
- }
185
-
186
- /* eslint-disable camelcase */
187
- /** Whether the sender should be appointed as fee payer. */
188
- get is_fee_payer() {
189
- return this.#isFeePayer;
190
- }
191
- /* eslint-enable camelcase */
192
- }
193
-
194
- /**
195
- * Computes a hash of a combined set of app and fee calls.
196
- * @param appCalls - A set of app calls.
197
- * @param feeCalls - A set of calls used to pay fees.
198
- * @returns A hash of a combined call set.
199
- */
200
- export async function computeCombinedPayloadHash(
201
- appPayload: EncodedAppEntrypointCalls,
202
- feePayload: EncodedFeeEntrypointCalls,
203
- ): Promise<Fr> {
204
- return poseidon2HashWithSeparator(
205
- [await appPayload.hash(), await feePayload.hash()],
206
- GeneratorIndex.COMBINED_PAYLOAD,
207
- );
208
121
  }
209
122
 
210
123
  /** Encodes FunctionCalls for execution, following Noir's convention */
@@ -224,6 +137,7 @@ export async function encode(calls: FunctionCall[]): Promise<EncodedCalls> {
224
137
  function_selector: call.selector.toField(),
225
138
  target_address: call.to.toField(),
226
139
  is_public: call.type == FunctionType.PUBLIC,
140
+ hide_msg_sender: call.hideMsgSender,
227
141
  is_static: call.isStatic,
228
142
  }));
229
143