@aztec/aztec.js 0.71.0 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dest/account/contract.d.ts +1 -1
  2. package/dest/account/contract.d.ts.map +1 -1
  3. package/dest/account_manager/deploy_account_method.js +7 -7
  4. package/dest/account_manager/index.d.ts +9 -6
  5. package/dest/account_manager/index.d.ts.map +1 -1
  6. package/dest/account_manager/index.js +28 -18
  7. package/dest/api/ethereum.d.ts +2 -1
  8. package/dest/api/ethereum.d.ts.map +1 -1
  9. package/dest/api/ethereum.js +3 -2
  10. package/dest/barretenberg-threads.wasm.gz +0 -0
  11. package/dest/barretenberg.wasm.gz +0 -0
  12. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  13. package/dest/contract/base_contract_interaction.js +3 -2
  14. package/dest/contract/contract.js +2 -2
  15. package/dest/contract/contract_base.d.ts +2 -2
  16. package/dest/contract/contract_base.d.ts.map +1 -1
  17. package/dest/contract/contract_base.js +2 -2
  18. package/dest/contract/contract_function_interaction.d.ts +1 -1
  19. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  20. package/dest/contract/contract_function_interaction.js +4 -4
  21. package/dest/contract/deploy_method.d.ts +2 -2
  22. package/dest/contract/deploy_method.d.ts.map +1 -1
  23. package/dest/contract/deploy_method.js +19 -19
  24. package/dest/contract/deploy_proven_tx.d.ts +2 -2
  25. package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
  26. package/dest/contract/deploy_proven_tx.js +4 -4
  27. package/dest/contract/deploy_sent_tx.d.ts +4 -4
  28. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  29. package/dest/contract/deploy_sent_tx.js +9 -7
  30. package/dest/contract/proven_tx.d.ts.map +1 -1
  31. package/dest/contract/proven_tx.js +3 -3
  32. package/dest/contract/sent_tx.d.ts +3 -3
  33. package/dest/contract/sent_tx.d.ts.map +1 -1
  34. package/dest/contract/sent_tx.js +4 -4
  35. package/dest/deployment/broadcast_function.d.ts +1 -1
  36. package/dest/deployment/broadcast_function.d.ts.map +1 -1
  37. package/dest/deployment/broadcast_function.js +23 -14
  38. package/dest/deployment/deploy_instance.d.ts +1 -1
  39. package/dest/deployment/deploy_instance.d.ts.map +1 -1
  40. package/dest/deployment/deploy_instance.js +3 -3
  41. package/dest/deployment/protocol_contracts.d.ts +2 -2
  42. package/dest/deployment/protocol_contracts.d.ts.map +1 -1
  43. package/dest/deployment/protocol_contracts.js +5 -5
  44. package/dest/deployment/register_class.js +3 -3
  45. package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
  46. package/dest/entrypoint/default_entrypoint.js +3 -3
  47. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
  48. package/dest/entrypoint/default_multi_call_entrypoint.js +5 -5
  49. package/dest/entrypoint/payload.d.ts +22 -7
  50. package/dest/entrypoint/payload.d.ts.map +1 -1
  51. package/dest/entrypoint/payload.js +35 -28
  52. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  53. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
  54. package/dest/fee/private_fee_payment_method.js +8 -8
  55. package/dest/fee/public_fee_payment_method.js +20 -21
  56. package/dest/index.d.ts +4 -5
  57. package/dest/index.d.ts.map +1 -1
  58. package/dest/index.js +4 -5
  59. package/dest/main.js +2 -0
  60. package/dest/main.js.LICENSE.txt +25 -0
  61. package/dest/rpc_clients/pxe_client.d.ts +1 -1
  62. package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
  63. package/dest/utils/abi_types.d.ts +3 -1
  64. package/dest/utils/abi_types.d.ts.map +1 -1
  65. package/dest/utils/anvil_test_watcher.d.ts +5 -1
  66. package/dest/utils/anvil_test_watcher.d.ts.map +1 -1
  67. package/dest/utils/anvil_test_watcher.js +47 -7
  68. package/dest/utils/authwit.d.ts +3 -3
  69. package/dest/utils/authwit.d.ts.map +1 -1
  70. package/dest/utils/authwit.js +9 -5
  71. package/dest/utils/chain_monitor.d.ts +2 -1
  72. package/dest/utils/chain_monitor.d.ts.map +1 -1
  73. package/dest/utils/chain_monitor.js +7 -2
  74. package/dest/utils/cheat_codes.d.ts +5 -2
  75. package/dest/utils/cheat_codes.d.ts.map +1 -1
  76. package/dest/utils/cheat_codes.js +9 -2
  77. package/dest/utils/l1_contracts.d.ts +1 -1
  78. package/dest/utils/l1_contracts.d.ts.map +1 -1
  79. package/dest/utils/portal_manager.d.ts +2 -2
  80. package/dest/utils/portal_manager.d.ts.map +1 -1
  81. package/dest/utils/portal_manager.js +8 -8
  82. package/dest/utils/pub_key.d.ts +1 -1
  83. package/dest/utils/pub_key.d.ts.map +1 -1
  84. package/dest/wallet/account_wallet.d.ts +1 -1
  85. package/dest/wallet/account_wallet.d.ts.map +1 -1
  86. package/dest/wallet/account_wallet.js +9 -9
  87. package/dest/wallet/account_wallet_with_private_key.d.ts +1 -1
  88. package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -1
  89. package/dest/wallet/account_wallet_with_private_key.js +3 -3
  90. package/dest/wallet/base_wallet.d.ts +8 -12
  91. package/dest/wallet/base_wallet.d.ts.map +1 -1
  92. package/dest/wallet/base_wallet.js +13 -25
  93. package/package.json +10 -9
  94. package/src/account/contract.ts +1 -1
  95. package/src/account_manager/deploy_account_method.ts +6 -6
  96. package/src/account_manager/index.ts +34 -25
  97. package/src/api/ethereum.ts +2 -1
  98. package/src/contract/base_contract_interaction.ts +3 -1
  99. package/src/contract/contract.ts +1 -1
  100. package/src/contract/contract_base.ts +2 -2
  101. package/src/contract/contract_function_interaction.ts +3 -3
  102. package/src/contract/deploy_method.ts +20 -20
  103. package/src/contract/deploy_proven_tx.ts +2 -2
  104. package/src/contract/deploy_sent_tx.ts +7 -5
  105. package/src/contract/proven_tx.ts +0 -2
  106. package/src/contract/sent_tx.ts +4 -4
  107. package/src/deployment/broadcast_function.ts +28 -14
  108. package/src/deployment/deploy_instance.ts +5 -2
  109. package/src/deployment/protocol_contracts.ts +4 -4
  110. package/src/deployment/register_class.ts +2 -2
  111. package/src/entrypoint/default_entrypoint.ts +2 -2
  112. package/src/entrypoint/default_multi_call_entrypoint.ts +4 -4
  113. package/src/entrypoint/payload.ts +53 -25
  114. package/src/fee/fee_juice_payment_method_with_claim.ts +6 -5
  115. package/src/fee/private_fee_payment_method.ts +7 -7
  116. package/src/fee/public_fee_payment_method.ts +23 -23
  117. package/src/index.ts +3 -5
  118. package/src/utils/abi_types.ts +4 -1
  119. package/src/utils/anvil_test_watcher.ts +54 -6
  120. package/src/utils/authwit.ts +9 -5
  121. package/src/utils/chain_monitor.ts +8 -2
  122. package/src/utils/cheat_codes.ts +11 -2
  123. package/src/utils/l1_contracts.ts +1 -1
  124. package/src/utils/portal_manager.ts +8 -8
  125. package/src/utils/pub_key.ts +1 -1
  126. package/src/wallet/account_wallet.ts +12 -11
  127. package/src/wallet/account_wallet_with_private_key.ts +2 -2
  128. package/src/wallet/base_wallet.ts +17 -27
  129. package/dest/api/init.d.ts +0 -7
  130. package/dest/api/init.d.ts.map +0 -1
  131. package/dest/api/init.js +0 -10
  132. package/src/api/init.ts +0 -10
