godprotocol 1.1.2 → 1.1.31

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.
package/utils/services.js CHANGED
@@ -50,6 +50,7 @@ const post_request = (payload, cb) => {
50
50
  typeof payload.data !== "string"
51
51
  ? JSON.stringify(payload.data)
52
52
  : payload.data;
53
+ console.log('uh')
53
54
 
54
55
  let req = http.request(
55
56
  {
@@ -71,6 +72,7 @@ const post_request = (payload, cb) => {
71
72
  });
72
73
 
73
74
  res.on("end", () => {
75
+ console.log('hey')
74
76
  resolve(JSON.parse(data));
75
77
  // console.log("Response:", data);
76
78
  });
package/utils/vm_utils.js CHANGED
@@ -3,68 +3,101 @@ import Callable from "../Datatypes/callable";
3
3
  import Num from "../Datatypes/num";
4
4
  import Str from "../Datatypes/str";
5
5
  import Twa from "../Datatypes/twa";
6
+ import Ins from "../Datatypes/instance";
6
7
  import Voi from "../Datatypes/voi";
8
+ import Bool from "../Datatypes/bool";
9
+ import Instance from "../Datatypes/instance";
10
+ import Func from "../Datatypes/func";
11
+ import Cls from "../Datatypes/cls";
7
12
 
8
13
  class Vm_utils {
9
- constructor() {}
14
+ constructor() {
15
+ this.literal_methods = {
16
+ number: ['add','sub','div','mul', 'exp', 'floordiv', 'eq', "ne", "lt", 'gt', 'gte', 'lte', 'neg', 'abs', 'and', 'or', 'xor', 'lshift', 'rshift', 'invert'].map(i=>`__${i}__`).concat(['to_int', 'to_float', 'to_string', 'sqrt', 'log', 'sin', 'sinh', 'tanh', 'cosh', 'atanh', 'acosh', 'asinh', 'atan', 'acos', 'asin', 'cos', 'tan', 'round', 'factorial', 'ceil', 'floor', 'is_prime', 'is_even', 'is_odd', 'is_perfect_square', 'to_degrees', 'to_radians']),
17
+ string: ['upper','lower','title','slice', 'concat', 'find', 'includes', 'index', 'trim', 'split', 'padstart', 'padend', 'repeat', 'replace', 'startswith', 'endswith', 'count', 'length', 'reverse', 'is_numeric', 'is_empty', 'is_blank', 'charcode'],
18
+ array:[
19
+ 'push', 'pop', 'length', 'run', 'copy', 'deepcopy', 'extend', 'slice', 'index', 'includes', 'replace', 'map', 'find', 'filter', 'padstart', 'padend', 'clear', 'to_string', 'reverse', 'repeat', 'join', 'splice'
20
+ ],
21
+ twain: [
22
+ 'entries', 'get', 'set', 'keys', 'clear', 'is_empty', 'values', 'copy', 'deepcopy', 'remove'
23
+ ]
24
+ }
25
+
26
+ this.datatypes = ['string', 'number', 'void', 'boolean', 'array', 'twain']
27
+ }
28
+
29
+ gen_uid = ()=>{
30
+ return `_${Math.random().toString().replace('.', '')}_${Date.now()}`
31
+ }
10
32
 
11
- handle_chain = async (address) => {
12
- let chain = await this.account.manager.web.spli_get(address);
33
+ parse_dynamic = async(literal, options={})=>{
34
+ let {chain, config} = options;
13
35
 
14
- return chain;
15
- };
36
+ let aircode = this.account.aircode;
37
+ let sequence = aircode.to_sequence(JSON.stringify(literal), chain.physical_address)
16
38
 
17
- get_type = (object) => {
18
- let type = typeof object;
39
+ let res = await chain.add_config(sequence[0].body[0]);
40
+ let address = await this.execute(res, {chain})
19
41
 
20
- if (type == "object") {
21
- if (Array.isArray(object)) type = "array";
22
- else if (!type) type = "void";
23
- else type = "twain";
42
+ return address;
43
+ }
44
+
45
+ resolve_addr = (addr)=>{
46
+ if (!addr)return addr
47
+
48
+ if (addr.startsWith('@')){
49
+ addr = `${this.account.physical_address}/${addr.slice(2)}`
24
50
  }
25
- return type;
26
- };
27
51
 
28
- parse_content = async (object, options) => {
29
- let { type } = options || {};
30
- if (!type) type = this.get_type(object);
52
+ return addr;
53
+ }
54
+
55
+ cloth_object = async addr=>{
56
+
57
+ }
31
58
 
32
- let instance;
33
- switch (type) {
34
- case "number":
35
- instance = new Num(object);
59
+ cloth_content = async(content, options)=>{
60
+ let obj;
61
+
62
+ if (content instanceof Instance)return content;
63
+
64
+ switch(content.type){
65
+ case 'number':
66
+ obj = new Num(content, this.account)
67
+ break;
68
+ case 'string':
69
+ obj = new Str(content, this.account)
70
+ break;
71
+ case 'boolean':
72
+ obj = new Bool(content, this.account)
36
73
  break;
37
- case "string":
38
- instance = new Str(object);
74
+ case 'void':
75
+ obj = new Voi(content, this.account)
39
76
  break;
40
- case "array":
41
- instance = new Arr(object);
77
+ case 'array':
78
+ obj = new Arr(content, this.account)
79
+ break
80
+ case 'twain':
81
+ obj = new Twa(content, this.account)
42
82
  break;
43
- case "twain":
44
- instance = new Twa(object);
83
+ case 'instance':
84
+ obj = new Instance(content, this.account)
45
85
  break;
46
- case "function":
47
- instance = new Callable(object);
86
+ case 'function':
87
+ obj = new Func(content, this.account)
48
88
  break;
49
- case "class":
50
- instance = new Callable(object);
89
+ case 'class':
90
+ obj = new Cls(content, this.account)
51
91
  break;
52
92
  default:
53
- instance = new Voi();
93
+ if (content.type === 'address'){
94
+ obj = new Func(content, this.account)
95
+ }else obj = content
96
+ // console.log(content, 'uh')
54
97
  }
55
98
 
56
- return instance;
57
- };
58
-
59
- read_chain = async (address) => {
60
- let chain = await this.handle_chain(address);
61
-
62
- let content = await chain.read();
63
- content =
64
- (content && (await content.parse())) || (await this.parse_content(null));
65
-
66
- return content;
67
- };
99
+ return await obj.sync(options)
100
+ }
68
101
  }
69
102
 
70
103
  export default Vm_utils;
@@ -1 +0,0 @@
1
- {"servers":[{"port":1408,"hostname":"127.0.0.1","repo":true,"domain":"127.0.0.1:1408"},{"port":1409,"hostname":"127.0.0.1","repo":true,"domain":"127.0.0.1:1409"}]}
@@ -1 +0,0 @@
1
- {"servers":[{"port":1408,"hostname":"127.0.0.1","repo":true,"domain":"127.0.0.1:1408"},{"port":1409,"hostname":"127.0.0.1","repo":true,"domain":"127.0.0.1:1409"}]}