@aztec/aztec.js 3.0.3 → 4.0.0-devnet.1-patch.0
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 +18 -12
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +16 -10
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/events.d.ts +10 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +30 -20
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/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/batch_call.d.ts +1 -1
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +3 -1
- package/dest/contract/contract_base.d.ts +4 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +3 -12
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +6 -6
- 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 +15 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +127 -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/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 +7 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +15 -16
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
- package/dest/fee/private_fee_payment_method.js +10 -10
- package/dest/fee/public_fee_payment_method.js +10 -10
- package/dest/fee/sponsored_fee_payment.js +3 -3
- package/dest/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 +1642 -1007
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +201 -107
- package/package.json +24 -13
- 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 +24 -9
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +1 -0
- 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 +47 -3
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +4 -2
- package/src/contract/contract_function_interaction.ts +13 -6
- 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 +96 -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/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +17 -21
- package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +7 -7
- package/src/fee/public_fee_payment_method.ts +8 -8
- package/src/fee/sponsored_fee_payment.ts +3 -3
- package/src/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 +319 -118
- 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/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/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/deployment/broadcast_function.ts +0 -148
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { Aliased } from './wallet.js';
|
|
4
|
+
/**
|
|
5
|
+
* Current capability manifest version.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CAPABILITY_VERSION: "1.0";
|
|
8
|
+
/**
|
|
9
|
+
* Pattern for matching contract functions with wildcards.
|
|
10
|
+
*
|
|
11
|
+
* Used in simulation and transaction capabilities to specify which
|
|
12
|
+
* contract functions are allowed.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Allow any function on a specific contract
|
|
16
|
+
* \{ contract: ammAddress, function: '*' \}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Allow only 'swap' function on a specific contract
|
|
20
|
+
* \{ contract: ammAddress, function: 'swap' \}
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Allow 'transfer' on any contract
|
|
24
|
+
* \{ contract: '*', function: 'transfer' \}
|
|
25
|
+
*/
|
|
26
|
+
export interface ContractFunctionPattern {
|
|
27
|
+
/** Contract address or '*' for any contract */
|
|
28
|
+
contract: AztecAddress | '*';
|
|
29
|
+
/** Function name or '*' for any function */
|
|
30
|
+
function: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Account access capability - grants access to user accounts.
|
|
34
|
+
*
|
|
35
|
+
* Maps to wallet methods:
|
|
36
|
+
* - getAccounts (when canGet: true)
|
|
37
|
+
* - createAuthWit (when canCreateAuthWit: true)
|
|
38
|
+
*
|
|
39
|
+
* The wallet decides which accounts to reveal to the app.
|
|
40
|
+
* Apps don't specify which accounts they want - they just request
|
|
41
|
+
* the capability and the wallet shows them the available accounts.
|
|
42
|
+
*/
|
|
43
|
+
export interface AccountsCapability {
|
|
44
|
+
/** Discriminator for capability type */
|
|
45
|
+
type: 'accounts';
|
|
46
|
+
/** Can get accounts from wallet. Maps to: getAccounts */
|
|
47
|
+
canGet?: boolean;
|
|
48
|
+
/** Can create auth witnesses for accounts. Maps to: createAuthWit */
|
|
49
|
+
canCreateAuthWit?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Granted account access capability.
|
|
53
|
+
*
|
|
54
|
+
* Extends the request with specific accounts that were granted by the wallet.
|
|
55
|
+
*/
|
|
56
|
+
export interface GrantedAccountsCapability extends AccountsCapability {
|
|
57
|
+
/** Specific accounts granted by the wallet with their aliases. The wallet adds this when granting the capability. */
|
|
58
|
+
accounts: Aliased<AztecAddress>[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Contract interaction capability - for registering and querying contracts.
|
|
62
|
+
*
|
|
63
|
+
* Maps to wallet methods:
|
|
64
|
+
* - registerContract (when canRegister: true)
|
|
65
|
+
* - getContractMetadata (when canGetMetadata: true)
|
|
66
|
+
*
|
|
67
|
+
* Matching is done by contract address, not class ID. This allows updating
|
|
68
|
+
* existing contracts with new artifacts (e.g., when contract is upgraded
|
|
69
|
+
* to a new contractClassId on-chain).
|
|
70
|
+
*
|
|
71
|
+
* Note: For querying contract class metadata, use ContractClassesCapability instead.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Register and query specific contracts
|
|
75
|
+
* \{
|
|
76
|
+
* type: 'contracts',
|
|
77
|
+
* contracts: [ammAddress, tokenAddress],
|
|
78
|
+
* canRegister: true,
|
|
79
|
+
* canGetMetadata: true
|
|
80
|
+
* \}
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Query any contract (read-only)
|
|
84
|
+
* \{
|
|
85
|
+
* type: 'contracts',
|
|
86
|
+
* contracts: '*',
|
|
87
|
+
* canGetMetadata: true
|
|
88
|
+
* \}
|
|
89
|
+
*/
|
|
90
|
+
export interface ContractsCapability {
|
|
91
|
+
/** Discriminator for capability type */
|
|
92
|
+
type: 'contracts';
|
|
93
|
+
/**
|
|
94
|
+
* Which contracts this applies to:
|
|
95
|
+
* - '*': Any contract address
|
|
96
|
+
* - AztecAddress[]: Specific contract addresses
|
|
97
|
+
*/
|
|
98
|
+
contracts: '*' | AztecAddress[];
|
|
99
|
+
/**
|
|
100
|
+
* Can register contracts and update existing registrations.
|
|
101
|
+
* Maps to: registerContract
|
|
102
|
+
*
|
|
103
|
+
* When true, allows:
|
|
104
|
+
* - Registering new contract instances at specified addresses
|
|
105
|
+
* - Re-registering existing contracts with updated artifacts (e.g., after upgrade)
|
|
106
|
+
*/
|
|
107
|
+
canRegister?: boolean;
|
|
108
|
+
/** Can query contract metadata. Maps to: getContractMetadata */
|
|
109
|
+
canGetMetadata?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Granted contract interaction capability.
|
|
113
|
+
*
|
|
114
|
+
* The wallet may reduce the scope (e.g., from '*' to specific addresses).
|
|
115
|
+
*/
|
|
116
|
+
export interface GrantedContractsCapability extends ContractsCapability {
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Contract class capability - for querying contract class metadata.
|
|
120
|
+
*
|
|
121
|
+
* Maps to wallet methods:
|
|
122
|
+
* - getContractClassMetadata
|
|
123
|
+
*
|
|
124
|
+
* Contract classes are identified by their class ID (Fr), not by contract address.
|
|
125
|
+
* Multiple contract instances can share the same class. This capability grants
|
|
126
|
+
* permission to query metadata for specific contract classes.
|
|
127
|
+
*
|
|
128
|
+
* Apps typically acquire this permission automatically when registering a contract
|
|
129
|
+
* with an artifact (the wallet auto-grants permission for that contract's class ID).
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Query specific contract classes
|
|
133
|
+
* \{
|
|
134
|
+
* type: 'contractClasses',
|
|
135
|
+
* classes: [classId1, classId2],
|
|
136
|
+
* canGetMetadata: true
|
|
137
|
+
* \}
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* // Query any contract class (wildcard)
|
|
141
|
+
* \{
|
|
142
|
+
* type: 'contractClasses',
|
|
143
|
+
* classes: '*',
|
|
144
|
+
* canGetMetadata: true
|
|
145
|
+
* \}
|
|
146
|
+
*/
|
|
147
|
+
export interface ContractClassesCapability {
|
|
148
|
+
/** Discriminator for capability type */
|
|
149
|
+
type: 'contractClasses';
|
|
150
|
+
/**
|
|
151
|
+
* Which contract classes this applies to:
|
|
152
|
+
* - '*': Any contract class ID
|
|
153
|
+
* - Fr[]: Specific contract class IDs
|
|
154
|
+
*/
|
|
155
|
+
classes: '*' | Fr[];
|
|
156
|
+
/** Can query contract class metadata. Maps to: getContractClassMetadata */
|
|
157
|
+
canGetMetadata: boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Granted contract class capability.
|
|
161
|
+
*
|
|
162
|
+
* The wallet may reduce the scope (e.g., from '*' to specific class IDs).
|
|
163
|
+
*/
|
|
164
|
+
export interface GrantedContractClassesCapability extends ContractClassesCapability {
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Transaction simulation capability - for simulating transactions and utilities.
|
|
168
|
+
*
|
|
169
|
+
* Maps to wallet methods:
|
|
170
|
+
* - simulateTx (when transactions scope specified)
|
|
171
|
+
* - simulateUtility (when utilities scope specified)
|
|
172
|
+
* - profileTx (when transactions scope specified)
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* // Simulate any transaction on specific contracts
|
|
176
|
+
* \{
|
|
177
|
+
* type: 'simulation',
|
|
178
|
+
* transactions: \{
|
|
179
|
+
* scope: [
|
|
180
|
+
* \{ contract: ammAddress, function: '*' \},
|
|
181
|
+
* \{ contract: tokenAddress, function: 'transfer' \}
|
|
182
|
+
* ]
|
|
183
|
+
* \}
|
|
184
|
+
* \}
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* // Simulate any transaction and utility call
|
|
188
|
+
* \{
|
|
189
|
+
* type: 'simulation',
|
|
190
|
+
* transactions: \{ scope: '*' \},
|
|
191
|
+
* utilities: \{ scope: '*' \}
|
|
192
|
+
* \}
|
|
193
|
+
*/
|
|
194
|
+
export interface SimulationCapability {
|
|
195
|
+
/** Discriminator for capability type */
|
|
196
|
+
type: 'simulation';
|
|
197
|
+
/** Transaction simulation scope. Maps to: simulateTx, profileTx */
|
|
198
|
+
transactions?: {
|
|
199
|
+
/**
|
|
200
|
+
* Which contracts/functions to allow:
|
|
201
|
+
* - '*': Any transaction
|
|
202
|
+
* - ContractFunctionPattern[]: Specific contract functions
|
|
203
|
+
*/
|
|
204
|
+
scope: '*' | ContractFunctionPattern[];
|
|
205
|
+
};
|
|
206
|
+
/** Utility simulation scope (unconstrained calls). Maps to: simulateUtility */
|
|
207
|
+
utilities?: {
|
|
208
|
+
/**
|
|
209
|
+
* Which contracts/functions to allow:
|
|
210
|
+
* - '*': Any utility call
|
|
211
|
+
* - ContractFunctionPattern[]: Specific contract functions
|
|
212
|
+
*/
|
|
213
|
+
scope: '*' | ContractFunctionPattern[];
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Granted transaction simulation capability.
|
|
218
|
+
*
|
|
219
|
+
* The wallet may reduce the scope (e.g., from '*' to specific patterns).
|
|
220
|
+
*/
|
|
221
|
+
export interface GrantedSimulationCapability extends SimulationCapability {
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Transaction execution capability - for sending transactions.
|
|
225
|
+
*
|
|
226
|
+
* Maps to wallet methods:
|
|
227
|
+
* - sendTx
|
|
228
|
+
*
|
|
229
|
+
* Policy enforcement (rate limits, spending limits) should be handled
|
|
230
|
+
* at the contract level in Aztec, not at the wallet level.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* // Send specific transactions with approval
|
|
234
|
+
* \{
|
|
235
|
+
* type: 'transaction',
|
|
236
|
+
* scope: [
|
|
237
|
+
* \{ contract: ammAddress, function: 'swap' \},
|
|
238
|
+
* \{ contract: ammAddress, function: 'addLiquidity' \}
|
|
239
|
+
* ]
|
|
240
|
+
* \}
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* // Send any transaction
|
|
244
|
+
* \{
|
|
245
|
+
* type: 'transaction',
|
|
246
|
+
* scope: '*'
|
|
247
|
+
* \}
|
|
248
|
+
*/
|
|
249
|
+
export interface TransactionCapability {
|
|
250
|
+
/** Discriminator for capability type */
|
|
251
|
+
type: 'transaction';
|
|
252
|
+
/**
|
|
253
|
+
* Which contracts/functions to allow:
|
|
254
|
+
* - '*': Any transaction
|
|
255
|
+
* - ContractFunctionPattern[]: Specific patterns
|
|
256
|
+
*/
|
|
257
|
+
scope: '*' | ContractFunctionPattern[];
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Granted transaction execution capability.
|
|
261
|
+
*
|
|
262
|
+
* The wallet may reduce the scope (e.g., from '*' to specific patterns).
|
|
263
|
+
*/
|
|
264
|
+
export interface GrantedTransactionCapability extends TransactionCapability {
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Data access capability - for querying private data.
|
|
268
|
+
*
|
|
269
|
+
* Maps to wallet methods:
|
|
270
|
+
* - getAddressBook (when addressBook: true)
|
|
271
|
+
* - getPrivateEvents (when privateEvents specified)
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* // Access address book and events from specific contract
|
|
275
|
+
* \{
|
|
276
|
+
* type: 'data',
|
|
277
|
+
* addressBook: true,
|
|
278
|
+
* privateEvents: \{
|
|
279
|
+
* contracts: [ammAddress],
|
|
280
|
+
* events: ['Swap', 'LiquidityAdded']
|
|
281
|
+
* \}
|
|
282
|
+
* \}
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* // Access all events from any contract
|
|
286
|
+
* \{
|
|
287
|
+
* type: 'data',
|
|
288
|
+
* privateEvents: \{
|
|
289
|
+
* contracts: '*',
|
|
290
|
+
* events: '*'
|
|
291
|
+
* \}
|
|
292
|
+
* \}
|
|
293
|
+
*/
|
|
294
|
+
export interface DataCapability {
|
|
295
|
+
/** Discriminator for capability type */
|
|
296
|
+
type: 'data';
|
|
297
|
+
/** Access to address book. Maps to: getAddressBook */
|
|
298
|
+
addressBook?: boolean;
|
|
299
|
+
/** Access to private events. Maps to: getPrivateEvents */
|
|
300
|
+
privateEvents?: {
|
|
301
|
+
/**
|
|
302
|
+
* Which contracts to allow event queries from:
|
|
303
|
+
* - '*': Any contract
|
|
304
|
+
* - AztecAddress[]: Specific contracts
|
|
305
|
+
*/
|
|
306
|
+
contracts: '*' | AztecAddress[];
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Granted data access capability.
|
|
311
|
+
*
|
|
312
|
+
* The wallet may reduce the scope (e.g., from '*' to specific contracts).
|
|
313
|
+
*/
|
|
314
|
+
export interface GrantedDataCapability extends DataCapability {
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Union type of all capability scopes (app request).
|
|
318
|
+
*
|
|
319
|
+
* Capabilities group wallet operations by their security sensitivity
|
|
320
|
+
* and functional cohesion, making permission requests understandable
|
|
321
|
+
* to users.
|
|
322
|
+
*/
|
|
323
|
+
export type Capability = AccountsCapability | ContractsCapability | ContractClassesCapability | SimulationCapability | TransactionCapability | DataCapability;
|
|
324
|
+
/**
|
|
325
|
+
* Union type of all granted capabilities (wallet response).
|
|
326
|
+
*
|
|
327
|
+
* The wallet may augment capabilities with additional information:
|
|
328
|
+
* - AccountsCapability: adds specific accounts granted
|
|
329
|
+
* - Other capabilities: may reduce scope (e.g., '*' to specific addresses)
|
|
330
|
+
*/
|
|
331
|
+
export type GrantedCapability = GrantedAccountsCapability | GrantedContractsCapability | GrantedContractClassesCapability | GrantedSimulationCapability | GrantedTransactionCapability | GrantedDataCapability;
|
|
332
|
+
/**
|
|
333
|
+
* Application capability manifest.
|
|
334
|
+
*
|
|
335
|
+
* Sent by dApp to declare all operations it needs. This reduces authorization
|
|
336
|
+
* friction from multiple dialogs to a single comprehensive permission request.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* // DEX application manifest
|
|
340
|
+
* const manifest: AppCapabilities = \{
|
|
341
|
+
* version: CAPABILITY_VERSION,
|
|
342
|
+
* metadata: \{
|
|
343
|
+
* name: 'MyDEX',
|
|
344
|
+
* version: '1.0.0',
|
|
345
|
+
* description: 'Decentralized exchange for private token swaps',
|
|
346
|
+
* url: 'https://example.com',
|
|
347
|
+
* icon: 'https://example.com/icon.png'
|
|
348
|
+
* \},
|
|
349
|
+
* capabilities: [
|
|
350
|
+
* \{
|
|
351
|
+
* type: 'accounts',
|
|
352
|
+
* canGet: true,
|
|
353
|
+
* canCreateAuthWit: true
|
|
354
|
+
* \},
|
|
355
|
+
* \{
|
|
356
|
+
* type: 'contracts',
|
|
357
|
+
* contracts: [ammAddress, tokenAAddress, tokenBAddress],
|
|
358
|
+
* canRegister: true,
|
|
359
|
+
* canGetMetadata: true
|
|
360
|
+
* \},
|
|
361
|
+
* \{
|
|
362
|
+
* type: 'simulation',
|
|
363
|
+
* transactions: \{
|
|
364
|
+
* scope: [\{ contract: ammAddress, function: '*' \}]
|
|
365
|
+
* \}
|
|
366
|
+
* \},
|
|
367
|
+
* \{
|
|
368
|
+
* type: 'transaction',
|
|
369
|
+
* scope: [\{ contract: ammAddress, function: 'swap' \}]
|
|
370
|
+
* \}
|
|
371
|
+
* ]
|
|
372
|
+
* \};
|
|
373
|
+
*/
|
|
374
|
+
export interface AppCapabilities {
|
|
375
|
+
/**
|
|
376
|
+
* Manifest version for forward compatibility.
|
|
377
|
+
* Currently only '1.0' is supported.
|
|
378
|
+
*/
|
|
379
|
+
version: typeof CAPABILITY_VERSION;
|
|
380
|
+
/** Application metadata for display in authorization dialogs. */
|
|
381
|
+
metadata: {
|
|
382
|
+
/** Human-readable app name */
|
|
383
|
+
name: string;
|
|
384
|
+
/** App version */
|
|
385
|
+
version: string;
|
|
386
|
+
/** Optional description of what the app does */
|
|
387
|
+
description?: string;
|
|
388
|
+
/** Optional website URL */
|
|
389
|
+
url?: string;
|
|
390
|
+
/** Optional icon URL or data URI */
|
|
391
|
+
icon?: string;
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Requested capabilities grouped by scope.
|
|
395
|
+
*/
|
|
396
|
+
capabilities: Capability[];
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Wallet capability response.
|
|
400
|
+
*
|
|
401
|
+
* Returned by wallet after user reviews and approves/denies the capability request.
|
|
402
|
+
*
|
|
403
|
+
* The wallet can modify requested capabilities:
|
|
404
|
+
* - Reduce scope (e.g., restrict to specific contracts instead of '*')
|
|
405
|
+
* - Add information (e.g., specify which accounts are granted)
|
|
406
|
+
* - Deny capabilities (by omitting them from the `granted` array)
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* // App requests
|
|
410
|
+
* const manifest: AppCapabilities = \{
|
|
411
|
+
* version: '1.0',
|
|
412
|
+
* metadata: \{ name: 'MyDApp', version: '1.0.0' \},
|
|
413
|
+
* capabilities: [
|
|
414
|
+
* \{ type: 'accounts', canGet: true \},
|
|
415
|
+
* \{ type: 'contracts', contracts: '*', canRegister: true \}
|
|
416
|
+
* ]
|
|
417
|
+
* \};
|
|
418
|
+
*
|
|
419
|
+
* // Wallet responds with specific accounts and restricted contracts
|
|
420
|
+
* const response = await wallet.requestCapabilities(manifest);
|
|
421
|
+
* console.log(response.granted);
|
|
422
|
+
* // [
|
|
423
|
+
* // \{ type: 'accounts', canGet: true, accounts: [addr1, addr2] \},
|
|
424
|
+
* // \{ type: 'contracts', contracts: [specificContract], canRegister: true \}
|
|
425
|
+
* // ]
|
|
426
|
+
*/
|
|
427
|
+
export interface WalletCapabilities {
|
|
428
|
+
/** Response version for forward compatibility. */
|
|
429
|
+
version: typeof CAPABILITY_VERSION;
|
|
430
|
+
/**
|
|
431
|
+
* Capabilities granted by the wallet.
|
|
432
|
+
* Capabilities not in this array were implicitly denied.
|
|
433
|
+
* Empty array means the user denied all capabilities.
|
|
434
|
+
*/
|
|
435
|
+
granted: GrantedCapability[];
|
|
436
|
+
/** Wallet implementation details. */
|
|
437
|
+
wallet: {
|
|
438
|
+
/** Wallet name/implementation */
|
|
439
|
+
name: string;
|
|
440
|
+
/** Wallet version */
|
|
441
|
+
version: string;
|
|
442
|
+
};
|
|
443
|
+
}
|
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stdlib/abi';
|
|
|
3
3
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
4
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { Account } from '../account/account.js';
|
|
6
7
|
import type { Contract } from '../contract/contract.js';
|
|
7
8
|
import type { ContractBase } from '../contract/contract_base.js';
|
|
8
|
-
import { DeployMethod, type
|
|
9
|
+
import { DeployMethod, type DeployOptionsWithoutWait, type RequestDeployOptions, type SimulateDeployOptions } from '../contract/deploy_method.js';
|
|
10
|
+
import type { FeePaymentMethodOption, InteractionWaitOptions } from '../contract/interaction_options.js';
|
|
9
11
|
import type { Wallet } from './index.js';
|
|
12
|
+
/**
|
|
13
|
+
* Extended fee payment method option for account deployments that includes entrypoint wrapping options
|
|
14
|
+
*/
|
|
15
|
+
export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
|
|
16
|
+
/** Optional entrypoint-specific options for wrapping execution payloads */
|
|
17
|
+
feeEntrypointOptions?: unknown;
|
|
18
|
+
};
|
|
10
19
|
/**
|
|
11
20
|
* The configuration options for the request method. Omits the contractAddressSalt, since
|
|
12
21
|
* for account contracts that is fixed in the constructor
|
|
13
22
|
*/
|
|
14
|
-
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'
|
|
23
|
+
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
|
|
24
|
+
/** Fee options specific to account deployment */
|
|
25
|
+
fee?: DeployAccountFeePaymentMethodOption;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Base configuration options for the send/prove methods without wait parameter. Omits:
|
|
29
|
+
* - The contractAddressSalt, since for account contracts that is fixed in the constructor.
|
|
30
|
+
* - UniversalDeployment flag, since account contracts are always deployed with it set to true
|
|
31
|
+
*/
|
|
32
|
+
export type DeployAccountOptionsWithoutWait = Omit<DeployOptionsWithoutWait, 'contractAddressSalt' | 'universalDeploy'>;
|
|
15
33
|
/**
|
|
16
34
|
* The configuration options for the send/prove methods. Omits:
|
|
17
35
|
* - The contractAddressSalt, since for account contracts that is fixed in the constructor.
|
|
18
36
|
* - UniversalDeployment flag, since account contracts are always deployed with it set to true
|
|
19
37
|
*/
|
|
20
|
-
export type DeployAccountOptions =
|
|
38
|
+
export type DeployAccountOptions<W extends InteractionWaitOptions = undefined> = DeployAccountOptionsWithoutWait & {
|
|
39
|
+
/**
|
|
40
|
+
* Whether to wait for the transaction to be mined.
|
|
41
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
42
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
43
|
+
* - false: return txHash immediately without waiting
|
|
44
|
+
*/
|
|
45
|
+
wait?: W;
|
|
46
|
+
};
|
|
21
47
|
/**
|
|
22
48
|
* The configuration options for the simulate method. Omits the contractAddressSalt, since
|
|
23
49
|
* for account contracts that is fixed in the constructor
|
|
@@ -29,7 +55,8 @@ export type SimulateDeployAccountOptions = Omit<SimulateDeployOptions, 'contract
|
|
|
29
55
|
*/
|
|
30
56
|
export declare class DeployAccountMethod<TContract extends ContractBase = Contract> extends DeployMethod<TContract> {
|
|
31
57
|
private salt;
|
|
32
|
-
|
|
58
|
+
private account;
|
|
59
|
+
constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract, salt: Fr, account: Account, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact);
|
|
33
60
|
/**
|
|
34
61
|
* Returns a FeePaymentMethod that routes the original one provided as an argument
|
|
35
62
|
* through the account's entrypoint. This allows an account contract to pay
|
|
@@ -38,6 +65,7 @@ export declare class DeployAccountMethod<TContract extends ContractBase = Contra
|
|
|
38
65
|
* For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
|
|
39
66
|
*
|
|
40
67
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
68
|
+
* @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
|
|
41
69
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
42
70
|
*/
|
|
43
71
|
private getSelfFeePaymentMethod;
|
|
@@ -47,6 +75,6 @@ export declare class DeployAccountMethod<TContract extends ContractBase = Contra
|
|
|
47
75
|
* @returns The execution payload for this operation
|
|
48
76
|
*/
|
|
49
77
|
request(opts?: RequestDeployAccountOptions): Promise<ExecutionPayload>;
|
|
50
|
-
convertDeployOptionsToRequestOptions(options:
|
|
78
|
+
convertDeployOptionsToRequestOptions(options: DeployAccountOptionsWithoutWait): RequestDeployOptions;
|
|
51
79
|
}
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
80
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X2FjY291bnRfbWV0aG9kLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L2RlcGxveV9hY2NvdW50X21ldGhvZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUU1RSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ3JELE9BQU8sRUFBRSxnQkFBZ0IsRUFBMEIsTUFBTSxrQkFBa0IsQ0FBQztBQUU1RSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSx1QkFBd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AO,EAAE,+BAA+B,GAAG,oBAAoB,CAS5G;CACF"}
|
|
@@ -8,8 +8,9 @@ import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_pa
|
|
|
8
8
|
* contracts that can pay for their own fee, plus some preconfigured options to avoid errors.
|
|
9
9
|
*/ export class DeployAccountMethod extends DeployMethod {
|
|
10
10
|
salt;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
account;
|
|
12
|
+
constructor(publicKeys, wallet, artifact, postDeployCtor, salt, account, args = [], constructorNameOrArtifact){
|
|
13
|
+
super(publicKeys, wallet, artifact, postDeployCtor, args, constructorNameOrArtifact), this.salt = salt, this.account = account;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Returns a FeePaymentMethod that routes the original one provided as an argument
|
|
@@ -19,12 +20,13 @@ import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_pa
|
|
|
19
20
|
* For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
|
|
20
21
|
*
|
|
21
22
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
23
|
+
* @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
|
|
22
24
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
23
|
-
*/ getSelfFeePaymentMethod(originalPaymentMethod) {
|
|
25
|
+
*/ getSelfFeePaymentMethod(originalPaymentMethod, feeEntrypointOptions) {
|
|
24
26
|
if (!this.address) {
|
|
25
27
|
throw new Error('Instance is not yet constructed. This is a bug!');
|
|
26
28
|
}
|
|
27
|
-
return new AccountEntrypointMetaPaymentMethod(this.
|
|
29
|
+
return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Returns the execution payload that allows this operation to happen on chain.
|
|
@@ -51,7 +53,7 @@ import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_pa
|
|
|
51
53
|
];
|
|
52
54
|
// If this is a self-deployment, manage the fee accordingly
|
|
53
55
|
if (opts?.deployer?.equals(AztecAddress.ZERO)) {
|
|
54
|
-
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
|
|
56
|
+
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
|
|
55
57
|
const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
|
|
56
58
|
// Notice they are reversed (fee payment usually goes first):
|
|
57
59
|
// this is because we need to construct the contract BEFORE it can pay for its own fee
|
package/dest/wallet/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './wallet.js';
|
|
2
2
|
export * from './account_manager.js';
|
|
3
|
-
|
|
3
|
+
export * from './capabilities.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93YWxsZXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLG1CQUFtQixDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
package/dest/wallet/index.js
CHANGED