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

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 (261) hide show
  1. package/dest/account/account.d.ts +26 -42
  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 +20 -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 +7 -9
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/account/signerless_account.js +8 -11
  15. package/dest/api/abi.d.ts +1 -1
  16. package/dest/api/account.d.ts +3 -4
  17. package/dest/api/account.d.ts.map +1 -1
  18. package/dest/api/account.js +2 -3
  19. package/dest/api/addresses.d.ts +1 -1
  20. package/dest/api/authorization.d.ts +2 -2
  21. package/dest/api/authorization.d.ts.map +1 -1
  22. package/dest/api/authorization.js +1 -1
  23. package/dest/api/block.d.ts +1 -1
  24. package/dest/api/contract.d.ts +19 -13
  25. package/dest/api/contract.d.ts.map +1 -1
  26. package/dest/api/contract.js +17 -11
  27. package/dest/api/crypto.d.ts +1 -1
  28. package/dest/api/deployment.d.ts +1 -2
  29. package/dest/api/deployment.d.ts.map +1 -1
  30. package/dest/api/deployment.js +0 -1
  31. package/dest/api/eth_address.d.ts +1 -1
  32. package/dest/api/ethereum.d.ts +1 -1
  33. package/dest/api/events.d.ts +10 -6
  34. package/dest/api/events.d.ts.map +1 -1
  35. package/dest/api/events.js +30 -20
  36. package/dest/api/fee.d.ts +1 -1
  37. package/dest/api/fee_testing.d.ts +1 -1
  38. package/dest/api/fields.d.ts +4 -2
  39. package/dest/api/fields.d.ts.map +1 -1
  40. package/dest/api/fields.js +3 -1
  41. package/dest/api/keys.d.ts +2 -2
  42. package/dest/api/keys.js +1 -1
  43. package/dest/api/log.d.ts +1 -1
  44. package/dest/api/messaging.d.ts +1 -1
  45. package/dest/api/node.d.ts +8 -4
  46. package/dest/api/node.d.ts.map +1 -1
  47. package/dest/api/node.js +7 -3
  48. package/dest/api/note.d.ts +2 -2
  49. package/dest/api/note.d.ts.map +1 -1
  50. package/dest/api/note.js +1 -1
  51. package/dest/api/protocol.d.ts +7 -1
  52. package/dest/api/protocol.d.ts.map +1 -1
  53. package/dest/api/protocol.js +6 -0
  54. package/dest/api/trees.d.ts +1 -1
  55. package/dest/api/tx.d.ts +2 -2
  56. package/dest/api/tx.d.ts.map +1 -1
  57. package/dest/api/tx.js +1 -1
  58. package/dest/api/utils.d.ts +1 -1
  59. package/dest/api/wallet.d.ts +3 -3
  60. package/dest/api/wallet.d.ts.map +1 -1
  61. package/dest/api/wallet.js +2 -2
  62. package/dest/authorization/call_authorization_request.d.ts +2 -2
  63. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  64. package/dest/contract/base_contract_interaction.d.ts +8 -11
  65. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  66. package/dest/contract/base_contract_interaction.js +5 -17
  67. package/dest/contract/batch_call.d.ts +8 -9
  68. package/dest/contract/batch_call.d.ts.map +1 -1
  69. package/dest/contract/batch_call.js +59 -36
  70. package/dest/contract/checker.d.ts +1 -1
  71. package/dest/contract/contract.d.ts +2 -2
  72. package/dest/contract/contract.d.ts.map +1 -1
  73. package/dest/contract/contract.js +4 -5
  74. package/dest/contract/contract_base.d.ts +6 -10
  75. package/dest/contract/contract_base.d.ts.map +1 -1
  76. package/dest/contract/contract_base.js +5 -12
  77. package/dest/contract/contract_function_interaction.d.ts +5 -14
  78. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  79. package/dest/contract/contract_function_interaction.js +18 -12
  80. package/dest/contract/deploy_method.d.ts +85 -24
  81. package/dest/contract/deploy_method.d.ts.map +1 -1
  82. package/dest/contract/deploy_method.js +71 -36
  83. package/dest/contract/get_gas_limits.d.ts +1 -1
  84. package/dest/contract/get_gas_limits.js +3 -3
  85. package/dest/contract/interaction_options.d.ts +51 -7
  86. package/dest/contract/interaction_options.d.ts.map +1 -1
  87. package/dest/contract/interaction_options.js +12 -11
  88. package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
  89. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  90. package/dest/contract/protocol_contracts/auth-registry.js +1005 -0
  91. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
  92. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  93. package/dest/contract/protocol_contracts/contract-class-registry.js +139 -0
  94. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
  95. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  96. package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
  97. package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
  98. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  99. package/dest/contract/protocol_contracts/fee-juice.js +434 -0
  100. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  101. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  102. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +601 -0
  103. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  104. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  105. package/dest/contract/protocol_contracts/public-checks.js +609 -0
  106. package/dest/contract/wait_for_proven.d.ts +2 -2
  107. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  108. package/dest/contract/wait_for_proven.js +1 -1
  109. package/dest/contract/wait_opts.d.ts +16 -0
  110. package/dest/contract/wait_opts.d.ts.map +1 -0
  111. package/dest/contract/wait_opts.js +5 -0
  112. package/dest/deployment/contract_deployer.d.ts +1 -1
  113. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  114. package/dest/deployment/contract_deployer.js +1 -1
  115. package/dest/deployment/publish_class.d.ts +1 -1
  116. package/dest/deployment/publish_class.js +3 -3
  117. package/dest/deployment/publish_instance.d.ts +2 -2
  118. package/dest/deployment/publish_instance.d.ts.map +1 -1
  119. package/dest/deployment/publish_instance.js +3 -3
  120. package/dest/ethereum/portal_manager.d.ts +7 -6
  121. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  122. package/dest/ethereum/portal_manager.js +48 -22
  123. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
  124. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  125. package/dest/fee/fee_juice_payment_method_with_claim.js +9 -9
  126. package/dest/fee/fee_payment_method.d.ts +2 -2
  127. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  128. package/dest/fee/private_fee_payment_method.d.ts +2 -2
  129. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  130. package/dest/fee/private_fee_payment_method.js +14 -14
  131. package/dest/fee/public_fee_payment_method.d.ts +2 -2
  132. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  133. package/dest/fee/public_fee_payment_method.js +14 -14
  134. package/dest/fee/sponsored_fee_payment.d.ts +2 -2
  135. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  136. package/dest/fee/sponsored_fee_payment.js +5 -5
  137. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  138. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  139. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  140. package/dest/utils/abi_types.d.ts +2 -2
  141. package/dest/utils/abi_types.d.ts.map +1 -1
  142. package/dest/utils/authwit.d.ts +14 -12
  143. package/dest/utils/authwit.d.ts.map +1 -1
  144. package/dest/utils/authwit.js +27 -20
  145. package/dest/utils/cross_chain.d.ts +2 -2
  146. package/dest/utils/cross_chain.d.ts.map +1 -1
  147. package/dest/utils/fee_juice.d.ts +2 -2
  148. package/dest/utils/fee_juice.js +2 -2
  149. package/dest/utils/field_compressed_string.d.ts +1 -1
  150. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  151. package/dest/utils/field_compressed_string.js +1 -1
  152. package/dest/utils/node.d.ts +13 -2
  153. package/dest/utils/node.d.ts.map +1 -1
  154. package/dest/utils/node.js +46 -0
  155. package/dest/utils/pub_key.d.ts +2 -2
  156. package/dest/utils/pub_key.d.ts.map +1 -1
  157. package/dest/utils/pub_key.js +1 -1
  158. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +6 -9
  159. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  160. package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
  161. package/dest/wallet/account_manager.d.ts +3 -9
  162. package/dest/wallet/account_manager.d.ts.map +1 -1
  163. package/dest/wallet/account_manager.js +6 -12
  164. package/dest/wallet/capabilities.d.ts +452 -0
  165. package/dest/wallet/capabilities.d.ts.map +1 -0
  166. package/dest/wallet/capabilities.js +3 -0
  167. package/dest/wallet/deploy_account_method.d.ts +49 -10
  168. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  169. package/dest/wallet/deploy_account_method.js +35 -7
  170. package/dest/wallet/index.d.ts +2 -2
  171. package/dest/wallet/index.d.ts.map +1 -1
  172. package/dest/wallet/index.js +1 -1
  173. package/dest/wallet/wallet.d.ts +1853 -1533
  174. package/dest/wallet/wallet.d.ts.map +1 -1
  175. package/dest/wallet/wallet.js +223 -124
  176. package/package.json +27 -15
  177. package/src/account/account.ts +35 -60
  178. package/src/account/account_contract.ts +7 -8
  179. package/src/account/account_with_secret_key.ts +34 -9
  180. package/src/account/index.ts +3 -2
  181. package/src/account/signerless_account.ts +15 -15
  182. package/src/api/account.ts +10 -3
  183. package/src/api/authorization.ts +1 -0
  184. package/src/api/contract.ts +26 -10
  185. package/src/api/deployment.ts +0 -1
  186. package/src/api/events.ts +35 -27
  187. package/src/api/fields.ts +3 -1
  188. package/src/api/keys.ts +2 -2
  189. package/src/api/node.ts +7 -3
  190. package/src/api/note.ts +1 -1
  191. package/src/api/protocol.ts +7 -0
  192. package/src/api/tx.ts +4 -0
  193. package/src/api/wallet.ts +52 -9
  194. package/src/authorization/call_authorization_request.ts +1 -1
  195. package/src/contract/base_contract_interaction.ts +27 -16
  196. package/src/contract/batch_call.ts +62 -48
  197. package/src/contract/contract.ts +7 -5
  198. package/src/contract/contract_base.ts +5 -15
  199. package/src/contract/contract_function_interaction.ts +26 -17
  200. package/src/contract/deploy_method.ts +175 -47
  201. package/src/contract/get_gas_limits.ts +3 -3
  202. package/src/contract/interaction_options.ts +59 -13
  203. package/src/contract/protocol_contracts/auth-registry.ts +553 -0
  204. package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
  205. package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
  206. package/src/contract/protocol_contracts/fee-juice.ts +266 -0
  207. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +336 -0
  208. package/src/contract/protocol_contracts/public-checks.ts +320 -0
  209. package/src/contract/wait_for_proven.ts +1 -1
  210. package/src/contract/wait_opts.ts +21 -0
  211. package/src/deployment/contract_deployer.ts +3 -2
  212. package/src/deployment/publish_class.ts +3 -3
  213. package/src/deployment/publish_instance.ts +3 -6
  214. package/src/ethereum/portal_manager.ts +65 -34
  215. package/src/fee/fee_juice_payment_method_with_claim.ts +9 -7
  216. package/src/fee/fee_payment_method.ts +1 -1
  217. package/src/fee/private_fee_payment_method.ts +12 -10
  218. package/src/fee/public_fee_payment_method.ts +13 -11
  219. package/src/fee/sponsored_fee_payment.ts +6 -4
  220. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  221. package/src/utils/abi_types.ts +1 -1
  222. package/src/utils/authwit.ts +40 -22
  223. package/src/utils/cross_chain.ts +1 -1
  224. package/src/utils/fee_juice.ts +2 -2
  225. package/src/utils/field_compressed_string.ts +1 -1
  226. package/src/utils/node.ts +62 -0
  227. package/src/utils/pub_key.ts +2 -2
  228. package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
  229. package/src/wallet/account_manager.ts +7 -15
  230. package/src/wallet/capabilities.ts +500 -0
  231. package/src/wallet/deploy_account_method.ts +78 -16
  232. package/src/wallet/index.ts +1 -1
  233. package/src/wallet/wallet.ts +387 -166
  234. package/dest/account/interface.d.ts +0 -19
  235. package/dest/account/interface.d.ts.map +0 -1
  236. package/dest/account/interface.js +0 -5
  237. package/dest/contract/deploy_sent_tx.d.ts +0 -43
  238. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  239. package/dest/contract/deploy_sent_tx.js +0 -40
  240. package/dest/contract/protocol_contracts.d.ts +0 -9
  241. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  242. package/dest/contract/protocol_contracts.js +0 -26
  243. package/dest/contract/sent_tx.d.ts +0 -51
  244. package/dest/contract/sent_tx.d.ts.map +0 -1
  245. package/dest/contract/sent_tx.js +0 -90
  246. package/dest/contract/unsafe_contract.d.ts +0 -15
  247. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  248. package/dest/contract/unsafe_contract.js +0 -6
  249. package/dest/deployment/broadcast_function.d.ts +0 -24
  250. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  251. package/dest/deployment/broadcast_function.js +0 -74
  252. package/dest/wallet/base_wallet.d.ts +0 -91
  253. package/dest/wallet/base_wallet.d.ts.map +0 -1
  254. package/dest/wallet/base_wallet.js +0 -238
  255. package/src/account/interface.ts +0 -25
  256. package/src/contract/deploy_sent_tx.ts +0 -68
  257. package/src/contract/protocol_contracts.ts +0 -35
  258. package/src/contract/sent_tx.ts +0 -130
  259. package/src/contract/unsafe_contract.ts +0 -19
  260. package/src/deployment/broadcast_function.ts +0 -148
  261. package/src/wallet/base_wallet.ts +0 -350
