@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.
- package/dest/account_entrypoint.d.ts +49 -8
- package/dest/account_entrypoint.d.ts.map +1 -1
- package/dest/account_entrypoint.js +97 -121
- package/dest/constants.d.ts +1 -1
- package/dest/default_entrypoint.d.ts +6 -8
- package/dest/default_entrypoint.d.ts.map +1 -1
- package/dest/default_entrypoint.js +16 -12
- package/dest/default_multi_call_entrypoint.d.ts +8 -8
- package/dest/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/default_multi_call_entrypoint.js +62 -34
- package/dest/encoding.d.ts +10 -43
- package/dest/encoding.d.ts.map +1 -1
- package/dest/encoding.js +22 -70
- package/dest/index.d.ts +1 -1
- package/dest/interfaces.d.ts +40 -60
- package/dest/interfaces.d.ts.map +1 -1
- package/dest/interfaces.js +8 -2
- package/package.json +11 -9
- package/src/account_entrypoint.ts +120 -93
- package/src/default_entrypoint.ts +24 -14
- package/src/default_multi_call_entrypoint.ts +69 -36
- package/src/encoding.ts +16 -102
- package/src/interfaces.ts +37 -65
- package/dest/payload.d.ts +0 -32
- package/dest/payload.d.ts.map +0 -1
- package/dest/payload.js +0 -27
- package/src/payload.ts +0 -35
package/dest/encoding.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
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 =
|
|
6
|
-
declare const FEE_MAX_CALLS = 2;
|
|
5
|
+
export 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,13 +31,13 @@ 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
|
|
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 */
|
|
37
38
|
hashedArguments: HashedValues[];
|
|
38
39
|
/** The index of the generator to use for hashing */
|
|
39
|
-
|
|
40
|
+
domainSeparator: number;
|
|
40
41
|
/**
|
|
41
42
|
* A nonce to inject into the payload of the transaction. When used with cancellable=true, this nonce will be
|
|
42
43
|
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
@@ -49,7 +50,7 @@ export declare abstract class EncodedCallsForEntrypoint implements EncodedCalls
|
|
|
49
50
|
/** The hashed args for the call, ready to be injected in the execution cache */
|
|
50
51
|
hashedArguments: HashedValues[],
|
|
51
52
|
/** The index of the generator to use for hashing */
|
|
52
|
-
|
|
53
|
+
domainSeparator: number,
|
|
53
54
|
/**
|
|
54
55
|
* A nonce to inject into the payload of the transaction. When used with cancellable=true, this nonce will be
|
|
55
56
|
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
@@ -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
|
-
|
|
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,36 +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
|
|
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
|
-
|
|
121
|
-
//# sourceMappingURL=encoding.d.ts.map
|
|
88
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2RpbmcuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9lbmNvZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0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DRSxnRUFBZ0U7SUFDekQsb0JBQW9CLEVBQUUsbUJBQW1CLEVBQUU7SUFDbEQsZ0ZBQWdGO0lBQ3pFLGVBQWUsRUFBRSxZQUFZLEVBQUU7SUFDdEMsb0RBQW9EO0lBQzdDLGVBQWUsRUFBRSxNQUFNO0lBQzlCOzs7O09BSUc7SUFFSSxRQUFRLEVBQUUsRUFBRSxFQUNqQjtJQUdKOzs7T0FHRztJQUNILElBQUksY0FBYywwQkFFakI7SUFHRDs7O09BR0c7SUFDSCxRQUFRLElBQUksRUFBRSxFQUFFLENBRWY7SUFFRDs7O09BR0c7SUFDSCxJQUFJLGdCQUVIO0lBRUQsMkRBQTJEO0lBQzNELFNBQVMsQ0FBQyxxQkFBcUIsU0FTOUI7SUFFRDs7Ozs7O09BTUc7SUFDSCxPQUFhLE1BQU0sQ0FDakIsYUFBYSxFQUFFLFlBQVksRUFBRSxHQUFHLEtBQUssQ0FBQyxZQUFZLEVBQUUsT0FBTyxhQUFhLENBQUMsRUFDekUsT0FBTyxLQUFjLHNDQWF0QjtDQUNGO0FBRUQsdUVBQXVFO0FBQ3ZFLHdCQUFzQixNQUFNLENBQUMsS0FBSyxFQUFFLFlBQVksRUFBRSxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0F3QnpFIn0=
|
package/dest/encoding.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,YAAY,EA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C,YAAY,EAAE,OAAO,aAAa,CAAC,EACzE,OAAO,KAAc,sCAatB;CACF;AAED,uEAAuE;AACvE,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAwBzE"}
|
package/dest/encoding.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomainSeparator } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
4
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
6
6
|
import { HashedValues } from '@aztec/stdlib/tx';
|
|
7
7
|
// These must match the values defined in:
|
|
8
8
|
// - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
|
|
9
|
-
const APP_MAX_CALLS =
|
|
10
|
-
// - and noir-projects/aztec-nr/aztec/src/entrypoint/fee.nr
|
|
11
|
-
const FEE_MAX_CALLS = 2;
|
|
9
|
+
export const APP_MAX_CALLS = 5;
|
|
12
10
|
/**
|
|
13
11
|
* Entrypoints derive their arguments from the calls that they'll ultimate make.
|
|
14
12
|
* This utility class helps in creating the payload for the entrypoint by taking into
|
|
15
13
|
* account how the calls are encoded and hashed.
|
|
16
|
-
* */ export class
|
|
14
|
+
* */ export class EncodedAppEntrypointCalls {
|
|
17
15
|
encodedFunctionCalls;
|
|
18
16
|
hashedArguments;
|
|
19
|
-
|
|
17
|
+
domainSeparator;
|
|
20
18
|
tx_nonce;
|
|
21
|
-
constructor(/** Function calls in the expected format (Noir's convention) */ encodedFunctionCalls, /** The hashed args for the call, ready to be injected in the execution cache */ hashedArguments, /** The index of the generator to use for hashing */
|
|
19
|
+
constructor(/** Function calls in the expected format (Noir's convention) */ encodedFunctionCalls, /** The hashed args for the call, ready to be injected in the execution cache */ hashedArguments, /** The index of the generator to use for hashing */ domainSeparator, /**
|
|
22
20
|
* A nonce to inject into the payload of the transaction. When used with cancellable=true, this nonce will be
|
|
23
21
|
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
24
22
|
* but higher fee. The nullifier ensures only one transaction can succeed.
|
|
@@ -26,7 +24,7 @@ const FEE_MAX_CALLS = 2;
|
|
|
26
24
|
tx_nonce){
|
|
27
25
|
this.encodedFunctionCalls = encodedFunctionCalls;
|
|
28
26
|
this.hashedArguments = hashedArguments;
|
|
29
|
-
this.
|
|
27
|
+
this.domainSeparator = domainSeparator;
|
|
30
28
|
this.tx_nonce = tx_nonce;
|
|
31
29
|
}
|
|
32
30
|
/* eslint-disable camelcase */ /**
|
|
@@ -35,11 +33,20 @@ 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
|
|
41
48
|
*/ hash() {
|
|
42
|
-
return poseidon2HashWithSeparator(this.toFields(), this.
|
|
49
|
+
return poseidon2HashWithSeparator(this.toFields(), this.domainSeparator);
|
|
43
50
|
}
|
|
44
51
|
/** Serializes the function calls to an array of fields. */ functionCallsToFields() {
|
|
45
52
|
return this.encodedFunctionCalls.flatMap((call)=>[
|
|
@@ -47,80 +54,24 @@ const FEE_MAX_CALLS = 2;
|
|
|
47
54
|
call.function_selector,
|
|
48
55
|
call.target_address,
|
|
49
56
|
new Fr(call.is_public),
|
|
57
|
+
new Fr(call.hide_msg_sender),
|
|
50
58
|
new Fr(call.is_static)
|
|
51
59
|
]);
|
|
52
60
|
}
|
|
53
61
|
/**
|
|
54
|
-
* Encodes a set of function calls for a dapp entrypoint
|
|
55
|
-
* @param functionCalls - The function calls to execute
|
|
56
|
-
* @returns The encoded calls
|
|
57
|
-
*/ static async fromFunctionCalls(functionCalls) {
|
|
58
|
-
const encoded = await encode(functionCalls);
|
|
59
|
-
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, 0, Fr.random());
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
62
|
* Encodes the functions for the app-portion of a transaction from a set of function calls and a nonce
|
|
63
63
|
* @param functionCalls - The function calls to execute
|
|
64
64
|
* @param txNonce - A nonce used to enable transaction cancellation when cancellable=true. Transactions with the same
|
|
65
65
|
* nonce can be replaced by submitting a new one with a higher fee.
|
|
66
66
|
* @returns The encoded calls
|
|
67
|
-
*/ static async
|
|
67
|
+
*/ static async create(functionCalls, txNonce = Fr.random()) {
|
|
68
68
|
if (functionCalls.length > APP_MAX_CALLS) {
|
|
69
69
|
throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
|
|
70
70
|
}
|
|
71
71
|
const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), APP_MAX_CALLS);
|
|
72
72
|
const encoded = await encode(paddedCalls);
|
|
73
|
-
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments,
|
|
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);
|
|
73
|
+
return new EncodedAppEntrypointCalls(encoded.encodedFunctionCalls, encoded.hashedArguments, DomainSeparator.SIGNATURE_PAYLOAD, txNonce);
|
|
89
74
|
}
|
|
90
|
-
toFields() {
|
|
91
|
-
return [
|
|
92
|
-
...this.functionCallsToFields(),
|
|
93
|
-
this.tx_nonce
|
|
94
|
-
];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/** Encoded calls for fee payment */ export class EncodedFeeEntrypointCalls extends EncodedCallsForEntrypoint {
|
|
98
|
-
#isFeePayer;
|
|
99
|
-
constructor(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce, isFeePayer){
|
|
100
|
-
super(encodedFunctionCalls, hashedArguments, generatorIndex, txNonce);
|
|
101
|
-
this.#isFeePayer = isFeePayer;
|
|
102
|
-
}
|
|
103
|
-
toFields() {
|
|
104
|
-
return [
|
|
105
|
-
...this.functionCallsToFields(),
|
|
106
|
-
this.tx_nonce,
|
|
107
|
-
new Fr(this.#isFeePayer)
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
|
-
/* eslint-disable camelcase */ /** Whether the sender should be appointed as fee payer. */ get is_fee_payer() {
|
|
111
|
-
return this.#isFeePayer;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Computes a hash of a combined set of app and fee calls.
|
|
116
|
-
* @param appCalls - A set of app calls.
|
|
117
|
-
* @param feeCalls - A set of calls used to pay fees.
|
|
118
|
-
* @returns A hash of a combined call set.
|
|
119
|
-
*/ export async function computeCombinedPayloadHash(appPayload, feePayload) {
|
|
120
|
-
return poseidon2HashWithSeparator([
|
|
121
|
-
await appPayload.hash(),
|
|
122
|
-
await feePayload.hash()
|
|
123
|
-
], GeneratorIndex.COMBINED_PAYLOAD);
|
|
124
75
|
}
|
|
125
76
|
/** Encodes FunctionCalls for execution, following Noir's convention */ export async function encode(calls) {
|
|
126
77
|
const hashedArguments = [];
|
|
@@ -136,6 +87,7 @@ const FEE_MAX_CALLS = 2;
|
|
|
136
87
|
function_selector: call.selector.toField(),
|
|
137
88
|
target_address: call.to.toField(),
|
|
138
89
|
is_public: call.type == FunctionType.PUBLIC,
|
|
90
|
+
hide_msg_sender: call.hideMsgSender,
|
|
139
91
|
is_static: call.isStatic
|
|
140
92
|
}));
|
|
141
93
|
return {
|
package/dest/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export * from './interfaces.js';
|
|
|
10
10
|
export * from './default_entrypoint.js';
|
|
11
11
|
export * from './encoding.js';
|
|
12
12
|
export * from './default_multi_call_entrypoint.js';
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxjQUFjLHlCQUF5QixDQUFDO0FBQ3hDLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLG9DQUFvQyxDQUFDIn0=
|
package/dest/interfaces.d.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
3
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
7
|
-
import
|
|
4
|
+
import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
|
+
import { z } from 'zod';
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
7
|
+
* Information on the connected chain. Used by wallets when constructing transactions to protect against replay
|
|
8
|
+
* attacks.
|
|
10
9
|
*/
|
|
11
|
-
export type
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
17
|
-
* but higher fee. The nullifier ensures only one transaction can succeed.
|
|
18
|
-
*/
|
|
19
|
-
txNonce?: Fr;
|
|
10
|
+
export type ChainInfo = {
|
|
11
|
+
/** The L1 chain id */
|
|
12
|
+
chainId: Fr;
|
|
13
|
+
/** The version of the rollup */
|
|
14
|
+
version: Fr;
|
|
20
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Zod schema for ChainInfo
|
|
18
|
+
*/
|
|
19
|
+
export declare const ChainInfoSchema: z.ZodObject<{
|
|
20
|
+
chainId: z.ZodType<Fr, any, string>;
|
|
21
|
+
version: z.ZodType<Fr, any, string>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
chainId: Fr;
|
|
24
|
+
version: Fr;
|
|
25
|
+
}, {
|
|
26
|
+
chainId: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}>;
|
|
21
29
|
/**
|
|
22
30
|
* Creates transaction execution requests out of a set of function calls, a fee payment method and
|
|
23
31
|
* general options for the transaction
|
|
@@ -26,11 +34,24 @@ export interface EntrypointInterface {
|
|
|
26
34
|
/**
|
|
27
35
|
* Generates an execution request out of set of function calls.
|
|
28
36
|
* @param exec - The execution intents to be run.
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
37
|
+
* @param gasSettings - The gas settings for the transaction.
|
|
38
|
+
* @param chainInfo - Chain information (chainId and version) for replay protection.
|
|
39
|
+
* @param options - Miscellaneous tx options that enable/disable features of the entrypoint
|
|
31
40
|
* @returns The authenticated transaction execution request.
|
|
32
41
|
*/
|
|
33
|
-
createTxExecutionRequest(exec: ExecutionPayload,
|
|
42
|
+
createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings, chainInfo: ChainInfo, options?: any): Promise<TxExecutionRequest>;
|
|
43
|
+
/**
|
|
44
|
+
* Wraps an execution payload such that it is executed *via* this entrypoint.
|
|
45
|
+
* This returns an ExecutionPayload with the entrypoint as the caller for the wrapped payload.
|
|
46
|
+
* Useful for account self-funding deployments and batching calls beyond the limit
|
|
47
|
+
* of a single entrypoint call.
|
|
48
|
+
*
|
|
49
|
+
* @param exec - The execution payload to wrap
|
|
50
|
+
* @param options - Implementation-specific options
|
|
51
|
+
* @returns A new execution payload with a single call to this entrypoint
|
|
52
|
+
* @throws Error if the payload cannot be wrapped (e.g., exceeds call limit)
|
|
53
|
+
*/
|
|
54
|
+
wrapExecutionPayload(exec: ExecutionPayload, options?: any): Promise<ExecutionPayload>;
|
|
34
55
|
}
|
|
35
56
|
/** Creates authorization witnesses. */
|
|
36
57
|
export interface AuthWitnessProvider {
|
|
@@ -41,45 +62,4 @@ export interface AuthWitnessProvider {
|
|
|
41
62
|
*/
|
|
42
63
|
createAuthWit(messageHash: Fr | Buffer): Promise<AuthWitness>;
|
|
43
64
|
}
|
|
44
|
-
|
|
45
|
-
* Holds information about how the fee for a transaction is to be paid.
|
|
46
|
-
*/
|
|
47
|
-
export interface FeePaymentMethod {
|
|
48
|
-
/** The asset used to pay the fee. */
|
|
49
|
-
getAsset(): Promise<AztecAddress>;
|
|
50
|
-
/**
|
|
51
|
-
* Returns the data to be added to the final execution request
|
|
52
|
-
* to pay the fee in the given asset
|
|
53
|
-
* @param gasSettings - The gas limits and max fees.
|
|
54
|
-
* @returns The function calls to pay the fee.
|
|
55
|
-
*/
|
|
56
|
-
getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
|
|
57
|
-
/**
|
|
58
|
-
* The expected fee payer for this tx.
|
|
59
|
-
* @param gasSettings - The gas limits and max fees.
|
|
60
|
-
*/
|
|
61
|
-
getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Fee payment options for a transaction.
|
|
65
|
-
*/
|
|
66
|
-
export type FeeOptions = {
|
|
67
|
-
/** The fee payment method to use */
|
|
68
|
-
paymentMethod: FeePaymentMethod;
|
|
69
|
-
/** The gas settings */
|
|
70
|
-
gasSettings: GasSettings;
|
|
71
|
-
};
|
|
72
|
-
/** Fee options as set by a user. */
|
|
73
|
-
export type UserFeeOptions = {
|
|
74
|
-
/** The fee payment method to use */
|
|
75
|
-
paymentMethod?: FeePaymentMethod;
|
|
76
|
-
/** The gas settings */
|
|
77
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
78
|
-
/** Percentage to pad the base fee by, if empty, defaults to 0.5 */
|
|
79
|
-
baseFeePadding?: number;
|
|
80
|
-
/** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
|
|
81
|
-
estimateGas?: boolean;
|
|
82
|
-
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
83
|
-
estimatedGasPadding?: number;
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=interfaces.d.ts.map
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL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xXQUFXLG1CQUFtQjtJQUNsQzs7OztPQUlHO0lBQ0gsYUFBYSxDQUFDLFdBQVcsRUFBRSxFQUFFLEdBQUcsTUFBTSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztDQUMvRCJ9
|
package/dest/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,sBAAsB;IACtB,OAAO,EAAE,EAAE,CAAC;IACZ,iCAAiC;IACjC,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;EAG1B,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,wBAAwB,CACtB,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE/B;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACxF;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/D"}
|
package/dest/interfaces.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for ChainInfo
|
|
5
|
+
*/ export const ChainInfoSchema = z.object({
|
|
6
|
+
chainId: Fr.schema,
|
|
7
|
+
version: Fr.schema
|
|
8
|
+
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@aztec/entrypoints",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/entrypoints",
|
|
4
4
|
"description": "Implementation of sample contract entrypoints for the Aztec Network",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.6-commit.a2d1860fe9",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./account": "./dest/account_entrypoint.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"tsconfig": "./tsconfig.json"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "yarn clean && tsc
|
|
24
|
-
"build:dev": "tsc
|
|
25
|
-
"build:ts": "tsc
|
|
23
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
24
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
25
|
+
"build:ts": "../scripts/tsc.sh",
|
|
26
26
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
27
27
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
28
28
|
},
|
|
@@ -67,15 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.
|
|
71
|
-
"@aztec/foundation": "0.0.
|
|
72
|
-
"@aztec/protocol-contracts": "0.0.
|
|
73
|
-
"@aztec/stdlib": "0.0.
|
|
74
|
-
"tslib": "^2.4.0"
|
|
70
|
+
"@aztec/constants": "0.0.6-commit.a2d1860fe9",
|
|
71
|
+
"@aztec/foundation": "0.0.6-commit.a2d1860fe9",
|
|
72
|
+
"@aztec/protocol-contracts": "0.0.6-commit.a2d1860fe9",
|
|
73
|
+
"@aztec/stdlib": "0.0.6-commit.a2d1860fe9",
|
|
74
|
+
"tslib": "^2.4.0",
|
|
75
|
+
"zod": "^3.23.8"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
78
|
"@jest/globals": "^30.0.0",
|
|
78
79
|
"@types/jest": "^30.0.0",
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
79
81
|
"jest": "^30.0.0",
|
|
80
82
|
"ts-node": "^10.9.1",
|
|
81
83
|
"typescript": "^5.3.3"
|