@aztec/aztec.js 0.67.1 → 0.68.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/api/addresses.d.ts +3 -0
- package/dest/api/addresses.d.ts.map +1 -0
- package/dest/api/addresses.js +3 -0
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -4
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +18 -8
- package/dest/contract/get_gas_limits.d.ts +12 -2
- package/dest/contract/get_gas_limits.d.ts.map +1 -1
- package/dest/contract/get_gas_limits.js +1 -1
- package/dest/contract/index.d.ts +6 -6
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +7 -7
- package/dest/fee/fee_juice_payment_method.d.ts +1 -1
- package/dest/fee/fee_juice_payment_method.js +2 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +4 -3
- package/dest/fee/fee_payment_method.d.ts +1 -1
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/no_fee_payment_method.d.ts +1 -1
- package/dest/fee/no_fee_payment_method.js +2 -2
- package/dest/fee/private_fee_payment_method.d.ts +2 -17
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +38 -17
- package/dest/fee/public_fee_payment_method.d.ts +2 -9
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +37 -11
- package/dest/index.d.ts +5 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +7 -5
- package/dest/rpc_clients/pxe_client.d.ts +1 -1
- package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
- package/dest/rpc_clients/pxe_client.js +2 -2
- package/dest/utils/anvil_test_watcher.js +2 -2
- package/dest/wallet/base_wallet.d.ts +4 -4
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +9 -9
- package/package.json +16 -13
- package/{dest/api/aztec_address.d.ts → src/api/addresses.ts} +1 -1
- package/src/contract/base_contract_interaction.ts +16 -3
- package/src/contract/contract_function_interaction.ts +22 -8
- package/src/contract/get_gas_limits.ts +15 -2
- package/src/contract/index.ts +10 -6
- package/src/fee/fee_juice_payment_method.ts +1 -1
- package/src/fee/fee_juice_payment_method_with_claim.ts +3 -2
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/no_fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +46 -16
- package/src/fee/public_fee_payment_method.ts +45 -10
- package/src/index.ts +4 -20
- package/src/rpc_clients/pxe_client.ts +1 -1
- package/src/utils/anvil_test_watcher.ts +1 -1
- package/src/wallet/base_wallet.ts +16 -7
- package/dest/api/aztec_address.d.ts.map +0 -1
- package/dest/api/aztec_address.js +0 -2
- package/dest/main.js +0 -2
- package/dest/main.js.LICENSE.txt +0 -23
- package/src/api/aztec_address.ts +0 -1
|
@@ -7,7 +7,7 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
|
7
7
|
*/
|
|
8
8
|
export interface FeePaymentMethod {
|
|
9
9
|
/** The asset used to pay the fee. */
|
|
10
|
-
getAsset(): AztecAddress
|
|
10
|
+
getAsset(): Promise<AztecAddress>;
|
|
11
11
|
/**
|
|
12
12
|
* Creates a function call to pay the fee in the given asset.
|
|
13
13
|
* @param gasSettings - The gas limits and max fees.
|
|
@@ -5,17 +5,17 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
7
7
|
import { type Wallet } from '../account/wallet.js';
|
|
8
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
9
|
+
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
8
10
|
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Holds information about how the fee for a transaction is to be paid.
|
|
12
14
|
*/
|
|
13
15
|
export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
16
|
+
private assetPromise: Promise<AztecAddress> | null = null;
|
|
17
|
+
|
|
14
18
|
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* The asset used to pay the fee.
|
|
17
|
-
*/
|
|
18
|
-
private asset: AztecAddress,
|
|
19
19
|
/**
|
|
20
20
|
* Address which will hold the fee payment.
|
|
21
21
|
*/
|
|
@@ -26,11 +26,6 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
26
26
|
*/
|
|
27
27
|
private wallet: Wallet,
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Address that the FPC sends notes it receives to.
|
|
31
|
-
*/
|
|
32
|
-
private feeRecipient: AztecAddress,
|
|
33
|
-
|
|
34
29
|
/**
|
|
35
30
|
* If true, the max fee will be set to 1.
|
|
36
31
|
* TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
|
|
@@ -42,8 +37,43 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
42
37
|
* The asset used to pay the fee.
|
|
43
38
|
* @returns The asset used to pay the fee.
|
|
44
39
|
*/
|
|
45
|
-
getAsset() {
|
|
46
|
-
|
|
40
|
+
getAsset(): Promise<AztecAddress> {
|
|
41
|
+
if (!this.assetPromise) {
|
|
42
|
+
// We use signer-less wallet because this function could be triggered before the associated account is deployed.
|
|
43
|
+
const signerlessWallet = new SignerlessWallet(this.wallet);
|
|
44
|
+
|
|
45
|
+
const interaction = new ContractFunctionInteraction(
|
|
46
|
+
signerlessWallet,
|
|
47
|
+
this.paymentContract,
|
|
48
|
+
{
|
|
49
|
+
name: 'get_accepted_asset',
|
|
50
|
+
functionType: FunctionType.PRIVATE,
|
|
51
|
+
isInternal: false,
|
|
52
|
+
isStatic: false,
|
|
53
|
+
parameters: [],
|
|
54
|
+
returnTypes: [
|
|
55
|
+
{
|
|
56
|
+
kind: 'struct',
|
|
57
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
58
|
+
fields: [
|
|
59
|
+
{
|
|
60
|
+
name: 'inner',
|
|
61
|
+
type: {
|
|
62
|
+
kind: 'field',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
errorTypes: {},
|
|
69
|
+
isInitializer: false,
|
|
70
|
+
},
|
|
71
|
+
[],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
this.assetPromise = interaction.simulate();
|
|
75
|
+
}
|
|
76
|
+
return this.assetPromise!;
|
|
47
77
|
}
|
|
48
78
|
|
|
49
79
|
getFeePayer(): Promise<AztecAddress> {
|
|
@@ -65,11 +95,11 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
65
95
|
caller: this.paymentContract,
|
|
66
96
|
action: {
|
|
67
97
|
name: 'setup_refund',
|
|
68
|
-
args: [this.
|
|
69
|
-
selector: FunctionSelector.fromSignature('setup_refund((Field),
|
|
98
|
+
args: [this.wallet.getAddress().toField(), maxFee, nonce],
|
|
99
|
+
selector: FunctionSelector.fromSignature('setup_refund((Field),Field,Field)'),
|
|
70
100
|
type: FunctionType.PRIVATE,
|
|
71
101
|
isStatic: false,
|
|
72
|
-
to: this.
|
|
102
|
+
to: await this.getAsset(),
|
|
73
103
|
returnTypes: [],
|
|
74
104
|
},
|
|
75
105
|
});
|
|
@@ -78,10 +108,10 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
78
108
|
{
|
|
79
109
|
name: 'fee_entrypoint_private',
|
|
80
110
|
to: this.paymentContract,
|
|
81
|
-
selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,
|
|
111
|
+
selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,Field)'),
|
|
82
112
|
type: FunctionType.PRIVATE,
|
|
83
113
|
isStatic: false,
|
|
84
|
-
args: [maxFee,
|
|
114
|
+
args: [maxFee, nonce],
|
|
85
115
|
returnTypes: [],
|
|
86
116
|
},
|
|
87
117
|
];
|
|
@@ -4,18 +4,18 @@ 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
|
|
|
7
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
7
8
|
import { type AccountWallet } from '../wallet/account_wallet.js';
|
|
9
|
+
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
8
10
|
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Holds information about how the fee for a transaction is to be paid.
|
|
12
14
|
*/
|
|
13
15
|
export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
16
|
+
private assetPromise: Promise<AztecAddress> | null = null;
|
|
17
|
+
|
|
14
18
|
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* The asset used to pay the fee.
|
|
17
|
-
*/
|
|
18
|
-
protected asset: AztecAddress,
|
|
19
19
|
/**
|
|
20
20
|
* Address which will hold the fee payment.
|
|
21
21
|
*/
|
|
@@ -30,8 +30,43 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
30
30
|
* The asset used to pay the fee.
|
|
31
31
|
* @returns The asset used to pay the fee.
|
|
32
32
|
*/
|
|
33
|
-
getAsset() {
|
|
34
|
-
|
|
33
|
+
getAsset(): Promise<AztecAddress> {
|
|
34
|
+
if (!this.assetPromise) {
|
|
35
|
+
// We use signer-less wallet because this function could be triggered before the associated account is deployed.
|
|
36
|
+
const signerlessWallet = new SignerlessWallet(this.wallet);
|
|
37
|
+
|
|
38
|
+
const interaction = new ContractFunctionInteraction(
|
|
39
|
+
signerlessWallet,
|
|
40
|
+
this.paymentContract,
|
|
41
|
+
{
|
|
42
|
+
name: 'get_accepted_asset',
|
|
43
|
+
functionType: FunctionType.PRIVATE,
|
|
44
|
+
isInternal: false,
|
|
45
|
+
isStatic: false,
|
|
46
|
+
parameters: [],
|
|
47
|
+
returnTypes: [
|
|
48
|
+
{
|
|
49
|
+
kind: 'struct',
|
|
50
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
51
|
+
fields: [
|
|
52
|
+
{
|
|
53
|
+
name: 'inner',
|
|
54
|
+
type: {
|
|
55
|
+
kind: 'field',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
errorTypes: {},
|
|
62
|
+
isInitializer: false,
|
|
63
|
+
},
|
|
64
|
+
[],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.assetPromise = interaction.simulate();
|
|
68
|
+
}
|
|
69
|
+
return this.assetPromise!;
|
|
35
70
|
}
|
|
36
71
|
|
|
37
72
|
getFeePayer(): Promise<AztecAddress> {
|
|
@@ -43,7 +78,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
43
78
|
* @param gasSettings - The gas settings.
|
|
44
79
|
* @returns The function call to pay the fee.
|
|
45
80
|
*/
|
|
46
|
-
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
81
|
+
async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
47
82
|
const nonce = Fr.random();
|
|
48
83
|
const maxFee = gasSettings.getFeeLimit();
|
|
49
84
|
|
|
@@ -58,7 +93,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
58
93
|
selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),Field,Field)'),
|
|
59
94
|
type: FunctionType.PUBLIC,
|
|
60
95
|
isStatic: false,
|
|
61
|
-
to: this.
|
|
96
|
+
to: await this.getAsset(),
|
|
62
97
|
returnTypes: [],
|
|
63
98
|
},
|
|
64
99
|
},
|
|
@@ -68,10 +103,10 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
68
103
|
{
|
|
69
104
|
name: 'fee_entrypoint_public',
|
|
70
105
|
to: this.paymentContract,
|
|
71
|
-
selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,
|
|
106
|
+
selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,Field)'),
|
|
72
107
|
type: FunctionType.PRIVATE,
|
|
73
108
|
isStatic: false,
|
|
74
|
-
args: [maxFee,
|
|
109
|
+
args: [maxFee, nonce],
|
|
75
110
|
returnTypes: [],
|
|
76
111
|
},
|
|
77
112
|
]);
|
package/src/index.ts
CHANGED
|
@@ -13,29 +13,12 @@
|
|
|
13
13
|
* ```typescript
|
|
14
14
|
* import { TxHash } from '@aztec.js/tx_hash'
|
|
15
15
|
* import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/aztec.js/abi';
|
|
16
|
-
* import { AztecAddress } from '@aztec/aztec.js/
|
|
16
|
+
* import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
17
17
|
* import { EthAddress } from '@aztec/aztec.js/eth_address';
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
20
|
* TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
|
|
21
21
|
*/
|
|
22
|
-
export {
|
|
23
|
-
BatchCall,
|
|
24
|
-
Contract,
|
|
25
|
-
ContractBase,
|
|
26
|
-
ContractFunctionInteraction,
|
|
27
|
-
DefaultWaitOpts,
|
|
28
|
-
DeployMethod,
|
|
29
|
-
DeploySentTx,
|
|
30
|
-
SentTx,
|
|
31
|
-
type ContractMethod,
|
|
32
|
-
type ContractNotes,
|
|
33
|
-
type ContractStorageLayout,
|
|
34
|
-
type DeployOptions,
|
|
35
|
-
type ProfileResult,
|
|
36
|
-
type SendMethodOptions,
|
|
37
|
-
type WaitOpts,
|
|
38
|
-
} from './contract/index.js';
|
|
39
22
|
|
|
40
23
|
export { ContractDeployer } from './deployment/index.js';
|
|
41
24
|
|
|
@@ -79,7 +62,6 @@ export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, type Walle
|
|
|
79
62
|
// // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
|
|
80
63
|
// // here once the issue is resolved.
|
|
81
64
|
export {
|
|
82
|
-
AztecAddress,
|
|
83
65
|
ContractClassWithId,
|
|
84
66
|
ContractInstanceWithAddress,
|
|
85
67
|
EthAddress,
|
|
@@ -110,7 +92,6 @@ export {
|
|
|
110
92
|
AuthWitness,
|
|
111
93
|
Body,
|
|
112
94
|
Comparator,
|
|
113
|
-
CompleteAddress,
|
|
114
95
|
ContractClass2BlockL2Logs,
|
|
115
96
|
EncryptedLogPayload,
|
|
116
97
|
EpochProofQuote,
|
|
@@ -174,3 +155,6 @@ export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contra
|
|
|
174
155
|
export * from './api/abi.js';
|
|
175
156
|
export * from './api/fee.js';
|
|
176
157
|
export * from './api/init.js';
|
|
158
|
+
// Granular export, even if not in the api folder
|
|
159
|
+
export * from './contract/index.js';
|
|
160
|
+
export * from './api/addresses.js';
|
|
@@ -46,7 +46,7 @@ export class AnvilTestWatcher {
|
|
|
46
46
|
const isAutoMining = await this.cheatcodes.isAutoMining();
|
|
47
47
|
|
|
48
48
|
if (isAutoMining) {
|
|
49
|
-
this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), 1000);
|
|
49
|
+
this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), this.logger, 1000);
|
|
50
50
|
this.filledRunningPromise.start();
|
|
51
51
|
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
|
|
52
52
|
} else {
|
|
@@ -86,14 +86,14 @@ export abstract class BaseWallet implements Wallet {
|
|
|
86
86
|
getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
87
87
|
return this.pxe.getRegisteredAccount(address);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
return this.pxe.
|
|
89
|
+
registerSender(address: AztecAddress): Promise<AztecAddress> {
|
|
90
|
+
return this.pxe.registerSender(address);
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
return this.pxe.
|
|
92
|
+
getSenders(): Promise<AztecAddress[]> {
|
|
93
|
+
return this.pxe.getSenders();
|
|
94
94
|
}
|
|
95
|
-
async
|
|
96
|
-
await this.pxe.
|
|
95
|
+
async removeSender(address: AztecAddress): Promise<void> {
|
|
96
|
+
await this.pxe.removeSender(address);
|
|
97
97
|
}
|
|
98
98
|
registerContract(contract: {
|
|
99
99
|
/** Instance */ instance: ContractInstanceWithAddress;
|
|
@@ -115,9 +115,18 @@ export abstract class BaseWallet implements Wallet {
|
|
|
115
115
|
simulatePublic: boolean,
|
|
116
116
|
msgSender?: AztecAddress,
|
|
117
117
|
skipTxValidation?: boolean,
|
|
118
|
+
enforceFeePayment?: boolean,
|
|
118
119
|
profile?: boolean,
|
|
119
120
|
): Promise<TxSimulationResult> {
|
|
120
|
-
return this.pxe.simulateTx(
|
|
121
|
+
return this.pxe.simulateTx(
|
|
122
|
+
txRequest,
|
|
123
|
+
simulatePublic,
|
|
124
|
+
msgSender,
|
|
125
|
+
skipTxValidation,
|
|
126
|
+
enforceFeePayment,
|
|
127
|
+
profile,
|
|
128
|
+
this.scopes,
|
|
129
|
+
);
|
|
121
130
|
}
|
|
122
131
|
sendTx(tx: Tx): Promise<TxHash> {
|
|
123
132
|
return this.pxe.sendTx(tx);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_address.d.ts","sourceRoot":"","sources":["../../src/api/aztec_address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfYWRkcmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hcGkvYXp0ZWNfYWRkcmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0saUNBQWlDLENBQUMifQ==
|