godprotocol 1.0.842 → 1.1.0

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 (64) hide show
  1. package/Executables/callables.js +131 -0
  2. package/Executables/executables.js +230 -0
  3. package/Executables/functions/adminstrator/adm_register.js +29 -0
  4. package/Executables/functions/adminstrator/native_components.js +10 -0
  5. package/Executables/functions/adminstrator/query_selectors.js +10 -0
  6. package/Executables/functions/adminstrator/render.js +24 -0
  7. package/Executables/functions/array_register.js +161 -0
  8. package/Executables/functions/assign.js +19 -0
  9. package/Executables/functions/display.js +55 -0
  10. package/Executables/functions/folder.js +95 -0
  11. package/Executables/functions/folder_register.js +87 -0
  12. package/Executables/functions/importcheck.js +13 -0
  13. package/Executables/functions/indices.js +56 -0
  14. package/Executables/functions/len.js +22 -0
  15. package/Executables/functions/methods/array.js +272 -0
  16. package/Executables/functions/methods/string.js +197 -0
  17. package/Executables/functions/methods/twain.js +148 -0
  18. package/Executables/functions/op.js +15 -0
  19. package/Executables/functions/price_register.js +30 -0
  20. package/Executables/functions/pricing.js +26 -0
  21. package/Executables/functions/servers/account.js +81 -0
  22. package/Executables/functions/servers/account_register.js +56 -0
  23. package/Executables/functions/servers/block.js +21 -0
  24. package/Executables/functions/servers/block_register.js +18 -0
  25. package/Executables/functions/servers/chain.js +42 -0
  26. package/Executables/functions/servers/chain_register.js +28 -0
  27. package/Executables/functions/set_error_catch.js +34 -0
  28. package/Executables/functions/string_register.js +130 -0
  29. package/Executables/functions/twain_register.js +56 -0
  30. package/Executables/functions/typecast.js +43 -0
  31. package/Executables/functions/utils.js +9 -0
  32. package/Executables/stack.js +53 -0
  33. package/Index.js +2 -55
  34. package/Loader_sequence/main.js +371 -124
  35. package/Loader_sequence/repository.js +1 -1
  36. package/Objects/Account.js +101 -34
  37. package/Objects/Block.js +24 -18
  38. package/Objects/Blockweb.js +1 -1
  39. package/Objects/Chain.js +127 -29
  40. package/Objects/Explorer.js +3 -17
  41. package/Objects/Fee.js +33 -0
  42. package/Objects/Filesystem.js +98 -25
  43. package/Objects/Frame.js +10 -3
  44. package/Objects/Manager.js +193 -23
  45. package/Objects/Opcodes.js +48 -10
  46. package/Objects/Oracle.js +11 -8
  47. package/Objects/Protocol.js +5 -0
  48. package/Objects/Virtual_machine.js +130 -59
  49. package/Trinity.js +20 -0
  50. package/callables.js +172 -0
  51. package/framer.js +65 -12
  52. package/opcodes/add.js +6 -1
  53. package/opcodes/indices.js +60 -6
  54. package/opcodes/jmp.js +2 -0
  55. package/opcodes/std.js +5 -2
  56. package/opcodes.js +56 -18
  57. package/package.json +2 -2
  58. package/starter_scripts/constants.seq +11 -0
  59. package/utils/create_server.js +15 -7
  60. package/utils/hash.js +2 -2
  61. package/utils/logger.js +79 -0
  62. package/utils/services.js +5 -3
  63. package/utils/type_coersion.js +3 -0
  64. package/utils/vm_utils.js +292 -0
