opportunity-service 0.0.604 → 0.0.605

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  const IPFS = require('ipfs');
11
2
  const OrbitDB = require('orbit-db');
12
3
  const operations = ['>', '<', '==', '>=', '<='];
@@ -22,103 +13,8 @@ const optionsToWrite = {
22
13
  };
23
14
  class OpportunityStorageProvider {
24
15
  constructor(address) {
25
- // Create IPFS instance
26
- this.initIPFSInstance = () => __awaiter(this, void 0, void 0, function* () {
27
- return yield IPFS.create({
28
- repo: Math.random().toString(),
29
- start: true,
30
- preload: {
31
- enabled: false,
32
- },
33
- EXPERIMENTAL: { pubsub: true },
34
- });
35
- });
36
- this.initIPFSInstance();
37
- this.listen(address);
38
- }
39
- listen(address = '') {
40
- this.initIPFSInstance().then((ipfs) => __awaiter(this, void 0, void 0, function* () {
41
- var _a, _b;
42
- const orbitdb = yield OrbitDB.createInstance(ipfs);
43
- // Create / Open a database
44
- if (address == '') {
45
- this.db = yield orbitdb.docs('database.default');
46
- console.log(this.db);
47
- console.log(this.db.address);
48
- }
49
- else {
50
- if (!((_a = this.db) === null || _a === void 0 ? void 0 : _a.dbname) || ((_b = this.db) === null || _b === void 0 ? void 0 : _b.dbname) == '') {
51
- console.log('Connecting orbitdb to: ' + address);
52
- orbitdb.
53
- this.db = yield orbitdb.docs(address, {
54
- type: 'docstore',
55
- accessController: {
56
- admin: ['*'],
57
- write: ['*']
58
- },
59
- //indexBy: 'collection'
60
- });
61
- //await this.db.load();
62
- }
63
- console.log(this.db);
64
- }
65
- // Listen for updates from peers
66
- this.db.events.on("replicated", address => {
67
- console.log(this.db.iterator({ limit: -1 }).collect());
68
- });
69
- // Add an entry
70
- const hash = yield this.db.put({ _id: 0, collection: "hmm" });
71
- console.log(hash);
72
- // Query
73
- const result = this.db.iterator({ limit: -1 }).collect();
74
- console.log(JSON.stringify(result, null, 2));
75
- }));
76
- }
77
- /**
78
- * Returns a Promise that resolves to the multihash of the entry as a String.
79
- * @param doc
80
- * @returns
81
- */
82
- store(doc) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- try {
85
- const hash = yield this.db.put(doc).then(hash => {
86
- return hash;
87
- });
88
- return hash;
89
- }
90
- catch (error) {
91
- console.log(error);
92
- return '';
93
- }
94
- });
95
- }
96
- /**
97
- * Returns an Array of all Objects that match the given key in their _id field or the field specified by indexBy. If no document with
98
- * that key exists, this returns an empty array.
99
- * @param key
100
- */
101
- retrieveDoc(key = '', collection) {
102
- return __awaiter(this, void 0, void 0, function* () {
103
- try {
104
- const docs = yield this.db.get(key);
105
- return docs;
106
- }
107
- catch (error) {
108
- console.log(error);
109
- return [];
110
- }
111
- });
112
- }
113
- retrieveDocsByCollection(collection) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- return yield this.db.query((doc) => doc[collection] == collection);
116
- });
117
- }
118
- deleteDoc(key) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const hash = yield this.db.del(key);
121
- });
16
+ // this.initIPFSInstance()
17
+ //this.listen(address)
122
18
  }
123
19
  }
