@aztec/aztec.js 3.0.0-canary.a9708bd → 3.0.0-devnet.2

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 (278) hide show
  1. package/dest/account/account.d.ts +60 -0
  2. package/dest/account/account.d.ts.map +1 -0
  3. package/dest/account/account.js +59 -0
  4. package/dest/account/account_contract.d.ts +5 -5
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_contract.js +0 -1
  7. package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
  8. package/dest/account/account_with_secret_key.d.ts.map +1 -0
  9. package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
  10. package/dest/account/index.d.ts +1 -4
  11. package/dest/account/index.d.ts.map +1 -1
  12. package/dest/account/index.js +1 -4
  13. package/dest/account/signerless_account.d.ts +24 -0
  14. package/dest/account/signerless_account.d.ts.map +1 -0
  15. package/dest/account/signerless_account.js +27 -0
  16. package/dest/api/abi.d.ts +1 -0
  17. package/dest/api/abi.d.ts.map +1 -1
  18. package/dest/api/account.d.ts +4 -2
  19. package/dest/api/account.d.ts.map +1 -1
  20. package/dest/api/account.js +3 -1
  21. package/dest/api/addresses.d.ts +1 -0
  22. package/dest/api/addresses.d.ts.map +1 -1
  23. package/dest/api/addresses.js +1 -0
  24. package/dest/api/authorization.d.ts +2 -0
  25. package/dest/api/authorization.d.ts.map +1 -1
  26. package/dest/api/authorization.js +2 -0
  27. package/dest/api/block.d.ts +3 -0
  28. package/dest/api/block.d.ts.map +1 -0
  29. package/dest/api/block.js +2 -0
  30. package/dest/api/contract.d.ts +4 -5
  31. package/dest/api/contract.d.ts.map +1 -1
  32. package/dest/api/contract.js +3 -3
  33. package/dest/api/crypto.d.ts +2 -0
  34. package/dest/api/crypto.d.ts.map +1 -0
  35. package/dest/api/crypto.js +1 -0
  36. package/dest/api/ethereum.d.ts +0 -1
  37. package/dest/api/ethereum.d.ts.map +1 -1
  38. package/dest/api/ethereum.js +0 -1
  39. package/dest/api/events.d.ts +12 -0
  40. package/dest/api/events.d.ts.map +1 -0
  41. package/dest/api/events.js +30 -0
  42. package/dest/api/fee.d.ts +1 -2
  43. package/dest/api/fee.d.ts.map +1 -1
  44. package/dest/api/fee.js +0 -1
  45. package/dest/api/keys.d.ts +4 -0
  46. package/dest/api/keys.d.ts.map +1 -0
  47. package/dest/api/keys.js +3 -0
  48. package/dest/api/log.d.ts +1 -0
  49. package/dest/api/log.d.ts.map +1 -1
  50. package/dest/api/log.js +1 -0
  51. package/dest/api/messaging.d.ts +3 -0
  52. package/dest/api/messaging.d.ts.map +1 -0
  53. package/dest/api/messaging.js +2 -0
  54. package/dest/api/node.d.ts +21 -0
  55. package/dest/api/node.d.ts.map +1 -0
  56. package/dest/api/node.js +18 -0
  57. package/dest/api/note.d.ts +2 -0
  58. package/dest/api/note.d.ts.map +1 -0
  59. package/dest/api/note.js +1 -0
  60. package/dest/api/protocol.d.ts +3 -0
  61. package/dest/api/protocol.d.ts.map +1 -0
  62. package/dest/api/protocol.js +2 -0
  63. package/dest/api/trees.d.ts +3 -0
  64. package/dest/api/trees.d.ts.map +1 -0
  65. package/dest/api/trees.js +2 -0
  66. package/dest/api/tx.d.ts +2 -0
  67. package/dest/api/tx.d.ts.map +1 -0
  68. package/dest/api/tx.js +1 -0
  69. package/dest/api/utils.d.ts +10 -6
  70. package/dest/api/utils.d.ts.map +1 -1
  71. package/dest/api/utils.js +10 -5
  72. package/dest/api/wallet.d.ts +4 -1
  73. package/dest/api/wallet.d.ts.map +1 -1
  74. package/dest/api/wallet.js +4 -1
  75. package/dest/contract/base_contract_interaction.d.ts +6 -48
  76. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  77. package/dest/contract/base_contract_interaction.js +6 -106
  78. package/dest/contract/batch_call.d.ts +6 -14
  79. package/dest/contract/batch_call.d.ts.map +1 -1
  80. package/dest/contract/batch_call.js +42 -52
  81. package/dest/contract/contract.d.ts +1 -1
  82. package/dest/contract/contract.d.ts.map +1 -1
  83. package/dest/contract/contract.js +2 -12
  84. package/dest/contract/contract_base.d.ts +1 -1
  85. package/dest/contract/contract_base.d.ts.map +1 -1
  86. package/dest/contract/contract_function_interaction.d.ts +29 -40
  87. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  88. package/dest/contract/contract_function_interaction.js +41 -53
  89. package/dest/contract/deploy_method.d.ts +63 -56
  90. package/dest/contract/deploy_method.d.ts.map +1 -1
  91. package/dest/contract/deploy_method.js +68 -86
  92. package/dest/contract/deploy_sent_tx.d.ts +0 -1
  93. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  94. package/dest/contract/deploy_sent_tx.js +7 -10
  95. package/dest/contract/interaction_options.d.ts +74 -19
  96. package/dest/contract/interaction_options.d.ts.map +1 -1
  97. package/dest/contract/interaction_options.js +51 -3
  98. package/dest/contract/sent_tx.d.ts +3 -3
  99. package/dest/contract/sent_tx.d.ts.map +1 -1
  100. package/dest/contract/sent_tx.js +5 -5
  101. package/dest/contract/wait_for_proven.d.ts +3 -3
  102. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  103. package/dest/contract/wait_for_proven.js +2 -2
  104. package/dest/deployment/publish_instance.d.ts +1 -1
  105. package/dest/deployment/publish_instance.d.ts.map +1 -1
  106. package/dest/deployment/publish_instance.js +2 -5
  107. package/dest/ethereum/portal_manager.d.ts +3 -4
  108. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  109. package/dest/ethereum/portal_manager.js +3 -5
  110. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +12 -7
  111. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  112. package/dest/fee/fee_juice_payment_method_with_claim.js +21 -12
  113. package/dest/fee/fee_payment_method.d.ts +26 -0
  114. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  115. package/dest/fee/fee_payment_method.js +3 -0
  116. package/dest/fee/private_fee_payment_method.d.ts +22 -5
  117. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  118. package/dest/fee/private_fee_payment_method.js +34 -13
  119. package/dest/fee/public_fee_payment_method.d.ts +22 -5
  120. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  121. package/dest/fee/public_fee_payment_method.js +37 -14
  122. package/dest/fee/sponsored_fee_payment.d.ts +2 -0
  123. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  124. package/dest/fee/sponsored_fee_payment.js +4 -0
  125. package/dest/utils/authwit.d.ts +77 -25
  126. package/dest/utils/authwit.d.ts.map +1 -1
  127. package/dest/utils/authwit.js +219 -24
  128. package/dest/utils/cross_chain.d.ts +24 -0
  129. package/dest/utils/cross_chain.d.ts.map +1 -0
  130. package/dest/utils/cross_chain.js +30 -0
  131. package/dest/utils/fee_juice.d.ts +3 -2
  132. package/dest/utils/fee_juice.d.ts.map +1 -1
  133. package/dest/utils/fee_juice.js +3 -2
  134. package/dest/{fee → wallet}/account_entrypoint_meta_payment_method.d.ts +13 -10
  135. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  136. package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
  137. package/dest/wallet/account_manager.d.ts +69 -0
  138. package/dest/wallet/account_manager.d.ts.map +1 -0
  139. package/dest/wallet/account_manager.js +113 -0
  140. package/dest/wallet/base_wallet.d.ts +78 -35
  141. package/dest/wallet/base_wallet.d.ts.map +1 -1
  142. package/dest/wallet/base_wallet.js +216 -48
  143. package/dest/wallet/deploy_account_method.d.ts +52 -0
  144. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  145. package/dest/wallet/deploy_account_method.js +77 -0
  146. package/dest/wallet/index.d.ts +2 -15
  147. package/dest/wallet/index.d.ts.map +1 -1
  148. package/dest/wallet/index.js +2 -19
  149. package/dest/wallet/wallet.d.ts +2473 -6
  150. package/dest/wallet/wallet.d.ts.map +1 -1
  151. package/dest/wallet/wallet.js +202 -3
  152. package/package.json +25 -21
  153. package/src/account/account.ts +97 -0
  154. package/src/account/account_contract.ts +4 -6
  155. package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
  156. package/src/account/index.ts +1 -4
  157. package/src/account/signerless_account.ts +46 -0
  158. package/src/api/abi.ts +11 -0
  159. package/src/api/account.ts +4 -2
  160. package/src/api/addresses.ts +1 -0
  161. package/src/api/authorization.ts +11 -0
  162. package/src/api/block.ts +2 -0
  163. package/src/api/contract.ts +16 -8
  164. package/src/api/crypto.ts +1 -0
  165. package/src/api/ethereum.ts +0 -1
  166. package/src/api/events.ts +44 -0
  167. package/src/api/fee.ts +1 -2
  168. package/src/api/keys.ts +8 -0
  169. package/src/api/log.ts +1 -0
  170. package/src/api/messaging.ts +2 -0
  171. package/src/api/node.ts +20 -0
  172. package/src/api/note.ts +1 -0
  173. package/src/api/protocol.ts +2 -0
  174. package/src/api/trees.ts +2 -0
  175. package/src/api/tx.ts +11 -0
  176. package/src/api/utils.ts +12 -19
  177. package/src/api/wallet.ts +33 -5
  178. package/src/contract/base_contract_interaction.ts +9 -138
  179. package/src/contract/batch_call.ts +52 -61
  180. package/src/contract/contract.ts +2 -12
  181. package/src/contract/contract_function_interaction.ts +65 -97
  182. package/src/contract/deploy_method.ts +117 -99
  183. package/src/contract/deploy_sent_tx.ts +4 -10
  184. package/src/contract/interaction_options.ts +126 -24
  185. package/src/contract/sent_tx.ts +4 -4
  186. package/src/contract/wait_for_proven.ts +4 -4
  187. package/src/deployment/publish_instance.ts +3 -8
  188. package/src/ethereum/portal_manager.ts +4 -12
  189. package/src/fee/fee_juice_payment_method_with_claim.ts +26 -17
  190. package/src/fee/fee_payment_method.ts +26 -0
  191. package/src/fee/private_fee_payment_method.ts +60 -41
  192. package/src/fee/public_fee_payment_method.ts +73 -49
  193. package/src/fee/sponsored_fee_payment.ts +6 -0
  194. package/src/utils/authwit.ts +250 -38
  195. package/src/utils/cross_chain.ts +53 -0
  196. package/src/utils/fee_juice.ts +4 -3
  197. package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
  198. package/src/wallet/account_manager.ts +154 -0
  199. package/src/wallet/base_wallet.ts +287 -78
  200. package/src/wallet/deploy_account_method.ts +125 -0
  201. package/src/wallet/index.ts +2 -32
  202. package/src/wallet/wallet.ts +357 -29
  203. package/dest/account_manager/account_manager.d.ts +0 -119
  204. package/dest/account_manager/account_manager.d.ts.map +0 -1
  205. package/dest/account_manager/account_manager.js +0 -202
  206. package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
  207. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
  208. package/dest/account_manager/deploy_account_sent_tx.js +0 -29
  209. package/dest/account_manager/index.d.ts +0 -3
  210. package/dest/account_manager/index.d.ts.map +0 -1
  211. package/dest/account_manager/index.js +0 -2
  212. package/dest/api/interfaces.d.ts +0 -2
  213. package/dest/api/interfaces.d.ts.map +0 -1
  214. package/dest/api/interfaces.js +0 -1
  215. package/dest/api/log_id.d.ts +0 -2
  216. package/dest/api/log_id.d.ts.map +0 -1
  217. package/dest/api/log_id.js +0 -1
  218. package/dest/api/rpc.d.ts +0 -3
  219. package/dest/api/rpc.d.ts.map +0 -1
  220. package/dest/api/rpc.js +0 -2
  221. package/dest/api/tx_hash.d.ts +0 -2
  222. package/dest/api/tx_hash.d.ts.map +0 -1
  223. package/dest/api/tx_hash.js +0 -1
  224. package/dest/contract/deploy_proven_tx.d.ts +0 -21
  225. package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
  226. package/dest/contract/deploy_proven_tx.js +0 -21
  227. package/dest/contract/proven_tx.d.ts +0 -21
  228. package/dest/contract/proven_tx.d.ts.map +0 -1
  229. package/dest/contract/proven_tx.js +0 -23
  230. package/dest/ethereum/l1_contracts.d.ts +0 -3
  231. package/dest/ethereum/l1_contracts.d.ts.map +0 -1
  232. package/dest/ethereum/l1_contracts.js +0 -13
  233. package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +0 -1
  234. package/dest/fee/account_entrypoint_meta_payment_method.js +0 -64
  235. package/dest/fee/fee_juice_payment_method.d.ts +0 -14
  236. package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
  237. package/dest/fee/fee_juice_payment_method.js +0 -21
  238. package/dest/fee/utils.d.ts +0 -13
  239. package/dest/fee/utils.d.ts.map +0 -1
  240. package/dest/fee/utils.js +0 -32
  241. package/dest/index.d.ts +0 -59
  242. package/dest/index.d.ts.map +0 -1
  243. package/dest/index.js +0 -62
  244. package/dest/rpc_clients/node/index.d.ts +0 -12
  245. package/dest/rpc_clients/node/index.d.ts.map +0 -1
  246. package/dest/rpc_clients/node/index.js +0 -72
  247. package/dest/rpc_clients/pxe_client.d.ts +0 -10
  248. package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
  249. package/dest/rpc_clients/pxe_client.js +0 -23
  250. package/dest/utils/pxe.d.ts +0 -4
  251. package/dest/utils/pxe.d.ts.map +0 -1
  252. package/dest/utils/pxe.js +0 -14
  253. package/dest/wallet/account_wallet.d.ts +0 -74
  254. package/dest/wallet/account_wallet.d.ts.map +0 -1
  255. package/dest/wallet/account_wallet.js +0 -232
  256. package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
  257. package/dest/wallet/signerless_wallet.d.ts +0 -23
  258. package/dest/wallet/signerless_wallet.d.ts.map +0 -1
  259. package/dest/wallet/signerless_wallet.js +0 -33
  260. package/src/account_manager/account_manager.ts +0 -276
  261. package/src/account_manager/deploy_account_sent_tx.ts +0 -46
  262. package/src/account_manager/index.ts +0 -2
  263. package/src/api/interfaces.ts +0 -1
  264. package/src/api/log_id.ts +0 -1
  265. package/src/api/rpc.ts +0 -2
  266. package/src/api/tx_hash.ts +0 -1
  267. package/src/contract/deploy_proven_tx.ts +0 -45
  268. package/src/contract/proven_tx.ts +0 -36
  269. package/src/ethereum/l1_contracts.ts +0 -21
  270. package/src/fee/account_entrypoint_meta_payment_method.ts +0 -89
  271. package/src/fee/fee_juice_payment_method.ts +0 -25
  272. package/src/fee/utils.ts +0 -39
  273. package/src/index.ts +0 -85
  274. package/src/rpc_clients/node/index.ts +0 -77
  275. package/src/rpc_clients/pxe_client.ts +0 -25
  276. package/src/utils/pxe.ts +0 -17
  277. package/src/wallet/account_wallet.ts +0 -246
  278. package/src/wallet/signerless_wallet.ts +0 -56
