@aztec/entrypoints 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9

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,18 +1,59 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
1
2
  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';
3
+ import type { GasSettings } from '@aztec/stdlib/gas';
4
+ import { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
5
+ import type { AuthWitnessProvider, ChainInfo, EntrypointInterface } from './interfaces.js';
6
+ /**
7
+ * The mechanism via which an account contract will pay for a transaction in which it gets invoked.
8
+ */
9
+ export declare enum AccountFeePaymentMethodOptions {
10
+ /**
11
+ * Signals that some other contract is in charge of paying the fee, nothing needs to be done.
12
+ */
13
+ EXTERNAL = 0,
14
+ /**
15
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance,
16
+ * **which it must already have prior to this transaction**.
17
+ *
18
+ * The contract will set itself as the fee payer and end the setup phase.
19
+ */
20
+ PREEXISTING_FEE_JUICE = 1,
21
+ /**
22
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance
23
+ * **which is being claimed in the same transaction**.
24
+ *
25
+ * The contract will set itself as the fee payer but not end setup phase - this is done by the Fee Juice
26
+ * contract after enqueuing a public call, which unlike most public calls is whitelisted by the nodes
27
+ * to be executable during the setup phase.
28
+ */
29
+ FEE_JUICE_WITH_CLAIM = 2
30
+ }
31
+ /**
32
+ * General options for the tx execution.
33
+ */
34
+ export type DefaultAccountEntrypointOptions = {
35
+ /** Whether the transaction can be cancelled. */
36
+ cancellable?: boolean;
37
+ /**
38
+ * A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
39
+ * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
40
+ * but higher fee. The nullifier ensures only one transaction can succeed.
41
+ */
42
+ txNonce?: Fr;
43
+ /** Options that configure how the account contract behaves depending on the fee payment method of the tx */
44
+ feePaymentMethodOptions: AccountFeePaymentMethodOptions;
45
+ };
5
46
  /**
6
47
  * Implementation for an entrypoint interface that follows the default entrypoint signature
7
48
  * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
8
49
  */
9
50
  export declare class DefaultAccountEntrypoint implements EntrypointInterface {
51
+ #private;
10
52
  private address;
11
53
  private auth;
12
- private chainId;
13
- private version;
14
- constructor(address: AztecAddress, auth: AuthWitnessProvider, chainId?: number, version?: number);
15
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
54
+ constructor(address: AztecAddress, auth: AuthWitnessProvider);
55
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, chainInfo: ChainInfo, options: DefaultAccountEntrypointOptions): Promise<TxExecutionRequest>;
56
+ wrapExecutionPayload(exec: ExecutionPayload, options: DefaultAccountEntrypointOptions): Promise<ExecutionPayload>;
16
57
  private getEntrypointAbi;
17
58
  }