@@ -1,6 +1,6 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
2
  import { type GasSettings } from '@aztec/circuits.js';
3
- import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
3
+ import { FunctionSelector, FunctionType, U128 } from '@aztec/foundation/abi';
4
4
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
 
@@ -80,35 +80,35 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
80
80
  */
81
81
  async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
82
82
  const nonce = Fr.random();
83
- const maxFee = gasSettings.getFeeLimit();
83
+ const maxFee = new U128(gasSettings.getFeeLimit().toBigInt());
84
84
 
85
- return Promise.resolve([
86
- this.wallet
87
- .setPublicAuthWit(
88
- {
89
- caller: this.paymentContract,
90
- action: {
91
- name: 'transfer_in_public',
92
- args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, nonce],
93
- selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),Field,Field)'),
94
- type: FunctionType.PUBLIC,
95
- isStatic: false,
96
- to: await this.getAsset(),
97
- returnTypes: [],
98
- },
99
- },
100
- true,
101
- )
102
- .request(),
85
+ const setPublicAuthWitInteraction = await this.wallet.setPublicAuthWit(
86
+ {
87
+ caller: this.paymentContract,
88
+ action: {
89
+ name: 'transfer_in_public',
90
+ args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), ...maxFee.toFields(), nonce],
91
+ selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),(Field,Field),Field)'),
92
+ type: FunctionType.PUBLIC,
93
+ isStatic: false,
94
+ to: await this.getAsset(),
95
+ returnTypes: [],
96
+ },
97
+ },
98
+ true,
99
+ );
100
+
101
+ return [
102
+ await setPublicAuthWitInteraction.request(),
103
103
  {
104
104
  name: 'fee_entrypoint_public',
105
105
  to: this.paymentContract,
106
- selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,Field)'),
106
+ selector: await FunctionSelector.fromSignature('fee_entrypoint_public((Field,Field),Field)'),
107
107
  type: FunctionType.PRIVATE,
108
108
  isStatic: false,
109
- args: [maxFee, nonce],
109
+ args: [...maxFee.toFields(), nonce],
110
110
  returnTypes: [],
111
111
  },
