@aztec/pxe 0.28.0 → 0.29.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 (43) hide show
  1. package/dest/contract_data_oracle/index.d.ts +23 -9
  2. package/dest/contract_data_oracle/index.d.ts.map +1 -1
  3. package/dest/contract_data_oracle/index.js +55 -39
  4. package/dest/contract_data_oracle/private_functions_tree.d.ts +7 -15
  5. package/dest/contract_data_oracle/private_functions_tree.d.ts.map +1 -1
  6. package/dest/contract_data_oracle/private_functions_tree.js +10 -15
  7. package/dest/database/contracts/contract_instance_db.d.ts +2 -0
  8. package/dest/database/contracts/contract_instance_db.d.ts.map +1 -1
  9. package/dest/database/kv_pxe_database.d.ts +3 -4
  10. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  11. package/dest/database/kv_pxe_database.js +16 -17
  12. package/dest/database/pxe_database.d.ts +5 -2
  13. package/dest/database/pxe_database.d.ts.map +1 -1
  14. package/dest/kernel_oracle/index.d.ts +1 -0
  15. package/dest/kernel_oracle/index.d.ts.map +1 -1
  16. package/dest/kernel_prover/kernel_prover.js +4 -4
  17. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  18. package/dest/pxe_http/pxe_http_server.js +2 -4
  19. package/dest/pxe_service/pxe_service.d.ts +2 -4
  20. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  21. package/dest/pxe_service/pxe_service.js +17 -32
  22. package/dest/pxe_service/test/pxe_test_suite.js +2 -2
  23. package/dest/simulator_oracle/index.d.ts.map +1 -1
  24. package/dest/simulator_oracle/index.js +6 -13
  25. package/package.json +12 -12
  26. package/src/contract_data_oracle/index.ts +63 -50
  27. package/src/contract_data_oracle/private_functions_tree.ts +12 -17
  28. package/src/database/contracts/contract_instance_db.ts +3 -0
  29. package/src/database/kv_pxe_database.ts +17 -17
  30. package/src/database/pxe_database.ts +6 -2
  31. package/src/kernel_prover/kernel_prover.ts +3 -3
  32. package/src/pxe_http/pxe_http_server.ts +0 -4
  33. package/src/pxe_service/pxe_service.ts +20 -36
  34. package/src/pxe_service/test/pxe_test_suite.ts +1 -1
  35. package/src/simulator_oracle/index.ts +5 -14
  36. package/dest/contract_database/index.d.ts +0 -2
  37. package/dest/contract_database/index.d.ts.map +0 -1
  38. package/dest/contract_database/index.js +0 -2
  39. package/dest/contract_database/memory_contract_database.d.ts +0 -43
  40. package/dest/contract_database/memory_contract_database.d.ts.map +0 -1
  41. package/dest/contract_database/memory_contract_database.js +0 -51
  42. package/src/contract_database/index.ts +0 -1
  43. package/src/contract_database/memory_contract_database.ts +0 -58
