@noir-lang/noirc_abi 0.16.0 → 0.17.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.
@@ -1,18 +1,50 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {any} abi
5
- * @param {any} inputs
6
- * @param {any} return_value
4
+ * @param {Abi} abi
5
+ * @param {InputMap} inputs
6
+ * @param {InputValue | undefined} return_value
7
7
  * @returns {WitnessMap}
8
8
  */
9
- export function abiEncode(abi: any, inputs: any, return_value: any): WitnessMap;
9
+ export function abiEncode(abi: Abi, inputs: InputMap, return_value?: InputValue): WitnessMap;
10
10
  /**
11
- * @param {any} abi
11
+ * @param {Abi} abi
12
12
  * @param {WitnessMap} witness_map
13
13
  * @returns {any}
14
14
  */
15
- export function abiDecode(abi: any, witness_map: WitnessMap): any;
15
+ export function abiDecode(abi: Abi, witness_map: WitnessMap): any;
16
+
17
+ export type Field = string | number | boolean;
18
+ export type InputValue = Field | Field[] | InputMap;
19
+ export type InputMap = { [key: string]: InputValue };
20
+
21
+
22
+
23
+ export type Visibility = "public" | "private";
24
+ export type Sign = "unsigned" | "signed";
25
+ export type AbiType =
26
+ { kind: "field" } |
27
+ { kind: "boolean" } |
28
+ { kind: "string", length: number } |
29
+ { kind: "integer", sign: Sign, width: number } |
30
+ { kind: "array", length: number, type: AbiType } |
31
+ { kind: "tuple", fields: AbiType[] } |
32
+ { kind: "struct", path: string, fields: [string, AbiType][] };
33
+
34
+ export type AbiParameter = {
35
+ name: string,
36
+ type: AbiType,
37
+ visibility: Visibility,
38
+ };
39
+
40
+ export type Abi = {
41
+ parameters: AbiParameter[],
42
+ param_witnesses: Record<string, number[]>,
43
+ return_type: AbiType | null,
44
+ return_witnesses: number[],
45
+ }
46
+
47
+
16
48
 
17
49
  // Map from witness index to hex string value of witness.
18
50
  export type WitnessMap = Map<number, string>;
@@ -9,28 +9,6 @@ heap.push(undefined, null, true, false);
9
9
 
10
10
  function getObject(idx) { return heap[idx]; }
11
11
 
12
- function isLikeNone(x) {
13
- return x === undefined || x === null;
14
- }
15
-
16
- let cachedFloat64Memory0 = null;
17
-
18
- function getFloat64Memory0() {
19
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
20
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
21
- }
22
- return cachedFloat64Memory0;
23
- }
24
-
25
- let cachedInt32Memory0 = null;
26
-
27
- function getInt32Memory0() {
28
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
29
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
30
- }
31
- return cachedInt32Memory0;
32
- }
33
-
34
12
  let heap_next = heap.length;
35
13
 
36
14
  function dropObject(idx) {
@@ -118,6 +96,28 @@ function passStringToWasm0(arg, malloc, realloc) {
118
96
  return ptr;
119
97
  }
120
98
 
99
+ function isLikeNone(x) {
100
+ return x === undefined || x === null;
101
+ }
102
+
103
+ let cachedInt32Memory0 = null;
104
+
105
+ function getInt32Memory0() {
106
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
107
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
108
+ }
109
+ return cachedInt32Memory0;
110
+ }
111
+
112
+ let cachedFloat64Memory0 = null;
113
+
114
+ function getFloat64Memory0() {
115
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
116
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
117
+ }
118
+ return cachedFloat64Memory0;
119
+ }
120
+
121
121
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
122
122
 
123
123
  cachedTextDecoder.decode();
@@ -127,15 +127,15 @@ function getStringFromWasm0(ptr, len) {
127
127
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
128
128
  }
129
129
  /**
130
- * @param {any} abi
131
- * @param {any} inputs
132
- * @param {any} return_value
130
+ * @param {Abi} abi
131
+ * @param {InputMap} inputs
132
+ * @param {InputValue | undefined} return_value
133
133
  * @returns {WitnessMap}
134
134
  */
