@aztec/entrypoints 3.0.0-nightly.20251003 → 3.0.0-nightly.20251004
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 +43 -2
- package/dest/account_entrypoint.d.ts.map +1 -1
- package/dest/account_entrypoint.js +30 -13
- package/dest/default_entrypoint.d.ts +2 -2
- package/dest/default_entrypoint.d.ts.map +1 -1
- package/dest/default_entrypoint.js +1 -4
- package/dest/interfaces.d.ts +9 -23
- package/dest/interfaces.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/account_entrypoint.ts +49 -8
- package/src/default_entrypoint.ts +2 -9
- package/src/interfaces.ts +9 -23
|
@@ -1,8 +1,49 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
1
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
3
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
3
4
|
import { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
4
|
-
import type { AuthWitnessProvider, EntrypointInterface
|
|
5
|
+
import type { AuthWitnessProvider, EntrypointInterface } from './interfaces.js';
|
|
5
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
|
+
};
|
|
6
47
|
/**
|
|
7
48
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
8
49
|
* for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
@@ -13,7 +54,7 @@ export declare class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
13
54
|
private chainId;
|
|
14
55
|
private version;
|
|
15
56
|
constructor(address: AztecAddress, auth: AuthWitnessProvider, chainId?: number, version?: number);
|
|
16
|
-
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options:
|
|
57
|
+
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options: DefaultAccountEntrypointOptions): Promise<TxExecutionRequest>;
|
|
17
58
|
private getEntrypointAbi;
|
|
18
59
|
}
|
|
19
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":"
|
|
1
|
+
{"version":3,"file":"account_entrypoint.d.ts","sourceRoot":"","sources":["../src/account_entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,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;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;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;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,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,kBAAkB,CAAC;IAgC9B,OAAO,CAAC,gBAAgB;CA0DzB"}
|
|
@@ -3,6 +3,28 @@ 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
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
|
|
@@ -21,18 +43,17 @@ import { EncodedAppEntrypointCalls } from './encoding.js';
|
|
|
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,
|
|
46
|
+
const { cancellable, txNonce, feePaymentMethodOptions } = options;
|
|
25
47
|
// Encode the calls for the app
|
|
26
48
|
const encodedCalls = await EncodedAppEntrypointCalls.create(calls, txNonce);
|
|
27
|
-
// Obtain the entrypoint hashed args, built from the app and
|
|
49
|
+
// Obtain the entrypoint hashed args, built from the app encoded calls and global options
|
|
28
50
|
const abi = this.getEntrypointAbi();
|
|
29
51
|
const entrypointHashedArgs = await HashedValues.fromArgs(encodeArguments(abi, [
|
|
30
52
|
encodedCalls,
|
|
31
|
-
|
|
32
|
-
!!endSetup,
|
|
53
|
+
feePaymentMethodOptions,
|
|
33
54
|
!!cancellable
|
|
34
55
|
]));
|
|
35
|
-
// Generate the
|
|
56
|
+
// Generate the payload auth witness, by signing the hash of the payload
|
|
36
57
|
const appPayloadAuthwitness = await this.auth.createAuthWit(await encodedCalls.hash());
|
|
37
58
|
// Assemble the tx request
|
|
38
59
|
const txRequest = TxExecutionRequest.from({
|
|
@@ -142,15 +163,11 @@ import { EncodedAppEntrypointCalls } from './encoding.js';
|
|
|
142
163
|
visibility: 'public'
|
|
143
164
|
},
|
|
144
165
|
{
|
|
145
|
-
name: '
|
|
166
|
+
name: 'fee_payment_method',
|
|
146
167
|
type: {
|
|
147
|
-
kind: '
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
name: 'end_setup',
|
|
152
|
-
type: {
|
|
153
|
-
kind: 'boolean'
|
|
168
|
+
kind: 'integer',
|
|
169
|
+
sign: 'unsigned',
|
|
170
|
+
width: 8
|
|
154
171
|
}
|
|
155
172
|
},
|
|
156
173
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
2
2
|
import { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
3
|
-
import type { EntrypointInterface
|
|
3
|
+
import type { EntrypointInterface } from './interfaces.js';
|
|
4
4
|
import type { ExecutionPayload } from './payload.js';
|
|
5
5
|
/**
|
|
6
6
|
* Default implementation of the entrypoint interface. It calls a function on a contract directly
|
|
@@ -9,6 +9,6 @@ export declare class DefaultEntrypoint implements EntrypointInterface {
|
|
|
9
9
|
private chainId;
|
|
10
10
|
private rollupVersion;
|
|
11
11
|
constructor(chainId: number, rollupVersion: number);
|
|
12
|
-
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings
|
|
12
|
+
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest>;
|
|
13
13
|
}
|
|
14
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,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,
|
|
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, gasSettings
|
|
13
|
-
if (options.txNonce || options.cancellable !== undefined || options.isFeePayer || options.endSetup) {
|
|
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) {
|
package/dest/interfaces.d.ts
CHANGED
|
@@ -4,28 +4,14 @@ import type { GasSettings } from '@aztec/stdlib/gas';
|
|
|
4
4
|
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
5
|
import type { ExecutionPayload } from './payload.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Information on the connected chain. Used by wallets when constructing transactions to protect against replay
|
|
8
|
+
* attacks.
|
|
8
9
|
*/
|
|
9
|
-
export type
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
15
|
-
* but higher fee. The nullifier ensures only one transaction can succeed.
|
|
16
|
-
*/
|
|
17
|
-
txNonce?: Fr;
|
|
18
|
-
/**
|
|
19
|
-
* Account contracts usually support paying transaction fees using their own fee juice balance, which is configured
|
|
20
|
-
* by setting this flag to true.
|
|
21
|
-
*/
|
|
22
|
-
isFeePayer: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* When paying transactions with fee juice, the account contract itself usually has to signal the end of the setup phase since
|
|
25
|
-
* no other contract will do it. This is configurable independently of the previous flag because in the case of using
|
|
26
|
-
* FeeJuiceWithClaim the account contract is the fee payer, but the end of the setup is handled by the FeeJuice contract.
|
|
27
|
-
*/
|
|
28
|
-
endSetup: boolean;
|
|
10
|
+
export type ChainInfo = {
|
|
11
|
+
/** The L1 chain id */
|
|
12
|
+
chainId: Fr;
|
|
13
|
+
/** The version of the rollup */
|
|
14
|
+
version: Fr;
|
|
29
15
|
};
|
|
30
16
|
/**
|
|
31
17
|
* Creates transaction execution requests out of a set of function calls, a fee payment method and
|
|
@@ -36,10 +22,10 @@ export interface EntrypointInterface {
|
|
|
36
22
|
* Generates an execution request out of set of function calls.
|
|
37
23
|
* @param exec - The execution intents to be run.
|
|
38
24
|
* @param gasSettings - The gas settings for the transaction.
|
|
39
|
-
* @param options - Miscellaneous tx options that enable/disable features of the
|
|
25
|
+
* @param options - Miscellaneous tx options that enable/disable features of the entrypoint
|
|
40
26
|
* @returns The authenticated transaction execution request.
|
|
41
27
|
*/
|
|
42
|
-
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options
|
|
28
|
+
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, options?: any): Promise<TxExecutionRequest>;
|
|
43
29
|
}
|
|
44
30
|
/** Creates authorization witnesses. */
|
|
45
31
|
export interface AuthWitnessProvider {
|
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,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD
|
|
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,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,sBAAsB;IACtB,OAAO,EAAE,EAAE,CAAC;IACZ,iCAAiC;IACjC,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF;;;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/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": "3.0.0-nightly.
|
|
5
|
+
"version": "3.0.0-nightly.20251004",
|
|
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": "3.0.0-nightly.
|
|
71
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
72
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
73
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
70
|
+
"@aztec/constants": "3.0.0-nightly.20251004",
|
|
71
|
+
"@aztec/foundation": "3.0.0-nightly.20251004",
|
|
72
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251004",
|
|
73
|
+
"@aztec/stdlib": "3.0.0-nightly.20251004",
|
|
74
74
|
"tslib": "^2.4.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
@@ -6,9 +6,51 @@ import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
|
6
6
|
|
|
7
7
|
import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
|
|
8
8
|
import { EncodedAppEntrypointCalls } from './encoding.js';
|
|
9
|
-
import type { AuthWitnessProvider, EntrypointInterface
|
|
9
|
+
import type { AuthWitnessProvider, EntrypointInterface } from './interfaces.js';
|
|
10
10
|
import { ExecutionPayload } from './payload.js';
|
|
11
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
|
+
|
|
12
54
|
/**
|
|
13
55
|
* Implementation for an entrypoint interface that follows the default entrypoint signature
|
|
14
56
|
* for an account, which accepts an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
@@ -24,22 +66,22 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
24
66
|
async createTxExecutionRequest(
|
|
25
67
|
exec: ExecutionPayload,
|
|
26
68
|
gasSettings: GasSettings,
|
|
27
|
-
options:
|
|
69
|
+
options: DefaultAccountEntrypointOptions,
|
|
28
70
|
): Promise<TxExecutionRequest> {
|
|
29
71
|
// Initial request with calls, authWitnesses and capsules
|
|
30
72
|
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
31
73
|
// Global tx options
|
|
32
|
-
const { cancellable, txNonce,
|
|
74
|
+
const { cancellable, txNonce, feePaymentMethodOptions } = options;
|
|
33
75
|
// Encode the calls for the app
|
|
34
76
|
const encodedCalls = await EncodedAppEntrypointCalls.create(calls, txNonce);
|
|
35
77
|
|
|
36
|
-
// 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
|
|
37
79
|
const abi = this.getEntrypointAbi();
|
|
38
80
|
const entrypointHashedArgs = await HashedValues.fromArgs(
|
|
39
|
-
encodeArguments(abi, [encodedCalls,
|
|
81
|
+
encodeArguments(abi, [encodedCalls, feePaymentMethodOptions, !!cancellable]),
|
|
40
82
|
);
|
|
41
83
|
|
|
42
|
-
// Generate the
|
|
84
|
+
// Generate the payload auth witness, by signing the hash of the payload
|
|
43
85
|
const appPayloadAuthwitness = await this.auth.createAuthWit(await encodedCalls.hash());
|
|
44
86
|
|
|
45
87
|
// Assemble the tx request
|
|
@@ -108,8 +150,7 @@ export class DefaultAccountEntrypoint implements EntrypointInterface {
|
|
|
108
150
|
},
|
|
109
151
|
visibility: 'public',
|
|
110
152
|
},
|
|
111
|
-
{ name: '
|
|
112
|
-
{ name: 'end_setup', type: { kind: 'boolean' } },
|
|
153
|
+
{ name: 'fee_payment_method', type: { kind: 'integer', sign: 'unsigned', width: 8 } },
|
|
113
154
|
{ name: 'cancellable', type: { kind: 'boolean' } },
|
|
114
155
|
],
|
|
115
156
|
returnTypes: [],
|
|
@@ -2,7 +2,7 @@ import { FunctionType } from '@aztec/stdlib/abi';
|
|
|
2
2
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
3
3
|
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
|
-
import type { EntrypointInterface
|
|
5
|
+
import type { EntrypointInterface } from './interfaces.js';
|
|
6
6
|
import type { ExecutionPayload } from './payload.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -14,14 +14,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
|
|
|
14
14
|
private rollupVersion: number,
|
|
15
15
|
) {}
|
|
16
16
|
|
|
17
|
-
async createTxExecutionRequest(
|
|
18
|
-
exec: ExecutionPayload,
|
|
19
|
-
gasSettings: GasSettings,
|
|
20
|
-
options: TxExecutionOptions,
|
|
21
|
-
): Promise<TxExecutionRequest> {
|
|
22
|
-
if (options.txNonce || options.cancellable !== undefined || options.isFeePayer || options.endSetup) {
|
|
23
|
-
throw new Error('TxExecutionOptions are not supported in DefaultEntrypoint');
|
|
24
|
-
}
|
|
17
|
+
async createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest> {
|
|
25
18
|
// Initial request with calls, authWitnesses and capsules
|
|
26
19
|
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
27
20
|
|
package/src/interfaces.ts
CHANGED
|
@@ -6,28 +6,14 @@ import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
|
6
6
|
import type { ExecutionPayload } from './payload.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Information on the connected chain. Used by wallets when constructing transactions to protect against replay
|
|
10
|
+
* attacks.
|
|
10
11
|
*/
|
|
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;
|
|
20
|
-
/**
|
|
21
|
-
* Account contracts usually support paying transaction fees using their own fee juice balance, which is configured
|
|
22
|
-
* by setting this flag to true.
|
|
23
|
-
*/
|
|
24
|
-
isFeePayer: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* When paying transactions with fee juice, the account contract itself usually has to signal the end of the setup phase since
|
|
27
|
-
* no other contract will do it. This is configurable independently of the previous flag because in the case of using
|
|
28
|
-
* FeeJuiceWithClaim the account contract is the fee payer, but the end of the setup is handled by the FeeJuice contract.
|
|
29
|
-
*/
|
|
30
|
-
endSetup: boolean;
|
|
12
|
+
export type ChainInfo = {
|
|
13
|
+
/** The L1 chain id */
|
|
14
|
+
chainId: Fr;
|
|
15
|
+
/** The version of the rollup */
|
|
16
|
+
version: Fr;
|
|
31
17
|
};
|
|
32
18
|
|
|
33
19
|
/**
|
|
@@ -39,13 +25,13 @@ export interface EntrypointInterface {
|
|
|
39
25
|
* Generates an execution request out of set of function calls.
|
|
40
26
|
* @param exec - The execution intents to be run.
|
|
41
27
|
* @param gasSettings - The gas settings for the transaction.
|
|
42
|
-
* @param options - Miscellaneous tx options that enable/disable features of the
|
|
28
|
+
* @param options - Miscellaneous tx options that enable/disable features of the entrypoint
|
|
43
29
|
* @returns The authenticated transaction execution request.
|
|
44
30
|
*/
|
|
45
31
|
createTxExecutionRequest(
|
|
46
32
|
exec: ExecutionPayload,
|
|
47
33
|
gasSettings: GasSettings,
|
|
48
|
-
options
|
|
34
|
+
options?: any,
|
|
49
35
|
): Promise<TxExecutionRequest>;
|
|
50
36
|
}
|
|
51
37
|
|