@aztec/aztec.js 0.0.1-commit.24de95ac → 0.0.1-commit.2e2504e2
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 +26 -42
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +9 -10
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +20 -9
- 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 +4 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +7 -9
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/abi.d.ts +1 -1
- package/dest/api/account.d.ts +3 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +2 -3
- package/dest/api/addresses.d.ts +1 -1
- 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/block.d.ts +1 -1
- package/dest/api/contract.d.ts +17 -11
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +15 -9
- package/dest/api/crypto.d.ts +1 -1
- package/dest/api/deployment.d.ts +1 -1
- package/dest/api/eth_address.d.ts +1 -1
- package/dest/api/ethereum.d.ts +1 -1
- package/dest/api/events.d.ts +1 -1
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee_testing.d.ts +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/keys.d.ts +2 -2
- package/dest/api/keys.js +1 -1
- package/dest/api/log.d.ts +1 -1
- package/dest/api/messaging.d.ts +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/note.d.ts +2 -2
- package/dest/api/note.d.ts.map +1 -1
- package/dest/api/note.js +1 -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/trees.d.ts +1 -1
- 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/utils.d.ts +1 -1
- package/dest/api/wallet.d.ts +3 -3
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -2
- package/dest/authorization/call_authorization_request.d.ts +2 -2
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -11
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +8 -9
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +54 -34
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/contract.d.ts +2 -2
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +4 -5
- package/dest/contract/contract_base.d.ts +6 -10
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +5 -12
- package/dest/contract/contract_function_interaction.d.ts +3 -3
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +9 -6
- package/dest/contract/deploy_method.d.ts +71 -23
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +49 -29
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/interaction_options.d.ts +44 -7
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +12 -11
- 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 +585 -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 +593 -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.d.ts +1 -1
- package/dest/deployment/broadcast_function.js +4 -4
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/deployment/publish_class.d.ts +1 -1
- 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 +7 -6
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +48 -22
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
- package/dest/fee/fee_payment_method.d.ts +2 -2
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +2 -2
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +4 -4
- package/dest/fee/public_fee_payment_method.d.ts +2 -2
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +4 -4
- package/dest/fee/sponsored_fee_payment.d.ts +2 -2
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +2 -2
- 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 +14 -12
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +27 -20
- package/dest/utils/cross_chain.d.ts +2 -2
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/fee_juice.d.ts +2 -2
- package/dest/utils/fee_juice.js +2 -2
- package/dest/utils/field_compressed_string.d.ts +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/node.d.ts +13 -2
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- 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_entrypoint_meta_payment_method.d.ts +6 -9
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
- package/dest/wallet/account_manager.d.ts +3 -9
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +6 -12
- 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 +37 -9
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +9 -7
- package/dest/wallet/index.d.ts +2 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -1
- package/dest/wallet/wallet.d.ts +1577 -1465
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +200 -111
- package/package.json +26 -14
- package/src/account/account.ts +35 -60
- package/src/account/account_contract.ts +7 -8
- package/src/account/account_with_secret_key.ts +34 -9
- package/src/account/index.ts +3 -2
- package/src/account/signerless_account.ts +15 -15
- package/src/api/account.ts +10 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +24 -8
- package/src/api/fields.ts +2 -1
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/note.ts +1 -1
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +4 -0
- package/src/api/wallet.ts +47 -8
- package/src/authorization/call_authorization_request.ts +1 -1
- package/src/contract/base_contract_interaction.ts +27 -16
- package/src/contract/batch_call.ts +67 -48
- package/src/contract/contract.ts +7 -5
- package/src/contract/contract_base.ts +5 -15
- package/src/contract/contract_function_interaction.ts +10 -11
- package/src/contract/deploy_method.ts +134 -40
- package/src/contract/interaction_options.ts +52 -13
- 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 +4 -4
- package/src/deployment/contract_deployer.ts +3 -2
- package/src/deployment/publish_class.ts +3 -3
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +65 -34
- package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +5 -3
- package/src/fee/public_fee_payment_method.ts +5 -3
- package/src/fee/sponsored_fee_payment.ts +3 -1
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +40 -22
- package/src/utils/cross_chain.ts +1 -1
- package/src/utils/fee_juice.ts +2 -2
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/node.ts +62 -0
- package/src/utils/pub_key.ts +2 -2
- package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
- package/src/wallet/account_manager.ts +7 -15
- package/src/wallet/capabilities.ts +491 -0
- package/src/wallet/deploy_account_method.ts +41 -16
- package/src/wallet/index.ts +1 -1
- package/src/wallet/wallet.ts +322 -151
- 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 -43
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -40
- 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 -51
- 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/dest/wallet/base_wallet.d.ts +0 -91
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -238
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -68
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -130
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/wallet/base_wallet.ts +0 -350
package/src/wallet/wallet.ts
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import
|
|
3
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import { BlockNumber, BlockNumberPositiveSchema } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import {
|
|
5
|
+
type AbiDecoded,
|
|
5
6
|
AbiTypeSchema,
|
|
6
7
|
type ContractArtifact,
|
|
7
8
|
ContractArtifactSchema,
|
|
8
9
|
type EventMetadataDefinition,
|
|
9
|
-
|
|
10
|
+
type FunctionCall,
|
|
10
11
|
FunctionType,
|
|
11
12
|
} from '@aztec/stdlib/abi';
|
|
12
13
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
13
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import {
|
|
15
|
-
type ContractClassMetadata,
|
|
16
|
-
ContractClassWithIdSchema,
|
|
17
|
-
type ContractInstanceWithAddress,
|
|
18
|
-
ContractInstanceWithAddressSchema,
|
|
19
|
-
type ContractInstantiationData,
|
|
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
|
-
import {
|
|
24
|
-
import
|
|
17
|
+
import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
18
|
+
import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
|
|
25
19
|
import {
|
|
26
20
|
Capsule,
|
|
27
21
|
HashedValues,
|
|
@@ -30,19 +24,23 @@ import {
|
|
|
30
24
|
TxReceipt,
|
|
31
25
|
TxSimulationResult,
|
|
32
26
|
UtilitySimulationResult,
|
|
27
|
+
inTxSchema,
|
|
33
28
|
} from '@aztec/stdlib/tx';
|
|
34
29
|
|
|
35
30
|
import { z } from 'zod';
|
|
36
31
|
|
|
37
|
-
import
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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.
|
|
@@ -58,80 +56,76 @@ export type Aliased<T> = {
|
|
|
58
56
|
item: T;
|
|
59
57
|
};
|
|
60
58
|
|
|
61
|
-
/**
|
|
62
|
-
* A reduced representation of a Contract, only including its instance and artifact
|
|
63
|
-
*/
|
|
64
|
-
export type ContractInstanceAndArtifact = Pick<Contract, 'artifact' | 'instance'>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Options that can be provided to the wallet for configuration of the fee payment.
|
|
68
|
-
*/
|
|
69
|
-
export type UserFeeOptions = {
|
|
70
|
-
/**
|
|
71
|
-
* Informs the wallet that the crafted tx already contains the necessary calls to pay for its fee
|
|
72
|
-
* and who is paying
|
|
73
|
-
*/
|
|
74
|
-
embeddedPaymentMethodFeePayer?: AztecAddress;
|
|
75
|
-
} & GasSettingsOption;
|
|
76
|
-
|
|
77
59
|
/**
|
|
78
60
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
79
|
-
* a simplified version that only hints at the wallet
|
|
61
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
80
62
|
* fee payment method or not
|
|
81
63
|
*/
|
|
82
64
|
export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
83
65
|
/** The fee options */
|
|
84
|
-
fee?:
|
|
66
|
+
fee?: GasSettingsOption & FeeEstimationOptions;
|
|
85
67
|
};
|
|
86
68
|
|
|
87
69
|
/**
|
|
88
70
|
* Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
|
|
89
|
-
* a simplified version that only hints at the wallet
|
|
71
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
90
72
|
* fee payment method or not
|
|
91
73
|
*/
|
|
92
74
|
export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
93
75
|
/** The fee options */
|
|
94
|
-
fee?:
|
|
76
|
+
fee?: GasSettingsOption;
|
|
95
77
|
};
|
|
96
78
|
|
|
97
79
|
/**
|
|
98
80
|
* Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
|
|
99
|
-
* a simplified version that only hints at the wallet
|
|
81
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
100
82
|
* fee payment method or not
|
|
101
83
|
*/
|
|
102
|
-
export type SendOptions =
|
|
84
|
+
export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
|
|
85
|
+
SendInteractionOptionsWithoutWait,
|
|
86
|
+
'fee'
|
|
87
|
+
> & {
|
|
103
88
|
/** The fee options */
|
|
104
|
-
fee?:
|
|
89
|
+
fee?: GasSettingsOption;
|
|
90
|
+
/** Whether to wait for the transaction to be mined */
|
|
91
|
+
wait?: W;
|
|
105
92
|
};
|
|
106
93
|
|
|
107
94
|
/**
|
|
108
|
-
* 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).
|
|
109
96
|
*/
|
|
110
|
-
export type BatchableMethods =
|
|
97
|
+
export type BatchableMethods = Omit<Wallet, 'batch'>;
|
|
111
98
|
|
|
112
99
|
/**
|
|
113
|
-
*
|
|
114
|
-
* This is what the wallet will accept as arguments to the `batch` method.
|
|
100
|
+
* A method call with its name and arguments.
|
|
115
101
|
*/
|
|
116
|
-
|
|
102
|
+
type BatchedMethodInternal<T extends keyof BatchableMethods> = {
|
|
117
103
|
/** The method name */
|
|
118
104
|
name: T;
|
|
119
105
|
/** The method arguments */
|
|
120
106
|
args: Parameters<BatchableMethods[T]>;
|
|
121
107
|
};
|
|
122
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
|
+
|
|
123
117
|
/**
|
|
124
118
|
* Helper type to extract the return type of a batched method
|
|
125
119
|
*/
|
|
126
120
|
export type BatchedMethodResult<T> =
|
|
127
|
-
T extends
|
|
121
|
+
T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
|
|
128
122
|
|
|
129
123
|
/**
|
|
130
124
|
* Wrapper type for batch results that includes the method name for discriminated union deserialization.
|
|
131
125
|
* Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
|
|
132
126
|
* when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
|
|
133
127
|
*/
|
|
134
|
-
export type BatchedMethodResultWrapper<T extends BatchedMethod
|
|
128
|
+
export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
|
|
135
129
|
/** The method name */
|
|
136
130
|
name: T['name'];
|
|
137
131
|
/** The method result */
|
|
@@ -141,66 +135,99 @@ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMe
|
|
|
141
135
|
/**
|
|
142
136
|
* Maps a tuple of BatchedMethod to a tuple of their wrapped return types
|
|
143
137
|
*/
|
|
144
|
-
export type BatchResults<T extends readonly BatchedMethod
|
|
138
|
+
export type BatchResults<T extends readonly BatchedMethod[]> = {
|
|
145
139
|
[K in keyof T]: BatchedMethodResultWrapper<T[K]>;
|
|
146
140
|
};
|
|
147
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Filter options when querying private events.
|
|
144
|
+
*/
|
|
145
|
+
export type PrivateEventFilter = {
|
|
146
|
+
/** The address of the contract that emitted the events. */
|
|
147
|
+
contractAddress: AztecAddress;
|
|
148
|
+
/** Addresses of accounts that are in scope for this filter. */
|
|
149
|
+
scopes: AztecAddress[];
|
|
150
|
+
/** Transaction in which the events were emitted. */
|
|
151
|
+
txHash?: TxHash;
|
|
152
|
+
/** The block number from which to start fetching events (inclusive).
|
|
153
|
+
* Optional. If provided, it must be greater or equal than 1.
|
|
154
|
+
* Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
|
|
155
|
+
* */
|
|
156
|
+
fromBlock?: BlockNumber;
|
|
157
|
+
/** The block number until which to fetch logs (not inclusive).
|
|
158
|
+
* Optional. If provided, it must be greater than fromBlock.
|
|
159
|
+
* Defaults to the latest known block to PXE + 1.
|
|
160
|
+
*/
|
|
161
|
+
toBlock?: BlockNumber;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* An ABI decoded private event with associated metadata.
|
|
166
|
+
*/
|
|
167
|
+
export type PrivateEvent<T> = {
|
|
168
|
+
/** The ABI decoded event */
|
|
169
|
+
event: T;
|
|
170
|
+
/** Metadata describing event context information such as tx and block */
|
|
171
|
+
metadata: InTx;
|
|
172
|
+
};
|
|
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
|
+
|
|
148
200
|
/**
|
|
149
201
|
* The wallet interface.
|
|
150
202
|
*/
|
|
151
203
|
export type Wallet = {
|
|
152
|
-
getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
|
|
153
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
154
204
|
getPrivateEvents<T>(
|
|
155
|
-
contractAddress: AztecAddress,
|
|
156
205
|
eventMetadata: EventMetadataDefinition,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
recipients: AztecAddress[],
|
|
160
|
-
): Promise<T[]>;
|
|
206
|
+
eventFilter: PrivateEventFilter,
|
|
207
|
+
): Promise<PrivateEvent<T>[]>;
|
|
161
208
|
getChainInfo(): Promise<ChainInfo>;
|
|
162
|
-
|
|
209
|
+
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
210
|
+
getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
|
|
163
211
|
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
|
|
164
212
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
165
213
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
166
214
|
registerContract(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
registerContract(
|
|
171
|
-
instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
|
|
172
|
-
artifact: ContractArtifact,
|
|
173
|
-
): Promise<ContractInstanceWithAddress>;
|
|
174
|
-
registerContract(
|
|
175
|
-
instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
|
|
176
|
-
artifact: ContractArtifact | undefined,
|
|
177
|
-
secretKey: Fr | undefined,
|
|
215
|
+
instance: ContractInstanceWithAddress,
|
|
216
|
+
artifact?: ContractArtifact,
|
|
217
|
+
secretKey?: Fr,
|
|
178
218
|
): Promise<ContractInstanceWithAddress>;
|
|
179
219
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
180
|
-
simulateUtility(
|
|
181
|
-
functionName: string,
|
|
182
|
-
args: any[],
|
|
183
|
-
to: AztecAddress,
|
|
184
|
-
authwits?: AuthWitness[],
|
|
185
|
-
): Promise<UtilitySimulationResult>;
|
|
220
|
+
simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
|
|
186
221
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
187
|
-
sendTx
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
): Promise<AuthWitness>;
|
|
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
|
-
export const ContractInstantiationDataSchema = z.object({
|
|
196
|
-
constructorArtifact: optional(z.union([FunctionAbiSchema, z.string()])),
|
|
197
|
-
constructorArgs: optional(z.array(z.any())),
|
|
198
|
-
skipArgsDecoding: optional(z.boolean()),
|
|
199
|
-
salt: schemas.Fr,
|
|
200
|
-
publicKeys: optional(PublicKeys.schema),
|
|
201
|
-
deployer: optional(schemas.AztecAddress),
|
|
202
|
-
});
|
|
203
|
-
|
|
204
231
|
export const FunctionCallSchema = z.object({
|
|
205
232
|
name: z.string(),
|
|
206
233
|
to: schemas.AztecAddress,
|
|
@@ -217,9 +244,10 @@ export const ExecutionPayloadSchema = z.object({
|
|
|
217
244
|
authWitnesses: z.array(AuthWitness.schema),
|
|
218
245
|
capsules: z.array(Capsule.schema),
|
|
219
246
|
extraHashedArgs: z.array(HashedValues.schema),
|
|
247
|
+
feePayer: optional(schemas.AztecAddress),
|
|
220
248
|
});
|
|
221
249
|
|
|
222
|
-
export const
|
|
250
|
+
export const GasSettingsOptionSchema = z.object({
|
|
223
251
|
gasSettings: optional(
|
|
224
252
|
z.object({
|
|
225
253
|
gasLimits: optional(Gas.schema),
|
|
@@ -228,19 +256,26 @@ export const UserFeeOptionsSchema = z.object({
|
|
|
228
256
|
maxPriorityFeePerGas: optional(z.object({ feePerDaGas: schemas.BigInt, feePerL2Gas: schemas.BigInt })),
|
|
229
257
|
}),
|
|
230
258
|
),
|
|
231
|
-
embeddedPaymentMethodFeePayer: optional(schemas.AztecAddress),
|
|
232
259
|
});
|
|
233
260
|
|
|
234
|
-
export const WalletSimulationFeeOptionSchema =
|
|
261
|
+
export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
|
|
235
262
|
estimatedGasPadding: optional(z.number()),
|
|
236
263
|
estimateGas: optional(z.boolean()),
|
|
237
264
|
});
|
|
238
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
|
+
|
|
239
273
|
export const SendOptionsSchema = z.object({
|
|
240
274
|
from: schemas.AztecAddress,
|
|
241
275
|
authWitnesses: optional(z.array(AuthWitness.schema)),
|
|
242
276
|
capsules: optional(z.array(Capsule.schema)),
|
|
243
|
-
fee: optional(
|
|
277
|
+
fee: optional(GasSettingsOptionSchema),
|
|
278
|
+
wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
|
|
244
279
|
});
|
|
245
280
|
|
|
246
281
|
export const SimulateOptionsSchema = z.object({
|
|
@@ -258,72 +293,176 @@ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
|
|
|
258
293
|
skipProofGeneration: optional(z.boolean()),
|
|
259
294
|
});
|
|
260
295
|
|
|
261
|
-
export const InstanceDataSchema = z.union([
|
|
262
|
-
schemas.AztecAddress,
|
|
263
|
-
ContractInstanceWithAddressSchema,
|
|
264
|
-
ContractInstantiationDataSchema,
|
|
265
|
-
z.object({ instance: ContractInstanceWithAddressSchema, artifact: ContractArtifactSchema }),
|
|
266
|
-
]);
|
|
267
|
-
|
|
268
296
|
export const MessageHashOrIntentSchema = z.union([
|
|
269
|
-
schemas.Fr,
|
|
270
|
-
schemas.Buffer,
|
|
271
|
-
z.object({ consumer: schemas.AztecAddress, innerHash: z.union([schemas.Buffer, schemas.Fr]) }),
|
|
297
|
+
z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
|
|
272
298
|
z.object({
|
|
273
299
|
caller: schemas.AztecAddress,
|
|
274
300
|
call: FunctionCallSchema,
|
|
275
301
|
}),
|
|
276
302
|
]);
|
|
277
303
|
|
|
278
|
-
export const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
args: z.tuple([InstanceDataSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
|
|
286
|
-
}),
|
|
287
|
-
z.object({
|
|
288
|
-
name: z.literal('sendTx'),
|
|
289
|
-
args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
|
|
290
|
-
}),
|
|
304
|
+
export const EventMetadataDefinitionSchema = z.object({
|
|
305
|
+
eventSelector: schemas.EventSelector,
|
|
306
|
+
abiType: AbiTypeSchema,
|
|
307
|
+
fieldNames: z.array(z.string()),
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
|
|
291
311
|
z.object({
|
|
292
|
-
|
|
293
|
-
|
|
312
|
+
event: AbiDecodedSchema,
|
|
313
|
+
metadata: inTxSchema(),
|
|
294
314
|
}),
|
|
295
|
-
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
export const PrivateEventFilterSchema = z.object({
|
|
318
|
+
contractAddress: schemas.AztecAddress,
|
|
319
|
+
scopes: z.array(schemas.AztecAddress),
|
|
320
|
+
txHash: optional(TxHash.schema),
|
|
321
|
+
fromBlock: optional(BlockNumberPositiveSchema),
|
|
322
|
+
toBlock: optional(BlockNumberPositiveSchema),
|
|
323
|
+
});
|
|
296
324
|
|
|
297
325
|
export const ContractMetadataSchema = z.object({
|
|
298
|
-
|
|
326
|
+
instance: optional(ContractInstanceWithAddressSchema),
|
|
299
327
|
isContractInitialized: z.boolean(),
|
|
300
328
|
isContractPublished: z.boolean(),
|
|
301
|
-
|
|
329
|
+
isContractUpdated: z.boolean(),
|
|
330
|
+
updatedContractClassId: optional(schemas.Fr),
|
|
331
|
+
});
|
|
302
332
|
|
|
303
333
|
export const ContractClassMetadataSchema = z.object({
|
|
304
|
-
|
|
334
|
+
isArtifactRegistered: z.boolean(),
|
|
305
335
|
isContractClassPubliclyRegistered: z.boolean(),
|
|
306
|
-
|
|
307
|
-
}) satisfies ZodFor<ContractClassMetadata>;
|
|
336
|
+
});
|
|
308
337
|
|
|
309
|
-
export const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
fieldNames: z.array(z.string()),
|
|
338
|
+
export const ContractFunctionPatternSchema = z.object({
|
|
339
|
+
contract: z.union([schemas.AztecAddress, z.literal('*')]),
|
|
340
|
+
function: z.union([z.string(), z.literal('*')]),
|
|
313
341
|
});
|
|
314
342
|
|
|
315
|
-
export const
|
|
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 = {
|
|
316
456
|
getChainInfo: z
|
|
317
457
|
.function()
|
|
318
458
|
.args()
|
|
319
459
|
.returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
|
|
320
|
-
getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
|
|
321
460
|
getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
|
|
322
|
-
|
|
461
|
+
getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
|
|
323
462
|
getPrivateEvents: z
|
|
324
463
|
.function()
|
|
325
|
-
.args(
|
|
326
|
-
.returns(z.array(
|
|
464
|
+
.args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
|
|
465
|
+
.returns(z.array(PrivateEventSchema)),
|
|
327
466
|
registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
|
|
328
467
|
getAddressBook: z
|
|
329
468
|
.function()
|
|
@@ -335,28 +474,60 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
335
474
|
.returns(z.array(z.object({ alias: z.string(), item: schemas.AztecAddress }))),
|
|
336
475
|
registerContract: z
|
|
337
476
|
.function()
|
|
338
|
-
.args(
|
|
477
|
+
.args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
|
|
339
478
|
.returns(ContractInstanceWithAddressSchema),
|
|
340
479
|
simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
|
|
341
480
|
simulateUtility: z
|
|
342
481
|
.function()
|
|
343
|
-
.args(
|
|
482
|
+
.args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
|
|
344
483
|
.returns(UtilitySimulationResult.schema),
|
|
345
484
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
346
|
-
sendTx: z
|
|
485
|
+
sendTx: z
|
|
486
|
+
.function()
|
|
487
|
+
.args(ExecutionPayloadSchema, SendOptionsSchema)
|
|
488
|
+
.returns(z.union([TxHash.schema, TxReceipt.schema])),
|
|
347
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,
|
|
348
531
|
// @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
|
|
349
|
-
batch: z
|
|
350
|
-
.function()
|
|
351
|
-
.args(z.array(BatchedMethodSchema))
|
|
352
|
-
.returns(
|
|
353
|
-
z.array(
|
|
354
|
-
z.discriminatedUnion('name', [
|
|
355
|
-
z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
|
|
356
|
-
z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
|
|
357
|
-
z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
|
|
358
|
-
z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
|
|
359
|
-
]),
|
|
360
|
-
),
|
|
361
|
-
),
|
|
532
|
+
batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(BatchedResultSchema)),
|
|
362
533
|
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
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=interface.d.ts.map
|
|
@@ -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,0BAA0B,CAAC;AACnD,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"}
|