124
20
  export default OpportunityStorageProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"OpportunityStorageProvider.js","sourceRoot":"","sources":["../../../src/modules/storage/OpportunityStorageProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAQnC,MAAM,U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,CAAC,CAAA,CAAC,CAAC;IACT,CAAC;IAGD;;;;MAIE;IACI,KAAK,CAAC,GAAsD;;YAC9D,IAAI;gBACA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC5C,OAAO,IAAI,CAAC;gBAChB,CAAC,CAAC,CAAA;gBAEF,OAAO,IAAI,CAAC;aACf;YAAC,OAAM,KAAK,EAAE;gBACX,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAClB,OAAO,EAAE,CAAA;aACZ;QACL,CAAC;KAAA;IAED;;;;MAIE;IACI,WAAW,CAAC,MAAc,EAAE,EAAE,UAAkB;;YACtD,IAAI;gBACA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACnC,OAAO,IAAI,CAAA;aACV;YAAC,OAAM,KAAK,EAAE;gBACX,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAClB,OAAO,EAAE,CAAA;aACZ;QACL,CAAC;KAAA;IAEI,wBAAwB,CAAC,UAAkB;;YAC5C,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,CAAA;QACtE,CAAC;KAAA;IAEK,SAAS,CAAC,GAAW;;YACvB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC;KAAA;CACJ;AAED,eAAe,0BAA0B,CAAA"}
1
+ {"version":3,"file":"OpportunityStorageProvider.js","sourceRoot":"","sources":["../../../src/modules/storage/OpportunityStorageProvider.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAQnC,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE/C,MAAM,cAAc,GAAG;IACnB,mDAAmD;IACnD,gBAAgB,EAAE;QAChB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,KAAK,EAAE,CAAC,GAAG,CAAC;KACb;IACD,OAAO,EAAE,YAAY;CACxB,CAAA;AAGD,MAAM,0BAA0B;IAG5B,YAAY,OAAe;QACxB,0BAA0B;QACzB,sBAAsB;IAC1B,CAAC;CA0FJ;AAED,eAAe,0BAA0B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opportunity-service",
3
- "version": "0.0.604",
3
+ "version": "0.0.605",
4
4
  "description": "A service layer that connects all services between the blockchain and ui.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,10 +25,10 @@ class OpportunityStorageProvider {
25
25
  private db: any
26
26
 
27
27
  constructor(address: string) {
28
- this.initIPFSInstance()
29
- this.listen(address)
28
+ // this.initIPFSInstance()
29
+ //this.listen(address)
30
30
  }
31
-
31
+ /*
32
32
 
33
33
  // Create IPFS instance
34
34
  initIPFSInstance = async () => {
@@ -55,7 +55,7 @@ class OpportunityStorageProvider {
55
55
 
56
56
  if (!this.db?.dbname || this.db?.dbname == '') {
57
57
  console.log('Connecting orbitdb to: ' + address)
58
- orbitdb.
58
+
59
59
  this.db = await orbitdb.docs(address, {
60
60
  type: 'docstore',
61
61
  accessController: {
@@ -86,11 +86,7 @@ class OpportunityStorageProvider {
86
86
  }
87
87
 
88
88
 
89
- /**
90
- * Returns a Promise that resolves to the multihash of the entry as a String.
91
- * @param doc
92
- * @returns
93
- */
89
+
94
90
  async store(doc: DisputeDoc | WorkRelationshipDoc | UserSummaryDoc): Promise<string> {
95
91
  try {
96
92
  const hash = await this.db.put(doc).then(hash => {
@@ -104,11 +100,6 @@ class OpportunityStorageProvider {
104
100
  }
105
101
  }
106
102
 
107
- /**
108
- * Returns an Array of all Objects that match the given key in their _id field or the field specified by indexBy. If no document with
109
- * that key exists, this returns an empty array.
110
- * @param key
111
- */
112
103
  async retrieveDoc(key: string = '', collection: string): Promise<DisputeDoc> | Promise<WorkRelationshipDoc> | Promise<UserSummaryDoc> {
113
104
  try {
114
105
  const docs = await this.db.get(key)
@@ -125,7 +116,7 @@ class OpportunityStorageProvider {
125
116
 
126
117
  async deleteDoc(key: string) {
127
118
  const hash = await this.db.del(key)
128
- }
119
+ }*/
129
120
  }
130
121
 
131
122
  export default OpportunityStorageProvider