@aztec/aztec.js 0.33.0 → 0.35.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/contract.d.ts +6 -1
- package/dest/account/contract.d.ts.map +1 -1
- package/dest/account/contract.js +1 -1
- package/dest/account_manager/deploy_account_method.d.ts +15 -0
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -0
- package/dest/account_manager/deploy_account_method.js +43 -0
- package/dest/account_manager/deploy_account_sent_tx.d.ts +3 -3
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_sent_tx.js +7 -6
- package/dest/account_manager/index.d.ts +9 -3
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +21 -17
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +5 -2
- package/dest/contract/contract_function_interaction.d.ts +4 -4
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +9 -5
- package/dest/contract/deploy_method.d.ts +11 -4
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +33 -15
- package/dest/contract/deploy_sent_tx.js +2 -2
- package/dest/entrypoint/default_entrypoint.d.ts +3 -3
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_entrypoint.js +11 -7
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +15 -0
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/default_multi_call_entrypoint.js +85 -0
- package/dest/entrypoint/entrypoint.d.ts +17 -14
- package/dest/entrypoint/entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/entrypoint.js +5 -2
- package/dest/entrypoint/payload.d.ts +73 -0
- package/dest/entrypoint/payload.d.ts.map +1 -0
- package/dest/entrypoint/payload.js +109 -0
- package/dest/fee/fee_payment_method.d.ts +3 -4
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.d.ts +4 -5
- package/dest/fee/native_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.js +5 -5
- package/dest/fee/private_fee_payment_method.d.ts +3 -2
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +4 -3
- package/dest/fee/public_fee_payment_method.d.ts +3 -3
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +4 -3
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -2
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +3 -3
- package/dest/utils/cheat_codes.d.ts +4 -4
- package/dest/utils/cheat_codes.d.ts.map +1 -1
- package/dest/utils/cheat_codes.js +11 -11
- package/dest/utils/pxe.js +3 -3
- package/dest/wallet/account_wallet.d.ts +2 -2
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +3 -3
- package/dest/wallet/base_wallet.d.ts +2 -2
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.d.ts +3 -3
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +3 -3
- package/package.json +7 -7
- package/src/account/contract.ts +7 -1
- package/src/account_manager/deploy_account_method.ts +74 -0
- package/src/account_manager/deploy_account_sent_tx.ts +6 -5
- package/src/account_manager/index.ts +39 -23
- package/src/contract/batch_call.ts +4 -1
- package/src/contract/contract_function_interaction.ts +11 -7
- package/src/contract/deploy_method.ts +44 -22
- package/src/contract/deploy_sent_tx.ts +1 -1
- package/src/entrypoint/default_entrypoint.ts +18 -11
- package/src/entrypoint/default_multi_call_entrypoint.ts +89 -0
- package/src/entrypoint/entrypoint.ts +19 -14
- package/src/entrypoint/payload.ts +144 -0
- package/src/fee/fee_payment_method.ts +3 -4
- package/src/fee/native_fee_payment_method.ts +5 -6
- package/src/fee/private_fee_payment_method.ts +4 -3
- package/src/fee/public_fee_payment_method.ts +4 -4
- package/src/index.ts +2 -2
- package/src/utils/authwit.ts +2 -2
- package/src/utils/cheat_codes.ts +10 -10
- package/src/utils/pxe.ts +2 -2
- package/src/wallet/account_wallet.ts +3 -3
- package/src/wallet/base_wallet.ts +2 -2
- package/src/wallet/signerless_wallet.ts +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
+
import { type GasSettings } from '@aztec/circuits.js';
|
|
2
3
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
|
-
import { type Fr } from '@aztec/foundation/fields';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Holds information about how the fee for a transaction is to be paid.
|
|
@@ -17,9 +17,8 @@ export interface FeePaymentMethod {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates a function call to pay the fee in the given asset.
|
|
20
|
-
*
|
|
21
|
-
* @param maxFee - The maximum fee to be paid in the given asset.
|
|
20
|
+
* @param gasSettings - The gas limits and max fees.
|
|
22
21
|
* @returns The function call to pay the fee.
|
|
23
22
|
*/
|
|
24
|
-
getFunctionCalls(
|
|
23
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
|
|
25
24
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import { type AztecAddress, FunctionData } from '@aztec/circuits.js';
|
|
2
|
+
import { type AztecAddress, FunctionData, type GasSettings } from '@aztec/circuits.js';
|
|
3
3
|
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
|
-
import { type Fr } from '@aztec/foundation/fields';
|
|
5
4
|
import { getCanonicalGasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
6
5
|
|
|
7
6
|
import { type Wallet } from '../account/wallet.js';
|
|
@@ -47,16 +46,16 @@ export class NativeFeePaymentMethod implements FeePaymentMethod {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
/**
|
|
50
|
-
* Creates a function call to pay the fee in gas token
|
|
51
|
-
* @param
|
|
49
|
+
* Creates a function call to pay the fee in gas token.
|
|
50
|
+
* @param gasSettings - The gas settings.
|
|
52
51
|
* @returns A function call
|
|
53
52
|
*/
|
|
54
|
-
getFunctionCalls(
|
|
53
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
55
54
|
return Promise.resolve([
|
|
56
55
|
{
|
|
57
56
|
to: this.#gasTokenAddress,
|
|
58
57
|
functionData: new FunctionData(FunctionSelector.fromSignature('pay_fee(Field)'), false),
|
|
59
|
-
args: [
|
|
58
|
+
args: [gasSettings.getFeeLimit()],
|
|
60
59
|
},
|
|
61
60
|
]);
|
|
62
61
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import { FunctionData } from '@aztec/circuits.js';
|
|
2
|
+
import { FunctionData, type GasSettings } from '@aztec/circuits.js';
|
|
3
3
|
import { computeMessageSecretHash } from '@aztec/circuits.js/hash';
|
|
4
4
|
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
5
5
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
@@ -53,11 +53,12 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Creates a function call to pay the fee in the given asset.
|
|
56
|
-
* @param
|
|
56
|
+
* @param gasSettings - The gas settings.
|
|
57
57
|
* @returns The function call to pay the fee.
|
|
58
58
|
*/
|
|
59
|
-
async getFunctionCalls(
|
|
59
|
+
async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
60
60
|
const nonce = Fr.random();
|
|
61
|
+
const maxFee = gasSettings.getFeeLimit();
|
|
61
62
|
const messageHash = computeAuthWitMessageHash(
|
|
62
63
|
this.paymentContract,
|
|
63
64
|
this.wallet.getChainId(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import { FunctionData } from '@aztec/circuits.js';
|
|
2
|
+
import { FunctionData, type GasSettings } from '@aztec/circuits.js';
|
|
3
3
|
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
4
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -46,12 +46,12 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Creates a function call to pay the fee in the given asset.
|
|
49
|
-
* @param
|
|
49
|
+
* @param gasSettings - The gas settings.
|
|
50
50
|
* @returns The function call to pay the fee.
|
|
51
51
|
*/
|
|
52
|
-
getFunctionCalls(
|
|
52
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
53
53
|
const nonce = Fr.random();
|
|
54
|
-
|
|
54
|
+
const maxFee = gasSettings.getFeeLimit();
|
|
55
55
|
const messageHash = computeAuthWitMessageHash(
|
|
56
56
|
this.paymentContract,
|
|
57
57
|
this.wallet.getChainId(),
|
package/src/index.ts
CHANGED
|
@@ -85,7 +85,7 @@ export {
|
|
|
85
85
|
Body,
|
|
86
86
|
CompleteAddress,
|
|
87
87
|
ExtendedNote,
|
|
88
|
-
FunctionCall,
|
|
88
|
+
type FunctionCall,
|
|
89
89
|
GrumpkinPrivateKey,
|
|
90
90
|
L1ToL2Message,
|
|
91
91
|
L1Actor,
|
|
@@ -100,7 +100,7 @@ export {
|
|
|
100
100
|
MerkleTreeId,
|
|
101
101
|
Note,
|
|
102
102
|
PXE,
|
|
103
|
-
|
|
103
|
+
PackedValues,
|
|
104
104
|
PartialAddress,
|
|
105
105
|
PublicKey,
|
|
106
106
|
SyncStatus,
|
package/src/utils/authwit.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FunctionCall,
|
|
1
|
+
import { type FunctionCall, PackedValues } from '@aztec/circuit-types';
|
|
2
2
|
import { type AztecAddress, type Fr, GeneratorIndex } from '@aztec/circuits.js';
|
|
3
3
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ export const computeAuthWitMessageHash = (caller: AztecAddress, chainId: Fr, ver
|
|
|
25
25
|
computeInnerAuthWitHash([
|
|
26
26
|
caller.toField(),
|
|
27
27
|
action.functionData.selector.toField(),
|
|
28
|
-
|
|
28
|
+
PackedValues.fromValues(action.args).hash,
|
|
29
29
|
]),
|
|
30
30
|
);
|
|
31
31
|
};
|
package/src/utils/cheat_codes.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Note, type PXE } from '@aztec/circuit-types';
|
|
2
2
|
import { type AztecAddress, type EthAddress, Fr } from '@aztec/circuits.js';
|
|
3
3
|
import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
|
|
4
|
-
import {
|
|
4
|
+
import { keccak256, pedersenHash } from '@aztec/foundation/crypto';
|
|
5
5
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
6
6
|
|
|
7
7
|
import fs from 'fs';
|
|
@@ -90,7 +90,7 @@ export class EthCheatCodes {
|
|
|
90
90
|
if (res.error) {
|
|
91
91
|
throw new Error(`Error mining: ${res.error.message}`);
|
|
92
92
|
}
|
|
93
|
-
this.logger(`Mined ${numberOfBlocks} blocks`);
|
|
93
|
+
this.logger.info(`Mined ${numberOfBlocks} blocks`);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -102,7 +102,7 @@ export class EthCheatCodes {
|
|
|
102
102
|
if (res.error) {
|
|
103
103
|
throw new Error(`Error setting next block timestamp: ${res.error.message}`);
|
|
104
104
|
}
|
|
105
|
-
this.logger(`Set next block timestamp to ${timestamp}`);
|
|
105
|
+
this.logger.info(`Set next block timestamp to ${timestamp}`);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
@@ -116,7 +116,7 @@ export class EthCheatCodes {
|
|
|
116
116
|
}
|
|
117
117
|
const jsonContent = JSON.stringify(res.result);
|
|
118
118
|
fs.writeFileSync(`${fileName}.json`, jsonContent, 'utf8');
|
|
119
|
-
this.logger(`Dumped state to ${fileName}`);
|
|
119
|
+
this.logger.info(`Dumped state to ${fileName}`);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -129,7 +129,7 @@ export class EthCheatCodes {
|
|
|
129
129
|
if (res.error) {
|
|
130
130
|
throw new Error(`Error loading state: ${res.error.message}`);
|
|
131
131
|
}
|
|
132
|
-
this.logger(`Loaded state from ${fileName}`);
|
|
132
|
+
this.logger.info(`Loaded state from ${fileName}`);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -155,7 +155,7 @@ export class EthCheatCodes {
|
|
|
155
155
|
if (res.error) {
|
|
156
156
|
throw new Error(`Error setting storage for contract ${contract} at ${slot}: ${res.error.message}`);
|
|
157
157
|
}
|
|
158
|
-
this.logger(`Set storage for contract ${contract} at ${slot} to ${value}`);
|
|
158
|
+
this.logger.info(`Set storage for contract ${contract} at ${slot} to ${value}`);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
@@ -167,7 +167,7 @@ export class EthCheatCodes {
|
|
|
167
167
|
public keccak256(baseSlot: bigint, key: bigint): bigint {
|
|
168
168
|
// abi encode (removing the 0x) - concat key and baseSlot (both padded to 32 bytes)
|
|
169
169
|
const abiEncoded = toHex(key, true).substring(2) + toHex(baseSlot, true).substring(2);
|
|
170
|
-
return toBigIntBE(
|
|
170
|
+
return toBigIntBE(keccak256(Buffer.from(abiEncoded, 'hex')));
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
@@ -179,7 +179,7 @@ export class EthCheatCodes {
|
|
|
179
179
|
if (res.error) {
|
|
180
180
|
throw new Error(`Error impersonating ${who}: ${res.error.message}`);
|
|
181
181
|
}
|
|
182
|
-
this.logger(`Impersonating ${who}`);
|
|
182
|
+
this.logger.info(`Impersonating ${who}`);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
@@ -191,7 +191,7 @@ export class EthCheatCodes {
|
|
|
191
191
|
if (res.error) {
|
|
192
192
|
throw new Error(`Error when stopping the impersonation of ${who}: ${res.error.message}`);
|
|
193
193
|
}
|
|
194
|
-
this.logger(`Stopped impersonating ${who}`);
|
|
194
|
+
this.logger.info(`Stopped impersonating ${who}`);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
@@ -204,7 +204,7 @@ export class EthCheatCodes {
|
|
|
204
204
|
if (res.error) {
|
|
205
205
|
throw new Error(`Error setting bytecode for ${contract}: ${res.error.message}`);
|
|
206
206
|
}
|
|
207
|
-
this.logger(`Set bytecode for ${contract} to ${bytecode}`);
|
|
207
|
+
this.logger.info(`Set bytecode for ${contract} to ${bytecode}`);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
/**
|
package/src/utils/pxe.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { retryUntil } from '@aztec/foundation/retry';
|
|
|
5
5
|
export const waitForPXE = async (pxe: PXE, logger?: DebugLogger) => {
|
|
6
6
|
await retryUntil(async () => {
|
|
7
7
|
try {
|
|
8
|
-
logger?.('Attempting to contact PXE...');
|
|
8
|
+
logger?.debug('Attempting to contact PXE...');
|
|
9
9
|
await pxe.getNodeInfo();
|
|
10
10
|
return true;
|
|
11
11
|
} catch (error) {
|
|
12
|
-
logger?.('Failed to contact PXE
|
|
12
|
+
logger?.verbose('Failed to contact PXE');
|
|
13
13
|
}
|
|
14
14
|
return undefined;
|
|
15
15
|
}, 'RPC Get Node Info');
|
|
@@ -4,7 +4,7 @@ import { type ABIParameterVisibility, type FunctionAbi, FunctionType } from '@az
|
|
|
4
4
|
|
|
5
5
|
import { type AccountInterface } from '../account/interface.js';
|
|
6
6
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
7
|
-
import { type
|
|
7
|
+
import { type ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
8
8
|
import { computeAuthWitMessageHash } from '../utils/authwit.js';
|
|
9
9
|
import { BaseWallet } from './base_wallet.js';
|
|
10
10
|
|
|
@@ -16,8 +16,8 @@ export class AccountWallet extends BaseWallet {
|
|
|
16
16
|
super(pxe);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
createTxExecutionRequest(
|
|
20
|
-
return this.account.createTxExecutionRequest(
|
|
19
|
+
createTxExecutionRequest(exec: ExecutionRequestInit): Promise<TxExecutionRequest> {
|
|
20
|
+
return this.account.createTxExecutionRequest(exec);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
getChainId(): Fr {
|
|
@@ -28,7 +28,7 @@ import { type NodeInfo } from '@aztec/types/interfaces';
|
|
|
28
28
|
|
|
29
29
|
import { type Wallet } from '../account/wallet.js';
|
|
30
30
|
import { type ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
31
|
-
import { type
|
|
31
|
+
import { type ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* A base class for Wallet implementations
|
|
@@ -42,7 +42,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
42
42
|
|
|
43
43
|
abstract getVersion(): Fr;
|
|
44
44
|
|
|
45
|
-
abstract createTxExecutionRequest(
|
|
45
|
+
abstract createTxExecutionRequest(exec: ExecutionRequestInit): Promise<TxExecutionRequest>;
|
|
46
46
|
|
|
47
47
|
abstract createAuthWit(
|
|
48
48
|
messageHashOrIntent:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type AuthWitness, type
|
|
1
|
+
import { type AuthWitness, type PXE, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
import { type CompleteAddress, type Fr } from '@aztec/circuits.js';
|
|
3
3
|
|
|
4
4
|
import { DefaultEntrypoint } from '../entrypoint/default_entrypoint.js';
|
|
5
|
-
import { type EntrypointInterface } from '../entrypoint/entrypoint.js';
|
|
5
|
+
import { type EntrypointInterface, type ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
6
6
|
import { BaseWallet } from './base_wallet.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -13,14 +13,14 @@ export class SignerlessWallet extends BaseWallet {
|
|
|
13
13
|
super(pxe);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async createTxExecutionRequest(
|
|
16
|
+
async createTxExecutionRequest(execution: ExecutionRequestInit): Promise<TxExecutionRequest> {
|
|
17
17
|
let entrypoint = this.entrypoint;
|
|
18
18
|
if (!entrypoint) {
|
|
19
19
|
const { chainId, protocolVersion } = await this.pxe.getNodeInfo();
|
|
20
20
|
entrypoint = new DefaultEntrypoint(chainId, protocolVersion);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
return entrypoint.createTxExecutionRequest(
|
|
23
|
+
return entrypoint.createTxExecutionRequest(execution);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
getChainId(): Fr {
|