godprotocol 1.0.4 → 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 (92) 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 +20 -20
  59. package/Objects/Account.js +90 -91
  60. package/Objects/Block.js +45 -0
  61. package/Objects/Blockweb.js +31 -9
  62. package/Objects/Chain.js +96 -0
  63. package/Objects/Explorer.js +18 -62
  64. package/Objects/Filesystem.js +162 -15
  65. package/Objects/Frame.js +23 -31
  66. package/Objects/Manager.js +56 -0
  67. package/Objects/Opcodes.js +15 -11
  68. package/Objects/Oracle.js +35 -0
  69. package/Objects/Virtual_machine.js +76 -57
  70. package/Objects/folder.js +9 -93
  71. package/framer.js +28 -5
  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 +2 -5
  77. package/utils/create_server.js +24 -12
  78. package/utils/functions.js +8 -0
  79. package/utils/hash.js +2 -36
  80. package/utils/services.js +25 -15
  81. package/.keypair +0 -1
  82. package/Datatypes/Array.js +0 -57
  83. package/Datatypes/Number.js +0 -38
  84. package/Datatypes/String.js +0 -41
  85. package/Datatypes/Twain.js +0 -70
  86. package/Objects/Blockchain.js +0 -141
  87. package/Objects/Emitter.js +0 -38
  88. package/Objects/Queries.js +0 -13
  89. package/Objects/file.js +0 -213
  90. package/Socket.js +0 -83
  91. package/index.d.ts +0 -50
  92. package/utils/gen_key_pair.js +0 -36
