@aztec/aztec.js 3.0.0-canary.a9708bd → 3.0.0-devnet.2
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 +60 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +59 -0
- package/dest/account/account_contract.d.ts +5 -5
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_contract.js +0 -1
- package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
- package/dest/account/account_with_secret_key.d.ts.map +1 -0
- package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
- package/dest/account/index.d.ts +1 -4
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -4
- package/dest/account/signerless_account.d.ts +24 -0
- package/dest/account/signerless_account.d.ts.map +1 -0
- package/dest/account/signerless_account.js +27 -0
- package/dest/api/abi.d.ts +1 -0
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/account.d.ts +4 -2
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +3 -1
- package/dest/api/addresses.d.ts +1 -0
- package/dest/api/addresses.d.ts.map +1 -1
- package/dest/api/addresses.js +1 -0
- package/dest/api/authorization.d.ts +2 -0
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +2 -0
- package/dest/api/block.d.ts +3 -0
- package/dest/api/block.d.ts.map +1 -0
- package/dest/api/block.js +2 -0
- package/dest/api/contract.d.ts +4 -5
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -3
- package/dest/api/crypto.d.ts +2 -0
- package/dest/api/crypto.d.ts.map +1 -0
- package/dest/api/crypto.js +1 -0
- package/dest/api/ethereum.d.ts +0 -1
- package/dest/api/ethereum.d.ts.map +1 -1
- package/dest/api/ethereum.js +0 -1
- package/dest/api/events.d.ts +12 -0
- package/dest/api/events.d.ts.map +1 -0
- package/dest/api/events.js +30 -0
- package/dest/api/fee.d.ts +1 -2
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +0 -1
- package/dest/api/keys.d.ts +4 -0
- package/dest/api/keys.d.ts.map +1 -0
- package/dest/api/keys.js +3 -0
- package/dest/api/log.d.ts +1 -0
- package/dest/api/log.d.ts.map +1 -1
- package/dest/api/log.js +1 -0
- package/dest/api/messaging.d.ts +3 -0
- package/dest/api/messaging.d.ts.map +1 -0
- package/dest/api/messaging.js +2 -0
- package/dest/api/node.d.ts +21 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +18 -0
- package/dest/api/note.d.ts +2 -0
- package/dest/api/note.d.ts.map +1 -0
- package/dest/api/note.js +1 -0
- package/dest/api/protocol.d.ts +3 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +2 -0
- package/dest/api/trees.d.ts +3 -0
- package/dest/api/trees.d.ts.map +1 -0
- package/dest/api/trees.js +2 -0
- package/dest/api/tx.d.ts +2 -0
- package/dest/api/tx.d.ts.map +1 -0
- package/dest/api/tx.js +1 -0
- package/dest/api/utils.d.ts +10 -6
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +10 -5
- package/dest/api/wallet.d.ts +4 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +4 -1
- package/dest/contract/base_contract_interaction.d.ts +6 -48
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +6 -106
- package/dest/contract/batch_call.d.ts +6 -14
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +42 -52
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +2 -12
- package/dest/contract/contract_base.d.ts +1 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +29 -40
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +41 -53
- package/dest/contract/deploy_method.d.ts +63 -56
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +68 -86
- package/dest/contract/deploy_sent_tx.d.ts +0 -1
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +7 -10
- package/dest/contract/interaction_options.d.ts +74 -19
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +51 -3
- package/dest/contract/sent_tx.d.ts +3 -3
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +5 -5
- package/dest/contract/wait_for_proven.d.ts +3 -3
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +2 -2
- package/dest/deployment/publish_instance.d.ts +1 -1
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +2 -5
- package/dest/ethereum/portal_manager.d.ts +3 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +3 -5
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +12 -7
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +21 -12
- package/dest/fee/fee_payment_method.d.ts +26 -0
- package/dest/fee/fee_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_payment_method.js +3 -0
- package/dest/fee/private_fee_payment_method.d.ts +22 -5
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +34 -13
- package/dest/fee/public_fee_payment_method.d.ts +22 -5
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +37 -14
- package/dest/fee/sponsored_fee_payment.d.ts +2 -0
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +4 -0
- package/dest/utils/authwit.d.ts +77 -25
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +219 -24
- package/dest/utils/cross_chain.d.ts +24 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +30 -0
- package/dest/utils/fee_juice.d.ts +3 -2
- package/dest/utils/fee_juice.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +3 -2
- package/dest/{fee → wallet}/account_entrypoint_meta_payment_method.d.ts +13 -10
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
- package/dest/wallet/account_manager.d.ts +69 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +113 -0
- package/dest/wallet/base_wallet.d.ts +78 -35
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +216 -48
- package/dest/wallet/deploy_account_method.d.ts +52 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +77 -0
- package/dest/wallet/index.d.ts +2 -15
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +2 -19
- package/dest/wallet/wallet.d.ts +2473 -6
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +202 -3
- package/package.json +25 -21
- package/src/account/account.ts +97 -0
- package/src/account/account_contract.ts +4 -6
- package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
- package/src/account/index.ts +1 -4
- package/src/account/signerless_account.ts +46 -0
- package/src/api/abi.ts +11 -0
- package/src/api/account.ts +4 -2
- package/src/api/addresses.ts +1 -0
- package/src/api/authorization.ts +11 -0
- package/src/api/block.ts +2 -0
- package/src/api/contract.ts +16 -8
- package/src/api/crypto.ts +1 -0
- package/src/api/ethereum.ts +0 -1
- package/src/api/events.ts +44 -0
- package/src/api/fee.ts +1 -2
- package/src/api/keys.ts +8 -0
- package/src/api/log.ts +1 -0
- package/src/api/messaging.ts +2 -0
- package/src/api/node.ts +20 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +2 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +11 -0
- package/src/api/utils.ts +12 -19
- package/src/api/wallet.ts +33 -5
- package/src/contract/base_contract_interaction.ts +9 -138
- package/src/contract/batch_call.ts +52 -61
- package/src/contract/contract.ts +2 -12
- package/src/contract/contract_function_interaction.ts +65 -97
- package/src/contract/deploy_method.ts +117 -99
- package/src/contract/deploy_sent_tx.ts +4 -10
- package/src/contract/interaction_options.ts +126 -24
- package/src/contract/sent_tx.ts +4 -4
- package/src/contract/wait_for_proven.ts +4 -4
- package/src/deployment/publish_instance.ts +3 -8
- package/src/ethereum/portal_manager.ts +4 -12
- package/src/fee/fee_juice_payment_method_with_claim.ts +26 -17
- package/src/fee/fee_payment_method.ts +26 -0
- package/src/fee/private_fee_payment_method.ts +60 -41
- package/src/fee/public_fee_payment_method.ts +73 -49
- package/src/fee/sponsored_fee_payment.ts +6 -0
- package/src/utils/authwit.ts +250 -38
- package/src/utils/cross_chain.ts +53 -0
- package/src/utils/fee_juice.ts +4 -3
- package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
- package/src/wallet/account_manager.ts +154 -0
- package/src/wallet/base_wallet.ts +287 -78
- package/src/wallet/deploy_account_method.ts +125 -0
- package/src/wallet/index.ts +2 -32
- package/src/wallet/wallet.ts +357 -29
- package/dest/account_manager/account_manager.d.ts +0 -119
- package/dest/account_manager/account_manager.d.ts.map +0 -1
- package/dest/account_manager/account_manager.js +0 -202
- package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_sent_tx.js +0 -29
- package/dest/account_manager/index.d.ts +0 -3
- package/dest/account_manager/index.d.ts.map +0 -1
- package/dest/account_manager/index.js +0 -2
- package/dest/api/interfaces.d.ts +0 -2
- package/dest/api/interfaces.d.ts.map +0 -1
- package/dest/api/interfaces.js +0 -1
- package/dest/api/log_id.d.ts +0 -2
- package/dest/api/log_id.d.ts.map +0 -1
- package/dest/api/log_id.js +0 -1
- package/dest/api/rpc.d.ts +0 -3
- package/dest/api/rpc.d.ts.map +0 -1
- package/dest/api/rpc.js +0 -2
- package/dest/api/tx_hash.d.ts +0 -2
- package/dest/api/tx_hash.d.ts.map +0 -1
- package/dest/api/tx_hash.js +0 -1
- package/dest/contract/deploy_proven_tx.d.ts +0 -21
- package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
- package/dest/contract/deploy_proven_tx.js +0 -21
- package/dest/contract/proven_tx.d.ts +0 -21
- package/dest/contract/proven_tx.d.ts.map +0 -1
- package/dest/contract/proven_tx.js +0 -23
- package/dest/ethereum/l1_contracts.d.ts +0 -3
- package/dest/ethereum/l1_contracts.d.ts.map +0 -1
- package/dest/ethereum/l1_contracts.js +0 -13
- package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +0 -1
- package/dest/fee/account_entrypoint_meta_payment_method.js +0 -64
- package/dest/fee/fee_juice_payment_method.d.ts +0 -14
- package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_juice_payment_method.js +0 -21
- package/dest/fee/utils.d.ts +0 -13
- package/dest/fee/utils.d.ts.map +0 -1
- package/dest/fee/utils.js +0 -32
- package/dest/index.d.ts +0 -59
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -62
- package/dest/rpc_clients/node/index.d.ts +0 -12
- package/dest/rpc_clients/node/index.d.ts.map +0 -1
- package/dest/rpc_clients/node/index.js +0 -72
- package/dest/rpc_clients/pxe_client.d.ts +0 -10
- package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
- package/dest/rpc_clients/pxe_client.js +0 -23
- package/dest/utils/pxe.d.ts +0 -4
- package/dest/utils/pxe.d.ts.map +0 -1
- package/dest/utils/pxe.js +0 -14
- package/dest/wallet/account_wallet.d.ts +0 -74
- package/dest/wallet/account_wallet.d.ts.map +0 -1
- package/dest/wallet/account_wallet.js +0 -232
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.d.ts +0 -23
- package/dest/wallet/signerless_wallet.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.js +0 -33
- package/src/account_manager/account_manager.ts +0 -276
- package/src/account_manager/deploy_account_sent_tx.ts +0 -46
- package/src/account_manager/index.ts +0 -2
- package/src/api/interfaces.ts +0 -1
- package/src/api/log_id.ts +0 -1
- package/src/api/rpc.ts +0 -2
- package/src/api/tx_hash.ts +0 -1
- package/src/contract/deploy_proven_tx.ts +0 -45
- package/src/contract/proven_tx.ts +0 -36
- package/src/ethereum/l1_contracts.ts +0 -21
- package/src/fee/account_entrypoint_meta_payment_method.ts +0 -89
- package/src/fee/fee_juice_payment_method.ts +0 -25
- package/src/fee/utils.ts +0 -39
- package/src/index.ts +0 -85
- package/src/rpc_clients/node/index.ts +0 -77
- package/src/rpc_clients/pxe_client.ts +0 -25
- package/src/utils/pxe.ts +0 -17
- package/src/wallet/account_wallet.ts +0 -246
- package/src/wallet/signerless_wallet.ts +0 -56
|
@@ -1,49 +1,21 @@
|
|
|
1
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
2
|
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import {
|
|
6
|
-
type Capsule,
|
|
7
|
-
type HashedValues,
|
|
8
|
-
type OffchainEffect,
|
|
9
|
-
type SimulationStats,
|
|
10
|
-
type TxExecutionRequest,
|
|
11
|
-
type TxProfileResult,
|
|
12
|
-
collectOffchainEffects,
|
|
13
|
-
} from '@aztec/stdlib/tx';
|
|
5
|
+
import { type Capsule, type HashedValues, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
14
6
|
|
|
15
7
|
import type { Wallet } from '../wallet/wallet.js';
|
|
16
8
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
import { getGasLimits } from './get_gas_limits.js';
|
|
10
|
+
import {
|
|
11
|
+
type ProfileInteractionOptions,
|
|
12
|
+
type RequestInteractionOptions,
|
|
13
|
+
type SimulateInteractionOptions,
|
|
14
|
+
type SimulationReturn,
|
|
15
|
+
toProfileOptions,
|
|
16
|
+
toSimulateOptions,
|
|
22
17
|
} from './interaction_options.js';
|
|
23
18
|
|
|
24
|
-
/**
|
|
25
|
-
* Represents the result type of a simulation.
|
|
26
|
-
* By default, it will just be the return value of the simulated function
|
|
27
|
-
* so contract interfaces behave as plain functions. If `includeMetadata` is set to true in `SimulateMethodOptions` on the input of `simulate(...)`,
|
|
28
|
-
* it will provide extra information.
|
|
29
|
-
*/
|
|
30
|
-
type SimulationReturn<T extends boolean | undefined> = T extends true
|
|
31
|
-
? {
|
|
32
|
-
/**
|
|
33
|
-
* Additional stats about the simulation
|
|
34
|
-
*/
|
|
35
|
-
stats: SimulationStats;
|
|
36
|
-
/**
|
|
37
|
-
* Offchain effects generated during the simulation
|
|
38
|
-
*/
|
|
39
|
-
offchainEffects: OffchainEffect[];
|
|
40
|
-
/**
|
|
41
|
-
* Return value of the function
|
|
42
|
-
*/
|
|
43
|
-
result: any;
|
|
44
|
-
}
|
|
45
|
-
: any;
|
|
46
|
-
|
|
47
19
|
/**
|
|
48
20
|
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
49
21
|
* It contains available interactions one can call on a method, including view.
|
|
@@ -64,69 +36,71 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
64
36
|
}
|
|
65
37
|
}
|
|
66
38
|
|
|
67
|
-
// docs:start:create
|
|
68
39
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @
|
|
72
|
-
* @returns A Promise that resolves to a transaction instance.
|
|
40
|
+
* Returns the encoded function call wrapped by this interaction
|
|
41
|
+
* Useful when generating authwits
|
|
42
|
+
* @returns An encoded function call
|
|
73
43
|
*/
|
|
74
|
-
public
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
44
|
+
public async getFunctionCall() {
|
|
45
|
+
const args = encodeArguments(this.functionDao, this.args);
|
|
46
|
+
return {
|
|
47
|
+
name: this.functionDao.name,
|
|
48
|
+
args,
|
|
49
|
+
selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
|
|
50
|
+
type: this.functionDao.functionType,
|
|
51
|
+
to: this.contractAddress,
|
|
52
|
+
isStatic: this.functionDao.isStatic,
|
|
53
|
+
hideMsgSender: false /** Only set to `true` for enqueued public function calls */,
|
|
54
|
+
returnTypes: this.functionDao.returnTypes,
|
|
55
|
+
};
|
|
85
56
|
}
|
|
86
57
|
|
|
87
|
-
// docs:start:request
|
|
88
58
|
/**
|
|
89
|
-
* Returns
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
* @returns An execution payload wrapped in promise.
|
|
59
|
+
* Returns the execution payload that allows this operation to happen on chain.
|
|
60
|
+
* @param options - Configuration options.
|
|
61
|
+
* @returns The execution payload for this operation
|
|
93
62
|
*/
|
|
94
|
-
public override async request(options:
|
|
95
|
-
|
|
96
|
-
const args = encodeArguments(this.functionDao, this.args);
|
|
97
|
-
const calls = [
|
|
98
|
-
{
|
|
99
|
-
name: this.functionDao.name,
|
|
100
|
-
args,
|
|
101
|
-
selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
|
|
102
|
-
type: this.functionDao.functionType,
|
|
103
|
-
to: this.contractAddress,
|
|
104
|
-
isStatic: this.functionDao.isStatic,
|
|
105
|
-
returnTypes: this.functionDao.returnTypes,
|
|
106
|
-
},
|
|
107
|
-
];
|
|
63
|
+
public override async request(options: RequestInteractionOptions = {}): Promise<ExecutionPayload> {
|
|
64
|
+
const calls = [await this.getFunctionCall()];
|
|
108
65
|
const { authWitnesses, capsules } = options;
|
|
109
|
-
|
|
66
|
+
const feeExecutionPayload = options.fee?.paymentMethod
|
|
67
|
+
? await options.fee.paymentMethod.getExecutionPayload()
|
|
68
|
+
: undefined;
|
|
69
|
+
const functionExecutionPayload = new ExecutionPayload(
|
|
110
70
|
calls,
|
|
111
71
|
this.authWitnesses.concat(authWitnesses ?? []),
|
|
112
72
|
this.capsules.concat(capsules ?? []),
|
|
113
73
|
this.extraHashedArgs,
|
|
114
74
|
);
|
|
75
|
+
const finalExecutionPayload = feeExecutionPayload
|
|
76
|
+
? mergeExecutionPayloads([feeExecutionPayload, functionExecutionPayload])
|
|
77
|
+
: functionExecutionPayload;
|
|
78
|
+
return finalExecutionPayload;
|
|
115
79
|
}
|
|
116
80
|
|
|
117
81
|
// docs:start:simulate
|
|
118
82
|
/**
|
|
119
|
-
* Simulate a transaction and get its
|
|
83
|
+
* Simulate a transaction and get information from its execution.
|
|
120
84
|
* Differs from prove in a few important ways:
|
|
121
|
-
* 1. It returns the values of the function execution
|
|
85
|
+
* 1. It returns the values of the function execution, plus additional metadata if requested
|
|
122
86
|
* 2. It supports `utility`, `private` and `public` functions
|
|
123
87
|
*
|
|
124
|
-
* @param options - An optional object containing additional configuration for the
|
|
125
|
-
* @returns
|
|
88
|
+
* @param options - An optional object containing additional configuration for the simulation.
|
|
89
|
+
* @returns Depending on the simulation options, this method directly returns the result value of the executed
|
|
90
|
+
* function or a rich object containing extra metadata, such as estimated gas costs (if requested via options),
|
|
91
|
+
* execution statistics and emitted offchain effects
|
|
126
92
|
*/
|
|
127
|
-
public async simulate<T extends
|
|
93
|
+
public async simulate<T extends SimulateInteractionOptions>(
|
|
94
|
+
options: T,
|
|
95
|
+
): Promise<SimulationReturn<Exclude<T['fee'], undefined>['estimateGas']>>;
|
|
96
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
97
|
+
public async simulate<T extends SimulateInteractionOptions>(
|
|
98
|
+
options: T,
|
|
99
|
+
): Promise<SimulationReturn<T['includeMetadata']>>;
|
|
128
100
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
129
|
-
public async simulate(
|
|
101
|
+
public async simulate(
|
|
102
|
+
options: SimulateInteractionOptions,
|
|
103
|
+
): Promise<SimulationReturn<typeof options.includeMetadata>> {
|
|
130
104
|
// docs:end:simulate
|
|
131
105
|
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
132
106
|
const utilityResult = await this.wallet.simulateUtility(
|
|
@@ -146,13 +120,8 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
146
120
|
}
|
|
147
121
|
}
|
|
148
122
|
|
|
149
|
-
const
|
|
150
|
-
const simulatedTx = await this.wallet.simulateTx(
|
|
151
|
-
txRequest,
|
|
152
|
-
true /* simulatePublic */,
|
|
153
|
-
options.skipTxValidation,
|
|
154
|
-
options.skipFeeEnforcement ?? true,
|
|
155
|
-
);
|
|
123
|
+
const executionPayload = await this.request(options);
|
|
124
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, await toSimulateOptions(options));
|
|
156
125
|
|
|
157
126
|
let rawReturnValues;
|
|
158
127
|
if (this.functionDao.functionType == FunctionType.PRIVATE) {
|
|
@@ -171,11 +140,16 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
171
140
|
|
|
172
141
|
const returnValue = rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
|
|
173
142
|
|
|
174
|
-
if (options.includeMetadata) {
|
|
143
|
+
if (options.includeMetadata || options.fee?.estimateGas) {
|
|
144
|
+
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
145
|
+
this.log.verbose(
|
|
146
|
+
`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`,
|
|
147
|
+
);
|
|
175
148
|
return {
|
|
176
149
|
stats: simulatedTx.stats,
|
|
177
150
|
offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
|
|
178
151
|
result: returnValue,
|
|
152
|
+
estimatedGas: { gasLimits, teardownGasLimits },
|
|
179
153
|
};
|
|
180
154
|
} else {
|
|
181
155
|
return returnValue;
|
|
@@ -188,19 +162,13 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
188
162
|
*
|
|
189
163
|
* @returns An object containing the function return value and profile result.
|
|
190
164
|
*/
|
|
191
|
-
public async profile(options:
|
|
192
|
-
if (options.from !== AztecAddress.ZERO && !options.from.equals(this.wallet.getAddress())) {
|
|
193
|
-
throw new Error(
|
|
194
|
-
`The address provided as from does not match the wallet address. Expected ${this.wallet.getAddress().toString()}, got ${options.from.toString()}.`,
|
|
195
|
-
);
|
|
196
|
-
}
|
|
165
|
+
public async profile(options: ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
197
166
|
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
198
167
|
throw new Error("Can't profile a utility function.");
|
|
199
168
|
}
|
|
200
|
-
const { authWitnesses, capsules, fee } = options;
|
|
201
169
|
|
|
202
|
-
const
|
|
203
|
-
return await this.wallet.profileTx(
|
|
170
|
+
const executionPayload = await this.request(options);
|
|
171
|
+
return await this.wallet.profileTx(executionPayload, await toProfileOptions(options));
|
|
204
172
|
}
|
|
205
173
|
|
|
206
174
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, getInitializer } from '@aztec/stdlib/abi';
|
|
5
4
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -10,9 +9,8 @@ import {
|
|
|
10
9
|
getContractClassFromArtifact,
|
|
11
10
|
getContractInstanceFromInstantiationParams,
|
|
12
11
|
} from '@aztec/stdlib/contract';
|
|
13
|
-
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
14
12
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
15
|
-
import type
|
|
13
|
+
import { type Capsule, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
16
14
|
|
|
17
15
|
import { publishContractClass } from '../deployment/publish_class.js';
|
|
18
16
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
@@ -21,30 +19,71 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
21
19
|
import type { Contract } from './contract.js';
|
|
22
20
|
import type { ContractBase } from './contract_base.js';
|
|
23
21
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
24
|
-
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
25
22
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
26
|
-
import
|
|
23
|
+
import { getGasLimits } from './get_gas_limits.js';
|
|
24
|
+
import {
|
|
25
|
+
type ProfileInteractionOptions,
|
|
26
|
+
type RequestInteractionOptions,
|
|
27
|
+
type SendInteractionOptions,
|
|
28
|
+
type SimulationInteractionFeeOptions,
|
|
29
|
+
type SimulationReturn,
|
|
30
|
+
toProfileOptions,
|
|
31
|
+
toSendOptions,
|
|
32
|
+
toSimulateOptions,
|
|
33
|
+
} from './interaction_options.js';
|
|
27
34
|
|
|
28
35
|
/**
|
|
29
36
|
* Options for deploying a contract on the Aztec network.
|
|
30
|
-
* Allows specifying a contract address salt
|
|
37
|
+
* Allows specifying a contract address salt and different options to tweak contract publication
|
|
38
|
+
* and initialization
|
|
31
39
|
*/
|
|
32
|
-
|
|
33
|
-
export type DeployOptions = {
|
|
40
|
+
export type RequestDeployOptions = RequestInteractionOptions & {
|
|
34
41
|
/** An optional salt value used to deterministically calculate the contract address. */
|
|
35
42
|
contractAddressSalt?: Fr;
|
|
36
|
-
/**
|
|
37
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Deployer address that will be used for the deployed contract's address computation.
|
|
45
|
+
* If set to 0, the sender's address won't be mixed in
|
|
46
|
+
*/
|
|
47
|
+
deployer?: AztecAddress;
|
|
38
48
|
/** Skip contract class publication. */
|
|
39
49
|
skipClassPublication?: boolean;
|
|
40
50
|
/** Skip publication, instead just privately initialize the contract. */
|
|
41
51
|
skipInstancePublication?: boolean;
|
|
42
52
|
/** Skip contract initialization. */
|
|
43
53
|
skipInitialization?: boolean;
|
|
44
|
-
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Extends the deployment options with the required parameters to send the transaction
|
|
58
|
+
*/
|
|
59
|
+
export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
|
|
60
|
+
/**
|
|
61
|
+
* Set to true to *not* include the sender in the address computation. This option
|
|
62
|
+
* is mutually exclusive with "deployer"
|
|
63
|
+
*/
|
|
64
|
+
universalDeploy?: boolean;
|
|
65
|
+
} & Pick<SendInteractionOptions, 'from' | 'fee'>;
|
|
45
66
|
// docs:end:deploy_options
|
|
46
67
|
// TODO(@spalladino): Add unit tests for this class!
|
|
47
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Options for simulating the deployment of a contract
|
|
71
|
+
* Allows skipping certain validations and computing gas estimations
|
|
72
|
+
*/
|
|
73
|
+
export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
74
|
+
/** The fee options for the transaction. */
|
|
75
|
+
fee?: SimulationInteractionFeeOptions;
|
|
76
|
+
/** Simulate without checking for the validity of the resulting transaction,
|
|
77
|
+
* e.g. whether it emits any existing nullifiers. */
|
|
78
|
+
skipTxValidation?: boolean;
|
|
79
|
+
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
80
|
+
skipFeeEnforcement?: boolean;
|
|
81
|
+
/** Whether to include metadata such as offchain effects and performance statistics
|
|
82
|
+
* (e.g. timing information of the different circuits and oracles) in
|
|
83
|
+
* the simulation result, instead of just the return value of the function */
|
|
84
|
+
includeMetadata?: boolean;
|
|
85
|
+
};
|
|
86
|
+
|
|
48
87
|
/**
|
|
49
88
|
* Contract interaction for deployment.
|
|
50
89
|
* Handles class publication, instance publication, and initialization of the contract.
|
|
@@ -67,8 +106,8 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
67
106
|
constructor(
|
|
68
107
|
private publicKeys: PublicKeys,
|
|
69
108
|
wallet: Wallet,
|
|
70
|
-
|
|
71
|
-
|
|
109
|
+
protected artifact: ContractArtifact,
|
|
110
|
+
protected postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
72
111
|
private args: any[] = [],
|
|
73
112
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
74
113
|
authWitnesses: AuthWitness[] = [],
|
|
@@ -79,78 +118,43 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
79
118
|
}
|
|
80
119
|
|
|
81
120
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* - Initialize the contract
|
|
86
|
-
*
|
|
87
|
-
* A tx is not necessary if the function has no public functions nor any
|
|
88
|
-
* initializer function.
|
|
89
|
-
*
|
|
90
|
-
* This function internally calls `request()` and `sign()` methods to prepare
|
|
91
|
-
* the transaction for deployment. The resulting signed transaction can be
|
|
92
|
-
* later sent using the `send()` method.
|
|
93
|
-
*
|
|
94
|
-
* @param options - An object containing optional deployment settings, contractAddressSalt, and from.
|
|
95
|
-
* @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
|
|
96
|
-
*/
|
|
97
|
-
public async create(options: DeployOptions): Promise<TxExecutionRequest> {
|
|
98
|
-
const requestWithoutFee = await this.request(options);
|
|
99
|
-
const { fee: userFee, txNonce, cancellable } = options;
|
|
100
|
-
const fee = await this.getFeeOptions(requestWithoutFee, userFee, { txNonce, cancellable });
|
|
101
|
-
return this.wallet.createTxExecutionRequest(requestWithoutFee, fee, { txNonce, cancellable });
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// REFACTOR: Having a `request` method with different semantics than the ones in the other
|
|
105
|
-
// derived ContractInteractions is confusing. We should unify the flow of all ContractInteractions.
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Returns an array of function calls that represent this operation. Useful as a building
|
|
109
|
-
* block for constructing batch requests.
|
|
110
|
-
* @param options - Deployment options.
|
|
111
|
-
* @returns An array of function calls.
|
|
112
|
-
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
113
|
-
* it returns a promise for an array instead of a function call directly.
|
|
121
|
+
* Returns the execution payload that allows this operation to happen on chain.
|
|
122
|
+
* @param options - Configuration options.
|
|
123
|
+
* @returns The execution payload for this operation
|
|
114
124
|
*/
|
|
115
|
-
public async request(options
|
|
125
|
+
public async request(options?: RequestDeployOptions): Promise<ExecutionPayload> {
|
|
116
126
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
117
127
|
|
|
118
|
-
|
|
119
|
-
// Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
|
|
120
|
-
// runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
|
|
121
|
-
// in case the initializer is public. This hints at the need of having "transient" contracts scoped to a
|
|
122
|
-
// simulation, so we can run the simulation with a set of contracts, but only "commit" them to the wallet
|
|
123
|
-
// once this tx has gone through.
|
|
124
|
-
await this.wallet.registerContract({ artifact: this.artifact, instance: await this.getInstance(options) });
|
|
128
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
125
129
|
|
|
126
130
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
132
|
+
? await options.fee.paymentMethod.getExecutionPayload()
|
|
133
|
+
: undefined;
|
|
134
|
+
const finalExecutionPayload = feeExecutionPayload
|
|
135
|
+
? mergeExecutionPayloads([feeExecutionPayload, publication, initialization])
|
|
136
|
+
: mergeExecutionPayloads([publication, initialization]);
|
|
137
|
+
if (!finalExecutionPayload.calls.length) {
|
|
130
138
|
throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
return
|
|
141
|
+
return finalExecutionPayload;
|
|
134
142
|
}
|
|
135
143
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*/
|
|
142
|
-
public async profile(options: DeployOptions & ProfileMethodOptions): Promise<TxProfileResult> {
|
|
143
|
-
const txRequest = await this.create(options);
|
|
144
|
-
return await this.wallet.profileTx(txRequest, options.profileMode, options.skipProofGeneration, options?.from);
|
|
144
|
+
convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
|
|
145
|
+
return {
|
|
146
|
+
...options,
|
|
147
|
+
deployer: !options?.universalDeploy ? options.from : undefined,
|
|
148
|
+
};
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
/**
|
|
148
|
-
* Adds this contract to the
|
|
152
|
+
* Adds this contract to the wallet and returns the Contract object.
|
|
149
153
|
* @param options - Deployment options.
|
|
150
154
|
*/
|
|
151
|
-
public async register(options
|
|
155
|
+
public async register(options?: RequestDeployOptions): Promise<TContract> {
|
|
152
156
|
const instance = await this.getInstance(options);
|
|
153
|
-
await this.wallet.registerContract(
|
|
157
|
+
await this.wallet.registerContract(instance, this.artifact);
|
|
154
158
|
return this.postDeployCtor(instance.address, this.wallet);
|
|
155
159
|
}
|
|
156
160
|
|
|
@@ -162,7 +166,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
162
166
|
* @param options - Contract creation options.
|
|
163
167
|
* @returns An execution payload with potentially calls (and bytecode capsule) to the class registry and instance registry.
|
|
164
168
|
*/
|
|
165
|
-
protected async getPublicationExecutionPayload(options
|
|
169
|
+
protected async getPublicationExecutionPayload(options?: RequestDeployOptions): Promise<ExecutionPayload> {
|
|
166
170
|
const calls: ExecutionPayload[] = [];
|
|
167
171
|
|
|
168
172
|
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
@@ -178,7 +182,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
// Publish the contract class if it hasn't been published already.
|
|
181
|
-
if (!options
|
|
185
|
+
if (!options?.skipClassPublication) {
|
|
182
186
|
if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
183
187
|
this.log.debug(
|
|
184
188
|
`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
|
|
@@ -193,7 +197,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
// Publish the contract instance:
|
|
196
|
-
if (!options
|
|
200
|
+
if (!options?.skipInstancePublication) {
|
|
197
201
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
198
202
|
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
199
203
|
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
@@ -209,11 +213,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
209
213
|
* @param options - Deployment options.
|
|
210
214
|
* @returns - An array of function calls.
|
|
211
215
|
*/
|
|
212
|
-
protected async getInitializationExecutionPayload(
|
|
213
|
-
options: Omit<DeployOptions, 'from'> = {},
|
|
214
|
-
): Promise<ExecutionPayload> {
|
|
216
|
+
protected async getInitializationExecutionPayload(options?: RequestDeployOptions): Promise<ExecutionPayload> {
|
|
215
217
|
const executionsPayloads: ExecutionPayload[] = [];
|
|
216
|
-
if (this.constructorArtifact && !options
|
|
218
|
+
if (this.constructorArtifact && !options?.skipInitialization) {
|
|
217
219
|
const { address } = await this.getInstance(options);
|
|
218
220
|
const constructorCall = new ContractFunctionInteraction(
|
|
219
221
|
this.wallet,
|
|
@@ -235,7 +237,11 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
235
237
|
* @returns A SentTx object that returns the receipt and the deployed contract instance.
|
|
236
238
|
*/
|
|
237
239
|
public override send(options: DeployOptions): DeploySentTx<TContract> {
|
|
238
|
-
const sendTx = () =>
|
|
240
|
+
const sendTx = async () => {
|
|
241
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
242
|
+
const sendOptions = await toSendOptions(options);
|
|
243
|
+
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
244
|
+
};
|
|
239
245
|
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
240
246
|
return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, () => this.getInstance(options));
|
|
241
247
|
}
|
|
@@ -246,43 +252,55 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
246
252
|
* @param options - An object containing various initialization and publication options.
|
|
247
253
|
* @returns An instance object.
|
|
248
254
|
*/
|
|
249
|
-
public async getInstance(options
|
|
255
|
+
public async getInstance(options?: RequestDeployOptions): Promise<ContractInstanceWithAddress> {
|
|
250
256
|
if (!this.instance) {
|
|
251
257
|
this.instance = await getContractInstanceFromInstantiationParams(this.artifact, {
|
|
252
258
|
constructorArgs: this.args,
|
|
253
|
-
salt: options.
|
|
259
|
+
salt: options?.contractAddressSalt ?? Fr.random(),
|
|
254
260
|
publicKeys: this.publicKeys,
|
|
255
261
|
constructorArtifact: this.constructorArtifact,
|
|
256
|
-
deployer: options
|
|
262
|
+
deployer: options?.deployer ? options.deployer : AztecAddress.ZERO,
|
|
257
263
|
});
|
|
258
264
|
}
|
|
259
265
|
return this.instance;
|
|
260
266
|
}
|
|
261
267
|
|
|
262
268
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @
|
|
269
|
+
* Simulate the deployment
|
|
270
|
+
*
|
|
271
|
+
* @param options - An optional object containing additional configuration for the simulation.
|
|
272
|
+
* @returns A simulation result object containing metadata of the execution, including gas
|
|
273
|
+
* estimations (if requested via options), execution statistics and emitted offchain effects
|
|
266
274
|
*/
|
|
267
|
-
public
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
txProvingResult.stats,
|
|
275
|
+
public async simulate(options: SimulateDeployOptions): Promise<SimulationReturn<true>> {
|
|
276
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
277
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, await toSimulateOptions(options));
|
|
278
|
+
|
|
279
|
+
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
280
|
+
this.log.verbose(
|
|
281
|
+
`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`,
|
|
275
282
|
);
|
|
283
|
+
return {
|
|
284
|
+
stats: simulatedTx.stats!,
|
|
285
|
+
offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
|
|
286
|
+
result: undefined,
|
|
287
|
+
estimatedGas: { gasLimits, teardownGasLimits },
|
|
288
|
+
};
|
|
276
289
|
}
|
|
277
290
|
|
|
278
291
|
/**
|
|
279
|
-
*
|
|
280
|
-
* @param options -
|
|
292
|
+
* Simulate a deployment and profile the gate count for each function in the transaction.
|
|
293
|
+
* @param options - Same options as `send`, plus extra profiling options.
|
|
294
|
+
*
|
|
295
|
+
* @returns An object containing the function return value and profile result.
|
|
281
296
|
*/
|
|
282
|
-
public
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
297
|
+
public async profile(options: DeployOptions & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
298
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
299
|
+
return await this.wallet.profileTx(executionPayload, {
|
|
300
|
+
...(await toProfileOptions(options)),
|
|
301
|
+
profileMode: options.profileMode,
|
|
302
|
+
skipProofGeneration: options.skipProofGeneration,
|
|
303
|
+
});
|
|
286
304
|
}
|
|
287
305
|
|
|
288
306
|
/** Return this deployment address. */
|
|
@@ -2,7 +2,6 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
-
import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
5
|
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
7
6
|
|
|
8
7
|
import type { Wallet } from '../wallet/wallet.js';
|
|
@@ -57,18 +56,13 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
57
56
|
*/
|
|
58
57
|
public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
|
|
59
58
|
const receipt = await super.wait(opts);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
protected async getContractObject(wallet?: Wallet): Promise<TContract> {
|
|
65
|
-
const isWallet = (pxeWalletOrNode: Wallet | AztecNode | PXE): pxeWalletOrNode is Wallet =>
|
|
66
|
-
!!(pxeWalletOrNode as Wallet).createTxExecutionRequest;
|
|
67
|
-
const contractWallet = wallet ?? (isWallet(this.pxeWalletOrNode) && this.pxeWalletOrNode);
|
|
59
|
+
// In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
|
|
60
|
+
const contractWallet = opts?.wallet ?? (this.walletOrNode as Wallet);
|
|
68
61
|
if (!contractWallet) {
|
|
69
62
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
70
63
|
}
|
|
71
64
|
const instance = await this.instanceGetter();
|
|
72
|
-
|
|
65
|
+
const contract = (await this.postDeployCtor(instance.address, contractWallet)) as TContract;
|
|
66
|
+
return { ...receipt, contract };
|
|
73
67
|
}
|
|
74
68
|
}
|