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.
Files changed (71) hide show
  1. package/Datatypes/arr.js +559 -254
  2. package/Datatypes/bool.js +8 -5
  3. package/Datatypes/callable.js +1 -1
  4. package/Datatypes/cls.js +193 -24
  5. package/Datatypes/conf.js +2 -2
  6. package/Datatypes/err.js +25 -0
  7. package/Datatypes/func.js +89 -13
  8. package/Datatypes/functions/storage.js +572 -12
  9. package/Datatypes/functions/wallet.js +49 -0
  10. package/Datatypes/instance.js +87 -122
  11. package/Datatypes/num.js +192 -153
  12. package/Datatypes/str.js +188 -122
  13. package/Datatypes/twa.js +346 -71
  14. package/Datatypes/voi.js +9 -4
  15. package/Index.js +1 -1
  16. package/Instances/account.js +0 -0
  17. package/Instances/event.js +0 -0
  18. package/Instances/fold.js +103 -0
  19. package/Instances/folder_queries.js +46 -0
  20. package/Instances/response.js +31 -0
  21. package/Objects/Account.js +160 -110
  22. package/Objects/Blockweb.js +6 -11
  23. package/Objects/Callable.js +223 -188
  24. package/Objects/Chain.js +127 -142
  25. package/Objects/Datatypes.js +114 -588
  26. package/Objects/Manager.js +349 -39
  27. package/Objects/Oracle.js +283 -210
  28. package/Objects/Repository.js +12 -33
  29. package/Objects/Trinity.js +9 -7
  30. package/Objects/Utils.js +8 -8
  31. package/Objects/Virtual_machine.js +320 -320
  32. package/README.md +0 -0
  33. package/callables/functions/assert.js +10 -0
  34. package/callables/functions/display.js +2 -3
  35. package/callables/functions/env.js +5 -0
  36. package/callables/functions/event.js +14 -0
  37. package/callables/functions/exit.js +3 -2
  38. package/callables/functions/folder.js +15 -0
  39. package/callables/functions/get_uid.js +6 -0
  40. package/callables/functions/hash.js +7 -0
  41. package/callables/functions/import_.js +62 -0
  42. package/callables/functions/local.js +9 -0
  43. package/callables/functions/net.js +33 -18
  44. package/callables/functions/parse.js +35 -0
  45. package/callables/functions/query.js +12 -0
  46. package/callables/functions/render.js +9 -13
  47. package/callables/functions/servers.js +10 -0
  48. package/callables/functions/spawn.js +7 -0
  49. package/callables/functions/store.js +75 -0
  50. package/callables/functions/super_.js +24 -0
  51. package/callables/functions/typeof.js +32 -0
  52. package/callables/functions/wait.js +9 -0
  53. package/callables/register.js +193 -8
  54. package/html/create.js +110 -0
  55. package/html/index.js +114 -0
  56. package/html/load.js +165 -0
  57. package/html/parse.js +171 -0
  58. package/html/run.js +151 -0
  59. package/html/util.js +5 -0
  60. package/package.json +5 -3
  61. package/repos/fs.js +114 -0
  62. package/repos/github.js +73 -0
  63. package/repos/ram.js +47 -0
  64. package/utils/create_server.js +66 -26
  65. package/utils/hash.js +3 -2
  66. package/utils/ops.js +2 -0
  67. package/utils/oracle_handlers.js +7 -0
  68. package/utils/services.js +18 -51
  69. package/utils/socket_server.js +36 -0
  70. package/utils/vm_utils.js +271 -59
  71. package/callables/functions/assign.js +0 -6
