@noir-lang/noir_codegen 1.0.0-beta.7-d692001.nightly → 1.0.0-beta.7-077bb6d.nightly
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.
|
@@ -58,7 +58,7 @@ export type AbiTypeWithGenerics = {
|
|
|
58
58
|
* Maps an ABI type to an ABI type with generics.
|
|
59
59
|
* This performs pure type conversion, and does not generate any bindings.
|
|
60
60
|
*/
|
|
61
|
-
export declare function mapAbiTypeToAbiTypeWithGenerics(abiType: AbiType
|
|
61
|
+
export declare function mapAbiTypeToAbiTypeWithGenerics(abiType: AbiType): AbiTypeWithGenerics;
|
|
62
62
|
/**
|
|
63
63
|
* Finds the structs in an ABI type.
|
|
64
64
|
* This won't explore nested structs.
|
|
@@ -13,60 +13,44 @@ export class BindingId {
|
|
|
13
13
|
* Maps an ABI type to an ABI type with generics.
|
|
14
14
|
* This performs pure type conversion, and does not generate any bindings.
|
|
15
15
|
*/
|
|
16
|
-
export function mapAbiTypeToAbiTypeWithGenerics(abiType
|
|
17
|
-
let returnedType;
|
|
16
|
+
export function mapAbiTypeToAbiTypeWithGenerics(abiType) {
|
|
18
17
|
switch (abiType.kind) {
|
|
19
18
|
case 'field':
|
|
20
19
|
case 'boolean':
|
|
21
20
|
case 'string':
|
|
22
21
|
case 'integer':
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const type = mapAbiTypeToAbiTypeWithGenerics(abiType.type, allTypes);
|
|
27
|
-
returnedType = {
|
|
22
|
+
return abiType;
|
|
23
|
+
case 'array':
|
|
24
|
+
return {
|
|
28
25
|
kind: 'array',
|
|
29
26
|
length: abiType.length,
|
|
30
|
-
type,
|
|
27
|
+
type: mapAbiTypeToAbiTypeWithGenerics(abiType.type),
|
|
31
28
|
};
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
29
|
case 'struct': {
|
|
35
30
|
const structType = {
|
|
36
31
|
path: abiType.path,
|
|
37
|
-
fields: abiType.fields.map(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
type,
|
|
42
|
-
};
|
|
43
|
-
}),
|
|
32
|
+
fields: abiType.fields.map((field) => ({
|
|
33
|
+
name: field.name,
|
|
34
|
+
type: mapAbiTypeToAbiTypeWithGenerics(field.type),
|
|
35
|
+
})),
|
|
44
36
|
generics: [],
|
|
45
37
|
};
|
|
46
|
-
|
|
38
|
+
return {
|
|
47
39
|
kind: 'struct',
|
|
48
40
|
structType,
|
|
49
41
|
args: [],
|
|
50
42
|
};
|
|
51
|
-
break;
|
|
52
43
|
}
|
|
53
44
|
case 'tuple':
|
|
54
|
-
|
|
45
|
+
return {
|
|
55
46
|
kind: 'tuple',
|
|
56
|
-
fields: abiType.fields.map(
|
|
57
|
-
const type = mapAbiTypeToAbiTypeWithGenerics(field, allTypes);
|
|
58
|
-
allTypes.push(type);
|
|
59
|
-
return type;
|
|
60
|
-
}),
|
|
47
|
+
fields: abiType.fields.map(mapAbiTypeToAbiTypeWithGenerics),
|
|
61
48
|
};
|
|
62
|
-
break;
|
|
63
49
|
default: {
|
|
64
50
|
const exhaustiveCheck = abiType;
|
|
65
51
|
throw new Error(`Unhandled abi type: ${exhaustiveCheck}`);
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
|
-
allTypes.push(returnedType);
|
|
69
|
-
return returnedType;
|
|
70
54
|
}
|
|
71
55
|
/**
|
|
72
56
|
* Finds the structs in an ABI type.
|
|
@@ -58,11 +58,13 @@ export class TypingsGenerator {
|
|
|
58
58
|
// Map all the types used in the ABIs to the demonomorphized types
|
|
59
59
|
for (const { abi, circuitName, artifact } of circuits) {
|
|
60
60
|
const params = abi.parameters.map((param) => {
|
|
61
|
-
const type = mapAbiTypeToAbiTypeWithGenerics(param.type
|
|
61
|
+
const type = mapAbiTypeToAbiTypeWithGenerics(param.type);
|
|
62
|
+
this.allTypes.push(type);
|
|
62
63
|
return { name: param.name, type };
|
|
63
64
|
});
|
|
64
65
|
if (abi.return_type) {
|
|
65
|
-
const returnType = mapAbiTypeToAbiTypeWithGenerics(abi.return_type.abi_type
|
|
66
|
+
const returnType = mapAbiTypeToAbiTypeWithGenerics(abi.return_type.abi_type);
|
|
67
|
+
this.allTypes.push(returnType);
|
|
66
68
|
this.demonomorphizedAbis.push({ circuitName, params, returnType, artifact });
|
|
67
69
|
}
|
|
68
70
|
else {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"contributors": [
|
|
4
4
|
"The Noir Team <team@noir-lang.org>"
|
|
5
5
|
],
|
|
6
|
-
"version": "1.0.0-beta.7-
|
|
6
|
+
"version": "1.0.0-beta.7-077bb6d.nightly",
|
|
7
7
|
"packageManager": "yarn@4.5.2",
|
|
8
8
|
"license": "(MIT OR Apache-2.0)",
|
|
9
9
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"url": "https://github.com/noir-lang/noir/issues"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@noir-lang/types": "1.0.0-beta.7-
|
|
20
|
+
"@noir-lang/types": "1.0.0-beta.7-077bb6d.nightly",
|
|
21
21
|
"glob": "^11.0.2",
|
|
22
22
|
"ts-command-line-args": "^2.5.1"
|
|
23
23
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dev": "tsc-multi --watch",
|
|
36
36
|
"build": "tsc",
|
|
37
37
|
"test": "yarn test:codegen && yarn test:node && yarn test:clean",
|
|
38
|
-
"test:codegen": "${NARGO:-nargo} export --program-dir=./test/test_lib && tsx src/main.ts ./test/test_lib/export/** --out-dir ./test/codegen",
|
|
38
|
+
"test:codegen": "rm -rf ./test/test_lib/export && ${NARGO:-nargo} export --program-dir=./test/test_lib && tsx src/main.ts ./test/test_lib/export/** --out-dir ./test/codegen",
|
|
39
39
|
"test:node": "mocha --timeout 25000 --exit --config ./.mocharc.json",
|
|
40
40
|
"test:clean": "rm -rf ./test/codegen ./test/test_lib/export",
|
|
41
41
|
"prettier": "prettier 'src/**/*.ts'",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"clean": "rm -rf ./lib"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@noir-lang/noir_js": "1.0.0-beta.7-
|
|
49
|
+
"@noir-lang/noir_js": "1.0.0-beta.7-077bb6d.nightly",
|
|
50
50
|
"@types/chai": "^4",
|
|
51
51
|
"@types/mocha": "^10.0.10",
|
|
52
52
|
"@types/node": "^22.13.10",
|