@theqrl/hypc 0.0.2 → 0.3.1

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 (60) hide show
  1. package/README.md +62 -15
  2. package/abi.js +17 -7
  3. package/bindings/compile.js +158 -31
  4. package/bindings/core.js +22 -6
  5. package/bindings/helpers.js +3 -4
  6. package/bindings/index.js +13 -6
  7. package/common/helpers.js +17 -3
  8. package/downloadCurrentVersion.js +20 -14
  9. package/formatters.js +2 -3
  10. package/hypc.js +91 -35
  11. package/hypjson.js +110 -1732
  12. package/linker.js +63 -32
  13. package/package.json +28 -28
  14. package/smtchecker.js +3 -1
  15. package/smtsolver.js +44 -17
  16. package/translate.js +4 -4
  17. package/verifyVersion.js +17 -7
  18. package/wrapper.js +305 -30
  19. package/build/clean.js +0 -6
  20. package/build/pack-publish-block.js +0 -10
  21. package/build/postbuild.js +0 -3
  22. package/contractA_hyp_A.bin +0 -1
  23. package/contractB_hyp_B.bin +0 -1
  24. package/importA_hyp_C.bin +0 -1
  25. package/importB_hyp_D.bin +0 -1
  26. package/libX_hyp_X.bin +0 -1
  27. package/libY_hyp_Y.bin +0 -1
  28. package/libZ_hyp_Z.bin +0 -1
  29. package/test/abi.js +0 -77
  30. package/test/cli.js +0 -245
  31. package/test/compiler.js +0 -791
  32. package/test/index.js +0 -36
  33. package/test/linker.js +0 -132
  34. package/test/resources/fixtureAsmJson.hyp +0 -8
  35. package/test/resources/fixtureAsmJson.json +0 -528
  36. package/test/resources/fixtureAsmJson.output +0 -101
  37. package/test/resources/fixtureIncorrectSource.hyp +0 -1
  38. package/test/resources/fixtureSmoke.hyp +0 -5
  39. package/test/resources/importA.hyp +0 -7
  40. package/test/resources/importB.hyp +0 -5
  41. package/test/resources/importCallback/base/contractA.hyp +0 -8
  42. package/test/resources/importCallback/base/contractB.hyp +0 -6
  43. package/test/resources/importCallback/contractC.hyp +0 -4
  44. package/test/resources/importCallback/includeA/libX.hyp +0 -4
  45. package/test/resources/importCallback/includeA/libY.hyp +0 -6
  46. package/test/resources/importCallback/includeA/utils.hyp +0 -4
  47. package/test/resources/importCallback/includeB/libZ.hyp +0 -4
  48. package/test/resources/smtChecker/loop.hyp +0 -8
  49. package/test/resources/smtChecker/smoke.hyp +0 -5
  50. package/test/resources/smtChecker/smoke_with_engine.hyp +0 -6
  51. package/test/resources/smtChecker/smoke_with_multi_engine.hyp +0 -8
  52. package/test/smtcallback.js +0 -221
  53. package/test/smtchecker.js +0 -83
  54. package/test/translate.js +0 -83
  55. package/test_resources_fixtureSmoke_hyp_C.abi +0 -1
  56. package/test_resources_fixtureSmoke_hyp_C.bin +0 -1
  57. package/test_resources_importA_hyp_C.bin +0 -1
  58. package/test_resources_importB_hyp_D.bin +0 -1
  59. package/tsconfig.json +0 -25
  60. package/utils_hyp_Utils.bin +0 -1
package/wrapper.js CHANGED
@@ -1,20 +1,161 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
- const memorystream_1 = __importDefault(require("memorystream"));
38
+ const crypto_1 = require("crypto");
6
39
  const follow_redirects_1 = require("follow-redirects");
40
+ const fs = __importStar(require("fs"));
41
+ const js_sha3_1 = require("js-sha3");
42
+ const path = __importStar(require("path"));
7
43
  const formatters_1 = require("./formatters");
8
44
  const helpers_1 = require("./common/helpers");
9
45
  const bindings_1 = __importDefault(require("./bindings"));
10
46
  const translate_1 = __importDefault(require("./translate"));