135
135
  module.exports.abiEncode = function(abi, inputs, return_value) {
136
136
  try {
137
137
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
138
- wasm.abiEncode(retptr, addHeapObject(abi), addHeapObject(inputs), addHeapObject(return_value));
138
+ wasm.abiEncode(retptr, addHeapObject(abi), addHeapObject(inputs), isLikeNone(return_value) ? 0 : addHeapObject(return_value));
139
139
  var r0 = getInt32Memory0()[retptr / 4 + 0];
140
140
  var r1 = getInt32Memory0()[retptr / 4 + 1];
141
141
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -149,7 +149,7 @@ module.exports.abiEncode = function(abi, inputs, return_value) {
149
149
  };
150
150
 
151
151
  /**
152
- * @param {any} abi
152
+ * @param {Abi} abi
153
153
  * @param {WitnessMap} witness_map
154
154
  * @returns {any}
155
155
  */
@@ -169,8 +169,8 @@ module.exports.abiDecode = function(abi, witness_map) {
169
169
  }
170
170
  };
171
171
 
172
- function __wbg_adapter_28(arg0, arg1, arg2, arg3) {
173
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h640c0c6add9d0132(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
172
+ function __wbg_adapter_26(arg0, arg1, arg2, arg3) {
173
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h345d08f7c40b28d9(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
174
174
  }
175
175
 
176
176
  function handleError(f, args) {
@@ -181,18 +181,16 @@ function handleError(f, args) {
181
181
  }
182
182
  }
183
183
 
184
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
185
- const obj = getObject(arg1);
186
- const ret = typeof(obj) === 'number' ? obj : undefined;
187
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
188
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
189
- };
190
-
191
184
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
192
185
  takeObject(arg0);
193
186
  };
194
187
 
195
- module.exports.__wbg_new_b88faf1d36aaeaaf = function() {
188
+ module.exports.__wbg_constructor_8b80183f1e67730f = function(arg0) {
189
+ const ret = new Error(takeObject(arg0));
190
+ return addHeapObject(ret);
191
+ };
192
+
193
+ module.exports.__wbg_new_31288a3fdd8270cf = function() {
196
194
  const ret = new Map();
197
195
  return addHeapObject(ret);
198
196
  };
@@ -211,9 +209,11 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
211
209
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
212
210
  };
213
211
 
214
- module.exports.__wbg_constructor_ee715a20a6d6befb = function(arg0) {
215
- const ret = new Error(takeObject(arg0));
216
- return addHeapObject(ret);
212
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
213
+ const obj = getObject(arg1);
214
+ const ret = typeof(obj) === 'number' ? obj : undefined;
215
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
216
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
217
217
  };
218
218
 
219
219
  module.exports.__wbindgen_is_undefined = function(arg0) {
@@ -221,11 +221,6 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
221
221
  return ret;
222
222
  };
223
223
 
224
- module.exports.__wbindgen_is_null = function(arg0) {
225
- const ret = getObject(arg0) === null;
226
- return ret;
227
- };
228
-
229
224
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
230
225
  const ret = new Error();
231
226
  return addHeapObject(ret);
@@ -263,7 +258,7 @@ module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
263
258
  const a = state0.a;
264
259
  state0.a = 0;
265
260
  try {
266
- return __wbg_adapter_28(a, state0.b, arg0, arg1);
261
+ return __wbg_adapter_26(a, state0.b, arg0, arg1);
267
262
  } finally {
268
263
  state0.a = a;
269
264
  }
Binary file
@@ -7,5 +7,5 @@ export function __wbindgen_malloc(a: number): number;
7
7
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
8
8
  export function __wbindgen_add_to_stack_pointer(a: number): number;
9
9
  export function __wbindgen_free(a: number, b: number): void;
10
- export function wasm_bindgen__convert__closures__invoke2_mut__h640c0c6add9d0132(a: number, b: number, c: number, d: number): void;
10
+ export function wasm_bindgen__convert__closures__invoke2_mut__h345d08f7c40b28d9(a: number, b: number, c: number, d: number): void;
11
11
  export function __wbindgen_exn_store(a: number): void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "The Noir Team <team@noir-lang.org>"
5
5
  ],
6
- "version": "0.16.0",
6
+ "version": "0.17.0",
7
7
  "license": "(MIT OR Apache-2.0)",
8
8
  "files": [
9
9
  "nodejs",
@@ -26,15 +26,17 @@
26
26
  "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
27
27
  "test:browser": "web-test-runner",
28
28
  "clean": "chmod u+w web nodejs || true && rm -rf ./nodejs ./web ./target ./result",
29
- "publish": "yarn npm publish",
30
- "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
29
+ "nightly:version": "jq --arg new_version \"-$(git rev-parse --short HEAD)$1\" '.version = .version + $new_version' package.json > package-tmp.json && mv package-tmp.json package.json",
30
+ "publish": "echo 📡 publishing `$npm_package_name` && yarn npm publish",
31
+ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0",
32
+ "build:nix": "nix build -L .#noirc_abi_wasm",
33
+ "install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/noirc_abi_wasm/nodejs ./ && cp -rL ./result/noirc_abi_wasm/web ./"
31
34
  },
32
35
  "devDependencies": {
33
36
  "@esm-bundle/chai": "^4.3.4-fix.0",
34
37
  "@web/dev-server-esbuild": "^0.3.6",
35
38
  "@web/test-runner": "^0.15.3",
36
39
  "@web/test-runner-playwright": "^0.10.0",
37
- "@web/test-runner-webdriver": "^0.7.0",
38
40
  "eslint": "^8.50.0",
39
41
  "mocha": "^10.2.0"
40
42
  }
@@ -1,18 +1,50 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {any} abi
5
- * @param {any} inputs
6
- * @param {any} return_value
4
+ * @param {Abi} abi
5
+ * @param {InputMap} inputs
6
+ * @param {InputValue | undefined} return_value
7
7
  * @returns {WitnessMap}
8
8
  */
9
- export function abiEncode(abi: any, inputs: any, return_value: any): WitnessMap;
9
+ export function abiEncode(abi: Abi, inputs: InputMap, return_value?: InputValue): WitnessMap;
10
10
  /**
11
- * @param {any} abi
11
+ * @param {Abi} abi
12
12
  * @param {WitnessMap} witness_map
13
13
  * @returns {any}
14
14
  */
15
- export function abiDecode(abi: any, witness_map: WitnessMap): any;
15
+ export function abiDecode(abi: Abi, witness_map: WitnessMap): any;
16
+
17
+ export type Field = string | number | boolean;
18
+ export type InputValue = Field | Field[] | InputMap;
19
+ export type InputMap = { [key: string]: InputValue };
20
+
21
+
22
+
23
+ export type Visibility = "public" | "private";
24
+ export type Sign = "unsigned" | "signed";
25
+ export type AbiType =
26
+ { kind: "field" } |
27
+ { kind: "boolean" } |
28
+ { kind: "string", length: number } |
29
+ { kind: "integer", sign: Sign, width: number } |
30
+ { kind: "array", length: number, type: AbiType } |
31
+ { kind: "tuple", fields: AbiType[] } |
32
+ { kind: "struct", path: string, fields: [string, AbiType][] };
33
+
34
+ export type AbiParameter = {
35
+ name: string,
36
+ type: AbiType,
37
+ visibility: Visibility,
38
+ };
39
+
40
+ export type Abi = {
41
+ parameters: AbiParameter[],
42
+ param_witnesses: Record<string, number[]>,
43
+ return_type: AbiType | null,
44
+ return_witnesses: number[],
45
+ }
46
+
47
+
16
48
 
17
49
  // Map from witness index to hex string value of witness.
18
50
  export type WitnessMap = Map<number, string>;
@@ -33,7 +65,7 @@ export interface InitOutput {
33
65
  readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
34
66
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
35
67
  readonly __wbindgen_free: (a: number, b: number) => void;
36
- readonly wasm_bindgen__convert__closures__invoke2_mut__h640c0c6add9d0132: (a: number, b: number, c: number, d: number) => void;
68
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h345d08f7c40b28d9: (a: number, b: number, c: number, d: number) => void;
37
69
  readonly __wbindgen_exn_store: (a: number) => void;
38
70
  }
39
71
 
@@ -6,28 +6,6 @@ heap.push(undefined, null, true, false);
6
6
 
7
7
  function getObject(idx) { return heap[idx]; }
8
8
 
9
- function isLikeNone(x) {
10
- return x === undefined || x === null;
11
- }
12
-
13
- let cachedFloat64Memory0 = null;
14
-
15
- function getFloat64Memory0() {
16
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
17
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
18
- }
19
- return cachedFloat64Memory0;
20
- }
21
-
22
- let cachedInt32Memory0 = null;
23
-
24
- function getInt32Memory0() {
25
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
26
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
27
- }
28
- return cachedInt32Memory0;
29
- }
30
-
31
9
  let heap_next = heap.length;