112
- ]);
112
+ ];
113
113
  }
114
114
  }
package/src/index.ts CHANGED
@@ -45,6 +45,7 @@ export {
45
45
  type L2AmountClaim,
46
46
  type L2AmountClaimWithRecipient,
47
47
  type L2Claim,
48
+ type U128Like,
48
49
  type WrappedFieldLike,
49
50
  type IntentAction,
50
51
  } from './utils/index.js';
@@ -117,7 +118,6 @@ export {
117
118
  TxHash,
118
119
  TxReceipt,
119
120
  TxStatus,
120
- UnencryptedL2BlockL2Logs,
121
121
  UnencryptedL2Log,
122
122
  UniqueNote,
123
123
  createAztecNodeClient,
@@ -147,14 +147,12 @@ export { elapsed } from '@aztec/foundation/timer';
147
147
  export { type FieldsOf } from '@aztec/foundation/types';
148
148
  export { fileURLToPath } from '@aztec/foundation/url';
149
149
 
150
- export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contracts } from '@aztec/ethereum';
151
-
152
150
  // Start of section that exports public api via granular api.
153
151
  // Here you *can* do `export *` as the granular api defacto exports things explicitly.
154
152
  // This entire index file will be deprecated at some point after we're satisfied.
155
153
  export * from './api/abi.js';
156
154
  export * from './api/fee.js';
157
- export * from './api/init.js';
155
+ export * from './api/addresses.js';
156
+ export * from './api/ethereum.js';
158
157
  // Granular export, even if not in the api folder
159
158
  export * from './contract/index.js';
160
- export * from './api/addresses.js';
@@ -13,7 +13,7 @@ export type FieldLike = Fr | Buffer | bigint | number | { /** Converts to field
13
13
  export type EthAddressLike = { /** Wrapped address */ address: FieldLike } | EthAddress;
14
14
 
15
15
  /** Any type that can be converted into an AztecAddress Aztec.nr struct. */
16
- export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress | Fr;
16
+ export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress;
17
17
 
18
18
  /** Any type that can be converted into a FunctionSelector Aztec.nr struct. */
19
19
  export type FunctionSelectorLike = FieldLike | FunctionSelector;
@@ -21,5 +21,8 @@ export type FunctionSelectorLike = FieldLike | FunctionSelector;
21
21
  /** Any type that can be converted into an EventSelector Aztec.nr struct. */
22
22
  export type EventSelectorLike = FieldLike | EventSelector;
23
23
 
24
+ /** Any type that can be converted into a U128. */
25
+ export type U128Like = bigint | number;
26
+
24
27
  /** Any type that can be converted into a struct with a single `inner` field. */
25
28
  export type WrappedFieldLike = { /** Wrapped value */ inner: FieldLike } | FieldLike;
@@ -15,9 +15,12 @@ import type * as chains from 'viem/chains';
15
15
  * block within the slot. And if so, it will time travel into the next slot.
16
16
  */
