@aztec/native 0.0.1-commit.b655e406 → 0.0.1-commit.fce3e4f
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.
- package/dest/index.d.ts +1 -1
- package/dest/msgpack_channel.d.ts +1 -1
- package/dest/msgpack_channel.d.ts.map +1 -1
- package/dest/native_module.d.ts +64 -1
- package/dest/native_module.d.ts.map +1 -1
- package/dest/native_module.js +15 -14
- package/package.json +8 -10
- package/src/native_module.ts +85 -21
- package/build/amd64-linux/nodejs_module.node +0 -0
- package/build/amd64-macos/nodejs_module.node +0 -0
- package/build/arm64-linux/nodejs_module.node +0 -0
- package/build/arm64-macos/nodejs_module.node +0 -0
package/dest/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './native_module.js';
|
|
2
2
|
export { type RoundtripDuration, MsgpackChannel } from './msgpack_channel.js';
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUFFLGNBQWMsRUFBRSxNQUFNLHNCQUFzQixDQUFDIn0=
|
|
@@ -22,4 +22,4 @@ export declare class MsgpackChannel<M extends number = number, Req extends Messa
|
|
|
22
22
|
}>;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
25
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibXNncGFja19jaGFubmVsLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvbXNncGFja19jaGFubmVsLnRzIl0s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yxDQUFDLENBQUE7S0FBRSxDQUFDLENBMEQ3RDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgpack_channel.d.ts","sourceRoot":"","sources":["../src/msgpack_channel.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;CAC9D;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAYF,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI;KAAG,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI;CAAE,CAAC;AAEjE,qBAAa,cAAc,CACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,GAAG,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,EAChC,IAAI,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG;IAYd,OAAO,CAAC,IAAI;IAV/B,mCAAmC;IACnC,OAAO,CAAC,OAAO,CAKZ;IAEH,OAAO,CAAC,KAAK,CAAK;
|
|
1
|
+
{"version":3,"file":"msgpack_channel.d.ts","sourceRoot":"","sources":["../src/msgpack_channel.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;CAC9D;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAYF,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI;KAAG,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI;CAAE,CAAC;AAEjE,qBAAa,cAAc,CACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,GAAG,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,EAChC,IAAI,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG;IAYd,OAAO,CAAC,IAAI;IAV/B,mCAAmC;IACnC,OAAO,CAAC,OAAO,CAKZ;IAEH,OAAO,CAAC,KAAK,CAAK;IAElB,YAA2B,IAAI,EAAE,eAAe,EAAI;IAEvC,WAAW,CAAC,CAAC,SAAS,CAAC,EAClC,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,GACX,OAAO,CAAC;QAAE,QAAQ,EAAE,iBAAiB,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC,CA0D7D;CACF"}
|
package/dest/native_module.d.ts
CHANGED
|
@@ -4,6 +4,69 @@ interface NativeClassCtor {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const NativeWorldState: NativeClassCtor;
|
|
6
6
|
export declare const NativeLMDBStore: NativeClassCtor;
|
|
7
|
+
/**
|
|
8
|
+
* Contract provider interface for callbacks to fetch contract data.
|
|
9
|
+
* These callbacks are invoked by C++ during simulation when contract data is needed.
|
|
10
|
+
*/
|
|
11
|
+
export interface ContractProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Fetch a contract instance by address.
|
|
14
|
+
* @param address - The contract address as a string (hex format)
|
|
15
|
+
* @returns Promise resolving to msgpack-serialized ContractInstanceHint buffer, or undefined if not found
|
|
16
|
+
*/
|
|
17
|
+
getContractInstance(address: string): Promise<Buffer | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Fetch a contract class by class ID.
|
|
20
|
+
* @param classId - The contract class ID as a string (hex format)
|
|
21
|
+
* @returns Promise resolving to msgpack-serialized ContractClassHint buffer, or undefined if not found
|
|
22
|
+
*/
|
|
23
|
+
getContractClass(classId: string): Promise<Buffer | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Add contracts from deployment data.
|
|
26
|
+
* @param contractDeploymentData - Msgpack-serialized ContractDeploymentData buffer
|
|
27
|
+
* @returns Promise that resolves when contracts are added
|
|
28
|
+
*/
|
|
29
|
+
addContracts(contractDeploymentData: Buffer): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Fetch the bytecode commitment for a contract class.
|
|
32
|
+
* @param classId - The contract class ID as a string (hex format)
|
|
33
|
+
* @returns Promise resolving to msgpack-serialized Fr buffer, or undefined if not found
|
|
34
|
+
*/
|
|
35
|
+
getBytecodeCommitment(classId: string): Promise<Buffer | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch the debug function name for a contract function.
|
|
38
|
+
* @param address - The contract address as a string (hex format)
|
|
39
|
+
* @param selector - The function selector as a string (hex format)
|
|
40
|
+
* @returns Promise resolving to function name string, or undefined if not found
|
|
41
|
+
*/
|
|
42
|
+
getDebugFunctionName(address: string, selector: string): Promise<string | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new checkpoint for the contract database state.
|
|
45
|
+
* Enables rollback to current state in case of a revert.
|
|
46
|
+
* @returns Promise that resolves when checkpoint is created
|
|
47
|
+
*/
|
|
48
|
+
createCheckpoint(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Commit the current checkpoint, accepting its state as latest.
|
|
51
|
+
* @returns Promise that resolves when checkpoint is committed
|
|
52
|
+
*/
|
|
53
|
+
commitCheckpoint(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Revert the current checkpoint, discarding its state and rolling back.
|
|
56
|
+
* @returns Promise that resolves when checkpoint is reverted
|
|
57
|
+
*/
|
|
58
|
+
revertCheckpoint(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* AVM simulation function that takes serialized inputs and a contract provider.
|
|
62
|
+
* The contract provider enables C++ to callback to TypeScript for contract data during simulation.
|
|
63
|
+
* @param inputs - Msgpack-serialized AvmFastSimulationInputs buffer
|
|
64
|
+
* @param contractProvider - Object with callbacks for fetching contract instances and classes
|
|
65
|
+
* @param worldStateHandle - Native handle to WorldState instance
|
|
66
|
+
* TODO(MW): include generate_hints bool
|
|
67
|
+
* @returns Promise resolving to msgpack-serialized AvmCircuitPublicInputs buffer
|
|
68
|
+
*/
|
|
69
|
+
export declare const avmSimulate: (inputs: Buffer, contractProvider: ContractProvider, worldStateHandle: any) => Promise<Buffer>;
|
|
7
70
|
/**
|
|
8
71
|
* AVM simulation function that uses pre-collected hints from TypeScript simulation.
|
|
9
72
|
* All contract data and merkle tree hints are included in the AvmCircuitInputs, so no runtime
|
|
@@ -13,4 +76,4 @@ export declare const NativeLMDBStore: NativeClassCtor;
|
|
|
13
76
|
*/
|
|
14
77
|
export declare const avmSimulateWithHintedDbs: (inputs: Buffer) => Promise<Buffer>;
|
|
15
78
|
export {};
|
|
16
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF0aXZlX21vZHVsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL25hdGl2ZV9tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFNUQsVUFBVSxlQUFlO0lBQ3ZCLEtBQUssR0FBRyxJQUFJLEVBQUUsT0FBTyxFQUFFLEdBQUcsZUFBZSxDQUFDO0NBQzNDO0FBYUQsZUFBTyxNQUFNLGdCQUFnQixFQUFFLGVBQTRELENBQUM7QUFDNUYsZUFBTyxNQUFNLGVBQWUsRUFBRSxlQUEyRCxDQUFDO0FBRTFGOzs7R0FHRztBQUNILE1BQU0sV0FBVyxnQkFBZ0I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NILGVBQU8sTUFBTSx3QkFBd0IsRUFBRSxDQUFDLE1BQU0sRUFBRSxNQUFNLEtBQUssT0FBTyxDQUFDLE1BQU0sQ0FFckQsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native_module.d.ts","sourceRoot":"","sources":["../src/native_module.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,UAAU,eAAe;IACvB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"native_module.d.ts","sourceRoot":"","sources":["../src/native_module.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,UAAU,eAAe;IACvB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;CAC3C;AAaD,eAAO,MAAM,gBAAgB,EAAE,eAA4D,CAAC;AAC5F,eAAO,MAAM,eAAe,EAAE,eAA2D,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClE;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAE/D;;;;OAIG;IACH,YAAY,CAAC,sBAAsB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;OAIG;IACH,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEpE;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAErF;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;OAGG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;OAGG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,CACxB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,GAAG,KAClB,OAAO,CAAC,MAAM,CAIC,CAAC;AACrB;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAErD,CAAC"}
|
package/dest/native_module.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
import { findNapiBinary } from '@aztec/bb.js';
|
|
1
2
|
import { createRequire } from 'module';
|
|
2
|
-
import { dirname, join } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
3
|
function loadNativeModule() {
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const platform = process.platform === 'darwin' ? 'macos' : process.platform;
|
|
10
|
-
const variant = `${arch}-${platform}`;
|
|
11
|
-
const modulePath = join(__dirname, '..', 'build', variant, 'nodejs_module.node');
|
|
12
|
-
try {
|
|
13
|
-
const require = createRequire(import.meta.url);
|
|
14
|
-
return require(modulePath);
|
|
15
|
-
} catch (error) {
|
|
16
|
-
throw new Error(`Failed to load native module for ${variant} from ${modulePath}. ` + `Supported: amd64-linux, arm64-linux, amd64-macos, arm64-macos. ` + `Error: ${error}`);
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const napiPath = findNapiBinary();
|
|
6
|
+
if (!napiPath) {
|
|
7
|
+
throw new Error('NAPI binary not found for current platform.');
|
|
17
8
|
}
|
|
9
|
+
return require(napiPath);
|
|
18
10
|
}
|
|
19
11
|
const nativeModule = loadNativeModule();
|
|
20
12
|
export const NativeWorldState = nativeModule.WorldState;
|
|
21
13
|
export const NativeLMDBStore = nativeModule.LMDBStore;
|
|
14
|
+
/**
|
|
15
|
+
* AVM simulation function that takes serialized inputs and a contract provider.
|
|
16
|
+
* The contract provider enables C++ to callback to TypeScript for contract data during simulation.
|
|
17
|
+
* @param inputs - Msgpack-serialized AvmFastSimulationInputs buffer
|
|
18
|
+
* @param contractProvider - Object with callbacks for fetching contract instances and classes
|
|
19
|
+
* @param worldStateHandle - Native handle to WorldState instance
|
|
20
|
+
* TODO(MW): include generate_hints bool
|
|
21
|
+
* @returns Promise resolving to msgpack-serialized AvmCircuitPublicInputs buffer
|
|
22
|
+
*/ export const avmSimulate = nativeModule.avmSimulate;
|
|
22
23
|
/**
|
|
23
24
|
* AVM simulation function that uses pre-collected hints from TypeScript simulation.
|
|
24
25
|
* All contract data and merkle tree hints are included in the AvmCircuitInputs, so no runtime
|
package/package.json
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/native",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.fce3e4f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "yarn clean &&
|
|
10
|
-
"build:dev": "
|
|
11
|
-
"build:cpp": "PROJECT=$(pwd); cd $(git rev-parse --show-toplevel)/barretenberg/cpp; cmake --preset ${PRESET:-clang16-pic} && cmake --build --preset ${PRESET:-clang16-pic} --target nodejs_module && cd $PROJECT && yarn generate",
|
|
12
|
-
"clean:cpp": "rm -rf $(git rev-parse --show-toplevel)/barretenberg/cpp/build-pic",
|
|
9
|
+
"build": "yarn clean && tsgo -b",
|
|
10
|
+
"build:dev": "tsgo -b --watch",
|
|
13
11
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
14
|
-
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
15
|
-
"generate": "bash scripts/copy_modules.sh"
|
|
12
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
16
13
|
},
|
|
17
14
|
"inherits": [
|
|
18
|
-
"../package.common.json"
|
|
19
|
-
"./package.local.json"
|
|
15
|
+
"../package.common.json"
|
|
20
16
|
],
|
|
21
17
|
"dependencies": {
|
|
22
|
-
"@aztec/
|
|
18
|
+
"@aztec/bb.js": "0.0.1-commit.fce3e4f",
|
|
19
|
+
"@aztec/foundation": "0.0.1-commit.fce3e4f",
|
|
23
20
|
"msgpackr": "^1.11.2"
|
|
24
21
|
},
|
|
25
22
|
"devDependencies": {
|
|
26
23
|
"@jest/globals": "^30.0.0",
|
|
27
24
|
"@types/jest": "^30.0.0",
|
|
28
25
|
"@types/node": "^22.15.17",
|
|
26
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
29
27
|
"jest": "^30.0.0",
|
|
30
28
|
"ts-node": "^10.9.1",
|
|
31
29
|
"typescript": "^5.3.3"
|
package/src/native_module.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { findNapiBinary } from '@aztec/bb.js';
|
|
2
|
+
|
|
1
3
|
import { createRequire } from 'module';
|
|
2
|
-
import { dirname, join } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
5
|
import type { MessageReceiver } from './msgpack_channel.js';
|
|
6
6
|
|
|
@@ -9,26 +9,12 @@ interface NativeClassCtor {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function loadNativeModule(): Record<string, NativeClassCtor> {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
|
|
17
|
-
const platform = process.platform === 'darwin' ? 'macos' : process.platform;
|
|
18
|
-
const variant = `${arch}-${platform}`;
|
|
19
|
-
|
|
20
|
-
const modulePath = join(__dirname, '..', 'build', variant, 'nodejs_module.node');
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const require = createRequire(import.meta.url);
|
|
24
|
-
return require(modulePath);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Failed to load native module for ${variant} from ${modulePath}. ` +
|
|
28
|
-
`Supported: amd64-linux, arm64-linux, amd64-macos, arm64-macos. ` +
|
|
29
|
-
`Error: ${error}`,
|
|
30
|
-
);
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const napiPath = findNapiBinary();
|
|
14
|
+
if (!napiPath) {
|
|
15
|
+
throw new Error('NAPI binary not found for current platform.');
|
|
31
16
|
}
|
|
17
|
+
return require(napiPath);
|
|
32
18
|
}
|
|
33
19
|
|
|
34
20
|
const nativeModule: Record<string, NativeClassCtor | Function> = loadNativeModule();
|
|
@@ -36,6 +22,84 @@ const nativeModule: Record<string, NativeClassCtor | Function> = loadNativeModul
|
|
|
36
22
|
export const NativeWorldState: NativeClassCtor = nativeModule.WorldState as NativeClassCtor;
|
|
37
23
|
export const NativeLMDBStore: NativeClassCtor = nativeModule.LMDBStore as NativeClassCtor;
|
|
38
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Contract provider interface for callbacks to fetch contract data.
|
|
27
|
+
* These callbacks are invoked by C++ during simulation when contract data is needed.
|
|
28
|
+
*/
|
|
29
|
+
export interface ContractProvider {
|
|
30
|
+
/**
|
|
31
|
+
* Fetch a contract instance by address.
|
|
32
|
+
* @param address - The contract address as a string (hex format)
|
|
33
|
+
* @returns Promise resolving to msgpack-serialized ContractInstanceHint buffer, or undefined if not found
|
|
34
|
+
*/
|
|
35
|
+
getContractInstance(address: string): Promise<Buffer | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch a contract class by class ID.
|
|
38
|
+
* @param classId - The contract class ID as a string (hex format)
|
|
39
|
+
* @returns Promise resolving to msgpack-serialized ContractClassHint buffer, or undefined if not found
|
|
40
|
+
*/
|
|
41
|
+
getContractClass(classId: string): Promise<Buffer | undefined>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Add contracts from deployment data.
|
|
45
|
+
* @param contractDeploymentData - Msgpack-serialized ContractDeploymentData buffer
|
|
46
|
+
* @returns Promise that resolves when contracts are added
|
|
47
|
+
*/
|
|
48
|
+
addContracts(contractDeploymentData: Buffer): Promise<void>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Fetch the bytecode commitment for a contract class.
|
|
52
|
+
* @param classId - The contract class ID as a string (hex format)
|
|
53
|
+
* @returns Promise resolving to msgpack-serialized Fr buffer, or undefined if not found
|
|
54
|
+
*/
|
|
55
|
+
getBytecodeCommitment(classId: string): Promise<Buffer | undefined>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Fetch the debug function name for a contract function.
|
|
59
|
+
* @param address - The contract address as a string (hex format)
|
|
60
|
+
* @param selector - The function selector as a string (hex format)
|
|
61
|
+
* @returns Promise resolving to function name string, or undefined if not found
|
|
62
|
+
*/
|
|
63
|
+
getDebugFunctionName(address: string, selector: string): Promise<string | undefined>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Create a new checkpoint for the contract database state.
|
|
67
|
+
* Enables rollback to current state in case of a revert.
|
|
68
|
+
* @returns Promise that resolves when checkpoint is created
|
|
69
|
+
*/
|
|
70
|
+
createCheckpoint(): Promise<void>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Commit the current checkpoint, accepting its state as latest.
|
|
74
|
+
* @returns Promise that resolves when checkpoint is committed
|
|
75
|
+
*/
|
|
76
|
+
commitCheckpoint(): Promise<void>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Revert the current checkpoint, discarding its state and rolling back.
|
|
80
|
+
* @returns Promise that resolves when checkpoint is reverted
|
|
81
|
+
*/
|
|
82
|
+
revertCheckpoint(): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* AVM simulation function that takes serialized inputs and a contract provider.
|
|
87
|
+
* The contract provider enables C++ to callback to TypeScript for contract data during simulation.
|
|
88
|
+
* @param inputs - Msgpack-serialized AvmFastSimulationInputs buffer
|
|
89
|
+
* @param contractProvider - Object with callbacks for fetching contract instances and classes
|
|
90
|
+
* @param worldStateHandle - Native handle to WorldState instance
|
|
91
|
+
* TODO(MW): include generate_hints bool
|
|
92
|
+
* @returns Promise resolving to msgpack-serialized AvmCircuitPublicInputs buffer
|
|
93
|
+
*/
|
|
94
|
+
export const avmSimulate: (
|
|
95
|
+
inputs: Buffer,
|
|
96
|
+
contractProvider: ContractProvider,
|
|
97
|
+
worldStateHandle: any,
|
|
98
|
+
) => Promise<Buffer> = nativeModule.avmSimulate as (
|
|
99
|
+
inputs: Buffer,
|
|
100
|
+
contractProvider: ContractProvider,
|
|
101
|
+
worldStateHandle: any,
|
|
102
|
+
) => Promise<Buffer>;
|
|
39
103
|
/**
|
|
40
104
|
* AVM simulation function that uses pre-collected hints from TypeScript simulation.
|
|
41
105
|
* All contract data and merkle tree hints are included in the AvmCircuitInputs, so no runtime
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|