@aztec/aztec.js 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.db765a8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/api/abi.d.ts +2 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/contract.d.ts +3 -3
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +1 -1
- package/dest/api/wallet.d.ts +2 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +3 -3
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- 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 +17 -8
- package/dest/contract/contract_function_interaction.d.ts +5 -5
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +102 -13
- package/dest/contract/deploy_method.d.ts +37 -12
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +42 -21
- package/dest/contract/get_gas_limits.js +3 -3
- package/dest/contract/interaction_options.d.ts +62 -21
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +33 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts +10 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/auth-registry.js +506 -59
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +12 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -1
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/fee-juice.js +8 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +1 -1
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +17 -1
- package/dest/contract/protocol_contracts/public-checks.d.ts +1 -1
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/public-checks.js +17 -1
- package/dest/utils/abi_types.d.ts +6 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/abi_types.js +1 -1
- package/dest/utils/authwit.d.ts +5 -5
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +10 -6
- package/dest/wallet/capabilities.d.ts +13 -5
- package/dest/wallet/capabilities.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.d.ts +15 -4
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +26 -0
- package/dest/wallet/wallet.d.ts +163 -16
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +33 -7
- package/package.json +10 -10
- package/src/api/abi.ts +1 -0
- package/src/api/contract.ts +8 -1
- package/src/api/wallet.ts +1 -0
- package/src/contract/base_contract_interaction.ts +3 -2
- package/src/contract/batch_call.ts +17 -14
- package/src/contract/contract_function_interaction.ts +101 -20
- package/src/contract/deploy_method.ts +77 -32
- package/src/contract/get_gas_limits.ts +3 -3
- package/src/contract/interaction_options.ts +96 -23
- package/src/contract/protocol_contracts/auth-registry.ts +239 -37
- package/src/contract/protocol_contracts/contract-class-registry.ts +3 -0
- package/src/contract/protocol_contracts/fee-juice.ts +2 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +5 -1
- package/src/contract/protocol_contracts/public-checks.ts +5 -1
- package/src/utils/abi_types.ts +7 -0
- package/src/utils/authwit.ts +20 -22
- package/src/wallet/capabilities.ts +13 -4
- package/src/wallet/deploy_account_method.ts +39 -2
- package/src/wallet/wallet.ts +46 -6
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
getContractInstanceFromInstantiationParams,
|
|
10
10
|
} from '@aztec/stdlib/contract';
|
|
11
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
|
-
import { type Capsule,
|
|
12
|
+
import { type Capsule, HashedValues, type TxProfileResult, type TxReceipt } 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 { SendOptions, 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';
|
|
@@ -22,11 +22,15 @@ import { getGasLimits } from './get_gas_limits.js';
|
|
|
22
22
|
import {
|
|
23
23
|
NO_WAIT,
|
|
24
24
|
type NoWait,
|
|
25
|
+
type OffchainOutput,
|
|
25
26
|
type ProfileInteractionOptions,
|
|
26
27
|
type RequestInteractionOptions,
|
|
27
28
|
type SendInteractionOptionsWithoutWait,
|
|
28
29
|
type SimulationInteractionFeeOptions,
|
|
29
|
-
type
|
|
30
|
+
type SimulationResult,
|
|
31
|
+
type TxSendResultImmediate,
|
|
32
|
+
type TxSendResultMined,
|
|
33
|
+
extractOffchainOutput,
|
|
30
34
|
toProfileOptions,
|
|
31
35
|
toSendOptions,
|
|
32
36
|
toSimulateOptions,
|
|
@@ -82,7 +86,7 @@ export type DeployOptionsWithoutWait = Omit<RequestDeployOptions, 'deployer'> &
|
|
|
82
86
|
* is mutually exclusive with "deployer"
|
|
83
87
|
*/
|
|
84
88
|
universalDeploy?: boolean;
|
|
85
|
-
} & Pick<SendInteractionOptionsWithoutWait, 'from' | 'fee'>;
|
|
89
|
+
} & Pick<SendInteractionOptionsWithoutWait, 'from' | 'fee' | 'additionalScopes'>;
|
|
86
90
|
|
|
87
91
|
/**
|
|
88
92
|
* Extends the deployment options with the required parameters to send the transaction.
|
|
@@ -123,20 +127,32 @@ export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = TxR
|
|
|
123
127
|
instance: ContractInstanceWithAddress;
|
|
124
128
|
};
|
|
125
129
|
|
|
130
|
+
/** Wait options that request a full receipt instead of just the contract instance. */
|
|
131
|
+
type WaitWithReturnReceipt = {
|
|
132
|
+
/** Request the full receipt instead of just the contract instance. */
|
|
133
|
+
returnReceipt: true;
|
|
134
|
+
};
|
|
135
|
+
|
|
126
136
|
/**
|
|
127
137
|
* Represents the result type of deploying a contract.
|
|
128
138
|
* - If wait is NO_WAIT, returns TxHash immediately.
|
|
129
139
|
* - If wait has returnReceipt: true, returns DeployTxReceipt after waiting.
|
|
130
140
|
* - Otherwise (undefined or DeployWaitOptions without returnReceipt), returns TContract after waiting.
|
|
131
141
|
*/
|
|
142
|
+
/** Result of deploying a contract when waiting for mining (default case). */
|
|
143
|
+
export type DeployResultMined<TContract extends ContractBase> = {
|
|
144
|
+
/** The deployed contract instance. */
|
|
145
|
+
contract: TContract;
|
|
146
|
+
/** The deploy transaction receipt. */
|
|
147
|
+
receipt: DeployTxReceipt<TContract>;
|
|
148
|
+
} & OffchainOutput;
|
|
149
|
+
|
|
150
|
+
/** Conditional return type for deploy based on wait options. */
|
|
132
151
|
export type DeployReturn<TContract extends ContractBase, W extends DeployInteractionWaitOptions> = W extends NoWait
|
|
133
|
-
?
|
|
134
|
-
: W extends
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
? DeployTxReceipt<TContract>
|
|
139
|
-
: TContract;
|
|
152
|
+
? TxSendResultImmediate
|
|
153
|
+
: W extends WaitWithReturnReceipt
|
|
154
|
+
? TxSendResultMined<DeployTxReceipt<TContract>>
|
|
155
|
+
: DeployResultMined<TContract>;
|
|
140
156
|
|
|
141
157
|
/**
|
|
142
158
|
* Contract interaction for deployment.
|
|
@@ -164,6 +180,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
164
180
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
165
181
|
authWitnesses: AuthWitness[] = [],
|
|
166
182
|
capsules: Capsule[] = [],
|
|
183
|
+
private extraHashedArgs: HashedValues[] = [],
|
|
167
184
|
) {
|
|
168
185
|
super(wallet, authWitnesses, capsules);
|
|
169
186
|
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
|
|
@@ -174,20 +191,29 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
174
191
|
* @param options - Configuration options.
|
|
175
192
|
* @returns The execution payload for this operation
|
|
176
193
|
*/
|
|
177
|
-
public async request(options
|
|
194
|
+
public async request(options: RequestDeployOptions = {}): Promise<ExecutionPayload> {
|
|
178
195
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
179
196
|
|
|
180
197
|
if (!options?.skipRegistration) {
|
|
181
198
|
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
182
199
|
}
|
|
183
|
-
|
|
200
|
+
const { authWitnesses, capsules } = options;
|
|
201
|
+
|
|
202
|
+
// Propagates the included authwitnesses, capsules, and extraHashedArgs
|
|
203
|
+
// potentially baked into the interaction
|
|
204
|
+
const initialExecutionPayload = new ExecutionPayload(
|
|
205
|
+
[],
|
|
206
|
+
this.authWitnesses.concat(authWitnesses ?? []),
|
|
207
|
+
this.capsules.concat(capsules ?? []),
|
|
208
|
+
this.extraHashedArgs,
|
|
209
|
+
);
|
|
184
210
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
185
211
|
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
186
212
|
? await options.fee.paymentMethod.getExecutionPayload()
|
|
187
213
|
: undefined;
|
|
188
214
|
const finalExecutionPayload = feeExecutionPayload
|
|
189
|
-
? mergeExecutionPayloads([feeExecutionPayload, publication, initialization])
|
|
190
|
-
: mergeExecutionPayloads([publication, initialization]);
|
|
215
|
+
? mergeExecutionPayloads([initialExecutionPayload, feeExecutionPayload, publication, initialization])
|
|
216
|
+
: mergeExecutionPayloads([initialExecutionPayload, publication, initialization]);
|
|
191
217
|
if (!finalExecutionPayload.calls.length) {
|
|
192
218
|
throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
|
|
193
219
|
}
|
|
@@ -207,7 +233,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
207
233
|
* @param options - Deploy options with wait parameter
|
|
208
234
|
* @returns Send options with wait parameter
|
|
209
235
|
*/
|
|
210
|
-
|
|
236
|
+
protected convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
|
|
211
237
|
options: DeployOptions<W>,
|
|
212
238
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
213
239
|
): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
|
|
@@ -219,6 +245,24 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
219
245
|
} as any;
|
|
220
246
|
}
|
|
221
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Converts deploy simulation options into wallet-level simulate options.
|
|
250
|
+
* @param options - The deploy simulation options to convert.
|
|
251
|
+
*/
|
|
252
|
+
protected convertDeployOptionsToSimulateOptions(options: SimulateDeployOptions): SimulateOptions {
|
|
253
|
+
return toSimulateOptions(options);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Converts deploy profile options into wallet-level profile options.
|
|
258
|
+
* @param options - The deploy profile options to convert.
|
|
259
|
+
*/
|
|
260
|
+
protected convertDeployOptionsToProfileOptions(
|
|
261
|
+
options: DeployOptionsWithoutWait & ProfileInteractionOptions,
|
|
262
|
+
): ProfileOptions {
|
|
263
|
+
return toProfileOptions(options);
|
|
264
|
+
}
|
|
265
|
+
|
|
222
266
|
/**
|
|
223
267
|
* Adds this contract to the wallet and returns the Contract object.
|
|
224
268
|
* @param options - Deployment options.
|
|
@@ -308,8 +352,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
308
352
|
* @returns TxHash (if wait is NO_WAIT), TContract (if wait is undefined or doesn't have returnReceipt), or DeployTxReceipt (if wait.returnReceipt is true)
|
|
309
353
|
*/
|
|
310
354
|
// Overload for when wait is not specified at all - returns the contract
|
|
311
|
-
public override send(options: DeployOptionsWithoutWait): Promise<TContract
|
|
312
|
-
// Generic overload for explicit wait values
|
|
355
|
+
public override send(options: DeployOptionsWithoutWait): Promise<DeployResultMined<TContract>>;
|
|
313
356
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
314
357
|
public override send<W extends DeployInteractionWaitOptions>(
|
|
315
358
|
options: DeployOptions<W>,
|
|
@@ -320,12 +363,15 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
320
363
|
const sendOptions = this.convertDeployOptionsToSendOptions(options);
|
|
321
364
|
|
|
322
365
|
if (options.wait === NO_WAIT) {
|
|
323
|
-
const
|
|
324
|
-
this.log.debug(`Sent deployment tx ${txHash.hash} of ${this.artifact.name} contract`);
|
|
325
|
-
return
|
|
366
|
+
const result = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<NoWait>);
|
|
367
|
+
this.log.debug(`Sent deployment tx ${result.txHash.hash} of ${this.artifact.name} contract`);
|
|
368
|
+
return result;
|
|
326
369
|
}
|
|
327
370
|
|
|
328
|
-
const receipt = await this.wallet.sendTx(
|
|
371
|
+
const { receipt, ...offchainOutput } = await this.wallet.sendTx(
|
|
372
|
+
executionPayload,
|
|
373
|
+
sendOptions as SendOptions<WaitOpts | undefined>,
|
|
374
|
+
);
|
|
329
375
|
this.log.debug(`Deployed ${this.artifact.name} contract in tx ${receipt.txHash}`);
|
|
330
376
|
|
|
331
377
|
// Attach contract instance
|
|
@@ -334,10 +380,10 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
334
380
|
|
|
335
381
|
// Return full receipt if requested, otherwise just the contract
|
|
336
382
|
if (options.wait && typeof options.wait === 'object' && options.wait.returnReceipt) {
|
|
337
|
-
return { ...receipt, contract, instance };
|
|
383
|
+
return { receipt: { ...receipt, contract, instance }, ...offchainOutput };
|
|
338
384
|
}
|
|
339
385
|
|
|
340
|
-
return contract;
|
|
386
|
+
return { contract, receipt, ...offchainOutput };
|
|
341
387
|
}
|
|
342
388
|
|
|
343
389
|
/**
|
|
@@ -366,9 +412,12 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
366
412
|
* @returns A simulation result object containing metadata of the execution, including gas
|
|
367
413
|
* estimations (if requested via options), execution statistics and emitted offchain effects
|
|
368
414
|
*/
|
|
369
|
-
public async simulate(options: SimulateDeployOptions): Promise<
|
|
415
|
+
public async simulate(options: SimulateDeployOptions): Promise<SimulationResult> {
|
|
370
416
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
371
|
-
const simulatedTx = await this.wallet.simulateTx(
|
|
417
|
+
const simulatedTx = await this.wallet.simulateTx(
|
|
418
|
+
executionPayload,
|
|
419
|
+
this.convertDeployOptionsToSimulateOptions(options),
|
|
420
|
+
);
|
|
372
421
|
|
|
373
422
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
374
423
|
this.log.verbose(
|
|
@@ -376,7 +425,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
376
425
|
);
|
|
377
426
|
return {
|
|
378
427
|
stats: simulatedTx.stats!,
|
|
379
|
-
|
|
428
|
+
...extractOffchainOutput(simulatedTx.offchainEffects),
|
|
380
429
|
result: undefined,
|
|
381
430
|
estimatedGas: { gasLimits, teardownGasLimits },
|
|
382
431
|
};
|
|
@@ -390,11 +439,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
390
439
|
*/
|
|
391
440
|
public async profile(options: DeployOptionsWithoutWait & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
392
441
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
393
|
-
return await this.wallet.profileTx(executionPayload,
|
|
394
|
-
...toProfileOptions(options),
|
|
395
|
-
profileMode: options.profileMode,
|
|
396
|
-
skipProofGeneration: options.skipProofGeneration,
|
|
397
|
-
});
|
|
442
|
+
return await this.wallet.profileTx(executionPayload, this.convertDeployOptionsToProfileOptions(options));
|
|
398
443
|
}
|
|
399
444
|
|
|
400
445
|
/** Return this deployment address. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { Gas } from '@aztec/stdlib/gas';
|
|
3
3
|
import type { TxSimulationResult } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
@@ -23,8 +23,8 @@ export function getGasLimits(
|
|
|
23
23
|
const gasLimits = simulationResult.gasUsed.totalGas.mul(1 + pad);
|
|
24
24
|
const teardownGasLimits = simulationResult.gasUsed.teardownGas.mul(1 + pad);
|
|
25
25
|
|
|
26
|
-
if (gasLimits.l2Gas >
|
|
27
|
-
throw new Error('Transaction consumes more gas than the
|
|
26
|
+
if (gasLimits.l2Gas > MAX_PROCESSABLE_L2_GAS) {
|
|
27
|
+
throw new Error('Transaction consumes more l2 gas than the maximum processable gas');
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
30
30
|
gasLimits,
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
3
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
-
import
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
type Capsule,
|
|
8
|
+
OFFCHAIN_MESSAGE_IDENTIFIER,
|
|
9
|
+
type OffchainEffect,
|
|
10
|
+
type SimulationStats,
|
|
11
|
+
type TxHash,
|
|
12
|
+
type TxReceipt,
|
|
13
|
+
} from '@aztec/stdlib/tx';
|
|
6
14
|
|
|
7
15
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
8
16
|
import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
|
|
@@ -82,6 +90,13 @@ export type SendInteractionOptionsWithoutWait = RequestInteractionOptions & {
|
|
|
82
90
|
from: AztecAddress;
|
|
83
91
|
/** The fee options for the transaction. */
|
|
84
92
|
fee?: InteractionFeeOptions;
|
|
93
|
+
/**
|
|
94
|
+
* Additional addresses whose private state and keys should be accessible during execution,
|
|
95
|
+
* beyond the sender's. Required when the transaction needs to access private state or keys
|
|
96
|
+
* belonging to an address other than `from`, e.g. withdrawing from an escrow that holds
|
|
97
|
+
* its own private notes.
|
|
98
|
+
*/
|
|
99
|
+
additionalScopes?: AztecAddress[];
|
|
85
100
|
};
|
|
86
101
|
|
|
87
102
|
/**
|
|
@@ -109,8 +124,8 @@ export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
|
109
124
|
skipTxValidation?: boolean;
|
|
110
125
|
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
111
126
|
skipFeeEnforcement?: boolean;
|
|
112
|
-
/** Whether to include metadata such as
|
|
113
|
-
* the simulation result,
|
|
127
|
+
/** Whether to include metadata such as performance statistics (e.g. timing information of the different circuits and oracles) and gas estimation
|
|
128
|
+
* in the simulation result, in addition to the return value and offchain effects */
|
|
114
129
|
includeMetadata?: boolean;
|
|
115
130
|
};
|
|
116
131
|
|
|
@@ -124,31 +139,89 @@ export type ProfileInteractionOptions = SimulateInteractionOptions & {
|
|
|
124
139
|
skipProofGeneration?: boolean;
|
|
125
140
|
};
|
|
126
141
|
|
|
142
|
+
/** A message emitted during execution or proving, to be delivered offchain. */
|
|
143
|
+
export type OffchainMessage = {
|
|
144
|
+
/** The intended recipient of the message. */
|
|
145
|
+
recipient: AztecAddress;
|
|
146
|
+
/** The message payload (typically encrypted). */
|
|
147
|
+
payload: Fr[];
|
|
148
|
+
/** The contract that emitted the message. */
|
|
149
|
+
contractAddress: AztecAddress;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Groups all unproven outputs from private execution that are returned to the client. */
|
|
153
|
+
export type OffchainOutput = {
|
|
154
|
+
/** Raw offchain effects emitted during execution. */
|
|
155
|
+
offchainEffects: OffchainEffect[];
|
|
156
|
+
/** Messages emitted during execution, to be delivered offchain. */
|
|
157
|
+
offchainMessages: OffchainMessage[];
|
|
158
|
+
};
|
|
159
|
+
|
|
127
160
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
161
|
+
* Splits an array of offchain effects into decoded offchain messages and remaining effects.
|
|
162
|
+
* Effects whose data starts with `OFFCHAIN_MESSAGE_IDENTIFIER` are parsed as messages and removed
|
|
163
|
+
* from the effects array.
|
|
164
|
+
*/
|
|
165
|
+
export function extractOffchainOutput(effects: OffchainEffect[]): OffchainOutput {
|
|
166
|
+
const offchainEffects: OffchainEffect[] = [];
|
|
167
|
+
const offchainMessages: OffchainMessage[] = [];
|
|
168
|
+
|
|
169
|
+
for (const effect of effects) {
|
|
170
|
+
if (effect.data.length >= 2 && effect.data[0].equals(OFFCHAIN_MESSAGE_IDENTIFIER)) {
|
|
171
|
+
offchainMessages.push({
|
|
172
|
+
recipient: AztecAddress.fromField(effect.data[1]),
|
|
173
|
+
payload: effect.data.slice(2),
|
|
174
|
+
contractAddress: effect.contractAddress,
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
offchainEffects.push(effect);
|
|
143
178
|
}
|
|
144
|
-
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return { offchainEffects, offchainMessages };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Returns an empty `OffchainOutput` (no effects, no messages).
|
|
186
|
+
*/
|
|
187
|
+
export function emptyOffchainOutput(): OffchainOutput {
|
|
188
|
+
return { offchainEffects: [], offchainMessages: [] };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Represents the result of a simulation.
|
|
193
|
+
* Always includes the return value and offchain output.
|
|
194
|
+
* When `includeMetadata` or `fee.estimateGas` is set, also includes stats and gas estimation.
|
|
195
|
+
*/
|
|
196
|
+
export type SimulationResult = {
|
|
197
|
+
/** Return value of the function */
|
|
198
|
+
result: any;
|
|
199
|
+
/** Additional stats about the simulation. Present when `includeMetadata` is set. */
|
|
200
|
+
stats?: SimulationStats;
|
|
201
|
+
/** Gas estimation results. Present when `includeMetadata` or `fee.estimateGas` is set. */
|
|
202
|
+
estimatedGas?: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>;
|
|
203
|
+
} & OffchainOutput;
|
|
204
|
+
|
|
205
|
+
/** Result of sendTx when not waiting for mining. */
|
|
206
|
+
export type TxSendResultImmediate = {
|
|
207
|
+
/** The hash of the sent transaction. */
|
|
208
|
+
txHash: TxHash;
|
|
209
|
+
} & OffchainOutput;
|
|
210
|
+
|
|
211
|
+
/** Result of sendTx when waiting for mining. */
|
|
212
|
+
export type TxSendResultMined<TReturn = TxReceipt> = {
|
|
213
|
+
/** The transaction receipt. */
|
|
214
|
+
receipt: TReturn;
|
|
215
|
+
} & OffchainOutput;
|
|
145
216
|
|
|
146
217
|
/**
|
|
147
218
|
* Represents the result type of sending a transaction.
|
|
148
|
-
* If `wait` is NO_WAIT, returns
|
|
149
|
-
*
|
|
219
|
+
* If `wait` is NO_WAIT, returns TxSendResultImmediate.
|
|
220
|
+
* Otherwise returns TxSendResultMined.
|
|
150
221
|
*/
|
|
151
|
-
export type SendReturn<T extends InteractionWaitOptions, TReturn = TxReceipt> = T extends NoWait
|
|
222
|
+
export type SendReturn<T extends InteractionWaitOptions, TReturn = TxReceipt> = T extends NoWait
|
|
223
|
+
? TxSendResultImmediate
|
|
224
|
+
: TxSendResultMined<TReturn>;
|
|
152
225
|
|
|
153
226
|
/**
|
|
154
227
|
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|