17
17
  export class AnvilTestWatcher {
18
+ private isSandbox: boolean = false;
19
+
18
20
  private rollup: GetContractReturnType<typeof RollupAbi, PublicClient<HttpTransport, chains.Chain>>;
19
21
 
20
22
  private filledRunningPromise?: RunningPromise;
23
+ private mineIfOutdatedPromise?: RunningPromise;
21
24
 
22
25
  private logger: Logger = createLogger(`aztecjs:utils:watcher`);
23
26
 
@@ -36,6 +39,10 @@ export class AnvilTestWatcher {
36
39
  this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
37
40
  }
38
41
 
42
+ setIsSandbox(isSandbox: boolean) {
43
+ this.isSandbox = isSandbox;
44
+ }
45
+
39
46
  async start() {
40
47
  if (this.filledRunningPromise) {
41
48
  throw new Error('Watcher already watching for filled slot');
@@ -48,8 +55,10 @@ export class AnvilTestWatcher {
48
55
  const isAutoMining = await this.cheatcodes.isAutoMining();
49
56
 
50
57
  if (isAutoMining) {
51
- this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), this.logger, 1000);
58
+ this.filledRunningPromise = new RunningPromise(() => this.warpTimeIfNeeded(), this.logger, 1000);
52
59
  this.filledRunningPromise.start();
60
+ this.mineIfOutdatedPromise = new RunningPromise(() => this.mineIfOutdated(), this.logger, 1000);
61
+ this.mineIfOutdatedPromise.start();
53
62
  this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
54
63
  } else {
55
64
  this.logger.info(`Watcher not started because not auto mining`);
@@ -58,25 +67,64 @@ export class AnvilTestWatcher {
58
67
 
59
68
  async stop() {
60
69
  await this.filledRunningPromise?.stop();
70
+ await this.mineIfOutdatedPromise?.stop();
71
+ }
72
+
73
+ async mineIfOutdated() {
74
+ // this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
75
+ if (!this.dateProvider) {
76
+ return;
77
+ }
78
+
79
+ const l1Time = (await this.cheatcodes.timestamp()) * 1000;
80
+ const wallTime = this.dateProvider.now();
81
+
82
+ // If the wall time is more than 24 seconds away from L1 time,
83
+ // mine a block and sync the clocks
84
+ if (Math.abs(wallTime - l1Time) > 24 * 1000) {
85
+ this.logger.warn(`Wall time is more than 24 seconds away from L1 time, mining a block and syncing clocks`);
86
+ await this.cheatcodes.evmMine();
87
+ const newL1Time = await this.cheatcodes.timestamp();
88
+ this.logger.info(`New L1 time: ${newL1Time}`);
89
+ this.dateProvider.setTime(newL1Time * 1000);
90
+ }
61
91
  }
62
92
 
63
- async mineIfSlotFilled() {
93
+ async warpTimeIfNeeded() {
64
94
  try {
65
95
  const currentSlot = await this.rollup.read.getCurrentSlot();
66
96
  const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
67
97
  const blockLog = await this.rollup.read.getBlock([pendingBlockNumber]);
98
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([currentSlot + 1n]));
68
99
 
69
100
  if (currentSlot === blockLog.slotNumber) {
70
101
  // We should jump to the next slot
71
- const timestamp = await this.rollup.read.getTimestampForSlot([currentSlot + 1n]);
72
102
  try {
73
- await this.cheatcodes.warp(Number(timestamp));
74
- this.dateProvider?.setTime(Number(timestamp) * 1000);
103
+ await this.cheatcodes.warp(nextSlotTimestamp);
104
+ this.dateProvider?.setTime(nextSlotTimestamp * 1000);
75
105
  } catch (e) {
76
- this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
106
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
77
107
  }
78
108
 
79
109
  this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
110
+ return;
111
+ }
112
+
113
+ // If we are not in sandbox, we don't need to warp time
114
+ if (!this.isSandbox) {
115
+ return;
116
+ }
117
+
118
+ const currentTimestamp = this.dateProvider?.now() ?? Date.now();
119
+ if (currentTimestamp > nextSlotTimestamp * 1000) {
120
+ try {
121
+ await this.cheatcodes.warp(nextSlotTimestamp);
122
+ this.dateProvider?.setTime(nextSlotTimestamp * 1000);
123
+ } catch (e) {
124
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
125
+ }
126
+
127
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
80
128
  }
81
129
  } catch (err) {
82
130
  this.logger.error('mineIfSlotFilled failed');
@@ -50,17 +50,17 @@ export type IntentAction = {
50
50
  * @param metadata - The metadata for the intent (chainId, version)
51
51
  * @returns The message hash for the action
52
52
  */
53
- export const computeAuthWitMessageHash = (intent: IntentInnerHash | IntentAction, metadata: IntentMetadata) => {
53
+ export const computeAuthWitMessageHash = async (intent: IntentInnerHash | IntentAction, metadata: IntentMetadata) => {
54
54
  const chainId = metadata.chainId;
55
55
  const version = metadata.version;
56
56
 
57
57
  if ('caller' in intent) {
58
- const action = intent.action instanceof ContractFunctionInteraction ? intent.action.request() : intent.action;
58
+ const action = intent.action instanceof ContractFunctionInteraction ? await intent.action.request() : intent.action;
59
59
  return computeOuterAuthWitHash(
60
60
  action.to,
61
61
  chainId,
62
62
  version,
63
- computeInnerAuthWitHashFromAction(intent.caller, action),
63
+ await computeInnerAuthWitHashFromAction(intent.caller, action),
64
64
  );
65
65
  } else {
66
66
  const inner = Buffer.isBuffer(intent.innerHash) ? Fr.fromBuffer(intent.innerHash) : intent.innerHash;
@@ -69,8 +69,12 @@ export const computeAuthWitMessageHash = (intent: IntentInnerHash | IntentAction
69
69
  };
70
70
  // docs:end:authwit_computeAuthWitMessageHash
71
71
 
72
- export const computeInnerAuthWitHashFromAction = (caller: AztecAddress, action: FunctionCall) =>
73
- computeInnerAuthWitHash([caller.toField(), action.selector.toField(), HashedValues.fromValues(action.args).hash]);
72
+ export const computeInnerAuthWitHashFromAction = async (caller: AztecAddress, action: FunctionCall) =>
73
+ computeInnerAuthWitHash([
74
+ caller.toField(),
75
+ action.selector.toField(),
76
+ (await HashedValues.fromValues(action.args)).hash,
77
+ ]);
74
78
 
75
79
  /**
76
80
  * Compute the inner hash for an authentication witness.
@@ -1,4 +1,4 @@
1
- import { type RollupContract } from '@aztec/ethereum';
1
+ import { type RollupContract } from '@aztec/ethereum/contracts';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
 
4
4
  import { type PublicClient } from 'viem';
@@ -27,7 +27,7 @@ export class ChainMonitor {
27
27
  if (this.handle) {
28
28
  throw new Error('Chain monitor already started');
29
29
  }
30
- this.handle = setInterval(() => this.run(), this.intervalMs);
30
+ this.handle = setInterval(this.safeRun.bind(this), this.intervalMs);
31
31
  }
32
32
 
33
33
  stop() {
@@ -37,6 +37,12 @@ export class ChainMonitor {
37
37
  }
38
38
  }
39
39
 
40
+ private safeRun() {
41
+ void this.run().catch(error => {
42
+ this.logger.error('Error in chain monitor loop', error);
43
+ });
44
+ }
45
+
40
46
  async run() {
41
47
  const newL1BlockNumber = Number(await this.l1Client.getBlockNumber({ cacheTime: 0 }));
42
48
  if (this.l1BlockNumber === newL1BlockNumber) {
@@ -1,7 +1,8 @@
1
1
  import { type EpochProofClaim, type Note, type PXE } from '@aztec/circuit-types';
2
2
  import { type AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
3
3
  import { deriveStorageSlotInMap } from '@aztec/circuits.js/hash';
4
- import { EthCheatCodes, type L1ContractAddresses } from '@aztec/ethereum';
4
+ import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
5
+ import { type L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
5
6
  import { createLogger } from '@aztec/foundation/log';
6
7
  import { RollupAbi } from '@aztec/l1-artifacts';
7
8
 
@@ -188,6 +189,14 @@ export class RollupCheatCodes {
188
189
  await action(owner, this.rollup);
189
190
  await this.ethCheatCodes.stopImpersonating(owner);
190
191
  }
192
+
193
+ /** Directly calls the L1 gas fee oracle. */
194
+ public async updateL1GasFeeOracle() {
195
+ await this.asOwner(async (account, rollup) => {
196
+ await rollup.write.updateL1GasFeeOracle({ account, chain: this.client.chain });
197
+ this.logger.warn(`Updated L1 gas fee oracle`);
198
+ });
199
+ }
191
200
  }
192
201
 
193
202
  /**
@@ -215,7 +224,7 @@ export class AztecCheatCodes {
215
224
  * @param key - The key to lookup in the map
216
225
  * @returns The storage slot of the value in the map
217
226
  */
218
- public computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Fr {
227
+ public computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr> {
219
228
  const keyFr = typeof key === 'bigint' ? new Fr(key) : key.toField();
220
229
  return deriveStorageSlotInMap(mapSlot, keyFr);
221
230
  }
@@ -1,4 +1,4 @@
1
- import { type L1ContractAddresses } from '@aztec/ethereum';
1
+ import { type L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
 
4
4
  import { createPXEClient } from '../rpc_clients/index.js';
@@ -7,7 +7,7 @@ import {
7
7
  type SiblingPath,
8
8
  computeSecretHash,
9
9
  } from '@aztec/aztec.js';
10
- import { extractEvent } from '@aztec/ethereum';
10
+ import { extractEvent } from '@aztec/ethereum/utils';
11
11
  import { sha256ToField } from '@aztec/foundation/crypto';
12
12
  import { FeeJuicePortalAbi, OutboxAbi, TestERC20Abi, TokenPortalAbi } from '@aztec/l1-artifacts';
13
13
 
@@ -36,7 +36,7 @@ export type L2Claim = {
36
36
  };
37
37
 
38
38
  /** L1 to L2 message info that corresponds to an amount to claim. */
39
- export type L2AmountClaim = L2Claim & { /** Amount to claim */ claimAmount: Fr };
39
+ export type L2AmountClaim = L2Claim & { /** Amount to claim */ claimAmount: bigint };
40
40
 
41
41
  /** L1 to L2 message info that corresponds to an amount to claim with associated recipient. */
42
42
  export type L2AmountClaimWithRecipient = L2AmountClaim & {
@@ -49,9 +49,9 @@ function stringifyEthAddress(address: EthAddress | Hex, name?: string) {
49
49
  }
50
50
 
51
51
  /** Generates a pair secret and secret hash */
52
- export function generateClaimSecret(logger?: Logger): [Fr, Fr] {
52
+ export async function generateClaimSecret(logger?: Logger): Promise<[Fr, Fr]> {
53
53
  const secret = Fr.random();
54
- const secretHash = computeSecretHash(secret);
54
+ const secretHash = await computeSecretHash(secret);
55
55
  logger?.verbose(`Generated claim secret=${secret.toString()} hash=${secretHash.toString()}`);
56
56
  return [secret, secretHash];
57
57
  }
@@ -144,7 +144,7 @@ export class L1FeeJuicePortalManager {
144
144
  * @param mint - Whether to mint the tokens before sending (only during testing).
145
145
  */
146
146
  public async bridgeTokensPublic(to: AztecAddress, amount: bigint, mint = false): Promise<L2AmountClaim> {
147
- const [claimSecret, claimSecretHash] = generateClaimSecret();
147
+ const [claimSecret, claimSecretHash] = await generateClaimSecret();
148
148
  if (mint) {
149
149
  await this.tokenManager.mint(amount, this.walletClient.account.address);
150
150
  }
@@ -173,7 +173,7 @@ export class L1FeeJuicePortalManager {
173
173
  );
174
174
 
175
175
  return {
176
- claimAmount: new Fr(amount),
176
+ claimAmount: amount,
177
177
  claimSecret,
178
178
  claimSecretHash,
179
179
  messageHash: log.args.key,
@@ -264,7 +264,7 @@ export class L1ToL2TokenPortalManager {
264
264
  );
265
265
 
266
266
  return {
267
- claimAmount: new Fr(amount),
267
+ claimAmount: amount,
268
268
  claimSecret,
269
269
  claimSecretHash,
270
270
  messageHash: log.args.key,
@@ -306,7 +306,7 @@ export class L1ToL2TokenPortalManager {
306
306
  );
307
307
 
308
308
  return {
309
- claimAmount: new Fr(amount),
309
+ claimAmount: amount,
310
310
  claimSecret,
311
311
  claimSecretHash,
312
312
  recipient: to,
@@ -6,7 +6,7 @@ import { Grumpkin } from '@aztec/circuits.js/barretenberg';
6
6
  * @param privateKey - The private key.
7
7
  * @returns The generated public key.
8
8
  */
9
- export function generatePublicKey(privateKey: GrumpkinScalar): PublicKey {
9
+ export function generatePublicKey(privateKey: GrumpkinScalar): Promise<PublicKey> {
10
10
  const grumpkin = new Grumpkin();
11
11
  return grumpkin.mul(grumpkin.generator(), privateKey);
12
12
  }
@@ -55,7 +55,7 @@ export class AccountWallet extends BaseWallet {
55
55
  } else if (messageHashOrIntent instanceof Fr) {
56
56
  messageHash = messageHashOrIntent;
57
57
  } else {
58
- messageHash = this.getMessageHash(messageHashOrIntent);
58
+ messageHash = await this.getMessageHash(messageHashOrIntent);
59
59
  }
60
60
 
61
61
  const witness = await this.account.createAuthWit(messageHash);
@@ -72,17 +72,17 @@ export class AccountWallet extends BaseWallet {
72
72
  * @param authorized - True to authorize, false to revoke authorization.
73
73
  * @returns - A function interaction.
74
74
  */
75
- public setPublicAuthWit(
75
+ public async setPublicAuthWit(
76
76
  messageHashOrIntent: Fr | Buffer | IntentInnerHash | IntentAction,
77
77
  authorized: boolean,
78
- ): ContractFunctionInteraction {
78
+ ): Promise<ContractFunctionInteraction> {
79
79
  let messageHash: Fr;
80
80
  if (Buffer.isBuffer(messageHashOrIntent)) {
81
81
  messageHash = Fr.fromBuffer(messageHashOrIntent);
82
82
  } else if (messageHashOrIntent instanceof Fr) {
83
83
  messageHash = messageHashOrIntent;
84
84
  } else {
85
- messageHash = this.getMessageHash(messageHashOrIntent);
85
+ messageHash = await this.getMessageHash(messageHashOrIntent);
86
86
  }
87
87
 
88
88
  return new ContractFunctionInteraction(this, ProtocolContractAddress.AuthRegistry, this.getSetAuthorizedAbi(), [
@@ -91,16 +91,17 @@ export class AccountWallet extends BaseWallet {
91
91
  ]);
92
92
  }
93
93
 
94
- private getInnerHashAndConsumer(intent: IntentInnerHash | IntentAction): {
94
+ private async getInnerHashAndConsumer(intent: IntentInnerHash | IntentAction): Promise<{
95
95
  /** The inner hash */
96
96
  innerHash: Fr;
97
97
  /** The consumer of the authwit */
98
98
  consumer: AztecAddress;
99
- } {
99
+ }> {
100
100
  if ('caller' in intent && 'action' in intent) {
101
- const action = intent.action instanceof ContractFunctionInteraction ? intent.action.request() : intent.action;
101
+ const action =
102
+ intent.action instanceof ContractFunctionInteraction ? await intent.action.request() : intent.action;
102
103
  return {
103
- innerHash: computeInnerAuthWitHashFromAction(intent.caller, action),
104
+ innerHash: await computeInnerAuthWitHashFromAction(intent.caller, action),
104
105
  consumer: action.to,
105
106
  };
106
107
  } else if (Buffer.isBuffer(intent.innerHash)) {
@@ -115,7 +116,7 @@ export class AccountWallet extends BaseWallet {
115
116
  * @param intent - A tuple of (consumer and inner hash) or (caller and action)
116
117
  * @returns The message hash
117
118
  */
118
- private getMessageHash(intent: IntentInnerHash | IntentAction): Fr {
119
+ private getMessageHash(intent: IntentInnerHash | IntentAction): Promise<Fr> {
119
120
  const chainId = this.getChainId();
120
121
  const version = this.getVersion();
121
122
  return computeAuthWitMessageHash(intent, { chainId, version });
@@ -140,9 +141,9 @@ export class AccountWallet extends BaseWallet {
140
141
  /** boolean flag indicating if the authwit is valid in public context */
141
142
  isValidInPublic: boolean;
142
143
  }> {
143
- const { innerHash, consumer } = this.getInnerHashAndConsumer(intent);
144
+ const { innerHash, consumer } = await this.getInnerHashAndConsumer(intent);
144
145
 
145
- const messageHash = this.getMessageHash(intent);
146
+ const messageHash = await this.getMessageHash(intent);
146
147
  const results = { isValidInPrivate: false, isValidInPublic: false };
147
148
 
148
149
  // Check private
@@ -30,9 +30,9 @@ export class AccountWalletWithSecretKey extends AccountWallet {
30
30
  * note - this ensures that the address secret always corresponds to an address point with y being positive
31
31
  * dev - this is also referred to as the address secret, which decrypts payloads encrypted to an address point
32
32
  */
33
- public getEncryptionSecret() {
33
+ public async getEncryptionSecret() {
34
34
  return computeAddressSecret(
35
- this.getCompleteAddress().getPreaddress(),
35
+ await this.getCompleteAddress().getPreaddress(),
36
36
  deriveMasterIncomingViewingSecretKey(this.getSecretKey()),
37
37
  );
38
38
  }
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  type AuthWitness,
3
+ type ContractClassMetadata,
4
+ type ContractMetadata,
3
5
  type EventMetadataDefinition,
4
6
  type ExtendedNote,
5
- type GetUnencryptedLogsResponse,
7
+ type GetContractClassLogsResponse,
8
+ type GetPublicLogsResponse,
6
9
  type L2Block,
7
10
  type LogFilter,
8
11
  type NotesFilter,
@@ -21,7 +24,6 @@ import {
21
24
  import {
22
25
  type AztecAddress,
23
26
  type CompleteAddress,
24
- type ContractClassWithId,
25
27
  type ContractInstanceWithAddress,
26
28
  type Fr,
27
29
  type GasFees,
@@ -65,15 +67,6 @@ export abstract class BaseWallet implements Wallet {
65
67
  getAddress() {
66
68
  return this.getCompleteAddress().address;
67
69
  }
68
- getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
69
- return this.pxe.getContractInstance(address);
70
- }
71
- getContractClass(id: Fr): Promise<ContractClassWithId | undefined> {
72
- return this.pxe.getContractClass(id);
73
- }
74
- getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
75
- return this.pxe.getContractArtifact(id);
76
- }
77
70
  addCapsule(capsule: Fr[]): Promise<void> {
78
71
  return this.pxe.addCapsule(capsule);
79
72
  }
@@ -160,10 +153,10 @@ export abstract class BaseWallet implements Wallet {
160
153
  ): Promise<AbiDecoded> {
161
154
  return this.pxe.simulateUnconstrained(functionName, args, to, from);
162
155
  }
163
- getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
164
- return this.pxe.getUnencryptedLogs(filter);
156
+ getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
157
+ return this.pxe.getPublicLogs(filter);
165
158
  }
166
- getContractClassLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
159
+ getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
167
160
  return this.pxe.getContractClassLogs(filter);
168
161
  }
169
162
  getBlockNumber(): Promise<number> {
@@ -181,28 +174,25 @@ export abstract class BaseWallet implements Wallet {
181
174
  getAuthWitness(messageHash: Fr) {
182
175
  return this.pxe.getAuthWitness(messageHash);
183
176
  }
184
- isContractClassPubliclyRegistered(id: Fr): Promise<boolean> {
185
- return this.pxe.isContractClassPubliclyRegistered(id);
186
- }
187
- isContractPubliclyDeployed(address: AztecAddress): Promise<boolean> {
188
- return this.pxe.isContractPubliclyDeployed(address);
189
- }
190
- isContractInitialized(address: AztecAddress): Promise<boolean> {
191
- return this.pxe.isContractInitialized(address);
192
- }
193
177
  getPXEInfo(): Promise<PXEInfo> {
194
178
  return this.pxe.getPXEInfo();
195
179
  }
196
- getEncryptedEvents<T>(
180
+ getContractClassMetadata(id: Fr, includeArtifact: boolean = false): Promise<ContractClassMetadata> {
181
+ return this.pxe.getContractClassMetadata(id, includeArtifact);
182
+ }
183
+ getContractMetadata(address: AztecAddress): Promise<ContractMetadata> {
184
+ return this.pxe.getContractMetadata(address);
185
+ }
186
+ getPrivateEvents<T>(
197
187
  event: EventMetadataDefinition,
198
188
  from: number,
199
189
  limit: number,
200
190
  vpks: Point[] = [this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey],
201
191
  ): Promise<T[]> {
202
- return this.pxe.getEncryptedEvents(event, from, limit, vpks);
192
+ return this.pxe.getPrivateEvents(event, from, limit, vpks);
203
193
  }
204
- getUnencryptedEvents<T>(event: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
205
- return this.pxe.getUnencryptedEvents(event, from, limit);
194
+ getPublicEvents<T>(event: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
195
+ return this.pxe.getPublicEvents(event, from, limit);
206
196
  }
207
197
  public getL1ToL2MembershipWitness(
208
198
  contractAddress: AztecAddress,
@@ -1,7 +0,0 @@
1
- /**
2
- * This should only be needed to be called in CJS environments that don't have top level await.
3
- * Initializes any asynchronous subsystems required to use the library.
4
- * At time of writing, this is just our foundation crypto lib.
5
- */
6
- export declare function initAztecJs(): Promise<void>;
7
- //# sourceMappingURL=init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/api/init.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,WAAW,kBAEhC"}
package/dest/api/init.js DELETED
@@ -1,10 +0,0 @@
1
- import { init } from '@aztec/foundation/crypto';
2
- /**
3
- * This should only be needed to be called in CJS environments that don't have top level await.
4
- * Initializes any asynchronous subsystems required to use the library.
5
- * At time of writing, this is just our foundation crypto lib.
6
- */
7
- export async function initAztecJs() {
8
- await init();
9
- }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hcGkvaW5pdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsSUFBSSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFaEQ7Ozs7R0FJRztBQUNILE1BQU0sQ0FBQyxLQUFLLFVBQVUsV0FBVztJQUMvQixNQUFNLElBQUksRUFBRSxDQUFDO0FBQ2YsQ0FBQyJ9
package/src/api/init.ts DELETED
@@ -1,10 +0,0 @@
1
- import { init } from '@aztec/foundation/crypto';
2
-
3
- /**
4
- * This should only be needed to be called in CJS environments that don't have top level await.
5
- * Initializes any asynchronous subsystems required to use the library.
6
- * At time of writing, this is just our foundation crypto lib.
7
- */
8
- export async function initAztecJs() {
9
- await init();
10
- }