@aztec/aztec.js 0.80.0 → 0.82.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 → account_contract.d.ts} +11 -5
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/{contract.js → account_contract.js} +5 -1
- package/dest/account/index.d.ts +2 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -2
- package/dest/account/interface.d.ts +1 -13
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -0
- package/dest/account_manager/account_manager.d.ts +105 -0
- package/dest/account_manager/account_manager.d.ts.map +1 -0
- package/dest/account_manager/account_manager.js +165 -0
- package/dest/account_manager/deploy_account_method.d.ts +4 -4
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +28 -13
- 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 +2 -2
- package/dest/account_manager/index.d.ts +1 -104
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +1 -157
- package/dest/api/account.d.ts +2 -1
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/contract.d.ts +4 -1
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -0
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/utils.d.ts +2 -1
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +2 -1
- package/dest/api/wallet.d.ts +1 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +22 -57
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +12 -67
- package/dest/contract/batch_call.d.ts +6 -18
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +25 -54
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract_base.d.ts +2 -2
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +38 -18
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +34 -41
- package/dest/contract/deploy_method.d.ts +7 -8
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +27 -32
- package/dest/contract/deploy_proven_tx.d.ts +2 -3
- package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.d.ts +2 -3
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +4 -4
- package/dest/contract/protocol_contracts.d.ts +1 -1
- package/dest/contract/protocol_contracts.d.ts.map +1 -1
- package/dest/contract/proven_tx.d.ts +3 -4
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.d.ts +4 -16
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +6 -37
- package/dest/contract/unsafe_contract.d.ts +1 -1
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.d.ts +17 -0
- package/dest/contract/wait_for_proven.d.ts.map +1 -0
- package/dest/contract/wait_for_proven.js +17 -0
- package/dest/deployment/broadcast_function.js +12 -8
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/register_class.d.ts +1 -1
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +6 -11
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +3 -2
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +12 -8
- package/dest/ethereum/portal_manager.d.ts +20 -11
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +64 -30
- package/dest/fee/fee_juice_payment_method.d.ts +3 -3
- package/dest/fee/fee_juice_payment_method.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method.js +3 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +4 -4
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
- package/dest/fee/private_fee_payment_method.d.ts +6 -6
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +13 -12
- package/dest/fee/public_fee_payment_method.d.ts +7 -7
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +10 -11
- package/dest/fee/utils.d.ts +13 -0
- package/dest/fee/utils.d.ts.map +1 -0
- package/dest/fee/utils.js +32 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/test/aztec_cheat_codes.d.ts +2 -2
- package/dest/test/aztec_cheat_codes.d.ts.map +1 -1
- package/dest/test/aztec_cheat_codes.js +3 -3
- package/dest/utils/authwit.d.ts +16 -9
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +26 -35
- package/dest/wallet/account_wallet.d.ts +6 -6
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +15 -17
- package/dest/wallet/base_wallet.d.ts +12 -35
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +11 -64
- package/dest/wallet/index.d.ts +2 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +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 -6
- package/dest/wallet/wallet.d.ts +11 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/account/{contract.ts → account_contract.ts} +17 -4
- package/src/account/index.ts +2 -3
- package/src/account/interface.ts +1 -12
- package/src/account_manager/account_manager.ts +235 -0
- package/src/account_manager/deploy_account_method.ts +35 -15
- package/src/account_manager/deploy_account_sent_tx.ts +4 -4
- package/src/account_manager/index.ts +1 -227
- package/src/api/account.ts +2 -8
- package/src/api/contract.ts +5 -5
- package/src/api/fee.ts +1 -1
- package/src/api/utils.ts +1 -1
- package/src/api/wallet.ts +7 -1
- package/src/contract/base_contract_interaction.ts +32 -88
- package/src/contract/batch_call.ts +40 -43
- package/src/contract/contract.ts +1 -1
- package/src/contract/contract_base.ts +1 -1
- package/src/contract/contract_function_interaction.ts +85 -56
- package/src/contract/deploy_method.ts +24 -26
- package/src/contract/deploy_proven_tx.ts +2 -3
- package/src/contract/deploy_sent_tx.ts +6 -6
- package/src/contract/protocol_contracts.ts +1 -1
- package/src/contract/proven_tx.ts +2 -3
- package/src/contract/sent_tx.ts +6 -47
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/deployment/broadcast_function.ts +40 -40
- package/src/deployment/contract_deployer.ts +1 -1
- package/src/deployment/register_class.ts +9 -22
- package/src/entrypoint/default_multi_call_entrypoint.ts +14 -7
- package/src/ethereum/portal_manager.ts +73 -24
- package/src/fee/fee_juice_payment_method.ts +4 -5
- package/src/fee/fee_juice_payment_method_with_claim.ts +24 -20
- package/src/fee/private_fee_payment_method.ts +29 -28
- package/src/fee/public_fee_payment_method.ts +29 -29
- package/src/fee/utils.ts +39 -0
- package/src/index.ts +1 -1
- package/src/test/aztec_cheat_codes.ts +3 -3
- package/src/utils/authwit.ts +32 -35
- package/src/wallet/account_wallet.ts +18 -17
- package/src/wallet/base_wallet.ts +27 -88
- package/src/wallet/index.ts +2 -2
- package/src/wallet/signerless_wallet.ts +9 -8
- package/src/wallet/wallet.ts +34 -0
- package/dest/account/contract.d.ts.map +0 -1
- package/dest/account/wallet.d.ts +0 -11
- package/dest/account/wallet.d.ts.map +0 -1
- package/dest/api/entrypoint.d.ts +0 -2
- package/dest/api/entrypoint.d.ts.map +0 -1
- package/dest/api/entrypoint.js +0 -1
- package/dest/entrypoint/default_entrypoint.d.ts +0 -12
- package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_entrypoint.js +0 -28
- package/dest/entrypoint/entrypoint.d.ts +0 -39
- package/dest/entrypoint/entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/entrypoint.js +0 -20
- package/dest/entrypoint/payload.d.ts +0 -128
- package/dest/entrypoint/payload.d.ts.map +0 -1
- package/dest/entrypoint/payload.js +0 -143
- package/dest/fee/fee_payment_method.d.ts +0 -22
- package/dest/fee/fee_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_payment_method.js +0 -3
- package/src/account/wallet.ts +0 -13
- package/src/api/entrypoint.ts +0 -1
- package/src/entrypoint/default_entrypoint.ts +0 -39
- package/src/entrypoint/entrypoint.ts +0 -60
- package/src/entrypoint/payload.ts +0 -238
- package/src/fee/fee_payment_method.ts +0 -22
- /package/dest/{account → wallet}/wallet.js +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
|
+
import { mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
1
3
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
4
|
import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, getInitializer } from '@aztec/stdlib/abi';
|
|
3
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -11,10 +13,9 @@ import type { GasSettings } from '@aztec/stdlib/gas';
|
|
|
11
13
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
14
|
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
13
15
|
|
|
14
|
-
import type { Wallet } from '../account/wallet.js';
|
|
15
16
|
import { deployInstance } from '../deployment/deploy_instance.js';
|
|
16
17
|
import { registerContractClass } from '../deployment/register_class.js';
|
|
17
|
-
import
|
|
18
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
18
19
|
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
19
20
|
import type { Contract } from './contract.js';
|
|
20
21
|
import type { ContractBase } from './contract_base.js';
|
|
@@ -76,8 +77,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
76
77
|
*/
|
|
77
78
|
public async create(options: DeployOptions = {}): Promise<TxExecutionRequest> {
|
|
78
79
|
const requestWithoutFee = await this.request(options);
|
|
79
|
-
const fee
|
|
80
|
-
|
|
80
|
+
const { fee: userFee, nonce, cancellable } = options;
|
|
81
|
+
const fee = await this.getFeeOptions(requestWithoutFee, userFee, { nonce, cancellable });
|
|
82
|
+
return this.wallet.createTxExecutionRequest(requestWithoutFee, fee, { nonce, cancellable });
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
// REFACTOR: Having a `request` method with different semantics than the ones in the other
|
|
@@ -91,12 +93,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
91
93
|
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
92
94
|
* it returns a promise for an array instead of a function call directly.
|
|
93
95
|
*/
|
|
94
|
-
public async request(options: DeployOptions = {}): Promise<
|
|
95
|
-
const deployment = await this.
|
|
96
|
+
public async request(options: DeployOptions = {}): Promise<ExecutionPayload> {
|
|
97
|
+
const deployment = await this.getDeploymentExecutionPayload(options);
|
|
96
98
|
|
|
97
|
-
// NOTE: MEGA HACK. Remove with #10007
|
|
98
|
-
// register the contract after generating deployment function calls in order to publicly register the class and (optioanlly) emit its bytecode
|
|
99
|
-
//
|
|
100
99
|
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
|
|
101
100
|
// Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
|
|
102
101
|
// runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
|
|
@@ -105,15 +104,14 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
105
104
|
// once this tx has gone through.
|
|
106
105
|
await this.wallet.registerContract({ artifact: this.artifact, instance: await this.getInstance(options) });
|
|
107
106
|
|
|
108
|
-
const bootstrap = await this.
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
107
|
+
const bootstrap = await this.getInitializeExecutionPayload(options);
|
|
108
|
+
const exec = [deployment, bootstrap];
|
|
109
|
+
const fnCalls = exec.map(exec => exec.calls).flat();
|
|
110
|
+
if (!fnCalls.length) {
|
|
112
111
|
throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`);
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
return mergeExecutionRequestInits(requests, { nonce, cancellable });
|
|
114
|
+
return mergeExecutionPayloads(exec);
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
/**
|
|
@@ -127,12 +125,12 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
127
125
|
}
|
|
128
126
|
|
|
129
127
|
/**
|
|
130
|
-
* Returns
|
|
128
|
+
* Returns the execution payload for registration of the class and deployment of the instance, depending on the provided options.
|
|
131
129
|
* @param options - Deployment options.
|
|
132
|
-
* @returns
|
|
130
|
+
* @returns An execution payload with potentially calls (and bytecode capsule) to the class registerer and instance deployer.
|
|
133
131
|
*/
|
|
134
|
-
protected async
|
|
135
|
-
const calls:
|
|
132
|
+
protected async getDeploymentExecutionPayload(options: DeployOptions = {}): Promise<ExecutionPayload> {
|
|
133
|
+
const calls: ExecutionPayload[] = [];
|
|
136
134
|
|
|
137
135
|
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
138
136
|
const instance = await this.getInstance(options);
|
|
@@ -157,17 +155,17 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
157
155
|
`Creating request for registering contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
|
|
158
156
|
);
|
|
159
157
|
const registerContractClassInteraction = await registerContractClass(this.wallet, this.artifact);
|
|
160
|
-
calls.push(registerContractClassInteraction);
|
|
158
|
+
calls.push(await registerContractClassInteraction.request());
|
|
161
159
|
}
|
|
162
160
|
}
|
|
163
161
|
|
|
164
162
|
// Deploy the contract via the instance deployer.
|
|
165
163
|
if (!options.skipPublicDeployment) {
|
|
166
164
|
const deploymentInteraction = await deployInstance(this.wallet, instance);
|
|
167
|
-
calls.push(deploymentInteraction);
|
|
165
|
+
calls.push(await deploymentInteraction.request());
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
return calls;
|
|
168
|
+
return mergeExecutionPayloads(calls);
|
|
171
169
|
}
|
|
172
170
|
|
|
173
171
|
/**
|
|
@@ -175,8 +173,8 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
175
173
|
* @param options - Deployment options.
|
|
176
174
|
* @returns - An array of function calls.
|
|
177
175
|
*/
|
|
178
|
-
protected async
|
|
179
|
-
const
|
|
176
|
+
protected async getInitializeExecutionPayload(options: DeployOptions): Promise<ExecutionPayload> {
|
|
177
|
+
const executionsPayloads: ExecutionPayload[] = [];
|
|
180
178
|
if (this.constructorArtifact && !options.skipInitialization) {
|
|
181
179
|
const { address } = await this.getInstance(options);
|
|
182
180
|
const constructorCall = new ContractFunctionInteraction(
|
|
@@ -185,9 +183,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
185
183
|
this.constructorArtifact,
|
|
186
184
|
this.args,
|
|
187
185
|
);
|
|
188
|
-
|
|
186
|
+
executionsPayloads.push(await constructorCall.request());
|
|
189
187
|
}
|
|
190
|
-
return
|
|
188
|
+
return mergeExecutionPayloads(executionsPayloads);
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
/**
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
2
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
3
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
4
|
|
|
6
|
-
import type { Wallet } from '../
|
|
5
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
7
6
|
import type { Contract } from './contract.js';
|
|
8
7
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
9
8
|
import { ProvenTx } from './proven_tx.js';
|
|
@@ -13,7 +12,7 @@ import { ProvenTx } from './proven_tx.js';
|
|
|
13
12
|
*/
|
|
14
13
|
export class DeployProvenTx<TContract extends Contract = Contract> extends ProvenTx {
|
|
15
14
|
constructor(
|
|
16
|
-
wallet:
|
|
15
|
+
wallet: Wallet,
|
|
17
16
|
tx: Tx,
|
|
18
17
|
private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
19
18
|
private instanceGetter: () => Promise<ContractInstanceWithAddress>,
|
|
@@ -5,7 +5,7 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
|
5
5
|
import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
6
|
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
|
-
import type { Wallet } from '../
|
|
8
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
9
9
|
import type { Contract } from './contract.js';
|
|
10
10
|
import type { ContractBase } from './contract_base.js';
|
|
11
11
|
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
@@ -29,13 +29,13 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
29
29
|
private log = createLogger('aztecjs:deploy_sent_tx');
|
|
30
30
|
|
|
31
31
|
constructor(
|
|
32
|
-
|
|
32
|
+
wallet: Wallet,
|
|
33
33
|
txHashPromise: Promise<TxHash>,
|
|
34
34
|
private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
35
35
|
/** A getter for the deployed contract instance */
|
|
36
36
|
public instanceGetter: () => Promise<ContractInstanceWithAddress>,
|
|
37
37
|
) {
|
|
38
|
-
super(
|
|
38
|
+
super(wallet, txHashPromise);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -62,9 +62,9 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
protected async getContractObject(wallet?: Wallet): Promise<TContract> {
|
|
65
|
-
const isWallet = (
|
|
66
|
-
!!(
|
|
67
|
-
const contractWallet = wallet ?? (isWallet(this.
|
|
65
|
+
const isWallet = (pxeWalletOrNode: Wallet | AztecNode | PXE): pxeWalletOrNode is Wallet =>
|
|
66
|
+
!!(pxeWalletOrNode as Wallet).createTxExecutionRequest;
|
|
67
|
+
const contractWallet = wallet ?? (isWallet(this.pxeWalletOrNode) && this.pxeWalletOrNode);
|
|
68
68
|
if (!contractWallet) {
|
|
69
69
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
70
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
2
|
|
|
3
|
-
import type { Wallet } from '../
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
4
|
import { UnsafeContract } from './unsafe_contract.js';
|
|
5
5
|
|
|
6
6
|
/** Returns a Contract wrapper for the class registerer. */
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
2
1
|
import { Tx } from '@aztec/stdlib/tx';
|
|
3
2
|
|
|
4
|
-
import type { Wallet } from '../
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
5
4
|
import { SentTx } from './sent_tx.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction.
|
|
9
8
|
*/
|
|
10
9
|
export class ProvenTx extends Tx {
|
|
11
|
-
constructor(protected wallet:
|
|
10
|
+
constructor(protected wallet: Wallet, tx: Tx) {
|
|
12
11
|
super(
|
|
13
12
|
tx.data,
|
|
14
13
|
tx.clientIvcProof,
|
package/src/contract/sent_tx.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
-
import type { AztecNode,
|
|
3
|
+
import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
import { type TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
7
|
+
|
|
6
8
|
/** Options related to waiting for a tx. */
|
|
7
9
|
export type WaitOpts = {
|
|
8
10
|
/** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
|
|
9
11
|
ignoreDroppedReceiptsFor?: number;
|
|
10
12
|
/** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
|
|
11
13
|
timeout?: number;
|
|
12
|
-
/** The maximum time (in seconds) to wait for the transaction to be proven. Defaults to 600. */
|
|
13
|
-
provenTimeout?: number;
|
|
14
14
|
/** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
|
|
15
15
|
interval?: number;
|
|
16
|
-
/** Whether to wait for the tx to be proven. */
|
|
17
|
-
proven?: boolean;
|
|
18
|
-
/** Whether to include information useful for debugging/testing in the receipt. */
|
|
19
|
-
debug?: boolean;
|
|
20
16
|
/** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
|
|
21
17
|
dontThrowOnRevert?: boolean;
|
|
22
18
|
};
|
|
@@ -24,9 +20,7 @@ export type WaitOpts = {
|
|
|
24
20
|
export const DefaultWaitOpts: WaitOpts = {
|
|
25
21
|
ignoreDroppedReceiptsFor: 5,
|
|
26
22
|
timeout: 60,
|
|
27
|
-
provenTimeout: 600,
|
|
28
23
|
interval: 1,
|
|
29
|
-
debug: false,
|
|
30
24
|
};
|
|
31
25
|
|
|
32
26
|
/**
|
|
@@ -34,7 +28,7 @@ export const DefaultWaitOpts: WaitOpts = {
|
|
|
34
28
|
* its hash, receipt, and mining status.
|
|
35
29
|
*/
|
|
36
30
|
export class SentTx {
|
|
37
|
-
constructor(protected
|
|
31
|
+
constructor(protected pxeWalletOrNode: Wallet | AztecNode | PXE, protected txHashPromise: Promise<TxHash>) {}
|
|
38
32
|
|
|
39
33
|
/**
|
|
40
34
|
* Retrieves the transaction hash of the SentTx instance.
|
|
@@ -56,7 +50,7 @@ export class SentTx {
|
|
|
56
50
|
*/
|
|
57
51
|
public async getReceipt(): Promise<TxReceipt> {
|
|
58
52
|
const txHash = await this.getTxHash();
|
|
59
|
-
return await this.
|
|
53
|
+
return await this.pxeWalletOrNode.getTxReceipt(txHash);
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
/**
|
|
@@ -71,32 +65,9 @@ export class SentTx {
|
|
|
71
65
|
`Transaction ${await this.getTxHash()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`,
|
|
72
66
|
);
|
|
73
67
|
}
|
|
74
|
-
if (opts?.proven && receipt.blockNumber !== undefined) {
|
|
75
|
-
await this.waitForProven(receipt.blockNumber, opts);
|
|
76
|
-
}
|
|
77
|
-
if (opts?.debug) {
|
|
78
|
-
const txHash = await this.getTxHash();
|
|
79
|
-
const { data: tx } = (await this.pxeOrNode.getTxEffect(txHash))!;
|
|
80
|
-
receipt.debugInfo = {
|
|
81
|
-
noteHashes: tx.noteHashes,
|
|
82
|
-
nullifiers: tx.nullifiers,
|
|
83
|
-
publicDataWrites: tx.publicDataWrites,
|
|
84
|
-
l2ToL1Msgs: tx.l2ToL1Msgs,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
68
|
return receipt;
|
|
88
69
|
}
|
|
89
70
|
|
|
90
|
-
/**
|
|
91
|
-
* Gets public logs emitted by this tx.
|
|
92
|
-
* @remarks This function will wait for the tx to be mined if it hasn't been already.
|
|
93
|
-
* @returns The requested logs.
|
|
94
|
-
*/
|
|
95
|
-
public async getPublicLogs(): Promise<GetPublicLogsResponse> {
|
|
96
|
-
await this.wait();
|
|
97
|
-
return this.pxeOrNode.getPublicLogs({ txHash: await this.getTxHash() });
|
|
98
|
-
}
|
|
99
|
-
|
|
100
71
|
protected async waitForReceipt(opts?: WaitOpts): Promise<TxReceipt> {
|
|
101
72
|
const txHash = await this.getTxHash();
|
|
102
73
|
const startTime = Date.now();
|
|
@@ -104,7 +75,7 @@ export class SentTx {
|
|
|
104
75
|
|
|
105
76
|
return await retryUntil(
|
|
106
77
|
async () => {
|
|
107
|
-
const txReceipt = await this.
|
|
78
|
+
const txReceipt = await this.pxeWalletOrNode.getTxReceipt(txHash);
|
|
108
79
|
// If receipt is not yet available, try again
|
|
109
80
|
if (txReceipt.status === TxStatus.PENDING) {
|
|
110
81
|
return undefined;
|
|
@@ -126,16 +97,4 @@ export class SentTx {
|
|
|
126
97
|
opts?.interval ?? DefaultWaitOpts.interval,
|
|
127
98
|
);
|
|
128
99
|
}
|
|
129
|
-
|
|
130
|
-
protected async waitForProven(minedBlock: number, opts?: WaitOpts) {
|
|
131
|
-
return await retryUntil(
|
|
132
|
-
async () => {
|
|
133
|
-
const provenBlock = await this.pxeOrNode.getProvenBlockNumber();
|
|
134
|
-
return provenBlock >= minedBlock ? provenBlock : undefined;
|
|
135
|
-
},
|
|
136
|
-
'isProven',
|
|
137
|
-
opts?.provenTimeout ?? DefaultWaitOpts.provenTimeout,
|
|
138
|
-
opts?.interval ?? DefaultWaitOpts.interval,
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
100
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
3
|
|
|
4
|
-
import type { Wallet } from '../
|
|
4
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
5
5
|
import { ContractBase } from './contract_base.js';
|
|
6
6
|
|
|
7
7
|
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
|
+
import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
|
|
4
|
+
import type { TxReceipt } from '../index.js';
|
|
5
|
+
import { DefaultWaitOpts } from './sent_tx.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for waiting for a transaction to be proven.
|
|
9
|
+
*/
|
|
10
|
+
export type WaitForProvenOpts = {
|
|
11
|
+
/** Time to wait for the tx to be proven before timing out */
|
|
12
|
+
provenTimeout?: number;
|
|
13
|
+
/** Ellapsed time between polls to the node */
|
|
14
|
+
interval?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const DefaultWaitForProvenOpts: WaitForProvenOpts = {
|
|
18
|
+
provenTimeout: 600,
|
|
19
|
+
interval: DefaultWaitOpts.interval,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Wait for a transaction to be proven by polling the node
|
|
24
|
+
*/
|
|
25
|
+
export async function waitForProven(pxeOrNode: PXE | AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts) {
|
|
26
|
+
if (!receipt.blockNumber) {
|
|
27
|
+
throw new Error(`Cannot wait for proven: receipt of tx ${receipt.txHash} does not have a block number`);
|
|
28
|
+
}
|
|
29
|
+
return await retryUntil(
|
|
30
|
+
async () => {
|
|
31
|
+
const provenBlock = await pxeOrNode.getProvenBlockNumber();
|
|
32
|
+
return provenBlock >= receipt.blockNumber! ? provenBlock : undefined;
|
|
33
|
+
},
|
|
34
|
+
'isProven',
|
|
35
|
+
opts?.provenTimeout ?? DefaultWaitForProvenOpts.provenTimeout,
|
|
36
|
+
opts?.interval ?? DefaultWaitForProvenOpts.interval,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -59,31 +59,31 @@ export async function broadcastPrivateFunction(
|
|
|
59
59
|
const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
|
|
60
60
|
|
|
61
61
|
const registerer = await getRegistererContract(wallet);
|
|
62
|
-
const fn = registerer.methods.broadcast_private_function(
|
|
63
|
-
contractClass.id,
|
|
64
|
-
artifactMetadataHash,
|
|
65
|
-
unconstrainedFunctionsArtifactTreeRoot,
|
|
66
|
-
privateFunctionTreeSiblingPath,
|
|
67
|
-
privateFunctionTreeLeafIndex,
|
|
68
|
-
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
69
|
-
artifactTreeLeafIndex,
|
|
70
|
-
// eslint-disable-next-line camelcase
|
|
71
|
-
{ selector, metadata_hash: functionMetadataHash, vk_hash: vkHash },
|
|
72
|
-
);
|
|
73
|
-
|
|
74
62
|
const bytecode = bufferAsFields(
|
|
75
63
|
privateFunctionArtifact.bytecode,
|
|
76
64
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
77
65
|
);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
return registerer.methods
|
|
67
|
+
.broadcast_private_function(
|
|
68
|
+
contractClass.id,
|
|
69
|
+
artifactMetadataHash,
|
|
70
|
+
unconstrainedFunctionsArtifactTreeRoot,
|
|
71
|
+
privateFunctionTreeSiblingPath,
|
|
72
|
+
privateFunctionTreeLeafIndex,
|
|
73
|
+
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
74
|
+
artifactTreeLeafIndex,
|
|
75
|
+
// eslint-disable-next-line camelcase
|
|
76
|
+
{ selector, metadata_hash: functionMetadataHash, vk_hash: vkHash },
|
|
77
|
+
)
|
|
78
|
+
.with({
|
|
79
|
+
capsules: [
|
|
80
|
+
new Capsule(
|
|
81
|
+
ProtocolContractAddress.ContractClassRegisterer,
|
|
82
|
+
new Fr(REGISTERER_CONTRACT_BYTECODE_CAPSULE_SLOT),
|
|
83
|
+
bytecode,
|
|
84
|
+
),
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -122,27 +122,27 @@ export async function broadcastUnconstrainedFunction(
|
|
|
122
122
|
} = await createUnconstrainedFunctionMembershipProof(selector, artifact);
|
|
123
123
|
|
|
124
124
|
const registerer = await getRegistererContract(wallet);
|
|
125
|
-
const fn = registerer.methods.broadcast_unconstrained_function(
|
|
126
|
-
contractClass.id,
|
|
127
|
-
artifactMetadataHash,
|
|
128
|
-
privateFunctionsArtifactTreeRoot,
|
|
129
|
-
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
130
|
-
artifactTreeLeafIndex,
|
|
131
|
-
// eslint-disable-next-line camelcase
|
|
132
|
-
{ selector, metadata_hash: functionMetadataHash },
|
|
133
|
-
);
|
|
134
|
-
|
|
135
125
|
const bytecode = bufferAsFields(
|
|
136
126
|
unconstrainedFunctionArtifact.bytecode,
|
|
137
127
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
138
128
|
);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
return registerer.methods
|
|
130
|
+
.broadcast_unconstrained_function(
|
|
131
|
+
contractClass.id,
|
|
132
|
+
artifactMetadataHash,
|
|
133
|
+
privateFunctionsArtifactTreeRoot,
|
|
134
|
+
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
135
|
+
artifactTreeLeafIndex,
|
|
136
|
+
// eslint-disable-next-line camelcase
|
|
137
|
+
{ selector, metadata_hash: functionMetadataHash },
|
|
138
|
+
)
|
|
139
|
+
.with({
|
|
140
|
+
capsules: [
|
|
141
|
+
new Capsule(
|
|
142
|
+
ProtocolContractAddress.ContractClassRegisterer,
|
|
143
|
+
new Fr(REGISTERER_CONTRACT_BYTECODE_CAPSULE_SLOT),
|
|
144
|
+
bytecode,
|
|
145
|
+
),
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
148
|
}
|
|
@@ -2,9 +2,9 @@ import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
4
|
|
|
5
|
-
import type { Wallet } from '../account/wallet.js';
|
|
6
5
|
import { Contract } from '../contract/contract.js';
|
|
7
6
|
import { DeployMethod } from '../contract/deploy_method.js';
|
|
7
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A class for deploying contract.
|
|
@@ -9,36 +9,23 @@ import type { ContractFunctionInteraction } from '../contract/contract_function_
|
|
|
9
9
|
import { getRegistererContract } from '../contract/protocol_contracts.js';
|
|
10
10
|
import type { Wallet } from '../wallet/index.js';
|
|
11
11
|
|
|
12
|
-
const defaultEmitPublicBytecode =
|
|
13
|
-
// guard against `process` not being defined (e.g. in the browser)
|
|
14
|
-
typeof process === 'object' && typeof process.env === 'object'
|
|
15
|
-
? ['1', 'true', 'yes', ''].includes(process.env.AZTEC_EMIT_PUBLIC_BYTECODE ?? '')
|
|
16
|
-
: true;
|
|
17
|
-
|
|
18
12
|
/** Sets up a call to register a contract class given its artifact. */
|
|
19
13
|
export async function registerContractClass(
|
|
20
14
|
wallet: Wallet,
|
|
21
15
|
artifact: ContractArtifact,
|
|
22
|
-
emitPublicBytecode = defaultEmitPublicBytecode,
|
|
23
16
|
): Promise<ContractFunctionInteraction> {
|
|
24
17
|
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
|
|
25
18
|
await getContractClassFromArtifact(artifact);
|
|
26
19
|
const registerer = await getRegistererContract(wallet);
|
|
27
|
-
const fn = registerer.methods.register(
|
|
28
|
-
artifactHash,
|
|
29
|
-
privateFunctionsRoot,
|
|
30
|
-
publicBytecodeCommitment,
|
|
31
|
-
emitPublicBytecode,
|
|
32
|
-
);
|
|
33
20
|
|
|
34
21
|
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
return registerer.methods.register(artifactHash, privateFunctionsRoot, publicBytecodeCommitment).with({
|
|
23
|
+
capsules: [
|
|
24
|
+
new Capsule(
|
|
25
|
+
ProtocolContractAddress.ContractClassRegisterer,
|
|
26
|
+
new Fr(REGISTERER_CONTRACT_BYTECODE_CAPSULE_SLOT),
|
|
27
|
+
encodedBytecode,
|
|
28
|
+
),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
44
31
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { EncodedCallsForEntrypoint } from '@aztec/entrypoints/encoding';
|
|
2
|
+
import type { EntrypointInterface, FeeOptions } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
5
|
import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
|
|
3
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
7
|
import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
8
|
|
|
6
|
-
import { type EntrypointInterface, EntrypointPayload, type ExecutionRequestInit } from './entrypoint.js';
|
|
7
|
-
|
|
8
9
|
/**
|
|
9
10
|
* Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
|
|
10
11
|
*/
|
|
@@ -15,18 +16,24 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
15
16
|
private address: AztecAddress = ProtocolContractAddress.MultiCallEntrypoint,
|
|
16
17
|
) {}
|
|
17
18
|
|
|
18
|
-
async createTxExecutionRequest(
|
|
19
|
-
|
|
20
|
-
const
|
|
19
|
+
async createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions): Promise<TxExecutionRequest> {
|
|
20
|
+
// Initial request with calls, authWitnesses and capsules
|
|
21
|
+
const { calls, authWitnesses, capsules, extraHashedArgs } = exec;
|
|
22
|
+
|
|
23
|
+
// Encode the calls
|
|
24
|
+
const encodedCalls = await EncodedCallsForEntrypoint.fromAppExecution(calls);
|
|
25
|
+
|
|
26
|
+
// Obtain the entrypoint hashed args, built from the encoded calls
|
|
21
27
|
const abi = this.getEntrypointAbi();
|
|
22
|
-
const entrypointHashedArgs = await HashedValues.fromValues(encodeArguments(abi, [
|
|
28
|
+
const entrypointHashedArgs = await HashedValues.fromValues(encodeArguments(abi, [encodedCalls]));
|
|
23
29
|
|
|
30
|
+
// Assemble the tx request
|
|
24
31
|
const txRequest = TxExecutionRequest.from({
|
|
25
32
|
firstCallArgsHash: entrypointHashedArgs.hash,
|
|
26
33
|
origin: this.address,
|
|
27
34
|
functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
|
|
28
35
|
txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
|
|
29
|
-
argsOfCalls: [...
|
|
36
|
+
argsOfCalls: [...encodedCalls.hashedArguments, entrypointHashedArgs, ...extraHashedArgs],
|
|
30
37
|
authWitnesses,
|
|
31
38
|
capsules,
|
|
32
39
|
});
|