package/Objects/Oracle.js CHANGED
@@ -1,268 +1,341 @@
1
- import fs from "fs";
2
- import { hash } from "../utils/hash";
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
- class Fs {
6
- constructor(oracle) {
7
- this.oracle = oracle;
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
- this.fs = fs;
10
- this.base = __dirname;
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
- is_directory=async path=>{
14
- if(!await this.exists(path, {pure:true}))return false;
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
- try {
17
- const stats = this.fs.statSync(`${this.base}/${path}`);
18
- return stats.isDirectory();
19
- } catch (err) {
20
- // console.error(`Error checking path: ${err.message}`);
21
- return false; // Handle error, e.g., path doesn't exist
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
- exists = async (path, options={}) => {
26
- return this.fs.existsSync(`${this.base}/${path}`);
27
- };
28
-
29
- mkdir = async (path) => {
30
- path = `${this.base}/${path}`;
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
- !(await this.exists(path, {pure:true})) && this.fs.mkdirSync(path, { recursive: true });
33
- };
102
+ return result
103
+ }
34
104
 
35
- read = async(path)=>{
36
- let content;
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
- return content;
108
+ this.remotes.push(remote)
43
109
  }
44
110
 
45
- retrieve = async(path, options)=>{
46
- let config, result;
47
- if (options.current){
48
- config = {current: path}
49
- }else{
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
- return result
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
- write = async(path, content, options={})=>{
82
- let addr;
83
- if (options.config){
84
- await this.mkdir(path);
85
-
86
- let conf_path = `${path}/.config`
87
- let hash = await this.oracle.hash(content)
88
- let conf = await this.read(conf_path) || {index: 0}
89
- let obj = {content, sibling: conf.current}
90
- let current = `${path}/${hash}`
91
- conf.current = current;
92
- await this.write(conf_path, JSON.stringify(conf))
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 addr;
143
+ return res;
108
144
  }
109
145
 
110
- store = async(content, {path, type, hash: hash_, is_instance})=>{
111
- if (!type) type = this.oracle.get_type(content)
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
- let result, hash = hash_;
114
- switch(type){
115
- case 'array':
116
- hash = hash || await this.oracle.hash(content)
117
- let arr_path = `${path}/${hash}`
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
- let arr = []
121
- for (let i=0; i< content.length; i++){
122
- let item = content[i]
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
- let item_path = `${arr_path}/${i}`
125
- await this.mkdir(item_path)
126
- item = await this.store(item, {path: item_path})
167
+ read = async(path, options={})=>{
168
+ let {address, account, prefix} = options;
169
+ prefix = prefix || '.storage'
127
170
 
128
- let conf = await this.read(`${item_path}/.config`)
129
- if(!conf) conf = {index:0}
130
- else conf.index++
171
+ let has = (await this.get_accounts(address)).includes(account)
131
172
 
132
- await this.write(`${item_path}/${conf.index}`, item)
133
- await this.write(`${item_path}/.config`, JSON.stringify(conf));
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
- arr.push(conf.index)
136
- }
137
- let aconf = await this.read(`${path}/.config`) || {}
138
- let arr_hash = await this.oracle.hash(arr)
139
- let arr_conf = await this.read(`${arr_path}/.config`) || {index: 0}
140
- await this.write(`${arr_path}/${arr_hash}`, JSON.stringify({content:arr, type: is_instance? 'instance': type, previous: arr_conf.current, indice: aconf.indice}))
141
- arr_conf.current = arr_hash
142
- arr_conf.sibling = aconf.current;
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
- await this.write(`${arr_path}/.config`, JSON.stringify(arr_conf));
205
+ write = async(path, content, options={})=>{
206
+ let {account, address, prefix} = options
207
+ prefix = prefix || '.storage'
145
208
 
146
- aconf.current = arr_path;
147
- await this.write(`${path}/.config`, JSON.stringify(aconf))
148
-
149
- result = arr_path
209
+ await this.update_accounts(address, account)
210
+ let servers = await this.get_servers(account)
150
211
 
151
- break;
152
- case 'twain':
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
- twa[p_hash] = conf.index;
179
- await this.write(`${pair_path}/.config`, JSON.stringify(conf));
180
- }
181
-
182
- let pconf = await this.read(`${path}/.config`) || {}
215
+ await this.fetch({
216
+ method: 'write',
217
+ arg: {path, content, prefix}
218
+ }, server)
219
+ }
220
+ }
183
221
 
184
- let twa_hash = await this.oracle.hash(twa)
185
- let twa_conf = await this.read(`${twa_path}/.config`) || {index: 0}
186
- await this.write(`${twa_path}/${twa_hash}`, JSON.stringify({content:twa, type: is_instance? 'instance': type, previous: twa_conf.current, indice: pconf.indice}))
187
- twa_conf.current = twa_hash
188
- twa_conf.sibling = pconf.current;
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
- await this.write(`${twa_path}/.config`, JSON.stringify(twa_conf));
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
- pconf.current = twa_path;
193
- await this.write(`${path}/.config`, JSON.stringify(pconf))
194
-
195
- result = twa_path
196
- break;
197
- case 'string':
198
- hash = await this.oracle.hash(content)
199
- result = await this.write(`${path}/${hash}`, content)
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 result;
257
+ return servers
212
258
  }
213
- }
214
259
 
215
- class Oracle {
216
- constructor(manager) {
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
- this.manager = manager;
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
- this.fs = new Fs(this);
273
+ return accounts
221
274
  }
222
275
 
223
- read = async(path, options)=>{
224
- let result = await this.fs.retrieve(path, options)
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
- return result;
227
- }
283
+ accounts.push(account)
228
284
 
229
- write = async(path, content, options={})=>{
230
- let type = this.get_type(content), addr;
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
- if(options.config){
233
- return await this.fs.write(path, JSON.stringify(content), {config: true})
290
+ await this.fetch({
291
+ method: 'update_accounts',
292
+ arg: {address, account},
293
+ }, server)
234
294
  }
235
295
 
236
- if (options.hash) path = `${path}/${options.hash}`
296
+ return accounts
297
+ }
237
298
 
238
- addr = await this.fs.store(content, {path, type, has_hash: options.hash, is_instance: options.is_instance})
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 addr;
312
+ return servers
241
313
  }
242
314
 
243
- hash = async(value, alg)=>{
244
- if (typeof value !== 'string')value = JSON.stringify(value)
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
- sync = async () => {
250
- this.manager.path = `${this.manager.trinity.game}/${this.manager.name}`;
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 (content == null) return 'void'
258
-
259
- if (type === 'object'){
260
- if (Array.isArray(content)) type = 'array'
261
- else if (!content) type = 'void'
262
- else type = 'twain'
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;
@@ -1,38 +1,17 @@
1
- import { get_request, post_request } from "../utils/services";
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
- read_address = async (address) => {
11
- let content = await this.manager.oracle.fs.read_file(`${address}`);
12
-
13
- try {
14
- content = JSON.parse(content);
15
- } catch (err) {}
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
- sync = async () => {
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;
@@ -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
- mgrs.push(manager);
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
- constructor(){}
3
-
4
- resolve_addr = (addr)=>{
5
- if (!addr)return addr;
2
+ on = async(event_name, filter, handler) => {
3
+
4
+ }
6
5
 
7
- if (!addr.startsWith(this.physical_address)){
8
- addr = `${this.physical_address}/${addr}`
9
- }
6
+ reload = async(payload)=>{
7
+ let {address} = payload;
10
8
 
11
- return addr;
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