@aztec/aztec.js 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec

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 (191) hide show
  1. package/dest/account/account.d.ts +3 -4
  2. package/dest/account/account.d.ts.map +1 -1
  3. package/dest/account/account.js +1 -1
  4. package/dest/account/account_contract.d.ts +2 -2
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +3 -4
  7. package/dest/account/account_with_secret_key.d.ts.map +1 -1
  8. package/dest/account/index.d.ts +2 -2
  9. package/dest/account/index.d.ts.map +1 -1
  10. package/dest/account/interface.d.ts +2 -2
  11. package/dest/account/interface.d.ts.map +1 -1
  12. package/dest/account/signerless_account.d.ts +3 -4
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/api/abi.d.ts +1 -1
  15. package/dest/api/account.d.ts +2 -1
  16. package/dest/api/account.d.ts.map +1 -1
  17. package/dest/api/account.js +1 -0
  18. package/dest/api/addresses.d.ts +1 -1
  19. package/dest/api/authorization.d.ts +1 -1
  20. package/dest/api/block.d.ts +1 -1
  21. package/dest/api/contract.d.ts +3 -3
  22. package/dest/api/contract.d.ts.map +1 -1
  23. package/dest/api/contract.js +1 -1
  24. package/dest/api/crypto.d.ts +1 -1
  25. package/dest/api/deployment.d.ts +1 -1
  26. package/dest/api/eth_address.d.ts +1 -1
  27. package/dest/api/ethereum.d.ts +1 -1
  28. package/dest/api/events.d.ts +1 -1
  29. package/dest/api/fee.d.ts +1 -1
  30. package/dest/api/fee_testing.d.ts +1 -1
  31. package/dest/api/fields.d.ts +3 -2
  32. package/dest/api/fields.d.ts.map +1 -1
  33. package/dest/api/fields.js +2 -1
  34. package/dest/api/keys.d.ts +1 -1
  35. package/dest/api/log.d.ts +1 -1
  36. package/dest/api/messaging.d.ts +1 -1
  37. package/dest/api/node.d.ts +1 -1
  38. package/dest/api/note.d.ts +2 -2
  39. package/dest/api/note.d.ts.map +1 -1
  40. package/dest/api/note.js +1 -1
  41. package/dest/api/protocol.d.ts +1 -1
  42. package/dest/api/trees.d.ts +1 -1
  43. package/dest/api/tx.d.ts +2 -2
  44. package/dest/api/tx.d.ts.map +1 -1
  45. package/dest/api/tx.js +1 -1
  46. package/dest/api/utils.d.ts +1 -1
  47. package/dest/api/wallet.d.ts +2 -3
  48. package/dest/api/wallet.d.ts.map +1 -1
  49. package/dest/api/wallet.js +1 -2
  50. package/dest/authorization/call_authorization_request.d.ts +2 -23
  51. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  52. package/dest/contract/base_contract_interaction.d.ts +2 -3
  53. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  54. package/dest/contract/base_contract_interaction.js +1 -1
  55. package/dest/contract/batch_call.d.ts +8 -9
  56. package/dest/contract/batch_call.d.ts.map +1 -1
  57. package/dest/contract/batch_call.js +51 -33
  58. package/dest/contract/checker.d.ts +1 -1
  59. package/dest/contract/contract.d.ts +2 -2
  60. package/dest/contract/contract.d.ts.map +1 -1
  61. package/dest/contract/contract.js +4 -5
  62. package/dest/contract/contract_base.d.ts +5 -12
  63. package/dest/contract/contract_base.d.ts.map +1 -1
  64. package/dest/contract/contract_base.js +5 -12
  65. package/dest/contract/contract_function_interaction.d.ts +4 -4
  66. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  67. package/dest/contract/contract_function_interaction.js +9 -6
  68. package/dest/contract/deploy_method.d.ts +9 -8
  69. package/dest/contract/deploy_method.d.ts.map +1 -1
  70. package/dest/contract/deploy_method.js +9 -7
  71. package/dest/contract/deploy_sent_tx.d.ts +12 -7
  72. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  73. package/dest/contract/deploy_sent_tx.js +10 -4
  74. package/dest/contract/get_gas_limits.d.ts +1 -1
  75. package/dest/contract/interaction_options.d.ts +4 -4
  76. package/dest/contract/interaction_options.d.ts.map +1 -1
  77. package/dest/contract/interaction_options.js +4 -10
  78. package/dest/contract/protocol_contracts.d.ts +1 -1
  79. package/dest/contract/sent_tx.d.ts +2 -3
  80. package/dest/contract/sent_tx.d.ts.map +1 -1
  81. package/dest/contract/sent_tx.js +1 -1
  82. package/dest/contract/unsafe_contract.d.ts +1 -1
  83. package/dest/contract/unsafe_contract.d.ts.map +1 -1
  84. package/dest/contract/unsafe_contract.js +1 -1
  85. package/dest/contract/wait_for_proven.d.ts +2 -2
  86. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  87. package/dest/deployment/broadcast_function.d.ts +1 -1
  88. package/dest/deployment/broadcast_function.js +1 -1
  89. package/dest/deployment/contract_deployer.d.ts +1 -1
  90. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  91. package/dest/deployment/contract_deployer.js +1 -1
  92. package/dest/deployment/publish_class.d.ts +1 -1
  93. package/dest/deployment/publish_class.js +1 -1
  94. package/dest/deployment/publish_instance.d.ts +1 -1
  95. package/dest/ethereum/portal_manager.d.ts +4 -6
  96. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  97. package/dest/ethereum/portal_manager.js +40 -14
  98. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
  99. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  100. package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
  101. package/dest/fee/fee_payment_method.d.ts +2 -2
  102. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  103. package/dest/fee/private_fee_payment_method.d.ts +2 -2
  104. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  105. package/dest/fee/private_fee_payment_method.js +4 -4
  106. package/dest/fee/public_fee_payment_method.d.ts +2 -2
  107. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  108. package/dest/fee/public_fee_payment_method.js +4 -4
  109. package/dest/fee/sponsored_fee_payment.d.ts +2 -2
  110. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  111. package/dest/fee/sponsored_fee_payment.js +2 -2
  112. package/dest/utils/abi_types.d.ts +2 -2
  113. package/dest/utils/abi_types.d.ts.map +1 -1
  114. package/dest/utils/authwit.d.ts +7 -7
  115. package/dest/utils/authwit.d.ts.map +1 -1
  116. package/dest/utils/authwit.js +22 -11
  117. package/dest/utils/cross_chain.d.ts +2 -2
  118. package/dest/utils/cross_chain.d.ts.map +1 -1
  119. package/dest/utils/fee_juice.d.ts +2 -2
  120. package/dest/utils/fee_juice.js +2 -2
  121. package/dest/utils/field_compressed_string.d.ts +1 -1
  122. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  123. package/dest/utils/field_compressed_string.js +1 -1
  124. package/dest/utils/node.d.ts +2 -2
  125. package/dest/utils/node.d.ts.map +1 -1
  126. package/dest/utils/pub_key.d.ts +2 -2
  127. package/dest/utils/pub_key.d.ts.map +1 -1
  128. package/dest/utils/pub_key.js +1 -1
  129. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +2 -2
  130. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  131. package/dest/wallet/account_entrypoint_meta_payment_method.js +2 -2
  132. package/dest/wallet/account_manager.d.ts +2 -5
  133. package/dest/wallet/account_manager.d.ts.map +1 -1
  134. package/dest/wallet/account_manager.js +2 -2
  135. package/dest/wallet/deploy_account_method.d.ts +5 -5
  136. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  137. package/dest/wallet/deploy_account_method.js +2 -2
  138. package/dest/wallet/index.d.ts +1 -2
  139. package/dest/wallet/index.d.ts.map +1 -1
  140. package/dest/wallet/index.js +0 -1
  141. package/dest/wallet/wallet.d.ts +2173 -1097
  142. package/dest/wallet/wallet.d.ts.map +1 -1
  143. package/dest/wallet/wallet.js +42 -46
  144. package/package.json +13 -12
  145. package/src/account/account.ts +2 -3
  146. package/src/account/account_contract.ts +1 -1
  147. package/src/account/account_with_secret_key.ts +1 -1
  148. package/src/account/index.ts +1 -1
  149. package/src/account/interface.ts +1 -1
  150. package/src/account/signerless_account.ts +2 -3
  151. package/src/api/account.ts +1 -0
  152. package/src/api/contract.ts +2 -1
  153. package/src/api/fields.ts +2 -1
  154. package/src/api/note.ts +1 -1
  155. package/src/api/tx.ts +2 -0
  156. package/src/api/wallet.ts +5 -7
  157. package/src/authorization/call_authorization_request.ts +1 -1
  158. package/src/contract/base_contract_interaction.ts +2 -3
  159. package/src/contract/batch_call.ts +65 -48
  160. package/src/contract/contract.ts +7 -5
  161. package/src/contract/contract_base.ts +5 -15
  162. package/src/contract/contract_function_interaction.ts +10 -11
  163. package/src/contract/deploy_method.ts +13 -12
  164. package/src/contract/deploy_sent_tx.ts +17 -10
  165. package/src/contract/interaction_options.ts +4 -10
  166. package/src/contract/sent_tx.ts +2 -3
  167. package/src/contract/unsafe_contract.ts +1 -1
  168. package/src/deployment/broadcast_function.ts +1 -1
  169. package/src/deployment/contract_deployer.ts +3 -2
  170. package/src/deployment/publish_class.ts +1 -1
  171. package/src/ethereum/portal_manager.ts +58 -28
  172. package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
  173. package/src/fee/fee_payment_method.ts +1 -1
  174. package/src/fee/private_fee_payment_method.ts +5 -3
  175. package/src/fee/public_fee_payment_method.ts +5 -3
  176. package/src/fee/sponsored_fee_payment.ts +3 -1
  177. package/src/utils/abi_types.ts +1 -1
  178. package/src/utils/authwit.ts +21 -15
  179. package/src/utils/cross_chain.ts +1 -1
  180. package/src/utils/fee_juice.ts +2 -2
  181. package/src/utils/field_compressed_string.ts +1 -1
  182. package/src/utils/pub_key.ts +2 -2
  183. package/src/wallet/account_entrypoint_meta_payment_method.ts +2 -1
  184. package/src/wallet/account_manager.ts +2 -2
  185. package/src/wallet/deploy_account_method.ts +4 -3
  186. package/src/wallet/index.ts +0 -1
  187. package/src/wallet/wallet.ts +98 -91
  188. package/dest/wallet/base_wallet.d.ts +0 -91
  189. package/dest/wallet/base_wallet.d.ts.map +0 -1
  190. package/dest/wallet/base_wallet.js +0 -238
  191. package/src/wallet/base_wallet.ts +0 -350
