@aztec/aztec.js 0.74.0 → 0.75.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 (80) hide show
  1. package/README.md +1 -1
  2. package/dest/api/cheat_codes.d.ts +26 -0
  3. package/dest/api/cheat_codes.d.ts.map +1 -0
  4. package/dest/api/cheat_codes.js +30 -0
  5. package/dest/{utils → api/ethereum}/anvil_test_watcher.d.ts +1 -1
  6. package/dest/api/ethereum/anvil_test_watcher.d.ts.map +1 -0
  7. package/dest/{utils → api/ethereum}/anvil_test_watcher.js +2 -2
  8. package/dest/api/ethereum/chain_monitor.d.ts.map +1 -0
  9. package/dest/api/ethereum/chain_monitor.js +58 -0
  10. package/dest/api/ethereum/cheat_codes.d.ts +55 -0
  11. package/dest/api/ethereum/cheat_codes.d.ts.map +1 -0
  12. package/dest/api/ethereum/cheat_codes.js +127 -0
  13. package/dest/api/ethereum/index.d.ts +7 -0
  14. package/dest/api/ethereum/index.d.ts.map +1 -0
  15. package/dest/api/ethereum/index.js +7 -0
  16. package/dest/api/ethereum/l1_contracts.d.ts.map +1 -0
  17. package/dest/api/ethereum/l1_contracts.js +15 -0
  18. package/dest/{utils → api/ethereum}/portal_manager.d.ts +3 -1
  19. package/dest/api/ethereum/portal_manager.d.ts.map +1 -0
  20. package/dest/{utils → api/ethereum}/portal_manager.js +3 -2
  21. package/dest/api/log.d.ts +2 -0
  22. package/dest/api/log.d.ts.map +1 -0
  23. package/dest/api/log.js +2 -0
  24. package/dest/contract/index.d.ts +2 -2
  25. package/dest/contract/index.js +2 -2
  26. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +1 -1
  27. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
  28. package/dest/entrypoint/default_multi_call_entrypoint.js +2 -2
  29. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +1 -1
  30. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  31. package/dest/index.d.ts +5 -4
  32. package/dest/index.d.ts.map +1 -1
  33. package/dest/index.js +6 -5
  34. package/dest/utils/aztec_cheatcodes.d.ts +57 -0
  35. package/dest/utils/aztec_cheatcodes.d.ts.map +1 -0
  36. package/dest/utils/aztec_cheatcodes.js +71 -0
  37. package/dest/utils/index.d.ts +6 -11
  38. package/dest/utils/index.d.ts.map +1 -1
  39. package/dest/utils/index.js +6 -12
  40. package/dest/utils/node.d.ts +1 -0
  41. package/dest/utils/node.d.ts.map +1 -1
  42. package/dest/utils/node.js +2 -1
  43. package/dest/wallet/index.d.ts +1 -1
  44. package/dest/wallet/index.d.ts.map +1 -1
  45. package/package.json +11 -12
  46. package/src/api/cheat_codes.ts +35 -0
  47. package/src/{utils → api/ethereum}/anvil_test_watcher.ts +2 -1
  48. package/src/{utils → api/ethereum}/cheat_codes.ts +3 -106
  49. package/src/api/ethereum/index.ts +15 -0
  50. package/src/{utils → api/ethereum}/l1_contracts.ts +1 -1
  51. package/src/{utils → api/ethereum}/portal_manager.ts +4 -9
  52. package/src/api/log.ts +1 -0
  53. package/src/contract/index.ts +2 -2
  54. package/src/entrypoint/default_multi_call_entrypoint.ts +2 -1
  55. package/src/fee/fee_juice_payment_method_with_claim.ts +1 -1
  56. package/src/index.ts +4 -32
  57. package/src/utils/aztec_cheatcodes.ts +75 -0
  58. package/src/utils/index.ts +19 -11
  59. package/src/utils/node.ts +2 -0
  60. package/src/wallet/index.ts +1 -1
  61. package/dest/api/ethereum.d.ts +0 -3
  62. package/dest/api/ethereum.d.ts.map +0 -1
  63. package/dest/api/ethereum.js +0 -3
  64. package/dest/barretenberg-threads.wasm.gz +0 -0
  65. package/dest/barretenberg.wasm.gz +0 -0
  66. package/dest/main.js +0 -2
  67. package/dest/main.js.LICENSE.txt +0 -25
  68. package/dest/utils/anvil_test_watcher.d.ts.map +0 -1
  69. package/dest/utils/chain_monitor.d.ts.map +0 -1
  70. package/dest/utils/chain_monitor.js +0 -58
  71. package/dest/utils/cheat_codes.d.ts +0 -137
  72. package/dest/utils/cheat_codes.d.ts.map +0 -1
  73. package/dest/utils/cheat_codes.js +0 -225
  74. package/dest/utils/l1_contracts.d.ts.map +0 -1
  75. package/dest/utils/l1_contracts.js +0 -15
  76. package/dest/utils/portal_manager.d.ts.map +0 -1
  77. package/src/api/ethereum.ts +0 -2
  78. /package/dest/{utils → api/ethereum}/chain_monitor.d.ts +0 -0
  79. /package/dest/{utils → api/ethereum}/l1_contracts.d.ts +0 -0
  80. /package/src/{utils → api/ethereum}/chain_monitor.ts +0 -0
