godprotocol 1.2.18 → 1.2.19

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 (2) hide show
  1. package/Objects/Manager.js +39 -0
  2. package/package.json +1 -1
@@ -353,6 +353,45 @@ class Manager {
353
353
  return create_serv;
354
354
  }
355
355
 
356
+ get_init = async()=>{
357
+ let acc = this.init_account;
358
+
359
+ if (!acc && this.options.init_account) {
360
+ acc = await this.add_account(this.options.init_account.name, {password: this.options.init_account.password, init: true})
361
+ }
362
+
363
+ return acc;
364
+ }
365
+
366
+ get_from_repo = async(address, options={}) =>{
367
+ let acc = this.get_acc(options)
368
+
369
+ address = `.storage/${acc}/${address}/__literal__`
370
+ let content = await this.oracle.get_from_repos(address, {count: 1, args: options})
371
+
372
+ return content && JSON.parse(content)
373
+ }
374
+
375
+ get_acc = options=>{
376
+ let acc = options.account
377
+ if (!acc){
378
+ acc = this.options.init_account
379
+ if (!acc) return
380
+ acc = `Accounts/${acc.name}`
381
+ }
382
+
383
+ return acc;
384
+ }
385
+
386
+ set_to_repo = async(address, content, options={}) =>{
387
+ let acc = this.get_acc(options)
388
+
389
+ address = `.storage/${acc}/${address}/__literal__`
390
+ let response = await this.oracle.set_to_repos(address, JSON.stringify(content), {count: 1, args: options})
391
+
392
+ return response
393
+ }
394
+
356
395
  get_account = async(name) => {
357
396
  let acc = this.accounts[name]
358
397
  if (!acc){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "1.2.18",
3
+ "version": "1.2.19",
4
4
  "description": "A distributed computing environment",
5
5
  "main": "Index.js",
6
6
  "scripts": {