@noir-lang/noirc_abi 0.13.0 → 0.16.0-20a160c

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/CHANGELOG.md ADDED
File without changes
@@ -1,20 +1,56 @@
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>;
19
51
 
20
52
 
53
+
54
+ export type ABIError = Error;
55
+
56
+
@@ -1,7 +1,7 @@
1
1
  let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
- const { TextDecoder, TextEncoder } = require(`util`);
4
+ const { TextEncoder, TextDecoder } = require(`util`);
5
5
 
6
6
  const heap = new Array(128).fill(undefined);
7
7
 
@@ -9,6 +9,29 @@ heap.push(undefined, null, true, false);
9
9
 
10
10
  function getObject(idx) { return heap[idx]; }
11
11
 
12
+ let heap_next = heap.length;
13
+
14
+ function dropObject(idx) {
15
+ if (idx < 132) return;
16
+ heap[idx] = heap_next;
17
+ heap_next = idx;
18
+ }
19
+
20
+ function takeObject(idx) {
21
+ const ret = getObject(idx);
22
+ dropObject(idx);
23
+ return ret;
24
+ }
25
+
26
+ function addHeapObject(obj) {
27
+ if (heap_next === heap.length) heap.push(heap.length + 1);
28
+ const idx = heap_next;
29
+ heap_next = heap[idx];
30
+
31
+ heap[idx] = obj;
32
+ return idx;
33
+ }
34
+
12
35
  function isLikeNone(x) {
13
36
  return x === undefined || x === null;
14
37
  }
@@ -31,23 +54,7 @@ function getInt32Memory0() {
31
54
  return cachedInt32Memory0;
32
55
  }
33
56
 
34
- let heap_next = heap.length;
35
-
36
- function dropObject(idx) {
37
- if (idx < 132) return;
38
- heap[idx] = heap_next;
39
- heap_next = idx;
40
- }
41
-
42
- function takeObject(idx) {
43
- const ret = getObject(idx);
44
- dropObject(idx);
45
- return ret;
46
- }
47
-
48
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
49
-
50
- cachedTextDecoder.decode();
57
+ let WASM_VECTOR_LEN = 0;
51
58
 
52
59
  let cachedUint8Memory0 = null;
53
60
 
@@ -58,22 +65,6 @@ function getUint8Memory0() {
58
65
  return cachedUint8Memory0;
59
66
  }
60
67
 
61
- function getStringFromWasm0(ptr, len) {
62
- ptr = ptr >>> 0;
63
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
64
- }
65
-
66
- function addHeapObject(obj) {
67
- if (heap_next === heap.length) heap.push(heap.length + 1);
68
- const idx = heap_next;
69
- heap_next = heap[idx];
70
-
71
- heap[idx] = obj;
72
- return idx;
73
- }
74
-
75
- let WASM_VECTOR_LEN = 0;
76
-
77
68
  let cachedTextEncoder = new TextEncoder('utf-8');
78
69
 
79
70
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -126,16 +117,25 @@ function passStringToWasm0(arg, malloc, realloc) {
126
117
  WASM_VECTOR_LEN = offset;
127
118
  return ptr;
128
119
  }
120
+
121
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
122
+
123
+ cachedTextDecoder.decode();
124
+
125
+ function getStringFromWasm0(ptr, len) {
126
+ ptr = ptr >>> 0;
127
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
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
  */
@@ -181,33 +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.__wbindgen_string_new = function(arg0, arg1) {
196
- const ret = getStringFromWasm0(arg0, arg1);
188
+ module.exports.__wbg_constructor_ee715a20a6d6befb = function(arg0) {
189
+ const ret = new Error(takeObject(arg0));
197
190
  return addHeapObject(ret);
198
191
  };
199
192
 
200
- module.exports.__wbindgen_is_undefined = function(arg0) {
201
- const ret = getObject(arg0) === undefined;
202
- return ret;
203
- };
204
-
205
- module.exports.__wbindgen_is_null = function(arg0) {
206
- const ret = getObject(arg0) === null;
207
- return ret;
208
- };
209
-
210
- module.exports.__wbg_new_b3b0a89b9ad0bb3a = function() {
193
+ module.exports.__wbg_new_b88faf1d36aaeaaf = function() {
211
194
  const ret = new Map();
212
195
  return addHeapObject(ret);
213
196
  };
@@ -217,6 +200,13 @@ module.exports.__wbindgen_number_new = function(arg0) {
217
200
  return addHeapObject(ret);
218
201
  };
219
202
 
203
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
204
+ const obj = getObject(arg1);
205
+ const ret = typeof(obj) === 'number' ? obj : undefined;
206
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
207
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
208
+ };
209
+
220
210
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
221
211
  const obj = getObject(arg1);
222
212
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -226,6 +216,11 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
226
216
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
227
217
  };
228
218
 
219
+ module.exports.__wbindgen_is_undefined = function(arg0) {
220
+ const ret = getObject(arg0) === undefined;
221
+ return ret;
222
+ };
223
+
229
224
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
230
225
  const ret = new Error();
231
226
  return addHeapObject(ret);
@@ -251,6 +246,11 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
251
246
  }
252
247
  };
253
248
 
249
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
250
+ const ret = getStringFromWasm0(arg0, arg1);
251
+ return addHeapObject(ret);
252
+ };
253
+
254
254
  module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