@@ -1,14 +1,9 @@
1
- import {
2
- type AztecAddress,
3
- EthAddress,
4
- Fr,
5
- type Logger,
6
- type PXE,
7
- type SiblingPath,
8
- computeSecretHash,
9
- } from '@aztec/aztec.js';
1
+ import { type PXE, type SiblingPath } from '@aztec/circuit-types';
2
+ import { type AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
3
+ import { computeSecretHash } from '@aztec/circuits.js/hash';
10
4
  import { extractEvent } from '@aztec/ethereum/utils';
11
5
  import { sha256ToField } from '@aztec/foundation/crypto';
6
+ import { type Logger } from '@aztec/foundation/log';
12
7
  import { FeeJuicePortalAbi, OutboxAbi, TestERC20Abi, TokenPortalAbi } from '@aztec/l1-artifacts';
13
8
 
14
9
  import {
package/src/api/log.ts ADDED
@@ -0,0 +1 @@
1
+ export { createLogger, type Logger } from '@aztec/foundation/log';
@@ -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/contracts/compiling | Compiling contracts}
4
+ * `Wallet` instance, and to the {@link https://docs.aztec.network/developers/guides/smart_contracts/how_to_compile_contract | 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
@@ -30,7 +30,7 @@
30
30
  * has synchronized its changes.
31
31
  *
32
32
  * @remarks If you are using typescript, consider using the
33
- * {@link https://docs.aztec.network/developers/contracts/compiling#typescript-interfaces | autogenerated type-safe interfaces}
33
+ * {@link https://docs.aztec.network/developers/guides/smart_contracts/how_to_compile_contract#typescript-interfaces | autogenerated type-safe interfaces}
34
34
  * for interacting with your contracts.
35
35
  *
36
36
  * @packageDocumentation
@@ -1,9 +1,10 @@
1
- import { type EntrypointInterface, EntrypointPayload, type ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
2
1
  import { HashedValues, TxExecutionRequest } from '@aztec/circuit-types';
3
2
  import { type AztecAddress, TxContext } from '@aztec/circuits.js';
4
3
  import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/foundation/abi';
5
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
5
 
6
+ import { type EntrypointInterface, EntrypointPayload, type ExecutionRequestInit } from './entrypoint.js';
7
+
7
8
  /**
8
9
  * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
9
10
  */
@@ -4,7 +4,7 @@ import { FunctionType, U128 } from '@aztec/foundation/abi';
4
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
5
  import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
6
6
 
7
- import { type L2AmountClaim } from '../utils/portal_manager.js';
7
+ import { type L2AmountClaim } from '../api/ethereum/portal_manager.js';
8
8
  import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
9
9
 
10
10
  /**
package/src/index.ts CHANGED
@@ -22,34 +22,6 @@
22
22
 
23
23
  export { ContractDeployer } from './deployment/index.js';
24
24
 
25
- export {
26
- AnvilTestWatcher,
27
- CheatCodes,
28
- L1FeeJuicePortalManager,
29
- L1ToL2TokenPortalManager,
30
- L1TokenManager,
31
- L1TokenPortalManager,
32
- computeAuthWitMessageHash,
33
- computeInnerAuthWitHash,
34
- computeInnerAuthWitHashFromAction,
35
- generateClaimSecret,
36
- generatePublicKey,
37
- readFieldCompressedString,
38
- waitForPXE,
39
- waitForNode,
40
- type AztecAddressLike,
41
- type EthAddressLike,
42
- type EventSelectorLike,
43
- type FieldLike,
44
- type FunctionSelectorLike,
45
- type L2AmountClaim,
46
- type L2AmountClaimWithRecipient,
47
- type L2Claim,
48
- type U128Like,
49
- type WrappedFieldLike,
50
- type IntentAction,
51
- } from './utils/index.js';
52
-
53
25
  export { NoteSelector } from '@aztec/foundation/abi';
54
26
 
55
27
  export { createCompatibleClient, createPXEClient } from './rpc_clients/index.js';
@@ -120,12 +92,10 @@ export {
120
92
  TxStatus,
121
93
  UnencryptedL2Log,
122
94
  UniqueNote,
123
- createAztecNodeClient,
124
95
  getTimestampRangeForEpoch,
125
96
  merkleTreeIds,
126
97
  mockEpochProofQuote,
127
98
  mockTx,
128
- type AztecNode,
129
99
  type LogFilter,
130
100
  type PXE,
131
101
  type PartialAddress,
@@ -139,7 +109,6 @@ export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/foundation/
139
109
  export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
140
110
  export { sha256 } from '@aztec/foundation/crypto';
141
111
  export { makeFetch } from '@aztec/foundation/json-rpc/client';
142
- export { createLogger, type Logger } from '@aztec/foundation/log';
143
112
  export { retry, retryUntil } from '@aztec/foundation/retry';
144
113
  export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
145
114
  export { sleep } from '@aztec/foundation/sleep';
@@ -151,8 +120,11 @@ export { fileURLToPath } from '@aztec/foundation/url';
151
120
  // Here you *can* do `export *` as the granular api defacto exports things explicitly.
152
121
  // This entire index file will be deprecated at some point after we're satisfied.
153
122
  export * from './api/abi.js';
123
+ export * from './api/cheat_codes.js';
154
124
  export * from './api/fee.js';
155
125
  export * from './api/addresses.js';
156
- export * from './api/ethereum.js';
126
+ export * from './api/ethereum/index.js';
127
+ export * from './api/log.js';
157
128
  // Granular export, even if not in the api folder
158
129
  export * from './contract/index.js';
130
+ export * from './utils/index.js';
@@ -0,0 +1,75 @@
1
+ import { type Note, type PXE } from '@aztec/circuit-types';
2
+ import { type AztecAddress, Fr } from '@aztec/circuits.js';
3
+ import { deriveStorageSlotInMap } from '@aztec/circuits.js/hash';
4
+ import { createLogger } from '@aztec/foundation/log';
5
+
6
+ /**
7
+ * A class that provides utility functions for interacting with the aztec chain.
8
+ */
9
+ export class AztecCheatCodes {
10
+ constructor(
11
+ /**
12
+ * The PXE Service to use for interacting with the chain
13
+ */
14
+ public pxe: PXE,
15
+ /**
16
+ * The logger to use for the aztec cheatcodes
17
+ */
18
+ public logger = createLogger('aztecjs:cheat_codes'),
19
+ ) {}
20
+
21
+ /**
22
+ * Computes the slot value for a given map and key.
23
+ * @param mapSlot - The slot of the map (specified in Aztec.nr contract)
24
+ * @param key - The key to lookup in the map
25
+ * @returns The storage slot of the value in the map
26
+ */
27
+ public computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr> {
28
+ const keyFr = typeof key === 'bigint' ? new Fr(key) : key.toField();
29
+ return deriveStorageSlotInMap(mapSlot, keyFr);
30
+ }
31
+
32
+ /**
33
+ * Get the current blocknumber
34
+ * @returns The current block number
35
+ */
36
+ public async blockNumber(): Promise<number> {
37
+ return await this.pxe.getBlockNumber();
38
+ }
39
+
40
+ /**
41
+ * Get the current timestamp
42
+ * @returns The current timestamp
43
+ */
44
+ public async timestamp(): Promise<number> {
45
+ const res = await this.pxe.getBlock(await this.blockNumber());
46
+ return res?.header.globalVariables.timestamp.toNumber() ?? 0;
47
+ }
48
+
49
+ /**
50
+ * Loads the value stored at the given slot in the public storage of the given contract.
51
+ * @param who - The address of the contract
52
+ * @param slot - The storage slot to lookup
53
+ * @returns The value stored at the given slot
54
+ */
55
+ public async loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr> {
56
+ const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot));
57
+ return storageValue;
58
+ }
59
+
60
+ /**
61
+ * Loads the value stored at the given slot in the private storage of the given contract.
62
+ * @param contract - The address of the contract
63
+ * @param owner - The owner for whom the notes are encrypted
64
+ * @param slot - The storage slot to lookup
65
+ * @returns The notes stored at the given slot
66
+ */
67
+ public async loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]> {
68
+ const extendedNotes = await this.pxe.getNotes({
69
+ owner,
70
+ contractAddress: contract,
71
+ storageSlot: new Fr(slot),
72
+ });
73
+ return extendedNotes.map(extendedNote => extendedNote.note);
74
+ }
75
+ }
@@ -1,11 +1,19 @@
1
- export * from './pub_key.js';
2
- export * from './l1_contracts.js';
3
- export * from './abi_types.js';
4
- export * from './cheat_codes.js';
5
- export * from './authwit.js';
6
- export * from './pxe.js';
7
- export * from './node.js';
8
- export * from './anvil_test_watcher.js';
9
- export * from './field_compressed_string.js';
10
- export * from './portal_manager.js';
11
- export * from './chain_monitor.js';
1
+ export { generatePublicKey } from './pub_key.js';
2
+ export {
3
+ type AztecAddressLike,
4
+ type EthAddressLike,
5
+ type EventSelectorLike,
6
+ type FieldLike,
7
+ type FunctionSelectorLike,
8
+ type U128Like,
9
+ type WrappedFieldLike,
10
+ } from './abi_types.js';
11
+ export {
12
+ computeAuthWitMessageHash,
13
+ computeInnerAuthWitHash,
14
+ computeInnerAuthWitHashFromAction,
15
+ type IntentAction,
16
+ } from './authwit.js';
17
+ export { waitForPXE } from './pxe.js';
18
+ export { waitForNode, createAztecNodeClient, AztecNode } from './node.js';
19
+ export { readFieldCompressedString } from './field_compressed_string.js';
package/src/utils/node.ts CHANGED
@@ -15,3 +15,5 @@ export const waitForNode = async (node: AztecNode, logger?: Logger) => {
15
15
  return undefined;
16
16
  }, 'RPC Get Node Info');
17
17
  };
18
+
19
+ export { createAztecNodeClient, AztecNode } from '@aztec/circuit-types';
@@ -1,4 +1,4 @@
1
- import { type PXE } from '@aztec/circuit-types';
1
+ import { type PXE } from '@aztec/circuit-types/interfaces';
2
2
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
3
3
 
4
4
  import { type AccountContract } from '../account/contract.js';
@@ -1,3 +0,0 @@
1
- export { deployL1Contract, deployL1Contracts, DeployL1Contracts } from '@aztec/ethereum/deploy-l1-contracts';
2
- export { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
3
- //# sourceMappingURL=ethereum.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../src/api/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,3 +0,0 @@
1
- export { deployL1Contract, deployL1Contracts } from '@aztec/ethereum/deploy-l1-contracts';
2
- export { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXRoZXJldW0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXBpL2V0aGVyZXVtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxpQkFBaUIsRUFBcUIsTUFBTSxxQ0FBcUMsQ0FBQztBQUM3RyxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sZ0NBQWdDLENBQUMifQ==
Binary file
Binary file