@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/test/index.js DELETED
@@ -1,36 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const semver = __importStar(require("semver"));
27
- Promise.resolve().then(() => __importStar(require('./linker')));
28
- Promise.resolve().then(() => __importStar(require('./translate')));
29
- Promise.resolve().then(() => __importStar(require('./compiler')));
30
- Promise.resolve().then(() => __importStar(require('./smtcallback')));
31
- Promise.resolve().then(() => __importStar(require('./smtchecker')));
32
- Promise.resolve().then(() => __importStar(require('./abi')));
33
- // The CLI doesn't support Node 4
34
- if (semver.gte(process.version, '5.0.0')) {
35
- Promise.resolve().then(() => __importStar(require('./cli')));
36
- }
package/test/linker.js DELETED
@@ -1,132 +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 linker_1 = __importDefault(require("../linker"));
8
- (0, tape_1.default)('Link references', function (t) {
9
- t.test('Empty bytecode', function (st) {
10
- st.deepEqual(linker_1.default.findLinkReferences(''), {});
11
- st.end();
12
- });
13
- t.test('No references', function (st) {
14
- st.deepEqual(linker_1.default.findLinkReferences('6060604052341561000f57600080fd'), {});
15
- st.end();
16
- });
17
- t.test('One reference', function (st) {
18
- const bytecode = '6060604052341561000f57600080fd5b60f48061001d6000396000f300606060405260043610603e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166326121ff081146043575b600080fd5b3415604d57600080fd5b60536055565b005b73__lib2.hyp:L____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160006040518083038186803b151560b357600080fd5b6102c65a03f4151560c357600080fd5b5050505600a165627a7a723058207979b30bd4a07c77b02774a511f2a1dd04d7e5d65b5c2735b5fc96ad61d43ae40029';
19
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { 'lib2.hyp:L': [{ start: 116, length: 20 }] });
20
- st.end();
21
- });
22
- t.test('Two references', function (st) {
23
- const bytecode = '6060604052341561000f57600080fd5b61011a8061001e6000396000f30060606040526004361060255763ffffffff60e060020a60003504166326121ff08114602a575b600080fd5b3415603457600080fd5b603a603c565b005b73__lib2.hyp:L____________________________6326121ff06040518163ffffffff1660e060020a02815260040160006040518083038186803b1515608157600080fd5b6102c65a03f41515609157600080fd5b50505073__linkref.hyp:Lx________________________6326121ff06040518163ffffffff1660e060020a02815260040160006040518083038186803b151560d957600080fd5b6102c65a03f4151560e957600080fd5b5050505600a165627a7a72305820fdfb8eab411d7bc86d7dfbb0c985c30bebf1cc105dc5b807291551b3d5aa29d90029';
24
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { 'lib2.hyp:L': [{ start: 92, length: 20 }], 'linkref.hyp:Lx': [{ start: 180, length: 20 }] });
25
- st.end();
26
- });
27
- t.test('Library name with leading underscore', function (st) {
28
- const bytecode = '6060604052341561000f57600080fd5b60f48061001d6000396000f300606060405260043610603e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166326121ff081146043575b600080fd5b3415604d57600080fd5b60536055565b005b73__lib2.hyp:_L___________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160006040518083038186803b151560b357600080fd5b6102c65a03f4151560c357600080fd5b5050505600a165627a7a7230582089689827bbf0b7dc385ffcb4b1deb9f9e61741f61f89b4af65f806ff2b0d73470029';
29
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { 'lib2.hyp:_L': [{ start: 116, length: 20 }] });
30
- st.end();
31
- });
32
- t.test('Library name with leading underscore (without fqdn)', function (st) {
33
- const bytecode = '6060604052341561000f57600080fd5b60f48061001d6000396000f300606060405260043610603e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166326121ff081146043575b600080fd5b3415604d57600080fd5b60536055565b005b73___L____________________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160006040518083038186803b151560b357600080fd5b6102c65a03f4151560c357600080fd5b5050505600a165627a7a7230582089689827bbf0b7dc385ffcb4b1deb9f9e61741f61f89b4af65f806ff2b0d73470029';
34
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { _L: [{ start: 116, length: 20 }] });
35
- st.end();
36
- });
37
- t.test('Library name with underscore in the name', function (st) {
38
- const bytecode = '6060604052341561000f57600080fd5b60f48061001d6000396000f300606060405260043610603e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166326121ff081146043575b600080fd5b3415604d57600080fd5b60536055565b005b73__lib2.hyp:L_L__________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160006040518083038186803b151560b357600080fd5b6102c65a03f4151560c357600080fd5b5050505600a165627a7a723058205cb324a27452cc7f8894a57cb0e3ddce2dce0c423e4fc993a3dd51287abd49110029';
39
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { 'lib2.hyp:L_L': [{ start: 116, length: 20 }] });
40
- st.end();
41
- });
42
- // Note: this is a case the reference finder cannot properly handle as there's no way to tell
43
- t.test('Library name with trailing underscore', function (st) {
44
- const bytecode = '6060604052341561000f57600080fd5b60f48061001d6000396000f300606060405260043610603e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166326121ff081146043575b600080fd5b3415604d57600080fd5b60536055565b005b73__lib2.hyp:L____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160006040518083038186803b151560b357600080fd5b6102c65a03f4151560c357600080fd5b5050505600a165627a7a7230582058e61511a603707222cfa83fd3ae4269f94eb86513cb9042cf0b44877403d85c0029';
45
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { 'lib2.hyp:L': [{ start: 116, length: 20 }] });
46
- st.end();
47
- });
48
- t.test('Invalid input (too short)', function (st) {
49
- const bytecode = '6060604052341561000____66606060606060';
50
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), {});
51
- st.end();
52
- });
53
- t.test('Invalid input (1 byte short)', function (st) {
54
- const bytecode = '6060604052341561000__lib2.hyp:L___________________________66606060606060';
55
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), {});
56
- st.end();
57
- });
58
- t.test('Two references with same library name', function (st) {
59
- const bytecode = '6060604052341561000f57600080fd5b61011a8061001e6000396000f30060606040526004361060255763ffffffff60e060020a60003504166326121ff08114602a575b600080fd5b3415603457600080fd5b603a603c565b005b73__lib2.hyp:L____________________________6326121ff06040518163ffffffff1660e060020a02815260040160006040518083038186803b1515608157600080fd5b6102c65a03f41515609157600080fd5b50505073__lib2.hyp:L____________________________6326121ff06040518163ffffffff1660e060020a02815260040160006040518083038186803b151560d957600080fd5b6102c65a03f4151560e957600080fd5b5050505600a165627a7a72305820fdfb8eab411d7bc86d7dfbb0c985c30bebf1cc105dc5b807291551b3d5aa29d90029';
60
- st.deepEqual(linker_1.default.findLinkReferences(bytecode), { 'lib2.hyp:L': [{ start: 92, length: 20 }, { start: 180, length: 20 }] });
61
- st.end();
62
- });
63
- });
64
- (0, tape_1.default)('Linking', function (t) {
65
- t.test('link properly', function (st) {
66
- /*
67
- 'lib.hyp': 'library L { function f() public returns (uint) { return 7; } }',
68
- 'cont.hyp': 'import "lib.hyp"; contract x { function g() public { L.f(); } }'
69
- */
70
- let bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.hyp:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
71
- bytecode = linker_1.default.linkBytecode(bytecode, { 'lib.hyp:L': 'Z123456' });
72
- st.ok(bytecode.indexOf('_') < 0);
73
- st.end();
74
- });
75
- t.test('link properly with two-level configuration (from standard JSON)', function (st) {
76
- /*
77
- 'lib.hyp': 'library L { function f() public returns (uint) { return 7; } }',
78
- 'cont.hyp': 'import "lib.hyp"; contract x { function g() public { L.f(); } }'
79
- */
80
- let bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.hyp:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
81
- bytecode = linker_1.default.linkBytecode(bytecode, { 'lib.hyp': { L: 'Z123456' } });
82
- st.ok(bytecode.indexOf('_') < 0);
83
- st.end();
84
- });
85
- t.test('linker to fail with missing library', function (st) {
86
- /*
87
- 'lib.hyp': 'library L { function f() public returns (uint) { return 7; } }',
88
- 'cont.hyp': 'import "lib.hyp"; contract x { function g() public { L.f(); } }'
89
- */
90
- let bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.hyp:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
91
- bytecode = linker_1.default.linkBytecode(bytecode, {});
92
- st.ok(bytecode.indexOf('_') >= 0);
93
- st.end();
94
- });
95
- t.test('linker to fail with invalid address', function (st) {
96
- /*
97
- 'lib.hyp': 'library L { function f() public returns (uint) { return 7; } }',
98
- 'cont.hyp': 'import "lib.hyp"; contract x { function g() public { L.f(); } }'
99
- */
100
- const bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.hyp:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
101
- st.throws(function () {
102
- linker_1.default.linkBytecode(bytecode, { 'lib.hyp:L': '' });
103
- });
104
- st.end();
105
- });
106
- t.test('linker properly with truncated library name', function (st) {
107
- /*
108
- 'lib.hyp': 'library L1234567890123456789012345678901234567890 { function f() public returns (uint) { return 7; } }',
109
- 'cont.hyp': 'import "lib.hyp"; contract x { function g() public { L1234567890123456789012345678901234567890.f(); } }'
110
- */
111
- let bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.hyp:L123456789012345678901234567__6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a723058209f88ff686bd8ceb0fc08853dc1332d5ff81dbcf5af3a1e9aa366828091761f8c0029';
112
- bytecode = linker_1.default.linkBytecode(bytecode, { 'lib.hyp:L1234567890123456789012345678901234567890': 'Z123456' });
113
- st.ok(bytecode.indexOf('_') < 0);
114
- st.end();
115
- });
116
- t.test('hashed placeholder', function (st) {
117
- let bytecode = '6060604052341561000__$7484607a72fb0587588e5a1e608f0b16de$__66606060606060';
118
- bytecode = linker_1.default.linkBytecode(bytecode, { 'lib2.hyp:L': 'Z123456' });
119
- st.equal(bytecode, '6060604052341561000000000000000000000000000000000000012345666606060606060');
120
- st.end();
121
- });
122
- t.test('link properly when library doesn\'t have colon in name', function (st) {
123
- /*
124
- 'lib.hyp': 'library L { function f() public returns (uint) { return 7; } }',
125
- 'cont.hyp': 'import "lib.hyp"; contract x { function g() public { L.f(); } }'
126
- */
127
- let bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__libName_______________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
128
- bytecode = linker_1.default.linkBytecode(bytecode, { libName: 'Z123456' });
129
- st.ok(bytecode.indexOf('_') < 0);
130
- st.end();
131
- });
132
- });
@@ -1,8 +0,0 @@
1
- contract C {
2
- // Leaving an empty line here intentionally
3
-
4
-
5
- function f() public returns (bytes4) {
6
- return this.f.selector;
7
- }
8
- }