32
10
 
33
11
  function dropObject(idx) {
@@ -115,6 +93,28 @@ function passStringToWasm0(arg, malloc, realloc) {
115
93
  return ptr;
116
94
  }
117
95
 
96
+ function isLikeNone(x) {
97
+ return x === undefined || x === null;
98
+ }
99
+
100
+ let cachedInt32Memory0 = null;
101
+
102
+ function getInt32Memory0() {
103
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
104
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
105
+ }
106
+ return cachedInt32Memory0;
107
+ }
108
+
109
+ let cachedFloat64Memory0 = null;
110
+
111
+ function getFloat64Memory0() {
112
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
113
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
114
+ }
115
+ return cachedFloat64Memory0;
116
+ }
117
+
118
118
  const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
119
119
 
120
120
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
@@ -124,15 +124,15 @@ function getStringFromWasm0(ptr, len) {
124
124
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
125
125
  }
126
126
  /**
127
- * @param {any} abi
128
- * @param {any} inputs
129
- * @param {any} return_value
127
+ * @param {Abi} abi
128
+ * @param {InputMap} inputs
129
+ * @param {InputValue | undefined} return_value
130
130
  * @returns {WitnessMap}
131
131
  */
132
132
  export function abiEncode(abi, inputs, return_value) {
133
133
  try {
134
134
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
135
- wasm.abiEncode(retptr, addHeapObject(abi), addHeapObject(inputs), addHeapObject(return_value));
135
+ wasm.abiEncode(retptr, addHeapObject(abi), addHeapObject(inputs), isLikeNone(return_value) ? 0 : addHeapObject(return_value));
136
136
  var r0 = getInt32Memory0()[retptr / 4 + 0];
137
137
  var r1 = getInt32Memory0()[retptr / 4 + 1];
138
138
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -146,7 +146,7 @@ export function abiEncode(abi, inputs, return_value) {
146
146
  }
147
147
 
148
148
  /**
149
- * @param {any} abi
149
+ * @param {Abi} abi
150
150
  * @param {WitnessMap} witness_map
151
151
  * @returns {any}
152
152
  */
@@ -166,8 +166,8 @@ export function abiDecode(abi, witness_map) {
166
166
  }
167
167
  }
168
168
 
169
- function __wbg_adapter_28(arg0, arg1, arg2, arg3) {
170
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h640c0c6add9d0132(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
169
+ function __wbg_adapter_26(arg0, arg1, arg2, arg3) {
170
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h345d08f7c40b28d9(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
171
171
  }
172
172
 
173
173
  function handleError(f, args) {
@@ -212,16 +212,14 @@ async function __wbg_load(module, imports) {
212
212
  function __wbg_get_imports() {
213
213
  const imports = {};
214
214
  imports.wbg = {};
215
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
216
- const obj = getObject(arg1);
217
- const ret = typeof(obj) === 'number' ? obj : undefined;
218
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
219
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
220
- };
221
215
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
222
216
  takeObject(arg0);
223
217
  };
224
- imports.wbg.__wbg_new_b88faf1d36aaeaaf = function() {
218
+ imports.wbg.__wbg_constructor_8b80183f1e67730f = function(arg0) {
219
+ const ret = new Error(takeObject(arg0));
220
+ return addHeapObject(ret);
221
+ };
222
+ imports.wbg.__wbg_new_31288a3fdd8270cf = function() {
225
223
  const ret = new Map();
226
224
  return addHeapObject(ret);
227
225
  };
@@ -237,18 +235,16 @@ function __wbg_get_imports() {
237
235
  getInt32Memory0()[arg0 / 4 + 1] = len1;
238
236
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
239
237
  };
240
- imports.wbg.__wbg_constructor_ee715a20a6d6befb = function(arg0) {
241
- const ret = new Error(takeObject(arg0));
242
- return addHeapObject(ret);
238
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
239
+ const obj = getObject(arg1);
240
+ const ret = typeof(obj) === 'number' ? obj : undefined;
241
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
242
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
243
243
  };
244
244
  imports.wbg.__wbindgen_is_undefined = function(arg0) {
245
245
  const ret = getObject(arg0) === undefined;
246
246
  return ret;
247
247
  };
248
- imports.wbg.__wbindgen_is_null = function(arg0) {
249
- const ret = getObject(arg0) === null;
250
- return ret;
251
- };
252
248
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
253
249
  const ret = new Error();
254
250
  return addHeapObject(ret);
@@ -282,7 +278,7 @@ function __wbg_get_imports() {
282
278
  const a = state0.a;
283
279
  state0.a = 0;
284
280
  try {
285
- return __wbg_adapter_28(a, state0.b, arg0, arg1);
281
+ return __wbg_adapter_26(a, state0.b, arg0, arg1);
286
282
  } finally {
287
283
  state0.a = a;
288
284
  }
Binary file
@@ -7,5 +7,5 @@ export function __wbindgen_malloc(a: number): number;
7
7
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
8
8
  export function __wbindgen_add_to_stack_pointer(a: number): number;
9
9
  export function __wbindgen_free(a: number, b: number): void;
10
- export function wasm_bindgen__convert__closures__invoke2_mut__h640c0c6add9d0132(a: number, b: number, c: number, d: number): void;
10
+ export function wasm_bindgen__convert__closures__invoke2_mut__h345d08f7c40b28d9(a: number, b: number, c: number, d: number): void;
11
11
  export function __wbindgen_exn_store(a: number): void;