godprotocol 1.1.32 → 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 +241 -137
- package/callables/functions/assign.js +0 -6
package/Objects/Oracle.js
CHANGED
|
@@ -1,268 +1,341 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import Fs from "godprotocol/repos/fs.js";
|
|
2
|
+
import Handlers from "godprotocol/utils/oracle_handlers.js";
|
|
3
|
+
import { post_request } from "godprotocol/utils/services.js";
|
|
4
|
+
|
|
5
|
+
class Oracle extends Handlers{
|
|
6
|
+
constructor(server, mirror) {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.server = server
|
|
10
|
+
this.mirror = mirror;
|
|
11
|
+
this.repos = new Array()
|
|
12
|
+
this.remotes = new Array()
|
|
13
|
+
}
|
|
4
14
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
15
|
+
add_repo = async (repository)=>{
|
|
16
|
+
let {filter, repo} = repository
|
|
17
|
+
if (await this.get_repo(repo.type, repo.options.name))
|
|
18
|
+
return;
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
switch(repo.type){
|
|
21
|
+
case 'fs':
|
|
22
|
+
repo = new Fs(repo.options)
|
|
23
|
+
break
|
|
24
|
+
}
|
|
25
|
+
this.repos.push({filter, repo})
|
|
12
26
|
|
|
13
|
-
|
|
14
|
-
if(
|
|
27
|
+
if(!this.manager) return;
|
|
28
|
+
if (this.server_match(this.manager.server, this.server)){
|
|
29
|
+
for (let r=0; r< this.remotes.length; r++){
|
|
30
|
+
let remote = this.remotes[r]
|
|
15
31
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
await this.fetch({
|
|
33
|
+
method: 'add_repo',
|
|
34
|
+
arg: {...repo}
|
|
35
|
+
}, remote)
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
await this.fetch({
|
|
39
|
+
method: 'add_repo',
|
|
40
|
+
arg: {...repo}
|
|
41
|
+
}, this.server)
|
|
22
42
|
}
|
|
23
43
|
}
|
|
24
44
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
call = async(payload)=>{
|
|
46
|
+
let {method, arg} = payload, result = {};
|
|
47
|
+
|
|
48
|
+
switch(method){
|
|
49
|
+
case 'update_servers':
|
|
50
|
+
let addr = `.oracle/${arg.account}/.configs`
|
|
51
|
+
let servers = await this.get_from_repos(addr)
|
|
52
|
+
if (servers){
|
|
53
|
+
servers = JSON.parse(servers)
|
|
54
|
+
if (servers.find(s=>this.server_match(s, arg.server))){
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
servers.push(arg.server)
|
|
58
|
+
}else servers = [arg.server]
|
|
59
|
+
|
|
60
|
+
await this.set_to_repos(addr, JSON.stringify(servers))
|
|
61
|
+
break;
|
|
62
|
+
case 'update_accounts':
|
|
63
|
+
let a_addr = `.oracle/${arg.address}/.configs`
|
|
64
|
+
let accs = await this.get_from_repos(a_addr)
|
|
65
|
+
if (accs){
|
|
66
|
+
accs = JSON.parse(accs)
|
|
67
|
+
if (accs.includes(arg.account)){
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
accs.push(arg.account)
|
|
71
|
+
}else accs = [arg.account]
|
|
72
|
+
|
|
73
|
+
await this.set_to_repos(a_addr, JSON.stringify(accs))
|
|
74
|
+
break
|
|
75
|
+
case 'get_accounts':
|
|
76
|
+
result = this.get_accounts(arg.address, true)
|
|
77
|
+
break
|
|
78
|
+
case 'get_servers':
|
|
79
|
+
result = this.get_servers(arg.account, true)
|
|
80
|
+
break
|
|
81
|
+
case 'write':
|
|
82
|
+
await this.set_to_repos(`${arg.prefix}/${arg.path}`, arg.content)
|
|
83
|
+
break;
|
|
84
|
+
case 'read':
|
|
85
|
+
let res = await this.get_from_repos(`${arg.prefix}/${arg.path}`)
|
|
86
|
+
result = {content: res}
|
|
87
|
+
break;
|
|
88
|
+
case 'fs':
|
|
89
|
+
let repo = await this.get_repo('fs', arg.name)
|
|
90
|
+
result = await repo.call(arg.payload)
|
|
91
|
+
break
|
|
92
|
+
case 'sync':
|
|
93
|
+
let repos = this.string_repos()
|
|
94
|
+
await this.push_remote(arg.manager_server)
|
|
95
|
+
result = {repos}
|
|
96
|
+
break
|
|
97
|
+
case 'add_repo':
|
|
98
|
+
await this.add_repo(arg)
|
|
99
|
+
break
|
|
100
|
+
}
|
|
31
101
|
|
|
32
|
-
|
|
33
|
-
}
|
|
102
|
+
return result
|
|
103
|
+
}
|
|
34
104
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
try{
|
|
38
|
-
content = this.fs.readFileSync(`${this.base}/${path}`, {encoding:'utf-8'})
|
|
39
|
-
content = JSON.parse(content)
|
|
40
|
-
}catch(e){}
|
|
105
|
+
push_remote = async(remote)=>{
|
|
106
|
+
if (this.remotes.find(rem=>this.server_match(rem, remote))) return;
|
|
41
107
|
|
|
42
|
-
|
|
108
|
+
this.remotes.push(remote)
|
|
43
109
|
}
|
|
44
110
|
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
config = await this.read(`${path}/.config`) || {};
|
|
51
|
-
|
|
52
|
-
if (!config.current) {
|
|
53
|
-
if (options.config){
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (options.sibling){
|
|
60
|
-
if (config.sibling){
|
|
61
|
-
let res = await this.read(`${config.sibling}`)
|
|
62
|
-
result = res.content
|
|
63
|
-
}
|
|
64
|
-
}else{
|
|
65
|
-
if (config.current){
|
|
66
|
-
let res = await this.read(`${config.current}/.config`)
|
|
67
|
-
|
|
68
|
-
let value = await this.read(`${config.current}/${res.index-1}`)
|
|
69
|
-
if(!value && res.current && !res.current.includes('/')){
|
|
70
|
-
value = await this.read(`${config.current}/${res.current}`)
|
|
71
|
-
}
|
|
72
|
-
if(options.config){
|
|
73
|
-
result = typeof value.content === 'string'? JSON.parse(value.content): value.content;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
111
|
+
string_repos = ()=>{
|
|
112
|
+
let repos = new Array();
|
|
113
|
+
for(let r=0; r< this.repos.length; r++){
|
|
114
|
+
let {filter, repo} = this.repos[r];
|
|
115
|
+
repos.push({filter, repo:{type: repo.type, options: repo.objectify()}})
|
|
76
116
|
}
|
|
117
|
+
return repos;
|
|
118
|
+
}
|
|
77
119
|
|
|
78
|
-
|
|
120
|
+
get_repo = async(type, name) => {
|
|
121
|
+
for (let r=0; r< this.repos.length; r++){
|
|
122
|
+
let {repo} = this.repos[r]
|
|
123
|
+
|
|
124
|
+
if (repo.type === type && repo.name === name)
|
|
125
|
+
return repo
|
|
126
|
+
}
|
|
79
127
|
}
|
|
80
128
|
|
|
81
|
-
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
await
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
await this.mkdir(current)
|
|
95
|
-
let current_conff = `${current}/.config`
|
|
96
|
-
let conff = await this.read(current_conff) || {index: 0}
|
|
97
|
-
await this.write(`${current}/${conff.index}`, JSON.stringify(obj))
|
|
98
|
-
conff.index++
|
|
99
|
-
|
|
100
|
-
await this.write(current_conff, JSON.stringify(conff))
|
|
101
|
-
addr = current
|
|
102
|
-
}else {
|
|
103
|
-
this.fs.writeFileSync(`${this.base}/${path}`, content)
|
|
104
|
-
addr = path;
|
|
129
|
+
fetch = async(payload, server)=>{
|
|
130
|
+
let res;
|
|
131
|
+
try{
|
|
132
|
+
res = await post_request({
|
|
133
|
+
options: {
|
|
134
|
+
...server,
|
|
135
|
+
path: '/oracle'
|
|
136
|
+
},
|
|
137
|
+
data: JSON.stringify(payload)
|
|
138
|
+
})
|
|
139
|
+
}catch(e){
|
|
140
|
+
console.log(e)
|
|
105
141
|
}
|
|
106
142
|
|
|
107
|
-
return
|
|
143
|
+
return res;
|
|
108
144
|
}
|
|
109
145
|
|
|
110
|
-
|
|
111
|
-
|
|
146
|
+
set_to_repos = async(address, content)=>{
|
|
147
|
+
for (let r=0; r< this.repos.length; r++){
|
|
148
|
+
let repo = this.repos[r]
|
|
112
149
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
await this.mkdir(arr_path)
|
|
150
|
+
if (!repo.filter || address.match(repo.filter)){
|
|
151
|
+
await repo.repo.write_file(address, content)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
119
155
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
156
|
+
get_from_repos = async(address)=>{
|
|
157
|
+
for (let r=0; r< this.repos.length; r++){
|
|
158
|
+
let repo = this.repos[r]
|
|
159
|
+
|
|
160
|
+
if (!repo.filter || address.match(repo.filter)){
|
|
161
|
+
let content = await repo.repo.read_file(address)
|
|
162
|
+
if (content) return content;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
123
166
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
167
|
+
read = async(path, options={})=>{
|
|
168
|
+
let {address, account, prefix} = options;
|
|
169
|
+
prefix = prefix || '.storage'
|
|
127
170
|
|
|
128
|
-
|
|
129
|
-
if(!conf) conf = {index:0}
|
|
130
|
-
else conf.index++
|
|
171
|
+
let has = (await this.get_accounts(address)).includes(account)
|
|
131
172
|
|
|
132
|
-
|
|
133
|
-
|
|
173
|
+
if(!has) return;
|
|
174
|
+
|
|
175
|
+
let servers = await this.get_servers(account)
|
|
176
|
+
for (let s=0; s< servers.length; s++){
|
|
177
|
+
let server = servers[s]
|
|
178
|
+
if (this.server_match(server, this.server)){
|
|
179
|
+
let res = await this.fetch({
|
|
180
|
+
method: 'read',
|
|
181
|
+
arg: {path, prefix}
|
|
182
|
+
}, server)
|
|
183
|
+
|
|
184
|
+
if(res && res.content){
|
|
185
|
+
return res.content
|
|
186
|
+
}else break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (let s=0; s< servers.length; s++){
|
|
190
|
+
let server = servers[s]
|
|
191
|
+
if (this.server_match(server, this.server)){
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
134
194
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
195
|
+
let res = await this.fetch({
|
|
196
|
+
method: 'read',
|
|
197
|
+
arg: {path, prefix}
|
|
198
|
+
}, server)
|
|
199
|
+
if(res && res.content){
|
|
200
|
+
return res.content
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
143
204
|
|
|
144
|
-
|
|
205
|
+
write = async(path, content, options={})=>{
|
|
206
|
+
let {account, address, prefix} = options
|
|
207
|
+
prefix = prefix || '.storage'
|
|
145
208
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
result = arr_path
|
|
209
|
+
await this.update_accounts(address, account)
|
|
210
|
+
let servers = await this.get_servers(account)
|
|
150
211
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
hash = hash || await this.oracle.hash(content)
|
|
154
|
-
let twa_path = `${path}/${hash}`
|
|
155
|
-
await this.mkdir(twa_path)
|
|
156
|
-
|
|
157
|
-
let twa = {}
|
|
158
|
-
for (let prop in content){
|
|
159
|
-
let value = content[prop];
|
|
160
|
-
let p_hash = await this.oracle.hash(prop)
|
|
161
|
-
let pair_path = `${twa_path}/${p_hash}`
|
|
162
|
-
await this.mkdir(pair_path)
|
|
163
|
-
let p_addr = await this.store(prop, {path: pair_path})
|
|
164
|
-
let val_addr = await this.store(value, {path: pair_path})
|
|
165
|
-
|
|
166
|
-
let pair = [p_addr, val_addr]
|
|
167
|
-
|
|
168
|
-
let conf = await this.read(`${pair_path}/.config`)
|
|
169
|
-
if (!conf){
|
|
170
|
-
conf = {index: 0}
|
|
171
|
-
}else if (!Object.keys(conf).includes('index'))conf.index = 0
|
|
172
|
-
else {
|
|
173
|
-
conf.index++
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
await this.write(`${pair_path}/${conf.index}`, JSON.stringify(pair))
|
|
212
|
+
for (let s=0; s< servers.length; s++){
|
|
213
|
+
let server = servers[s]
|
|
177
214
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
215
|
+
await this.fetch({
|
|
216
|
+
method: 'write',
|
|
217
|
+
arg: {path, content, prefix}
|
|
218
|
+
}, server)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
183
221
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
222
|
+
get_servers = async(account, mirroring)=>{
|
|
223
|
+
let addr = `.oracle/${account}/.configs`
|
|
224
|
+
let servers = await this.get_from_repos(addr)
|
|
225
|
+
servers = servers ? JSON.parse(servers) : []
|
|
226
|
+
|
|
227
|
+
if(!mirroring && !servers.length && this.mirror){
|
|
228
|
+
servers = await this.fetch({
|
|
229
|
+
method: 'get_servers',
|
|
230
|
+
arg: {account}
|
|
231
|
+
}, this.mirror)
|
|
232
|
+
if (servers.length){
|
|
233
|
+
await this.set_to_repos(addr, JSON.stringify(servers))
|
|
234
|
+
await this.update_servers(account, [...servers])
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return servers
|
|
238
|
+
}
|
|
189
239
|
|
|
190
|
-
|
|
240
|
+
update_servers = async(account, servers)=>{
|
|
241
|
+
servers = servers || await this.get_servers(account)
|
|
242
|
+
|
|
243
|
+
if (servers.find(s=>this.server_match(s, this.server))){
|
|
244
|
+
return
|
|
245
|
+
}
|
|
191
246
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
break
|
|
201
|
-
case 'number':
|
|
202
|
-
hash = await this.oracle.hash(`0${content}`)
|
|
203
|
-
result = await this.write(`${path}/${hash}`, JSON.stringify(content))
|
|
204
|
-
break
|
|
205
|
-
case 'boolean':
|
|
206
|
-
hash = await this.oracle.hash(`0${content}`)
|
|
207
|
-
result = await this.write(`${path}/${hash}`, JSON.stringify(content))
|
|
208
|
-
break
|
|
247
|
+
servers.push(this.server)
|
|
248
|
+
for (let s=0; s< servers.length; s++){
|
|
249
|
+
let server = servers[s]
|
|
250
|
+
|
|
251
|
+
await this.fetch({
|
|
252
|
+
method: 'update_servers',
|
|
253
|
+
arg: {account, server: this.server},
|
|
254
|
+
}, server)
|
|
209
255
|
}
|
|
210
256
|
|
|
211
|
-
return
|
|
257
|
+
return servers
|
|
212
258
|
}
|
|
213
|
-
}
|
|
214
259
|
|
|
215
|
-
|
|
216
|
-
|
|
260
|
+
get_accounts = async(address, mirroring)=>{
|
|
261
|
+
let addr = `.oracle/${address}/.configs`
|
|
262
|
+
let accounts = await this.get_from_repos(addr)
|
|
263
|
+
|
|
264
|
+
accounts = accounts ? JSON.parse(accounts) : []
|
|
217
265
|
|
|
218
|
-
|
|
266
|
+
if (!mirroring && !accounts.length && this.mirror){
|
|
267
|
+
accounts = await this.fetch({
|
|
268
|
+
method: 'get_accounts',
|
|
269
|
+
arg: {address}
|
|
270
|
+
}, this.mirror)
|
|
271
|
+
}
|
|
219
272
|
|
|
220
|
-
|
|
273
|
+
return accounts
|
|
221
274
|
}
|
|
222
275
|
|
|
223
|
-
|
|
224
|
-
let
|
|
276
|
+
update_accounts = async(address, account)=>{
|
|
277
|
+
let accounts = await this.get_accounts(address)
|
|
278
|
+
|
|
279
|
+
if (accounts.includes(account)){
|
|
280
|
+
return
|
|
281
|
+
}
|
|
225
282
|
|
|
226
|
-
|
|
227
|
-
}
|
|
283
|
+
accounts.push(account)
|
|
228
284
|
|
|
229
|
-
|
|
230
|
-
|
|
285
|
+
let servers = await this.get_servers_from_address(address, accounts)
|
|
286
|
+
|
|
287
|
+
for (let s=0; s< servers.length; s++){
|
|
288
|
+
let server = servers[s]
|
|
231
289
|
|
|
232
|
-
|
|
233
|
-
|
|
290
|
+
await this.fetch({
|
|
291
|
+
method: 'update_accounts',
|
|
292
|
+
arg: {address, account},
|
|
293
|
+
}, server)
|
|
234
294
|
}
|
|
235
295
|
|
|
236
|
-
|
|
296
|
+
return accounts
|
|
297
|
+
}
|
|
237
298
|
|
|
238
|
-
|
|
299
|
+
get_servers_from_address = async(address, accounts)=>{
|
|
300
|
+
accounts = accounts || await this.get_accounts(address)
|
|
301
|
+
|
|
302
|
+
let servers = []
|
|
303
|
+
for (let a=0; a< accounts.length; a++){
|
|
304
|
+
let acc = accounts[a]
|
|
305
|
+
let servers_ = await this.get_servers(acc)
|
|
306
|
+
servers_.map(serv=>{
|
|
307
|
+
if(!servers.find(s=>this.server_match(s, serv)))
|
|
308
|
+
servers.push(serv)
|
|
309
|
+
})
|
|
310
|
+
}
|
|
239
311
|
|
|
240
|
-
return
|
|
312
|
+
return servers
|
|
241
313
|
}
|
|
242
314
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return hash(value, alg)
|
|
315
|
+
server_match = (s1, s2)=>{
|
|
316
|
+
return s1.hostname === s2.hostname && s1.port === s2.port
|
|
247
317
|
}
|
|
248
318
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
await this.fs.mkdir(this.manager.path)
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
get_type = (content)=>{
|
|
255
|
-
let type = typeof content;
|
|
319
|
+
set_manager = async(manager)=>{
|
|
320
|
+
console.log(`Manager:${manager.name} Oracle running at ${this.server.hostname}:${this.server.port}`)
|
|
256
321
|
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
322
|
+
if (!this.server_match(this.server, manager.server)){
|
|
323
|
+
let response = await this.fetch({
|
|
324
|
+
method: 'sync',
|
|
325
|
+
arg: {manager_server: manager.server}
|
|
326
|
+
}, this.server)
|
|
327
|
+
|
|
328
|
+
for (let r=0; r< response.repos.length; r++){
|
|
329
|
+
let repository = response.repos[r]
|
|
330
|
+
|
|
331
|
+
await this.add_repo(repository)
|
|
332
|
+
}
|
|
263
333
|
}
|
|
264
|
-
return type;
|
|
265
334
|
}
|
|
335
|
+
|
|
336
|
+
sync = async () => {
|
|
337
|
+
|
|
338
|
+
};
|
|
266
339
|
}
|
|
267
340
|
|
|
268
341
|
export default Oracle;
|
package/Objects/Repository.js
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class Repository {
|
|
4
|
-
constructor(manager) {
|
|
5
|
-
this.manager = manager;
|
|
6
|
-
|
|
7
|
-
this.gds = this.manager.oracle.gds;
|
|
1
|
+
class Repository{
|
|
2
|
+
constructor(){
|
|
8
3
|
}
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return content;
|
|
18
|
-
};
|
|
5
|
+
objectify = ()=>{
|
|
6
|
+
let obj = {}
|
|
7
|
+
if (this.type === 'fs'){
|
|
8
|
+
obj.name = this.name;
|
|
9
|
+
obj.remote = this.remote
|
|
10
|
+
obj.__dirname = this.__dirname
|
|
11
|
+
}
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
create_or_update_file = async (path, content, message, sha) => {
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
get_file_sha = async (path) => {
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
write_file = async (path, content, message = "") => {
|
|
32
|
-
await this.manager.oracle.fs.write_file(path, content)
|
|
33
|
-
|
|
34
|
-
return path
|
|
35
|
-
};
|
|
13
|
+
return obj
|
|
14
|
+
}
|
|
36
15
|
}
|
|
37
16
|
|
|
38
|
-
export default Repository;
|
|
17
|
+
export default Repository;
|
package/Objects/Trinity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Manager from "./Manager";
|
|
1
|
+
import Manager from "./Manager.js";
|
|
2
2
|
|
|
3
3
|
class Trinity {
|
|
4
4
|
constructor(game) {
|
|
@@ -7,18 +7,20 @@ class Trinity {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
add_manager = async (name, options) => {
|
|
10
|
+
let mgr = this.managers[name];
|
|
11
|
+
if(mgr) return manager
|
|
12
|
+
|
|
10
13
|
let manager = new Manager(name, {...options, trinity: this});
|
|
11
|
-
let mgrs = this.managers[name];
|
|
12
|
-
if (!mgrs) {
|
|
13
|
-
mgrs = new Array();
|
|
14
|
-
this.managers[name] = mgrs;
|
|
15
|
-
}
|
|
16
14
|
await manager.sync();
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
this.managers[name] = manager;
|
|
19
17
|
|
|
20
18
|
return manager;
|
|
21
19
|
};
|
|
20
|
+
|
|
21
|
+
get_manager = (name)=>{
|
|
22
|
+
return this.managers[name]
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export default Trinity;
|
package/Objects/Utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
class Utils{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!addr)return addr;
|
|
2
|
+
on = async(event_name, filter, handler) => {
|
|
3
|
+
|
|
4
|
+
}
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
reload = async(payload)=>{
|
|
7
|
+
let {address} = payload;
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
let res = await this.manager.oracle.read(`${address}/air`, {address, prefix: '.codes', account: this.physical_address})
|
|
10
|
+
|
|
11
|
+
await this.load({address: address.slice(this.physical_address.length+1), sequence: res, compiler: true, from_reload: true})
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|