godprotocol 1.0.5 → 1.0.6

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 (91) hide show
  1. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  2. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  3. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  4. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  5. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  6. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  7. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  8. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  9. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  10. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  11. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  12. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  13. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  14. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  15. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  16. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  17. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451 +1 -0
  18. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  19. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/46931496c37b22cb91df1929ca4d44b3349c68ec818b37b63dd8583f31e3015b +1 -0
  20. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/4c061633d7fc20f5202cf7d5940b8623c12064c5ede02977e8b5e9e6e7fb9687 +1 -0
  21. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/a20ee8d03f370f8bc61adaf18b681b3e2c4017defd3ad38cb99d2111167ca479 +1 -0
  22. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/ad1e584a505553ddda31fe599dad98fc35a04bd0ff5a654035f85137aa633842 +1 -0
  23. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/bb3d37eee86ecb7262c8ac311a2ddd7f6b9f6298682e348bc784e91511d41638 +1 -0
  24. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/be574e4859c2aba2a2e6a4eb7cf51f006fe2d493ad0268a1f6341e50f0beba90 +1 -0
  25. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5822a8abd3cb9f230711a1ceac473518a38f8824164c9536ae2d20ca264a385 +1 -0
  26. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5bbe585b2c9ef9a1dca11d1520b40847dc0858a0da1e509f646963be5d3866b +1 -0
  27. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f8127f98684c7e3ab56acdc33af3a3ffe02fbcce9740184d2fa64cc7f3db7fdc +1 -0
  28. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  29. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  30. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  31. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  32. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  33. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  34. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  35. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  36. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  37. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  38. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/51a3716d770009c68d68a8f39f912020972c5219187f79f77bdf996e6d3cc530 +1 -0
  39. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  40. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  41. package/Aircode/functions/parse_expression.js +117 -0
  42. package/Aircode/functions/parse_to_obj.js +26 -0
  43. package/Aircode/functions/parse_variable.js +35 -0
  44. package/Aircode/functions/tokenise.js +118 -0
  45. package/Aircode/functions/utils.js +11 -0
  46. package/Aircode/keywords/conditional.js +104 -0
  47. package/Aircode/keywords/parse.js +20 -0
  48. package/Aircode/main.js +94 -0
  49. package/Aircode/native_classes/Variable.js +36 -0
  50. package/Aircode/native_classes/datatypes/Number.js +20 -0
  51. package/Aircode/native_classes/datatypes/String.js +20 -0
  52. package/Aircode/native_classes/global.js +21 -0
  53. package/Aircode/native_classes/native.js +23 -0
  54. package/Aircode/native_classes/operators.js +47 -0
  55. package/Aircode/native_classes/parse.js +42 -0
  56. package/Aircode/utils/format_instructions.js +36 -0
  57. package/Aircode/utils/traverse.js +13 -0
  58. package/Index.js +19 -20
  59. package/Objects/Account.js +90 -98
  60. package/Objects/Block.js +45 -0
  61. package/Objects/Blockweb.js +30 -12
  62. package/Objects/Chain.js +96 -0
  63. package/Objects/Explorer.js +18 -62
  64. package/Objects/Filesystem.js +163 -12
  65. package/Objects/Frame.js +11 -1
  66. package/Objects/Manager.js +56 -0
  67. package/Objects/Opcodes.js +13 -17
  68. package/Objects/Oracle.js +35 -0
  69. package/Objects/Virtual_machine.js +72 -70
  70. package/Objects/folder.js +8 -83
  71. package/framer.js +27 -4
  72. package/opcodes/add.js +15 -38
  73. package/opcodes/jmp.js +9 -3
  74. package/opcodes/std.js +5 -0
  75. package/opcodes.js +19 -10
  76. package/package.json +1 -1
  77. package/utils/create_server.js +23 -12
  78. package/utils/hash.js +1 -38
  79. package/utils/services.js +25 -15
  80. package/.keypair +0 -1
  81. package/Datatypes/Array.js +0 -33
  82. package/Datatypes/Number.js +0 -21
  83. package/Datatypes/String.js +0 -23
  84. package/Datatypes/Twain.js +0 -42
  85. package/Objects/Blockchain.js +0 -135
  86. package/Objects/Emitter.js +0 -38
  87. package/Objects/Queries.js +0 -13
  88. package/Objects/file.js +0 -21
  89. package/Socket.js +0 -83
  90. package/index.d.ts +0 -50
  91. package/utils/gen_key_pair.js +0 -36