@@ -0,0 +1,130 @@
1
+ import { case_, concat, includes, index, indexof, repeat, slice, split, trim } from "./methods/string";
2
+
3
+ const string_register = (account)=>{
4
+ let add_callable = account.vm.add_callable;
5
+
6
+ add_callable('slice_', {
7
+ callable: slice,
8
+ config: {
9
+ parameters: [
10
+ {name:'str', position:0},
11
+ {name:'start', position:1},
12
+ {name:'end', position:2},
13
+ ]
14
+ }
15
+ })
16
+
17
+ add_callable('concat_', {
18
+ callable: concat,
19
+ config: {
20
+ parameters: [
21
+ {name:'str', position:0},
22
+ {name:'other', position:1},
23
+ {name:'index', position:2},
24
+ ]
25
+ }
26
+ })
27
+
28
+ add_callable('case_', {
29
+ callable: case_,
30
+ config: {
31
+ parameters: [
32
+ {name:'str', position:0},
33
+ {name:'type', position:1},
34
+ ]
35
+ }
36
+ })
37
+
38
+ add_callable('index_', {
39
+ callable: slice,
40
+ config: {
41
+ parameters: [
42
+ {name:'str', position:0},
43
+ {name:'n', position:1},
44
+ ]
45
+ }
46
+ })
47
+
48
+ add_callable('indexof_', {
49
+ callable: slice,
50
+ config: {
51
+ parameters: [
52
+ {name:'str', position:0},
53
+ {name:'char', position:1},
54
+ ]
55
+ }
56
+ })
57
+
58
+ add_callable('includes_', {
59
+ callable: slice,
60
+ config: {
61
+ parameters: [
62
+ {name:'str', position:0},
63
+ {name:'chars', position:1},
64
+ ]
65
+ }
66
+ })
67
+
68
+ add_callable('trim_', {
69
+ callable: trim,
70
+ config: {
71
+ parameters: [
72
+ {name:'str', position:0},
73
+ {name:'char', position:1},
74
+ {name:'type', position:2},
75
+ ]
76
+ }
77
+ })
78
+
79
+ add_callable('split_', {
80
+ callable: split,
81
+ config: {
82
+ parameters: [
83
+ {name:'str', position:0},
84
+ {name:'char', position:1}
85
+ ]
86
+ }
87
+ })
88
+
89
+ add_callable('repeat_', {
90
+ callable: repeat,
91
+ config: {
92
+ parameters: [
93
+ {name: 'str', position:0},
94
+ {name: 'n', position:1},
95
+ ]
96
+ }
97
+ })
98
+
99
+ add_callable('repeat_', {
100
+ callable: index,
101
+ config: {
102
+ parameters: [
103
+ {name: 'str', position:0},
104
+ {name: 'n', position:1},
105
+ ]
106
+ }
107
+ })
108
+
109
+ add_callable('repeat_', {
110
+ callable: indexof,
111
+ config: {
112
+ parameters: [
113
+ {name: 'str', position:0},
114
+ {name: 'char', position:1},
115
+ ]
116
+ }
117
+ })
118
+
119
+ add_callable('repeat_', {
120
+ callable: includes,
121
+ config: {
122
+ parameters: [
123
+ {name: 'str', position:0},
124
+ {name: 'chars', position:1},
125
+ ]
126
+ }
127
+ })
128
+ }
129
+
130
+ export default string_register
@@ -0,0 +1,56 @@
1
+ import { entries, get, keys, set, unset } from "./methods/twain";
2
+
3
+ const twain_register = (account)=>{
4
+ let add_callable = account.vm.add_callable;
5
+
6
+ add_callable('get_', {
7
+ callable: get,
8
+ config: {
9
+ parameters:[
10
+ {name: 'twain', position:0},
11
+ {name: 'prop', position:1},
12
+ ]
13
+ }
14
+ })
15
+
16
+ add_callable('set_', {
17
+ callable: set,
18
+ config: {
19
+ parameters:[
20
+ {name: 'twain', position:0},
21
+ {name: 'prop', position:1},
22
+ {name: 'value', position:2},
23
+ ]
24
+ }
25
+ })
26
+
27
+ add_callable('keys_', {
28
+ callable: keys,
29
+ config: {
30
+ parameters:[
31
+ {name: 'twain', position:0}
32
+ ]
33
+ }
34
+ })
35
+
36
+ add_callable('entries_', {
37
+ callable: entries,
38
+ config: {
39
+ parameters:[
40
+ {name: 'twain', position:0}
41
+ ]
42
+ }
43
+ })
44
+
45
+ add_callable('unset_', {
46
+ callable: unset,
47
+ config: {
48
+ parameters:[
49
+ {name: 'twain', position:0},
50
+ {name: 'prop', position:1},
51
+ ]
52
+ }
53
+ })
54
+ }
55
+
56
+ export default twain_register
@@ -0,0 +1,43 @@
1
+ const typecast =(args, vm, options)=>{
2
+
3
+ // console.log(args, 'typecast args')
4
+ let {type, obj}= args;
5
+ type = vm.static_value(type)
6
+ let static_type = type.static_value;
7
+ let result;
8
+
9
+ if (obj.hasOwnProperty('static_value')){
10
+ if(static_type === 'boolean'){
11
+ result= (!!obj.static_value)
12
+
13
+ return {result: vm.static_cast(result, obj.__address__)};
14
+ } else if(static_type === 'string'){
15
+ result = obj.static_value.toString()
16
+
17
+ return {result: vm.static_cast(result, obj.__address__)}
18
+ } else if (static_type === 'number'){
19
+ result = parseInt(obj.static_value)
20
+ if (isNaN(result)){
21
+ result = null
22
+ }
23
+ return {result: vm.static_cast(result, obj.__address__)};
24
+ }else if (static_type === 'array'){
25
+ if (obj.type === 'array'){
26
+ return {result: obj}
27
+ }
28
+ }else if (static_type === 'twain'){
29
+ if (obj.type === 'twain'){
30
+ return {result: obj}
31
+ }
32
+ }
33
+ } else if(obj.__print__) {
34
+ console.log(obj)
35
+ vm.exec({executable:obj.__print__, location:result=>{
36
+ let res = typecast({...args, obj: result}, vm)
37
+ res && vm.write_chain(res.result, options.location)
38
+ }})
39
+ }
40
+ }
41
+
42
+
43
+ export default typecast
@@ -0,0 +1,9 @@
1
+ const get_address = (args, vm, options) => {
2
+ return vm.air_object(args.object.__address__, options)
3
+ }
4
+
5
+ const get_id = (args, vm, options) => {
6
+ return vm.air_object(args.object.__id__, options)
7
+ }
8
+
9
+ export {get_address, get_id}
@@ -0,0 +1,53 @@
1
+ class Stack {
2
+ constructor(vm){
3
+ this.vm = vm;
4
+
5
+ this.stacks = new Object()
6
+ }
7
+
8
+ has_stack = (stack)=>{
9
+ stack = this.stacks[stack]
10
+ return !!(stack && stack.length)
11
+ }
12
+
13
+ initiate = (stack)=>{
14
+ let stack_arr = this.stacks[stack]
15
+ if(!stack_arr){
16
+ stack_arr = new Array({})
17
+ this.stacks[stack] = stack_arr;
18
+ }else stack_arr.push({})
19
+ }
20
+
21
+ push = (stack, block)=>{
22
+ stack = this.stacks[stack]
23
+ if(!stack)return
24
+ let trace = stack.slice(-1)[0]
25
+
26
+ trace[block.chain.name] = block;
27
+ }
28
+
29
+ pop = (stack_name)=>{
30
+ let stack = this.stacks[stack_name]
31
+ if (!stack)return
32
+
33
+ let trace = stack.pop()
34
+
35
+ this.repopulate(stack_name)
36
+
37
+ return trace
38
+ }
39
+
40
+ repopulate = (stack)=>{
41
+ let trace = this.stacks[stack].slice(-1)[0]
42
+
43
+ for(let name in trace){
44
+ let block = trace[name]
45
+
46
+ let chain = this.vm.handle_chain(block.chain.physical_address)
47
+ chain.forge_block(block.stringify())
48
+ }
49
+ }
50
+ }
51
+
52
+
53
+ export default Stack
package/Index.js CHANGED
@@ -1,57 +1,4 @@
1
- import Manager from "./Objects/Manager";
2
- import create_server from "./utils/create_server";
1
+ import Trinity from "./Trinity";
3
2
 