@@ -1,51 +0,0 @@
1
- /**
2
- * The MemoryContractDatabase class serves as an in-memory implementation of the ContractDatabase interface.
3
- * It allows for storing and retrieving contract data, such as ContractDao objects and associated function bytecodes,
4
- * within a contracts array. This class is particularly useful for testing and development purposes where a
5
- * persistent storage may not be required.
6
- */
7
- export class MemoryContractDatabase {
8
- constructor(log) {
9
- this.log = log;
10
- this.contracts = [];
11
- }
12
- /**
13
- * Adds a new ContractDao instance to the memory-based contract database.
14
- * The function stores the contract in an array and returns a resolved promise indicating successful addition.
15
- *
16
- * @param contract - The ContractDao instance to be added to the memory database.
17
- * @returns A Promise that resolves when the contract is successfully added.
18
- */
19
- addContract(contract) {
20
- this.log(`Adding contract ${contract.instance.address.toString()}`);
21
- this.contracts.push(contract);
22
- return Promise.resolve();
23
- }
24
- /**
25
- * Retrieve a ContractDao instance with the specified AztecAddress from the in-memory contracts list.
26
- * Returns the first match found or undefined if no contract with the given address is found.
27
- *
28
- * @param address - The AztecAddress to search for in the stored contracts.
29
- * @returns A Promise resolving to the ContractDao instance matching the given address or undefined.
30
- */
31
- getContract(address) {
32
- return Promise.resolve(this.contracts.find(c => c.instance.address.equals(address)));
33
- }
34
- getContracts() {
35
- return Promise.resolve(this.contracts);
36
- }
37
- /**
38
- * Retrieve the bytecode associated with a given contract address and function selector.
39
- * This function searches through the stored contracts to find a matching contract and function,
40
- * then returns the corresponding bytecode. If no match is found, it returns undefined.
41
- *
42
- * @param contractAddress - The AztecAddress representing the contract address to look for.
43
- * @param selector - The function selector.
44
- * @returns A Promise that resolves to the bytecode of the matching function or undefined if not found.
45
- */
46
- async getCode(contractAddress, selector) {
47
- const contract = await this.getContract(contractAddress);
48
- return contract?.functions.find(f => f.selector.equals(selector))?.bytecode;
49
- }
50
- }
51
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVtb3J5X2NvbnRyYWN0X2RhdGFiYXNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2RhdGFiYXNlL21lbW9yeV9jb250cmFjdF9kYXRhYmFzZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQTs7Ozs7R0FLRztBQUNILE1BQU0sT0FBTyxzQkFBc0I7SUFHakMsWUFBc0IsR0FBZ0I7UUFBaEIsUUFBRyxHQUFILEdBQUcsQ0FBYTtRQUY5QixjQUFTLEdBQWtCLEVBQUUsQ0FBQztJQUVHLENBQUM7SUFFMUM7Ozs7OztPQU1HO0lBQ0ksV0FBVyxDQUFDLFFBQXFCO1FBQ3RDLElBQUksQ0FBQyxHQUFHLENBQUMsbUJBQW1CLFFBQVEsQ0FBQyxRQUFRLENBQUMsT0FBTyxDQUFDLFFBQVEsRUFBRSxFQUFFLENBQUMsQ0FBQztRQUNwRSxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztRQUM5QixPQUFPLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBRUQ7Ozs7OztPQU1HO0lBQ0ksV0FBVyxDQUFDLE9BQXFCO1FBQ3RDLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDdkYsQ0FBQztJQUVNLFlBQVk7UUFDakIsT0FBTyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUN6QyxDQUFDO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDSSxLQUFLLENBQUMsT0FBTyxDQUFDLGVBQTZCLEVBQUUsUUFBMEI7UUFDNUUsTUFBTSxRQUFRLEdBQUcsTUFBTSxJQUFJLENBQUMsV0FBVyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ3pELE9BQU8sUUFBUSxFQUFFLFNBQVMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLFFBQVEsQ0FBQztJQUM5RSxDQUFDO0NBQ0YifQ==
@@ -1 +0,0 @@
1
- export * from './memory_contract_database.js';
@@ -1,58 +0,0 @@
1
- import { ContractDao, ContractDatabase } from '@aztec/circuit-types';
2
- import { FunctionSelector } from '@aztec/circuits.js';
3
- import { AztecAddress } from '@aztec/foundation/aztec-address';
4
- import { DebugLogger } from '@aztec/foundation/log';
5
-
6
- /**
7
- * The MemoryContractDatabase class serves as an in-memory implementation of the ContractDatabase interface.
8
- * It allows for storing and retrieving contract data, such as ContractDao objects and associated function bytecodes,
9
- * within a contracts array. This class is particularly useful for testing and development purposes where a
10
- * persistent storage may not be required.
11
- */
12
- export class MemoryContractDatabase implements ContractDatabase {
13
- private contracts: ContractDao[] = [];
14
-
15
- constructor(protected log: DebugLogger) {}
16
-
17
- /**
18
- * Adds a new ContractDao instance to the memory-based contract database.
19
- * The function stores the contract in an array and returns a resolved promise indicating successful addition.
20
- *
21
- * @param contract - The ContractDao instance to be added to the memory database.
22
- * @returns A Promise that resolves when the contract is successfully added.
23
- */
24
- public addContract(contract: ContractDao) {
25
- this.log(`Adding contract ${contract.instance.address.toString()}`);
26
- this.contracts.push(contract);
27
- return Promise.resolve();
28
- }
29
-
30
- /**
31
- * Retrieve a ContractDao instance with the specified AztecAddress from the in-memory contracts list.
32
- * Returns the first match found or undefined if no contract with the given address is found.
33
- *
34
- * @param address - The AztecAddress to search for in the stored contracts.
35
- * @returns A Promise resolving to the ContractDao instance matching the given address or undefined.
36
- */
37
- public getContract(address: AztecAddress): Promise<ContractDao | undefined> {
38
- return Promise.resolve(this.contracts.find(c => c.instance.address.equals(address)));
39
- }
40
-
41
- public getContracts(): Promise<ContractDao[]> {
42
- return Promise.resolve(this.contracts);
43
- }
44
-
45
- /**
46
- * Retrieve the bytecode associated with a given contract address and function selector.
47
- * This function searches through the stored contracts to find a matching contract and function,
48
- * then returns the corresponding bytecode. If no match is found, it returns undefined.
49
- *
50
- * @param contractAddress - The AztecAddress representing the contract address to look for.
51
- * @param selector - The function selector.
52
- * @returns A Promise that resolves to the bytecode of the matching function or undefined if not found.
53
- */
54
- public async getCode(contractAddress: AztecAddress, selector: FunctionSelector) {
55
- const contract = await this.getContract(contractAddress);
56
- return contract?.functions.find(f => f.selector.equals(selector))?.bytecode;
57
- }
58
- }