@@ -1,8 +1,8 @@
1
1
  import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
2
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
3
2
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
4
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
4
  import type { GasSettings } from '@aztec/stdlib/gas';
5
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
6
6
 
7
7
  /**
8
8
  * A fee payment method that uses a contract that blindly sponsors transactions.
@@ -35,6 +35,8 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
35
35
  ],
36
36
  [],
37
37
  [],
38
+ [],
39
+ this.paymentContract, // feePayer
38
40
  );
39
41
  }
40
42
 
@@ -1,5 +1,5 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
1
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
- import type { Fr } from '@aztec/foundation/fields';
3
3
  import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
4
  import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
5
5
  import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
@@ -22,7 +22,7 @@ export type IntentInnerHash = {
22
22
  /** The consumer */
23
23
  consumer: AztecAddress;
24
24
  /** The action to approve */
25
- innerHash: Buffer<ArrayBuffer> | Fr;
25
+ innerHash: Fr;
26
26
  };
27
27
 
28
28
  /** Intent with a call */
@@ -43,7 +43,7 @@ export type ContractFunctionInteractionCallIntent = {
43
43
 
44
44
  /** Identifies ContractFunctionInteractionCallIntents */
45
45
  function isContractFunctionIntractionCallIntent(
46
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
46
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
47
47
  ): messageHashOrIntent is ContractFunctionInteractionCallIntent {
48
48
  return (
49
49
  'caller' in messageHashOrIntent &&
@@ -102,14 +102,12 @@ export const computeAuthWitMessageHash = async (
102
102
  * @returns The message hash for the intent
103
103
  */
104
104
  export async function getMessageHashFromIntent(
105
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
105
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
106
106
  chainInfo: ChainInfo,
107
107
  ) {
108
108
  let messageHash: Fr;
109
109
  const { chainId, version } = chainInfo;
110
- if (Buffer.isBuffer(messageHashOrIntent)) {
111
- messageHash = Fr.fromBuffer(messageHashOrIntent);
112
- } else if (messageHashOrIntent instanceof Fr) {
110
+ if (messageHashOrIntent instanceof Fr) {
113
111
  messageHash = messageHashOrIntent;
114
112
  } else {
115
113
  messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
@@ -159,9 +157,6 @@ export async function lookupValidity(
159
157
  const call = isContractFunctionIntractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
160
158
  innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
161
159
  consumer = call.to;
162
- } else if (Buffer.isBuffer(intent.innerHash)) {
163
- innerHash = Fr.fromBuffer(intent.innerHash);
164
- consumer = intent.consumer;
165
160
  } else {
166
161
  ({ innerHash, consumer } = intent);
167
162
  }
@@ -174,9 +169,20 @@ export async function lookupValidity(
174
169
  name: 'lookup_validity',
175
170
  isInitializer: false,
176
171
  functionType: FunctionType.UTILITY,
177
- isInternal: false,
172
+ isOnlySelf: false,
178
173
  isStatic: false,
179
- parameters: [{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility }],
174
+ parameters: [
175
+ {
176
+ name: 'consumer',
177
+ type: {
178
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
179
+ kind: 'struct',
180
+ path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
181
+ },
182
+ visibility: 'private' as ABIParameterVisibility,
183
+ },
184
+ { name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
185
+ ],
180
186
  returnTypes: [{ kind: 'boolean' }],
181
187
  errorTypes: {},
182
188
  } as FunctionAbi;
@@ -194,7 +200,7 @@ export async function lookupValidity(
194
200
  name: 'utility_is_consumable',
195
201
  isInitializer: false,
196
202
  functionType: FunctionType.UTILITY,
197
- isInternal: false,
203
+ isOnlySelf: false,
198
204
  isStatic: false,
199
205
  parameters: [
200
206
  {
@@ -240,7 +246,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
240
246
  static async create(
241
247
  wallet: Wallet,
242
248
  from: AztecAddress,
243
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
249
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
244
250
  authorized: boolean,
245
251
  ) {
246
252
  const chainInfo = await wallet.getChainInfo();
@@ -291,7 +297,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
291
297
  name: 'set_authorized',
292
298
  isInitializer: false,
293
299
  functionType: FunctionType.PUBLIC,
294
- isInternal: true,
300
+ isOnlySelf: true,
295
301
  isStatic: false,
296
302
  parameters: [
297
303
  {
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
@@ -6,7 +6,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
6
6
 
7
7
  /**
8
8
  * Returns the owner's fee juice balance.
9
- * Note: This is used only e2e_sandbox_example test. TODO: Consider nuking.
9
+ * Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
10
10
  */
11
11
  export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
12
12
  const slot = await deriveStorageSlotInMap(new Fr(1), owner);
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  /**
4
4
  * The representation of a FieldCompressedString in aztec.nr
@@ -1,5 +1,5 @@
1
- import { Grumpkin } from '@aztec/foundation/crypto';
2
- import type { GrumpkinScalar } from '@aztec/foundation/fields';
1
+ import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
2
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
3
3
  import type { PublicKey } from '@aztec/stdlib/keys';
4
4
 
5
5
  /**
@@ -1,6 +1,5 @@
1
1
  import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
2
2
  import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
3
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
4
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
4
  import {
6
5
  type ContractArtifact,
@@ -12,6 +11,7 @@ import {
12
11
  } from '@aztec/stdlib/abi';
13
12
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
13
  import type { GasSettings } from '@aztec/stdlib/gas';
14
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
15
15
 
16
16
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
17
17
  import type { Wallet } from './index.js';
@@ -92,6 +92,7 @@ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
92
92
  [payloadAuthWitness, ...feeAuthwitnesses],
93
93
  [],
94
94
  feeEncodedCalls.hashedArguments,
95
+ feePayer,
95
96
  );
96
97
  }
97
98
 
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import {
3
3
  CompleteAddress,
4
4
  type ContractInstanceWithAddress,
@@ -138,7 +138,7 @@ export class AccountManager {
138
138
  this.getPublicKeys(),
139
139
  this.wallet,
140
140
  artifact,
141
- address => Contract.at(address, artifact, this.wallet),
141
+ instance => Contract.at(instance.address, artifact, this.wallet),
142
142
  new Fr(this.salt),
143
143
  constructorArgs,
144
144
  constructorName,
@@ -1,8 +1,9 @@
1
- import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
4
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
5
  import type { PublicKeys } from '@aztec/stdlib/keys';
6
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
6
7
 
7
8
  import type { Contract } from '../contract/contract.js';
8
9
  import type { ContractBase } from '../contract/contract_base.js';
@@ -44,7 +45,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
44
45
  publicKeys: PublicKeys,
45
46
  wallet: Wallet,
46
47
  artifact: ContractArtifact,
47
- postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
48
+ postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
48
49
  private salt: Fr,
49
50
  args: any[] = [],
50
51
  constructorNameOrArtifact?: string | FunctionArtifact,
@@ -1,3 +1,2 @@
1
1
  export * from './wallet.js';
2
- export * from './base_wallet.js';
3
2
  export * from './account_manager.js';
@@ -1,12 +1,13 @@
1
1
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import type { ExecutionPayload } from '@aztec/entrypoints/payload';
3
- 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';
4
4
  import {
5
+ type AbiDecoded,
5
6
  AbiTypeSchema,
6
7
  type ContractArtifact,
7
8
  ContractArtifactSchema,
8
9
  type EventMetadataDefinition,
9
- FunctionAbiSchema,
10
+ type FunctionCall,
10
11
  FunctionType,
11
12
  } from '@aztec/stdlib/abi';
12
13
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
@@ -16,12 +17,10 @@ import {
16
17
  ContractClassWithIdSchema,
17
18
  type ContractInstanceWithAddress,
18
19
  ContractInstanceWithAddressSchema,
19
- type ContractInstantiationData,
20
20
  type ContractMetadata,
21
21
  } from '@aztec/stdlib/contract';
22
22
  import { Gas } from '@aztec/stdlib/gas';
23
- import { PublicKeys } from '@aztec/stdlib/keys';
24
- import { AbiDecodedSchema, type ApiSchemaFor, type ZodFor, optional, schemas } from '@aztec/stdlib/schemas';
23
+ import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
25
24
  import {
26
25
  Capsule,
27
26
  HashedValues,
@@ -30,11 +29,12 @@ import {
30
29
  TxReceipt,
31
30
  TxSimulationResult,
32
31
  UtilitySimulationResult,
32
+ inTxSchema,
33
33
  } from '@aztec/stdlib/tx';
34
+ import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
34
35
 
35
36
  import { z } from 'zod';
36
37
 
37
- import type { Contract } from '../contract/contract.js';
38
38
  import type {
39
39
  FeeEstimationOptions,
40
40
  GasSettingsOption,
@@ -58,22 +58,6 @@ export type Aliased<T> = {
58
58
  item: T;
59
59
  };
60
60
 
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
61
  /**
78
62
  * Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
79
63
  * a simplified version that only hints at the wallet wether the interaction contains a
@@ -81,7 +65,7 @@ export type UserFeeOptions = {
81
65
  */
82
66
  export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
83
67
  /** The fee options */
84
- fee?: UserFeeOptions & FeeEstimationOptions;
68
+ fee?: GasSettingsOption & FeeEstimationOptions;
85
69
  };
86
70
 
87
71
  /**
@@ -91,7 +75,7 @@ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
91
75
  */
92
76
  export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
93
77
  /** The fee options */
94
- fee?: UserFeeOptions;
78
+ fee?: GasSettingsOption;
95
79
  };
96
80
 
97
81
  /**
@@ -101,13 +85,16 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
101
85
  */
102
86
  export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
103
87
  /** The fee options */
104
- fee?: UserFeeOptions;
88
+ fee?: GasSettingsOption;
105
89
  };
106
90
 
107
91
  /**
108
92
  * Helper type that represents all methods that can be batched.
109
93
  */
110
- export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility'>;
94
+ export type BatchableMethods = Pick<
95
+ Wallet,
96
+ 'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility' | 'simulateTx'
97
+ >;
111
98
 
112
99
  /**
113
100
  * From the batchable methods, we create a type that represents a method call with its name and arguments.
@@ -145,6 +132,38 @@ export type BatchResults<T extends readonly BatchedMethod<keyof BatchableMethods
145
132
  [K in keyof T]: BatchedMethodResultWrapper<T[K]>;
146
133
  };
147
134
 
135
+ /**
136
+ * Filter options when querying private events.
137
+ */
138
+ export type PrivateEventFilter = {
139
+ /** The address of the contract that emitted the events. */
140
+ contractAddress: AztecAddress;
141
+ /** Addresses of accounts that are in scope for this filter. */
142
+ scopes: AztecAddress[];
143
+ /** Transaction in which the events were emitted. */
144
+ txHash?: TxHash;
145
+ /** The block number from which to start fetching events (inclusive).
146
+ * Optional. If provided, it must be greater or equal than 1.
147
+ * Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
148
+ * */
149
+ fromBlock?: BlockNumber;
150
+ /** The block number until which to fetch logs (not inclusive).
151
+ * Optional. If provided, it must be greater than fromBlock.
152
+ * Defaults to the latest known block to PXE + 1.
153
+ */
154
+ toBlock?: BlockNumber;
155
+ };
156
+
157
+ /**
158
+ * An ABI decoded private event with associated metadata.
159
+ */
160
+ export type PrivateEvent<T> = {
161
+ /** The ABI decoded event */
162
+ event: T;
163
+ /** Metadata describing event context information such as tx and block */
164
+ metadata: InTx;
165
+ };
166
+
148
167
  /**
149
168
  * The wallet interface.
150
169
  */
@@ -152,55 +171,27 @@ export type Wallet = {
152
171
  getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
153
172
  getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
154
173
  getPrivateEvents<T>(
155
- contractAddress: AztecAddress,
156
174
  eventMetadata: EventMetadataDefinition,
157
- from: number,
158
- numBlocks: number,
159
- recipients: AztecAddress[],
160
- ): Promise<T[]>;
175
+ eventFilter: PrivateEventFilter,
176
+ ): Promise<PrivateEvent<T>[]>;
161
177
  getChainInfo(): Promise<ChainInfo>;
162
178
  getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
163
179
  registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
164
180
  getAddressBook(): Promise<Aliased<AztecAddress>[]>;
165
181
  getAccounts(): Promise<Aliased<AztecAddress>[]>;
166
182
  registerContract(
167
- instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
168
- ): Promise<ContractInstanceWithAddress>;
169
- // Overloaded definition to avoid zod issues
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,
183
+ instance: ContractInstanceWithAddress,
184
+ artifact?: ContractArtifact,
185
+ secretKey?: Fr,
178
186
  ): Promise<ContractInstanceWithAddress>;
179
187
  simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
180
- simulateUtility(
181
- functionName: string,
182
- args: any[],
183
- to: AztecAddress,
184
- authwits?: AuthWitness[],
185
- ): Promise<UtilitySimulationResult>;
188
+ simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
186
189
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
187
190
  sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
188
- createAuthWit(
189
- from: AztecAddress,
190
- messageHashOrIntent: Fr | Buffer<ArrayBuffer> | IntentInnerHash | CallIntent,
191
- ): Promise<AuthWitness>;
191
+ createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | IntentInnerHash | CallIntent): Promise<AuthWitness>;
192
192
  batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(methods: T): Promise<BatchResults<T>>;
193
193
  };
194
194
 
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
195
  export const FunctionCallSchema = z.object({
205
196
  name: z.string(),
206
197
  to: schemas.AztecAddress,
@@ -217,9 +208,10 @@ export const ExecutionPayloadSchema = z.object({
217
208
  authWitnesses: z.array(AuthWitness.schema),
218
209
  capsules: z.array(Capsule.schema),
219
210
  extraHashedArgs: z.array(HashedValues.schema),
211
+ feePayer: optional(schemas.AztecAddress),
220
212
  });
221
213
 
222
- export const UserFeeOptionsSchema = z.object({
214
+ export const GasSettingsOptionSchema = z.object({
223
215
  gasSettings: optional(
224
216
  z.object({
225
217
  gasLimits: optional(Gas.schema),
@@ -228,10 +220,9 @@ export const UserFeeOptionsSchema = z.object({
228
220
  maxPriorityFeePerGas: optional(z.object({ feePerDaGas: schemas.BigInt, feePerL2Gas: schemas.BigInt })),
229
221
  }),
230
222
  ),
231
- embeddedPaymentMethodFeePayer: optional(schemas.AztecAddress),
232
223
  });
233
224
 
234
- export const WalletSimulationFeeOptionSchema = UserFeeOptionsSchema.extend({
225
+ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
235
226
  estimatedGasPadding: optional(z.number()),
236
227
  estimateGas: optional(z.boolean()),
237
228
  });
@@ -240,7 +231,7 @@ export const SendOptionsSchema = z.object({
240
231
  from: schemas.AztecAddress,
241
232
  authWitnesses: optional(z.array(AuthWitness.schema)),
242
233
  capsules: optional(z.array(Capsule.schema)),
243
- fee: optional(UserFeeOptionsSchema),
234
+ fee: optional(GasSettingsOptionSchema),
244
235
  });
245
236
 
246
237
  export const SimulateOptionsSchema = z.object({
@@ -258,17 +249,9 @@ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
258
249
  skipProofGeneration: optional(z.boolean()),
259
250
  });
260
251
 
261
- export const InstanceDataSchema = z.union([
262
- schemas.AztecAddress,
263
- ContractInstanceWithAddressSchema,
264
- ContractInstantiationDataSchema,
265
- z.object({ instance: ContractInstanceWithAddressSchema, artifact: ContractArtifactSchema }),
266
- ]);
267
-
268
252
  export const MessageHashOrIntentSchema = z.union([
269
253
  schemas.Fr,
270
- schemas.Buffer,
271
- z.object({ consumer: schemas.AztecAddress, innerHash: z.union([schemas.Buffer, schemas.Fr]) }),
254
+ z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
272
255
  z.object({
273
256
  caller: schemas.AztecAddress,
274
257
  call: FunctionCallSchema,
@@ -282,7 +265,7 @@ export const BatchedMethodSchema = z.union([
282
265
  }),
283
266
  z.object({
284
267
  name: z.literal('registerContract'),
285
- args: z.tuple([InstanceDataSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
268
+ args: z.tuple([ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
286
269
  }),
287
270
  z.object({
288
271
  name: z.literal('sendTx'),
@@ -290,21 +273,29 @@ export const BatchedMethodSchema = z.union([
290
273
  }),
291
274
  z.object({
292
275
  name: z.literal('simulateUtility'),
293
- args: z.tuple([z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema))]),
276
+ args: z.tuple([FunctionCallSchema, optional(z.array(AuthWitness.schema))]),
277
+ }),
278
+ z.object({
279
+ name: z.literal('simulateTx'),
280
+ args: z.tuple([ExecutionPayloadSchema, SimulateOptionsSchema]),
294
281
  }),
295
282
  ]);
296
283
 
297
- export const ContractMetadataSchema = z.object({
298
- contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
299
- isContractInitialized: z.boolean(),
300
- isContractPublished: z.boolean(),
301
- }) satisfies ZodFor<ContractMetadata>;
284
+ export const ContractMetadataSchema = zodFor<ContractMetadata>()(
285
+ z.object({
286
+ contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
287
+ isContractInitialized: z.boolean(),
288
+ isContractPublished: z.boolean(),
289
+ }),
290
+ );
302
291
 
303
- export const ContractClassMetadataSchema = z.object({
304
- contractClass: z.union([ContractClassWithIdSchema, z.undefined()]),
305
- isContractClassPubliclyRegistered: z.boolean(),
306
- artifact: z.union([ContractArtifactSchema, z.undefined()]),
307
- }) satisfies ZodFor<ContractClassMetadata>;
292
+ export const ContractClassMetadataSchema = zodFor<ContractClassMetadata>()(
293
+ z.object({
294
+ contractClass: z.union([ContractClassWithIdSchema, z.undefined()]),
295
+ isContractClassPubliclyRegistered: z.boolean(),
296
+ artifact: z.union([ContractArtifactSchema, z.undefined()]),
297
+ }),
298
+ );
308
299
 
309
300
  export const EventMetadataDefinitionSchema = z.object({
310
301
  eventSelector: schemas.EventSelector,
@@ -312,6 +303,21 @@ export const EventMetadataDefinitionSchema = z.object({
312
303
  fieldNames: z.array(z.string()),
313
304
  });
314
305
 
306
+ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
307
+ z.object({
308
+ event: AbiDecodedSchema,
309
+ metadata: inTxSchema(),
310
+ }),
311
+ );
312
+
313
+ export const PrivateEventFilterSchema = z.object({
314
+ contractAddress: schemas.AztecAddress,
315
+ scopes: z.array(schemas.AztecAddress),
316
+ txHash: optional(TxHash.schema),
317
+ fromBlock: optional(BlockNumberPositiveSchema),
318
+ toBlock: optional(BlockNumberPositiveSchema),
319
+ });
320
+
315
321
  export const WalletSchema: ApiSchemaFor<Wallet> = {
316
322
  getChainInfo: z
317
323
  .function()
@@ -322,8 +328,8 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
322
328
  getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
323
329
  getPrivateEvents: z
324
330
  .function()
325
- .args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress))
326
- .returns(z.array(AbiDecodedSchema)),
331
+ .args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
332
+ .returns(z.array(PrivateEventSchema)),
327
333
  registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
328
334
  getAddressBook: z
329
335
  .function()
@@ -335,12 +341,12 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
335
341
  .returns(z.array(z.object({ alias: z.string(), item: schemas.AztecAddress }))),
336
342
  registerContract: z
337
343
  .function()
338
- .args(InstanceDataSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
344
+ .args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
339
345
  .returns(ContractInstanceWithAddressSchema),
340
346
  simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
341
347
  simulateUtility: z
342
348
  .function()
343
- .args(z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema)))
349
+ .args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
344
350
  .returns(UtilitySimulationResult.schema),
345
351
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
346
352
  sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
@@ -356,6 +362,7 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
356
362
  z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
357
363
  z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
358
364
  z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
365
+ z.object({ name: z.literal('simulateTx'), result: TxSimulationResult.schema }),
359
366
  ]),
360
367
  ),
361
368
  ),