@aztec/aztec.js 0.41.0 → 0.42.0
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/index.d.ts +2 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +7 -5
- package/dest/account_manager/index.d.ts +1 -1
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +2 -1
- package/dest/api/abi.d.ts +2 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/abi.js +1 -1
- package/dest/api/fee.d.ts +2 -0
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +3 -1
- package/dest/contract/base_contract_interaction.d.ts +7 -6
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +20 -9
- package/dest/contract/batch_call.d.ts +11 -0
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +50 -2
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +14 -10
- package/dest/contract/deploy_method.d.ts +5 -1
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +22 -6
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/get_gas_limits.d.ts.map +1 -1
- package/dest/contract/get_gas_limits.js +5 -3
- package/dest/contract/sent_tx.js +2 -2
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_entrypoint.js +6 -2
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +4 -4
- package/dest/entrypoint/payload.d.ts +24 -9
- package/dest/entrypoint/payload.d.ts.map +1 -1
- package/dest/entrypoint/payload.js +50 -29
- package/dest/fee/fee_payment_method.d.ts +6 -7
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.d.ts +5 -25
- package/dest/fee/native_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.js +9 -46
- package/dest/fee/native_fee_payment_method_with_claim.d.ts +17 -0
- package/dest/fee/native_fee_payment_method_with_claim.d.ts.map +1 -0
- package/dest/fee/native_fee_payment_method_with_claim.js +32 -0
- package/dest/fee/no_fee_payment_method.d.ts +13 -0
- package/dest/fee/no_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/no_fee_payment_method.js +17 -0
- package/dest/fee/private_fee_payment_method.d.ts +1 -5
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +13 -14
- package/dest/fee/public_fee_payment_method.d.ts +1 -5
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +13 -14
- package/dest/index.d.ts +11 -12
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +10 -11
- package/dest/rpc_clients/pxe_client.js +3 -3
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +2 -6
- package/dest/utils/cheat_codes.js +3 -3
- package/dest/wallet/base_wallet.d.ts +6 -1
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +7 -1
- package/dest/wallet/signerless_wallet.js +7 -7
- package/package.json +7 -7
- package/src/account/index.ts +2 -2
- package/src/account_manager/deploy_account_method.ts +10 -3
- package/src/account_manager/index.ts +5 -1
- package/src/api/abi.ts +2 -2
- package/src/api/fee.ts +2 -0
- package/src/contract/base_contract_interaction.ts +32 -8
- package/src/contract/batch_call.ts +77 -1
- package/src/contract/contract_function_interaction.ts +20 -10
- package/src/contract/deploy_method.ts +23 -6
- package/src/contract/get_gas_limits.ts +4 -3
- package/src/contract/sent_tx.ts +1 -1
- package/src/entrypoint/default_entrypoint.ts +7 -1
- package/src/entrypoint/default_multi_call_entrypoint.ts +3 -3
- package/src/entrypoint/payload.ts +58 -26
- package/src/fee/fee_payment_method.ts +6 -8
- package/src/fee/native_fee_payment_method.ts +8 -47
- package/src/fee/native_fee_payment_method_with_claim.ts +33 -0
- package/src/fee/no_fee_payment_method.ts +23 -0
- package/src/fee/private_fee_payment_method.ts +13 -17
- package/src/fee/public_fee_payment_method.ts +13 -18
- package/src/index.ts +34 -33
- package/src/rpc_clients/pxe_client.ts +2 -2
- package/src/utils/authwit.ts +1 -5
- package/src/utils/cheat_codes.ts +3 -3
- package/src/wallet/base_wallet.ts +8 -0
- package/src/wallet/signerless_wallet.ts +6 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr, type GasSettings, GeneratorIndex } from '@aztec/circuits.js';
|
|
1
|
+
import { FunctionCall, PackedValues } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, Fr, type GasSettings, GeneratorIndex } from '@aztec/circuits.js';
|
|
3
|
+
import { FunctionType } from '@aztec/foundation/abi';
|
|
3
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
5
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
5
6
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
@@ -39,13 +40,13 @@ type EncodedFunctionCall = {
|
|
|
39
40
|
/* eslint-enable camelcase */
|
|
40
41
|
|
|
41
42
|
/** Assembles an entrypoint payload */
|
|
42
|
-
export class EntrypointPayload {
|
|
43
|
+
export abstract class EntrypointPayload {
|
|
43
44
|
#packedArguments: PackedValues[] = [];
|
|
44
45
|
#functionCalls: EncodedFunctionCall[] = [];
|
|
45
46
|
#nonce = Fr.random();
|
|
46
47
|
#generatorIndex: number;
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
protected constructor(functionCalls: FunctionCall[], generatorIndex: number) {
|
|
49
50
|
for (const call of functionCalls) {
|
|
50
51
|
this.#packedArguments.push(PackedValues.fromValues(call.args));
|
|
51
52
|
}
|
|
@@ -53,9 +54,9 @@ export class EntrypointPayload {
|
|
|
53
54
|
/* eslint-disable camelcase */
|
|
54
55
|
this.#functionCalls = functionCalls.map((call, index) => ({
|
|
55
56
|
args_hash: this.#packedArguments[index].hash,
|
|
56
|
-
function_selector: call.
|
|
57
|
+
function_selector: call.selector.toField(),
|
|
57
58
|
target_address: call.to.toField(),
|
|
58
|
-
is_public:
|
|
59
|
+
is_public: call.type == FunctionType.PUBLIC,
|
|
59
60
|
is_static: call.isStatic,
|
|
60
61
|
}));
|
|
61
62
|
/* eslint-enable camelcase */
|
|
@@ -92,18 +93,7 @@ export class EntrypointPayload {
|
|
|
92
93
|
* Serializes the payload to an array of fields
|
|
93
94
|
* @returns The fields of the payload
|
|
94
95
|
*/
|
|
95
|
-
toFields(): Fr[]
|
|
96
|
-
return [
|
|
97
|
-
...this.#functionCalls.flatMap(call => [
|
|
98
|
-
call.args_hash,
|
|
99
|
-
call.function_selector,
|
|
100
|
-
call.target_address,
|
|
101
|
-
new Fr(call.is_public),
|
|
102
|
-
new Fr(call.is_static),
|
|
103
|
-
]),
|
|
104
|
-
this.#nonce,
|
|
105
|
-
];
|
|
106
|
-
}
|
|
96
|
+
abstract toFields(): Fr[];
|
|
107
97
|
|
|
108
98
|
/**
|
|
109
99
|
* Hashes the payload
|
|
@@ -113,13 +103,24 @@ export class EntrypointPayload {
|
|
|
113
103
|
return pedersenHash(this.toFields(), this.#generatorIndex);
|
|
114
104
|
}
|
|
115
105
|
|
|
106
|
+
/** Serializes the function calls to an array of fields. */
|
|
107
|
+
protected functionCallsToFields() {
|
|
108
|
+
return this.#functionCalls.flatMap(call => [
|
|
109
|
+
call.args_hash,
|
|
110
|
+
call.function_selector,
|
|
111
|
+
call.target_address,
|
|
112
|
+
new Fr(call.is_public),
|
|
113
|
+
new Fr(call.is_static),
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
|
|
116
117
|
/**
|
|
117
|
-
* Creates an execution payload from a set of function calls
|
|
118
|
+
* Creates an execution payload for a dapp from a set of function calls
|
|
118
119
|
* @param functionCalls - The function calls to execute
|
|
119
120
|
* @returns The execution payload
|
|
120
121
|
*/
|
|
121
122
|
static fromFunctionCalls(functionCalls: FunctionCall[]) {
|
|
122
|
-
return new
|
|
123
|
+
return new AppEntrypointPayload(functionCalls, 0);
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
/**
|
|
@@ -131,18 +132,49 @@ export class EntrypointPayload {
|
|
|
131
132
|
if (functionCalls.length > APP_MAX_CALLS) {
|
|
132
133
|
throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
|
|
133
134
|
}
|
|
134
|
-
const paddedCalls = padArrayEnd(functionCalls,
|
|
135
|
-
return new
|
|
135
|
+
const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), APP_MAX_CALLS);
|
|
136
|
+
return new AppEntrypointPayload(paddedCalls, GeneratorIndex.SIGNATURE_PAYLOAD);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
/**
|
|
139
140
|
* Creates an execution payload to pay the fee for a transaction
|
|
141
|
+
* @param sender - The address sending this payload
|
|
140
142
|
* @param feeOpts - The fee payment options
|
|
141
143
|
* @returns The execution payload
|
|
142
144
|
*/
|
|
143
|
-
static async fromFeeOptions(feeOpts?: FeeOptions) {
|
|
144
|
-
const calls =
|
|
145
|
-
const
|
|
146
|
-
|
|
145
|
+
static async fromFeeOptions(sender: AztecAddress, feeOpts?: FeeOptions) {
|
|
146
|
+
const calls = (await feeOpts?.paymentMethod.getFunctionCalls(feeOpts?.gasSettings)) ?? [];
|
|
147
|
+
const feePayer = await feeOpts?.paymentMethod.getFeePayer(feeOpts?.gasSettings);
|
|
148
|
+
const isFeePayer = !!feePayer && feePayer.equals(sender);
|
|
149
|
+
const paddedCalls = padArrayEnd(calls, FunctionCall.empty(), FEE_MAX_CALLS);
|
|
150
|
+
return new FeeEntrypointPayload(paddedCalls, GeneratorIndex.FEE_PAYLOAD, isFeePayer);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Entrypoint payload for app phase execution. */
|
|
155
|
+
class AppEntrypointPayload extends EntrypointPayload {
|
|
156
|
+
override toFields(): Fr[] {
|
|
157
|
+
return [...this.functionCallsToFields(), this.nonce];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Entrypoint payload for fee payment to be run during setup phase. */
|
|
162
|
+
class FeeEntrypointPayload extends EntrypointPayload {
|
|
163
|
+
#isFeePayer: boolean;
|
|
164
|
+
|
|
165
|
+
constructor(functionCalls: FunctionCall[], generatorIndex: number, isFeePayer: boolean) {
|
|
166
|
+
super(functionCalls, generatorIndex);
|
|
167
|
+
this.#isFeePayer = isFeePayer;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
override toFields(): Fr[] {
|
|
171
|
+
return [...this.functionCallsToFields(), this.nonce, new Fr(this.#isFeePayer)];
|
|
147
172
|
}
|
|
173
|
+
|
|
174
|
+
/* eslint-disable camelcase */
|
|
175
|
+
/** Whether the sender should be appointed as fee payer. */
|
|
176
|
+
get is_fee_payer() {
|
|
177
|
+
return this.#isFeePayer;
|
|
178
|
+
}
|
|
179
|
+
/* eslint-enable camelcase */
|
|
148
180
|
}
|
|
@@ -6,19 +6,17 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
|
6
6
|
* Holds information about how the fee for a transaction is to be paid.
|
|
7
7
|
*/
|
|
8
8
|
export interface FeePaymentMethod {
|
|
9
|
-
/**
|
|
10
|
-
* The asset used to pay the fee.
|
|
11
|
-
*/
|
|
9
|
+
/** The asset used to pay the fee. */
|
|
12
10
|
getAsset(): AztecAddress;
|
|
13
|
-
/**
|
|
14
|
-
* Address which will hold the fee payment.
|
|
15
|
-
*/
|
|
16
|
-
getPaymentContract(): AztecAddress;
|
|
17
|
-
|
|
18
11
|
/**
|
|
19
12
|
* Creates a function call to pay the fee in the given asset.
|
|
20
13
|
* @param gasSettings - The gas limits and max fees.
|
|
21
14
|
* @returns The function call to pay the fee.
|
|
22
15
|
*/
|
|
23
16
|
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
|
|
17
|
+
/**
|
|
18
|
+
* The expected fee payer for this tx.
|
|
19
|
+
* @param gasSettings - The gas limits and max fees.
|
|
20
|
+
*/
|
|
21
|
+
getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
|
|
24
22
|
}
|
|
@@ -1,63 +1,24 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import { type AztecAddress
|
|
3
|
-
import {
|
|
4
|
-
import { getCanonicalGasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
2
|
+
import { type AztecAddress } from '@aztec/circuits.js';
|
|
3
|
+
import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
5
4
|
|
|
6
|
-
import { type Wallet } from '../account/wallet.js';
|
|
7
5
|
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Pay fee directly in the native gas token.
|
|
11
9
|
*/
|
|
12
10
|
export class NativeFeePaymentMethod implements FeePaymentMethod {
|
|
13
|
-
|
|
11
|
+
constructor(protected sender: AztecAddress) {}
|
|
14
12
|
|
|
15
|
-
private constructor(canonicalGasTokenAddress: AztecAddress) {
|
|
16
|
-
this.#gasTokenAddress = canonicalGasTokenAddress;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static async create(wallet: Wallet): Promise<NativeFeePaymentMethod> {
|
|
20
|
-
const nodeInfo = await wallet.getNodeInfo();
|
|
21
|
-
return new NativeFeePaymentMethod(getCanonicalGasTokenAddress(nodeInfo.l1ContractAddresses.gasPortalAddress));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Gets the native gas asset used to pay the fee.
|
|
26
|
-
* @returns The asset used to pay the fee.
|
|
27
|
-
*/
|
|
28
13
|
getAsset() {
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The contract responsible for fee payment. This will be the same as the asset.
|
|
34
|
-
* @returns The contract address responsible for holding the fee payment.
|
|
35
|
-
*/
|
|
36
|
-
getPaymentContract() {
|
|
37
|
-
return this.#gasTokenAddress;
|
|
14
|
+
return GasTokenAddress;
|
|
38
15
|
}
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* @returns false
|
|
43
|
-
*/
|
|
44
|
-
isPrivateFeePayment(): boolean {
|
|
45
|
-
return false;
|
|
17
|
+
getFunctionCalls(): Promise<FunctionCall[]> {
|
|
18
|
+
return Promise.resolve([]);
|
|
46
19
|
}
|
|
47
20
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* @param gasSettings - The gas settings.
|
|
51
|
-
* @returns A function call
|
|
52
|
-
*/
|
|
53
|
-
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
54
|
-
return Promise.resolve([
|
|
55
|
-
{
|
|
56
|
-
to: this.#gasTokenAddress,
|
|
57
|
-
functionData: new FunctionData(FunctionSelector.fromSignature('pay_fee(Field)'), /*isPrivate=*/ false),
|
|
58
|
-
isStatic: false,
|
|
59
|
-
args: [gasSettings.getFeeLimit()],
|
|
60
|
-
},
|
|
61
|
-
]);
|
|
21
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
22
|
+
return Promise.resolve(this.sender);
|
|
62
23
|
}
|
|
63
24
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js';
|
|
3
|
+
import { FunctionType } from '@aztec/foundation/abi';
|
|
4
|
+
import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
5
|
+
|
|
6
|
+
import { NativeFeePaymentMethod } from './native_fee_payment_method.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pay fee directly with native gas token claimed on the same tx.
|
|
10
|
+
*/
|
|
11
|
+
export class NativeFeePaymentMethodWithClaim extends NativeFeePaymentMethod {
|
|
12
|
+
constructor(sender: AztecAddress, private claimAmount: bigint | Fr, private claimSecret: Fr) {
|
|
13
|
+
super(sender);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a function call to pay the fee in gas token.
|
|
18
|
+
* @returns A function call
|
|
19
|
+
*/
|
|
20
|
+
override getFunctionCalls(): Promise<FunctionCall[]> {
|
|
21
|
+
return Promise.resolve([
|
|
22
|
+
{
|
|
23
|
+
to: GasTokenAddress,
|
|
24
|
+
name: 'claim',
|
|
25
|
+
selector: FunctionSelector.fromSignature('claim((Field),Field,Field)'),
|
|
26
|
+
isStatic: false,
|
|
27
|
+
args: [this.sender, new Fr(this.claimAmount), this.claimSecret],
|
|
28
|
+
returnTypes: [],
|
|
29
|
+
type: FunctionType.PRIVATE,
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
+
import { AztecAddress } from '@aztec/circuits.js';
|
|
3
|
+
|
|
4
|
+
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Does not pay fees. Will work until we enforce fee payment for all txs.
|
|
8
|
+
*/
|
|
9
|
+
export class NoFeePaymentMethod implements FeePaymentMethod {
|
|
10
|
+
constructor() {}
|
|
11
|
+
|
|
12
|
+
getAsset() {
|
|
13
|
+
return AztecAddress.ZERO;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getFunctionCalls(): Promise<FunctionCall[]> {
|
|
17
|
+
return Promise.resolve([]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
21
|
+
return Promise.resolve(AztecAddress.ZERO);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
2
|
+
import { type GasSettings } from '@aztec/circuits.js';
|
|
3
3
|
import { computeSecretHash } from '@aztec/circuits.js/hash';
|
|
4
|
-
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
|
+
import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
|
|
5
5
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
6
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
7
7
|
|
|
@@ -43,12 +43,8 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
43
43
|
return this.asset;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @returns The contract address responsible for holding the fee payment.
|
|
49
|
-
*/
|
|
50
|
-
getPaymentContract() {
|
|
51
|
-
return this.paymentContract;
|
|
46
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
47
|
+
return Promise.resolve(this.paymentContract);
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
/**
|
|
@@ -64,13 +60,13 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
64
60
|
this.wallet.getChainId(),
|
|
65
61
|
this.wallet.getVersion(),
|
|
66
62
|
{
|
|
63
|
+
name: 'unshield',
|
|
67
64
|
args: [this.wallet.getCompleteAddress().address, this.paymentContract, maxFee, nonce],
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/*isPrivate=*/ true,
|
|
71
|
-
),
|
|
65
|
+
selector: FunctionSelector.fromSignature('unshield((Field),(Field),Field,Field)'),
|
|
66
|
+
type: FunctionType.PRIVATE,
|
|
72
67
|
isStatic: false,
|
|
73
68
|
to: this.asset,
|
|
69
|
+
returnTypes: [],
|
|
74
70
|
},
|
|
75
71
|
);
|
|
76
72
|
await this.wallet.createAuthWit(messageHash);
|
|
@@ -79,13 +75,13 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
79
75
|
|
|
80
76
|
return [
|
|
81
77
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
),
|
|
78
|
+
name: 'fee_entrypoint_private',
|
|
79
|
+
to: this.paymentContract,
|
|
80
|
+
selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field),Field,Field)'),
|
|
81
|
+
type: FunctionType.PRIVATE,
|
|
87
82
|
isStatic: false,
|
|
88
83
|
args: [maxFee, this.asset, secretHashForRebate, nonce],
|
|
84
|
+
returnTypes: [],
|
|
89
85
|
},
|
|
90
86
|
];
|
|
91
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
3
|
-
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
2
|
+
import { type GasSettings } from '@aztec/circuits.js';
|
|
3
|
+
import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
|
|
4
4
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
@@ -21,7 +21,6 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
21
21
|
* Address which will hold the fee payment.
|
|
22
22
|
*/
|
|
23
23
|
protected paymentContract: AztecAddress,
|
|
24
|
-
|
|
25
24
|
/**
|
|
26
25
|
* An auth witness provider to authorize fee payments
|
|
27
26
|
*/
|
|
@@ -36,12 +35,8 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
36
35
|
return this.asset;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* @returns The contract address responsible for holding the fee payment.
|
|
42
|
-
*/
|
|
43
|
-
getPaymentContract() {
|
|
44
|
-
return this.paymentContract;
|
|
38
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
39
|
+
return Promise.resolve(this.paymentContract);
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
/**
|
|
@@ -57,26 +52,26 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
57
52
|
this.wallet.getChainId(),
|
|
58
53
|
this.wallet.getVersion(),
|
|
59
54
|
{
|
|
55
|
+
name: 'transfer_public',
|
|
60
56
|
args: [this.wallet.getAddress(), this.paymentContract, maxFee, nonce],
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/*isPrivate=*/ false,
|
|
64
|
-
),
|
|
57
|
+
selector: FunctionSelector.fromSignature('transfer_public((Field),(Field),Field,Field)'),
|
|
58
|
+
type: FunctionType.PUBLIC,
|
|
65
59
|
isStatic: false,
|
|
66
60
|
to: this.asset,
|
|
61
|
+
returnTypes: [],
|
|
67
62
|
},
|
|
68
63
|
);
|
|
69
64
|
|
|
70
65
|
return Promise.resolve([
|
|
71
66
|
this.wallet.setPublicAuthWit(messageHash, true).request(),
|
|
72
67
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
),
|
|
68
|
+
name: 'fee_entrypoint_public',
|
|
69
|
+
to: this.paymentContract,
|
|
70
|
+
selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,(Field),Field)'),
|
|
71
|
+
type: FunctionType.PRIVATE,
|
|
78
72
|
isStatic: false,
|
|
79
73
|
args: [maxFee, this.asset, nonce],
|
|
74
|
+
returnTypes: [],
|
|
80
75
|
},
|
|
81
76
|
]);
|
|
82
77
|
}
|
package/src/index.ts
CHANGED
|
@@ -20,35 +20,36 @@
|
|
|
20
20
|
* TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
|
|
21
21
|
*/
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
ContractFunctionInteraction,
|
|
23
|
+
BatchCall,
|
|
25
24
|
Contract,
|
|
26
25
|
ContractBase,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ContractNotes,
|
|
30
|
-
|
|
31
|
-
BatchCall,
|
|
26
|
+
ContractFunctionInteraction,
|
|
27
|
+
type ContractMethod,
|
|
28
|
+
type ContractNotes,
|
|
29
|
+
type ContractStorageLayout,
|
|
32
30
|
DeployMethod,
|
|
33
31
|
DeploySentTx,
|
|
32
|
+
type SendMethodOptions,
|
|
33
|
+
SentTx,
|
|
34
|
+
type WaitOpts,
|
|
34
35
|
} from './contract/index.js';
|
|
35
36
|
|
|
36
37
|
export { ContractDeployer } from './deployment/index.js';
|
|
37
38
|
|
|
38
39
|
export {
|
|
39
|
-
generatePublicKey,
|
|
40
|
-
FieldLike,
|
|
41
|
-
EthAddressLike,
|
|
42
|
-
CheatCodes,
|
|
43
40
|
AztecAddressLike,
|
|
41
|
+
CheatCodes,
|
|
42
|
+
EthAddressLike,
|
|
43
|
+
EthCheatCodes,
|
|
44
|
+
FieldLike,
|
|
44
45
|
FunctionSelectorLike,
|
|
45
46
|
WrappedFieldLike,
|
|
46
|
-
EthCheatCodes,
|
|
47
47
|
computeAuthWitMessageHash,
|
|
48
48
|
computeInnerAuthWitHash,
|
|
49
49
|
computeOuterAuthWitHash,
|
|
50
|
-
|
|
50
|
+
generatePublicKey,
|
|
51
51
|
waitForAccountSynch,
|
|
52
|
+
waitForPXE,
|
|
52
53
|
} from './utils/index.js';
|
|
53
54
|
|
|
54
55
|
export { createPXEClient } from './rpc_clients/index.js';
|
|
@@ -58,21 +59,21 @@ export { AuthWitnessProvider } from './account/index.js';
|
|
|
58
59
|
export { AccountContract } from './account/index.js';
|
|
59
60
|
export { AccountManager } from './account_manager/index.js';
|
|
60
61
|
|
|
61
|
-
export { AccountWalletWithSecretKey,
|
|
62
|
+
export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, Wallet } from './wallet/index.js';
|
|
62
63
|
|
|
63
64
|
// // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
|
|
64
65
|
// // here once the issue is resolved.
|
|
65
66
|
export {
|
|
66
67
|
AztecAddress,
|
|
67
68
|
EthAddress,
|
|
68
|
-
Fr,
|
|
69
69
|
Fq,
|
|
70
|
+
Fr,
|
|
70
71
|
GlobalVariables,
|
|
71
72
|
GrumpkinScalar,
|
|
73
|
+
INITIAL_L2_BLOCK_NUM,
|
|
72
74
|
Point,
|
|
73
|
-
getContractInstanceFromDeployParams, // TODO(@spalladino) This method should be used from within the DeployMethod but not exposed in aztec.js
|
|
74
75
|
getContractClassFromArtifact,
|
|
75
|
-
|
|
76
|
+
getContractInstanceFromDeployParams,
|
|
76
77
|
} from '@aztec/circuits.js';
|
|
77
78
|
|
|
78
79
|
export { computeSecretHash } from '@aztec/circuits.js/hash';
|
|
@@ -90,17 +91,21 @@ export {
|
|
|
90
91
|
AuthWitness,
|
|
91
92
|
AztecNode,
|
|
92
93
|
Body,
|
|
94
|
+
Comparator,
|
|
93
95
|
CompleteAddress,
|
|
96
|
+
EncryptedL2BlockL2Logs,
|
|
97
|
+
EncryptedLogHeader,
|
|
98
|
+
EncryptedLogIncomingBody,
|
|
99
|
+
EncryptedLogOutgoingBody,
|
|
94
100
|
ExtendedNote,
|
|
95
|
-
|
|
101
|
+
FunctionCall,
|
|
96
102
|
GrumpkinPrivateKey,
|
|
97
|
-
L1ToL2Message,
|
|
98
103
|
L1Actor,
|
|
104
|
+
L1ToL2Message,
|
|
99
105
|
L2Actor,
|
|
100
106
|
L2Block,
|
|
101
107
|
L2BlockL2Logs,
|
|
102
|
-
|
|
103
|
-
UnencryptedL2BlockL2Logs,
|
|
108
|
+
EncryptedNoteL2BlockL2Logs,
|
|
104
109
|
LogFilter,
|
|
105
110
|
LogId,
|
|
106
111
|
LogType,
|
|
@@ -110,41 +115,37 @@ export {
|
|
|
110
115
|
PackedValues,
|
|
111
116
|
PartialAddress,
|
|
112
117
|
PublicKey,
|
|
118
|
+
SiblingPath,
|
|
113
119
|
SyncStatus,
|
|
114
120
|
Tx,
|
|
115
121
|
TxExecutionRequest,
|
|
116
122
|
TxHash,
|
|
117
123
|
TxReceipt,
|
|
118
124
|
TxStatus,
|
|
125
|
+
UnencryptedL2BlockL2Logs,
|
|
119
126
|
UnencryptedL2Log,
|
|
120
127
|
createAztecNodeClient,
|
|
121
|
-
emptyFunctionCall,
|
|
122
128
|
merkleTreeIds,
|
|
123
129
|
mockTx,
|
|
124
|
-
Comparator,
|
|
125
|
-
SiblingPath,
|
|
126
|
-
EncryptedLogHeader,
|
|
127
|
-
EncryptedLogIncomingBody,
|
|
128
|
-
EncryptedLogOutgoingBody,
|
|
129
130
|
} from '@aztec/circuit-types';
|
|
130
131
|
export { NodeInfo } from '@aztec/types/interfaces';
|
|
131
132
|
|
|
132
|
-
export {
|
|
133
|
+
export { ContractClassWithId, ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
133
134
|
|
|
134
135
|
// TODO: These kinds of things have no place on our public api.
|
|
135
136
|
// External devs will almost certainly have their own methods of doing these things.
|
|
136
137
|
// If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
|
|
137
138
|
export { encodeArguments } from '@aztec/foundation/abi';
|
|
139
|
+
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
138
140
|
export { sha256 } from '@aztec/foundation/crypto';
|
|
141
|
+
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
139
142
|
export { DebugLogger, createDebugLogger, onLog } from '@aztec/foundation/log';
|
|
140
143
|
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
144
|
+
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
141
145
|
export { sleep } from '@aztec/foundation/sleep';
|
|
142
146
|
export { elapsed } from '@aztec/foundation/timer';
|
|
143
|
-
export { fileURLToPath } from '@aztec/foundation/url';
|
|
144
|
-
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
145
|
-
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
146
|
-
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
147
147
|
export { FieldsOf } from '@aztec/foundation/types';
|
|
148
|
+
export { fileURLToPath } from '@aztec/foundation/url';
|
|
148
149
|
|
|
149
150
|
export {
|
|
150
151
|
DeployL1Contracts,
|
|
@@ -156,6 +157,6 @@ export {
|
|
|
156
157
|
// Start of section that exports public api via granular api.
|
|
157
158
|
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|
|
158
159
|
// This entire index file will be deprecated at some point after we're satisfied.
|
|
159
|
-
export * from './api/init.js';
|
|
160
160
|
export * from './api/abi.js';
|
|
161
161
|
export * from './api/fee.js';
|
|
162
|
+
export * from './api/init.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthWitness,
|
|
3
|
-
|
|
3
|
+
EncryptedNoteL2BlockL2Logs,
|
|
4
4
|
ExtendedNote,
|
|
5
5
|
ExtendedUnencryptedL2Log,
|
|
6
6
|
L2Block,
|
|
@@ -54,7 +54,7 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false)
|
|
|
54
54
|
TxExecutionRequest,
|
|
55
55
|
TxHash,
|
|
56
56
|
},
|
|
57
|
-
{ Tx, SimulatedTx, TxReceipt,
|
|
57
|
+
{ Tx, SimulatedTx, TxReceipt, EncryptedNoteL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness },
|
|
58
58
|
false,
|
|
59
59
|
'pxe',
|
|
60
60
|
fetch,
|
package/src/utils/authwit.ts
CHANGED
|
@@ -22,11 +22,7 @@ export const computeAuthWitMessageHash = (caller: AztecAddress, chainId: Fr, ver
|
|
|
22
22
|
action.to.toField(),
|
|
23
23
|
chainId,
|
|
24
24
|
version,
|
|
25
|
-
computeInnerAuthWitHash([
|
|
26
|
-
caller.toField(),
|
|
27
|
-
action.functionData.selector.toField(),
|
|
28
|
-
PackedValues.fromValues(action.args).hash,
|
|
29
|
-
]),
|
|
25
|
+
computeInnerAuthWitHash([caller.toField(), action.selector.toField(), PackedValues.fromValues(action.args).hash]),
|
|
30
26
|
);
|
|
31
27
|
};
|
|
32
28
|
// docs:end:authwit_computeAuthWitMessageHash
|
package/src/utils/cheat_codes.ts
CHANGED
|
@@ -265,11 +265,11 @@ export class AztecCheatCodes {
|
|
|
265
265
|
public async warp(to: number): Promise<void> {
|
|
266
266
|
const rollupContract = (await this.pxe.getNodeInfo()).l1ContractAddresses.rollupAddress;
|
|
267
267
|
await this.eth.setNextBlockTimestamp(to);
|
|
268
|
-
// also store this time on the rollup contract (slot
|
|
268
|
+
// also store this time on the rollup contract (slot 2 tracks `lastBlockTs`).
|
|
269
269
|
// This is because when the sequencer executes public functions, it uses the timestamp stored in the rollup contract.
|
|
270
|
-
await this.eth.store(rollupContract, 1n, BigInt(to));
|
|
271
|
-
// also store this on slot 2 of the rollup contract (`lastWarpedBlockTs`) which tracks the last time warp was used.
|
|
272
270
|
await this.eth.store(rollupContract, 2n, BigInt(to));
|
|
271
|
+
// also store this on slot 3 of the rollup contract (`lastWarpedBlockTs`) which tracks the last time warp was used.
|
|
272
|
+
await this.eth.store(rollupContract, 3n, BigInt(to));
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
/**
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type LogFilter,
|
|
8
8
|
type NoteFilter,
|
|
9
9
|
type PXE,
|
|
10
|
+
type PXEInfo,
|
|
10
11
|
type SimulatedTx,
|
|
11
12
|
type SyncStatus,
|
|
12
13
|
type Tx,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
type TxHash,
|
|
16
17
|
type TxReceipt,
|
|
17
18
|
} from '@aztec/circuit-types';
|
|
19
|
+
import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
|
|
18
20
|
import { type AztecAddress, type CompleteAddress, type Fq, type Fr, type PartialAddress } from '@aztec/circuits.js';
|
|
19
21
|
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
20
22
|
import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
@@ -158,6 +160,9 @@ export abstract class BaseWallet implements Wallet {
|
|
|
158
160
|
getSyncStatus(): Promise<SyncStatus> {
|
|
159
161
|
return this.pxe.getSyncStatus();
|
|
160
162
|
}
|
|
163
|
+
getSyncStats(): Promise<{ [key: string]: NoteProcessorStats }> {
|
|
164
|
+
return this.pxe.getSyncStats();
|
|
165
|
+
}
|
|
161
166
|
addAuthWitness(authWitness: AuthWitness) {
|
|
162
167
|
return this.pxe.addAuthWitness(authWitness);
|
|
163
168
|
}
|
|
@@ -170,4 +175,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
170
175
|
isContractPubliclyDeployed(address: AztecAddress): Promise<boolean> {
|
|
171
176
|
return this.pxe.isContractPubliclyDeployed(address);
|
|
172
177
|
}
|
|
178
|
+
getPXEInfo(): Promise<PXEInfo> {
|
|
179
|
+
return this.pxe.getPXEInfo();
|
|
180
|
+
}
|
|
173
181
|
}
|