@aztec/aztec.js 0.0.1-commit.023c3e5 → 0.0.1-commit.033589e
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 +5 -5
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -3
- 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/wallet.d.ts +2 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +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 +7 -16
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +107 -18
- 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 +2 -13
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +12 -258
- 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 +27 -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 +27 -1
- 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/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 +297 -89
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +54 -27
- package/package.json +20 -11
- package/src/api/abi.ts +1 -0
- package/src/api/contract.ts +10 -3
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +1 -0
- package/src/api/wallet.ts +5 -1
- package/src/contract/base_contract_interaction.ts +3 -2
- package/src/contract/batch_call.ts +17 -14
- package/src/contract/contract_function_interaction.ts +114 -26
- 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 -145
- 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/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/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 +110 -39
- 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/deployment/broadcast_function.ts +0 -148
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -102,21 +102,21 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
102
102
|
|
|
103
103
|
const witness = await this.wallet.createAuthWit(this.sender, {
|
|
104
104
|
caller: this.paymentContract,
|
|
105
|
-
call: {
|
|
105
|
+
call: FunctionCall.from({
|
|
106
106
|
name: 'transfer_to_public',
|
|
107
|
-
|
|
107
|
+
to: await this.getAsset(),
|
|
108
108
|
selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
|
|
109
109
|
type: FunctionType.PRIVATE,
|
|
110
110
|
hideMsgSender: false,
|
|
111
111
|
isStatic: false,
|
|
112
|
-
|
|
112
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
113
113
|
returnTypes: [],
|
|
114
|
-
},
|
|
114
|
+
}),
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
return new ExecutionPayload(
|
|
118
118
|
[
|
|
119
|
-
{
|
|
119
|
+
FunctionCall.from({
|
|
120
120
|
name: 'fee_entrypoint_private',
|
|
121
121
|
to: this.paymentContract,
|
|
122
122
|
selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
|
|
@@ -125,7 +125,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
125
125
|
isStatic: false,
|
|
126
126
|
args: [maxFee, txNonce],
|
|
127
127
|
returnTypes: [],
|
|
128
|
-
},
|
|
128
|
+
}),
|
|
129
129
|
],
|
|
130
130
|
[witness],
|
|
131
131
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -94,16 +94,16 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
94
94
|
|
|
95
95
|
const intent = {
|
|
96
96
|
caller: this.paymentContract,
|
|
97
|
-
call: {
|
|
97
|
+
call: FunctionCall.from({
|
|
98
98
|
name: 'transfer_in_public',
|
|
99
|
-
|
|
99
|
+
to: await this.getAsset(),
|
|
100
100
|
selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
|
|
101
101
|
type: FunctionType.PUBLIC,
|
|
102
|
-
isStatic: false,
|
|
103
102
|
hideMsgSender: false /** The target function performs an authwit check, so msg_sender is needed */,
|
|
104
|
-
|
|
103
|
+
isStatic: false,
|
|
104
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
105
105
|
returnTypes: [],
|
|
106
|
-
},
|
|
106
|
+
}),
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
const setPublicAuthWitInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
@@ -116,7 +116,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
116
116
|
return new ExecutionPayload(
|
|
117
117
|
[
|
|
118
118
|
...(await setPublicAuthWitInteraction.request()).calls,
|
|
119
|
-
{
|
|
119
|
+
FunctionCall.from({
|
|
120
120
|
name: 'fee_entrypoint_public',
|
|
121
121
|
to: this.paymentContract,
|
|
122
122
|
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
@@ -125,7 +125,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
125
125
|
isStatic: false,
|
|
126
126
|
args: [maxFee, txNonce],
|
|
127
127
|
returnTypes: [],
|
|
128
|
-
},
|
|
128
|
+
}),
|
|
129
129
|
],
|
|
130
130
|
[],
|
|
131
131
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -22,7 +22,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
22
22
|
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
23
23
|
return new ExecutionPayload(
|
|
24
24
|
[
|
|
25
|
-
{
|
|
25
|
+
FunctionCall.from({
|
|
26
26
|
name: 'sponsor_unconditionally',
|
|
27
27
|
to: this.paymentContract,
|
|
28
28
|
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
@@ -31,7 +31,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
31
31
|
isStatic: false,
|
|
32
32
|
args: [],
|
|
33
33
|
returnTypes: [],
|
|
34
|
-
},
|
|
34
|
+
}),
|
|
35
35
|
],
|
|
36
36
|
[],
|
|
37
37
|
[],
|
package/src/utils/abi_types.ts
CHANGED
|
@@ -23,3 +23,10 @@ export type U128Like = bigint | number;
|
|
|
23
23
|
|
|
24
24
|
/** Any type that can be converted into a struct with a single `inner` field. */
|
|
25
25
|
export type WrappedFieldLike = { /** Wrapped value */ inner: FieldLike } | FieldLike;
|
|
26
|
+
|
|
27
|
+
/** Noir `Option<T>` lowered ABI shape, plus ergonomic direct `T | null | undefined` inputs. */
|
|
28
|
+
export type OptionLike<T> =
|
|
29
|
+
| T
|
|
30
|
+
| null
|
|
31
|
+
| undefined
|
|
32
|
+
| { /** Whether the option is populated */ _is_some: boolean; /** Wrapped value */ _value: T };
|
package/src/utils/authwit.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, Funct
|
|
|
5
5
|
import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
|
|
6
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { computeVarArgsHash } from '@aztec/stdlib/hash';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TxProfileResult } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
10
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
11
11
|
import type {
|
|
@@ -15,7 +15,8 @@ import type {
|
|
|
15
15
|
SendInteractionOptionsWithoutWait,
|
|
16
16
|
SendReturn,
|
|
17
17
|
SimulateInteractionOptions,
|
|
18
|
-
|
|
18
|
+
SimulationResult,
|
|
19
|
+
TxSendResultMined,
|
|
19
20
|
} from '../contract/interaction_options.js';
|
|
20
21
|
import type { Wallet } from '../wallet/index.js';
|
|
21
22
|
|
|
@@ -189,10 +190,12 @@ export async function lookupValidity(
|
|
|
189
190
|
errorTypes: {},
|
|
190
191
|
} as FunctionAbi;
|
|
191
192
|
try {
|
|
192
|
-
results.isValidInPrivate = (
|
|
193
|
-
consumer,
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
results.isValidInPrivate = (
|
|
194
|
+
await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [consumer, innerHash]).simulate({
|
|
195
|
+
from: onBehalfOf,
|
|
196
|
+
authWitnesses: [witness],
|
|
197
|
+
})
|
|
198
|
+
).result as boolean;
|
|
196
199
|
// TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
|
|
197
200
|
// eslint-disable-next-line no-empty
|
|
198
201
|
} catch {}
|
|
@@ -219,12 +222,12 @@ export async function lookupValidity(
|
|
|
219
222
|
returnTypes: [{ kind: 'boolean' }],
|
|
220
223
|
errorTypes: {},
|
|
221
224
|
} as FunctionAbi;
|
|
222
|
-
results.isValidInPublic = (
|
|
223
|
-
wallet,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
).
|
|
225
|
+
results.isValidInPublic = (
|
|
226
|
+
await new ContractFunctionInteraction(wallet, ProtocolContractAddress.AuthRegistry, isConsumableAbi, [
|
|
227
|
+
onBehalfOf,
|
|
228
|
+
messageHash,
|
|
229
|
+
]).simulate({ from: onBehalfOf })
|
|
230
|
+
).result as boolean;
|
|
228
231
|
|
|
229
232
|
return results;
|
|
230
233
|
}
|
|
@@ -262,14 +265,10 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
262
265
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
263
266
|
* @returns The result of the transaction as returned by the contract function.
|
|
264
267
|
*/
|
|
265
|
-
public override simulate<T extends SimulateInteractionOptions>(
|
|
266
|
-
options: Omit<T, 'from'>,
|
|
267
|
-
): Promise<SimulationReturn<T['includeMetadata']>>;
|
|
268
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
269
268
|
public override simulate(
|
|
270
|
-
options: Omit<SimulateInteractionOptions, 'from'> = {},
|
|
271
|
-
): Promise<
|
|
272
|
-
return super.simulate({ ...options, from: this.from });
|
|
269
|
+
options: Omit<SimulateInteractionOptions, 'from'> = {} as Omit<SimulateInteractionOptions, 'from'>,
|
|
270
|
+
): Promise<SimulationResult> {
|
|
271
|
+
return super.simulate({ ...options, from: this.from } as SimulateInteractionOptions);
|
|
273
272
|
}
|
|
274
273
|
|
|
275
274
|
/**
|
|
@@ -290,8 +289,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
290
289
|
* @param options - An optional object containing 'fee' options information
|
|
291
290
|
* @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
|
|
292
291
|
*/
|
|
293
|
-
|
|
294
|
-
public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxReceipt>;
|
|
292
|
+
public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxSendResultMined>;
|
|
295
293
|
// Generic overload for explicit wait values
|
|
296
294
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
297
295
|
public override send<W extends InteractionWaitOptions>(
|
|
@@ -300,7 +298,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
300
298
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
301
299
|
public override send(
|
|
302
300
|
options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
|
|
303
|
-
): Promise<
|
|
301
|
+
): Promise<SendReturn<InteractionWaitOptions>> {
|
|
304
302
|
return super.send({ ...options, from: this.from });
|
|
305
303
|
}
|
|
306
304
|
|
|
@@ -32,6 +32,15 @@ export interface ContractFunctionPattern {
|
|
|
32
32
|
|
|
33
33
|
/** Function name or '*' for any function */
|
|
34
34
|
function: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Additional addresses whose private state and keys are accessible
|
|
38
|
+
* when calling this function, beyond the sender's.
|
|
39
|
+
* - undefined: No additional scopes allowed
|
|
40
|
+
* - AztecAddress[]: Only these specific addresses allowed as additional scopes
|
|
41
|
+
* - '*': All known address allowed as an additional scope
|
|
42
|
+
*/
|
|
43
|
+
additionalScopes?: AztecAddress[] | '*';
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
/**
|
|
@@ -180,11 +189,11 @@ export interface ContractClassesCapability {
|
|
|
180
189
|
export interface GrantedContractClassesCapability extends ContractClassesCapability {}
|
|
181
190
|
|
|
182
191
|
/**
|
|
183
|
-
* Transaction simulation capability - for simulating transactions and utilities.
|
|
192
|
+
* Transaction simulation capability - for simulating transactions and executing utilities.
|
|
184
193
|
*
|
|
185
194
|
* Maps to wallet methods:
|
|
186
195
|
* - simulateTx (when transactions scope specified)
|
|
187
|
-
* -
|
|
196
|
+
* - executeUtility (when utilities scope specified)
|
|
188
197
|
* - profileTx (when transactions scope specified)
|
|
189
198
|
*
|
|
190
199
|
* @example
|
|
@@ -200,7 +209,7 @@ export interface GrantedContractClassesCapability extends ContractClassesCapabil
|
|
|
200
209
|
* \}
|
|
201
210
|
*
|
|
202
211
|
* @example
|
|
203
|
-
* // Simulate any transaction and utility call
|
|
212
|
+
* // Simulate any transaction and execute any utility call
|
|
204
213
|
* \{
|
|
205
214
|
* type: 'simulation',
|
|
206
215
|
* transactions: \{ scope: '*' \},
|
|
@@ -221,7 +230,7 @@ export interface SimulationCapability {
|
|
|
221
230
|
scope: '*' | ContractFunctionPattern[];
|
|
222
231
|
};
|
|
223
232
|
|
|
224
|
-
/** Utility
|
|
233
|
+
/** Utility execution scope (unconstrained calls). Maps to: executeUtility */
|
|
225
234
|
utilities?: {
|
|
226
235
|
/**
|
|
227
236
|
* Which contracts/functions to allow:
|
|
@@ -9,15 +9,22 @@ import type { Account } from '../account/account.js';
|
|
|
9
9
|
import type { Contract } from '../contract/contract.js';
|
|
10
10
|
import type { ContractBase } from '../contract/contract_base.js';
|
|
11
11
|
import {
|
|
12
|
+
type DeployInteractionWaitOptions,
|
|
12
13
|
DeployMethod,
|
|
14
|
+
type DeployOptions,
|
|
13
15
|
type DeployOptionsWithoutWait,
|
|
14
16
|
type RequestDeployOptions,
|
|
15
17
|
type SimulateDeployOptions,
|
|
16
18
|
} from '../contract/deploy_method.js';
|
|
17
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
FeePaymentMethodOption,
|
|
21
|
+
InteractionWaitOptions,
|
|
22
|
+
ProfileInteractionOptions,
|
|
23
|
+
} from '../contract/interaction_options.js';
|
|
24
|
+
import type { WaitOpts } from '../contract/wait_opts.js';
|
|
18
25
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
19
26
|
import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
|
|
20
|
-
import type { Wallet } from './index.js';
|
|
27
|
+
import type { ProfileOptions, SendOptions, SimulateOptions, Wallet } from './index.js';
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* Extended fee payment method option for account deployments that includes entrypoint wrapping options
|
|
@@ -147,4 +154,34 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
147
154
|
deployer: options.from,
|
|
148
155
|
};
|
|
149
156
|
}
|
|
157
|
+
|
|
158
|
+
protected override convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
|
|
159
|
+
options: DeployOptions<W>,
|
|
160
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
161
|
+
): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
|
|
162
|
+
return super.convertDeployOptionsToSendOptions(this.injectContractAddressIntoScopes(options));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
protected override convertDeployOptionsToSimulateOptions(options: SimulateDeployOptions): SimulateOptions {
|
|
166
|
+
return super.convertDeployOptionsToSimulateOptions(this.injectContractAddressIntoScopes(options));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
protected override convertDeployOptionsToProfileOptions(
|
|
170
|
+
options: DeployOptionsWithoutWait & ProfileInteractionOptions,
|
|
171
|
+
): ProfileOptions {
|
|
172
|
+
return super.convertDeployOptionsToProfileOptions(this.injectContractAddressIntoScopes(options));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Injects the contract's own address into scopes so the constructor can access its own keys.
|
|
177
|
+
* @param options - The deploy options to augment with the contract address.
|
|
178
|
+
*/
|
|
179
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
180
|
+
private injectContractAddressIntoScopes<T extends { additionalScopes?: AztecAddress[] }>(options: T): T {
|
|
181
|
+
if (!this.address) {
|
|
182
|
+
throw new Error('Instance not yet constructed. This is a bug!');
|
|
183
|
+
}
|
|
184
|
+
const existing = options.additionalScopes ?? [];
|
|
185
|
+
return { ...options, additionalScopes: [...existing, this.address] };
|
|
186
|
+
}
|
|
150
187
|
}
|
package/src/wallet/wallet.ts
CHANGED
|
@@ -7,8 +7,7 @@ import {
|
|
|
7
7
|
type ContractArtifact,
|
|
8
8
|
ContractArtifactSchema,
|
|
9
9
|
type EventMetadataDefinition,
|
|
10
|
-
|
|
11
|
-
FunctionType,
|
|
10
|
+
FunctionCall,
|
|
12
11
|
} from '@aztec/stdlib/abi';
|
|
13
12
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
14
13
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -23,7 +22,7 @@ import {
|
|
|
23
22
|
TxProfileResult,
|
|
24
23
|
TxReceipt,
|
|
25
24
|
TxSimulationResult,
|
|
26
|
-
|
|
25
|
+
UtilityExecutionResult,
|
|
27
26
|
inTxSchema,
|
|
28
27
|
} from '@aztec/stdlib/tx';
|
|
29
28
|
|
|
@@ -140,37 +139,66 @@ export type BatchResults<T extends readonly BatchedMethod[]> = {
|
|
|
140
139
|
};
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
|
-
*
|
|
142
|
+
* Base filter options for event queries.
|
|
144
143
|
*/
|
|
145
|
-
export type
|
|
146
|
-
/** The address of the contract that emitted the events. */
|
|
147
|
-
contractAddress: AztecAddress;
|
|
148
|
-
/** Addresses of accounts that are in scope for this filter. */
|
|
149
|
-
scopes: AztecAddress[];
|
|
144
|
+
export type EventFilterBase = {
|
|
150
145
|
/** Transaction in which the events were emitted. */
|
|
151
146
|
txHash?: TxHash;
|
|
152
147
|
/** The block number from which to start fetching events (inclusive).
|
|
153
148
|
* Optional. If provided, it must be greater or equal than 1.
|
|
154
149
|
* Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
|
|
155
|
-
|
|
150
|
+
*/
|
|
156
151
|
fromBlock?: BlockNumber;
|
|
157
152
|
/** The block number until which to fetch logs (not inclusive).
|
|
158
153
|
* Optional. If provided, it must be greater than fromBlock.
|
|
159
|
-
* Defaults to the latest known block to PXE + 1.
|
|
160
154
|
*/
|
|
161
155
|
toBlock?: BlockNumber;
|
|
162
156
|
};
|
|
163
157
|
|
|
164
158
|
/**
|
|
165
|
-
*
|
|
159
|
+
* Filter options when querying private events.
|
|
160
|
+
*/
|
|
161
|
+
export type PrivateEventFilter = EventFilterBase & {
|
|
162
|
+
/** The address of the contract that emitted the events. */
|
|
163
|
+
contractAddress: AztecAddress;
|
|
164
|
+
/** Addresses of accounts that are in scope for this filter. */
|
|
165
|
+
scopes: AztecAddress[];
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Filter options when querying public events.
|
|
166
170
|
*/
|
|
167
|
-
export type
|
|
171
|
+
export type PublicEventFilter = EventFilterBase & {
|
|
172
|
+
/** The address of the contract that emitted the events. */
|
|
173
|
+
contractAddress?: AztecAddress;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* An ABI decoded event with associated metadata.
|
|
178
|
+
* @typeParam T - The decoded event type
|
|
179
|
+
* @typeParam M - Additional metadata fields (empty by default)
|
|
180
|
+
*/
|
|
181
|
+
export type Event<T, M extends object = object> = {
|
|
168
182
|
/** The ABI decoded event */
|
|
169
183
|
event: T;
|
|
170
184
|
/** Metadata describing event context information such as tx and block */
|
|
171
|
-
metadata: InTx;
|
|
185
|
+
metadata: InTx & M;
|
|
172
186
|
};
|
|
173
187
|
|
|
188
|
+
/** An ABI decoded private event with associated metadata. */
|
|
189
|
+
export type PrivateEvent<T> = Event<T>;
|
|
190
|
+
|
|
191
|
+
/** An ABI decoded public event with associated metadata (includes contract address). */
|
|
192
|
+
export type PublicEvent<T> = Event<
|
|
193
|
+
T,
|
|
194
|
+
{
|
|
195
|
+
/**
|
|
196
|
+
* Address of the contract that emitted this event
|
|
197
|
+
*/
|
|
198
|
+
contractAddress: AztecAddress;
|
|
199
|
+
}
|
|
200
|
+
>;
|
|
201
|
+
|
|
174
202
|
/**
|
|
175
203
|
* Contract metadata including deployment and registration status.
|
|
176
204
|
*/
|
|
@@ -197,6 +225,16 @@ export type ContractClassMetadata = {
|
|
|
197
225
|
isContractClassPubliclyRegistered: boolean;
|
|
198
226
|
};
|
|
199
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Options for executing a utility function call.
|
|
230
|
+
*/
|
|
231
|
+
export type ExecuteUtilityOptions = {
|
|
232
|
+
/** The scope for the utility execution (determines which notes and keys are visible). */
|
|
233
|
+
scope: AztecAddress;
|
|
234
|
+
/** Optional auth witnesses to use during execution. */
|
|
235
|
+
authWitnesses?: AuthWitness[];
|
|
236
|
+
};
|
|
237
|
+
|
|
200
238
|
/**
|
|
201
239
|
* The wallet interface.
|
|
202
240
|
*/
|
|
@@ -217,7 +255,7 @@ export type Wallet = {
|
|
|
217
255
|
secretKey?: Fr,
|
|
218
256
|
): Promise<ContractInstanceWithAddress>;
|
|
219
257
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
220
|
-
|
|
258
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
|
|
221
259
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
222
260
|
sendTx<W extends InteractionWaitOptions = undefined>(
|
|
223
261
|
exec: ExecutionPayload,
|
|
@@ -228,19 +266,8 @@ export type Wallet = {
|
|
|
228
266
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
229
267
|
};
|
|
230
268
|
|
|
231
|
-
export const FunctionCallSchema = z.object({
|
|
232
|
-
name: z.string(),
|
|
233
|
-
to: schemas.AztecAddress,
|
|
234
|
-
selector: schemas.FunctionSelector,
|
|
235
|
-
type: z.nativeEnum(FunctionType),
|
|
236
|
-
isStatic: z.boolean(),
|
|
237
|
-
hideMsgSender: z.boolean(),
|
|
238
|
-
args: z.array(schemas.Fr),
|
|
239
|
-
returnTypes: z.array(AbiTypeSchema),
|
|
240
|
-
});
|
|
241
|
-
|
|
242
269
|
export const ExecutionPayloadSchema = z.object({
|
|
243
|
-
calls: z.array(
|
|
270
|
+
calls: z.array(FunctionCall.schema),
|
|
244
271
|
authWitnesses: z.array(AuthWitness.schema),
|
|
245
272
|
capsules: z.array(Capsule.schema),
|
|
246
273
|
extraHashedArgs: z.array(HashedValues.schema),
|
|
@@ -276,6 +303,7 @@ export const SendOptionsSchema = z.object({
|
|
|
276
303
|
capsules: optional(z.array(Capsule.schema)),
|
|
277
304
|
fee: optional(GasSettingsOptionSchema),
|
|
278
305
|
wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
|
|
306
|
+
additionalScopes: optional(z.array(schemas.AztecAddress)),
|
|
279
307
|
});
|
|
280
308
|
|
|
281
309
|
export const SimulateOptionsSchema = z.object({
|
|
@@ -286,6 +314,7 @@ export const SimulateOptionsSchema = z.object({
|
|
|
286
314
|
skipTxValidation: optional(z.boolean()),
|
|
287
315
|
skipFeeEnforcement: optional(z.boolean()),
|
|
288
316
|
includeMetadata: optional(z.boolean()),
|
|
317
|
+
additionalScopes: optional(z.array(schemas.AztecAddress)),
|
|
289
318
|
});
|
|
290
319
|
|
|
291
320
|
export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
|
|
@@ -297,7 +326,7 @@ export const MessageHashOrIntentSchema = z.union([
|
|
|
297
326
|
z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
|
|
298
327
|
z.object({
|
|
299
328
|
caller: schemas.AztecAddress,
|
|
300
|
-
call:
|
|
329
|
+
call: FunctionCall.schema,
|
|
301
330
|
}),
|
|
302
331
|
]);
|
|
303
332
|
|
|
@@ -307,6 +336,21 @@ export const EventMetadataDefinitionSchema = z.object({
|
|
|
307
336
|
fieldNames: z.array(z.string()),
|
|
308
337
|
});
|
|
309
338
|
|
|
339
|
+
const EventFilterBaseSchema = z.object({
|
|
340
|
+
txHash: optional(TxHash.schema),
|
|
341
|
+
fromBlock: optional(BlockNumberPositiveSchema),
|
|
342
|
+
toBlock: optional(BlockNumberPositiveSchema),
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
export const PrivateEventFilterSchema = EventFilterBaseSchema.extend({
|
|
346
|
+
contractAddress: schemas.AztecAddress,
|
|
347
|
+
scopes: z.array(schemas.AztecAddress),
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
export const PublicEventFilterSchema = EventFilterBaseSchema.extend({
|
|
351
|
+
contractAddress: optional(schemas.AztecAddress),
|
|
352
|
+
});
|
|
353
|
+
|
|
310
354
|
export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
|
|
311
355
|
z.object({
|
|
312
356
|
event: AbiDecodedSchema,
|
|
@@ -314,13 +358,12 @@ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded
|
|
|
314
358
|
}),
|
|
315
359
|
);
|
|
316
360
|
|
|
317
|
-
export const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
});
|
|
361
|
+
export const PublicEventSchema = zodFor<PublicEvent<AbiDecoded>>()(
|
|
362
|
+
z.object({
|
|
363
|
+
event: AbiDecodedSchema,
|
|
364
|
+
metadata: z.intersection(inTxSchema(), z.object({ contractAddress: schemas.AztecAddress })),
|
|
365
|
+
}),
|
|
366
|
+
);
|
|
324
367
|
|
|
325
368
|
export const ContractMetadataSchema = z.object({
|
|
326
369
|
instance: optional(ContractInstanceWithAddressSchema),
|
|
@@ -338,6 +381,7 @@ export const ContractClassMetadataSchema = z.object({
|
|
|
338
381
|
export const ContractFunctionPatternSchema = z.object({
|
|
339
382
|
contract: z.union([schemas.AztecAddress, z.literal('*')]),
|
|
340
383
|
function: z.union([z.string(), z.literal('*')]),
|
|
384
|
+
additionalScopes: optional(z.union([z.array(schemas.AztecAddress), z.literal('*')])),
|
|
341
385
|
});
|
|
342
386
|
|
|
343
387
|
export const AccountsCapabilitySchema = z.object({
|
|
@@ -448,6 +492,22 @@ export const WalletCapabilitiesSchema = z.object({
|
|
|
448
492
|
expiresAt: optional(z.number()),
|
|
449
493
|
});
|
|
450
494
|
|
|
495
|
+
const OffchainEffectSchema = z.object({
|
|
496
|
+
data: z.array(schemas.Fr),
|
|
497
|
+
contractAddress: schemas.AztecAddress,
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
const OffchainMessageSchema = z.object({
|
|
501
|
+
recipient: schemas.AztecAddress,
|
|
502
|
+
payload: z.array(schemas.Fr),
|
|
503
|
+
contractAddress: schemas.AztecAddress,
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
const OffchainOutputSchema = z.object({
|
|
507
|
+
offchainEffects: z.array(OffchainEffectSchema),
|
|
508
|
+
offchainMessages: z.array(OffchainMessageSchema),
|
|
509
|
+
});
|
|
510
|
+
|
|
451
511
|
/**
|
|
452
512
|
* Record of all wallet method schemas (excluding batch).
|
|
453
513
|
* This is the single source of truth for method schemas - batch schemas are derived from this.
|
|
@@ -477,15 +537,26 @@ const WalletMethodSchemas = {
|
|
|
477
537
|
.args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
|
|
478
538
|
.returns(ContractInstanceWithAddressSchema),
|
|
479
539
|
simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
|
|
480
|
-
|
|
540
|
+
executeUtility: z
|
|
481
541
|
.function()
|
|
482
|
-
.args(
|
|
483
|
-
|
|
542
|
+
.args(
|
|
543
|
+
FunctionCall.schema,
|
|
544
|
+
z.object({
|
|
545
|
+
scope: schemas.AztecAddress,
|
|
546
|
+
authWitnesses: optional(z.array(AuthWitness.schema)),
|
|
547
|
+
}),
|
|
548
|
+
)
|
|
549
|
+
.returns(UtilityExecutionResult.schema),
|
|
484
550
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
485
551
|
sendTx: z
|
|
486
552
|
.function()
|
|
487
553
|
.args(ExecutionPayloadSchema, SendOptionsSchema)
|
|
488
|
-
.returns(
|
|
554
|
+
.returns(
|
|
555
|
+
z.union([
|
|
556
|
+
z.object({ txHash: TxHash.schema }).merge(OffchainOutputSchema),
|
|
557
|
+
z.object({ receipt: TxReceipt.schema }).merge(OffchainOutputSchema),
|
|
558
|
+
]),
|
|
559
|
+
),
|
|
489
560
|
createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
|
|
490
561
|
requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
|
|
491
562
|
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
3
|
-
import type { Wallet } from '../wallet/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
6
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
7
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
8
|
-
* @param wallet - Wallet to send the transaction.
|
|
9
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
10
|
-
* @param selector - Selector of the function to be broadcast.
|
|
11
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
12
|
-
*/
|
|
13
|
-
export declare function broadcastPrivateFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
14
|
-
/**
|
|
15
|
-
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
16
|
-
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
17
|
-
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
18
|
-
* @param wallet - Wallet to send the transaction.
|
|
19
|
-
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
20
|
-
* @param selector - Selector of the function to be broadcast.
|
|
21
|
-
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
22
|
-
*/
|
|
23
|
-
export declare function broadcastUtilityFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvYWRjYXN0X2Z1bmN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVwbG95bWVudC9icm9hZGNhc3RfZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQWdDLE1BQU0sbUJBQW1CLENBQUM7QUFTMUcsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSw4Q0FBOEMsQ0FBQztBQUVoRyxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVqRDs7Ozs7Ozs7R0FRRztBQUNILHdCQUFzQix3QkFBd0IsQ0FDNUMsTUFBTSxFQUFFLE1BQU0sRUFDZCxRQUFRLEVBQUUsZ0JBQWdCLEVBQzFCLFFBQVEsRUFBRSxnQkFBZ0IsR0FDekIsT0FBTyxDQUFDLDJCQUEyQixDQUFDLENBb0R0QztBQUVEOzs7Ozs7OztHQVFHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxNQUFNLEVBQUUsTUFBTSxFQUNkLFFBQVEsRUFBRSxnQkFBZ0IsRUFDMUIsUUFBUSxFQUFFLGdCQUFnQixHQUN6QixPQUFPLENBQUMsMkJBQTJCLENBQUMsQ0E4Q3RDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CA8CtC"}
|