@aztec/aztec.js 0.0.1-commit.d3ec352c → 0.0.1-commit.d431d1c

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