11
47
  const Module = module.constructor;
12
- function wrapper(hypjson) {
13
- const { coreBindings, compileBindings, methodFlags } = (0, bindings_1.default)(hypjson);
48
+ /**
49
+ * Wraps an Emscripten compiler module in the hypc-js API.
50
+ *
51
+ * A JavaScript exception that unwinds through the compiler's wasm frames, such as the RangeError
52
+ * of a stack overflow inside the compiler, leaves that module instance unable to compile (see
53
+ * `guarded` in bindings/compile.ts). `compile` throws the exception, and the next compilation
54
+ * runs on a fresh instance of the module, which `reload` returns. By default a module that
55
+ * `require` loaded is reloaded from its file, and `loadRemoteVersion` reloads from the downloaded
56
+ * source. Where neither applies, as in a browser or a bundle, pass a function that returns a fresh
57
+ * module. Without one, the same instance goes on once the compiler has discarded the abandoned
58
+ * compilation, which compilers from 0.3.0 on do in hyperion_reset(); with an older compiler, or
59
+ * after a WebAssembly trap, the next compilation returns an error that says the module cannot be
60
+ * used again.
61
+ *
62
+ * @param hypjson The Emscripten compiled Hyperion object.
63
+ * @param reload Returns a fresh instance of the same module.
64
+ */
65
+ function wrapper(hypjson, reload = reloaderFor(hypjson)) {
66
+ let bindings = (0, bindings_1.default)(hypjson);
67
+ const { methodFlags } = bindings;
68
+ // Why no compilation can run any more, once that is certain: the instance cannot compile, and no
69
+ // fresh one can be loaded.
70
+ let unusable;
71
+ // Set while the instance goes on after discarding an abandoned compilation and its next output
72
+ // has not yet shown whether the compiler supports that; holds why it was needed.
73
+ let recoveringInPlace;
74
+ const withoutReplacement = (why) => `The compiler module cannot be used again: ${why}. Load a fresh module, or pass a function that does so as the second argument of setupMethods.`;
75
+ // The bindings of the current module instance, after an exception unwound through the previous
76
+ // one: of a fresh instance where one can be loaded, otherwise of the same instance after asking
77
+ // it to discard the abandoned compilation. Throws when neither is possible.
78
+ function usableBindings() {
79
+ if (unusable !== undefined) {
80
+ throw new Error(unusable);
81
+ }
82
+ if (!bindings.poisoned) {
83
+ return bindings;
84
+ }
85
+ const why = `an exception unwound through the compiler during an earlier compilation (${(0, helpers_1.describeException)(bindings.poisonedBy)})`;
86
+ if (reload !== undefined) {
87
+ try {
88
+ bindings = (0, bindings_1.default)(reload());
89
+ }
90
+ catch (e) {
91
+ throw new Error(`The compiler module cannot be used again: ${why}, and reloading it failed: ${(0, helpers_1.describeException)(e)}`);
92
+ }
93
+ return bindings;
94
+ }
95
+ // No fresh instance can be loaded here, as in a browser or a bundle. A JavaScript exception
96
+ // leaves the instance's memory intact, and hyperion_reset() of compilers from 0.3.0 on
97
+ // discards the abandoned compilation's state, so the same instance can go on; whether this
98
+ // compiler does that shows in its next output (see compileMethod). What the abandoned
99
+ // compilation allocated stays allocated, since its destructors never ran and cannot be run
100
+ // now, which is why a fresh instance is preferred wherever one can be loaded. After a trap (a
101
+ // WebAssembly.RuntimeError, which is also what an Emscripten abort throws) the memory cannot
102
+ // be trusted.
103
+ if (typeof WebAssembly !== 'undefined' && bindings.poisonedBy instanceof WebAssembly.RuntimeError) {
104
+ unusable = withoutReplacement(`${why}, and the instance cannot be reused after a WebAssembly trap`);
105
+ throw new Error(unusable);
106
+ }
107
+ if ((0, helpers_1.isNil)(bindings.coreBindings.reset)) {
108
+ unusable = withoutReplacement(`${why}, and this compiler has no hyperion_reset() to discard it with`);
109
+ throw new Error(unusable);
110
+ }
111
+ try {
112
+ bindings.coreBindings.reset();
113
+ }
114
+ catch (e) {
115
+ unusable = withoutReplacement(`${why}, and hyperion_reset() failed afterwards: ${(0, helpers_1.describeException)(e)}`);
116
+ throw new Error(unusable);
117
+ }
118
+ bindings.poisoned = false;
119
+ bindings.poisonedBy = undefined;
120
+ recoveringInPlace = why;
121
+ return bindings;
122
+ }
123
+ // The compile method of that name, run on the current module instance, or null if the compiler
124
+ // lacks the method.
125
+ function compileMethod(name) {
126
+ if ((0, helpers_1.isNil)(bindings.compileBindings[name])) {
127
+ return null;
128
+ }
129
+ return function (...args) {
130
+ let current;
131
+ try {
132
+ current = usableBindings();
133
+ }
134
+ catch (e) {
135
+ return (0, formatters_1.formatFatalError)(e.message);
136
+ }
137
+ const output = current.compileBindings[name](...args);
138
+ if (recoveringInPlace !== undefined) {
139
+ const why = recoveringInPlace;
140
+ recoveringInPlace = undefined;
141
+ if (reportsStaleCompilerStack(output)) {
142
+ unusable = withoutReplacement(`${why}, and this compiler's hyperion_reset() does not discard the abandoned compilation (compilers from 0.3.0 on do)`);
143
+ return (0, formatters_1.formatFatalError)(unusable);
144
+ }
145
+ }
146
+ return output;
147
+ };
148
+ }
149
+ const compileBindings = {
150
+ compileJson: compileMethod('compileJson'),
151
+ compileJsonCallback: compileMethod('compileJsonCallback'),
152
+ compileJsonMulti: compileMethod('compileJsonMulti'),
153
+ compileStandard: compileMethod('compileStandard')
154
+ };
14
155
  return {
15
- version: coreBindings.version,
16
- semver: coreBindings.versionToSemver,
17
- license: coreBindings.license,
156
+ version: () => bindings.coreBindings.version(),
157
+ semver: () => bindings.coreBindings.versionToSemver(),
158
+ license: () => bindings.coreBindings.license(),
18
159
  lowlevel: {
19
160
  compileSingle: compileBindings.compileJson,
20
161
  compileMulti: compileBindings.compileJsonMulti,
@@ -28,36 +169,170 @@ function wrapper(hypjson) {
28
169
  nativeStandardJSON: methodFlags.compileJsonStandardSupported
29
170
  },
30
171
  compile: compileStandardWrapper.bind(this, compileBindings),
31
- // Loads the compiler of the given version from the github repository
32
- // instead of from the local filesystem.
172
+ // Loads the compiler of the given version from binaries.theqrl.org instead of from the
173
+ // local filesystem, after checking it against list.json.
33
174
  loadRemoteVersion,
34
175
  // Use this if you want to add wrapper functions around the pure module.
35
176
  setupMethods: wrapper
36
177
  };
37
178
  }
38
- function loadRemoteVersion(versionString, callback) {
39
- const memoryStream = new memorystream_1.default(null, { readable: false });
40
- const url = `https://binaries.theqrl.org/bin/hypjson-${versionString}.js`;
41
- follow_redirects_1.https.get(url, response => {
179
+ // Loads the source of a compiler module as require() does, in a Module of its own that is in
180
+ // neither require.cache nor module.children, so that an instance can be dropped once it is no
181
+ // longer usable. Emscripten's Node support adds a process-wide `unhandledRejection` listener on
182
+ // every load, which would accumulate and keep every instance alive; the listeners a load adds are
183
+ // removed again.
184
+ function loadModuleSource(source, filename) {
185
+ const events = ['uncaughtException', 'unhandledRejection'];
186
+ const listenersBefore = events.map(event => process.listeners(event));
187
+ try {
188
+ const hypjson = new Module(filename);
189
+ hypjson.filename = filename;
190
+ hypjson.paths = Module._nodeModulePaths(path.dirname(filename));
191
+ hypjson._compile(source, filename);
192
+ hypjson.loaded = true;
193
+ return hypjson.exports;
194
+ }
195
+ finally {
196
+ events.forEach((event, i) => {
197
+ for (const listener of process.listeners(event)) {
198
+ if (!listenersBefore[i].includes(listener)) {
199
+ process.removeListener(event, listener);
200
+ }
201
+ }
202
+ });
203
+ }
204
+ }
205
+ // A function that loads a fresh instance of a module that require() loaded, found through
206
+ // require.cache; undefined where there is no such record, as in a browser or a bundle.
207
+ function reloaderFor(hypjson) {
208
+ const cache = typeof require === 'function' ? require.cache : undefined;
209
+ if (!cache) {
210
+ return undefined;
211
+ }
212
+ const record = Object.keys(cache)
213
+ .map(key => cache[key])
214
+ .find(entry => entry && entry.exports === hypjson && typeof entry.filename === 'string');
215
+ if (!record) {
216
+ return undefined;
217
+ }
218
+ return () => loadModuleSource(fs.readFileSync(record.filename, 'utf8'), record.filename);
219
+ }
220
+ // True if the compiler's output reports the CompilerStack of an abandoned compilation, which is
221
+ // what an instance whose hyperion_reset() did not discard it answers to every compilation.
222
+ function reportsStaleCompilerStack(output) {
223
+ let parsed;
224
+ try {
225
+ parsed = JSON.parse(output);
226
+ }
227
+ catch (e) {
228
+ return false;
229
+ }
230
+ const errors = parsed && parsed.errors;
231
+ return Array.isArray(errors) && errors.some(error => {
232
+ // Compilers before 0.4.x reported errors as strings.
233
+ const message = typeof error === 'string' ? error : error && error.message;
234
+ const internal = typeof error === 'string' || (error && error.type === 'InternalCompilerError');
235
+ return internal && typeof message === 'string' && message.includes('You shall not have another CompilerStack aside me.');
236
+ });
237
+ }
238
+ const BINARIES_HOST = 'binaries.theqrl.org';
239
+ const BINARIES_URL = `https://${BINARIES_HOST}/bin/`;
240
+ // list.json is a few kilobytes and a compiler build about 9 MB.
241
+ const MAX_LIST_BYTES = 1024 * 1024;
242
+ const MAX_BUILD_BYTES = 64 * 1024 * 1024;
243
+ // Follow redirects only to https URLs on the binaries host.
244
+ function beforeRedirect(options) {
245
+ if (options.protocol !== 'https:' || options.hostname !== BINARIES_HOST) {
246
+ throw new Error(`Refusing to follow a redirect to ${options.protocol}//${options.hostname}.`);
247
+ }
248
+ }
249
+ // Calls back once, with an error or the complete body of a 200 response.
250
+ function download(url, maxBytes, callback) {
251
+ let done = false;
252
+ const finish = (error, body) => {
253
+ if (!done) {
254
+ done = true;
255
+ callback(error, body);
256
+ }
257
+ };
258
+ follow_redirects_1.https.get(url, { beforeRedirect, maxRedirects: 5 }, response => {
42
259
  if (response.statusCode !== 200) {
43
- callback(new Error(`Error retrieving binary: ${response.statusMessage}`));
260
+ response.resume();
261
+ finish(new Error(`Error retrieving ${url}: ${response.statusCode} ${response.statusMessage}`));
262
+ return;
44
263
  }
45
- else {
46
- response.pipe(memoryStream);
47
- response.on('end', () => {
48
- // Based on the require-from-string package.
49
- const hypjson = new Module();
50
- hypjson._compile(memoryStream.toString(), `hypjson-${versionString}.js`);
51
- if (module.parent && module.parent.children) {
52
- // Make sure the module is plugged into the hierarchy correctly to have parent
53
- // properly garbage collected.
54
- module.parent.children.splice(module.parent.children.indexOf(hypjson), 1);
55
- }
56
- callback(null, wrapper(hypjson.exports));
57
- });
264
+ const chunks = [];
265
+ let length = 0;
266
+ response.on('data', chunk => {
267
+ length += chunk.length;
268
+ if (length > maxBytes) {
269
+ response.destroy();
270
+ finish(new Error(`${url} is larger than ${maxBytes} bytes.`));
271
+ }
272
+ else {
273
+ chunks.push(chunk);
274
+ }
275
+ });
276
+ response.on('end', () => finish(null, Buffer.concat(chunks)));
277
+ response.on('error', finish);
278
+ }).on('error', finish);
279
+ }
280
+ // The list.json entry for "latest", a release such as "0.2.0", or a build such as
281
+ // "v0.2.0+commit.e36a0aea".
282
+ function findBuild(list, versionString) {
283
+ const releases = list.releases || {};
284
+ const buildPath = versionString === 'latest'
285
+ ? releases[list.latestRelease]
286
+ : releases[versionString] || `hypjson-${versionString}.js`;
287
+ const build = (list.builds || []).find(entry => entry.path === buildPath);
288
+ if (!build ||
289
+ !/^hypjson-v[0-9A-Za-z.+-]+\.js$/.test(build.path) ||
290
+ typeof build.keccak256 !== 'string' ||
291
+ typeof build.sha256 !== 'string') {
292
+ throw new Error(`Version ${versionString} is not in ${BINARIES_URL}list.json.`);
293
+ }
294
+ return build;
295
+ }
296
+ // Downloads a compiler build and runs it only if its keccak256 and sha256 match list.json.
297
+ function loadRemoteVersion(versionString, callback) {
298
+ download(BINARIES_URL + 'list.json', MAX_LIST_BYTES, (listError, listBody) => {
299
+ if (listError) {
300
+ callback(listError);
301
+ return;
302
+ }
303
+ let build;
304
+ try {
305
+ build = findBuild(JSON.parse(listBody.toString('utf8')), versionString);
306
+ }
307
+ catch (e) {
308
+ callback(e);
309
+ return;
58
310
  }
59
- }).on('error', function (error) {
60
- callback(error);
311
+ download(BINARIES_URL + build.path, MAX_BUILD_BYTES, (error, body) => {
312
+ if (error) {
313
+ callback(error);
314
+ return;
315
+ }
316
+ const keccak = '0x' + (0, js_sha3_1.keccak256)(body);
317
+ const sha256 = '0x' + (0, crypto_1.createHash)('sha256').update(body).digest('hex');
318
+ if (keccak !== build.keccak256.toLowerCase() || sha256 !== build.sha256.toLowerCase()) {
319
+ callback(new Error(`${build.path} does not match the keccak256 and sha256 in list.json, so it was not run.`));
320
+ return;
321
+ }
322
+ let hypc;
323
+ try {
324
+ // The source stays referenced so that a fresh instance can be loaded if an exception
325
+ // unwinds through this one (see wrapper).
326
+ const source = body.toString('utf8');
327
+ const load = () => loadModuleSource(source, build.path);
328
+ hypc = wrapper(load(), load);
329
+ }
330
+ catch (e) {
331
+ callback(e);
332
+ return;
333
+ }
334
+ callback(null, hypc);
335
+ });
61
336
  });
62
337
  }
63
338
  // Expects a Standard JSON I/O but supports old compilers
@@ -87,12 +362,12 @@ function compileStandardWrapper(compile, inputRaw, readCallback) {
87
362
  }
88
363
  // Try to wrap around old versions
89
364
  if (!(0, helpers_1.isNil)(compile.compileJsonCallback)) {
90
- const inputJson = JSON.stringify({ sources: sources });
365
+ const inputJson = JSON.stringify({ sources });
91
366
  const output = compile.compileJsonCallback(inputJson, optimize, readCallback);
92
367
  return translateOutput(output, libraries);
93
368
  }
94
369
  if (!(0, helpers_1.isNil)(compile.compileJsonMulti)) {
95
- const output = compile.compileJsonMulti(JSON.stringify({ sources: sources }), optimize);
370
+ const output = compile.compileJsonMulti(JSON.stringify({ sources }), optimize);
96
371
  return translateOutput(output, libraries);
97
372
  }
98
373
  // Try our luck with an ancient compiler
package/build/clean.js DELETED
@@ -1,6 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const distFolder = path.join(__dirname, 'dist');
4
- if (fs.existsSync(distFolder)) {
5
- fs.rmdirSync(distFolder);
6
- }
@@ -1,10 +0,0 @@
1
- // This is meant to run in a hook before npm pack.
2
- // Reporting an error from the hook interrupts the command.
3
- if (process.env.BYPASS_SAFETY_CHECK === 'false' || process.env.BYPASS_SAFETY_CHECK === undefined) {
4
- console.error('Run `npm run build:tarball` or `npm run publish:tarball` to pack or publish the package');
5
- process.exit(1);
6
- }
7
- else if (process.env.BYPASS_SAFETY_CHECK !== 'true') {
8
- console.error('Invalid value of the BYPASS_SAFETY_CHECK variable. Must be "true", "false" or unset.');
9
- process.exit(1);
10
- }
@@ -1,3 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- fs.chmodSync(path.join(__dirname, '../dist', 'hypc.js'), '755');
@@ -1 +0,0 @@
1
- 6080604052348015600e575f80fd5b50603e80601a5f395ff3fe60806040525f80fdfea26469706673582212207da9777c17d9abc5309ba89332ae703efba54bf7fb9c290d475d6c0f7cb7a6c86468797063430000020033
@@ -1 +0,0 @@
1
- 6080604052348015600e575f80fd5b50603e80601a5f395ff3fe60806040525f80fdfea264697066735822122019ceaad2fc0893d39b61042424757a67bf6723d77172da4c38279007c2723bbf6468797063430000020033
package/importA_hyp_C.bin DELETED
@@ -1 +0,0 @@
1
- 6080604052348015600e575f80fd5b5060ab8061001b5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c806326121ff014602a575b5f80fd5b60306044565b604051603b9190605e565b60405180910390f35b5f90565b5f819050919050565b6058816048565b82525050565b5f602082019050606f5f8301846051565b9291505056fea264697066735822122003aa2795a073c7ca2063308c3a8a13fb3a1ce6028c399f889636bd9eabe1f73f6468797063430000020033
package/importB_hyp_D.bin DELETED
@@ -1 +0,0 @@
1
- 6080604052348015600e575f80fd5b5060ab8061001b5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c806326121ff014602a575b5f80fd5b60306044565b604051603b9190605e565b60405180910390f35b5f90565b5f819050919050565b6058816048565b82525050565b5f602082019050606f5f8301846051565b9291505056fea2646970667358221220f96d6c685f4fe201ee93ca17a8b69d8182984a86c16908f46d7becc54efcfb846468797063430000020033
package/libX_hyp_X.bin DELETED
@@ -1 +0,0 @@
1
- 6055604b600b8282823980515f1a607314603f577f4e487b71000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220e78306f3d7dc80c45acbd51f639ead3e6f620f10144ea624b2c7e88c6c1504e96468797063430000020033
package/libY_hyp_Y.bin DELETED
@@ -1 +0,0 @@
1
- 6055604b600b8282823980515f1a607314603f577f4e487b71000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220fe2cbe5e62e395650d519ac764d3d5271e9af30d3e271d1c291677812e14d7ce6468797063430000020033
package/libZ_hyp_Z.bin DELETED
@@ -1 +0,0 @@
1
- 6055604b600b8282823980515f1a607314603f577f4e487b71000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212208cf9773d6268fc017aed7c3282d7e4ec482fd3b5d956250412103e5d65854bfc6468797063430000020033
package/test/abi.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const tape_1 = __importDefault(require("tape"));
7
- const abi_1 = __importDefault(require("../abi"));
8
- (0, tape_1.default)('ABI translator', function (t) {
9
- t.test('Empty ABI', function (st) {
10
- st.deepEqual(abi_1.default.update('0.4.0', []), []);
11
- st.end();
12
- });
13
- t.test('0.1.1 (no constructor)', function (st) {
14
- st.deepEqual(abi_1.default.update('0.1.1', []), [{ inputs: [], payable: true, stateMutability: 'payable', type: 'constructor' }, { payable: true, stateMutability: 'payable', type: 'fallback' }]);
15
- st.end();
16
- });
17
- t.test('0.3.6 (constructor)', function (st) {
18
- const input = [{ inputs: [], type: 'constructor' }];
19
- st.deepEqual(abi_1.default.update('0.3.6', input), [{ inputs: [], payable: true, stateMutability: 'payable', type: 'constructor' }, { payable: true, stateMutability: 'payable', type: 'fallback' }]);
20
- st.end();
21
- });
22
- t.test('0.3.6 (non-constant function)', function (st) {
23
- const input = [{ inputs: [], type: 'function' }];
24
- st.deepEqual(abi_1.default.update('0.3.6', input), [{ inputs: [], payable: true, stateMutability: 'payable', type: 'function' }, { payable: true, stateMutability: 'payable', type: 'fallback' }]);
25
- st.end();
26
- });
27
- t.test('0.3.6 (constant function)', function (st) {
28
- const input = [{ inputs: [], type: 'function', constant: true }];
29
- st.deepEqual(abi_1.default.update('0.3.6', input), [{ inputs: [], constant: true, stateMutability: 'view', type: 'function' }, { payable: true, stateMutability: 'payable', type: 'fallback' }]);
30
- st.end();
31
- });
32
- t.test('0.3.6 (event)', function (st) {
33
- const input = [{ inputs: [], type: 'event' }];
34
- st.deepEqual(abi_1.default.update('0.3.6', input), [{ inputs: [], type: 'event' }, { payable: true, stateMutability: 'payable', type: 'fallback' }]);
35
- st.end();
36
- });
37
- t.test('0.3.6 (has no fallback)', function (st) {
38
- const input = [{ inputs: [], type: 'constructor' }];
39
- st.deepEqual(abi_1.default.update('0.3.6', input), [{ inputs: [], type: 'constructor', payable: true, stateMutability: 'payable' }, { type: 'fallback', payable: true, stateMutability: 'payable' }]);
40
- st.end();
41
- });
42
- t.test('0.4.0 (has fallback)', function (st) {
43
- const input = [{ inputs: [], type: 'constructor' }, { type: 'fallback' }];
44
- st.deepEqual(abi_1.default.update('0.4.0', input), [{ inputs: [], type: 'constructor', payable: true, stateMutability: 'payable' }, { type: 'fallback', stateMutability: 'nonpayable' }]);
45
- st.end();
46
- });
47
- t.test('0.4.0 (non-constant function)', function (st) {
48
- const input = [{ inputs: [], type: 'function' }];
49
- st.deepEqual(abi_1.default.update('0.4.0', input), [{ inputs: [], stateMutability: 'nonpayable', type: 'function' }]);
50
- st.end();
51
- });
52
- t.test('0.4.0 (constant function)', function (st) {
53
- const input = [{ inputs: [], type: 'function', constant: true }];
54
- st.deepEqual(abi_1.default.update('0.4.0', input), [{ inputs: [], constant: true, stateMutability: 'view', type: 'function' }]);
55
- st.end();
56
- });
57
- t.test('0.4.0 (payable function)', function (st) {
58
- const input = [{ inputs: [], payable: true, type: 'function' }];
59
- st.deepEqual(abi_1.default.update('0.4.0', input), [{ inputs: [], payable: true, stateMutability: 'payable', type: 'function' }]);
60
- st.end();
61
- });
62
- t.test('0.4.1 (constructor not payable)', function (st) {
63
- const input = [{ inputs: [], payable: false, type: 'constructor' }];
64
- st.deepEqual(abi_1.default.update('0.4.1', input), [{ inputs: [], payable: true, stateMutability: 'payable', type: 'constructor' }]);
65
- st.end();
66
- });
67
- t.test('0.4.5 (constructor payable)', function (st) {
68
- const input = [{ inputs: [], payable: false, type: 'constructor' }];
69
- st.deepEqual(abi_1.default.update('0.4.5', input), [{ inputs: [], payable: false, stateMutability: 'nonpayable', type: 'constructor' }]);
70
- st.end();
71
- });
72
- t.test('0.4.16 (statemutability)', function (st) {
73
- const input = [{ inputs: [], payable: false, stateMutability: 'pure', type: 'function' }];
74
- st.deepEqual(abi_1.default.update('0.4.16', input), [{ inputs: [], payable: false, stateMutability: 'pure', type: 'function' }]);
75
- st.end();
76
- });
77
- });