godprotocol 1.0.7991 → 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 (88) 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 -7
  34. package/Loader_sequence/main.js +535 -119
  35. package/Loader_sequence/repository.js +33 -0
  36. package/Objects/Account.js +220 -54
  37. package/Objects/Block.js +46 -16
  38. package/Objects/Blockweb.js +14 -0
  39. package/Objects/Chain.js +163 -16
  40. package/Objects/Fee.js +33 -0
  41. package/Objects/Filesystem.js +100 -26
  42. package/Objects/Frame.js +10 -3
  43. package/Objects/Manager.js +272 -46
  44. package/Objects/Opcodes.js +60 -10
  45. package/Objects/Oracle.js +90 -5
  46. package/Objects/Protocol.js +5 -0
  47. package/Objects/Virtual_machine.js +145 -53
  48. package/Trinity.js +20 -0
  49. package/callables.js +172 -0
  50. package/framer.js +111 -52
  51. package/opcodes/add.js +6 -6
  52. package/opcodes/indices.js +82 -0
  53. package/opcodes/jmp.js +12 -11
  54. package/opcodes/std.js +7 -2
  55. package/opcodes.js +72 -14
  56. package/package.json +6 -5
  57. package/readme.md +1 -1
  58. package/starter_scripts/constants.seq +11 -0
  59. package/utils/create_server.js +34 -27
  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
  65. package/.babelrc +0 -3
  66. package/build/Account.js +0 -162
  67. package/build/Block.js +0 -65
  68. package/build/Blockweb.js +0 -36
  69. package/build/Chain.js +0 -119
  70. package/build/Explorer.js +0 -47
  71. package/build/Filesystem.js +0 -127
  72. package/build/Frame.js +0 -52
  73. package/build/Index.js +0 -15
  74. package/build/Manager.js +0 -99
  75. package/build/Opcodes.js +0 -39
  76. package/build/Oracle.js +0 -42
  77. package/build/Virtual_machine.js +0 -128
  78. package/build/add.js +0 -41
  79. package/build/create_server.js +0 -119
  80. package/build/framer.js +0 -57
  81. package/build/functions.js +0 -82
  82. package/build/hash.js +0 -14
  83. package/build/jmp.js +0 -19
  84. package/build/main.js +0 -283
  85. package/build/opcodes.js +0 -42
  86. package/build/privacy.js +0 -27
  87. package/build/services.js +0 -50
  88. package/build/std.js +0 -11