@@ -1,57 +0,0 @@
1
- import { fs_buffer, hash, store } from "../utils/hash";
2
-
3
- class Arr {
4
- constructor(object, account) {
5
- this.object = object;
6
- this.account = account;
7
- }
8
-
9
- store = (obj) => {
10
- return store(obj, this.account);
11
- };
12
-
13
- persistent_load = (initiator) => {
14
- let sequence = [
15
- `link ${initiator.path}/Opcodes/${this.account}`,
16
- `link ${initiator.path}/Datatypes/Array`,
17
- "timestep value",
18
- ];
19
- this.object.map((o, i) => {
20
- store(o, this.account, initiator);
21
- sequence.push(`write {pending_children:-${i + 1}}`);
22
- });
23
- sequence.push(
24
- ...[
25
- "mine",
26
- "pop_link",
27
- "history -1",
28
- "timestep output",
29
- "write {pending_children:-1}",
30
- "mine",
31
- "pop_link",
32
- ]
33
- );
34
-
35
- initiator.load(sequence);
36
-
37
- return this.object;
38
- };
39
-
40
- load = (initiator) => {
41
- if (initiator) return this.persistent_load(initiator);
42
-
43
- let arr = [];
44
- for (let a = 0; a < this.object.length; a++) {
45
- let item = this.object[a];
46
- arr.push(this.store(item));
47
- }
48
- let addr = `${this.account.path}/Datatypes/Array/${hash(
49
- JSON.stringify(arr)
50
- )}`;
51
- fs_buffer({ addr, data: arr });
52
-
53
- return addr;
54
- };
55
- }
56
-
57
- export default Arr;
@@ -1,38 +0,0 @@
1
- import { fs_buffer } from "../utils/hash";
2
-
3
- class Num {
4
- constructor(object, account) {
5
- this.object = object;
6
- this.account = account;
7
- }
8
-
9
- load = (initiator) => {
10
- initiator.load([
11
- `link ${initiator.path}/Opcodes/${this.account}`,
12
- `link ${initiator.path}/Datatypes/Number`,
13
- "timestep value",
14
- `write ${this.object}`,
15
- "mine",
16
- "pop_link",
17
- "history -1",
18
- "timestep output",
19
- "write {pending_children:-1}",
20
- "mine",
21
- "pop_link",
22
- ]);
23
-
24
- return this.object;
25
- };
26
-
27
- store = (initiator) => {
28
- if (initiator) return this.load(initiator);
29
-
30
- let addr = `${this.account.path}/Datatypes/Number/${this.object}`;
31
-
32
- fs_buffer({ addr, data: { type: "number", value: this.object } });
33
-
34
- return addr;
35
- };
36
- }
37
-
38
- export default Num;
@@ -1,41 +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;
7
- this.account = account;
8
- }
9
-
10
- load = (initiator) => {
11
- initiator.load([
12
- `link ${initiator.path}/Opcodes/${this.account}`,
13
- `link ${initiator.path}/Datatypes/String`,
14
- "timestep value",
15
- `write ${this.object}`,
16
- "mine",
17
- "pop_link",
18
- "history -1",
19
- "timestep output",
20
- "write {pending_children:-1}",
21
- "mine",
22
- "pop_link",
23
- ]);
24
-
25
- return this.object;
26
- };
27
-
28
- store = (initiator) => {
29
- if (initiator) return this.load(initiator);
30
-
31
- let addr = `${this.account.path}/Datatypes/String/${hash(
32
- this.object || "[blank]"
33
- )}`;
34
-
35
- fs_buffer({ addr, data: { type: "string", value: this.object } });
36
-
37
- return addr;
38
- };
39
- }
40
-
41
- export default Str;
@@ -1,70 +0,0 @@
1
- import { fs_buffer, hash, store } from "../utils/hash";
2
-
3
- class Twain {
4
- constructor(object, account) {
5
- this.object = object;
6
- this.account = account;
7
- }
8
-
9
- store = (obj) => {
10
- return store(obj, this.account);
11
- };
12
-
13
- persistent_load = (initiator) => {
14
- let sequence = [
15
- `link ${initiator.path}/Opcodes/${this.account}`,
16
- `link ${initiator.path}/Datatypes/Twain`,
17
- ];
18
- for (let prop in this.object) {
19
- let value = this.object[prop];
20
- sequence.push(`timestep prop`);
21
- let prop_addr = store(prop, this.account, initiator);
22
- sequence.push(`write {pending_children:-1}`);
23
- sequence.push(`timestep value`);
24
- let value_addr = store(value, this.account, initiator);
25
- sequence.push(`write {pending_children:-1}`);
26
- obj[prop_addr] = value_addr;
27
- }
28
- sequence.push(
29
- ...[
30
- "mine",
31
- "pop_link",
32
- "history -1",
33
- "timestep output",
34
- "write {pending_children:-1}",
35
- "mine",
36
- "pop_link",
37
- ]
38
- );
39
-
40
- initiator.load(sequence);
41
-
42
- return this.object;
43
- };
44
-
45
- load = (initiator) => {
46
- if (initiator) return this.persistent_load();
47
-
48
- let obj = {};
49
- for (let prop in this.object) {
50
- let value = this.object[prop];
51
- let prop_addr = this.store(prop);
52
- let value_addr = this.store(value);
53
- obj[prop_addr] = value_addr;
54
- }
55
- let addr = `${this.account.path}/Datatypes/Twain/${hash(
56
- JSON.stringify(obj)
57
- )}`;
58
- this.address = addr;
59
-
60
- fs_buffer({ addr, data: obj });
61
-
62
- return addr;
63
- };
64
-
65
- stringify = () => {
66
- return JSON.stringify(this.object);
67
- };
68
- }
69
-
70
- export default Twain;
@@ -1,141 +0,0 @@
1
- import Explorer from "./Explorer";
2
- import Twain from "../Datatypes/Twain";
3
- import { fs_buffer, hash } from "../utils/hash";
4
-
5
- class Block {
6
- constructor(index, chain, data, previous_hash = "") {
7
- this.index = index;
8
- this.timestamp = Date.now();
9
- this.data = data;
10
- this.previous_hash = previous_hash;
11
- this.chain = chain;
12
- this.parents = new Array();
13
- this.children = new Array();
14
- this.path = `${this.chain.path}:${this.index}`;
15
-
16
- this.column = 0;
17
- }
18
-
19
- get = (prop) => {
20
- return this[prop];
21
- };
22
-
23
- set = (prop, value) => {
24
- this[prop] = value;
25
- };
26
-
27
- connect = (chain) => {
28
- chain.pending_children.push(this);
29
- };
30
-
31
- calculate_hash() {
32
- return hash(`${JSON.stringify(this.data)}`);
33
- }
34
-
35
- stringify = (not_twained) => {
36
- let obj = {
37
- index: this.index,
38
- hash: this.hash,
39
- previous_hash: this.previous_hash,
40
- chain: this.chain.address,
41
- };
42
- if (not_twained) {
43
- }
44
-
45
- let twain = new Twain(obj, this.chain.parent.account);
46
- twain.load();
47
-
48
- return {
49
- type: "twain",
50
- path: twain.address,
51
- };
52
- };
53
- }
54
-
55
- class Blockchain extends Explorer {
56
- constructor(parent, context) {
57
- super();
58
-
59
- this.parent = parent;
60
- this.context = context;
61
- this.name = this.parent.name;
62
- this.blocks = new Array();
63
- this.pending_children = new Array();
64
- this.connections = new Array();
65
- this.hash = hash(this.parent.path);
66
- this.path = parent.path;
67
-
68
- this.txs = new Array();
69
- }
70
-
71
- add_tx = (tx) => {
72
- if (!this.txs.length) this.prior_timestep = Date.now();
73
- this.txs.push(tx);
74
- };
75
-
76
- stringify = () => {
77
- let obj = {
78
- parent: this.parent.path,
79
- hash: this.hash,
80
- name: this.name,
81
- blocks: this.blocks.map((b) => b.hash),
82
- connections: this.connections.map((b) => b.hash),
83
- };
84
- let twain = new Twain(obj, this.parent.account);
85
- twain.load();
86
-
87
- return { type: "twain", path: twain.address };
88
- };
89
-
90
- store = (block) => {
91
- fs_buffer({ addr: block.address, data: block.stringify() });
92
-
93
- fs_buffer({
94
- addr: `${this.parent.account.path}/Objects/Blockchain/Blockchain/${this.hash}`,
95
- data: this.stringify(),
96
- });
97
-
98
- block.file && block.file.store();
99
- };
100
-
101
- handle_children = (block) => {
102
- this.pending_children.push(block);
103
- this.connections.push(block);
104
- };
105
-
106
- mine = () => {
107
- let blk = new Block(this.blocks.length, this, this.txs);
108
-
109
- let latest_blk = this.get_latest_block();
110
- blk.previous_hash = latest_blk && latest_blk.hash;
111
-
112
- blk.calculate_hash();
113
-
114
- let active_file = this.parent.get_active_file();
115
-
116
- blk.metadata = { content: active_file.contents.length };
117
- blk.timelapse = blk.timestamp - this.start_time;
118
-
119
- blk.file = active_file;
120
-
121
- this.blocks.push(blk);
122
-
123
- this.store(blk);
124
- active_file.reset_content();
125
-
126
- this.txs = new Array();
127
- this.pending_children = new Array();
128
-
129
- return blk;
130
- };
131
-
132
- get_latest_block() {
133
- return this.blocks[this.blocks.length - 1];
134
- }
135
-
136
- add_block(new_block) {
137
- this.blocks.push(new_block);
138
- }
139
- }
140
-
141
- export { Blockchain, 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,213 +0,0 @@
1
- import fs from "fs";
2
- import Twain from "../Datatypes/Twain";
3
- import { store } from "../utils/hash";
4
-
5
- class File {
6
- object_name = "File";
7
-
8
- constructor(name, folder) {
9
- this.name = name;
10
- this.parent = folder;
11
-
12
- this.path = `${this.parent.path}/${this.name}`;
13
-
14
- this.contents = new Array();
15
- this.content = null;
16
- this.set_path();
17
-
18
- this.frame_path = `${this.parent.account.path}/Objects/File`;
19
-
20
- this.r = 0;
21
- this.col = "0";
22
- }
23
-
24
- activate_content = (index) => {
25
- let content = this.contents[Number(index)];
26
-
27
- let obj = {};
28
- for (let prop in content) {
29
- let value = content[prop];
30
-
31
- obj[prop] = this.parse_content(value[0]);
32
- }
33
-
34
- return obj;
35
- };
36
-
37
- parse_content = (content) => {
38
- if (content && content.includes && content.includes("/")) {
39
- let res = this.parent.chain.connections.find((c, i) => {
40
- return c.path === content;
41
- });
42
-
43
- let obj = this.datatypes(
44
- res.file.activate_content(res.metadata.content),
45
- res
46
- );
47
-
48
- return obj;
49
- } else return content;
50
- };
51
-
52
- datatypes = (obj, block) => {
53
- if (
54
- block.chain.parent.path === `${this.parent.account.path}/Datatypes/Number`
55
- ) {
56
- return Number(obj.value);
57
- } else if (
58
- block.chain.parent.path === `${this.parent.account.path}/Datatypes/String`
59
- ) {
60
- return obj.value.toString();
61
- }
62
- return obj;
63
- };
64
-
65
- reset_content = () => {
66
- if (this.content) {
67
- if (this.r < 0) {
68
- this.contents.splice(this.r, 1, this.content);
69
- } else this.contents.push(this.content);
70
- }
71
- this.r = 0;
72
- this.col = "0";
73
-
74
- this.content = null;
75
-
76
- this.parent.active_file = null;
77
- };
78
-
79
- get = (opcode) => {
80
- return this[opcode];
81
- };
82
-
83
- timestep = (col) => {
84
- this.col = col;
85
- };
86
-
87
- history = (r) => {
88
- this.r = Number(r);
89
- let content = this.contents.slice(r)[0];
90
- this.content = content;
91
- };
92
-
93
- fetch_arg = (path) => {
94
- let block = this.chain.explore({ parents: `${this.frame_path}/${path}` });
95
- return block.file.parse(true);
96
- };
97
-
98
- readonly = (prop, index, context) => {
99
- let initiator = context.get_context(0);
100
- if (
101
- [
102
- "timelapse",
103
- "timestamp",
104
- "data",
105
- "hash",
106
- "path",
107
- "children",
108
- "parents",
109
- "chain",
110
- ].includes(prop)
111
- ) {
112
- let blk = context.pending_children.slice(index || 0)[0];
113
- store(blk[prop], "readonly", initiator);
114
- } else if (
115
- [
116
- "parent",
117
- "context",
118
- "name",
119
- "hash",
120
- "path",
121
- "connections",
122
- "pending_children",
123
- "blocks",
124
- ].includes(prop)
125
- ) {
126
- let value = context[prop];
127
- if (index && Array.isArray(value)) value.slice(index)[0];
128
- store(value, "readonly", initiator);
129
- }
130
-
131
- return `${initiator.path}/Opcodes/readonly:${
132
- initiator.pending_children.slice(-1)[0].index
133
- }`;
134
- };
135
-
136
- write = (data, context) => {
137
- if (data.startsWith("{") && data.endsWith("}")) {
138
- let offset = data.split(":");
139
- let prop = data[0].slice(1);
140
- let index = Number(offset[1].slice(0, -1));
141
-
142
- data = this.readonly(prop, index, context);
143
- }
144
-
145
- if (!this.content) this.content = new Object();
146
-
147
- let col = this.content[this.col];
148
- if (!col) {
149
- col = new Array();
150
-
151
- this.content[this.col] = col;
152
- }
153
-
154
- if (!col.includes(data)) col.unshift(data);
155
- };
156
-
157
- read = (history) => {
158
- let res = this.content[this.row];
159
- if (this.col) res = res[this.col];
160
-
161
- return history != null ? res[history] : res;
162
- };
163
-
164
- run = (args, vm) => {
165
- let block = vm.web.explore({ name: args });
166
-
167
- block.map((blk) => vm.push(blk));
168
- };
169
-
170
- parse = (content) => {
171
- content = content || this.fetch_arg(`parse/content`);
172
-
173
- let obj = content && this.content;
174
- if (!obj) {
175
- obj = this.stringify();
176
- }
177
-
178
- obj = new Twain(obj);
179
-
180
- fs.writeFileSync(`${this.frame_path}/parse/output`, obj.stringify());
181
-
182
- return obj;
183
- };
184
-
185
- store = () => {
186
- let str = "";
187
- this.reset_content();
188
-
189
- this.contents.map((c) => (str += `${JSON.stringify(c)}\n`));
190
- fs.writeFileSync(this.path, str);
191
- };
192
-
193
- set_path = () => {
194
- if (!fs.existsSync(this.path)) {
195
- fs.writeFileSync(this.path, "");
196
- } else {
197
- this.existed = true;
198
- let content = fs.readFileSync(this.path, { encoding: "utf-8" });
199
- try {
200
- content = content.split("\n").map((c) => JSON.parse(c));
201
- } catch (e) {
202
- content = [];
203
- }
204
- if (!Array.isArray(content)) {
205
- content = [content];
206
- }
207
-
208
- this.contents = content;
209
- }
210
- };
211
- }
212
-
213
- 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 };