@@ -1,97 +1,72 @@
1
1
  import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
2
- import type { ExecutionPayload } from '@aztec/entrypoints/payload';
3
- import { Fr } from '@aztec/foundation/fields';
2
+ import type { AuthWitnessProvider, ChainInfo, EntrypointInterface } from '@aztec/entrypoints/interfaces';
4
3
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { CompleteAddress } from '@aztec/stdlib/contract';
5
6
  import type { GasSettings } from '@aztec/stdlib/gas';
6
- import type { TxExecutionRequest } from '@aztec/stdlib/tx';
7
+ import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
7
8
 
8
9
  import { type CallIntent, type IntentInnerHash, computeAuthWitMessageHash } from '../utils/authwit.js';
9
- import type { AccountInterface } from './interface.js';
10
10
 
11
11
  /**
12
- * An authwit provider that can create both private and public authwits
13
- * with an intent as input, as opposed to just a precomputed inner hash
12
+ * Provides authorization for actions via the AuthWitness mechanism.
14
13
  */
15
- interface AuthwitnessIntentProvider {
14
+ export interface AuthorizationProvider {
16
15
  /**
17
- * Creates a private authwit from an intent or inner hash, to be provided
18
- * during function execution
16
+ * Creates an authentication witness from an inner hash with consumer, or a call intent
19
17
  * @param intent - The action (or inner hash) to authorize
18
+ * @param chainInfo - Chain information needed for message hash computation
20
19
  */
21
- createAuthWit(intent: IntentInnerHash | CallIntent | Buffer | Fr): Promise<AuthWitness>;
20
+ createAuthWit(intent: IntentInnerHash | CallIntent, chainInfo: ChainInfo): Promise<AuthWitness>;
22
21
  }
23
22
 
23
+ // docs:start:account-interface
24
24
  /**
25
- * A type defining an account, capable of both creating authwits and using them
26
- * to authenticate transaction execution requests.
25
+ * Minimal interface for transaction execution and authorization.
27
26
  */
28
- export type Account = AccountInterface & AuthwitnessIntentProvider;
27
+ export type Account = EntrypointInterface &
28
+ AuthorizationProvider & {
29
+ /** Returns the complete address for this account. */
30
+ getCompleteAddress(): CompleteAddress;
31
+ /** Returns the address for this account. */
32
+ getAddress(): AztecAddress;
33
+ };
34
+ // docs:end:account-interface
29
35
 
30
36
  /**
31
37
  * An account implementation that uses authwits as an authentication mechanism
32
38
  * and can assemble transaction execution requests for an entrypoint.
33
39
  */
34
40
  export class BaseAccount implements Account {
35
- constructor(protected account: AccountInterface) {}
41
+ constructor(
42
+ private entrypoint: EntrypointInterface,
43
+ private authWitnessProvider: AuthWitnessProvider,
44
+ private completeAddress: CompleteAddress,
45
+ ) {}
36
46
 
37
47
  createTxExecutionRequest(
38
48
  exec: ExecutionPayload,
39
49
  gasSettings: GasSettings,
50
+ chainInfo: ChainInfo,
40
51
  options: DefaultAccountEntrypointOptions,
41
52
  ): Promise<TxExecutionRequest> {
42
- return this.account.createTxExecutionRequest(exec, gasSettings, options);
53
+ return this.entrypoint.createTxExecutionRequest(exec, gasSettings, chainInfo, options);
43
54
  }
44
55
 
45
- getChainId(): Fr {
46
- return this.account.getChainId();
56
+ wrapExecutionPayload(exec: ExecutionPayload, options?: any): Promise<ExecutionPayload> {
57
+ return this.entrypoint.wrapExecutionPayload(exec, options);
47
58
  }
48
59
 
49
- getVersion(): Fr {
50
- return this.account.getVersion();
60
+ async createAuthWit(messageHashOrIntent: CallIntent | IntentInnerHash, chainInfo: ChainInfo): Promise<AuthWitness> {
61
+ const messageHash = await computeAuthWitMessageHash(messageHashOrIntent, chainInfo);
62
+ return this.authWitnessProvider.createAuthWit(messageHash);
51
63
  }
52
64
 
53
- /** Returns the complete address of the account that implements this wallet. */
54
- public getCompleteAddress() {
55
- return this.account.getCompleteAddress();
65
+ getCompleteAddress(): CompleteAddress {
66
+ return this.completeAddress;
56
67
  }
57
68
 
58
- /** Returns the address of the account that implements this wallet. */
59
- public getAddress() {
60
- return this.getCompleteAddress().address;
61
- }
62
-
63
- /**
64
- * Computes an authentication witness from either a message hash or an intent.
65
- *
66
- * If a message hash is provided, it will create a witness for the hash directly.
67
- * Otherwise, it will compute the message hash using the intent, along with the
68
- * chain id and the version values provided by the wallet.
69
- *
70
- * @param messageHashOrIntent - The message hash of the intent to approve
71
- * @returns The authentication witness
72
- */
73
- async createAuthWit(messageHashOrIntent: Fr | Buffer | CallIntent | IntentInnerHash): Promise<AuthWitness> {
74
- let messageHash: Fr;
75
- if (Buffer.isBuffer(messageHashOrIntent)) {
76
- messageHash = Fr.fromBuffer(messageHashOrIntent);
77
- } else if (messageHashOrIntent instanceof Fr) {
78
- messageHash = messageHashOrIntent;
79
- } else {
80
- messageHash = await this.getMessageHash(messageHashOrIntent);
81
- }
82
-
83
- return this.account.createAuthWit(messageHash);
84
- }
85
-
86
- /**
87
- * Returns the message hash for the given intent
88
- *
89
- * @param intent - A tuple of (consumer and inner hash) or (caller and action)
90
- * @returns The message hash
91
- */
92
- private getMessageHash(intent: IntentInnerHash | CallIntent): Promise<Fr> {
93
- const chainId = this.getChainId();
94
- const version = this.getVersion();
95
- return computeAuthWitMessageHash(intent, { chainId, version });
69
+ getAddress(): AztecAddress {
70
+ return this.completeAddress.address;
96
71
  }
97
72
  }
@@ -1,11 +1,11 @@
1
- import type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import type { AuthWitnessProvider } from '@aztec/entrypoints/interfaces';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ContractArtifact } from '@aztec/stdlib/abi';
4
4
  import type { CompleteAddress } from '@aztec/stdlib/contract';
5
5
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
6
6
  import { deriveKeys } from '@aztec/stdlib/keys';
7
7
 
8
- import type { AccountInterface } from './interface.js';
8
+ import type { Account } from './account.js';
9
9
 
10
10
  /**
11
11
  * An account contract instance. Knows its artifact, deployment arguments, how to create
@@ -31,14 +31,13 @@ export interface AccountContract {
31
31
  >;
32
32
 
33
33
  /**
34
- * Returns the account interface for this account contract given an instance at the provided address.
35
- * The account interface is responsible for assembling tx requests given requested function calls, and
34
+ * Returns the account implementation for this account contract given an instance at the provided address.
35
+ * The account is responsible for assembling tx requests given requested function calls, and
36
36
  * for creating signed auth witnesses given action identifiers (message hashes).
37
37
  * @param address - Address of this account contract.
38
- * @param chainInfo - Chain id and version of the rollup where the account contract is initialized / published.
39
- * @returns An account interface instance for creating tx requests and authorizing actions.
38
+ * @returns An account instance for creating tx requests and authorizing actions.
40
39
  */
41
- getInterface(address: CompleteAddress, chainInfo: ChainInfo): AccountInterface;
40
+ getAccount(address: CompleteAddress): Account;
42
41
 
43
42
  /**
44
43
  * Returns the auth witness provider for the given address.
@@ -1,23 +1,48 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { CompleteAddress } from '@aztec/stdlib/contract';
6
+ import type { GasSettings } from '@aztec/stdlib/gas';
2
7
  import { computeAddressSecret, deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
8
+ import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
3
9
 
4
- import { BaseAccount } from './account.js';
5
- import type { Salt } from './index.js';
6
- import type { AccountInterface } from './interface.js';
10
+ import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
11
+ import type { Account, Salt } from './index.js';
7
12
 
8
13
  /**
9
- * Extends {@link Account} with the encryption private key. Not required for
14
+ * Extends {@link BaseAccount} with the encryption private key. Not required for
10
15
  * implementing the wallet interface but useful for testing purposes or exporting
11
16
  * an account to another pxe.
12
17
  */
13
- export class AccountWithSecretKey extends BaseAccount {
18
+ export class AccountWithSecretKey implements Account {
14
19
  constructor(
15
- account: AccountInterface,
20
+ private account: Account,
16
21
  private secretKey: Fr,
17
22
  /** Deployment salt for this account contract. */
18
23
  public readonly salt: Salt,
19
- ) {
20
- super(account);
24
+ ) {}
25
+
26
+ createTxExecutionRequest(
27
+ exec: ExecutionPayload,
28
+ gasSettings: GasSettings,
29
+ chainInfo: ChainInfo,
30
+ options?: any,
31
+ ): Promise<TxExecutionRequest> {
32
+ return this.account.createTxExecutionRequest(exec, gasSettings, chainInfo, options);
33
+ }
34
+
35
+ wrapExecutionPayload(exec: ExecutionPayload, options?: any): Promise<ExecutionPayload> {
36
+ return this.account.wrapExecutionPayload(exec, options);
37
+ }
38
+ createAuthWit(intent: IntentInnerHash | CallIntent, chainInfo: ChainInfo): Promise<AuthWitness> {
39
+ return this.account.createAuthWit(intent, chainInfo);
40
+ }
41
+ getCompleteAddress(): CompleteAddress {
42
+ return this.account.getCompleteAddress();
43
+ }
44
+ getAddress(): AztecAddress {
45
+ return this.account.getAddress();
21
46
  }
22
47
 
23
48
  /** Returns the encryption private key associated with this account. */
@@ -3,10 +3,11 @@
3
3
  *
4
4
  * @packageDocumentation
5
5
  */
6
- import type { Fr } from '@aztec/foundation/fields';
6
+ import type { Fr } from '@aztec/foundation/curves/bn254';
7
7
 
8
8
  export { type AccountContract, getAccountContractAddress } from './account_contract.js';
9
- export { type AccountInterface } from './interface.js';
9
+ export { type Account, BaseAccount, type AuthorizationProvider } from './account.js';
10
+ export { AccountWithSecretKey } from './account_with_secret_key.js';
10
11
 
11
12
  /** A contract deployment salt. */
12
13
  export type Salt = Fr | number | bigint;
@@ -1,12 +1,11 @@
1
1
  import type { ChainInfo, EntrypointInterface } from '@aztec/entrypoints/interfaces';
2
2
  import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
3
- import type { ExecutionPayload } from '@aztec/entrypoints/payload';
4
- import type { Fr } from '@aztec/foundation/fields';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
5
4
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
6
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
6
  import type { CompleteAddress } from '@aztec/stdlib/contract';
8
7
  import type { GasSettings } from '@aztec/stdlib/gas';
9
- import type { TxExecutionRequest } from '@aztec/stdlib/tx';
8
+ import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
10
9
 
11
10
  import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
12
11
  import type { Account } from './account.js';
@@ -16,20 +15,25 @@ import type { Account } from './account.js';
16
15
  */
17
16
  export class SignerlessAccount implements Account {
18
17
  private entrypoint: EntrypointInterface;
19
- constructor(chainInfo: ChainInfo) {
20
- this.entrypoint = new DefaultMultiCallEntrypoint(chainInfo.chainId.toNumber(), chainInfo.version.toNumber());
18
+
19
+ constructor() {
20
+ this.entrypoint = new DefaultMultiCallEntrypoint();
21
21
  }
22
22
 
23
- createTxExecutionRequest(exec: ExecutionPayload, gasSettings: GasSettings): Promise<TxExecutionRequest> {
24
- return this.entrypoint.createTxExecutionRequest(exec, gasSettings);
23
+ createTxExecutionRequest(
24
+ exec: ExecutionPayload,
25
+ gasSettings: GasSettings,
26
+ chainInfo: ChainInfo,
27
+ ): Promise<TxExecutionRequest> {
28
+ return this.entrypoint.createTxExecutionRequest(exec, gasSettings, chainInfo);
25
29
  }
26
30
 
27
- getChainId(): Fr {
28
- throw new Error('SignerlessAccount: Method getChainId not implemented.');
31
+ wrapExecutionPayload(exec: ExecutionPayload, options?: any): Promise<ExecutionPayload> {
32
+ return this.entrypoint.wrapExecutionPayload(exec, options);
29
33
  }
30
34
 
31
- getVersion(): Fr {
32
- throw new Error('SignerlessAccount: Method getVersion not implemented.');
35
+ createAuthWit(_intent: Fr | Buffer | IntentInnerHash | CallIntent): Promise<AuthWitness> {
36
+ throw new Error('SignerlessAccount: Method createAuthWit not implemented.');
33
37
  }
34
38
 
35
39
  getCompleteAddress(): CompleteAddress {
@@ -39,8 +43,4 @@ export class SignerlessAccount implements Account {
39
43
  getAddress(): AztecAddress {
40
44
  throw new Error('SignerlessAccount: Method getAddress not implemented.');
41
45
  }
42
-
43
- createAuthWit(_intent: Fr | Buffer | IntentInnerHash | CallIntent): Promise<AuthWitness> {
44
- throw new Error('SignerlessAccount: Method createAuthWit not implemented.');
45
- }
46
46
  }
@@ -1,6 +1,13 @@
1
- export { type AccountContract, type AccountInterface, type Salt, getAccountContractAddress } from '../account/index.js';
1
+ export {
2
+ type Account,
3
+ type AccountContract,
4
+ AccountWithSecretKey,
5
+ BaseAccount,
6
+ type AuthorizationProvider,
7
+ getAccountContractAddress,
8
+ type Salt,
9
+ } from '../account/index.js';
2
10
  export type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
11
+ export { ChainInfoSchema } from '@aztec/entrypoints/interfaces';
3
12
 
4
- export { AccountWithSecretKey } from '../account/account_with_secret_key.js';
5
- export { type Account, BaseAccount } from '../account/account.js';
6
13
  export { SignerlessAccount } from '../account/signerless_account.js';
@@ -2,6 +2,7 @@ export { AuthWitness } from '@aztec/stdlib/auth-witness';
2
2
  export {
3
3
  SetPublicAuthwitContractInteraction,
4
4
  type ContractFunctionInteractionCallIntent,
5
+ isContractFunctionInteractionCallIntent,
5
6
  getMessageHashFromIntent,
6
7
  computeAuthWitMessageHash,
7
8
  computeInnerAuthWitHashFromAction,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `contract` module provides utilities for deploying and interacting with contracts, based on a
3
3
  * `Wallet` instance and a compiled artifact. Refer to the {@link account} module for how to obtain a valid
4
- * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/how_to_compile_contract | Compiling contracts}
4
+ * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts | Compiling contracts}
5
5
  * section of the documentation for how to generate an artifact out of your Noir source code.
6
6
  *
7
7
  * The {@link Contract} class is the main class in this module, and provides static methods for deploying
@@ -10,13 +10,21 @@
10
10
  * or can be queried via `simulate()`.
11
11
  *
12
12
  * ```ts
13
- * const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send().deployed();
13
+ * // Deploy and get the contract instance directly (default behavior)
14
+ * const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send({ from: accountAddress });
14
15
  * console.log(`Contract deployed at ${contract.address}`);
16
+ *
17
+ * // Or get the full receipt with contract and instance
18
+ * const receipt = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send({
19
+ * from: accountAddress,
20
+ * wait: { returnReceipt: true }
21
+ * });
22
+ * console.log(`Contract deployed at ${receipt.contract.address}`);
15
23
  * ```
16
24
  *
17
25
  * ```ts
18
- * const contract = await Contract.at(address, MyContractArtifact, wallet);
19
- * await contract.methods.mint(1000, owner).send().wait();
26
+ * const contract = Contract.at(address, MyContractArtifact, wallet);
27
+ * await contract.methods.mint(1000, owner).send({ from: accountAddress });
20
28
  * console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
21
29
  * ```
22
30
  *
@@ -25,12 +33,11 @@
25
33
  * a transaction to the network via the `send` method, but you can also `simulate` it without sending,
26
34
  * or obtaining the `request` for aggregating into a {@link BatchCall}.
27
35
  *
28
- * The result of `send`ing a transaction is a {@link SentTx} object, from which you can get the
29
- * transaction hash, or simply `wait` until the transaction is mined and the local PXE
30
- * has synchronized its changes.
36
+ * The `send` method returns a {@link TxReceipt} by default (waits for the transaction to be mined).
37
+ * If you pass `wait: NO_WAIT` in the options, it will return a {@link TxHash} immediately without waiting.
31
38
  *
32
39
  * @remarks If you are using typescript, consider using the
33
- * {@link https://docs.aztec.network/developers/aztec-nr/how_to_compile_contract#use-generated-interfaces | autogenerated type-safe interfaces}
40
+ * {@link https://docs.aztec.network/developers/aztec-nr/compiling_contracts#use-generated-interfaces | autogenerated type-safe interfaces}
34
41
  * for interacting with your contracts.
35
42
  *
36
43
  * @packageDocumentation
@@ -39,26 +46,35 @@ export { Contract } from '../contract/contract.js';
39
46
  export { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
40
47
 
41
48
  export {
49
+ NO_WAIT,
50
+ type NoWait,
42
51
  type RequestInteractionOptions,
43
52
  type SendInteractionOptions,
44
53
  type ProfileInteractionOptions,
45
54
  type SimulateInteractionOptions,
46
55
  type InteractionFeeOptions,
56
+ type InteractionWaitOptions,
57
+ type GasSettingsOption,
58
+ type SendReturn,
59
+ type SimulationReturn,
47
60
  toProfileOptions,
48
61
  toSendOptions,
49
62
  toSimulateOptions,
50
63
  } from '../contract/interaction_options.js';
51
64
 
52
- export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
65
+ export { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
53
66
  export { ContractBase, type ContractMethod, type ContractStorageLayout } from '../contract/contract_base.js';
54
67
  export { BatchCall } from '../contract/batch_call.js';
55
68
  export {
56
69
  type DeployOptions,
70
+ type DeployReturn,
71
+ type DeployTxReceipt,
72
+ type DeployWaitOptions,
73
+ type DeployInteractionWaitOptions,
57
74
  DeployMethod,
58
75
  type RequestDeployOptions,
59
76
  type SimulateDeployOptions,
60
77
  } from '../contract/deploy_method.js';
61
- export { DeploySentTx } from '../contract/deploy_sent_tx.js';
62
78
  export { waitForProven, type WaitForProvenOpts, DefaultWaitForProvenOpts } from '../contract/wait_for_proven.js';
63
79
  export { getGasLimits } from '../contract/get_gas_limits.js';
64
80
 
@@ -1,4 +1,3 @@
1
1
  export { publishContractClass } from '../deployment/publish_class.js';
2
- export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
3
2
  export { publishInstance } from '../deployment/publish_instance.js';
4
3
  export { ContractDeployer } from '../deployment/contract_deployer.js';
package/src/api/events.ts CHANGED
@@ -1,44 +1,52 @@
1
1
  import { type EventMetadataDefinition, EventSelector, decodeFromAbi } from '@aztec/stdlib/abi';
2
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
3
 
4
+ import type { PublicEvent, PublicEventFilter } from '../wallet/wallet.js';
5
+
4
6
  /**
5
7
  * Returns decoded public events given search parameters.
6
8
  * @param node - The node to request events from
7
- * @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
8
- * @param from - The block number to search from.
9
- * @param limit - The amount of blocks to search.
10
- * @returns - The deserialized events.
9
+ * @param eventMetadataDef - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
10
+ * @param filter - Filter options for the event query:
11
+ * - `contractAddress`: The address of the contract that emitted the events.
12
+ * - `txHash`: Transaction in which the events were emitted.
13
+ * - `fromBlock`: The block number from which to start fetching events (inclusive). Defaults to 1.
14
+ * - `toBlock`: The block number until which to fetch events (not inclusive). Defaults to latest + 1.
15
+ * @returns - The decoded events with metadata.
11
16
  */
12
- export async function getDecodedPublicEvents<T>(
17
+ export async function getPublicEvents<T>(
13
18
  node: AztecNode,
14
19
  eventMetadataDef: EventMetadataDefinition,
15
- from: number,
16
- limit: number,
17
- ): Promise<T[]> {
20
+ filter: PublicEventFilter,
21
+ ): Promise<PublicEvent<T>[]> {
18
22
  const { logs } = await node.getPublicLogs({
19
- fromBlock: from,
20
- toBlock: from + limit,
23
+ fromBlock: filter.fromBlock ? Number(filter.fromBlock) : undefined,
24
+ toBlock: filter.toBlock ? Number(filter.toBlock) : undefined,
25
+ txHash: filter.txHash,
26
+ contractAddress: filter.contractAddress,
21
27
  });
22
28
 
23
- const decodedEvents = logs
24
- .map(log => {
25
- // +1 for the event selector
26
- const expectedLength = eventMetadataDef.fieldNames.length + 1;
27
- if (log.log.fields.length !== expectedLength) {
28
- throw new Error(
29
- `Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length. Expected ${expectedLength}. Got ${log.log.fields.length}.`,
30
- );
31
- }
29
+ const decodedEvents: PublicEvent<T>[] = [];
30
+
31
+ for (const log of logs) {
32
+ const logFields = log.log.getEmittedFields();
33
+ // Event selector is at the last position of the emitted fields
34
+ const logEventSelector = EventSelector.fromField(logFields[logFields.length - 1]);
32
35
 
33
- const logFields = log.log.getEmittedFields();
34
- // We are assuming here that event logs are the last 4 bytes of the event. This is not enshrined but is a function of aztec.nr raw log emission.
35
- if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
36
- return undefined;
37
- }
36
+ if (!logEventSelector.equals(eventMetadataDef.eventSelector)) {
37
+ continue;
38
+ }
38
39
 
39
- return decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T;
40
- })
41
- .filter(log => log !== undefined) as T[];
40
+ decodedEvents.push({
41
+ event: decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T,
42
+ metadata: {
43
+ l2BlockNumber: log.id.blockNumber,
44
+ l2BlockHash: log.id.blockHash,
45
+ txHash: log.id.txHash,
46
+ contractAddress: log.log.contractAddress,
47
+ },
48
+ });
49
+ }
42
50
 
43
51
  return decodedEvents;
44
52
  }
package/src/api/fields.ts CHANGED
@@ -1 +1,3 @@
1
- export { Point, Fr, Fq, GrumpkinScalar } from '@aztec/foundation/fields';
1
+ export { Fr, Fq } from '@aztec/foundation/curves/bn254';
2
+ export { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
3
+ export { BlockNumber } from '@aztec/foundation/branded-types';
package/src/api/keys.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { type PublicKey, PublicKeys } from '@aztec/stdlib/keys';
2
2
  export {
3
- computeAppNullifierSecretKey,
3
+ computeAppNullifierHidingKey,
4
4
  deriveKeys,
5
5
  deriveMasterIncomingViewingSecretKey,
6
- deriveMasterNullifierSecretKey,
6
+ deriveMasterNullifierHidingKey,
7
7
  } from '@aztec/stdlib/keys';
8
8
  export { generatePublicKey } from '../utils/pub_key.js';
package/src/api/node.ts CHANGED
@@ -3,18 +3,22 @@
3
3
  *
4
4
  * The primary function is {@link createAztecNodeClient}, which creates a JSON-RPC client
5
5
  * that connects to a running Aztec node instance. Use {@link waitForNode} to wait for
6
- * the node to be ready before proceeding.
6
+ * the node to be ready before proceeding, and {@link waitForTx} to wait for a transaction
7
+ * to be mined.
7
8
  *
8
9
  * @example
9
10
  * ```ts
10
- * import { createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
11
+ * import { createAztecNodeClient, waitForNode, waitForTx } from '@aztec/aztec.js/node';
11
12
  *
12
13
  * const node = createAztecNodeClient('http://localhost:8080');
13
14
  * await waitForNode(node);
14
15
  * const blockNumber = await node.getBlockNumber();
16
+ *
17
+ * // Wait for a transaction
18
+ * const receipt = await waitForTx(node, txHash);
15
19
  * ```
16
20
  *
17
21
  * @packageDocumentation
18
22
  */
19
- export { createAztecNodeClient, waitForNode, type AztecNode } from '../utils/node.js';
23
+ export { createAztecNodeClient, waitForNode, waitForTx, type AztecNode } from '../utils/node.js';
20
24
  export { type NodeInfo } from '@aztec/stdlib/contract';
package/src/api/note.ts CHANGED
@@ -1 +1 @@
1
- export { UniqueNote, Comparator, Note } from '@aztec/stdlib/note';
1
+ export { Comparator, Note } from '@aztec/stdlib/note';
@@ -1,2 +1,9 @@
1
1
  export { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
2
  export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
3
+
4
+ export { AuthRegistryContract } from '../contract/protocol_contracts/auth-registry.js';
5
+ export { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js';
6
+ export { ContractInstanceRegistryContract } from '../contract/protocol_contracts/contract-instance-registry.js';
7
+ export { FeeJuiceContract } from '../contract/protocol_contracts/fee-juice.js';
8
+ export { MultiCallEntrypointContract } from '../contract/protocol_contracts/multi-call-entrypoint.js';
9
+ export { PublicChecksContract } from '../contract/protocol_contracts/public-checks.js';
package/src/api/tx.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  export {
2
2
  Tx,
3
3
  TxExecutionRequest,
4
+ TxExecutionResult,
4
5
  TxHash,
5
6
  TxReceipt,
6
7
  TxStatus,
8
+ SortedTxStatuses,
7
9
  Capsule,
8
10
  HashedValues,
9
11
  GlobalVariables,
10
12
  TxProfileResult,
13
+ ExecutionPayload,
14
+ mergeExecutionPayloads,
11
15
  } from '@aztec/stdlib/tx';