@aztec/aztec.js 0.0.1-commit.b655e406 → 0.0.1-commit.fce3e4f
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/account.d.ts +2 -3
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account_contract.d.ts +1 -1
- package/dest/account/account_with_secret_key.d.ts +1 -2
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/index.d.ts +1 -1
- package/dest/account/interface.d.ts +1 -1
- package/dest/account/signerless_account.d.ts +2 -3
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/api/abi.d.ts +1 -1
- package/dest/api/account.d.ts +2 -1
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -0
- package/dest/api/addresses.d.ts +1 -1
- package/dest/api/authorization.d.ts +1 -1
- package/dest/api/block.d.ts +1 -1
- package/dest/api/contract.d.ts +3 -3
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +1 -1
- package/dest/api/crypto.d.ts +1 -1
- package/dest/api/deployment.d.ts +1 -1
- package/dest/api/eth_address.d.ts +1 -1
- package/dest/api/ethereum.d.ts +1 -1
- package/dest/api/events.d.ts +1 -1
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee_testing.d.ts +1 -1
- package/dest/api/fields.d.ts +1 -1
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/log.d.ts +1 -1
- package/dest/api/messaging.d.ts +1 -1
- package/dest/api/node.d.ts +1 -1
- package/dest/api/note.d.ts +2 -2
- package/dest/api/note.d.ts.map +1 -1
- package/dest/api/note.js +1 -1
- package/dest/api/protocol.d.ts +1 -1
- package/dest/api/trees.d.ts +1 -1
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/utils.d.ts +1 -1
- package/dest/api/wallet.d.ts +2 -3
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -2
- package/dest/authorization/call_authorization_request.d.ts +1 -22
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +2 -3
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +1 -1
- package/dest/contract/batch_call.d.ts +8 -9
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +51 -33
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/contract.d.ts +2 -2
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +4 -5
- package/dest/contract/contract_base.d.ts +5 -12
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +5 -12
- 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 -6
- package/dest/contract/deploy_method.d.ts +8 -7
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +8 -6
- package/dest/contract/deploy_sent_tx.d.ts +12 -7
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +10 -4
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/interaction_options.d.ts +4 -4
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +4 -10
- package/dest/contract/protocol_contracts.d.ts +1 -1
- package/dest/contract/sent_tx.d.ts +1 -1
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/unsafe_contract.d.ts +1 -1
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/unsafe_contract.js +1 -1
- package/dest/contract/wait_for_proven.d.ts +1 -1
- package/dest/deployment/broadcast_function.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/deployment/publish_class.d.ts +1 -1
- package/dest/deployment/publish_instance.d.ts +1 -1
- package/dest/ethereum/portal_manager.d.ts +1 -3
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +33 -6
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +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 +2 -2
- package/dest/fee/fee_payment_method.d.ts +2 -2
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +2 -2
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +3 -3
- package/dest/fee/public_fee_payment_method.d.ts +2 -2
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +3 -3
- package/dest/fee/sponsored_fee_payment.d.ts +2 -2
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +2 -2
- package/dest/utils/abi_types.d.ts +1 -1
- package/dest/utils/authwit.d.ts +6 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +21 -10
- package/dest/utils/cross_chain.d.ts +1 -1
- package/dest/utils/fee_juice.d.ts +2 -2
- package/dest/utils/fee_juice.js +1 -1
- package/dest/utils/field_compressed_string.d.ts +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/node.d.ts +2 -2
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/pub_key.d.ts +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +2 -2
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +2 -2
- package/dest/wallet/account_manager.d.ts +1 -4
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +1 -1
- package/dest/wallet/deploy_account_method.d.ts +4 -4
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +1 -1
- package/dest/wallet/index.d.ts +1 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +0 -1
- package/dest/wallet/wallet.d.ts +617 -1130
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +23 -39
- package/package.json +13 -12
- package/src/account/account.ts +1 -2
- package/src/account/signerless_account.ts +1 -2
- package/src/api/account.ts +1 -0
- package/src/api/contract.ts +2 -1
- package/src/api/note.ts +1 -1
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +1 -7
- package/src/contract/base_contract_interaction.ts +2 -3
- package/src/contract/batch_call.ts +65 -48
- package/src/contract/contract.ts +7 -5
- package/src/contract/contract_base.ts +5 -15
- package/src/contract/contract_function_interaction.ts +10 -11
- package/src/contract/deploy_method.ts +12 -11
- package/src/contract/deploy_sent_tx.ts +17 -10
- package/src/contract/interaction_options.ts +4 -10
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/deployment/contract_deployer.ts +3 -2
- package/src/ethereum/portal_manager.ts +47 -12
- package/src/fee/fee_juice_payment_method_with_claim.ts +3 -1
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +4 -2
- package/src/fee/public_fee_payment_method.ts +4 -2
- package/src/fee/sponsored_fee_payment.ts +3 -1
- package/src/utils/authwit.ts +20 -14
- package/src/utils/fee_juice.ts +1 -1
- package/src/wallet/account_entrypoint_meta_payment_method.ts +2 -1
- package/src/wallet/account_manager.ts +1 -1
- package/src/wallet/deploy_account_method.ts +3 -2
- package/src/wallet/index.ts +0 -1
- package/src/wallet/wallet.ts +28 -72
- package/dest/wallet/base_wallet.d.ts +0 -91
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -238
- package/src/wallet/base_wallet.ts +0 -350
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, getInitializer } from '@aztec/stdlib/abi';
|
|
4
3
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -11,12 +10,12 @@ import {
|
|
|
11
10
|
} from '@aztec/stdlib/contract';
|
|
12
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
13
12
|
import { type Capsule, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
13
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
14
14
|
|
|
15
15
|
import { publishContractClass } from '../deployment/publish_class.js';
|
|
16
16
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
17
17
|
import type { Wallet } from '../wallet/wallet.js';
|
|
18
18
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
19
|
-
import type { Contract } from './contract.js';
|
|
20
19
|
import type { ContractBase } from './contract_base.js';
|
|
21
20
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
22
21
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
@@ -51,6 +50,8 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
51
50
|
skipInstancePublication?: boolean;
|
|
52
51
|
/** Skip contract initialization. */
|
|
53
52
|
skipInitialization?: boolean;
|
|
53
|
+
/** Skip contract registration in the wallet */
|
|
54
|
+
skipRegistration?: boolean;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -63,8 +64,6 @@ export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
|
|
|
63
64
|
*/
|
|
64
65
|
universalDeploy?: boolean;
|
|
65
66
|
} & Pick<SendInteractionOptions, 'from' | 'fee'>;
|
|
66
|
-
// docs:end:deploy_options
|
|
67
|
-
// TODO(@spalladino): Add unit tests for this class!
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
69
|
* Options for simulating the deployment of a contract
|
|
@@ -96,7 +95,7 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
96
95
|
*
|
|
97
96
|
* Extends the BaseContractInteraction class.
|
|
98
97
|
*/
|
|
99
|
-
export class DeployMethod<TContract extends ContractBase =
|
|
98
|
+
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
100
99
|
/** The contract instance to be deployed. */
|
|
101
100
|
private instance?: ContractInstanceWithAddress = undefined;
|
|
102
101
|
|
|
@@ -107,7 +106,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
107
106
|
private publicKeys: PublicKeys,
|
|
108
107
|
wallet: Wallet,
|
|
109
108
|
protected artifact: ContractArtifact,
|
|
110
|
-
protected postDeployCtor: (
|
|
109
|
+
protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
111
110
|
private args: any[] = [],
|
|
112
111
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
113
112
|
authWitnesses: AuthWitness[] = [],
|
|
@@ -125,7 +124,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
125
124
|
public async request(options?: RequestDeployOptions): Promise<ExecutionPayload> {
|
|
126
125
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
if (!options?.skipRegistration) {
|
|
128
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
129
|
+
}
|
|
129
130
|
|
|
130
131
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
131
132
|
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
@@ -155,7 +156,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
155
156
|
public async register(options?: RequestDeployOptions): Promise<TContract> {
|
|
156
157
|
const instance = await this.getInstance(options);
|
|
157
158
|
await this.wallet.registerContract(instance, this.artifact);
|
|
158
|
-
return this.postDeployCtor(instance
|
|
159
|
+
return this.postDeployCtor(instance, this.wallet);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
/**
|
|
@@ -239,7 +240,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
239
240
|
public override send(options: DeployOptions): DeploySentTx<TContract> {
|
|
240
241
|
const sendTx = async () => {
|
|
241
242
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
242
|
-
const sendOptions =
|
|
243
|
+
const sendOptions = toSendOptions(options);
|
|
243
244
|
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
244
245
|
};
|
|
245
246
|
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
@@ -274,7 +275,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
274
275
|
*/
|
|
275
276
|
public async simulate(options: SimulateDeployOptions): Promise<SimulationReturn<true>> {
|
|
276
277
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
277
|
-
const simulatedTx = await this.wallet.simulateTx(executionPayload,
|
|
278
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, toSimulateOptions(options));
|
|
278
279
|
|
|
279
280
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
280
281
|
this.log.verbose(
|
|
@@ -297,7 +298,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
297
298
|
public async profile(options: DeployOptions & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
298
299
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
299
300
|
return await this.wallet.profileTx(executionPayload, {
|
|
300
|
-
...
|
|
301
|
+
...toProfileOptions(options),
|
|
301
302
|
profileMode: options.profileMode,
|
|
302
303
|
skipProofGeneration: options.skipProofGeneration,
|
|
303
304
|
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
3
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
4
|
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
5
|
|
|
7
6
|
import type { Wallet } from '../wallet/wallet.js';
|
|
8
|
-
import type { Contract } from './contract.js';
|
|
9
7
|
import type { ContractBase } from './contract_base.js';
|
|
10
8
|
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
11
9
|
|
|
@@ -16,27 +14,37 @@ export type DeployedWaitOpts = WaitOpts & {
|
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
19
|
-
export type DeployTxReceipt<TContract extends ContractBase =
|
|
17
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
|
|
20
18
|
/** Instance of the newly deployed contract. */
|
|
21
19
|
contract: TContract;
|
|
20
|
+
/** The deployed contract instance with address and metadata. */
|
|
21
|
+
instance: ContractInstanceWithAddress;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
26
26
|
*/
|
|
27
|
-
export class DeploySentTx<TContract extends
|
|
27
|
+
export class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
|
|
28
28
|
private log = createLogger('aztecjs:deploy_sent_tx');
|
|
29
29
|
|
|
30
30
|
constructor(
|
|
31
31
|
wallet: Wallet,
|
|
32
32
|
sendTx: () => Promise<TxHash>,
|
|
33
|
-
private postDeployCtor: (
|
|
33
|
+
private postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
34
34
|
/** A getter for the deployed contract instance */
|
|
35
|
-
|
|
35
|
+
private instanceGetter: () => Promise<ContractInstanceWithAddress>,
|
|
36
36
|
) {
|
|
37
37
|
super(wallet, sendTx);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Returns the contract instance for this deployment.
|
|
42
|
+
* @returns The deployed contract instance with address and metadata.
|
|
43
|
+
*/
|
|
44
|
+
public async getInstance(): Promise<ContractInstanceWithAddress> {
|
|
45
|
+
return await this.instanceGetter();
|
|
46
|
+
}
|
|
47
|
+
|
|
40
48
|
/**
|
|
41
49
|
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
42
50
|
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
@@ -44,8 +52,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
44
52
|
*/
|
|
45
53
|
public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
|
|
46
54
|
const receipt = await this.wait(opts);
|
|
47
|
-
|
|
48
|
-
this.log.info(`Contract ${instance.address.toString()} successfully deployed.`);
|
|
55
|
+
this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
|
|
49
56
|
return receipt.contract;
|
|
50
57
|
}
|
|
51
58
|
|
|
@@ -62,7 +69,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
62
69
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
63
70
|
}
|
|
64
71
|
const instance = await this.instanceGetter();
|
|
65
|
-
const contract =
|
|
66
|
-
return { ...receipt, contract };
|
|
72
|
+
const contract = this.postDeployCtor(instance, contractWallet) as TContract;
|
|
73
|
+
return { ...receipt, contract, instance };
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -114,13 +114,10 @@ export type SimulationReturn<T extends boolean | undefined> = T extends true
|
|
|
114
114
|
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
115
115
|
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
116
116
|
*/
|
|
117
|
-
export
|
|
117
|
+
export function toSendOptions(options: SendInteractionOptions): SendOptions {
|
|
118
118
|
return {
|
|
119
119
|
...options,
|
|
120
120
|
fee: {
|
|
121
|
-
// If this interaction includes a fee payment method, pass the fee payer
|
|
122
|
-
// as a hint to the wallet
|
|
123
|
-
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
124
121
|
// If a payment method that includes gas settings was used,
|
|
125
122
|
// try to reuse as much as possible while still allowing
|
|
126
123
|
// manual override. CAREFUL: this can cause mismatches during proving
|
|
@@ -136,13 +133,10 @@ export async function toSendOptions(options: SendInteractionOptions): Promise<Se
|
|
|
136
133
|
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
137
134
|
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
138
135
|
*/
|
|
139
|
-
export
|
|
136
|
+
export function toSimulateOptions(options: SimulateInteractionOptions): SimulateOptions {
|
|
140
137
|
return {
|
|
141
138
|
...options,
|
|
142
139
|
fee: {
|
|
143
|
-
// If this interaction includes a fee payment method, pass the fee payer
|
|
144
|
-
// as a hint to the wallet
|
|
145
|
-
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
146
140
|
// If a payment method that includes gas settings was used,
|
|
147
141
|
// try to reuse as much as possible while still allowing
|
|
148
142
|
// manual override. CAREFUL: this can cause mismatches during proving
|
|
@@ -160,9 +154,9 @@ export async function toSimulateOptions(options: SimulateInteractionOptions): Pr
|
|
|
160
154
|
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
161
155
|
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
162
156
|
*/
|
|
163
|
-
export
|
|
157
|
+
export function toProfileOptions(options: ProfileInteractionOptions): ProfileOptions {
|
|
164
158
|
return {
|
|
165
|
-
...
|
|
159
|
+
...toSimulateOptions(options),
|
|
166
160
|
profileMode: options.profileMode,
|
|
167
161
|
skipProofGeneration: options.skipProofGeneration,
|
|
168
162
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import {
|
|
2
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
3
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
4
|
|
|
5
5
|
import { Contract } from '../contract/contract.js';
|
|
@@ -28,7 +28,8 @@ export class ContractDeployer {
|
|
|
28
28
|
* @returns A DeployMethod instance configured with the ABI, PXE, and constructor arguments.
|
|
29
29
|
*/
|
|
30
30
|
public deploy(...args: any[]) {
|
|
31
|
-
const postDeployCtor = (
|
|
31
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
32
|
+
Contract.at(instance.address, this.artifact, wallet);
|
|
32
33
|
return new DeployMethod(
|
|
33
34
|
this.publicKeys ?? PublicKeys.default(),
|
|
34
35
|
this.wallet,
|
|
@@ -177,17 +177,32 @@ export class L1FeeJuicePortalManager {
|
|
|
177
177
|
hash: await this.contract.write.depositToAztecPublic(args),
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
this.logger.info('Deposited to Aztec public successfully');
|
|
180
|
+
this.logger.info('Deposited to Aztec public successfully', { txReceipt });
|
|
181
181
|
|
|
182
182
|
const log = extractEvent(
|
|
183
183
|
txReceipt.logs,
|
|
184
184
|
this.contract.address,
|
|
185
185
|
this.contract.abi,
|
|
186
186
|
'DepositToAztecPublic',
|
|
187
|
-
log =>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
log => {
|
|
188
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
189
|
+
const normalizeHex = (val: string | bigint | number) => {
|
|
190
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
191
|
+
return hexStr.toLowerCase();
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const secretHashMatch = normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString());
|
|
195
|
+
const amountMatch = log.args.amount === amountToBridge;
|
|
196
|
+
const toMatch = normalizeHex(log.args.to) === normalizeHex(to.toString());
|
|
197
|
+
|
|
198
|
+
this.logger.debug(
|
|
199
|
+
`Event filter matching: secretHash=${secretHashMatch} (${log.args.secretHash} vs ${claimSecretHash.toString()}), ` +
|
|
200
|
+
`amount=${amountMatch} (${log.args.amount} vs ${amountToBridge}), ` +
|
|
201
|
+
`to=${toMatch} (${log.args.to} vs ${to.toString()})`,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
return secretHashMatch && amountMatch && toMatch;
|
|
205
|
+
},
|
|
191
206
|
this.logger,
|
|
192
207
|
);
|
|
193
208
|
|
|
@@ -282,10 +297,19 @@ export class L1ToL2TokenPortalManager {
|
|
|
282
297
|
this.portal.address,
|
|
283
298
|
this.portal.abi,
|
|
284
299
|
'DepositToAztecPublic',
|
|
285
|
-
log =>
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
300
|
+
log => {
|
|
301
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
302
|
+
const normalizeHex = (val: string | bigint | number) => {
|
|
303
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
304
|
+
return hexStr.toLowerCase();
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString()) &&
|
|
309
|
+
log.args.amount === amount &&
|
|
310
|
+
normalizeHex(log.args.to) === normalizeHex(to.toString())
|
|
311
|
+
);
|
|
312
|
+
},
|
|
289
313
|
this.logger,
|
|
290
314
|
);
|
|
291
315
|
|
|
@@ -323,7 +347,18 @@ export class L1ToL2TokenPortalManager {
|
|
|
323
347
|
this.portal.address,
|
|
324
348
|
this.portal.abi,
|
|
325
349
|
'DepositToAztecPrivate',
|
|
326
|
-
log =>
|
|
350
|
+
log => {
|
|
351
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
352
|
+
const normalizeHex = (val: string | bigint | number) => {
|
|
353
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
354
|
+
return hexStr.toLowerCase();
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
log.args.amount === amount &&
|
|
359
|
+
normalizeHex(log.args.secretHashForL2MessageConsumption) === normalizeHex(claimSecretHash.toString())
|
|
360
|
+
);
|
|
361
|
+
},
|
|
327
362
|
this.logger,
|
|
328
363
|
);
|
|
329
364
|
|
|
@@ -394,7 +429,7 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
394
429
|
);
|
|
395
430
|
|
|
396
431
|
const messageLeafId = getL2ToL1MessageLeafId({ leafIndex: messageIndex, siblingPath });
|
|
397
|
-
const isConsumedBefore = await this.outbox.read.
|
|
432
|
+
const isConsumedBefore = await this.outbox.read.hasMessageBeenConsumedAtCheckpoint([blockNumber, messageLeafId]);
|
|
398
433
|
if (isConsumedBefore) {
|
|
399
434
|
throw new Error(
|
|
400
435
|
`L1 to L2 message at block ${blockNumber} index ${messageIndex} height ${siblingPath.pathSize} has already been consumed`,
|
|
@@ -415,7 +450,7 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
415
450
|
hash: await this.extendedClient.writeContract(withdrawRequest),
|
|
416
451
|
});
|
|
417
452
|
|
|
418
|
-
const isConsumedAfter = await this.outbox.read.
|
|
453
|
+
const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtCheckpoint([blockNumber, messageLeafId]);
|
|
419
454
|
if (!isConsumedAfter) {
|
|
420
455
|
throw new Error(
|
|
421
456
|
`L1 to L2 message at block ${blockNumber} index ${messageIndex} height ${siblingPath.pathSize} not consumed after withdrawal`,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
3
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
5
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
5
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
8
|
import type { L2AmountClaim } from '../ethereum/portal_manager.js';
|
|
9
9
|
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
@@ -45,6 +45,8 @@ export class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
|
45
45
|
],
|
|
46
46
|
[],
|
|
47
47
|
[],
|
|
48
|
+
[],
|
|
49
|
+
this.sender, // feePayer
|
|
48
50
|
);
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
3
|
+
import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Holds information about how the fee for a transaction is to be paid.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
8
8
|
import type { Wallet } from '../wallet/wallet.js';
|
|
@@ -49,7 +49,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
49
49
|
const abi = {
|
|
50
50
|
name: 'get_accepted_asset',
|
|
51
51
|
functionType: FunctionType.PRIVATE,
|
|
52
|
-
|
|
52
|
+
isOnlySelf: false,
|
|
53
53
|
isStatic: false,
|
|
54
54
|
parameters: [],
|
|
55
55
|
returnTypes: [
|
|
@@ -129,6 +129,8 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
129
129
|
],
|
|
130
130
|
[witness],
|
|
131
131
|
[],
|
|
132
|
+
[],
|
|
133
|
+
this.paymentContract, // feePayer
|
|
132
134
|
);
|
|
133
135
|
}
|
|
134
136
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
4
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
8
8
|
import { SetPublicAuthwitContractInteraction } from '../utils/authwit.js';
|
|
@@ -43,7 +43,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
43
43
|
const abi = {
|
|
44
44
|
name: 'get_accepted_asset',
|
|
45
45
|
functionType: FunctionType.PRIVATE,
|
|
46
|
-
|
|
46
|
+
isOnlySelf: false,
|
|
47
47
|
isStatic: false,
|
|
48
48
|
parameters: [],
|
|
49
49
|
returnTypes: [
|
|
@@ -129,6 +129,8 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
129
129
|
],
|
|
130
130
|
[],
|
|
131
131
|
[],
|
|
132
|
+
[],
|
|
133
|
+
this.paymentContract, // feePayer
|
|
132
134
|
);
|
|
133
135
|
}
|
|
134
136
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
2
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A fee payment method that uses a contract that blindly sponsors transactions.
|
|
@@ -35,6 +35,8 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
35
35
|
],
|
|
36
36
|
[],
|
|
37
37
|
[],
|
|
38
|
+
[],
|
|
39
|
+
this.paymentContract, // feePayer
|
|
38
40
|
);
|
|
39
41
|
}
|
|
40
42
|
|
package/src/utils/authwit.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type IntentInnerHash = {
|
|
|
22
22
|
/** The consumer */
|
|
23
23
|
consumer: AztecAddress;
|
|
24
24
|
/** The action to approve */
|
|
25
|
-
innerHash:
|
|
25
|
+
innerHash: Fr;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/** Intent with a call */
|
|
@@ -43,7 +43,7 @@ export type ContractFunctionInteractionCallIntent = {
|
|
|
43
43
|
|
|
44
44
|
/** Identifies ContractFunctionInteractionCallIntents */
|
|
45
45
|
function isContractFunctionIntractionCallIntent(
|
|
46
|
-
messageHashOrIntent: Fr |
|
|
46
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
47
47
|
): messageHashOrIntent is ContractFunctionInteractionCallIntent {
|
|
48
48
|
return (
|
|
49
49
|
'caller' in messageHashOrIntent &&
|
|
@@ -102,14 +102,12 @@ export const computeAuthWitMessageHash = async (
|
|
|
102
102
|
* @returns The message hash for the intent
|
|
103
103
|
*/
|
|
104
104
|
export async function getMessageHashFromIntent(
|
|
105
|
-
messageHashOrIntent: Fr |
|
|
105
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
106
106
|
chainInfo: ChainInfo,
|
|
107
107
|
) {
|
|
108
108
|
let messageHash: Fr;
|
|
109
109
|
const { chainId, version } = chainInfo;
|
|
110
|
-
if (
|
|
111
|
-
messageHash = Fr.fromBuffer(messageHashOrIntent);
|
|
112
|
-
} else if (messageHashOrIntent instanceof Fr) {
|
|
110
|
+
if (messageHashOrIntent instanceof Fr) {
|
|
113
111
|
messageHash = messageHashOrIntent;
|
|
114
112
|
} else {
|
|
115
113
|
messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
|
|
@@ -159,9 +157,6 @@ export async function lookupValidity(
|
|
|
159
157
|
const call = isContractFunctionIntractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
160
158
|
innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
161
159
|
consumer = call.to;
|
|
162
|
-
} else if (Buffer.isBuffer(intent.innerHash)) {
|
|
163
|
-
innerHash = Fr.fromBuffer(intent.innerHash);
|
|
164
|
-
consumer = intent.consumer;
|
|
165
160
|
} else {
|
|
166
161
|
({ innerHash, consumer } = intent);
|
|
167
162
|
}
|
|
@@ -174,9 +169,20 @@ export async function lookupValidity(
|
|
|
174
169
|
name: 'lookup_validity',
|
|
175
170
|
isInitializer: false,
|
|
176
171
|
functionType: FunctionType.UTILITY,
|
|
177
|
-
|
|
172
|
+
isOnlySelf: false,
|
|
178
173
|
isStatic: false,
|
|
179
|
-
parameters: [
|
|
174
|
+
parameters: [
|
|
175
|
+
{
|
|
176
|
+
name: 'consumer',
|
|
177
|
+
type: {
|
|
178
|
+
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
179
|
+
kind: 'struct',
|
|
180
|
+
path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
181
|
+
},
|
|
182
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
183
|
+
},
|
|
184
|
+
{ name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
|
|
185
|
+
],
|
|
180
186
|
returnTypes: [{ kind: 'boolean' }],
|
|
181
187
|
errorTypes: {},
|
|
182
188
|
} as FunctionAbi;
|
|
@@ -194,7 +200,7 @@ export async function lookupValidity(
|
|
|
194
200
|
name: 'utility_is_consumable',
|
|
195
201
|
isInitializer: false,
|
|
196
202
|
functionType: FunctionType.UTILITY,
|
|
197
|
-
|
|
203
|
+
isOnlySelf: false,
|
|
198
204
|
isStatic: false,
|
|
199
205
|
parameters: [
|
|
200
206
|
{
|
|
@@ -240,7 +246,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
240
246
|
static async create(
|
|
241
247
|
wallet: Wallet,
|
|
242
248
|
from: AztecAddress,
|
|
243
|
-
messageHashOrIntent: Fr |
|
|
249
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
244
250
|
authorized: boolean,
|
|
245
251
|
) {
|
|
246
252
|
const chainInfo = await wallet.getChainInfo();
|
|
@@ -291,7 +297,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
291
297
|
name: 'set_authorized',
|
|
292
298
|
isInitializer: false,
|
|
293
299
|
functionType: FunctionType.PUBLIC,
|
|
294
|
-
|
|
300
|
+
isOnlySelf: true,
|
|
295
301
|
isStatic: false,
|
|
296
302
|
parameters: [
|
|
297
303
|
{
|
package/src/utils/fee_juice.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Returns the owner's fee juice balance.
|
|
9
|
-
* Note: This is used only
|
|
9
|
+
* Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
|
|
10
10
|
*/
|
|
11
11
|
export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
|
|
12
12
|
const slot = await deriveStorageSlotInMap(new Fr(1), owner);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
2
2
|
import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
|
|
3
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
4
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
4
|
import {
|
|
6
5
|
type ContractArtifact,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
} from '@aztec/stdlib/abi';
|
|
13
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
13
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
14
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
15
15
|
|
|
16
16
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
17
17
|
import type { Wallet } from './index.js';
|
|
@@ -92,6 +92,7 @@ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
|
92
92
|
[payloadAuthWitness, ...feeAuthwitnesses],
|
|
93
93
|
[],
|
|
94
94
|
feeEncodedCalls.hashedArguments,
|
|
95
|
+
feePayer,
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -138,7 +138,7 @@ export class AccountManager {
|
|
|
138
138
|
this.getPublicKeys(),
|
|
139
139
|
this.wallet,
|
|
140
140
|
artifact,
|
|
141
|
-
|
|
141
|
+
instance => Contract.at(instance.address, artifact, this.wallet),
|
|
142
142
|
new Fr(this.salt),
|
|
143
143
|
constructorArgs,
|
|
144
144
|
constructorName,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
7
8
|
import type { Contract } from '../contract/contract.js';
|
|
8
9
|
import type { ContractBase } from '../contract/contract_base.js';
|
|
@@ -44,7 +45,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
44
45
|
publicKeys: PublicKeys,
|
|
45
46
|
wallet: Wallet,
|
|
46
47
|
artifact: ContractArtifact,
|
|
47
|
-
postDeployCtor: (
|
|
48
|
+
postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
48
49
|
private salt: Fr,
|
|
49
50
|
args: any[] = [],
|
|
50
51
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
package/src/wallet/index.ts
CHANGED