255
255
  try {
256
256
  var state0 = {a: arg1, b: arg2};
Binary file
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.13.0",
6
+ "version": "0.16.0-20a160c",
7
7
  "license": "(MIT OR Apache-2.0)",
8
8
  "files": [
9
9
  "nodejs",
@@ -25,6 +25,9 @@
25
25
  "build": "bash ./build.sh",
26
26
  "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
27
27
  "test:browser": "web-test-runner",
28
+ "clean": "chmod u+w web nodejs || true && rm -rf ./nodejs ./web ./target ./result",
29
+ "nightly:version": "jq --arg new_version \"-$(git rev-parse --short HEAD)\" '.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",
28
31
  "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
29
32
  },
30
33
  "devDependencies": {
@@ -32,8 +35,7 @@
32
35
  "@web/dev-server-esbuild": "^0.3.6",
33
36
  "@web/test-runner": "^0.15.3",
34
37
  "@web/test-runner-playwright": "^0.10.0",
35
- "@web/test-runner-webdriver": "^0.7.0",
36
- "eslint": "^8.40.0",
38
+ "eslint": "^8.50.0",
37
39
  "mocha": "^10.2.0"
38
40
  }
39
- }
41
+ }
@@ -1,24 +1,60 @@
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>;
19
51
 
20
52
 
21
53
 
54
+ export type ABIError = Error;
55
+
56
+
57
+
22
58
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
23
59
 
24
60
  export interface InitOutput {
@@ -6,6 +6,29 @@ heap.push(undefined, null, true, false);
6
6
 
7
7
  function getObject(idx) { return heap[idx]; }
8
8
 
9
+ let heap_next = heap.length;
10
+
11
+ function dropObject(idx) {
12
+ if (idx < 132) return;
13
+ heap[idx] = heap_next;
14
+ heap_next = idx;
15
+ }
16
+
17
+ function takeObject(idx) {
18
+ const ret = getObject(idx);
19
+ dropObject(idx);
20
+ return ret;
21
+ }
22
+
23
+ function addHeapObject(obj) {
24
+ if (heap_next === heap.length) heap.push(heap.length + 1);
25
+ const idx = heap_next;
26
+ heap_next = heap[idx];
27
+
28
+ heap[idx] = obj;
29
+ return idx;
30
+ }
31
+
9
32
  function isLikeNone(x) {
10
33
  return x === undefined || x === null;
11
34
  }
@@ -28,23 +51,7 @@ function getInt32Memory0() {
28
51
  return cachedInt32Memory0;
29
52
  }
30
53
 
31
- let heap_next = heap.length;
32
-
33
- function dropObject(idx) {
34
- if (idx < 132) return;
35
- heap[idx] = heap_next;
36
- heap_next = idx;
37
- }
38
-
39
- function takeObject(idx) {
40
- const ret = getObject(idx);
41
- dropObject(idx);
42
- return ret;
43
- }
44
-
45
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
46
-
47
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
54
+ let WASM_VECTOR_LEN = 0;
48
55
 
49
56
  let cachedUint8Memory0 = null;
50
57
 
@@ -55,22 +62,6 @@ function getUint8Memory0() {
55
62
  return cachedUint8Memory0;
56
63
  }
57
64
 
58
- function getStringFromWasm0(ptr, len) {
59
- ptr = ptr >>> 0;
60
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
61
- }
62
-
63
- function addHeapObject(obj) {
64
- if (heap_next === heap.length) heap.push(heap.length + 1);
65
- const idx = heap_next;
66
- heap_next = heap[idx];
67
-
68
- heap[idx] = obj;
69
- return idx;
70
- }
71
-
72
- let WASM_VECTOR_LEN = 0;
73
-
74
65
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
75
66
 
76
67
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -123,16 +114,25 @@ function passStringToWasm0(arg, malloc, realloc) {
123
114
  WASM_VECTOR_LEN = offset;
124
115
  return ptr;
125
116
  }
117
+
118
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
119
+
120
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
121
+
122
+ function getStringFromWasm0(ptr, len) {
123
+ ptr = ptr >>> 0;
124
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
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
  */
@@ -212,28 +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.__wbindgen_string_new = function(arg0, arg1) {
225
- const ret = getStringFromWasm0(arg0, arg1);
218
+ imports.wbg.__wbg_constructor_ee715a20a6d6befb = function(arg0) {
219
+ const ret = new Error(takeObject(arg0));
226
220
  return addHeapObject(ret);
227
221
  };
228
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
229
- const ret = getObject(arg0) === undefined;
230
- return ret;
231
- };
232
- imports.wbg.__wbindgen_is_null = function(arg0) {
233
- const ret = getObject(arg0) === null;
234
- return ret;
235
- };
236
- imports.wbg.__wbg_new_b3b0a89b9ad0bb3a = function() {
222
+ imports.wbg.__wbg_new_b88faf1d36aaeaaf = function() {
237
223
  const ret = new Map();
238
224
  return addHeapObject(ret);
239
225
  };
@@ -241,6 +227,12 @@ function __wbg_get_imports() {
241
227
  const ret = arg0;
242
228
  return addHeapObject(ret);
243
229
  };
230
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
231
+ const obj = getObject(arg1);
232
+ const ret = typeof(obj) === 'number' ? obj : undefined;
233
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
234
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
235
+ };
244
236
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
245
237
  const obj = getObject(arg1);
246
238
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -249,6 +241,10 @@ function __wbg_get_imports() {
249
241
  getInt32Memory0()[arg0 / 4 + 1] = len1;
250
242
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
251
243
  };
244
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
245
+ const ret = getObject(arg0) === undefined;
246
+ return ret;
247
+ };
252
248
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
253
249
  const ret = new Error();
254
250
  return addHeapObject(ret);
@@ -271,6 +267,10 @@ function __wbg_get_imports() {
271
267
  wasm.__wbindgen_free(deferred0_0, deferred0_1);
272
268
  }
273
269
  };
270
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
271
+ const ret = getStringFromWasm0(arg0, arg1);
272
+ return addHeapObject(ret);
273
+ };
274
274
  imports.wbg.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
275
275
  try {
276
276
  var state0 = {a: arg1, b: arg2};
Binary file