@aztec/aztec.js 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a
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/events.d.ts +10 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +30 -20
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -10
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/auth-registry.js +61 -466
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -11
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +10 -409
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-instance-registry.js +76 -473
- package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/fee-juice.js +0 -401
- 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 +22 -0
- 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 +22 -8
- 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/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 +1412 -30
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +138 -8
- package/package.json +19 -10
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +1 -0
- package/src/api/keys.ts +2 -2
- package/src/api/wallet.ts +42 -0
- package/src/contract/protocol_contracts/auth-registry.ts +37 -231
- package/src/contract/protocol_contracts/contract-class-registry.ts +3 -195
- package/src/contract/protocol_contracts/contract-instance-registry.ts +33 -225
- package/src/contract/protocol_contracts/fee-juice.ts +0 -193
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +3 -0
- package/src/contract/protocol_contracts/public-checks.ts +3 -2
- package/src/wallet/capabilities.ts +491 -0
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +177 -18
package/src/wallet/wallet.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
type SimulateInteractionOptions,
|
|
41
41
|
} from '../contract/interaction_options.js';
|
|
42
42
|
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
43
|
+
import type { AppCapabilities, WalletCapabilities } from './capabilities.js';
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* A wrapper type that allows any item to be associated with an alias.
|
|
@@ -139,37 +140,66 @@ export type BatchResults<T extends readonly BatchedMethod[]> = {
|
|
|
139
140
|
};
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
|
-
*
|
|
143
|
+
* Base filter options for event queries.
|
|
143
144
|
*/
|
|
144
|
-
export type
|
|
145
|
-
/** The address of the contract that emitted the events. */
|
|
146
|
-
contractAddress: AztecAddress;
|
|
147
|
-
/** Addresses of accounts that are in scope for this filter. */
|
|
148
|
-
scopes: AztecAddress[];
|
|
145
|
+
export type EventFilterBase = {
|
|
149
146
|
/** Transaction in which the events were emitted. */
|
|
150
147
|
txHash?: TxHash;
|
|
151
148
|
/** The block number from which to start fetching events (inclusive).
|
|
152
149
|
* Optional. If provided, it must be greater or equal than 1.
|
|
153
150
|
* Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
|
|
154
|
-
|
|
151
|
+
*/
|
|
155
152
|
fromBlock?: BlockNumber;
|
|
156
153
|
/** The block number until which to fetch logs (not inclusive).
|
|
157
154
|
* Optional. If provided, it must be greater than fromBlock.
|
|
158
|
-
* Defaults to the latest known block to PXE + 1.
|
|
159
155
|
*/
|
|
160
156
|
toBlock?: BlockNumber;
|
|
161
157
|
};
|
|
162
158
|
|
|
163
159
|
/**
|
|
164
|
-
*
|
|
160
|
+
* Filter options when querying private events.
|
|
161
|
+
*/
|
|
162
|
+
export type PrivateEventFilter = EventFilterBase & {
|
|
163
|
+
/** The address of the contract that emitted the events. */
|
|
164
|
+
contractAddress: AztecAddress;
|
|
165
|
+
/** Addresses of accounts that are in scope for this filter. */
|
|
166
|
+
scopes: AztecAddress[];
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Filter options when querying public events.
|
|
165
171
|
*/
|
|
166
|
-
export type
|
|
172
|
+
export type PublicEventFilter = EventFilterBase & {
|
|
173
|
+
/** The address of the contract that emitted the events. */
|
|
174
|
+
contractAddress?: AztecAddress;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* An ABI decoded event with associated metadata.
|
|
179
|
+
* @typeParam T - The decoded event type
|
|
180
|
+
* @typeParam M - Additional metadata fields (empty by default)
|
|
181
|
+
*/
|
|
182
|
+
export type Event<T, M extends object = object> = {
|
|
167
183
|
/** The ABI decoded event */
|
|
168
184
|
event: T;
|
|
169
185
|
/** Metadata describing event context information such as tx and block */
|
|
170
|
-
metadata: InTx;
|
|
186
|
+
metadata: InTx & M;
|
|
171
187
|
};
|
|
172
188
|
|
|
189
|
+
/** An ABI decoded private event with associated metadata. */
|
|
190
|
+
export type PrivateEvent<T> = Event<T>;
|
|
191
|
+
|
|
192
|
+
/** An ABI decoded public event with associated metadata (includes contract address). */
|
|
193
|
+
export type PublicEvent<T> = Event<
|
|
194
|
+
T,
|
|
195
|
+
{
|
|
196
|
+
/**
|
|
197
|
+
* Address of the contract that emitted this event
|
|
198
|
+
*/
|
|
199
|
+
contractAddress: AztecAddress;
|
|
200
|
+
}
|
|
201
|
+
>;
|
|
202
|
+
|
|
173
203
|
/**
|
|
174
204
|
* Contract metadata including deployment and registration status.
|
|
175
205
|
*/
|
|
@@ -223,6 +253,7 @@ export type Wallet = {
|
|
|
223
253
|
opts: SendOptions<W>,
|
|
224
254
|
): Promise<SendReturn<W>>;
|
|
225
255
|
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
256
|
+
requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities>;
|
|
226
257
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
227
258
|
};
|
|
228
259
|
|
|
@@ -305,6 +336,21 @@ export const EventMetadataDefinitionSchema = z.object({
|
|
|
305
336
|
fieldNames: z.array(z.string()),
|
|
306
337
|
});
|
|
307
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
|
+
|
|
308
354
|
export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
|
|
309
355
|
z.object({
|
|
310
356
|
event: AbiDecodedSchema,
|
|
@@ -312,13 +358,12 @@ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded
|
|
|
312
358
|
}),
|
|
313
359
|
);
|
|
314
360
|
|
|
315
|
-
export const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
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
|
+
);
|
|
322
367
|
|
|
323
368
|
export const ContractMetadataSchema = z.object({
|
|
324
369
|
instance: optional(ContractInstanceWithAddressSchema),
|
|
@@ -333,6 +378,119 @@ export const ContractClassMetadataSchema = z.object({
|
|
|
333
378
|
isContractClassPubliclyRegistered: z.boolean(),
|
|
334
379
|
});
|
|
335
380
|
|
|
381
|
+
export const ContractFunctionPatternSchema = z.object({
|
|
382
|
+
contract: z.union([schemas.AztecAddress, z.literal('*')]),
|
|
383
|
+
function: z.union([z.string(), z.literal('*')]),
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
export const AccountsCapabilitySchema = z.object({
|
|
387
|
+
type: z.literal('accounts'),
|
|
388
|
+
canGet: optional(z.boolean()),
|
|
389
|
+
canCreateAuthWit: optional(z.boolean()),
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
export const GrantedAccountsCapabilitySchema = AccountsCapabilitySchema.extend({
|
|
393
|
+
accounts: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
export const ContractsCapabilitySchema = z.object({
|
|
397
|
+
type: z.literal('contracts'),
|
|
398
|
+
contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
|
|
399
|
+
canRegister: optional(z.boolean()),
|
|
400
|
+
canGetMetadata: optional(z.boolean()),
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
export const GrantedContractsCapabilitySchema = ContractsCapabilitySchema;
|
|
404
|
+
|
|
405
|
+
export const ContractClassesCapabilitySchema = z.object({
|
|
406
|
+
type: z.literal('contractClasses'),
|
|
407
|
+
classes: z.union([z.literal('*'), z.array(schemas.Fr)]),
|
|
408
|
+
canGetMetadata: z.boolean(),
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
export const GrantedContractClassesCapabilitySchema = ContractClassesCapabilitySchema;
|
|
412
|
+
|
|
413
|
+
export const SimulationCapabilitySchema = z.object({
|
|
414
|
+
type: z.literal('simulation'),
|
|
415
|
+
transactions: optional(
|
|
416
|
+
z.object({
|
|
417
|
+
scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
|
|
418
|
+
}),
|
|
419
|
+
),
|
|
420
|
+
utilities: optional(
|
|
421
|
+
z.object({
|
|
422
|
+
scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
|
|
423
|
+
}),
|
|
424
|
+
),
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
export const GrantedSimulationCapabilitySchema = SimulationCapabilitySchema;
|
|
428
|
+
|
|
429
|
+
export const TransactionCapabilitySchema = z.object({
|
|
430
|
+
type: z.literal('transaction'),
|
|
431
|
+
scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
export const GrantedTransactionCapabilitySchema = TransactionCapabilitySchema;
|
|
435
|
+
|
|
436
|
+
export const DataCapabilitySchema = z.object({
|
|
437
|
+
type: z.literal('data'),
|
|
438
|
+
addressBook: optional(z.boolean()),
|
|
439
|
+
privateEvents: optional(
|
|
440
|
+
z.object({
|
|
441
|
+
contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
|
|
442
|
+
}),
|
|
443
|
+
),
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
export const GrantedDataCapabilitySchema = DataCapabilitySchema;
|
|
447
|
+
|
|
448
|
+
export const CapabilitySchema = z.discriminatedUnion('type', [
|
|
449
|
+
AccountsCapabilitySchema,
|
|
450
|
+
ContractsCapabilitySchema,
|
|
451
|
+
ContractClassesCapabilitySchema,
|
|
452
|
+
SimulationCapabilitySchema,
|
|
453
|
+
TransactionCapabilitySchema,
|
|
454
|
+
DataCapabilitySchema,
|
|
455
|
+
]);
|
|
456
|
+
|
|
457
|
+
export const GrantedCapabilitySchema = z.discriminatedUnion('type', [
|
|
458
|
+
GrantedAccountsCapabilitySchema,
|
|
459
|
+
GrantedContractsCapabilitySchema,
|
|
460
|
+
GrantedContractClassesCapabilitySchema,
|
|
461
|
+
GrantedSimulationCapabilitySchema,
|
|
462
|
+
GrantedTransactionCapabilitySchema,
|
|
463
|
+
GrantedDataCapabilitySchema,
|
|
464
|
+
]);
|
|
465
|
+
|
|
466
|
+
export const AppCapabilitiesSchema = z.object({
|
|
467
|
+
version: z.literal('1.0'),
|
|
468
|
+
metadata: z.object({
|
|
469
|
+
name: z.string(),
|
|
470
|
+
version: z.string(),
|
|
471
|
+
description: optional(z.string()),
|
|
472
|
+
url: optional(z.string()),
|
|
473
|
+
icon: optional(z.string()),
|
|
474
|
+
}),
|
|
475
|
+
capabilities: z.array(CapabilitySchema),
|
|
476
|
+
behavior: optional(
|
|
477
|
+
z.object({
|
|
478
|
+
mode: optional(z.enum(['strict', 'permissive'])),
|
|
479
|
+
expiration: optional(z.number()),
|
|
480
|
+
}),
|
|
481
|
+
),
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
export const WalletCapabilitiesSchema = z.object({
|
|
485
|
+
version: z.literal('1.0'),
|
|
486
|
+
granted: z.array(GrantedCapabilitySchema),
|
|
487
|
+
wallet: z.object({
|
|
488
|
+
name: z.string(),
|
|
489
|
+
version: z.string(),
|
|
490
|
+
}),
|
|
491
|
+
expiresAt: optional(z.number()),
|
|
492
|
+
});
|
|
493
|
+
|
|
336
494
|
/**
|
|
337
495
|
* Record of all wallet method schemas (excluding batch).
|
|
338
496
|
* This is the single source of truth for method schemas - batch schemas are derived from this.
|
|
@@ -372,6 +530,7 @@ const WalletMethodSchemas = {
|
|
|
372
530
|
.args(ExecutionPayloadSchema, SendOptionsSchema)
|
|
373
531
|
.returns(z.union([TxHash.schema, TxReceipt.schema])),
|
|
374
532
|
createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
|
|
533
|
+
requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
|
|
375
534
|
};
|
|
376
535
|
|
|
377
536
|
/**
|