godprotocol 1.1.31 → 1.2.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.
- package/Datatypes/arr.js +559 -254
- package/Datatypes/bool.js +8 -5
- package/Datatypes/callable.js +1 -1
- package/Datatypes/cls.js +193 -24
- package/Datatypes/conf.js +2 -2
- package/Datatypes/err.js +25 -0
- package/Datatypes/func.js +89 -13
- package/Datatypes/functions/storage.js +572 -12
- package/Datatypes/functions/wallet.js +49 -0
- package/Datatypes/instance.js +87 -122
- package/Datatypes/num.js +192 -153
- package/Datatypes/str.js +188 -122
- package/Datatypes/twa.js +346 -71
- package/Datatypes/voi.js +9 -4
- package/Index.js +1 -1
- package/Instances/account.js +0 -0
- package/Instances/event.js +0 -0
- package/Instances/fold.js +103 -0
- package/Instances/folder_queries.js +46 -0
- package/Instances/response.js +31 -0
- package/Objects/Account.js +160 -110
- package/Objects/Blockweb.js +6 -11
- package/Objects/Callable.js +223 -188
- package/Objects/Chain.js +127 -142
- package/Objects/Datatypes.js +114 -588
- package/Objects/Manager.js +349 -39
- package/Objects/Oracle.js +283 -210
- package/Objects/Repository.js +12 -33
- package/Objects/Trinity.js +9 -7
- package/Objects/Utils.js +8 -8
- package/Objects/Virtual_machine.js +320 -320
- package/README.md +0 -0
- package/callables/functions/assert.js +10 -0
- package/callables/functions/display.js +2 -3
- package/callables/functions/env.js +5 -0
- package/callables/functions/event.js +14 -0
- package/callables/functions/exit.js +3 -2
- package/callables/functions/folder.js +15 -0
- package/callables/functions/get_uid.js +6 -0
- package/callables/functions/hash.js +7 -0
- package/callables/functions/import_.js +62 -0
- package/callables/functions/local.js +9 -0
- package/callables/functions/net.js +33 -18
- package/callables/functions/parse.js +35 -0
- package/callables/functions/query.js +12 -0
- package/callables/functions/render.js +9 -13
- package/callables/functions/servers.js +10 -0
- package/callables/functions/spawn.js +7 -0
- package/callables/functions/store.js +75 -0
- package/callables/functions/super_.js +24 -0
- package/callables/functions/typeof.js +32 -0
- package/callables/functions/wait.js +9 -0
- package/callables/register.js +193 -8
- package/html/create.js +110 -0
- package/html/index.js +114 -0
- package/html/load.js +165 -0
- package/html/parse.js +171 -0
- package/html/run.js +151 -0
- package/html/util.js +5 -0
- package/package.json +5 -3
- package/repos/fs.js +114 -0
- package/repos/github.js +73 -0
- package/repos/ram.js +47 -0
- package/utils/create_server.js +66 -26
- package/utils/hash.js +3 -2
- package/utils/ops.js +2 -0
- package/utils/oracle_handlers.js +7 -0
- package/utils/services.js +18 -51
- package/utils/socket_server.js +36 -0
- package/utils/vm_utils.js +271 -59
- package/callables/functions/assign.js +0 -6
package/Objects/Chain.js
CHANGED
|
@@ -1,208 +1,193 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Datatypes from "./Datatypes.js";
|
|
2
2
|
|
|
3
|
-
class
|
|
4
|
-
constructor(address,
|
|
5
|
-
super(
|
|
3
|
+
class Chain extends Datatypes{
|
|
4
|
+
constructor(address, account){
|
|
5
|
+
super()
|
|
6
6
|
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.path = ${this.account.manager.path}/${this.physical_address}
|
|
10
|
-
this.parent = parent;
|
|
7
|
+
this.address = address
|
|
8
|
+
this.account = account;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
chain = async(address)=>{
|
|
12
|
+
let chain = new Chain(address, this.account)
|
|
13
|
+
return chain;
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
await folder
|
|
16
|
+
folder = async (path)=>{
|
|
17
|
+
let fold = await this.account.ds.folder(this.address)
|
|
18
|
+
let folder = path ? await fold.folder(path) : fold
|
|
18
19
|
|
|
19
20
|
return folder
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let chain = await this.account.manager.web.set(address, this)
|
|
26
|
-
return chain;
|
|
23
|
+
read = async()=>{
|
|
24
|
+
let folder = await this.folder()
|
|
25
|
+
return await folder.readone()
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
write = async
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
let oracle = this.account.manager.oracle;
|
|
33
|
-
let conf = await oracle.fs.read(${this.path}/.config) || {}
|
|
34
|
-
|
|
35
|
-
let pth = ${this.path}/${options.hash}
|
|
36
|
-
let p_conf = await oracle.fs.read(${pth}/.config) || {}
|
|
37
|
-
let obj = {content, type: 'reference', previous: p_conf.current, sibling: conf.sibling}
|
|
38
|
-
let hsh = await oracle.hash(obj)
|
|
39
|
-
res = ${pth}/${hsh};
|
|
40
|
-
|
|
41
|
-
await oracle.fs.write(res, JSON.stringify(obj))
|
|
42
|
-
p_conf.current = res
|
|
43
|
-
await oracle.fs.write(${pth}/.config, JSON.stringify(p_conf))
|
|
44
|
-
|
|
45
|
-
conf.sibling = res;
|
|
46
|
-
await oracle.fs.write(${this.path}/.config, JSON.stringify(conf))
|
|
47
|
-
}else {
|
|
48
|
-
res = await this.persist(content, {...options })
|
|
49
|
-
}
|
|
50
|
-
return res
|
|
28
|
+
write = async(data)=>{
|
|
29
|
+
let folder = await this.folder()
|
|
30
|
+
return await folder.write(data)
|
|
51
31
|
}
|
|
52
32
|
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
return res;
|
|
57
|
-
}
|
|
33
|
+
write_config = async(config, options={})=>{
|
|
34
|
+
let folder = await this.folder('.configs')
|
|
58
35
|
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
let res = await folder.write(
|
|
37
|
+
{...config, _id: options._id || config._id},
|
|
38
|
+
{replace: !!config._id || options.replace}
|
|
39
|
+
)
|
|
40
|
+
return res.datapath
|
|
61
41
|
}
|
|
62
42
|
|
|
63
|
-
add_config = async
|
|
43
|
+
add_config = async(config, options)=>{
|
|
64
44
|
let result;
|
|
65
45
|
|
|
66
46
|
switch(config.type){
|
|
67
47
|
case 'module':
|
|
68
48
|
for (let b=0; b < config.body.length; b++){
|
|
69
49
|
let line = config.body[b]
|
|
70
|
-
|
|
71
50
|
config.body[b] = await this.add_config(line)
|
|
72
51
|
}
|
|
73
|
-
result = await this.write_config(config)
|
|
74
|
-
break;
|
|
75
|
-
case 'adm':
|
|
76
|
-
let adm_chain = await this.chain(config.location)
|
|
77
|
-
config.props = await this.add_config(config.props)
|
|
78
|
-
for (let c=0; c< config.children.length; c++){
|
|
79
|
-
config.children[c] = await this.add_config(config.children[c])
|
|
80
|
-
}
|
|
81
|
-
result = await adm_chain.write_config(config)
|
|
82
|
-
break;
|
|
83
|
-
case 'class':
|
|
84
|
-
let class_chain = await this.chain(config.name)
|
|
85
|
-
for (let name in config.methods){
|
|
86
|
-
config.methods[name] = await class_chain.add_config(config.methods[name])
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
result = await class_chain.write_config(config)
|
|
52
|
+
result = await this.write_config(config, options)
|
|
90
53
|
break;
|
|
91
54
|
case 'function':
|
|
92
|
-
let fn_chain = await this.chain(config.
|
|
93
|
-
for (let p=0; p< config.parameters.length; p++){
|
|
55
|
+
let fn_chain = await this.chain(config.address)
|
|
56
|
+
for (let p=0; p < config.parameters.length; p++){
|
|
94
57
|
config.parameters[p] = await fn_chain.add_config(config.parameters[p])
|
|
95
58
|
}
|
|
96
|
-
for (let b=0; b< config.body.length; b++){
|
|
97
|
-
|
|
59
|
+
for (let b=0; b < config.body.length; b++){
|
|
98
60
|
config.body[b] = await fn_chain.add_config(config.body[b])
|
|
99
61
|
}
|
|
100
62
|
result = await fn_chain.write_config(config)
|
|
101
63
|
break;
|
|
102
|
-
case '
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
break;
|
|
110
|
-
case 'trycatch':
|
|
111
|
-
let try_chain = await this.chain(config.location);
|
|
112
|
-
for (let t=0;t< config.try_body.length; t++){
|
|
113
|
-
config.try_body[t] = await this.add_config(config.try_body[t])
|
|
64
|
+
case 'class':
|
|
65
|
+
let cls_chain = await this.chain(config.address);
|
|
66
|
+
for (let name in config.methods){
|
|
67
|
+
let met = config.methods[name]
|
|
68
|
+
let res = await cls_chain.add_config(config.methods[name])
|
|
69
|
+
|
|
70
|
+
config.methods[name] = `${met.address}/${met._id}`
|
|
114
71
|
}
|
|
115
|
-
for (let
|
|
116
|
-
|
|
72
|
+
for (let name in config.properties){
|
|
73
|
+
let met = config.properties[name]
|
|
74
|
+
let res = await cls_chain.add_config(config.properties[name])
|
|
75
|
+
config.properties[name] = res
|
|
117
76
|
}
|
|
118
|
-
|
|
119
|
-
|
|
77
|
+
|
|
78
|
+
for (let name in config.class_.properties){
|
|
79
|
+
let met = config.class_.properties[name]
|
|
80
|
+
let res = await cls_chain.add_config(config.class_.properties[name])
|
|
81
|
+
config.class_.properties[name] = res
|
|
120
82
|
}
|
|
121
|
-
|
|
122
|
-
|
|
83
|
+
|
|
84
|
+
for (let name in config.class_.methods){
|
|
85
|
+
let met = config.class_.methods[name]
|
|
86
|
+
let res = await cls_chain.add_config(config.class_.methods[name])
|
|
87
|
+
config.class_.methods[name] = `${met.address}/${met._id}`
|
|
88
|
+
}
|
|
89
|
+
result = await cls_chain.write_config(config)
|
|
90
|
+
break
|
|
123
91
|
case 'condition':
|
|
124
92
|
let cond_chain = await this.chain(config.location)
|
|
125
|
-
for(let b=
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
for (let
|
|
129
|
-
|
|
93
|
+
for (let b=0; b< config.blocks.length; b++){
|
|
94
|
+
let blk = config.blocks[b]
|
|
95
|
+
blk.predicate = await this.add_config(blk.predicate)
|
|
96
|
+
for (let d = 0; d <blk.body.length; d++){
|
|
97
|
+
blk.body[d] = await this.add_config(blk.body[d])
|
|
130
98
|
}
|
|
131
99
|
}
|
|
132
100
|
result = await cond_chain.write_config(config)
|
|
133
101
|
break;
|
|
134
|
-
case 'assignment':
|
|
135
|
-
let ass_chain = await this.chain(config.identifier)
|
|
136
|
-
|
|
137
|
-
config.value = await ass_chain.add_config(config.value);
|
|
138
|
-
|
|
139
|
-
result = await ass_chain.write_config(config)
|
|
140
|
-
break;
|
|
141
102
|
case 'loop':
|
|
142
103
|
let loop_chain = await this.chain(config.location)
|
|
143
|
-
config.
|
|
144
|
-
if(config.loop_type === 'for'){
|
|
145
|
-
config.iterator = await this.add_config(config.iterator)
|
|
104
|
+
if (config.loop_type === 'for'){
|
|
146
105
|
config.update = await this.add_config(config.update)
|
|
106
|
+
config.iterator = await this.add_config(config.iterator)
|
|
147
107
|
}
|
|
108
|
+
config.condition = await this.add_config(config.condition)
|
|
148
109
|
|
|
149
110
|
for (let b=0; b< config.body.length; b++){
|
|
150
111
|
config.body[b] = await this.add_config(config.body[b])
|
|
151
112
|
}
|
|
152
113
|
result = await loop_chain.write_config(config)
|
|
153
114
|
break;
|
|
115
|
+
case 'assignment':
|
|
116
|
+
config.value = await this.add_config(config.value)
|
|
117
|
+
result = await (await this.chain(`${this.address}/${config.identifier}`)).write_config(config)
|
|
118
|
+
break;
|
|
119
|
+
case 'nest':
|
|
120
|
+
let n_chain = await this.chain(config.location)
|
|
121
|
+
for (let n=0; n < config.nests.length; n++){
|
|
122
|
+
config.nests[n] = await n_chain.add_config(config.nests[n])
|
|
123
|
+
}
|
|
124
|
+
result = await n_chain.write_config(config)
|
|
125
|
+
break;
|
|
126
|
+
case 'return':
|
|
127
|
+
config.output = await this.add_config(config.output)
|
|
128
|
+
result = config;
|
|
129
|
+
break;
|
|
154
130
|
case 'call':
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
config.identifier =
|
|
131
|
+
let call_chn = await this.chain(config.location)
|
|
132
|
+
if (config.identifier.type === 'nest'){
|
|
133
|
+
config.identifier = await (await this.chain(config.identifier.location)).write_config(config.identifier)
|
|
158
134
|
}
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
|
|
135
|
+
for (let a=0; a < config.arguments.length; a++){
|
|
136
|
+
let arg = config.arguments[a]
|
|
137
|
+
let chn = await this.chain(arg.location)
|
|
138
|
+
config.arguments[a] = await chn.add_config(arg)
|
|
162
139
|
}
|
|
163
|
-
result = await
|
|
140
|
+
result = await call_chn.write_config(config)
|
|
141
|
+
break
|
|
142
|
+
case 'adm':
|
|
143
|
+
console.log(config)
|
|
144
|
+
let adm_chain = await this.chain(config.location)
|
|
145
|
+
result = await adm_chain.write_config(config)
|
|
164
146
|
break;
|
|
165
|
-
case '
|
|
166
|
-
let
|
|
167
|
-
|
|
168
|
-
|
|
147
|
+
case 'trycatch':
|
|
148
|
+
let try_chain = await this.chain(config.location)
|
|
149
|
+
|
|
150
|
+
for (let i=0; i < config.try_body.length; i++){
|
|
151
|
+
let tbd = config.try_body[i]
|
|
152
|
+
config.try_body[i] = await try_chain.add_config(tbd)
|
|
169
153
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
154
|
+
for (let i=0; i < config.catch_body.length; i++){
|
|
155
|
+
let tbd = config.catch_body[i]
|
|
156
|
+
config.catch_body[i] = await try_chain.add_config(tbd)
|
|
157
|
+
}
|
|
158
|
+
result = await try_chain.write_config(config)
|
|
174
159
|
break;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
160
|
+
case 'raise':
|
|
161
|
+
let raise_chain = await this.chain(config.location)
|
|
162
|
+
config.object = await raise_chain.add_config(config.object)
|
|
163
|
+
result = raise_chain.write_config(config)
|
|
164
|
+
break
|
|
165
|
+
default:
|
|
166
|
+
if (config.type === 'void'){
|
|
181
167
|
result = config
|
|
182
|
-
}else if(config.type
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let item = config.value[i]
|
|
194
|
-
config.value[i] = await this.add_config(item)
|
|
168
|
+
}else if (this.account.vm.datatypes.includes(config.type)){
|
|
169
|
+
if (config.type === 'array'){
|
|
170
|
+
for (let i=0; i< config.value.length; i++){
|
|
171
|
+
config.value[i] = await this.add_config(config.value[i])
|
|
172
|
+
}
|
|
173
|
+
} else if (config.type === 'twain'){
|
|
174
|
+
for (let key in config.value){
|
|
175
|
+
let pair = config.value[key]
|
|
176
|
+
pair[0] = await this.add_config(pair[0])
|
|
177
|
+
pair[1] = await this.add_config(pair[1])
|
|
178
|
+
}
|
|
195
179
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
180
|
+
let d_chain = await this.chain(config.location)
|
|
181
|
+
result = await d_chain.write_config(config)
|
|
182
|
+
} else if (['variable', 'reference'].includes(config.type)) {
|
|
183
|
+
result = config
|
|
184
|
+
} else if (['continue', 'break'].includes(config.type)) {
|
|
185
|
+
result = config
|
|
199
186
|
}
|
|
200
|
-
|
|
201
187
|
}
|
|
202
188
|
|
|
203
189
|
return result;
|
|
204
190
|
}
|
|
205
|
-
|
|
206
191
|
}
|
|
207
192
|
|
|
208
|
-
export default
|
|
193
|
+
export default Chain;
|