4
- // let manager = new Manager();
5
3
 
6
- // let initiator = manager.initiate({
7
- // on_framed: () =>
8
- // initiator.assembler.run(
9
- // `@/datastore/main
10
-
11
- // >object
12
- // >keys []
13
- // >entries {}
14
- // >size 0
15
-
16
- // ./set
17
- // >key
18
- // >key_static getter key "static_value"
19
- // >value
20
- // >exists getter ../entries key
21
- // jmp_not_void :proceed
22
- // >../size add ../size 1
23
- // >../keys setter ../keys -1 key
24
-
25
- // :proceed
26
- // >../entries setter ../entries key_static value
27
- // ;
28
-
29
- // ./get
30
- // >key
31
- // >value getter ../entries key
32
- // ;
33
-
34
- // ./remove
35
- // >key
36
- // >../entries delete ../entries key
37
- // >../keys delete ../keys key
38
- // >../size sub ../size 1
39
- // ;
40
-
41
- // ./get_keys
42
- // >output ../keys
43
- // ;
44
-
45
- // ;`,
46
- // {
47
- // cb: (blks) => {
48
- // console.log(blks, blks.length, "did");
49
- // },
50
- // }
51
- // ),
52
- // });
53
-
54
- // create_server(null, { manager });
55
-
56
- export default Manager;
57
- export { create_server };
4
+ export default new Trinity();