@@ -0,0 +1,95 @@
1
+ const readone = (args, vm, options) =>{
2
+ let {query} = args;
3
+
4
+ let {fold} = clean_check_folder(args, vm)
5
+
6
+ vm.display(query, (res)=>{
7
+ vm.air_object(fold.readone(res), options)
8
+ })
9
+ }
10
+
11
+ const read = (args, vm, options) =>{
12
+ let {query} = args;
13
+
14
+ let {fold} = clean_check_folder(args, vm)
15
+
16
+ vm.display(query, (res)=>{
17
+ vm.air_object(fold.read(res), options)
18
+ })
19
+ }
20
+
21
+ const clean_check_folder = (args, vm)=>{
22
+ let {folder}= args;
23
+
24
+ let name = vm.read_chain(folder.name)
25
+ if(name.__classifier__ !== vm.get_type_address('string')){
26
+ return vm.stderr({name:'Type_error', message: "Folder name must be a string."})
27
+ }else name = vm.static_value(name);
28
+
29
+ let fold = vm.account.manager.oracle.gds.folder(name.static_value)
30
+
31
+ return {name, fold}
32
+ }
33
+
34
+ const write = (args, vm, options) =>{
35
+ let {data} = args;
36
+
37
+ let {fold} = clean_check_folder(args, vm)
38
+
39
+ vm.display(data, (res)=>{
40
+ vm.air_object(fold.write(res), options)
41
+ })
42
+ }
43
+
44
+ const write_several = (args, vm, options) =>{
45
+ let {data} = args;
46
+
47
+ let {fold} = clean_check_folder(args, vm)
48
+
49
+ vm.display(data, (res)=>{
50
+ vm.air_object(fold.write_several(res), options)
51
+ })
52
+ }
53
+
54
+
55
+ const remove = (args, vm, options) =>{
56
+ let {query} = args;
57
+
58
+ let {fold} = clean_check_folder(args, vm)
59
+
60
+ vm.display(query, (res)=>{
61
+ vm.air_object(fold.remove(res), options)
62
+ })
63
+ }
64
+
65
+ const remove_several = (args, vm, options) =>{
66
+ let {query} = args;
67
+
68
+ let {fold} = clean_check_folder(args, vm)
69
+
70
+ vm.display(query, (res)=>{
71
+ vm.air_object(fold.remove_several(res), options)
72
+ })
73
+ }
74
+
75
+ const update = (args, vm, options) =>{
76
+ let {query} = args;
77
+
78
+ let {fold} = clean_check_folder(args, vm)
79
+
80
+ vm.display(query, (res)=>{
81
+ vm.air_object(fold.update(res), options)
82
+ })
83
+ }
84
+
85
+ const update_several = (args, vm, options) =>{
86
+ let {query} = args;
87
+
88
+ let {fold} = clean_check_folder(args, vm)
89
+
90
+ vm.display(query, (res)=>{
91
+ vm.air_object(fold.update_several(res), options)
92
+ })
93
+ }
94
+
95
+ export {read, readone, update, update_several, write, write_several, remove, remove_several}
@@ -0,0 +1,87 @@
1
+ import { read, readone, remove, remove_several, update, update_several, write, write_several } from "./folder";
2
+
3
+ const folder_register = (account)=>{
4
+ let add_callable = account.vm.add_callable;
5
+
6
+ add_callable('read_', {
7
+ callable: read,
8
+ config: {
9
+ parameters: [
10
+ {name:'folder', position:0},
11
+ {name:'query', position:1},
12
+ ]
13
+ }
14
+ })
15
+
16
+ add_callable('readone_', {
17
+ callable: readone,
18
+ config: {
19
+ parameters: [
20
+ {name:'folder', position:0},
21
+ {name:'query', position:1},
22
+ ]
23
+ }
24
+ })
25
+
26
+ add_callable('update_', {
27
+ callable: update,
28
+ config: {
29
+ parameters: [
30
+ {name:'folder', position:0},
31
+ {name:'query', position:1},
32
+ ]
33
+ }
34
+ })
35
+
36
+ add_callable('update_several_', {
37
+ callable: update_several,
38
+ config: {
39
+ parameters: [
40
+ {name:'folder', position:0},
41
+ {name:'query', position:1},
42
+ ]
43
+ }
44
+ })
45
+
46
+ add_callable('write_several_', {
47
+ callable: write_several,
48
+ config: {
49
+ parameters: [
50
+ {name:'folder', position:0},
51
+ {name:'data', position:1},
52
+ ]
53
+ }
54
+ })
55
+
56
+ add_callable('write', {
57
+ callable: write,
58
+ config: {
59
+ parameters: [
60
+ {name:'folder', position:0},
61
+ {name:'data', position:1},
62
+ ]
63
+ }
64
+ })
65
+
66
+ add_callable('remove_several_', {
67
+ callable: remove_several,
68
+ config: {
69
+ parameters: [
70
+ {name:'folder', position:0},
71
+ {name:'query', position:1},
72
+ ]
73
+ }
74
+ })
75
+
76
+ add_callable('remove', {
77
+ callable: remove,
78
+ config: {
79
+ parameters: [
80
+ {name:'folder', position:0},
81
+ {name:'query', position:1},
82
+ ]
83
+ }
84
+ })
85
+ }
86
+
87
+ export default folder_register
@@ -0,0 +1,13 @@
1
+ const importcheck = (args, vm)=>{
2
+ console.log(args, 'importcheck.args')
3
+ let {names} = args;
4
+
5
+ if(!Array.isArray(names)) names = [names]
6
+
7
+ for (let n=0; n< names.length; n++){
8
+ let name = names[n]
9
+
10
+ }
11
+ }
12
+
13
+ export default importcheck
@@ -0,0 +1,56 @@
1
+
2
+
3
+ const get = (args, vm, options)=>{
4
+ let{obj,prop}=args;
5
+
6
+ // console.log(args, 'get args')
7
+ if(!obj||!prop) return vm.stderr(`Invalid arguments in get.callable`)
8
+
9
+ if (obj.__classifier__ === vm.get_type_address('twain')){
10
+ let get_ = require('./methods/twain').get
11
+ return get_({twain: obj, prop}, vm, options)
12
+ }
13
+ prop = vm.static_value(prop)
14
+
15
+ if (prop.__print__){
16
+ vm.exec({executable: prop.__print__, location: (prop)=>{
17
+
18
+ if(!prop.static_value)return this.stderr({name:'Type_error', message: "get.callables"})
19
+
20
+ let addr = obj[prop.static_value]
21
+ let result = vm.read_chain(addr)
22
+
23
+ vm.write_chain(result, options.location)
24
+
25
+ }})
26
+
27
+ return;
28
+ }
29
+
30
+ let static_prop = prop.static_value
31
+ let addr = obj[static_prop]
32
+ let result = vm.read_chain(addr)
33
+
34
+ return {result, is_callable: !!(result.__address__ && vm.handle_chain(result.__address__).datapath)}
35
+ }
36
+
37
+ const set = (args, vm)=>{
38
+ let {obj, prop, value} = args;
39
+
40
+ // console.log(args, 'set args')
41
+ if(!obj || !prop || !value) return vm.stderr(`Invalid arguments in set.callable`)
42
+
43
+ prop = vm.static_value(prop)
44
+
45
+ let static_prop = prop.static_value
46
+ let val_addr = value.__address__
47
+ obj[static_prop] = val_addr;
48
+
49
+ vm.write_chain(obj, obj.__address__, {is_callable: !!vm.handle_chain(value.__address__).datapath})
50
+
51
+ return {
52
+ result: obj,
53
+ }
54
+ }
55
+
56
+ export {get, set}
@@ -0,0 +1,22 @@
1
+ const len = (args, vm, options) => {
2
+ let {object} = args;
3
+
4
+ if(![vm.get_type_address('string'),vm.get_type_address('array')].includes(object.__classifier__)){
5
+ if (object.__len__){
6
+ vm.exec({executable: object.__len__, location: result=>{
7
+ if (result.__classifier__ !== vm.get_type_address('number')){
8
+ return vm.stderr({name:'Type_error', message: `__len__ method should only return type of 'number'`})
9
+ }
10
+
11
+ vm.write_chain(result, options.location)
12
+ }})
13
+ }else return vm.air_object(null, options)
14
+ }
15
+
16
+ let statics = vm.static_value(object)
17
+
18
+ vm.air_object(statics.static_value.length, options)
19
+ }
20
+
21
+
22
+ export default len
@@ -0,0 +1,272 @@
1
+ import typecast from "../typecast";
2
+
3
+ const insert = (args, vm, options) => {
4
+ let { arr, index, value } = args;
5
+
6
+ if (
7
+ !index ||
8
+ (index && index.__classifier__ !== vm.get_type_address("number"))
9
+ )
10
+ index = { static_value: undefined };
11
+ else index = vm.static_value(index);
12
+
13
+ vm.exec({
14
+ executable: arr.__print__,
15
+ location: (result) => {
16
+ if (index.static_value != undefined) {
17
+ result.static_value.splice(index.static_value, 0, value.__address__);
18
+ } else result.static_value = [...result.static_value, value.__address__];
19
+
20
+ vm.write_chain(result, result.__address__);
21
+
22
+ vm.air_object(result.static_value.length, options);
23
+ },
24
+ });
25
+ };
26
+
27
+ const pop = (args, vm, options) => {
28
+ let { arr, index } = args;
29
+
30
+ if (
31
+ !index ||
32
+ (index && index.__classifier__ !== vm.get_type_address("number"))
33
+ )
34
+ index = { static_value: undefined };
35
+ else index = vm.static_value(index);
36
+
37
+ vm.exec({
38
+ executable: arr.__print__,
39
+ location: (result) => {
40
+ let item;
41
+ if (
42
+ index.static_value != undefined ||
43
+ index.static_value >= result.static_value.length
44
+ ) {
45
+ item = result.static_value.splice(index.static_value, 1);
46
+ item = item[0];
47
+ } else item = result.static_value.pop();
48
+
49
+ vm.write_chain(result, result.__address__);
50
+
51
+ vm.write_chain(vm.read_chain(item), options.location);
52
+ },
53
+ });
54
+ };
55
+
56
+ const repeat = (args, vm, options) => {
57
+ let {arr, n} = args;
58
+
59
+ if (
60
+ !n ||
61
+ (n && n.__classifier__ !== vm.get_type_address("number"))
62
+ )
63
+ n = { static_value: 0 };
64
+ else n = vm.static_value(n);
65
+
66
+ vm.exec({executable: arr.__print__, location: result=>{
67
+ let og = result.static_value;
68
+ let sv = [...result.static_value];
69
+
70
+ for (let i=0; i< n.static_value; i++){
71
+ sv.push(...og)
72
+ }
73
+ vm.write_chain({...result, static_value: sv}, result.__address__)
74
+ vm.write_chain(arr, options.location)
75
+ }})
76
+ };
77
+
78
+ const concat_ = (arr, other, index) => {
79
+ if (index === undefined || index > arr.length) {
80
+ index = arr.length;
81
+ }
82
+
83
+ let start = arr.slice(0, index);
84
+ let end = arr.slice(index);
85
+
86
+ arr = [...start, ...other, ...end];
87
+
88
+ return arr;
89
+ };
90
+
91
+ const concat = (args, vm, options) => {
92
+ let { spread } = options;
93
+ let { arr, other, index } = args;
94
+
95
+ if (other.__classifier__ !== vm.get_type_address("array")) {
96
+ other = typecast({
97
+ obj: vm.static_value(other),
98
+ typ: { static_value: "array" },
99
+ });
100
+ } else other = vm.static_value(other);
101
+ if (
102
+ !index ||
103
+ (index && index.__classifier__ !== vm.get_type_address("number"))
104
+ )
105
+ index = { static_value: undefined };
106
+ else index = vm.static_value(index);
107
+
108
+ vm.exec({
109
+ executable: arr.__print__,
110
+ location: (result) => {
111
+ let res = concat_(
112
+ result.static_value,
113
+ spread ? other.static_value : [other.static_value],
114
+ index.static_value
115
+ );
116
+ vm.write_chain({ ...result, static_value: res }, result.__address__);
117
+
118
+ vm.write_chain(arr, options.location);
119
+ },
120
+ });
121
+ };
122
+
123
+ const index = (args, vm, options) => {
124
+ let { arr, n } = args;
125
+
126
+ if (!n || (n && n.__classifier__ !== vm.get_type_address("number")))
127
+ return vm.air_object(null, options);
128
+ else n = vm.static_value(n);
129
+
130
+ vm.exec({
131
+ executable: arr.__print__,
132
+ location: (result) => {
133
+ if (n.static_value < 0 ||( n.static_value >= result.static_value.length))
134
+ return vm.air_object(null, options);
135
+
136
+ vm.write_chain(vm.read_chain(result.static_value[n.static_value]), options.location);
137
+ },
138
+ });
139
+ };
140
+
141
+ const slice = (args, vm, options) => {
142
+ let { arr, start, end } = args;
143
+
144
+ if (start.__classifier__ !== vm.get_type_address("number")) {
145
+ return { result: arr };
146
+ } else start = vm.static_value(start);
147
+
148
+ if (!end || (end && end.__classifier__ !== vm.get_type_address("number"))) {
149
+ end = { static_value: undefined };
150
+ } else end = vm.static_value(end);
151
+
152
+ vm.exec({
153
+ executable: arr.__print__,
154
+ location: (result) => {
155
+ let new_val = result.static_value.slice(
156
+ start.static_value,
157
+ end.static_value
158
+ );
159
+
160
+ vm.air_object(new_val, options);
161
+ },
162
+ });
163
+ };
164
+
165
+ const clear = (args, vm) => {
166
+ let { arr } = args;
167
+
168
+ vm.exec({
169
+ executable: arr.__print__,
170
+ location: (result) => {
171
+ result.static_value = [];
172
+ vm.write_chain(result, result.__address__);
173
+
174
+ vm.write_chain(arr, options.location);
175
+ },
176
+ });
177
+ };
178
+
179
+ const replace = (args, vm) => {
180
+ let { arr, index, value } = args;
181
+
182
+ if (
183
+ !index ||
184
+ (index && index.__classifier__ !== vm.get_type_address("number"))
185
+ )
186
+ return { result: arr };
187
+ else index = vm.static_value(index);
188
+
189
+ vm.exec({
190
+ executable: arr.__print__,
191
+ location: (result) => {
192
+ result.static_value.splice(index.static_value, 1, value.__address__);
193
+
194
+ vm.write_chain(result, result.__address__);
195
+
196
+ vm.write_chain(arr, options.location);
197
+ },
198
+ });
199
+ };
200
+
201
+ const find = (args, vm, options)=>{
202
+ let {index} = options;
203
+ let {arr, executable} = args;
204
+
205
+ // console.log(args, 'find.args')
206
+
207
+ vm.exec({executable: arr.__print__, location: result=>{
208
+ let stv = result.static_value;
209
+
210
+ vm.exec({executable, metadata: {loop:{index:0, array: stv, conditioner: res=>{
211
+ res = vm.static_value(res)
212
+ return (res && res.static_value === true)
213
+ }}}, arguments:{argv:[{address: stv[0], position: 0}], argc:1}, location: (result, metadata)=>{
214
+ result = vm.static_value(result)
215
+ if(result.static_value=== true){
216
+ if (index){
217
+ vm.air_object(metadata.loop.index, options)
218
+ }else vm.write_chain(this.read_chain(stv[metadata.loop.index]), options.location)
219
+ }else {
220
+ vm.air_object(index? -1: null, options)
221
+ }
222
+ }})
223
+ }})
224
+ }
225
+
226
+ const filter = (args, vm, options)=>{
227
+ let {arr, executable} = args;
228
+
229
+ // console.log(args, 'filter.args')
230
+
231
+ vm.exec({executable: arr.__print__, location: result=>{
232
+ let stv = result.static_value;
233
+ let filts = []
234
+
235
+ vm.exec({executable, metadata: {loop:{index:0, array: stv, conditioner: reslt=>{
236
+ let res = vm.static_value(reslt)
237
+ if (res && res.static_value === true){
238
+ filts.push(reslt)
239
+ }
240
+ return true
241
+ }}}, arguments:{argv:[{address: stv[0], position: 0}], argc:1}, location: (result, metadata)=>{
242
+ vm.air_object(filts, {...options, item_type:'static_object'})
243
+ }})
244
+ }})
245
+ }
246
+
247
+ const map = (args, vm, options)=>{
248
+ let {arr, executable} = args;
249
+
250
+ // console.log(args, 'map.args')
251
+
252
+ vm.exec({executable: arr.__print__, location: result=>{
253
+ let stv = result.static_value;
254
+ let mapped_values = []
255
+
256
+ vm.exec({executable, metadata: {loop:{index:0, array: stv, conditioner: (res, metadata)=>{
257
+ mapped_values.push(res)
258
+ return metadata.loop.index+1 === stv.length
259
+ }}}, arguments:{argv:[{address: stv[0], position: 0}], argc:1}, location: (result)=>{
260
+
261
+ vm.air_object(mapped_values, {...options, item_type:'static_object'})
262
+
263
+ }})
264
+
265
+ }})
266
+ }
267
+
268
+ const copy = (args, vm, options)=>{
269
+ let {arr, depth} = args;
270
+ }
271
+
272
+ export { pop, insert, repeat, map, concat, index, find, clear, slice, replace , filter, copy};