@@ -1,33 +0,0 @@
1
- import { DefaultEntrypoint } from '@aztec/entrypoints/default';
2
- import { BaseWallet } from './base_wallet.js';
3
- /**
4
- * Wallet implementation which creates a transaction request directly to the requested contract without any signing.
5
- */ export class SignerlessWallet extends BaseWallet {
6
- entrypoint;
7
- constructor(pxe, entrypoint){
8
- super(pxe), this.entrypoint = entrypoint;
9
- }
10
- async createTxExecutionRequest(execution, fee, options) {
11
- let entrypoint = this.entrypoint;
12
- if (!entrypoint) {
13
- const { l1ChainId: chainId, rollupVersion } = await this.pxe.getNodeInfo();
14
- entrypoint = new DefaultEntrypoint(chainId, rollupVersion);
15
- }
16
- return entrypoint.createTxExecutionRequest(execution, fee, options);
17
- }
18
- getChainId() {
19
- throw new Error('SignerlessWallet: Method getChainId not implemented.');
20
- }
21
- getVersion() {
22
- throw new Error('SignerlessWallet: Method getVersion not implemented.');
23
- }
24
- getPublicKeysHash() {
25
- throw new Error('SignerlessWallet: Method getPublicKeysHash not implemented.');
26
- }
27
- getCompleteAddress() {
28
- throw new Error('SignerlessWallet: Method getCompleteAddress not implemented.');
29
- }
30
- createAuthWit(_intent) {
31
- throw new Error('SignerlessWallet: Method createAuthWit not implemented.');
32
- }
33
- }
@@ -1,276 +0,0 @@
1
- import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { CompleteAddress, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
- import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
5
- import type { PXE } from '@aztec/stdlib/interfaces/client';
6
- import { deriveKeys } from '@aztec/stdlib/keys';
7
-
8
- import type { AccountContract } from '../account/account_contract.js';
9
- import type { Salt } from '../account/index.js';
10
- import type { AccountInterface } from '../account/interface.js';
11
- import { Contract } from '../contract/contract.js';
12
- import { DeployMethod, type DeployOptions } from '../contract/deploy_method.js';
13
- import { DefaultWaitOpts, type WaitOpts } from '../contract/sent_tx.js';
14
- import { AccountEntrypointMetaPaymentMethod } from '../fee/account_entrypoint_meta_payment_method.js';
15
- import { AztecAddress, FeeJuicePaymentMethod, type FeePaymentMethod } from '../index.js';
16
- import { AccountWalletWithSecretKey, SignerlessWallet, type Wallet } from '../wallet/index.js';
17
- import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
18
-
19
- /**
20
- * Options to deploy an account contract.
21
- */
22
- export type DeployAccountOptions = Pick<
23
- DeployOptions,
24
- 'fee' | 'skipClassPublication' | 'skipInstancePublication' | 'skipInitialization'
25
- > & {
26
- /**
27
- * Wallet used for any txs to initialize and/or publish the account contract. Must be funded in order to pay for the fee.
28
- */
29
- deployWallet?: Wallet;
30
- };
31
-
32
- /**
33
- * Manages a user account. Provides methods for calculating the account's address, deploying the account contract,
34
- * and creating and registering the user wallet in the PXE Service.
35
- */
36
- export class AccountManager {
37
- private constructor(
38
- private pxe: PXE,
39
- private secretKey: Fr,
40
- private accountContract: AccountContract,
41
- private instance: ContractInstanceWithAddress,
42
- /**
43
- * Contract instantiation salt for the account contract
44
- */
45
- public readonly salt: Salt,
46
- ) {}
47
-
48
- static async create(pxe: PXE, secretKey: Fr, accountContract: AccountContract, salt?: Salt) {
49
- const { publicKeys } = await deriveKeys(secretKey);
50
- salt = salt !== undefined ? new Fr(salt) : Fr.random();
51
-
52
- const { constructorName, constructorArgs } = (await accountContract.getInitializationFunctionAndArgs()) ?? {
53
- constructorName: undefined,
54
- constructorArgs: undefined,
55
- };
56
-
57
- const artifact = await accountContract.getContractArtifact();
58
- const instance = await getContractInstanceFromInstantiationParams(artifact, {
59
- constructorArtifact: constructorName,
60
- constructorArgs,
61
- salt: salt,
62
- publicKeys,
63
- });
64
-
65
- return new AccountManager(pxe, secretKey, accountContract, instance, salt);
66
- }
67
-
68
- protected getPublicKeys() {
69
- return this.instance.publicKeys;
70
- }
71
-
72
- protected getPublicKeysHash() {
73
- return this.getPublicKeys().hash();
74
- }
75
-
76
- /**
77
- * Returns the entrypoint for this account as defined by its account contract.
78
- * @returns An entrypoint.
79
- */
80
- public async getAccount(): Promise<AccountInterface> {
81
- const nodeInfo = await this.pxe.getNodeInfo();
82
- const completeAddress = await this.getCompleteAddress();
83
- return this.accountContract.getInterface(completeAddress, nodeInfo);
84
- }
85
-
86
- /**
87
- * Gets the calculated complete address associated with this account.
88
- * Does not require the account to have been published for public execution.
89
- * @returns The address, partial address, and encryption public key.
90
- */
91
- public getCompleteAddress(): Promise<CompleteAddress> {
92
- return CompleteAddress.fromSecretKeyAndInstance(this.secretKey, this.instance);
93
- }
94
-
95
- /**
96
- * Gets the address for this given account.
97
- * Does not require the account to have been published for public execution.
98
- * @returns The address.
99
- */
100
- public getAddress() {
101
- return this.instance.address;
102
- }
103
-
104
- /**
105
- * Returns the contract instance definition associated with this account.
106
- * Does not require the account to have been published for public execution.
107
- * @returns ContractInstance instance.
108
- */
109
- public getInstance(): ContractInstanceWithAddress {
110
- return this.instance;
111
- }
112
-
113
- /**
114
- * Returns a Wallet instance associated with this account. Use it to create Contract
115
- * instances to be interacted with from this account.
116
- * @returns A Wallet instance.
117
- */
118
- public async getWallet(): Promise<AccountWalletWithSecretKey> {
119
- const entrypoint = await this.getAccount();
120
- return new AccountWalletWithSecretKey(this.pxe, entrypoint, this.secretKey, this.salt);
121
- }
122
-
123
- /**
124
- * Add this account in the PXE Service and returns the associated wallet. Adding
125
- * the account to the PXE Service is required for managing private state associated with it.
126
- * Use the returned wallet to create Contract instances to be interacted with from this account.
127
- * @param opts - Options to wait for the account to be synched.
128
- * @returns A Wallet instance.
129
- */
130
- public async register(): Promise<AccountWalletWithSecretKey> {
131
- await this.pxe.registerContract({
132
- artifact: await this.accountContract.getContractArtifact(),
133
- instance: this.getInstance(),
134
- });
135
-
136
- await this.pxe.registerAccount(this.secretKey, (await this.getCompleteAddress()).partialAddress);
137
-
138
- return this.getWallet();
139
- }
140
-
141
- /**
142
- * Returns the pre-populated ContractSetupMethods which can prepare a tx to
143
- * initialize and/or publish this account's account contract (depending on the contract's design).
144
- * If no wallet is provided, it uses a signerless wallet with the multi call entrypoint
145
- * @param deployWallet - Wallet used for any txs that are needed to
146
- * set up the account contract for use.
147
- * @returns A ContractSetupMethods instance that can set up this account contract for use
148
- */
149
- public async getDeployMethod(deployWallet?: Wallet): Promise<DeployMethod> {
150
- const artifact = await this.accountContract.getContractArtifact();
151
-
152
- if (!(await this.hasInitializer())) {
153
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/15576):
154
- // there should be a path which enables an account contract's class & instance to be published,
155
- // even if the account contract doesn't have an initializer function. This should not throw.
156
- throw new Error(`Account contract ${artifact.name} does not have an initializer function to call.`);
157
- }
158
-
159
- const completeAddress = await this.getCompleteAddress();
160
-
161
- await this.pxe.registerAccount(this.secretKey, completeAddress.partialAddress);
162
-
163
- const { constructorName, constructorArgs } = (await this.accountContract.getInitializationFunctionAndArgs()) ?? {
164
- constructorName: undefined,
165
- constructorArgs: undefined,
166
- };
167
-
168
- if (deployWallet) {
169
- // If deploying using an existing wallet/account, treat it like regular contract deployment.
170
- const thisWallet = await this.getWallet();
171
- return new DeployMethod(
172
- this.getPublicKeys(),
173
- deployWallet,
174
- artifact,
175
- address => Contract.at(address, artifact, thisWallet),
176
- constructorArgs,
177
- constructorName,
178
- );
179
- }
180
-
181
- const { l1ChainId: chainId, rollupVersion } = await this.pxe.getNodeInfo();
182
- // We use a signerless wallet with the multi call entrypoint in order to make multiple calls in one go.
183
- // If we used getWallet, the deployment would get routed via the account contract entrypoint
184
- // and it can't be used unless the contract is initialized.
185
- const wallet = new SignerlessWallet(this.pxe, new DefaultMultiCallEntrypoint(chainId, rollupVersion));
186
-
187
- return new DeployMethod(
188
- this.getPublicKeys(),
189
- wallet,
190
- artifact,
191
- address => Contract.at(address, artifact, wallet),
192
- constructorArgs,
193
- constructorName,
194
- );
195
- }
196
-
197
- /**
198
- * Returns a FeePaymentMethod that routes the original one provided as an argument
199
- * through the account's entrypoint. This allows an account contract to pay
200
- * for its own deployment and initialization.
201
- *
202
- * For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
203
- *
204
- * @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
205
- * @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
206
- */
207
- public async getSelfPaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
208
- const artifact = await this.accountContract.getContractArtifact();
209
- const wallet = await this.getWallet();
210
- const address = wallet.getAddress();
211
- return new AccountEntrypointMetaPaymentMethod(
212
- artifact,
213
- wallet,
214
- 'entrypoint',
215
- address,
216
- originalPaymentMethod ?? new FeeJuicePaymentMethod(address),
217
- );
218
- }
219
-
220
- /**
221
- * Submits a tx to initialize and/or publish this account's account contract
222
- * (depending on the contract's design).
223
- * Doesn't necessarily publish the class nor publish the instance.
224
- * Uses the salt provided in the constructor or a randomly generated one.
225
- * Adds the account to the PXE Service first.
226
- * @param opts - Fee options to be used for the deployment.
227
- * @returns A SentTx object that can be waited to get the associated Wallet.
228
- */
229
- public deploy(opts?: DeployAccountOptions): DeployAccountSentTx {
230
- let deployMethod: DeployMethod;
231
- const sendTx = () =>
232
- this.getDeployMethod(opts?.deployWallet)
233
- .then(method => {
234
- deployMethod = method;
235
- if (!opts?.deployWallet && opts?.fee) {
236
- return this.getSelfPaymentMethod(opts?.fee?.paymentMethod);
237
- }
238
- })
239
- .then(maybeWrappedPaymentMethod => {
240
- let fee = opts?.fee;
241
- if (maybeWrappedPaymentMethod) {
242
- fee = { ...opts?.fee, paymentMethod: maybeWrappedPaymentMethod };
243
- }
244
- return deployMethod.send({
245
- from: opts?.deployWallet?.getAddress() ?? AztecAddress.ZERO,
246
- contractAddressSalt: new Fr(this.salt),
247
- skipClassPublication: opts?.skipClassPublication ?? true,
248
- skipInstancePublication: opts?.skipInstancePublication ?? true,
249
- skipInitialization: opts?.skipInitialization ?? false,
250
- universalDeploy: true,
251
- fee,
252
- });
253
- })
254
- .then(tx => tx.getTxHash());
255
- return new DeployAccountSentTx(this.pxe, sendTx, this.getWallet());
256
- }
257
-
258
- /**
259
- * Deploys the account contract that backs this account if needed and awaits the tx to be mined.
260
- * Uses the salt provided in the constructor or a randomly generated one. If no initialization
261
- * is required it skips the transaction, and only registers the account in the PXE Service.
262
- * @param opts - Options to wait for the tx to be mined.
263
- * @returns A Wallet instance.
264
- */
265
- public async waitSetup(opts: DeployAccountOptions & WaitOpts = DefaultWaitOpts): Promise<AccountWalletWithSecretKey> {
266
- await ((await this.hasInitializer()) ? this.deploy(opts).wait(opts) : this.register());
267
- return this.getWallet();
268
- }
269
-
270
- /**
271
- * Returns whether this account contract has an initializer function.
272
- */
273
- public async hasInitializer() {
274
- return (await this.accountContract.getInitializationFunctionAndArgs()) !== undefined;
275
- }
276
- }
@@ -1,46 +0,0 @@
1
- import type { FieldsOf } from '@aztec/foundation/types';
2
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
3
- import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
4
-
5
- import { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
6
- import type { Wallet } from '../wallet/wallet.js';
7
-
8
- /** Extends a transaction receipt with a wallet instance for the newly deployed contract. */
9
- export type DeployAccountTxReceipt = FieldsOf<TxReceipt> & {
10
- /** Wallet that corresponds to the newly deployed account contract. */
11
- wallet: Wallet;
12
- };
13
-
14
- /**
15
- * A deployment transaction for an account contract sent to the network, extending SentTx with methods to get the resulting wallet.
16
- */
17
- export class DeployAccountSentTx extends SentTx {
18
- constructor(
19
- pxeOrNode: AztecNode | PXE,
20
- sendTx: () => Promise<TxHash>,
21
- private getWalletPromise: Promise<Wallet>,
22
- ) {
23
- super(pxeOrNode, sendTx);
24
- }
25
-
26
- /**
27
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
28
- * @param opts - Options for configuring the waiting for the tx to be mined.
29
- * @returns The deployed contract instance.
30
- */
31
- public async getWallet(opts?: WaitOpts): Promise<Wallet> {
32
- const receipt = await this.wait(opts);
33
- return receipt.wallet;
34
- }
35
-
36
- /**
37
- * Awaits for the tx to be mined and returns the receipt along with a wallet instance. Throws if tx is not mined.
38
- * @param opts - Options for configuring the waiting for the tx to be mined.
39
- * @returns The transaction receipt with the wallet for the deployed account contract.
40
- */
41
- public override async wait(opts: WaitOpts = DefaultWaitOpts): Promise<DeployAccountTxReceipt> {
42
- const receipt = await super.wait(opts);
43
- const wallet = await this.getWalletPromise;
44
- return { ...receipt, wallet };
45
- }
46
- }
@@ -1,2 +0,0 @@
1
- export { AccountManager, type DeployAccountOptions } from './account_manager.js';
2
- export { type DeployAccountTxReceipt, DeployAccountSentTx } from './deploy_account_sent_tx.js';
@@ -1 +0,0 @@
1
- export type { PXE } from '@aztec/stdlib/interfaces/client';
package/src/api/log_id.ts DELETED
@@ -1 +0,0 @@
1
- export { LogId } from '@aztec/stdlib/logs';
package/src/api/rpc.ts DELETED
@@ -1,2 +0,0 @@
1
- export { createPXEClient } from '../rpc_clients/pxe_client.js';
2
- export { createCompatibleClient } from '../rpc_clients/node/index.js';
@@ -1 +0,0 @@
1
- export { TxHash } from '@aztec/stdlib/tx';
@@ -1,45 +0,0 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { OffchainEffect, ProvingStats, TxProvingResult } from '@aztec/stdlib/tx';
4
- import { Tx } from '@aztec/stdlib/tx';
5
-
6
- import type { Wallet } from '../wallet/wallet.js';
7
- import type { Contract } from './contract.js';
8
- import { DeploySentTx } from './deploy_sent_tx.js';
9
- import { ProvenTx } from './proven_tx.js';
10
-
11
- /**
12
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract deployment.
13
- */
14
- export class DeployProvenTx<TContract extends Contract = Contract> extends ProvenTx {
15
- private constructor(
16
- wallet: Wallet,
17
- tx: Tx,
18
- offchainEffects: OffchainEffect[],
19
- private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
20
- private instanceGetter: () => Promise<ContractInstanceWithAddress>,
21
- stats?: ProvingStats,
22
- ) {
23
- super(wallet, tx, offchainEffects, stats);
24
- }
25
-
26
- static async fromProvingResult<TContract extends Contract = Contract>(
27
- wallet: Wallet,
28
- txProvingResult: TxProvingResult,
29
- postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
30
- instanceGetter: () => Promise<ContractInstanceWithAddress>,
31
- stats?: ProvingStats,
32
- ): Promise<DeployProvenTx<TContract>> {
33
- const tx = await txProvingResult.toTx();
34
- return new DeployProvenTx(wallet, tx, txProvingResult.getOffchainEffects(), postDeployCtor, instanceGetter, stats);
35
- }
36
-
37
- /**
38
- * Sends the transaction to the network via the provided wallet.
39
- */
40
- public override send(): DeploySentTx<TContract> {
41
- const sendTx = () => this.wallet.sendTx(this);
42
-
43
- return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, this.instanceGetter);
44
- }
45
- }
@@ -1,36 +0,0 @@
1
- import { type OffchainEffect, type ProvingStats, Tx } from '@aztec/stdlib/tx';
2
-
3
- import type { Wallet } from '../wallet/wallet.js';
4
- import { SentTx } from './sent_tx.js';
5
-
6
- /**
7
- * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction.
8
- */
9
- export class ProvenTx extends Tx {
10
- #wallet: Wallet;
11
-
12
- constructor(
13
- wallet: Wallet,
14
- tx: Tx,
15
- /** The offchain effects emitted during the execution of the transaction. */
16
- public offchainEffects: OffchainEffect[],
17
- // eslint-disable-next-line jsdoc/require-jsdoc
18
- public stats?: ProvingStats,
19
- ) {
20
- super(tx.txHash, tx.data, tx.clientIvcProof, tx.contractClassLogFields, tx.publicFunctionCalldata);
21
- this.#wallet = wallet;
22
- }
23
-
24
- protected get wallet(): Wallet {
25
- return this.#wallet;
26
- }
27
-
28
- /**
29
- * Sends the transaction to the network via the provided wallet.
30
- */
31
- public send(): SentTx {
32
- const sendTx = () => this.#wallet.sendTx(this);
33
-
34
- return new SentTx(this.#wallet, sendTx);
35
- }
36
- }
@@ -1,21 +0,0 @@
1
- import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
- import { retryUntil } from '@aztec/foundation/retry';
3
-
4
- import { createPXEClient } from '../rpc_clients/pxe_client.js';
5
-
6
- export const getL1ContractAddresses = async (url: string): Promise<L1ContractAddresses> => {
7
- const pxeClient = createPXEClient(url, {});
8
- const response = await retryUntil(
9
- async () => {
10
- try {
11
- return (await pxeClient.getNodeInfo()).l1ContractAddresses;
12
- } catch {
13
- // do nothing
14
- }
15
- },
16
- 'isNodeReady',
17
- 120,
18
- 1,
19
- );
20
- return response;
21
- };
@@ -1,89 +0,0 @@
1
- import {
2
- EncodedAppEntrypointCalls,
3
- EncodedCallsForEntrypoint,
4
- computeCombinedPayloadHash,
5
- } from '@aztec/entrypoints/encoding';
6
- import type { AuthWitnessProvider, FeePaymentMethod } from '@aztec/entrypoints/interfaces';
7
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
8
- import {
9
- type ContractArtifact,
10
- type FunctionArtifact,
11
- FunctionCall,
12
- FunctionSelector,
13
- encodeArguments,
14
- getFunctionArtifactByName,
15
- } from '@aztec/stdlib/abi';
16
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
17
- import type { GasSettings } from '@aztec/stdlib/gas';
18
-
19
- /**
20
- * Fee payment method that allows a contract to pay for its own deployment
21
- * It works by rerouting the provided fee payment method through the account's entrypoint,
22
- * which sets itself as fee payer.
23
- *
24
- * Usually, in order to pay fees it is necessary to obtain an ExecutionPayload that encodes the necessary information
25
- * that is sent to the user's account entrypoint, that has plumbing to handle a fee payload.
26
- * If there's no account contract yet (it's being deployed) a MultiCallContract is used, which doesn't have a concept of fees or
27
- * how to handle this payload.
28
- * HOWEVER, the account contract's entrypoint does, so this method reshapes that fee payload into a call to the account contract entrypoint
29
- * being deployed with the original fee payload.
30
- *
31
- * This class can be seen in action in AccountManager.ts#getSelfPaymentMethod
32
- */
33
- export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
34
- constructor(
35
- private artifact: ContractArtifact,
36
- private authWitnessProvider: AuthWitnessProvider,
37
- private feePaymentNameOrArtifact: string | FunctionArtifact,
38
- private accountAddress: AztecAddress,
39
- private paymentMethod: FeePaymentMethod,
40
- ) {}
41
-
42
- getAsset(): Promise<AztecAddress> {
43
- return this.paymentMethod.getAsset();
44
- }
45
-
46
- async getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload> {
47
- const emptyAppCalls = await EncodedAppEntrypointCalls.fromAppExecution([]);
48
- // Get the execution payload for the fee, it includes the calls and potentially authWitnesses
49
- const { calls: feeCalls, authWitnesses: feeAuthwitnesses } =
50
- await this.paymentMethod.getExecutionPayload(gasSettings);
51
- // Encode the calls for the fee
52
- const feePayer = await this.paymentMethod.getFeePayer(gasSettings);
53
- const isFeePayer = feePayer.equals(this.accountAddress);
54
- const feeEncodedCalls = await EncodedCallsForEntrypoint.fromFeeCalls(feeCalls, isFeePayer);
55
-
56
- // Get the entrypoint args
57
- const args = [emptyAppCalls, feeEncodedCalls, false];
58
- const feePaymentArtifact =
59
- typeof this.feePaymentNameOrArtifact === 'string'
60
- ? getFunctionArtifactByName(this.artifact, this.feePaymentNameOrArtifact)
61
- : this.feePaymentNameOrArtifact;
62
-
63
- const entrypointCall = new FunctionCall(
64
- feePaymentArtifact.name,
65
- this.accountAddress,
66
- await FunctionSelector.fromNameAndParameters(feePaymentArtifact.name, feePaymentArtifact.parameters),
67
- feePaymentArtifact.functionType,
68
- feePaymentArtifact.isStatic,
69
- encodeArguments(feePaymentArtifact, args),
70
- feePaymentArtifact.returnTypes,
71
- );
72
-
73
- // Compute the authwitness required to verify the combined payload
74
- const combinedPayloadAuthWitness = await this.authWitnessProvider.createAuthWit(
75
- await computeCombinedPayloadHash(emptyAppCalls, feeEncodedCalls),
76
- );
77
-
78
- return new ExecutionPayload(
79
- [entrypointCall],
80
- [combinedPayloadAuthWitness, ...feeAuthwitnesses],
81
- [],
82
- [...emptyAppCalls.hashedArguments, ...feeEncodedCalls.hashedArguments],
83
- );
84
- }
85
-
86
- getFeePayer(gasSettings: GasSettings): Promise<AztecAddress> {
87
- return this.paymentMethod.getFeePayer(gasSettings);
88
- }
89
- }
@@ -1,25 +0,0 @@
1
- import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
2
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
3
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
-
6
- // docs:start:fee_juice_method
7
- /**
8
- * Pay fee directly in the Fee Juice.
9
- */
10
- export class FeeJuicePaymentMethod implements FeePaymentMethod {
11
- // docs:end:fee_juice_method
12
- constructor(protected sender: AztecAddress) {}
13
-
14
- getAsset() {
15
- return Promise.resolve(ProtocolContractAddress.FeeJuice);
16
- }
17
-
18
- getExecutionPayload(): Promise<ExecutionPayload> {
19
- return Promise.resolve(ExecutionPayload.empty());
20
- }
21
-
22
- getFeePayer(): Promise<AztecAddress> {
23
- return Promise.resolve(this.sender);
24
- }
25
- }
package/src/fee/utils.ts DELETED
@@ -1,39 +0,0 @@
1
- import { DefaultEntrypoint } from '@aztec/entrypoints/default';
2
- import { type FunctionAbi, decodeFromAbi } from '@aztec/stdlib/abi';
3
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { GasSettings } from '@aztec/stdlib/gas';
5
-
6
- import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
7
- import type { Wallet } from '../wallet/wallet.js';
8
- import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
9
-
10
- /**
11
- * Use a wallet to simulate a function avoiding the wallet's entrypoint, as a SignerlessWallet would do
12
- * @param wallet - The wallet to use for the simulation.
13
- * @param contractAddress - The address of the contract to call.
14
- * @param abi - The ABI of the function to simulate.
15
- * @param args - The arguments to pass to the function.
16
- * @returns The return values of the function call.
17
- */
18
- export async function simulateWithoutSignature(
19
- wallet: Wallet,
20
- contractAddress: AztecAddress,
21
- abi: FunctionAbi,
22
- args: any[],
23
- ) {
24
- const interaction = new ContractFunctionInteraction(wallet, contractAddress, abi, args);
25
-
26
- const request = await interaction.request();
27
- const maxFeesPerGas = (await wallet.getCurrentBaseFees()).mul(1.5);
28
- const paymentMethod = new FeeJuicePaymentMethod(AztecAddress.ZERO);
29
- const gasSettings = GasSettings.default({ maxFeesPerGas });
30
- const fee = { gasSettings, paymentMethod };
31
-
32
- const { l1ChainId: chainId, rollupVersion } = await wallet.getNodeInfo();
33
- const entrypoint = new DefaultEntrypoint(chainId, rollupVersion);
34
- const signerlessTxExecutionRequest = await entrypoint.createTxExecutionRequest(request, fee, {});
35
-
36
- const simulationResult = await wallet.simulateTx(signerlessTxExecutionRequest, false, undefined, true);
37
- const rawReturnValues = simulationResult.getPrivateReturnValues().values;
38
- return decodeFromAbi(abi.returnTypes, rawReturnValues!);
39
- }