18
- //# sourceMappingURL=account_entrypoint.d.ts.map
59
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9lbnRyeXBvaW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYWNjb3VudF9lbnRyeXBvaW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUVwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUI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UMsZ0JBQWdCLENBQUMsQ0F1QjNCO0lBZ0NELE9BQU8sQ0FBQyxnQkFBZ0I7Q0EyRHpCIn0=
@@ -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,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IA+C9B,OAAO,CAAC,gBAAgB;CAqGzB"}
1
+ {"version":3,"file":"account_entrypoint.d.ts","sourceRoot":"","sources":["../src/account_entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGjG,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3F;;GAEG;AACH,oBAAY,8BAA8B;IACxC;;OAEG;IACH,QAAQ,IAAI;IACZ;;;;;OAKG;IACH,qBAAqB,IAAI;IACzB;;;;;;;OAOG;IACH,oBAAoB,IAAI;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,4GAA4G;IAC5G,uBAAuB,EAAE,8BAA8B,CAAC;CACzD,CAAC;AAEF;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;;IAEhE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;IAFd,YACU,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,mBAAmB,EAC/B;IAEE,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,kBAAkB,CAAC,CAgB7B;IAEK,oBAAoB,CACxB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,gBAAgB,CAAC,CAuB3B;IAgCD,OAAO,CAAC,gBAAgB;CA2DzB"}
@@ -1,72 +1,119 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
3
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
4
- import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
5
- import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encoding.js';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { FunctionCall, FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
3
+ import { ExecutionPayload, HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
4
+ import { EncodedAppEntrypointCalls } from './encoding.js';
5
+ /**
6
+ * The mechanism via which an account contract will pay for a transaction in which it gets invoked.
7
+ */ export var AccountFeePaymentMethodOptions = /*#__PURE__*/ function(AccountFeePaymentMethodOptions) {
8
+ /**
9
+ * Signals that some other contract is in charge of paying the fee, nothing needs to be done.
10
+ */ AccountFeePaymentMethodOptions[AccountFeePaymentMethodOptions["EXTERNAL"] = 0] = "EXTERNAL";
11
+ /**
12
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance,
13
+ * **which it must already have prior to this transaction**.
14
+ *
15
+ * The contract will set itself as the fee payer and end the setup phase.
16
+ */ AccountFeePaymentMethodOptions[AccountFeePaymentMethodOptions["PREEXISTING_FEE_JUICE"] = 1] = "PREEXISTING_FEE_JUICE";
17
+ /**
18
+ * Used to make the account contract publicly pay for the transaction with its own fee juice balance
19
+ * **which is being claimed in the same transaction**.
20
+ *
21
+ * The contract will set itself as the fee payer but not end setup phase - this is done by the Fee Juice
22
+ * contract after enqueuing a public call, which unlike most public calls is whitelisted by the nodes
23
+ * to be executable during the setup phase.
24
+ */ AccountFeePaymentMethodOptions[AccountFeePaymentMethodOptions["FEE_JUICE_WITH_CLAIM"] = 2] = "FEE_JUICE_WITH_CLAIM";
25
+ return AccountFeePaymentMethodOptions;
26
+ }({});
6
27
  /**
7
28
  * Implementation for an entrypoint interface that follows the default entrypoint signature
8
29
  * for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
9
30
  */ export class DefaultAccountEntrypoint {
10
31
  address;
11
32
  auth;
12
- chainId;
13
- version;
14
- constructor(address, auth, chainId = DEFAULT_CHAIN_ID, version = DEFAULT_VERSION){
33
+ constructor(address, auth){
15
34
  this.address = address;
16
35
  this.auth = auth;
17
- this.chainId = chainId;
18
- this.version = version;
19
36
  }
20
- async createTxExecutionRequest(exec, fee, options) {
21
- // Initial request with calls, authWitnesses and capsules
22
- const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
23
- // Global tx options
24
- const { cancellable, txNonce } = options;
25
- // 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
34
- const abi = this.getEntrypointAbi();
35
- const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [
36
- appEncodedCalls,
37
- feeEncodedCalls,
38
- !!cancellable
39
- ]));
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));
42
- // Assemble the tx request
37
+ async createTxExecutionRequest(exec, gasSettings, chainInfo, options) {
38
+ const { authWitnesses, capsules, extraHashedArgs } = exec;
39
+ const callData = await this.#buildEntrypointCallData(exec, options);
40
+ const entrypointHashedArgs = await HashedValues.fromArgs(callData.encodedArgs);
43
41
  const txRequest = TxExecutionRequest.from({
44
42
  firstCallArgsHash: entrypointHashedArgs.hash,
45
43
  origin: this.address,
46
- functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
47
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
44
+ functionSelector: callData.functionSelector,
45
+ txContext: new TxContext(chainInfo.chainId.toNumber(), chainInfo.version.toNumber(), gasSettings),
48
46
  argsOfCalls: [
49
- ...appEncodedCalls.hashedArguments,
50
- ...feeEncodedCalls.hashedArguments,
47
+ ...callData.encodedCalls.hashedArguments,
51
48
  entrypointHashedArgs,
52
49
  ...extraHashedArgs
53
50
  ],
54
51
  authWitnesses: [
55
52
  ...authWitnesses,
56
- ...feeAuthwitnesses,
57
- combinedPayloadAuthWitness
53
+ callData.payloadAuthWitness
58
54
  ],
59
55
  capsules,
60
56
  salt: Fr.random()
61
57
  });
62
58
  return txRequest;
63
59
  }
60
+ async wrapExecutionPayload(exec, options) {
61
+ const { authWitnesses, capsules, extraHashedArgs, feePayer } = exec;
62
+ const callData = await this.#buildEntrypointCallData(exec, options);
63
+ // Build the entrypoint function call
64
+ const entrypointCall = FunctionCall.from({
65
+ name: callData.abi.name,
66
+ to: this.address,
67
+ selector: callData.functionSelector,
68
+ type: callData.abi.functionType,
69
+ hideMsgSender: false,
70
+ isStatic: callData.abi.isStatic,
71
+ args: callData.encodedArgs,
72
+ returnTypes: callData.abi.returnTypes
73
+ });
74
+ return new ExecutionPayload([
75
+ entrypointCall
76
+ ], [
77
+ callData.payloadAuthWitness,
78
+ ...authWitnesses
79
+ ], capsules, [
80
+ ...callData.encodedCalls.hashedArguments,
81
+ ...extraHashedArgs
82
+ ], feePayer ?? this.address);
83
+ }
84
+ /**
85
+ * Builds the shared data needed for both creating a tx execution request and wrapping an execution payload.
86
+ * This includes encoding calls, building entrypoint arguments, and creating the authwitness.
87
+ * @param exec - The execution payload containing calls to encode
88
+ * @param options - Account entrypoint options including tx nonce and fee payment method
89
+ * @returns Encoded call data, ABI, function selector, and auth witness
90
+ */ async #buildEntrypointCallData(exec, options) {
91
+ const { calls } = exec;
92
+ const { cancellable, txNonce, feePaymentMethodOptions } = options;
93
+ const encodedCalls = await EncodedAppEntrypointCalls.create(calls, txNonce);
94
+ const abi = this.getEntrypointAbi();
95
+ const args = [
96
+ encodedCalls,
97
+ feePaymentMethodOptions,
98
+ !!cancellable
99
+ ];
100
+ const encodedArgs = encodeArguments(abi, args);
101
+ const functionSelector = await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters);
102
+ const payloadAuthWitness = await this.auth.createAuthWit(await encodedCalls.hash());
103
+ return {
104
+ encodedCalls,
105
+ abi,
106
+ encodedArgs,
107
+ functionSelector,
108
+ payloadAuthWitness
109
+ };
110
+ }
64
111
  getEntrypointAbi() {
65
112
  return {
66
113
  name: 'entrypoint',
67
114
  isInitializer: false,
68
115
  functionType: 'private',
69
- isInternal: false,
116
+ isOnlySelf: false,
70
117
  isStatic: false,
71
118
  parameters: [
72
119
  {
@@ -79,7 +126,7 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
79
126
  name: 'function_calls',
80
127
  type: {
81
128
  kind: 'array',
82
- length: 4,
129
+ length: 5,
83
130
  type: {
84
131
  kind: 'struct',
85
132
  path: 'authwit::entrypoint::function_call::FunctionCall',
@@ -129,80 +176,7 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
129
176
  }
130
177
  },
131
178
  {
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',
179
+ name: 'hide_msg_sender',
206
180
  type: {
207
181
  kind: 'boolean'
208
182
  }
@@ -222,17 +196,19 @@ import { EncodedCallsForEntrypoint, computeCombinedPayloadHash } from './encodin
222
196
  type: {
223
197
  kind: 'field'
224
198
  }
225
- },
226
- {
227
- name: 'is_fee_payer',
228
- type: {
229
- kind: 'boolean'
230
- }
231
199
  }
232
200
  ]
233
201
  },
234
202
  visibility: 'public'
235
203
  },
204
+ {
205
+ name: 'fee_payment_method',
206
+ type: {
207
+ kind: 'integer',
208
+ sign: 'unsigned',
209
+ width: 8
210
+ }
211
+ },
236
212
  {
237
213
  name: 'cancellable',
238
214
  type: {
@@ -2,4 +2,4 @@
2
2
  export declare const DEFAULT_CHAIN_ID = 31337;
3
3
  /** Default protocol version to use. */
4
4
  export declare const DEFAULT_VERSION = 1;
5
- //# sourceMappingURL=constants.d.ts.map
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDhGQUE4RjtBQUM5RixlQUFPLE1BQU0sZ0JBQWdCLFFBQVEsQ0FBQztBQUN0Qyx1Q0FBdUM7QUFDdkMsZUFBTyxNQUFNLGVBQWUsSUFBSSxDQUFDIn0=
@@ -1,13 +1,11 @@
1
- import { TxExecutionRequest } from '@aztec/stdlib/tx';
2
- import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from './interfaces.js';
3
- import type { ExecutionPayload } from './payload.js';
1
+ import type { GasSettings } from '@aztec/stdlib/gas';
2
+ import { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
3
+ import type { ChainInfo, EntrypointInterface } from './interfaces.js';
4
4
  /**
5
5
  * Default implementation of the entrypoint interface. It calls a function on a contract directly
6
6
  */
7
7
  export declare class DefaultEntrypoint implements EntrypointInterface {
8
- private chainId;
9
- private rollupVersion;
10
- constructor(chainId: number, rollupVersion: number);
11
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
8
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, chainInfo: ChainInfo): Promise<TxExecutionRequest>;
9
+ wrapExecutionPayload(exec: ExecutionPayload, _options?: any): Promise<ExecutionPayload>;
12
10
  }
13
- //# sourceMappingURL=default_entrypoint.d.ts.map
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmYXVsdF9lbnRyeXBvaW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZGVmYXVsdF9lbnRyeXBvaW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3JELE9BQU8sRUFBRSxnQkFBZ0IsRUFBMkIsa0JBQWtCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUVqRyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUV0RTs7R0FFRztBQUNILHFCQUFhLGlCQUFrQixZQUFXLG1CQUFtQjtJQUNyRCx3QkFBd0IsQ0FDNUIsSUFBSSxFQUFFLGdCQUFnQixFQUN0QixXQUFXLEVBQUUsV0FBVyxFQUN4QixTQUFTLEVBQUUsU0FBUyxHQUNuQixPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0EyQjdCO0lBRUssb0JBQW9CLENBQUMsSUFBSSxFQUFFLGdCQUFnQixFQUFFLFFBQVEsQ0FBQyxFQUFFLEdBQUcsR0FBRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FnQjVGO0NBQ0YifQ==
@@ -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,EAAE,gBAAgB,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,qBAAa,iBAAkB,YAAW,mBAAmB;IACrD,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,kBAAkB,CAAC,CA2B7B;IAEK,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgB5F;CACF"}
@@ -1,18 +1,9 @@
1
1
  import { FunctionType } from '@aztec/stdlib/abi';
2
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
2
+ import { ExecutionPayload, HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
3
3
  /**
4
4
  * Default implementation of the entrypoint interface. It calls a function on a contract directly
5
5
  */ export class DefaultEntrypoint {
6
- chainId;
7
- rollupVersion;
8
- constructor(chainId, rollupVersion){
9
- this.chainId = chainId;
10
- this.rollupVersion = rollupVersion;
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
- }
6
+ async createTxExecutionRequest(exec, gasSettings, chainInfo) {
16
7
  // Initial request with calls, authWitnesses and capsules
17
8
  const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
18
9
  if (calls.length > 1) {
@@ -27,9 +18,22 @@ import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
27
18
  throw new Error('Public entrypoints are not allowed');
28
19
  }
29
20
  // Assemble the tx request
30
- return new TxExecutionRequest(call.to, call.selector, hashedArguments[0].hash, new TxContext(this.chainId, this.rollupVersion, fee.gasSettings), [
21
+ return new TxExecutionRequest(call.to, call.selector, hashedArguments[0].hash, new TxContext(chainInfo.chainId.toNumber(), chainInfo.version.toNumber(), gasSettings), [
31
22
  ...hashedArguments,
32
23
  ...extraHashedArgs
33
24
  ], authWitnesses, capsules);
34
25
  }
26
+ async wrapExecutionPayload(exec, _options) {
27
+ if (exec.calls.length !== 1) {
28
+ throw new Error(`DefaultEntrypoint can only wrap a single call, got ${exec.calls.length}`);
29
+ }
30
+ const call = exec.calls[0];
31
+ const hashedArguments = await HashedValues.fromArgs(call.args);
32
+ return new ExecutionPayload([
33
+ call
34
+ ], exec.authWitnesses, exec.capsules, [
35
+ hashedArguments,
36
+ ...exec.extraHashedArgs
37
+ ], exec.feePayer);
38
+ }
35
39
  }
@@ -1,16 +1,16 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import { TxExecutionRequest } from '@aztec/stdlib/tx';
3
- import type { EntrypointInterface, FeeOptions } from './interfaces.js';
4
- import type { ExecutionPayload } from './payload.js';
2
+ import type { GasSettings } from '@aztec/stdlib/gas';
3
+ import { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
4
+ import type { ChainInfo, EntrypointInterface } from './interfaces.js';
5
5
  /**
6
6
  * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
7
7
  */
8
8
  export declare class DefaultMultiCallEntrypoint implements EntrypointInterface {
9
- private chainId;
10
- private version;
9
+ #private;
11
10
  private address;
12
- constructor(chainId: number, version: number, address?: AztecAddress);
13
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions): Promise<TxExecutionRequest>;
11
+ constructor(address?: AztecAddress);
12
+ createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, chainInfo: ChainInfo): Promise<TxExecutionRequest>;
13
+ wrapExecutionPayload(exec: ExecutionPayload, _options?: any): Promise<ExecutionPayload>;
14
14
  private getEntrypointAbi;
15
15
  }
16
- //# sourceMappingURL=default_multi_call_entrypoint.d.ts.map
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmYXVsdF9tdWx0aV9jYWxsX2VudHJ5cG9pbnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9kZWZhdWx0X211bHRpX2NhbGxfZW50cnlwb2ludC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNyRCxPQUFPLEVBQUUsZ0JBQWdCLEVBQTJCLGtCQUFrQixFQUFF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AE,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,EAAE,gBAAgB,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGjG,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;;IACxD,OAAO,CAAC,OAAO;IAA3B,YAAoB,OAAO,GAAE,YAA0D,EAAI;IAErF,wBAAwB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,kBAAkB,CAAC,CAiB7B;IAEK,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqB5F;IA0BD,OAAO,CAAC,gBAAgB;CAyDzB"}
@@ -1,59 +1,81 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
- import { FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
4
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
5
- import { EncodedCallsForEntrypoint } from './encoding.js';
3
+ import { FunctionCall, FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
4
+ import { ExecutionPayload, HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
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 {
9
- chainId;
10
- version;
11
9
  address;
12
- constructor(chainId, version, address = ProtocolContractAddress.MultiCallEntrypoint){
13
- this.chainId = chainId;
14
- this.version = version;
10
+ constructor(address = ProtocolContractAddress.MultiCallEntrypoint){
15
11
  this.address = address;
16
12
  }
17
- async createTxExecutionRequest(exec, fee) {
18
- // Initial request with calls, authWitnesses and capsules
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));
25
- // Obtain the entrypoint hashed args, built from the encoded calls
26
- const abi = this.getEntrypointAbi();
27
- const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [
28
- encodedCalls
29
- ]));
30
- // Assemble the tx request
13
+ async createTxExecutionRequest(exec, gasSettings, chainInfo) {
14
+ const { authWitnesses, capsules, extraHashedArgs } = exec;
15
+ const callData = await this.#buildEntrypointCallData(exec);
16
+ const entrypointHashedArgs = await HashedValues.fromArgs(callData.encodedArgs);
31
17
  const txRequest = TxExecutionRequest.from({
32
18
  firstCallArgsHash: entrypointHashedArgs.hash,
33
19
  origin: this.address,
34
- functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
35
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
20
+ functionSelector: callData.functionSelector,
21
+ txContext: new TxContext(chainInfo.chainId.toNumber(), chainInfo.version.toNumber(), gasSettings),
36
22
  argsOfCalls: [
37
- ...encodedCalls.hashedArguments,
23
+ ...callData.encodedCalls.hashedArguments,
38
24
  entrypointHashedArgs,
39
- ...extraHashedArgs,
40
- ...feeExtraHashedArgs
41
- ],
42
- authWitnesses: [
43
- ...feeAuthwitnesses,
44
- ...authWitnesses
25
+ ...extraHashedArgs
45
26
  ],
27
+ authWitnesses,
46
28
  capsules,
47
29
  salt: Fr.random()
48
30
  });
49
31
  return Promise.resolve(txRequest);
50
32
  }
33
+ async wrapExecutionPayload(exec, _options) {
34
+ const { authWitnesses, capsules, extraHashedArgs } = exec;
35
+ const callData = await this.#buildEntrypointCallData(exec);
36
+ const entrypointCall = FunctionCall.from({
37
+ name: callData.abi.name,
38
+ to: this.address,
39
+ selector: callData.functionSelector,
40
+ type: callData.abi.functionType,
41
+ hideMsgSender: false,
42
+ isStatic: callData.abi.isStatic,
43
+ args: callData.encodedArgs,
44
+ returnTypes: callData.abi.returnTypes
45
+ });
46
+ return new ExecutionPayload([
47
+ entrypointCall
48
+ ], authWitnesses, capsules, [
49
+ ...callData.encodedCalls.hashedArguments,
50
+ ...extraHashedArgs
51
+ ], exec.feePayer);
52
+ }
53
+ /**
54
+ * Builds the shared data needed for both creating a tx execution request and wrapping an execution payload.
55
+ * This includes encoding calls and building entrypoint arguments.
56
+ * @param exec - The execution payload containing calls to encode
57
+ * @returns Encoded call data, ABI, encoded arguments, and function selector
58
+ */ async #buildEntrypointCallData(exec) {
59
+ const { calls } = exec;
60
+ const encodedCalls = await EncodedAppEntrypointCalls.create(calls);
61
+ const abi = this.getEntrypointAbi();
62
+ const encodedArgs = encodeArguments(abi, [
63
+ encodedCalls
64
+ ]);
65
+ const functionSelector = await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters);
66
+ return {
67
+ encodedCalls,
68
+ abi,
69
+ encodedArgs,
70
+ functionSelector
71
+ };
72
+ }
51
73
  getEntrypointAbi() {
52
74
  return {
53
75
  name: 'entrypoint',
54
76
  isInitializer: false,
55
77
  functionType: 'private',
56
- isInternal: false,
78
+ isOnlySelf: false,
57
79
  isStatic: false,
58
80
  parameters: [
59
81
  {
@@ -66,7 +88,7 @@ import { EncodedCallsForEntrypoint } from './encoding.js';
66
88
  name: 'function_calls',
67
89
  type: {
68
90
  kind: 'array',
69
- length: 4,
91
+ length: 5,
70
92
  type: {
71
93
  kind: 'struct',
72
94
  path: 'authwit::entrypoint::function_call::FunctionCall',
@@ -115,6 +137,12 @@ import { EncodedCallsForEntrypoint } from './encoding.js';
115
137
  kind: 'boolean'
116
138
  }
117
139
  },
140
+ {
141
+ name: 'hide_msg_sender',
142
+ type: {
143
+ kind: 'boolean'
144
+ }
145
+ },
118
146
  {
119
147
  name: 'is_static',
120
148
  type: {