@aztec/aztec.js 0.0.1-commit.d3ec352c → 0.0.1-commit.f295ac2
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 +4 -4
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +1 -1
- package/dest/account/account_contract.d.ts +3 -3
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +4 -3
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/index.d.ts +2 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/interface.d.ts +2 -2
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/signerless_account.d.ts +2 -2
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/api/block.d.ts +2 -2
- package/dest/api/block.d.ts.map +1 -1
- package/dest/api/block.js +1 -1
- package/dest/api/fields.d.ts +3 -2
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +2 -1
- 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/wallet.d.ts +2 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -1
- package/dest/authorization/call_authorization_request.d.ts +23 -2
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/batch_call.d.ts +1 -1
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +3 -1
- 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 +1 -1
- package/dest/contract/deploy_method.d.ts +2 -2
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +6 -5
- 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 +928 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +797 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +867 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +824 -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 +576 -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 +592 -0
- package/dest/contract/sent_tx.d.ts +2 -3
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +4 -4
- package/dest/deployment/publish_class.js +3 -3
- 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 +9 -6
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +17 -18
- package/dest/fee/fee_juice_payment_method_with_claim.js +1 -1
- package/dest/fee/private_fee_payment_method.js +1 -1
- package/dest/fee/public_fee_payment_method.js +1 -1
- 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/abi_types.d.ts +2 -2
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +2 -2
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +1 -1
- package/dest/utils/cross_chain.d.ts +2 -2
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/pub_key.d.ts +2 -2
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -1
- package/dest/wallet/account_manager.d.ts +6 -3
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +1 -1
- package/dest/wallet/deploy_account_method.d.ts +2 -2
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +1 -1
- package/dest/wallet/wallet.d.ts +241 -954
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +61 -87
- package/package.json +14 -12
- package/src/account/account.ts +1 -1
- package/src/account/account_contract.ts +1 -1
- package/src/account/account_with_secret_key.ts +1 -1
- package/src/account/index.ts +1 -1
- package/src/account/interface.ts +1 -1
- package/src/account/signerless_account.ts +1 -1
- package/src/api/block.ts +1 -1
- package/src/api/fields.ts +2 -1
- package/src/api/protocol.ts +7 -0
- package/src/api/wallet.ts +4 -2
- package/src/authorization/call_authorization_request.ts +1 -1
- package/src/contract/batch_call.ts +4 -2
- package/src/contract/deploy_method.ts +8 -7
- package/src/contract/protocol_contracts/auth-registry.ts +542 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +442 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +501 -0
- package/src/contract/protocol_contracts/fee-juice.ts +462 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +338 -0
- package/src/contract/protocol_contracts/public-checks.ts +324 -0
- package/src/contract/sent_tx.ts +1 -2
- package/src/deployment/broadcast_function.ts +4 -4
- package/src/deployment/publish_class.ts +3 -3
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +20 -24
- package/src/fee/fee_juice_payment_method_with_claim.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +1 -1
- package/src/fee/public_fee_payment_method.ts +1 -1
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +1 -1
- package/src/utils/cross_chain.ts +1 -1
- package/src/utils/fee_juice.ts +1 -1
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/pub_key.ts +2 -2
- package/src/wallet/account_manager.ts +1 -1
- package/src/wallet/deploy_account_method.ts +1 -1
- package/src/wallet/wallet.ts +161 -81
- 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/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/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/unsafe_contract.ts +0 -19
package/src/wallet/wallet.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import
|
|
2
|
+
import { BlockNumber, BlockNumberPositiveSchema } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import {
|
|
5
|
+
type AbiDecoded,
|
|
4
6
|
AbiTypeSchema,
|
|
5
7
|
type ContractArtifact,
|
|
6
8
|
ContractArtifactSchema,
|
|
@@ -10,15 +12,9 @@ import {
|
|
|
10
12
|
} from '@aztec/stdlib/abi';
|
|
11
13
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
12
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import {
|
|
14
|
-
type ContractClassMetadata,
|
|
15
|
-
ContractClassWithIdSchema,
|
|
16
|
-
type ContractInstanceWithAddress,
|
|
17
|
-
ContractInstanceWithAddressSchema,
|
|
18
|
-
type ContractMetadata,
|
|
19
|
-
} from '@aztec/stdlib/contract';
|
|
15
|
+
import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
|
|
20
16
|
import { Gas } from '@aztec/stdlib/gas';
|
|
21
|
-
import { AbiDecodedSchema, type ApiSchemaFor,
|
|
17
|
+
import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
22
18
|
import {
|
|
23
19
|
Capsule,
|
|
24
20
|
HashedValues,
|
|
@@ -27,8 +23,9 @@ import {
|
|
|
27
23
|
TxReceipt,
|
|
28
24
|
TxSimulationResult,
|
|
29
25
|
UtilitySimulationResult,
|
|
26
|
+
inTxSchema,
|
|
30
27
|
} from '@aztec/stdlib/tx';
|
|
31
|
-
import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
28
|
+
import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
|
|
32
29
|
|
|
33
30
|
import { z } from 'zod';
|
|
34
31
|
|
|
@@ -57,7 +54,7 @@ export type Aliased<T> = {
|
|
|
57
54
|
|
|
58
55
|
/**
|
|
59
56
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
60
|
-
* a simplified version that only hints at the wallet
|
|
57
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
61
58
|
* fee payment method or not
|
|
62
59
|
*/
|
|
63
60
|
export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
@@ -67,7 +64,7 @@ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
|
67
64
|
|
|
68
65
|
/**
|
|
69
66
|
* Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
|
|
70
|
-
* a simplified version that only hints at the wallet
|
|
67
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
71
68
|
* fee payment method or not
|
|
72
69
|
*/
|
|
73
70
|
export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
@@ -77,7 +74,7 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
|
77
74
|
|
|
78
75
|
/**
|
|
79
76
|
* Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
|
|
80
|
-
* a simplified version that only hints at the wallet
|
|
77
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
81
78
|
* fee payment method or not
|
|
82
79
|
*/
|
|
83
80
|
export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
@@ -86,36 +83,40 @@ export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
|
86
83
|
};
|
|
87
84
|
|
|
88
85
|
/**
|
|
89
|
-
* Helper type that represents all methods that can be batched.
|
|
86
|
+
* Helper type that represents all methods that can be batched (all methods except batch itself).
|
|
90
87
|
*/
|
|
91
|
-
export type BatchableMethods =
|
|
92
|
-
Wallet,
|
|
93
|
-
'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility' | 'simulateTx'
|
|
94
|
-
>;
|
|
88
|
+
export type BatchableMethods = Omit<Wallet, 'batch'>;
|
|
95
89
|
|
|
96
90
|
/**
|
|
97
|
-
*
|
|
98
|
-
* This is what the wallet will accept as arguments to the `batch` method.
|
|
91
|
+
* A method call with its name and arguments.
|
|
99
92
|
*/
|
|
100
|
-
|
|
93
|
+
type BatchedMethodInternal<T extends keyof BatchableMethods> = {
|
|
101
94
|
/** The method name */
|
|
102
95
|
name: T;
|
|
103
96
|
/** The method arguments */
|
|
104
97
|
args: Parameters<BatchableMethods[T]>;
|
|
105
98
|
};
|
|
106
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Union of all possible batched method calls.
|
|
102
|
+
* This ensures type safety: the `args` must match the specific `name`.
|
|
103
|
+
*/
|
|
104
|
+
export type BatchedMethod = {
|
|
105
|
+
[K in keyof BatchableMethods]: BatchedMethodInternal<K>;
|
|
106
|
+
}[keyof BatchableMethods];
|
|
107
|
+
|
|
107
108
|
/**
|
|
108
109
|
* Helper type to extract the return type of a batched method
|
|
109
110
|
*/
|
|
110
111
|
export type BatchedMethodResult<T> =
|
|
111
|
-
T extends
|
|
112
|
+
T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
|
|
112
113
|
|
|
113
114
|
/**
|
|
114
115
|
* Wrapper type for batch results that includes the method name for discriminated union deserialization.
|
|
115
116
|
* Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
|
|
116
117
|
* when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
|
|
117
118
|
*/
|
|
118
|
-
export type BatchedMethodResultWrapper<T extends BatchedMethod
|
|
119
|
+
export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
|
|
119
120
|
/** The method name */
|
|
120
121
|
name: T['name'];
|
|
121
122
|
/** The method result */
|
|
@@ -125,25 +126,80 @@ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMe
|
|
|
125
126
|
/**
|
|
126
127
|
* Maps a tuple of BatchedMethod to a tuple of their wrapped return types
|
|
127
128
|
*/
|
|
128
|
-
export type BatchResults<T extends readonly BatchedMethod
|
|
129
|
+
export type BatchResults<T extends readonly BatchedMethod[]> = {
|
|
129
130
|
[K in keyof T]: BatchedMethodResultWrapper<T[K]>;
|
|
130
131
|
};
|
|
131
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Filter options when querying private events.
|
|
135
|
+
*/
|
|
136
|
+
export type PrivateEventFilter = {
|
|
137
|
+
/** The address of the contract that emitted the events. */
|
|
138
|
+
contractAddress: AztecAddress;
|
|
139
|
+
/** Addresses of accounts that are in scope for this filter. */
|
|
140
|
+
scopes: AztecAddress[];
|
|
141
|
+
/** Transaction in which the events were emitted. */
|
|
142
|
+
txHash?: TxHash;
|
|
143
|
+
/** The block number from which to start fetching events (inclusive).
|
|
144
|
+
* Optional. If provided, it must be greater or equal than 1.
|
|
145
|
+
* Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
|
|
146
|
+
* */
|
|
147
|
+
fromBlock?: BlockNumber;
|
|
148
|
+
/** The block number until which to fetch logs (not inclusive).
|
|
149
|
+
* Optional. If provided, it must be greater than fromBlock.
|
|
150
|
+
* Defaults to the latest known block to PXE + 1.
|
|
151
|
+
*/
|
|
152
|
+
toBlock?: BlockNumber;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* An ABI decoded private event with associated metadata.
|
|
157
|
+
*/
|
|
158
|
+
export type PrivateEvent<T> = {
|
|
159
|
+
/** The ABI decoded event */
|
|
160
|
+
event: T;
|
|
161
|
+
/** Metadata describing event context information such as tx and block */
|
|
162
|
+
metadata: InTx;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Contract metadata including deployment and registration status.
|
|
167
|
+
*/
|
|
168
|
+
export type ContractMetadata = {
|
|
169
|
+
/** The contract instance */
|
|
170
|
+
instance?: ContractInstanceWithAddress;
|
|
171
|
+
/** Whether the contract has been initialized (init nullifier exists) */
|
|
172
|
+
isContractInitialized: boolean;
|
|
173
|
+
/** Whether the contract instance is publicly deployed on-chain */
|
|
174
|
+
isContractPublished: boolean;
|
|
175
|
+
/** Whether the contract has been updated to a different class */
|
|
176
|
+
isContractUpdated: boolean;
|
|
177
|
+
/** The updated contract class ID if the contract has been updated */
|
|
178
|
+
updatedContractClassId?: Fr | undefined;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Contract class metadata.
|
|
183
|
+
*/
|
|
184
|
+
export type ContractClassMetadata = {
|
|
185
|
+
/** Whether the artifact is registered in the wallet */
|
|
186
|
+
isArtifactRegistered: boolean;
|
|
187
|
+
/** Whether the contract class is publicly registered on-chain */
|
|
188
|
+
isContractClassPubliclyRegistered: boolean;
|
|
189
|
+
};
|
|
190
|
+
|
|
132
191
|
/**
|
|
133
192
|
* The wallet interface.
|
|
134
193
|
*/
|
|
135
194
|
export type Wallet = {
|
|
136
|
-
getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
|
|
137
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
138
195
|
getPrivateEvents<T>(
|
|
139
|
-
contractAddress: AztecAddress,
|
|
140
196
|
eventMetadata: EventMetadataDefinition,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
recipients: AztecAddress[],
|
|
144
|
-
): Promise<T[]>;
|
|
197
|
+
eventFilter: PrivateEventFilter,
|
|
198
|
+
): Promise<PrivateEvent<T>[]>;
|
|
145
199
|
getChainInfo(): Promise<ChainInfo>;
|
|
146
200
|
getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
|
|
201
|
+
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
202
|
+
getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
|
|
147
203
|
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
|
|
148
204
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
149
205
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
@@ -157,7 +213,7 @@ export type Wallet = {
|
|
|
157
213
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
158
214
|
sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
|
|
159
215
|
createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
160
|
-
batch<const T extends readonly BatchedMethod
|
|
216
|
+
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
161
217
|
};
|
|
162
218
|
|
|
163
219
|
export const FunctionCallSchema = z.object({
|
|
@@ -226,59 +282,56 @@ export const MessageHashOrIntentSchema = z.union([
|
|
|
226
282
|
}),
|
|
227
283
|
]);
|
|
228
284
|
|
|
229
|
-
export const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
args: z.tuple([ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
|
|
237
|
-
}),
|
|
238
|
-
z.object({
|
|
239
|
-
name: z.literal('sendTx'),
|
|
240
|
-
args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
|
|
241
|
-
}),
|
|
242
|
-
z.object({
|
|
243
|
-
name: z.literal('simulateUtility'),
|
|
244
|
-
args: z.tuple([FunctionCallSchema, optional(z.array(AuthWitness.schema))]),
|
|
245
|
-
}),
|
|
285
|
+
export const EventMetadataDefinitionSchema = z.object({
|
|
286
|
+
eventSelector: schemas.EventSelector,
|
|
287
|
+
abiType: AbiTypeSchema,
|
|
288
|
+
fieldNames: z.array(z.string()),
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
|
|
246
292
|
z.object({
|
|
247
|
-
|
|
248
|
-
|
|
293
|
+
event: AbiDecodedSchema,
|
|
294
|
+
metadata: inTxSchema(),
|
|
249
295
|
}),
|
|
250
|
-
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
export const PrivateEventFilterSchema = z.object({
|
|
299
|
+
contractAddress: schemas.AztecAddress,
|
|
300
|
+
scopes: z.array(schemas.AztecAddress),
|
|
301
|
+
txHash: optional(TxHash.schema),
|
|
302
|
+
fromBlock: optional(BlockNumberPositiveSchema),
|
|
303
|
+
toBlock: optional(BlockNumberPositiveSchema),
|
|
304
|
+
});
|
|
251
305
|
|
|
252
306
|
export const ContractMetadataSchema = z.object({
|
|
253
|
-
|
|
307
|
+
instance: optional(ContractInstanceWithAddressSchema),
|
|
254
308
|
isContractInitialized: z.boolean(),
|
|
255
309
|
isContractPublished: z.boolean(),
|
|
256
|
-
|
|
310
|
+
isContractUpdated: z.boolean(),
|
|
311
|
+
updatedContractClassId: optional(schemas.Fr),
|
|
312
|
+
});
|
|
257
313
|
|
|
258
314
|
export const ContractClassMetadataSchema = z.object({
|
|
259
|
-
|
|
315
|
+
isArtifactRegistered: z.boolean(),
|
|
260
316
|
isContractClassPubliclyRegistered: z.boolean(),
|
|
261
|
-
artifact: z.union([ContractArtifactSchema, z.undefined()]),
|
|
262
|
-
}) satisfies ZodFor<ContractClassMetadata>;
|
|
263
|
-
|
|
264
|
-
export const EventMetadataDefinitionSchema = z.object({
|
|
265
|
-
eventSelector: schemas.EventSelector,
|
|
266
|
-
abiType: AbiTypeSchema,
|
|
267
|
-
fieldNames: z.array(z.string()),
|
|
268
317
|
});
|
|
269
318
|
|
|
270
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Record of all wallet method schemas (excluding batch).
|
|
321
|
+
* This is the single source of truth for method schemas - batch schemas are derived from this.
|
|
322
|
+
*/
|
|
323
|
+
const WalletMethodSchemas = {
|
|
271
324
|
getChainInfo: z
|
|
272
325
|
.function()
|
|
273
326
|
.args()
|
|
274
327
|
.returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
|
|
275
|
-
getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
|
|
276
|
-
getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
|
|
277
328
|
getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
|
|
329
|
+
getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
|
|
330
|
+
getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
|
|
278
331
|
getPrivateEvents: z
|
|
279
332
|
.function()
|
|
280
|
-
.args(
|
|
281
|
-
.returns(z.array(
|
|
333
|
+
.args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
|
|
334
|
+
.returns(z.array(PrivateEventSchema)),
|
|
282
335
|
registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
|
|
283
336
|
getAddressBook: z
|
|
284
337
|
.function()
|
|
@@ -300,19 +353,46 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
300
353
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
301
354
|
sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
|
|
302
355
|
createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Creates batch schemas from the individual wallet methods.
|
|
360
|
+
* This allows us to define them once and derive batch schemas automatically,
|
|
361
|
+
* reducing duplication and ensuring consistency.
|
|
362
|
+
*/
|
|
363
|
+
function createBatchSchemas<T extends Record<string, z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>>(
|
|
364
|
+
methodSchemas: T,
|
|
365
|
+
) {
|
|
366
|
+
const names = Object.keys(methodSchemas) as (keyof T)[];
|
|
367
|
+
|
|
368
|
+
const namesAndArgs = names.map(name =>
|
|
369
|
+
z.object({
|
|
370
|
+
name: z.literal(name),
|
|
371
|
+
args: methodSchemas[name].parameters(),
|
|
372
|
+
}),
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
const namesAndReturns = names.map(name =>
|
|
376
|
+
z.object({
|
|
377
|
+
name: z.literal(name),
|
|
378
|
+
result: methodSchemas[name].returnType(),
|
|
379
|
+
}),
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
// Type assertion needed because discriminatedUnion expects a tuple type [T, T, ...T[]]
|
|
383
|
+
// but we're building the array dynamically. The runtime behavior is correct.
|
|
384
|
+
return {
|
|
385
|
+
input: z.discriminatedUnion('name', namesAndArgs as [(typeof namesAndArgs)[0], ...typeof namesAndArgs]),
|
|
386
|
+
output: z.discriminatedUnion('name', namesAndReturns as [(typeof namesAndReturns)[0], ...typeof namesAndReturns]),
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const { input: BatchedMethodSchema, output: BatchedResultSchema } = createBatchSchemas(WalletMethodSchemas);
|
|
391
|
+
|
|
392
|
+
export { BatchedMethodSchema, BatchedResultSchema };
|
|
393
|
+
|
|
394
|
+
export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
395
|
+
...WalletMethodSchemas,
|
|
303
396
|
// @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
|
|
304
|
-
batch: z
|
|
305
|
-
.function()
|
|
306
|
-
.args(z.array(BatchedMethodSchema))
|
|
307
|
-
.returns(
|
|
308
|
-
z.array(
|
|
309
|
-
z.discriminatedUnion('name', [
|
|
310
|
-
z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
|
|
311
|
-
z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
|
|
312
|
-
z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
|
|
313
|
-
z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
|
|
314
|
-
z.object({ name: z.literal('simulateTx'), result: TxSimulationResult.schema }),
|
|
315
|
-
]),
|
|
316
|
-
),
|
|
317
|
-
),
|
|
397
|
+
batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(BatchedResultSchema)),
|
|
318
398
|
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
2
|
-
import { UnsafeContract } from './unsafe_contract.js';
|
|
3
|
-
/** Returns a Contract wrapper for the contract class registry. */
|
|
4
|
-
export declare function getClassRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
|
|
5
|
-
/** Returns a Contract wrapper for the contract instance registry. */
|
|
6
|
-
export declare function getInstanceRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
|
|
7
|
-
/** Returns a Contract wrapper for the fee juice contract */
|
|
8
|
-
export declare function getFeeJuice(wallet: Wallet): Promise<UnsafeContract>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdG9jb2xfY29udHJhY3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvcHJvdG9jb2xfY29udHJhY3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ2xELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxrRUFBa0U7QUFDbEUsd0JBQXNCLHdCQUF3QixDQUFDLE1BQU0sRUFBRSxNQUFNLDJCQVE1RDtBQUVELHFFQUFxRTtBQUNyRSx3QkFBc0IsMkJBQTJCLENBQUMsTUFBTSxFQUFFLE1BQU0sMkJBTy9EO0FBRUQsNERBQTREO0FBQzVELHdCQUFzQixXQUFXLENBQUMsTUFBTSxFQUFFLE1BQU0sMkJBTy9DIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol_contracts.d.ts","sourceRoot":"","sources":["../../src/contract/protocol_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,kEAAkE;AAClE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,MAAM,2BAQ5D;AAED,qEAAqE;AACrE,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,MAAM,2BAO/D;AAED,4DAA4D;AAC5D,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,2BAO/C"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
|
-
import { UnsafeContract } from './unsafe_contract.js';
|
|
3
|
-
/** Returns a Contract wrapper for the contract class registry. */ export async function getClassRegistryContract(wallet) {
|
|
4
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
|
|
5
|
-
if (!contractInstance) {
|
|
6
|
-
throw new Error("ContractClassRegistry is not registered in this wallet's instance");
|
|
7
|
-
}
|
|
8
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
9
|
-
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
10
|
-
}
|
|
11
|
-
/** Returns a Contract wrapper for the contract instance registry. */ export async function getInstanceRegistryContract(wallet) {
|
|
12
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
|
|
13
|
-
if (!contractInstance) {
|
|
14
|
-
throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
|
|
15
|
-
}
|
|
16
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
17
|
-
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
18
|
-
}
|
|
19
|
-
/** Returns a Contract wrapper for the fee juice contract */ export async function getFeeJuice(wallet) {
|
|
20
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
|
|
21
|
-
if (!contractInstance) {
|
|
22
|
-
throw new Error("FeeJuice is not registered in this wallet's instance");
|
|
23
|
-
}
|
|
24
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
25
|
-
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
26
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
4
|
-
import { ContractBase } from './contract_base.js';
|
|
5
|
-
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
|
|
6
|
-
export declare class UnsafeContract extends ContractBase {
|
|
7
|
-
constructor(
|
|
8
|
-
/** The deployed contract instance definition. */
|
|
9
|
-
instance: ContractInstanceWithAddress,
|
|
10
|
-
/** The Application Binary Interface for the contract. */
|
|
11
|
-
artifact: ContractArtifact,
|
|
12
|
-
/** The wallet used for interacting with this contract. */
|
|
13
|
-
wallet: Wallet);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5zYWZlX2NvbnRyYWN0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvdW5zYWZlX2NvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUUxRSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFbEQsaUhBQWlIO0FBQ2pILHFCQUFhLGNBQWUsU0FBUSxZQUFZO0lBQzlDO0lBQ0UsaURBQWlEO0lBQ2pELFFBQVEsRUFBRSwyQkFBMkI7SUFDckMseURBQXlEO0lBQ3pELFFBQVEsRUFBRSxnQkFBZ0I7SUFDMUIsMERBQTBEO0lBQzFELE1BQU0sRUFBRSxNQUFNLEVBR2Y7Q0FDRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unsafe_contract.d.ts","sourceRoot":"","sources":["../../src/contract/unsafe_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,iHAAiH;AACjH,qBAAa,cAAe,SAAQ,YAAY;IAC9C;IACE,iDAAiD;IACjD,QAAQ,EAAE,2BAA2B;IACrC,yDAAyD;IACzD,QAAQ,EAAE,gBAAgB;IAC1B,0DAA0D;IAC1D,MAAM,EAAE,MAAM,EAGf;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ContractBase } from './contract_base.js';
|
|
2
|
-
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */ export class UnsafeContract extends ContractBase {
|
|
3
|
-
constructor(/** The deployed contract instance definition. */ instance, /** The Application Binary Interface for the contract. */ artifact, /** The wallet used for interacting with this contract. */ wallet){
|
|
4
|
-
super(instance.address, artifact, wallet);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
|
-
|
|
3
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
4
|
-
import { UnsafeContract } from './unsafe_contract.js';
|
|
5
|
-
|
|
6
|
-
/** Returns a Contract wrapper for the contract class registry. */
|
|
7
|
-
export async function getClassRegistryContract(wallet: Wallet) {
|
|
8
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
|
|
9
|
-
if (!contractInstance) {
|
|
10
|
-
throw new Error("ContractClassRegistry is not registered in this wallet's instance");
|
|
11
|
-
}
|
|
12
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
13
|
-
|
|
14
|
-
return new UnsafeContract(contractInstance!, artifact!, wallet);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Returns a Contract wrapper for the contract instance registry. */
|
|
18
|
-
export async function getInstanceRegistryContract(wallet: Wallet) {
|
|
19
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
|
|
20
|
-
if (!contractInstance) {
|
|
21
|
-
throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
|
|
22
|
-
}
|
|
23
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
24
|
-
return new UnsafeContract(contractInstance!, artifact!, wallet);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Returns a Contract wrapper for the fee juice contract */
|
|
28
|
-
export async function getFeeJuice(wallet: Wallet) {
|
|
29
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
|
|
30
|
-
if (!contractInstance) {
|
|
31
|
-
throw new Error("FeeJuice is not registered in this wallet's instance");
|
|
32
|
-
}
|
|
33
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
34
|
-
return new UnsafeContract(contractInstance!, artifact!, wallet);
|
|
35
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
|
|
4
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
5
|
-
import { ContractBase } from './contract_base.js';
|
|
6
|
-
|
|
7
|
-
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
|
|
8
|
-
export class UnsafeContract extends ContractBase {
|
|
9
|
-
constructor(
|
|
10
|
-
/** The deployed contract instance definition. */
|
|
11
|
-
instance: ContractInstanceWithAddress,
|
|
12
|
-
/** The Application Binary Interface for the contract. */
|
|
13
|
-
artifact: ContractArtifact,
|
|
14
|
-
/** The wallet used for interacting with this contract. */
|
|
15
|
-
wallet: Wallet,
|
|
16
|
-
) {
|
|
17
|
-
super(instance.address, artifact, wallet);
|
|
18
|
-
}
|
|
19
|
-
}
|