@aztec/aztec.js 0.0.1-commit.96bb3f7 → 0.0.1-commit.a072138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account/account.d.ts +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +8 -9
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +19 -7
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +3 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +5 -6
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/contract.d.ts +16 -10
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +14 -8
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/authorization/call_authorization_request.d.ts +22 -1
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/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 +63 -16
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +41 -23
- package/dest/contract/interaction_options.d.ts +42 -5
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +8 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +27 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +558 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +26 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +385 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +426 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +575 -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 +583 -0
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/broadcast_function.js +3 -3
- package/dest/deployment/publish_class.js +2 -2
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +3 -1
- package/dest/ethereum/portal_manager.d.ts.map +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/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +5 -9
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +5 -8
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +5 -11
- package/dest/wallet/capabilities.d.ts +444 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +34 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +7 -5
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1460 -2424
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +179 -86
- package/package.json +14 -12
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +6 -7
- package/src/account/account_with_secret_key.ts +33 -8
- package/src/account/index.ts +2 -1
- package/src/account/signerless_account.ts +13 -12
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +22 -7
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +43 -2
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +2 -2
- package/src/contract/deploy_method.ts +122 -29
- package/src/contract/interaction_options.ts +49 -4
- package/src/contract/protocol_contracts/auth-registry.ts +351 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +241 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +264 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +332 -0
- package/src/contract/protocol_contracts/public-checks.ts +316 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/broadcast_function.ts +3 -3
- package/src/deployment/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/authwit.ts +19 -7
- package/src/utils/node.ts +62 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +5 -13
- package/src/wallet/capabilities.ts +491 -0
- package/src/wallet/deploy_account_method.ts +37 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +257 -93
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -129
- package/src/contract/unsafe_contract.ts +0 -19
package/src/wallet/wallet.ts
CHANGED
|
@@ -12,15 +12,10 @@ import {
|
|
|
12
12
|
} from '@aztec/stdlib/abi';
|
|
13
13
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
14
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import {
|
|
16
|
-
type ContractClassMetadata,
|
|
17
|
-
ContractClassWithIdSchema,
|
|
18
|
-
type ContractInstanceWithAddress,
|
|
19
|
-
ContractInstanceWithAddressSchema,
|
|
20
|
-
type ContractMetadata,
|
|
21
|
-
} from '@aztec/stdlib/contract';
|
|
15
|
+
import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
|
|
22
16
|
import { Gas } from '@aztec/stdlib/gas';
|
|
23
17
|
import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
18
|
+
import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
|
|
24
19
|
import {
|
|
25
20
|
Capsule,
|
|
26
21
|
HashedValues,
|
|
@@ -31,18 +26,21 @@ import {
|
|
|
31
26
|
UtilitySimulationResult,
|
|
32
27
|
inTxSchema,
|
|
33
28
|
} from '@aztec/stdlib/tx';
|
|
34
|
-
import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
|
|
35
29
|
|
|
36
30
|
import { z } from 'zod';
|
|
37
31
|
|
|
38
|
-
import
|
|
39
|
-
FeeEstimationOptions,
|
|
40
|
-
GasSettingsOption,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
import {
|
|
33
|
+
type FeeEstimationOptions,
|
|
34
|
+
type GasSettingsOption,
|
|
35
|
+
type InteractionWaitOptions,
|
|
36
|
+
NO_WAIT,
|
|
37
|
+
type ProfileInteractionOptions,
|
|
38
|
+
type SendInteractionOptionsWithoutWait,
|
|
39
|
+
type SendReturn,
|
|
40
|
+
type SimulateInteractionOptions,
|
|
44
41
|
} from '../contract/interaction_options.js';
|
|
45
42
|
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
43
|
+
import type { AppCapabilities, WalletCapabilities } from './capabilities.js';
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
46
|
* A wrapper type that allows any item to be associated with an alias.
|
|
@@ -60,7 +58,7 @@ export type Aliased<T> = {
|
|
|
60
58
|
|
|
61
59
|
/**
|
|
62
60
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
63
|
-
* a simplified version that only hints at the wallet
|
|
61
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
64
62
|
* fee payment method or not
|
|
65
63
|
*/
|
|
66
64
|
export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
@@ -70,7 +68,7 @@ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
|
70
68
|
|
|
71
69
|
/**
|
|
72
70
|
* Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
|
|
73
|
-
* a simplified version that only hints at the wallet
|
|
71
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
74
72
|
* fee payment method or not
|
|
75
73
|
*/
|
|
76
74
|
export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
@@ -80,45 +78,54 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
|
80
78
|
|
|
81
79
|
/**
|
|
82
80
|
* Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
|
|
83
|
-
* a simplified version that only hints at the wallet
|
|
81
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
84
82
|
* fee payment method or not
|
|
85
83
|
*/
|
|
86
|
-
export type SendOptions =
|
|
84
|
+
export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
|
|
85
|
+
SendInteractionOptionsWithoutWait,
|
|
86
|
+
'fee'
|
|
87
|
+
> & {
|
|
87
88
|
/** The fee options */
|
|
88
89
|
fee?: GasSettingsOption;
|
|
90
|
+
/** Whether to wait for the transaction to be mined */
|
|
91
|
+
wait?: W;
|
|
89
92
|
};
|
|
90
93
|
|
|
91
94
|
/**
|
|
92
|
-
* Helper type that represents all methods that can be batched.
|
|
95
|
+
* Helper type that represents all methods that can be batched (all methods except batch itself).
|
|
93
96
|
*/
|
|
94
|
-
export type BatchableMethods =
|
|
95
|
-
Wallet,
|
|
96
|
-
'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility' | 'simulateTx'
|
|
97
|
-
>;
|
|
97
|
+
export type BatchableMethods = Omit<Wallet, 'batch'>;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
* This is what the wallet will accept as arguments to the `batch` method.
|
|
100
|
+
* A method call with its name and arguments.
|
|
102
101
|
*/
|
|
103
|
-
|
|
102
|
+
type BatchedMethodInternal<T extends keyof BatchableMethods> = {
|
|
104
103
|
/** The method name */
|
|
105
104
|
name: T;
|
|
106
105
|
/** The method arguments */
|
|
107
106
|
args: Parameters<BatchableMethods[T]>;
|
|
108
107
|
};
|
|
109
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Union of all possible batched method calls.
|
|
111
|
+
* This ensures type safety: the `args` must match the specific `name`.
|
|
112
|
+
*/
|
|
113
|
+
export type BatchedMethod = {
|
|
114
|
+
[K in keyof BatchableMethods]: BatchedMethodInternal<K>;
|
|
115
|
+
}[keyof BatchableMethods];
|
|
116
|
+
|
|
110
117
|
/**
|
|
111
118
|
* Helper type to extract the return type of a batched method
|
|
112
119
|
*/
|
|
113
120
|
export type BatchedMethodResult<T> =
|
|
114
|
-
T extends
|
|
121
|
+
T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
|
|
115
122
|
|
|
116
123
|
/**
|
|
117
124
|
* Wrapper type for batch results that includes the method name for discriminated union deserialization.
|
|
118
125
|
* Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
|
|
119
126
|
* when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
|
|
120
127
|
*/
|
|
121
|
-
export type BatchedMethodResultWrapper<T extends BatchedMethod
|
|
128
|
+
export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
|
|
122
129
|
/** The method name */
|
|
123
130
|
name: T['name'];
|
|
124
131
|
/** The method result */
|
|
@@ -128,7 +135,7 @@ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMe
|
|
|
128
135
|
/**
|
|
129
136
|
* Maps a tuple of BatchedMethod to a tuple of their wrapped return types
|
|
130
137
|
*/
|
|
131
|
-
export type BatchResults<T extends readonly BatchedMethod
|
|
138
|
+
export type BatchResults<T extends readonly BatchedMethod[]> = {
|
|
132
139
|
[K in keyof T]: BatchedMethodResultWrapper<T[K]>;
|
|
133
140
|
};
|
|
134
141
|
|
|
@@ -164,18 +171,43 @@ export type PrivateEvent<T> = {
|
|
|
164
171
|
metadata: InTx;
|
|
165
172
|
};
|
|
166
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Contract metadata including deployment and registration status.
|
|
176
|
+
*/
|
|
177
|
+
export type ContractMetadata = {
|
|
178
|
+
/** The contract instance */
|
|
179
|
+
instance?: ContractInstanceWithAddress;
|
|
180
|
+
/** Whether the contract has been initialized (init nullifier exists) */
|
|
181
|
+
isContractInitialized: boolean;
|
|
182
|
+
/** Whether the contract instance is publicly deployed on-chain */
|
|
183
|
+
isContractPublished: boolean;
|
|
184
|
+
/** Whether the contract has been updated to a different class */
|
|
185
|
+
isContractUpdated: boolean;
|
|
186
|
+
/** The updated contract class ID if the contract has been updated */
|
|
187
|
+
updatedContractClassId?: Fr | undefined;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Contract class metadata.
|
|
192
|
+
*/
|
|
193
|
+
export type ContractClassMetadata = {
|
|
194
|
+
/** Whether the artifact is registered in the wallet */
|
|
195
|
+
isArtifactRegistered: boolean;
|
|
196
|
+
/** Whether the contract class is publicly registered on-chain */
|
|
197
|
+
isContractClassPubliclyRegistered: boolean;
|
|
198
|
+
};
|
|
199
|
+
|
|
167
200
|
/**
|
|
168
201
|
* The wallet interface.
|
|
169
202
|
*/
|
|
170
203
|
export type Wallet = {
|
|
171
|
-
getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
|
|
172
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
173
204
|
getPrivateEvents<T>(
|
|
174
205
|
eventMetadata: EventMetadataDefinition,
|
|
175
206
|
eventFilter: PrivateEventFilter,
|
|
176
207
|
): Promise<PrivateEvent<T>[]>;
|
|
177
208
|
getChainInfo(): Promise<ChainInfo>;
|
|
178
|
-
|
|
209
|
+
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
210
|
+
getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
|
|
179
211
|
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
|
|
180
212
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
181
213
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
@@ -187,9 +219,13 @@ export type Wallet = {
|
|
|
187
219
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
188
220
|
simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
|
|
189
221
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
190
|
-
sendTx
|
|
191
|
-
|
|
192
|
-
|
|
222
|
+
sendTx<W extends InteractionWaitOptions = undefined>(
|
|
223
|
+
exec: ExecutionPayload,
|
|
224
|
+
opts: SendOptions<W>,
|
|
225
|
+
): Promise<SendReturn<W>>;
|
|
226
|
+
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
227
|
+
requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities>;
|
|
228
|
+
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
193
229
|
};
|
|
194
230
|
|
|
195
231
|
export const FunctionCallSchema = z.object({
|
|
@@ -227,11 +263,19 @@ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
|
|
|
227
263
|
estimateGas: optional(z.boolean()),
|
|
228
264
|
});
|
|
229
265
|
|
|
266
|
+
export const WaitOptsSchema = z.object({
|
|
267
|
+
ignoreDroppedReceiptsFor: optional(z.number()),
|
|
268
|
+
timeout: optional(z.number()),
|
|
269
|
+
interval: optional(z.number()),
|
|
270
|
+
dontThrowOnRevert: optional(z.boolean()),
|
|
271
|
+
});
|
|
272
|
+
|
|
230
273
|
export const SendOptionsSchema = z.object({
|
|
231
274
|
from: schemas.AztecAddress,
|
|
232
275
|
authWitnesses: optional(z.array(AuthWitness.schema)),
|
|
233
276
|
capsules: optional(z.array(Capsule.schema)),
|
|
234
277
|
fee: optional(GasSettingsOptionSchema),
|
|
278
|
+
wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
|
|
235
279
|
});
|
|
236
280
|
|
|
237
281
|
export const SimulateOptionsSchema = z.object({
|
|
@@ -250,7 +294,6 @@ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
|
|
|
250
294
|
});
|
|
251
295
|
|
|
252
296
|
export const MessageHashOrIntentSchema = z.union([
|
|
253
|
-
schemas.Fr,
|
|
254
297
|
z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
|
|
255
298
|
z.object({
|
|
256
299
|
caller: schemas.AztecAddress,
|
|
@@ -258,45 +301,6 @@ export const MessageHashOrIntentSchema = z.union([
|
|
|
258
301
|
}),
|
|
259
302
|
]);
|
|
260
303
|
|
|
261
|
-
export const BatchedMethodSchema = z.union([
|
|
262
|
-
z.object({
|
|
263
|
-
name: z.literal('registerSender'),
|
|
264
|
-
args: z.tuple([schemas.AztecAddress, optional(z.string())]),
|
|
265
|
-
}),
|
|
266
|
-
z.object({
|
|
267
|
-
name: z.literal('registerContract'),
|
|
268
|
-
args: z.tuple([ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
|
|
269
|
-
}),
|
|
270
|
-
z.object({
|
|
271
|
-
name: z.literal('sendTx'),
|
|
272
|
-
args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
|
|
273
|
-
}),
|
|
274
|
-
z.object({
|
|
275
|
-
name: z.literal('simulateUtility'),
|
|
276
|
-
args: z.tuple([FunctionCallSchema, optional(z.array(AuthWitness.schema))]),
|
|
277
|
-
}),
|
|
278
|
-
z.object({
|
|
279
|
-
name: z.literal('simulateTx'),
|
|
280
|
-
args: z.tuple([ExecutionPayloadSchema, SimulateOptionsSchema]),
|
|
281
|
-
}),
|
|
282
|
-
]);
|
|
283
|
-
|
|
284
|
-
export const ContractMetadataSchema = zodFor<ContractMetadata>()(
|
|
285
|
-
z.object({
|
|
286
|
-
contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
|
|
287
|
-
isContractInitialized: z.boolean(),
|
|
288
|
-
isContractPublished: z.boolean(),
|
|
289
|
-
}),
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
export const ContractClassMetadataSchema = zodFor<ContractClassMetadata>()(
|
|
293
|
-
z.object({
|
|
294
|
-
contractClass: z.union([ContractClassWithIdSchema, z.undefined()]),
|
|
295
|
-
isContractClassPubliclyRegistered: z.boolean(),
|
|
296
|
-
artifact: z.union([ContractArtifactSchema, z.undefined()]),
|
|
297
|
-
}),
|
|
298
|
-
);
|
|
299
|
-
|
|
300
304
|
export const EventMetadataDefinitionSchema = z.object({
|
|
301
305
|
eventSelector: schemas.EventSelector,
|
|
302
306
|
abiType: AbiTypeSchema,
|
|
@@ -318,14 +322,143 @@ export const PrivateEventFilterSchema = z.object({
|
|
|
318
322
|
toBlock: optional(BlockNumberPositiveSchema),
|
|
319
323
|
});
|
|
320
324
|
|
|
321
|
-
export const
|
|
325
|
+
export const ContractMetadataSchema = z.object({
|
|
326
|
+
instance: optional(ContractInstanceWithAddressSchema),
|
|
327
|
+
isContractInitialized: z.boolean(),
|
|
328
|
+
isContractPublished: z.boolean(),
|
|
329
|
+
isContractUpdated: z.boolean(),
|
|
330
|
+
updatedContractClassId: optional(schemas.Fr),
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
export const ContractClassMetadataSchema = z.object({
|
|
334
|
+
isArtifactRegistered: z.boolean(),
|
|
335
|
+
isContractClassPubliclyRegistered: z.boolean(),
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
export const ContractFunctionPatternSchema = z.object({
|
|
339
|
+
contract: z.union([schemas.AztecAddress, z.literal('*')]),
|
|
340
|
+
function: z.union([z.string(), z.literal('*')]),
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
export const AccountsCapabilitySchema = z.object({
|
|
344
|
+
type: z.literal('accounts'),
|
|
345
|
+
canGet: optional(z.boolean()),
|
|
346
|
+
canCreateAuthWit: optional(z.boolean()),
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
export const GrantedAccountsCapabilitySchema = AccountsCapabilitySchema.extend({
|
|
350
|
+
accounts: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
export const ContractsCapabilitySchema = z.object({
|
|
354
|
+
type: z.literal('contracts'),
|
|
355
|
+
contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
|
|
356
|
+
canRegister: optional(z.boolean()),
|
|
357
|
+
canGetMetadata: optional(z.boolean()),
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
export const GrantedContractsCapabilitySchema = ContractsCapabilitySchema;
|
|
361
|
+
|
|
362
|
+
export const ContractClassesCapabilitySchema = z.object({
|
|
363
|
+
type: z.literal('contractClasses'),
|
|
364
|
+
classes: z.union([z.literal('*'), z.array(schemas.Fr)]),
|
|
365
|
+
canGetMetadata: z.boolean(),
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
export const GrantedContractClassesCapabilitySchema = ContractClassesCapabilitySchema;
|
|
369
|
+
|
|
370
|
+
export const SimulationCapabilitySchema = z.object({
|
|
371
|
+
type: z.literal('simulation'),
|
|
372
|
+
transactions: optional(
|
|
373
|
+
z.object({
|
|
374
|
+
scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
|
|
375
|
+
}),
|
|
376
|
+
),
|
|
377
|
+
utilities: optional(
|
|
378
|
+
z.object({
|
|
379
|
+
scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
|
|
380
|
+
}),
|
|
381
|
+
),
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
export const GrantedSimulationCapabilitySchema = SimulationCapabilitySchema;
|
|
385
|
+
|
|
386
|
+
export const TransactionCapabilitySchema = z.object({
|
|
387
|
+
type: z.literal('transaction'),
|
|
388
|
+
scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
export const GrantedTransactionCapabilitySchema = TransactionCapabilitySchema;
|
|
392
|
+
|
|
393
|
+
export const DataCapabilitySchema = z.object({
|
|
394
|
+
type: z.literal('data'),
|
|
395
|
+
addressBook: optional(z.boolean()),
|
|
396
|
+
privateEvents: optional(
|
|
397
|
+
z.object({
|
|
398
|
+
contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
|
|
399
|
+
}),
|
|
400
|
+
),
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
export const GrantedDataCapabilitySchema = DataCapabilitySchema;
|
|
404
|
+
|
|
405
|
+
export const CapabilitySchema = z.discriminatedUnion('type', [
|
|
406
|
+
AccountsCapabilitySchema,
|
|
407
|
+
ContractsCapabilitySchema,
|
|
408
|
+
ContractClassesCapabilitySchema,
|
|
409
|
+
SimulationCapabilitySchema,
|
|
410
|
+
TransactionCapabilitySchema,
|
|
411
|
+
DataCapabilitySchema,
|
|
412
|
+
]);
|
|
413
|
+
|
|
414
|
+
export const GrantedCapabilitySchema = z.discriminatedUnion('type', [
|
|
415
|
+
GrantedAccountsCapabilitySchema,
|
|
416
|
+
GrantedContractsCapabilitySchema,
|
|
417
|
+
GrantedContractClassesCapabilitySchema,
|
|
418
|
+
GrantedSimulationCapabilitySchema,
|
|
419
|
+
GrantedTransactionCapabilitySchema,
|
|
420
|
+
GrantedDataCapabilitySchema,
|
|
421
|
+
]);
|
|
422
|
+
|
|
423
|
+
export const AppCapabilitiesSchema = z.object({
|
|
424
|
+
version: z.literal('1.0'),
|
|
425
|
+
metadata: z.object({
|
|
426
|
+
name: z.string(),
|
|
427
|
+
version: z.string(),
|
|
428
|
+
description: optional(z.string()),
|
|
429
|
+
url: optional(z.string()),
|
|
430
|
+
icon: optional(z.string()),
|
|
431
|
+
}),
|
|
432
|
+
capabilities: z.array(CapabilitySchema),
|
|
433
|
+
behavior: optional(
|
|
434
|
+
z.object({
|
|
435
|
+
mode: optional(z.enum(['strict', 'permissive'])),
|
|
436
|
+
expiration: optional(z.number()),
|
|
437
|
+
}),
|
|
438
|
+
),
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
export const WalletCapabilitiesSchema = z.object({
|
|
442
|
+
version: z.literal('1.0'),
|
|
443
|
+
granted: z.array(GrantedCapabilitySchema),
|
|
444
|
+
wallet: z.object({
|
|
445
|
+
name: z.string(),
|
|
446
|
+
version: z.string(),
|
|
447
|
+
}),
|
|
448
|
+
expiresAt: optional(z.number()),
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Record of all wallet method schemas (excluding batch).
|
|
453
|
+
* This is the single source of truth for method schemas - batch schemas are derived from this.
|
|
454
|
+
*/
|
|
455
|
+
const WalletMethodSchemas = {
|
|
322
456
|
getChainInfo: z
|
|
323
457
|
.function()
|
|
324
458
|
.args()
|
|
325
459
|
.returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
|
|
326
|
-
getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
|
|
327
460
|
getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
|
|
328
|
-
|
|
461
|
+
getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
|
|
329
462
|
getPrivateEvents: z
|
|
330
463
|
.function()
|
|
331
464
|
.args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
|
|
@@ -349,21 +482,52 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
349
482
|
.args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
|
|
350
483
|
.returns(UtilitySimulationResult.schema),
|
|
351
484
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
352
|
-
sendTx: z
|
|
485
|
+
sendTx: z
|
|
486
|
+
.function()
|
|
487
|
+
.args(ExecutionPayloadSchema, SendOptionsSchema)
|
|
488
|
+
.returns(z.union([TxHash.schema, TxReceipt.schema])),
|
|
353
489
|
createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
|
|
490
|
+
requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Creates batch schemas from the individual wallet methods.
|
|
495
|
+
* This allows us to define them once and derive batch schemas automatically,
|
|
496
|
+
* reducing duplication and ensuring consistency.
|
|
497
|
+
*/
|
|
498
|
+
function createBatchSchemas<T extends Record<string, z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>>(
|
|
499
|
+
methodSchemas: T,
|
|
500
|
+
) {
|
|
501
|
+
const names = Object.keys(methodSchemas) as (keyof T)[];
|
|
502
|
+
|
|
503
|
+
const namesAndArgs = names.map(name =>
|
|
504
|
+
z.object({
|
|
505
|
+
name: z.literal(name),
|
|
506
|
+
args: methodSchemas[name].parameters(),
|
|
507
|
+
}),
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
const namesAndReturns = names.map(name =>
|
|
511
|
+
z.object({
|
|
512
|
+
name: z.literal(name),
|
|
513
|
+
result: methodSchemas[name].returnType(),
|
|
514
|
+
}),
|
|
515
|
+
);
|
|
516
|
+
|
|
517
|
+
// Type assertion needed because discriminatedUnion expects a tuple type [T, T, ...T[]]
|
|
518
|
+
// but we're building the array dynamically. The runtime behavior is correct.
|
|
519
|
+
return {
|
|
520
|
+
input: z.discriminatedUnion('name', namesAndArgs as [(typeof namesAndArgs)[0], ...typeof namesAndArgs]),
|
|
521
|
+
output: z.discriminatedUnion('name', namesAndReturns as [(typeof namesAndReturns)[0], ...typeof namesAndReturns]),
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const { input: BatchedMethodSchema, output: BatchedResultSchema } = createBatchSchemas(WalletMethodSchemas);
|
|
526
|
+
|
|
527
|
+
export { BatchedMethodSchema, BatchedResultSchema };
|
|
528
|
+
|
|
529
|
+
export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
530
|
+
...WalletMethodSchemas,
|
|
354
531
|
// @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
|
|
355
|
-
batch: z
|
|
356
|
-
.function()
|
|
357
|
-
.args(z.array(BatchedMethodSchema))
|
|
358
|
-
.returns(
|
|
359
|
-
z.array(
|
|
360
|
-
z.discriminatedUnion('name', [
|
|
361
|
-
z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
|
|
362
|
-
z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
|
|
363
|
-
z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
|
|
364
|
-
z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
|
|
365
|
-
z.object({ name: z.literal('simulateTx'), result: TxSimulationResult.schema }),
|
|
366
|
-
]),
|
|
367
|
-
),
|
|
368
|
-
),
|
|
532
|
+
batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(BatchedResultSchema)),
|
|
369
533
|
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
|
-
/**
|
|
6
|
-
* Handler for interfacing with an account. Knows how to create transaction execution
|
|
7
|
-
* requests and authorize actions for its corresponding account.
|
|
8
|
-
*/
|
|
9
|
-
export interface AccountInterface extends EntrypointInterface, AuthWitnessProvider {
|
|
10
|
-
/** Returns the complete address for this account. */
|
|
11
|
-
getCompleteAddress(): CompleteAddress;
|
|
12
|
-
/** Returns the address for this account. */
|
|
13
|
-
getAddress(): AztecAddress;
|
|
14
|
-
/** Returns the chain id for this account */
|
|
15
|
-
getChainId(): Fr;
|
|
16
|
-
/** Returns the rollup version for this account */
|
|
17
|
-
getVersion(): Fr;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWNjb3VudC9pbnRlcmZhY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUM5RixPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUk5RDs7O0dBR0c7QUFDSCxNQUFNLFdBQVcsZ0JBQWlCLFNBQVEsbUJBQW1CLEVBQUUsbUJBQW1CO0lBQ2hGLHFEQUFxRDtJQUNyRCxrQkFBa0IsSUFBSSxlQUFlLENBQUM7SUFFdEMsNENBQTRDO0lBQzVDLFVBQVUsSUFBSSxZQUFZLENBQUM7SUFFM0IsNENBQTRDO0lBQzVDLFVBQVUsSUFBSSxFQUFFLENBQUM7SUFFakIsa0RBQWtEO0lBQ2xELFVBQVUsSUFBSSxFQUFFLENBQUM7Q0FDbEIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/account/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB,EAAE,mBAAmB;IAChF,qDAAqD;IACrD,kBAAkB,IAAI,eAAe,CAAC;IAEtC,4CAA4C;IAC5C,UAAU,IAAI,YAAY,CAAC;IAE3B,4CAA4C;IAC5C,UAAU,IAAI,EAAE,CAAC;IAEjB,kDAAkD;IAClD,UAAU,IAAI,EAAE,CAAC;CAClB"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
4
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
5
|
-
import type { ContractBase } from './contract_base.js';
|
|
6
|
-
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
7
|
-
/** Options related to waiting for a deployment tx. */
|
|
8
|
-
export type DeployedWaitOpts = WaitOpts & {
|
|
9
|
-
/** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
|
|
10
|
-
wallet?: Wallet;
|
|
11
|
-
};
|
|
12
|
-
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
13
|
-
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
|
|
14
|
-
/** Instance of the newly deployed contract. */
|
|
15
|
-
contract: TContract;
|
|
16
|
-
/** The deployed contract instance with address and metadata. */
|
|
17
|
-
instance: ContractInstanceWithAddress;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
21
|
-
*/
|
|
22
|
-
export declare class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
|
|
23
|
-
private postDeployCtor;
|
|
24
|
-
/** A getter for the deployed contract instance */
|
|
25
|
-
private instanceGetter;
|
|
26
|
-
private log;
|
|
27
|
-
constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
28
|
-
/** A getter for the deployed contract instance */
|
|
29
|
-
instanceGetter: () => Promise<ContractInstanceWithAddress>);
|
|
30
|
-
/**
|
|
31
|
-
* Returns the contract instance for this deployment.
|
|
32
|
-
* @returns The deployed contract instance with address and metadata.
|
|
33
|
-
*/
|
|
34
|
-
getInstance(): Promise<ContractInstanceWithAddress>;
|
|
35
|
-
/**
|
|
36
|
-
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
37
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
38
|
-
* @returns The deployed contract instance.
|
|
39
|
-
*/
|
|
40
|
-
deployed(opts?: DeployedWaitOpts): Promise<TContract>;
|
|
41
|
-
/**
|
|
42
|
-
* Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
|
|
43
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
44
|
-
* @returns The transaction receipt with the deployed contract instance.
|
|
45
|
-
*/
|
|
46
|
-
wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X3NlbnRfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdC9kZXBsb3lfc2VudF90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUxRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNsRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUN2RCxPQUFPLEVBQUUsTUFBTSxFQUFFLEtBQUssUUFBUSxFQUFFLE1BQU0sY0FBYyxDQUFDO0FBRXJELHNEQUFzRDtBQUN0RCxNQUFNLE1BQU0sZ0JBQWdCLEdBQUcsUUFBUSxHQUFHO0lBQ3hDLCtHQUErRztJQUMvRyxNQUFNLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDakIsQ0FBQztBQUVGLDBHQUEwRztBQUMxRyxNQUFNLE1BQU0sZUFBZSxDQUFDLFNBQVMsU0FBUyxZQUFZLEdBQUcsWUFBWSxJQUFJLFFBQVEsQ0FBQyxTQUFTLENBQUMsR0FBRztJQUNqRywrQ0FBK0M7SUFDL0MsUUFBUSxFQUFFLFNBQVMsQ0FBQztJQUNwQixnRUFBZ0U7SUFDaEUsUUFBUSxFQUFFLDJCQUEyQixDQUFDO0NBQ3ZDLENBQUM7QUFFRjs7R0FFRztBQUNILHFCQUFhLFlBQVksQ0FBQyxTQUFTLFNBQVMsWUFBWSxHQUFHLFlBQVksQ0FBRSxTQUFRLE1BQU07SUFNbkYsT0FBTyxDQUFDLGNBQWM7SUFDdEIsa0RBQWtEO0lBQ2xELE9BQU8sQ0FBQyxjQUFjO0lBUHhCLE9BQU8sQ0FBQyxHQUFHLENBQTBDO0lBRXJELFlBQ0UsTUFBTSxFQUFFLE1BQU0sRUFDZCxNQUFNLEVBQUUsTUFBTSxPQUFPLENBQUMsTUFBTSxDQUFDLEVBQ3JCLGNBQWMsRUFBRSxDQUFDLFFBQVEsRUFBRSwyQkFBMkIsRUFBRSxNQUFNLEVBQUUsTUFBTSxLQUFLLFNBQVM7SUFDNUYsa0RBQWtEO0lBQzFDLGNBQWMsRUFBRSxNQUFNLE9BQU8sQ0FBQywyQkFBMkIsQ0FBQyxFQUduRTtJQUVEOzs7T0FHRztJQUNVLFdBQVcsSUFBSSxPQUFPLENBQUMsMkJBQTJCLENBQUMsQ0FFL0Q7SUFFRDs7OztPQUlHO0lBQ1UsUUFBUSxDQUFDLElBQUksQ0FBQyxFQUFFLGdCQUFnQixHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FJakU7SUFFRDs7OztPQUlHO0lBQ21CLElBQUksQ0FBQyxJQUFJLENBQUMsRUFBRSxnQkFBZ0IsR0FBRyxPQUFPLENBQUMsZUFBZSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBVXZGO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAErD,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACxC,+GAA+G;IAC/G,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,0GAA0G;AAC1G,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG;IACjG,+CAA+C;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB,gEAAgE;IAChE,QAAQ,EAAE,2BAA2B,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,CAAE,SAAQ,MAAM;IAMnF,OAAO,CAAC,cAAc;IACtB,kDAAkD;IAClD,OAAO,CAAC,cAAc;IAPxB,OAAO,CAAC,GAAG,CAA0C;IAErD,YACE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACrB,cAAc,EAAE,CAAC,QAAQ,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS;IAC5F,kDAAkD;IAC1C,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC,EAGnE;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAE/D;IAED;;;;OAIG;IACU,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAIjE;IAED;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAUvF;CACF"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { SentTx } from './sent_tx.js';
|
|
3
|
-
/**
|
|
4
|
-
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
5
|
-
*/ export class DeploySentTx extends SentTx {
|
|
6
|
-
postDeployCtor;
|
|
7
|
-
instanceGetter;
|
|
8
|
-
log;
|
|
9
|
-
constructor(wallet, sendTx, postDeployCtor, /** A getter for the deployed contract instance */ instanceGetter){
|
|
10
|
-
super(wallet, sendTx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter, this.log = createLogger('aztecjs:deploy_sent_tx');
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns the contract instance for this deployment.
|
|
14
|
-
* @returns The deployed contract instance with address and metadata.
|
|
15
|
-
*/ async getInstance() {
|
|
16
|
-
return await this.instanceGetter();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
20
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
21
|
-
* @returns The deployed contract instance.
|
|
22
|
-
*/ async deployed(opts) {
|
|
23
|
-
const receipt = await this.wait(opts);
|
|
24
|
-
this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
|
|
25
|
-
return receipt.contract;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
|
|
29
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
30
|
-
* @returns The transaction receipt with the deployed contract instance.
|
|
31
|
-
*/ async wait(opts) {
|
|
32
|
-
const receipt = await super.wait(opts);
|
|
33
|
-
// In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
|
|
34
|
-
const contractWallet = opts?.wallet ?? this.walletOrNode;
|
|
35
|
-
if (!contractWallet) {
|
|
36
|
-
throw new Error(`A wallet is required for creating a contract instance`);
|
|
37
|
-
}
|
|
38
|
-
const instance = await this.instanceGetter();
|
|
39
|
-
const contract = this.postDeployCtor(instance, contractWallet);
|
|
40
|
-
return {
|
|
41
|
-
...receipt,
|
|
42
|
-
contract,
|
|
43
|
-
instance
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -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
|
-
}
|