@@ -1,21 +0,0 @@
1
- import fs from "fs";
2
-
3
- class Num {
4
- constructor(object, account) {
5
- this.object = Number(object.join(""));
6
- this.account = account;
7
- this.path = `${this.account.path}/Datatypes/Number/${this.object}`;
8
- }
9
-
10
- load = () => {
11
- return this;
12
- };
13
-
14
- store = () => {
15
- fs.writeFileSync(this.path, this.object.toString());
16
-
17
- return this;
18
- };
19
- }
20
-
21
- export default Num;
@@ -1,23 +0,0 @@
1
- import fs from "fs";
2
- import { fs_buffer, hash } from "../utils/hash";
3
-
4
- class Str {
5
- constructor(object, account) {
6
- this.object = object.join("");
7
- this.hash = hash(this.object);
8
- this.account = account;
9
- }
10
-
11
- load = () => {
12
- return this;
13
- };
14
-
15
- store = () => {
16
- this.path = `${this.account.path}/Datatypes/String/${this.hash}`;
17
- fs.writeFileSync(this.path, this.object);
18
-
19
- return this;
20
- };
21
- }
22
-
23
- export default Str;
@@ -1,42 +0,0 @@
1
- import fs from "fs";
2
- import { hash } from "../utils/hash";
3
- import Arr from "./Array";
4
-
5
- class Twain {
6
- constructor(object, account) {
7
- this.object = object;
8
- this.account = account;
9
- }
10
-
11
- load = () => {
12
- let obj = {};
13
- this.object.map((o) => {
14
- let blk = this.account.vm.web.blocks[o];
15
- let pair = load(blk.read_metadata());
16
- if (!(pair instanceof Arr))
17
- return console.log("Something aint right in Twain.load");
18
-
19
- obj[pair.object[0]] = obj[pair.object[1]];
20
- });
21
- return obj;
22
- };
23
-
24
- store = () => {
25
- let curr_hash = hash("{}");
26
- this.object.map((o) => {
27
- hash(curr_hash + hash(o));
28
- });
29
- this.path = `${this.account.path}/Datatypes/Twain`;
30
- curr_hash = hash(curr_hash);
31
-
32
- fs.writeFileSync(`${this.path}/${curr_hash}`, this.stringify());
33
-
34
- return this;
35
- };
36
-
37
- stringify = () => {
38
- return JSON.stringify(this.object);
39
- };
40
- }
41
-
42
- export default Twain;
@@ -1,135 +0,0 @@
1
- import fs from "fs";
2
- import Explorer from "./Explorer";
3
- import Twain from "../Datatypes/Twain";
4
- import { hash } from "../utils/hash";
5
-
6
- class Block {
7
- constructor(chain) {
8
- this.index = chain.blocks.length;
9
- this.timestamp = Date.now();
10
- this.data = chain.txs;
11
- this.chain = chain;
12
- this.parents = new Array();
13
- this.children = new Array();
14
- this.hash = hash(hash(JSON.stringify(this.data)) + this.chain.hash);
15
- this.path = `${this.chain.path}/${this.hash}`;
16
-
17
- this.column = 0;
18
- }
19
-
20
- get = (prop) => {
21
- return this[prop];
22
- };
23
-
24
- set = (prop, value) => {
25
- this[prop] = value;
26
- };
27
-
28
- connect = (chain) => {
29
- chain.pending_children.push(this);
30
- };
31
-
32
- calculate_hash() {
33
- return this.hash;
34
- }
35
-
36
- read_metadata = (path) => {
37
- let res = "";
38
- try {
39
- res = JSON.parse(fs.readFileSync(path, { encoding: "utf-8" }));
40
- } catch (e) {
41
- console.log(e.message);
42
- }
43
- return res;
44
- };
45
-
46
- stringify = (str) => {
47
- let obj = {
48
- index: this.index,
49
- hash: this.hash,
50
- previous_hash: this.previous_hash,
51
- chain: this.chain.hash,
52
- };
53
-
54
- return str ? JSON.stringify(obj) : obj;
55
- };
56
- }
57
-
58
- class Chain extends Explorer {
59
- constructor(parent, context) {
60
- super();
61
-
62
- this.parent = parent;
63
- this.context = context;
64
- this.name = this.parent.name;
65
- this.blocks = new Array();
66
- this.pending_children = new Array();
67
- this.connections = new Array();
68
- this.hash = hash(this.parent.path);
69
- this.path = parent.path;
70
-
71
- this.txs = new Array();
72
- }
73
-
74
- add_tx = (tx) => {
75
- if (!this.txs.length) this.prior_timestep = Date.now();
76
- this.txs.push(tx);
77
- };
78
-
79
- stringify = () => {
80
- let obj = {
81
- parent: this.parent.path,
82
- hash: this.hash,
83
- name: this.name,
84
- blocks: this.blocks.map((b) => b.hash),
85
- connections: this.connections.map((b) => b.hash),
86
- };
87
- let twain = new Twain(obj, this.parent.account);
88
- twain.load();
89
-
90
- return { type: "twain", path: twain.address };
91
- };
92
-
93
- store = (block, vm) => {
94
- let metadata = this.parent.content_buffer;
95
-
96
- let file = this.parent.file(block.hash);
97
- file.content = metadata;
98
- file.store(this.parent.account);
99
- block.metadata = file.data_path;
100
-
101
- vm.web.new_block(block);
102
- };
103
-
104
- handle_children = (block) => {
105
- this.pending_children.push(block);
106
- this.connections.push(block);
107
- };
108
-
109
- mine = (vm) => {
110
- let blk = new Block(this);
111
-
112
- let latest_blk = this.get_latest_block();
113
- blk.previous_hash = latest_blk && latest_blk.hash;
114
- blk.timelapse = blk.timestamp - this.start_time;
115
-
116
- this.blocks.push(blk);
117
-
118
- this.store(blk, vm);
119
-
120
- this.txs = new Array();
121
- this.pending_children = new Array();
122
-
123
- return blk;
124
- };
125
-
126
- get_latest_block() {
127
- return this.blocks[this.blocks.length - 1];
128
- }
129
-
130
- add_block(new_block) {
131
- this.blocks.push(new_block);
132
- }
133
- }
134
-
135
- export { Chain, Block };
@@ -1,38 +0,0 @@
1
- class Emitter {
2
- constructor() {
3
- this.events = new Object();
4
- }
5
-
6
- emit = async (event, data, callback) => {
7
- let events = this.events[event] || new Array(),
8
- return_ = new Array();
9
-
10
- for (let e = 0; e < events.length; e++) {
11
- let listener = events[e];
12
- return_.push(listener && (await listener(data)));
13
- }
14
-
15
- typeof callback === "function" && (await callback(return_[0]));
16
- };
17
-
18
- listen = (event, listener, single) => {
19
- let listeners = this.events[event] || new Array();
20
-
21
- if (single) listeners = new Array(listener);
22
- else listeners.push(listener);
23
-
24
- this.events[event] = listeners;
25
- };
26
-
27
- single_listener = (event, listener) => this.listen(event, listener, true);
28
-
29
- remove_listener = (event, listener) => {
30
- let listeners = this.events[event] || new Array();
31
-
32
- listeners = listeners.filter((_listener) => _listener !== listener);
33
-
34
- this.events[event] = listeners;
35
- };
36
- }
37
-
38
- export default Emitter;
@@ -1,13 +0,0 @@
1
- class Queries {
2
- intersect = (v1, v2) => {};
3
-
4
- equals = (v1, v2) => {
5
- return v1 === v2;
6
- };
7
-
8
- not_equals = (v1, v2) => {
9
- return v1 !== v2;
10
- };
11
- }
12
-
13
- export default Queries;
package/Objects/file.js DELETED
@@ -1,21 +0,0 @@
1
- import { store } from "../utils/hash";
2
-
3
- class File {
4
- constructor(name, folder) {
5
- this.name = name;
6
- this.parent = folder;
7
-
8
- this.path = `${this.parent.path}/${this.name}`;
9
-
10
- this.content = null;
11
-
12
- this.frame_path = `${this.parent.account.path}/Objects/File`;
13
- }
14
-
15
- store = () => {
16
- this.content_object = store(this.content);
17
- this.data_path = this.content_object && this.content_object.path;
18
- };
19
- }
20
-
21
- export default File;
package/Socket.js DELETED
@@ -1,83 +0,0 @@
1
- const net = require("net");
2
- const { initiator } = require("./Index");
3
-
4
- let PORT = 1910;
5
- let Sockets = new Object();
6
- let Accounts_ = new Object();
7
- let pendings = new Object();
8
-
9
- const Socket_server = () => {
10
- let server = net.createServer((socket) => {
11
- console.log("meeeee");
12
- socket.on("connect", () => {
13
- Sockets[socket.id] = { socket };
14
- console.log(`New client connection - ${socket.id}`);
15
- });
16
-
17
- socket.on("data", (data) => {
18
- data = JSON.parse(data.toString());
19
- if (data.url === "link_account") {
20
- let acc = initiator.accounts[data.account];
21
- if (acc) {
22
- acc.sockets.push(socket);
23
- Sockets[socket.id].account = acc;
24
- let socs = Accounts_[data.account];
25
- if (!socs) {
26
- socs = new Array();
27
- Accounts_[data.account] = socs;
28
- }
29
- socs.push(socket);
30
-
31
- let pps = pendings[data.account];
32
- if (pps && pps.length) {
33
- pps.map((p) => socket.write(p.data));
34
- pendings[data.account] = new Array();
35
- }
36
- }
37
- } else initiator.load(data);
38
- console.log("Socket data..");
39
- });
40
-
41
- socket.on("end", () => {
42
- let soc_acc = Sockets[socket.id];
43
- delete Sockets[socket.id];
44
- if (soc_acc.account) {
45
- soc_acc.account.accounts = soc_acc.account.accounts.filter(
46
- (soc) => soc.id !== socket.id
47
- );
48
- let accs = Accounts_[soc_acc.account.path];
49
- if (accs) {
50
- accs = accs.filter((acc) => acc.id !== socket.id);
51
- Accounts_[soc_acc.account.path] = accs;
52
- }
53
- }
54
- console.log("Client disconnected");
55
- });
56
-
57
- socket.on("error", (err) => {
58
- console.error("Socket error:", err.message);
59
- });
60
- });
61
-
62
- server.listen(PORT, () => {
63
- // console.log(`Socket server listening on port ${PORT}`);
64
- });
65
- };
66
-
67
- const socket_send = (args, context) => {
68
- let socket = Accounts_[args.account];
69
- if (!socket) {
70
- let pps = pendings[args.account];
71
- if (!pps) {
72
- pps = new Array();
73
- pendings[args.account] = pps;
74
- }
75
- pps.push(args);
76
- return;
77
- }
78
-
79
- socket.write(args.data);
80
- };
81
-
82
- export default Socket_server;
83
- export { socket_send };
package/index.d.ts DELETED
@@ -1,50 +0,0 @@
1
- export class Account {
2
- constructor(name: string);
3
- load(data: { instructions: string[]; account: string }): null;
4
- frame(data: object): null;
5
- vm: Virtual_machine;
6
- }
7
-
8
- export class Virtual_machine {
9
- constructor(chain: Blockchain);
10
- state: Blockchain[];
11
- push(instructions: string[]): null;
12
- set(name: string, callable: function): null;
13
- }
14
-
15
- export class Blockchain {
16
- constructor(parent: Folder, context: Blockchain);
17
- add_tx(tx: string): null;
18
- store(block: Block): null;
19
- mine(): Block;
20
- get_latest_block(): Block | null;
21
- }
22
-
23
- export class Block {
24
- constructor(chain: Blockchain);
25
- get(prop: string): any;
26
-
27
- set(prop: string, value: any): null;
28
- connect(chain: Blockchain): null;
29
- calculate_hash(): string;
30
- }
31
-
32
- export class Folder {
33
- constructor(name: string, parent: Folder);
34
- file(name: string): File;
35
-
36
- folder(name: string, context: Blockchain): Folder;
37
- timestep(col: string): null;
38
- history(r: string): null;
39
- write(data: string): null;
40
- }
41
-
42
- export class File {
43
- constructor(name: string, folder: Folder);
44
- activate_context(index: number): null;
45
- timestep(col: string): null;
46
- history(r: string): null;
47
- write(data: string): null;
48
- readonly(prop: string, index: number, context: Blockchain): string;
49
- store(): null;
50
- }
@@ -1,36 +0,0 @@
1
- import fs from "fs";
2
- const EC = require("elliptic").ec;
3
-
4
- let key_path = "./.keypair";
5
-
6
- const manage_key_pair = () => {
7
- if (process.env.PUBLIC_KEY_COMPRESSED) return;
8
-
9
- let data;
10
- if (fs.existsSync(key_path)) {
11
- data = fs.readFileSync(key_path, { encoding: "utf-8" });
12
- if (data) data = JSON.parse(data);
13
- } else {
14
- data = generate_key_pair();
15
- fs.writeFileSync(key_path, JSON.stringify(data));
16
- }
17
-
18
- process.env.PUBLIC_KEY = data.public_key;
19
- process.env.PRIVATE_KEY = data.private_key;
20
- process.env.PUBLIC_KEY_COMPRESSED = data.public_key_compressed;
21
- };
22
-
23
- let generate_key_pair = () => {
24
- let ec = new EC("secp256k1");
25
- let keyPair = ec.genKeyPair();
26
-
27
- let private_key = keyPair.getPrivate("hex");
28
-
29
- let public_key = keyPair.getPublic("hex");
30
-
31
- let public_key_compressed = keyPair.getPublic(true, "hex");
32
-
33
- return { private_key, public_key, public_key_compressed };
34
- };
35
-
36
- export { manage_key_pair, generate_key_pair };