@aztec/aztec.js 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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 +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +8 -9
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +19 -7
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +3 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +5 -6
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/contract.d.ts +18 -12
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +16 -10
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/events.d.ts +10 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +30 -20
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- 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/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/authorization/call_authorization_request.d.ts +22 -1
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +3 -3
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +11 -6
- package/dest/contract/contract_base.d.ts +4 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +3 -12
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +10 -7
- package/dest/contract/deploy_method.d.ts +76 -17
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +55 -29
- package/dest/contract/interaction_options.d.ts +49 -5
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +8 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +997 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +139 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +426 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +593 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +601 -0
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/publish_class.js +2 -2
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +6 -3
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +10 -10
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
- package/dest/fee/private_fee_payment_method.js +10 -10
- package/dest/fee/public_fee_payment_method.js +10 -10
- package/dest/fee/sponsored_fee_payment.js +3 -3
- package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +120 -0
- package/dest/utils/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +5 -9
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +5 -8
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +5 -11
- package/dest/wallet/capabilities.d.ts +452 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +46 -7
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +33 -5
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1740 -2496
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +211 -108
- package/package.json +24 -13
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +6 -7
- package/src/account/account_with_secret_key.ts +33 -8
- package/src/account/index.ts +2 -1
- package/src/account/signerless_account.ts +13 -12
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +24 -9
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +1 -0
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +48 -3
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +10 -13
- package/src/contract/contract_function_interaction.ts +17 -7
- package/src/contract/deploy_method.ts +145 -35
- package/src/contract/interaction_options.ts +56 -4
- package/src/contract/protocol_contracts/auth-registry.ts +551 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +264 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +334 -0
- package/src/contract/protocol_contracts/public-checks.ts +318 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +9 -8
- package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +7 -7
- package/src/fee/public_fee_payment_method.ts +8 -8
- package/src/fee/sponsored_fee_payment.ts +3 -3
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/authwit.ts +19 -7
- package/src/utils/node.ts +62 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +5 -13
- package/src/wallet/capabilities.ts +500 -0
- package/src/wallet/deploy_account_method.ts +74 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +344 -130
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -129
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/deployment/broadcast_function.ts +0 -148
|
@@ -9,27 +9,46 @@ import {
|
|
|
9
9
|
getContractInstanceFromInstantiationParams,
|
|
10
10
|
} from '@aztec/stdlib/contract';
|
|
11
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
|
-
import { type Capsule, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
12
|
+
import { type Capsule, TxHash, type TxProfileResult, type TxReceipt, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
13
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
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
17
|
+
import type { ProfileOptions, SendOptions, SimulateOptions, Wallet } from '../wallet/wallet.js';
|
|
18
18
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
19
19
|
import type { ContractBase } from './contract_base.js';
|
|
20
20
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
21
|
-
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
22
21
|
import { getGasLimits } from './get_gas_limits.js';
|
|
23
22
|
import {
|
|
23
|
+
NO_WAIT,
|
|
24
|
+
type NoWait,
|
|
24
25
|
type ProfileInteractionOptions,
|
|
25
26
|
type RequestInteractionOptions,
|
|
26
|
-
type
|
|
27
|
+
type SendInteractionOptionsWithoutWait,
|
|
27
28
|
type SimulationInteractionFeeOptions,
|
|
28
29
|
type SimulationReturn,
|
|
29
30
|
toProfileOptions,
|
|
30
31
|
toSendOptions,
|
|
31
32
|
toSimulateOptions,
|
|
32
33
|
} from './interaction_options.js';
|
|
34
|
+
import type { WaitOpts } from './wait_opts.js';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Wait options specific to deployment transactions.
|
|
38
|
+
* Extends WaitOpts with a flag to return the full receipt instead of just the contract.
|
|
39
|
+
*/
|
|
40
|
+
export type DeployWaitOptions = WaitOpts & {
|
|
41
|
+
/** If true, return the full DeployTxReceipt instead of just the contract. Defaults to false. */
|
|
42
|
+
returnReceipt?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Type for wait options in deployment interactions.
|
|
47
|
+
* - NO_WAIT symbol: Don't wait, return TxHash immediately
|
|
48
|
+
* - DeployWaitOptions: Wait with custom options
|
|
49
|
+
* - undefined: Wait with default options
|
|
50
|
+
*/
|
|
51
|
+
export type DeployInteractionWaitOptions = NoWait | DeployWaitOptions | undefined;
|
|
33
52
|
|
|
34
53
|
/**
|
|
35
54
|
* Options for deploying a contract on the Aztec network.
|
|
@@ -55,21 +74,34 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
55
74
|
};
|
|
56
75
|
|
|
57
76
|
/**
|
|
58
|
-
*
|
|
77
|
+
* Base deployment options without wait parameter.
|
|
59
78
|
*/
|
|
60
|
-
export type
|
|
79
|
+
export type DeployOptionsWithoutWait = Omit<RequestDeployOptions, 'deployer'> & {
|
|
61
80
|
/**
|
|
62
81
|
* Set to true to *not* include the sender in the address computation. This option
|
|
63
82
|
* is mutually exclusive with "deployer"
|
|
64
83
|
*/
|
|
65
84
|
universalDeploy?: boolean;
|
|
66
|
-
} & Pick<
|
|
85
|
+
} & Pick<SendInteractionOptionsWithoutWait, 'from' | 'fee' | 'additionalScopes'>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Extends the deployment options with the required parameters to send the transaction.
|
|
89
|
+
*/
|
|
90
|
+
export type DeployOptions<W extends DeployInteractionWaitOptions = undefined> = DeployOptionsWithoutWait & {
|
|
91
|
+
/**
|
|
92
|
+
* Options for waiting for the transaction to be mined.
|
|
93
|
+
* - undefined (default): wait with default options and return the contract instance
|
|
94
|
+
* - DeployWaitOptions: wait with custom options and return contract or receipt based on returnReceipt flag
|
|
95
|
+
* - NO_WAIT: return TxHash immediately without waiting
|
|
96
|
+
*/
|
|
97
|
+
wait?: W;
|
|
98
|
+
};
|
|
67
99
|
|
|
68
100
|
/**
|
|
69
101
|
* Options for simulating the deployment of a contract
|
|
70
102
|
* Allows skipping certain validations and computing gas estimations
|
|
71
103
|
*/
|
|
72
|
-
export type SimulateDeployOptions = Omit<
|
|
104
|
+
export type SimulateDeployOptions = Omit<DeployOptionsWithoutWait, 'fee'> & {
|
|
73
105
|
/** The fee options for the transaction. */
|
|
74
106
|
fee?: SimulationInteractionFeeOptions;
|
|
75
107
|
/** Simulate without checking for the validity of the resulting transaction,
|
|
@@ -83,6 +115,29 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
83
115
|
includeMetadata?: boolean;
|
|
84
116
|
};
|
|
85
117
|
|
|
118
|
+
/** Receipt for a deployment transaction with the deployed contract instance. */
|
|
119
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = TxReceipt & {
|
|
120
|
+
/** Type-safe wrapper around the deployed contract instance, linked to the deployment wallet */
|
|
121
|
+
contract: TContract;
|
|
122
|
+
/** The deployed contract instance with address and metadata. */
|
|
123
|
+
instance: ContractInstanceWithAddress;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Represents the result type of deploying a contract.
|
|
128
|
+
* - If wait is NO_WAIT, returns TxHash immediately.
|
|
129
|
+
* - If wait has returnReceipt: true, returns DeployTxReceipt after waiting.
|
|
130
|
+
* - Otherwise (undefined or DeployWaitOptions without returnReceipt), returns TContract after waiting.
|
|
131
|
+
*/
|
|
132
|
+
export type DeployReturn<TContract extends ContractBase, W extends DeployInteractionWaitOptions> = W extends NoWait
|
|
133
|
+
? TxHash
|
|
134
|
+
: W extends {
|
|
135
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
136
|
+
returnReceipt: true;
|
|
137
|
+
}
|
|
138
|
+
? DeployTxReceipt<TContract>
|
|
139
|
+
: TContract;
|
|
140
|
+
|
|
86
141
|
/**
|
|
87
142
|
* Contract interaction for deployment.
|
|
88
143
|
* Handles class publication, instance publication, and initialization of the contract.
|
|
@@ -92,8 +147,6 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
92
147
|
* then technically the contract has already been "created", and all of the contract's
|
|
93
148
|
* functions (private and utility) can be interacted-with immediately, without any
|
|
94
149
|
* "deployment tx".
|
|
95
|
-
*
|
|
96
|
-
* Extends the BaseContractInteraction class.
|
|
97
150
|
*/
|
|
98
151
|
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
99
152
|
/** The contract instance to be deployed. */
|
|
@@ -142,13 +195,48 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
142
195
|
return finalExecutionPayload;
|
|
143
196
|
}
|
|
144
197
|
|
|
145
|
-
convertDeployOptionsToRequestOptions(options:
|
|
198
|
+
convertDeployOptionsToRequestOptions(options: DeployOptionsWithoutWait): RequestDeployOptions {
|
|
146
199
|
return {
|
|
147
200
|
...options,
|
|
148
201
|
deployer: !options?.universalDeploy ? options.from : undefined,
|
|
149
202
|
};
|
|
150
203
|
}
|
|
151
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Converts DeployOptions to SendOptions, stripping out the returnReceipt flag if present.
|
|
207
|
+
* @param options - Deploy options with wait parameter
|
|
208
|
+
* @returns Send options with wait parameter
|
|
209
|
+
*/
|
|
210
|
+
protected convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
|
|
211
|
+
options: DeployOptions<W>,
|
|
212
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
213
|
+
): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
|
|
214
|
+
return {
|
|
215
|
+
...toSendOptions({
|
|
216
|
+
...options,
|
|
217
|
+
wait: options.wait as any,
|
|
218
|
+
}),
|
|
219
|
+
} as any;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Converts deploy simulation options into wallet-level simulate options.
|
|
224
|
+
* @param options - The deploy simulation options to convert.
|
|
225
|
+
*/
|
|
226
|
+
protected convertDeployOptionsToSimulateOptions(options: SimulateDeployOptions): SimulateOptions {
|
|
227
|
+
return toSimulateOptions(options);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Converts deploy profile options into wallet-level profile options.
|
|
232
|
+
* @param options - The deploy profile options to convert.
|
|
233
|
+
*/
|
|
234
|
+
protected convertDeployOptionsToProfileOptions(
|
|
235
|
+
options: DeployOptionsWithoutWait & ProfileInteractionOptions,
|
|
236
|
+
): ProfileOptions {
|
|
237
|
+
return toProfileOptions(options);
|
|
238
|
+
}
|
|
239
|
+
|
|
152
240
|
/**
|
|
153
241
|
* Adds this contract to the wallet and returns the Contract object.
|
|
154
242
|
* @param options - Deployment options.
|
|
@@ -184,16 +272,17 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
184
272
|
|
|
185
273
|
// Publish the contract class if it hasn't been published already.
|
|
186
274
|
if (!options?.skipClassPublication) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
|
|
190
|
-
);
|
|
191
|
-
} else {
|
|
275
|
+
const classMetadata = await this.wallet.getContractClassMetadata(contractClass.id);
|
|
276
|
+
if (!classMetadata.isContractClassPubliclyRegistered) {
|
|
192
277
|
this.log.info(
|
|
193
278
|
`Creating request for publishing contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
|
|
194
279
|
);
|
|
195
280
|
const registerContractClassInteraction = await publishContractClass(this.wallet, this.artifact);
|
|
196
281
|
calls.push(await registerContractClassInteraction.request());
|
|
282
|
+
} else {
|
|
283
|
+
this.log.debug(
|
|
284
|
+
`Skipping contract class publication for ${contractClass.id.toString()} as it is already registered`,
|
|
285
|
+
);
|
|
197
286
|
}
|
|
198
287
|
}
|
|
199
288
|
|
|
@@ -202,7 +291,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
202
291
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
203
292
|
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
204
293
|
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
205
|
-
const deploymentInteraction =
|
|
294
|
+
const deploymentInteraction = publishInstance(this.wallet, instance);
|
|
206
295
|
calls.push(await deploymentInteraction.request());
|
|
207
296
|
}
|
|
208
297
|
|
|
@@ -231,20 +320,42 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
231
320
|
|
|
232
321
|
/**
|
|
233
322
|
* Send a contract deployment transaction (initialize and/or publish) using the provided options.
|
|
234
|
-
*
|
|
235
|
-
* allowing us to send a transaction specifically for contract deployment.
|
|
323
|
+
* By default, waits for the transaction to be mined and returns the deployed contract instance.
|
|
236
324
|
*
|
|
237
325
|
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
238
|
-
* @returns
|
|
326
|
+
* @returns TxHash (if wait is NO_WAIT), TContract (if wait is undefined or doesn't have returnReceipt), or DeployTxReceipt (if wait.returnReceipt is true)
|
|
239
327
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
328
|
+
// Overload for when wait is not specified at all - returns the contract
|
|
329
|
+
public override send(options: DeployOptionsWithoutWait): Promise<TContract>;
|
|
330
|
+
// Generic overload for explicit wait values
|
|
331
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
332
|
+
public override send<W extends DeployInteractionWaitOptions>(
|
|
333
|
+
options: DeployOptions<W>,
|
|
334
|
+
): Promise<DeployReturn<TContract, W>>;
|
|
335
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
336
|
+
public override async send(options: DeployOptions<DeployInteractionWaitOptions>): Promise<any> {
|
|
337
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
338
|
+
const sendOptions = this.convertDeployOptionsToSendOptions(options);
|
|
339
|
+
|
|
340
|
+
if (options.wait === NO_WAIT) {
|
|
341
|
+
const txHash = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<NoWait>);
|
|
342
|
+
this.log.debug(`Sent deployment tx ${txHash.hash} of ${this.artifact.name} contract`);
|
|
343
|
+
return txHash;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const receipt = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<WaitOpts | undefined>);
|
|
347
|
+
this.log.debug(`Deployed ${this.artifact.name} contract in tx ${receipt.txHash}`);
|
|
348
|
+
|
|
349
|
+
// Attach contract instance
|
|
350
|
+
const instance = await this.getInstance(options);
|
|
351
|
+
const contract = this.postDeployCtor(instance, this.wallet) as TContract;
|
|
352
|
+
|
|
353
|
+
// Return full receipt if requested, otherwise just the contract
|
|
354
|
+
if (options.wait && typeof options.wait === 'object' && options.wait.returnReceipt) {
|
|
355
|
+
return { ...receipt, contract, instance };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return contract;
|
|
248
359
|
}
|
|
249
360
|
|
|
250
361
|
/**
|
|
@@ -275,7 +386,10 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
275
386
|
*/
|
|
276
387
|
public async simulate(options: SimulateDeployOptions): Promise<SimulationReturn<true>> {
|
|
277
388
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
278
|
-
const simulatedTx = await this.wallet.simulateTx(
|
|
389
|
+
const simulatedTx = await this.wallet.simulateTx(
|
|
390
|
+
executionPayload,
|
|
391
|
+
this.convertDeployOptionsToSimulateOptions(options),
|
|
392
|
+
);
|
|
279
393
|
|
|
280
394
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
281
395
|
this.log.verbose(
|
|
@@ -295,13 +409,9 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
295
409
|
*
|
|
296
410
|
* @returns An object containing the function return value and profile result.
|
|
297
411
|
*/
|
|
298
|
-
public async profile(options:
|
|
412
|
+
public async profile(options: DeployOptionsWithoutWait & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
299
413
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
300
|
-
return await this.wallet.profileTx(executionPayload,
|
|
301
|
-
...toProfileOptions(options),
|
|
302
|
-
profileMode: options.profileMode,
|
|
303
|
-
skipProofGeneration: options.skipProofGeneration,
|
|
304
|
-
});
|
|
414
|
+
return await this.wallet.profileTx(executionPayload, this.convertDeployOptionsToProfileOptions(options));
|
|
305
415
|
}
|
|
306
416
|
|
|
307
417
|
/** Return this deployment address. */
|
|
@@ -2,10 +2,11 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
2
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
-
import type { Capsule, OffchainEffect, SimulationStats } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { Capsule, OffchainEffect, SimulationStats, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
8
8
|
import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
|
|
9
|
+
import type { WaitOpts } from './wait_opts.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Options used to tweak the simulation and add gas estimation capabilities
|
|
@@ -55,13 +56,52 @@ export type RequestInteractionOptions = {
|
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
|
-
*
|
|
59
|
+
* Constant for explicitly not waiting for transaction confirmation.
|
|
60
|
+
* We use this instead of false to avoid confusion with falsy checks.
|
|
61
|
+
*/
|
|
62
|
+
export const NO_WAIT = 'NO_WAIT' as const;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Type for the NO_WAIT constant.
|
|
66
|
+
*/
|
|
67
|
+
export type NoWait = typeof NO_WAIT;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Type for wait options in interactions.
|
|
71
|
+
* - NO_WAIT symbol: Don't wait for confirmation, return TxHash immediately
|
|
72
|
+
* - WaitOpts object: Wait with custom options and return receipt/result
|
|
73
|
+
* - undefined: Wait with default options and return receipt/result
|
|
74
|
+
*/
|
|
75
|
+
export type InteractionWaitOptions = NoWait | WaitOpts | undefined;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Base options for calling a (constrained) function in a contract, without wait parameter.
|
|
59
79
|
*/
|
|
60
|
-
export type
|
|
80
|
+
export type SendInteractionOptionsWithoutWait = RequestInteractionOptions & {
|
|
61
81
|
/** The sender's Aztec address. */
|
|
62
82
|
from: AztecAddress;
|
|
63
83
|
/** The fee options for the transaction. */
|
|
64
84
|
fee?: InteractionFeeOptions;
|
|
85
|
+
/**
|
|
86
|
+
* Additional addresses whose private state and keys should be accessible during execution,
|
|
87
|
+
* beyond the sender's. Required when the transaction needs to access private state or keys
|
|
88
|
+
* belonging to an address other than `from`, e.g. withdrawing from an escrow that holds
|
|
89
|
+
* its own private notes.
|
|
90
|
+
*/
|
|
91
|
+
additionalScopes?: AztecAddress[];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Represents options for calling a (constrained) function in a contract.
|
|
96
|
+
*/
|
|
97
|
+
export type SendInteractionOptions<W extends InteractionWaitOptions = undefined> = SendInteractionOptionsWithoutWait & {
|
|
98
|
+
/**
|
|
99
|
+
* Whether to wait for the transaction to be mined.
|
|
100
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
101
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
102
|
+
* - NO_WAIT: return txHash immediately without waiting
|
|
103
|
+
*/
|
|
104
|
+
wait?: W;
|
|
65
105
|
};
|
|
66
106
|
|
|
67
107
|
/**
|
|
@@ -110,11 +150,22 @@ export type SimulationReturn<T extends boolean | undefined> = T extends true
|
|
|
110
150
|
}
|
|
111
151
|
: any;
|
|
112
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Represents the result type of sending a transaction.
|
|
155
|
+
* If `wait` is NO_WAIT, returns TxHash immediately without waiting.
|
|
156
|
+
* If `wait` is undefined or WaitOpts, returns TReturn (defaults to TxReceipt) after waiting.
|
|
157
|
+
*/
|
|
158
|
+
export type SendReturn<T extends InteractionWaitOptions, TReturn = TxReceipt> = T extends NoWait ? TxHash : TReturn;
|
|
159
|
+
|
|
113
160
|
/**
|
|
114
161
|
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
115
162
|
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
163
|
+
* @param options - The send interaction options with optional wait parameter
|
|
164
|
+
* @returns The send options to forward to the wallet
|
|
116
165
|
*/
|
|
117
|
-
export function toSendOptions
|
|
166
|
+
export function toSendOptions<W extends InteractionWaitOptions = undefined>(
|
|
167
|
+
options: SendInteractionOptions<W>,
|
|
168
|
+
): SendOptions<W> {
|
|
118
169
|
return {
|
|
119
170
|
...options,
|
|
120
171
|
fee: {
|
|
@@ -126,6 +177,7 @@ export function toSendOptions(options: SendInteractionOptions): SendOptions {
|
|
|
126
177
|
...options.fee?.gasSettings,
|
|
127
178
|
},
|
|
128
179
|
},
|
|
180
|
+
wait: options.wait, // Pass through wait option
|
|
129
181
|
};
|
|
130
182
|
}
|
|
131
183
|
|