opportunity-service 0.0.504 → 0.0.509
Sign up to get free protection for your applications and to get access to all the features.
- package/.env +6 -1
- package/dist/OpportunityService.js +29 -28
- package/dist/OpportunityService.js.map +1 -1
- package/dist/api/ethereum/sendAsync.js +3 -10
- package/dist/api/ethereum/sendAsync.js.map +1 -1
- package/dist/api/exchange/complete-relationship.js +1 -4
- package/dist/api/exchange/complete-relationship.js.map +1 -1
- package/dist/api/exchange/create-dispute.js +41 -0
- package/dist/api/exchange/create-dispute.js.map +1 -0
- package/dist/api/exchange/create-task.js +9 -34
- package/dist/api/exchange/create-task.js.map +1 -1
- package/dist/api/exchange/enter-work-relationship.js +1 -4
- package/dist/api/exchange/enter-work-relationship.js.map +1 -1
- package/dist/api/exchange/inspect-relationship.js +1 -4
- package/dist/api/exchange/inspect-relationship.js.map +1 -1
- package/dist/api/identity/register-new-user.js +8 -32
- package/dist/api/identity/register-new-user.js.map +1 -1
- package/dist/api/index.js +23 -28
- package/dist/api/index.js.map +1 -1
- package/dist/api/internal/abis.js +3 -24
- package/dist/api/internal/abis.js.map +1 -1
- package/dist/api/internal/addresses.js +8 -28
- package/dist/api/internal/addresses.js.map +1 -1
- package/dist/api/internal/events.js +12 -14
- package/dist/api/internal/events.js.map +1 -1
- package/dist/api/internal/index.js +4 -12
- package/dist/api/internal/index.js.map +1 -1
- package/dist/api/market/create-market.js +1 -4
- package/dist/api/market/create-market.js.map +1 -1
- package/dist/api/voting/census.js +38 -0
- package/dist/api/voting/census.js.map +1 -0
- package/dist/api/voting/connect.js +33 -0
- package/dist/api/voting/connect.js.map +1 -0
- package/dist/api/voting/entity.js +39 -0
- package/dist/api/voting/entity.js.map +1 -0
- package/dist/api/voting/process.js +101 -0
- package/dist/api/voting/process.js.map +1 -0
- package/dist/blockchain/abi.json +2 -1
- package/dist/blockchain/addresses.json +12 -5
- package/dist/blockchain/bytecode.json +2 -1
- package/dist/constants/interface.js +1 -0
- package/dist/constants/interface.js.map +1 -0
- package/dist/constants/voting.js +1 -0
- package/dist/constants/voting.js.map +1 -0
- package/dist/constants.js +34 -39
- package/dist/constants.js.map +1 -1
- package/dist/events/OpportunityEventEmitter.js +3 -5
- package/dist/events/OpportunityEventEmitter.js.map +1 -1
- package/dist/events/start-event-listeners.js +3 -9
- package/dist/events/start-event-listeners.js.map +1 -1
- package/dist/events/sync-with-ethereum-node.js +3 -9
- package/dist/events/sync-with-ethereum-node.js.map +1 -1
- package/dist/modules/storage/OpportunityStorageProvider.js +3 -8
- package/dist/modules/storage/OpportunityStorageProvider.js.map +1 -1
- package/dist/sync/process/process-log.js +16 -36
- package/dist/sync/process/process-log.js.map +1 -1
- package/dist/sync/process/processDisputeCreated.js +33 -0
- package/dist/sync/process/processDisputeCreated.js.map +1 -0
- package/dist/sync/process/processMarketCreatedLog.js +7 -32
- package/dist/sync/process/processMarketCreatedLog.js.map +1 -1
- package/dist/sync/process/processMarketDestroyedEvent.js +1 -4
- package/dist/sync/process/processMarketDestroyedEvent.js.map +1 -1
- package/dist/sync/process/processUserAssignedTrueIdentification.js +7 -12
- package/dist/sync/process/processUserAssignedTrueIdentification.js.map +1 -1
- package/dist/sync/process/processUserRegistered.js +7 -12
- package/dist/sync/process/processUserRegistered.js.map +1 -1
- package/dist/sync/process/processUserSummaryCreated.js +7 -12
- package/dist/sync/process/processUserSummaryCreated.js.map +1 -1
- package/dist/sync/process/processWorkRelationshipCreated.js +9 -34
- package/dist/sync/process/processWorkRelationshipCreated.js.map +1 -1
- package/dist/sync/sync-jobs.js +5 -10
- package/dist/sync/sync-jobs.js.map +1 -1
- package/dist/sync/sync-markets.js +8 -32
- package/dist/sync/sync-markets.js.map +1 -1
- package/dist/types.js +1 -2
- package/gateways.all.json +190 -0
- package/package.json +23 -10
- package/src/OpportunityService.ts +9 -0
- package/src/api/exchange/create-dispute.ts +42 -0
- package/src/api/exchange/create-task.ts +1 -1
- package/src/api/identity/register-new-user.ts +1 -1
- package/src/api/internal/abis.ts +1 -1
- package/src/api/internal/addresses.ts +7 -5
- package/src/api/voting/census.ts +39 -0
- package/src/api/voting/connect.ts +34 -0
- package/src/api/voting/entity.ts +33 -0
- package/src/api/voting/process.ts +119 -0
- package/src/blockchain/abi.json +2 -1
- package/src/blockchain/addresses.json +16 -6
- package/src/blockchain/bytecode.json +2 -1
- package/src/{modules/whisper/ChatHttpServer.ts → constants/interface.ts} +0 -0
- package/src/{modules/whisper/ChatSocketServer.ts → constants/voting.ts} +0 -0
- package/src/constants.ts +9 -11
- package/src/sync/process/process-log.ts +3 -2
- package/src/sync/process/processDisputeCreated.ts +42 -0
- package/src/sync/sync-markets.ts +1 -1
- package/test/voting.test.ts +20 -0
- package/tsconfig.json +5 -3
- package/dist/modules/whisper/ChatHttpServer.js +0 -1
- package/dist/modules/whisper/ChatHttpServer.js.map +0 -1
- package/dist/modules/whisper/ChatSocketServer.js +0 -1
- package/dist/modules/whisper/ChatSocketServer.js.map +0 -1
- package/dist/modules/whisper/OpportunityChatProvider.js +0 -63
- package/dist/modules/whisper/OpportunityChatProvider.js.map +0 -1
- package/dist/rpc/connection.js +0 -1
- package/dist/rpc/connection.js.map +0 -1
- package/dist/rpc/index.js +0 -1
- package/dist/rpc/index.js.map +0 -1
- package/dist/rpc/interface/rpc-interface.js +0 -5
- package/dist/rpc/interface/rpc-interface.js.map +0 -1
- package/src/modules/whisper/OpportunityChatProvider.ts +0 -60
- package/src/rpc/connection.ts +0 -0
- package/src/rpc/index.ts +0 -0
- package/src/rpc/interface/rpc-interface.ts +0 -2
@@ -1,23 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
-
}) : function(o, v) {
|
12
|
-
o["default"] = v;
|
13
|
-
});
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
-
if (mod && mod.__esModule) return mod;
|
16
|
-
var result = {};
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
-
__setModuleDefault(result, mod);
|
19
|
-
return result;
|
20
|
-
};
|
21
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -27,26 +7,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
27
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
28
8
|
});
|
29
9
|
};
|
30
|
-
|
31
|
-
|
32
|
-
};
|
33
|
-
|
34
|
-
const OpportunityService_1 = __importDefault(require("../OpportunityService"));
|
35
|
-
const addressMap = __importStar(require("../blockchain/addresses.json"));
|
36
|
-
const constants_1 = require("../constants");
|
37
|
-
const process_log_1 = require("./process/process-log");
|
10
|
+
import opportunityService from '../OpportunityService';
|
11
|
+
import * as addressMap from '../blockchain/addresses.json';
|
12
|
+
import { Contracts } from '../constants';
|
13
|
+
import { processLog } from './process/process-log';
|
38
14
|
function syncMarkets() {
|
39
15
|
return __awaiter(this, void 0, void 0, function* () {
|
40
16
|
//sync Markets
|
41
|
-
yield
|
42
|
-
address: addressMap[
|
17
|
+
yield opportunityService.getProviderInterface().getLogs({
|
18
|
+
address: addressMap[opportunityService.getEthNetwork()][Contracts.MARKET_FACTORY],
|
43
19
|
fromBlock: 1,
|
44
20
|
toBlock: 'latest'
|
45
21
|
}).then((logs) => {
|
46
22
|
console.log('Found logs.. Processing...');
|
47
23
|
logs.forEach(log => {
|
48
24
|
if (log && Array.isArray(log.topics) && log.topics.length) {
|
49
|
-
|
25
|
+
processLog(log); // keccashinside here
|
50
26
|
}
|
51
27
|
});
|
52
28
|
})
|
@@ -55,5 +31,5 @@ function syncMarkets() {
|
|
55
31
|
});
|
56
32
|
});
|
57
33
|
}
|
58
|
-
|
34
|
+
export default syncMarkets;
|
59
35
|
//# sourceMappingURL=sync-markets.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sync-markets.js","sourceRoot":"","sources":["../../src/sync/sync-markets.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"sync-markets.js","sourceRoot":"","sources":["../../src/sync/sync-markets.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,SAAe,WAAW;;QACrB,cAAc;QACd,MAAM,kBAAkB,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC;YACrD,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC;YACjF,SAAS,EAAE,CAAC;YACZ,OAAO,EAAE,QAAQ;SACpB,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;YACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACf,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;oBACvD,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,qBAAqB;iBACzC;YACL,CAAC,CAAC,CAAA;QACN,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACT,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,GAAG,CAAC,CAAA;QAC/D,CAAC,CAAC,CAAA;IACN,CAAC;CAAA;AAED,eAAe,WAAW,CAAC"}
|
package/dist/types.js
CHANGED
@@ -0,0 +1,190 @@
|
|
1
|
+
{
|
2
|
+
"main":{
|
3
|
+
"web3":[
|
4
|
+
{
|
5
|
+
"uri":"https://xdai1.vocdoni.net"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"uri":"https://xdai2.vocdoni.net"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"uri":"https://xdai3.vocdoni.net"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"uri":"https://dai.poa.network"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"dvote":[
|
18
|
+
{
|
19
|
+
"uri":"wss://gw4.vocdoni.net/dvote",
|
20
|
+
"apis":[
|
21
|
+
"file",
|
22
|
+
"vote",
|
23
|
+
"census",
|
24
|
+
"results"
|
25
|
+
],
|
26
|
+
"pubKey":"02e7d206ee636bc170336002170b9f01d71488632fa3f4dfa895d423f93a50baeb"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"uri":"wss://gw3.vocdoni.net/dvote",
|
30
|
+
"apis":[
|
31
|
+
"file",
|
32
|
+
"vote",
|
33
|
+
"census",
|
34
|
+
"results"
|
35
|
+
],
|
36
|
+
"pubKey":"03fa03644287f3ab2d700dcad0ad042a2e45ed5f1db889f8d33f027c99adb4715e"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"uri":"https://gw4.vocdoni.net/dvote",
|
40
|
+
"apis":[
|
41
|
+
"file",
|
42
|
+
"vote",
|
43
|
+
"census",
|
44
|
+
"results"
|
45
|
+
],
|
46
|
+
"pubKey":"02e7d206ee636bc170336002170b9f01d71488632fa3f4dfa895d423f93a50baeb"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"uri":"https://gw3.vocdoni.net/dvote",
|
50
|
+
"apis":[
|
51
|
+
"file",
|
52
|
+
"vote",
|
53
|
+
"census",
|
54
|
+
"results"
|
55
|
+
],
|
56
|
+
"pubKey":"03fa03644287f3ab2d700dcad0ad042a2e45ed5f1db889f8d33f027c99adb4715e"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
},
|
60
|
+
"stage":{
|
61
|
+
"web3":[
|
62
|
+
{
|
63
|
+
"uri":"https://xdai1.vocdoni.net"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"uri":"https://xdai2.vocdoni.net"
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"uri":"https://xdai3.vocdoni.net"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"uri":"https://dai.poa.network"
|
73
|
+
}
|
74
|
+
],
|
75
|
+
"dvote":[
|
76
|
+
{
|
77
|
+
"uri":"wss://gw1.stg.vocdoni.net/dvote",
|
78
|
+
"apis":[
|
79
|
+
"file",
|
80
|
+
"vote",
|
81
|
+
"census",
|
82
|
+
"results"
|
83
|
+
],
|
84
|
+
"pubKey":"029b5470ec884e8f74f2ca7e3ed0698914f762fd092e7d49c77d4d6c3cce261cdd"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"uri":"wss://gw2.stg.vocdoni.net/dvote",
|
88
|
+
"apis":[
|
89
|
+
"file",
|
90
|
+
"vote",
|
91
|
+
"census",
|
92
|
+
"results"
|
93
|
+
],
|
94
|
+
"pubKey":"02012069e5481818a0e3c2768451334f4d0e166d0943027e2446941bdc2d73cef3"
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"uri":"https://gw1.stg.vocdoni.net/dvote",
|
98
|
+
"apis":[
|
99
|
+
"file",
|
100
|
+
"vote",
|
101
|
+
"census",
|
102
|
+
"results"
|
103
|
+
],
|
104
|
+
"pubKey":"029b5470ec884e8f74f2ca7e3ed0698914f762fd092e7d49c77d4d6c3cce261cdd"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"uri":"https://gw2.stg.vocdoni.net/dvote",
|
108
|
+
"apis":[
|
109
|
+
"file",
|
110
|
+
"vote",
|
111
|
+
"census",
|
112
|
+
"results"
|
113
|
+
],
|
114
|
+
"pubKey":"02012069e5481818a0e3c2768451334f4d0e166d0943027e2446941bdc2d73cef3"
|
115
|
+
}
|
116
|
+
]
|
117
|
+
},
|
118
|
+
"dev":{
|
119
|
+
"web3":[
|
120
|
+
{
|
121
|
+
"uri":"https://sokol.poa.network"
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"uri":"https://sokol.vocdoni.net"
|
125
|
+
}
|
126
|
+
],
|
127
|
+
"dvote":[
|
128
|
+
{
|
129
|
+
"uri":"https://gw2.dev.vocdoni.net/dvote",
|
130
|
+
"apis":[
|
131
|
+
"file",
|
132
|
+
"vote",
|
133
|
+
"census",
|
134
|
+
"results"
|
135
|
+
],
|
136
|
+
"pubKey":"02b42acf7899a8884168b0e62d8804501ce3330b4185f14805cd74b0e310da6746"
|
137
|
+
},
|
138
|
+
{
|
139
|
+
"uri":"wss://gw2.dev.vocdoni.net/dvote",
|
140
|
+
"apis":[
|
141
|
+
"file",
|
142
|
+
"vote",
|
143
|
+
"census",
|
144
|
+
"results"
|
145
|
+
],
|
146
|
+
"pubKey":"02b42acf7899a8884168b0e62d8804501ce3330b4185f14805cd74b0e310da6746"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"uri":"https://gw3.dev.vocdoni.net/dvote",
|
150
|
+
"apis":[
|
151
|
+
"file",
|
152
|
+
"vote",
|
153
|
+
"census",
|
154
|
+
"results"
|
155
|
+
],
|
156
|
+
"pubKey":"03961c89aef41d4bd8baf6aad35e06340541c67946026fcb165db59f2cdf7e0a7b"
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"uri":"wss://gw3.dev.vocdoni.net/dvote",
|
160
|
+
"apis":[
|
161
|
+
"file",
|
162
|
+
"vote",
|
163
|
+
"census",
|
164
|
+
"results"
|
165
|
+
],
|
166
|
+
"pubKey":"03961c89aef41d4bd8baf6aad35e06340541c67946026fcb165db59f2cdf7e0a7b"
|
167
|
+
},
|
168
|
+
{
|
169
|
+
"uri":"https://gw4.dev.vocdoni.net/dvote",
|
170
|
+
"apis":[
|
171
|
+
"file",
|
172
|
+
"vote",
|
173
|
+
"census",
|
174
|
+
"results"
|
175
|
+
],
|
176
|
+
"pubKey":"03e6c84557338a9cdfd510d17f90f9fcda7cbefac0fcdcb7a60b0e5fb31d2e4523"
|
177
|
+
},
|
178
|
+
{
|
179
|
+
"uri":"wss://gw4.dev.vocdoni.net/dvote",
|
180
|
+
"apis":[
|
181
|
+
"file",
|
182
|
+
"vote",
|
183
|
+
"census",
|
184
|
+
"results"
|
185
|
+
],
|
186
|
+
"pubKey":"03e6c84557338a9cdfd510d17f90f9fcda7cbefac0fcdcb7a60b0e5fb31d2e4523"
|
187
|
+
}
|
188
|
+
]
|
189
|
+
}
|
190
|
+
}
|
package/package.json
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "opportunity-service",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.509",
|
4
4
|
"description": "A service layer that connects all services between the blockchain and ui.",
|
5
5
|
"main": "index.js",
|
6
|
-
"scripts": {
|
6
|
+
"scripts": {
|
7
|
+
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
8
|
+
"coverage": "jest --coverage"
|
9
|
+
},
|
7
10
|
"repository": {
|
8
11
|
"type": "git",
|
9
12
|
"url": "git+https://github.com/OpportunityProtocol/opportunity-service.git"
|
@@ -13,38 +16,48 @@
|
|
13
16
|
"bugs": {
|
14
17
|
"url": "https://github.com/OpportunityProtocol/opportunity-service/issues"
|
15
18
|
},
|
19
|
+
"jest": {
|
20
|
+
"preset": "ts-jest",
|
21
|
+
"testEnvironment": "node",
|
22
|
+
"transform": {
|
23
|
+
"node_modules/variables/.+\\.(j|t)sx?$": "ts-jest"
|
24
|
+
},
|
25
|
+
"transformIgnorePatterns": [
|
26
|
+
"node_modules/(?!variables/.*)"
|
27
|
+
]
|
28
|
+
},
|
16
29
|
"homepage": "https://github.com/OpportunityProtocol/opportunity-service#readme",
|
17
30
|
"devDependencies": {
|
31
|
+
"@types/jest": "^27.0.3",
|
32
|
+
"@types/mocha": "^9.0.0",
|
18
33
|
"@types/node": "^14.14.41",
|
19
34
|
"chai": "^4.3.4",
|
20
35
|
"chai-as-promised": "^7.1.1",
|
21
36
|
"chai-bn": "^0.2.1",
|
22
|
-
"
|
37
|
+
"jest": "^27.3.1",
|
38
|
+
"mocha": "^8.4.0",
|
39
|
+
"ts-jest": "^27.0.7",
|
40
|
+
"typescript": "^4.5.2"
|
23
41
|
},
|
24
42
|
"dependencies": {
|
25
43
|
"@toruslabs/torus-embed": "^1.10.14",
|
26
44
|
"@types/sqlite3": "^3.1.7",
|
27
45
|
"@types/web3": "^1.2.2",
|
28
|
-
"
|
46
|
+
"assert": "^2.0.0",
|
29
47
|
"compression": "^1.7.4",
|
30
48
|
"cors": "^2.8.5",
|
31
49
|
"dotenv": "^8.2.0",
|
50
|
+
"dvote-js": "^1.13.3",
|
32
51
|
"ethereumjs-tx": "^2.1.2",
|
33
52
|
"ethers": "^5.2.0",
|
34
53
|
"ethrpc": "^6.2.4",
|
35
54
|
"express": "^4.17.1",
|
36
55
|
"fortmatic": "^2.2.1",
|
37
|
-
"helmet": "^4.6.0",
|
38
56
|
"ipfs": "^0.54.4",
|
39
57
|
"ipfs-api": "^26.1.2",
|
40
58
|
"ipfs-core": "^0.7.1",
|
41
59
|
"ipfs-http-client": "^49.0.4",
|
42
|
-
"knex": "^0.95.5",
|
43
60
|
"md5": "^2.3.0",
|
44
|
-
"mongodb": "^3.6.9",
|
45
|
-
"mongoose": "^5.12.12",
|
46
|
-
"sqlite3": "^5.0.2",
|
47
|
-
"typescript": "^4.4.3",
|
48
61
|
"web3": "^1.3.5"
|
49
62
|
}
|
50
63
|
}
|
@@ -23,6 +23,7 @@ class OpportunityService {
|
|
23
23
|
private opportunityLogger = null;
|
24
24
|
private storageProvider = opportunityStorageProvider;
|
25
25
|
private currentAccount = null;
|
26
|
+
private ethNetwork;
|
26
27
|
|
27
28
|
|
28
29
|
public api = opportunityAPI;
|
@@ -69,6 +70,14 @@ class OpportunityService {
|
|
69
70
|
startEventListeners(eventDictionary, onComplete);
|
70
71
|
}
|
71
72
|
|
73
|
+
setEthNetwork(network) {
|
74
|
+
this.ethNetwork = network;
|
75
|
+
}
|
76
|
+
|
77
|
+
getEthNetwork() {
|
78
|
+
return this.ethNetwork;
|
79
|
+
}
|
80
|
+
|
72
81
|
async startService() {
|
73
82
|
if (this.running) { return; }
|
74
83
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { FakeTransaction, Transaction, TxData } from "ethereumjs-tx";
|
2
|
+
import { Contracts, ContractType } from "../../constants";
|
3
|
+
import opportunityEventEmitter from "../../events/OpportunityEventEmitter";
|
4
|
+
import { ParamObject } from "../../types";
|
5
|
+
|
6
|
+
import * as abiMap from '../../blockchain/abi.json';
|
7
|
+
import * as addressMap from '../../blockchain/addresses.json'
|
8
|
+
import * as bytecodeMap from '../../blockchain/bytecode.json';
|
9
|
+
import opportunityService from "../../OpportunityService";
|
10
|
+
import { ethers, ContractFactory } from 'ethers';
|
11
|
+
import opportunityStorageProvider from "../../modules/storage/OpportunityStorageProvider";
|
12
|
+
import { Result } from "ethers/lib/utils";
|
13
|
+
|
14
|
+
const Tx = require("ethereumjs-tx").Transaction;
|
15
|
+
|
16
|
+
async function createDispute(data) : Promise<void> {
|
17
|
+
//createData(data)
|
18
|
+
|
19
|
+
const parsedData = JSON.parse(data)
|
20
|
+
const abi = abiMap[Contracts.DISPUTE]
|
21
|
+
|
22
|
+
const complaintMetadataPointer = parsedData['complaintMetadataPointer']
|
23
|
+
const complaintResponseMetadataPointer = parsedData['complaintResponseMetadataPointer']
|
24
|
+
const relationshipAddress = parsedData['relationshipAddress']
|
25
|
+
|
26
|
+
console.log(abi)
|
27
|
+
console.log(parsedData)
|
28
|
+
|
29
|
+
try {
|
30
|
+
// The factory we use for deploying contracts
|
31
|
+
const disputeContractfactory = new ContractFactory(abi, bytecodeMap[Contracts.DISPUTE], opportunityService.getSignersInterface())
|
32
|
+
|
33
|
+
// Deploy an instance of the contract
|
34
|
+
const disputeContract = await disputeContractfactory.deploy(relationshipAddress, addressMap[opportunityService.getEthNetwork()][Contracts.SCHEDULER], complaintMetadataPointer, complaintResponseMetadataPointer);
|
35
|
+
const txReceipt = await disputeContract.deployTransaction.wait()
|
36
|
+
console.log(txReceipt)
|
37
|
+
} catch(error) {
|
38
|
+
console.log('Service: Caught error creating new job: ' + error);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
export { createDispute }
|
@@ -40,7 +40,7 @@ async function createTask(data) : Promise<void> {
|
|
40
40
|
console.log('d')
|
41
41
|
const contract = await new ethers.Contract(taskMarket, abi).connect(opportunityService.getSignersInterface());
|
42
42
|
console.log('e')
|
43
|
-
const txResponse = await contract.functions.createJob(taskOwner, ContractType.NORMAL, taskMetadataPointer, addressMap[
|
43
|
+
const txResponse = await contract.functions.createJob(taskOwner, ContractType.NORMAL, taskMetadataPointer, addressMap[opportunityService.getEthNetwork()]['Dai'])
|
44
44
|
const txReceipt = await txResponse.wait()
|
45
45
|
console.log(txReceipt)
|
46
46
|
} catch(error) {
|
@@ -7,7 +7,7 @@ import * as abiMap from '../../blockchain/abi.json';
|
|
7
7
|
import { Result } from 'ethers/lib/utils';
|
8
8
|
|
9
9
|
async function registerNewUser(universalAddress) {
|
10
|
-
const txResult = new Contract(addressMap[Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION])
|
10
|
+
const txResult = new Contract(addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION])
|
11
11
|
.connect(opportunityService.getSignersInterface())
|
12
12
|
.functions
|
13
13
|
.registerNewUser(universalAddress)
|
package/src/api/internal/abis.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
import opportunityService from '../../OpportunityService';
|
1
2
|
import * as addressMap from '../../blockchain/addresses.json';
|
2
3
|
|
4
|
+
const ethNetwork = opportunityService.getEthNetwork()
|
5
|
+
|
3
6
|
export default {
|
4
|
-
'MarketFactory': addressMap['MarketFactory'],
|
5
|
-
'UserRegistration': addressMap['UserRegistration'],
|
6
|
-
'Dai': addressMap['Dai'],
|
7
|
-
'
|
8
|
-
'Banker': addressMap['Banker']
|
7
|
+
'MarketFactory': addressMap[ethNetwork]['MarketFactory'],
|
8
|
+
'UserRegistration': addressMap[ethNetwork]['UserRegistration'],
|
9
|
+
'Dai': addressMap[ethNetwork]['Dai'],
|
10
|
+
'Scheduler': addressMap[ethNetwork]['Scheduler']
|
9
11
|
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { providers } from "ethers"
|
2
|
+
import { CensusOffChainApi, CensusOffChain } from 'dvote-js'
|
3
|
+
|
4
|
+
import gwPool from "./connect"
|
5
|
+
|
6
|
+
let merkleTreeOrigin: string
|
7
|
+
let merkleRoot: string
|
8
|
+
|
9
|
+
|
10
|
+
async function publishVoteCensus(
|
11
|
+
censusName: string,
|
12
|
+
entityWallet: providers.JsonRpcSigner,
|
13
|
+
adminPubKey: string,
|
14
|
+
accountsToPublicKeys: Array<{ address: string, pubKey: string }>
|
15
|
+
) {
|
16
|
+
// Prepare the census parameters
|
17
|
+
const adminPublicKeys = [adminPubKey]
|
18
|
+
const publicKeyClaims : { key: string, value: string }[] = accountsToPublicKeys.map(account => {
|
19
|
+
const hashedAddress = CensusOffChain.Anonymous.digestPublicKey(BigInt(account.pubKey), BigInt(account.pubKey))
|
20
|
+
const value = ""
|
21
|
+
return { key: hashedAddress, value }
|
22
|
+
}) // hash the keys
|
23
|
+
|
24
|
+
// As the census does not exist yet, we create it (optional when it exists)
|
25
|
+
let { censusId } = await CensusOffChainApi.addCensus(censusName, adminPublicKeys, gwPool, entityWallet)
|
26
|
+
console.log(`Census added: "${censusName}" with ID ${censusId}`)
|
27
|
+
|
28
|
+
// Add claims to the new census
|
29
|
+
let result = await CensusOffChainApi.addClaimBulk(censusId, publicKeyClaims, true, gwPool, entityWallet)
|
30
|
+
console.log("Added", accountsToPublicKeys.length, "claims to", censusId)
|
31
|
+
if (result.invalidClaims.length > 0) console.error("Invalid claims", result.invalidClaims)
|
32
|
+
|
33
|
+
merkleRoot = await CensusOffChainApi.getRoot(censusId, gwPool)
|
34
|
+
console.log("Census Merkle Root", merkleRoot)
|
35
|
+
|
36
|
+
// Make it available publicly
|
37
|
+
merkleTreeOrigin = await CensusOffChainApi.publishCensus(censusId, gwPool, entityWallet)
|
38
|
+
console.log("Census published on", merkleTreeOrigin)
|
39
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import {
|
2
|
+
GatewayPool,
|
3
|
+
IGatewayDiscoveryParameters,
|
4
|
+
EthNetworkID,
|
5
|
+
VocdoniEnvironment
|
6
|
+
} from "dvote-js"
|
7
|
+
|
8
|
+
let gwPool : GatewayPool = null
|
9
|
+
|
10
|
+
export async function connectGateways(
|
11
|
+
ethNetworkId: EthNetworkID,
|
12
|
+
environment: VocdoniEnvironment,
|
13
|
+
bootnodesContentUri: string
|
14
|
+
) {
|
15
|
+
console.log("Connecting to the gateways")
|
16
|
+
|
17
|
+
//gateway options
|
18
|
+
const options: IGatewayDiscoveryParameters = {
|
19
|
+
networkId: ethNetworkId,
|
20
|
+
environment,
|
21
|
+
bootnodesContentUri,
|
22
|
+
numberOfGateways: 2,
|
23
|
+
// timeout: 10000,
|
24
|
+
}
|
25
|
+
|
26
|
+
const pool = await GatewayPool.discover(options)
|
27
|
+
return pool
|
28
|
+
}
|
29
|
+
|
30
|
+
async function disconnectGateways() {
|
31
|
+
gwPool.disconnect()
|
32
|
+
}
|
33
|
+
|
34
|
+
export default gwPool
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { EntityMetadata, EntityApi, EntityMetadataTemplate, GatewayPool } from "dvote-js"
|
2
|
+
import { providers } from 'ethers'
|
3
|
+
import gwPool from "./connect"
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Vocdoni Docs:
|
7
|
+
* We created JSON metadata containing the custom details of our entity
|
8
|
+
* We pinned the JSON content on IPFS using a gateway from the pool
|
9
|
+
* The hash of our metadata is QmdK5TnHDXPt4xozkuboyKP94RTrUxFr1z9Pkv5qhfahFG and should be available from any IPFS peer (opens new window)
|
10
|
+
* An Ethereum transaction was sent to the entities contract, defining the pointer to our new metadata.
|
11
|
+
* The value on the smart contract can only be updated by our wallet, the blockchain ensures the integrity of our data and IPFS ensures its global availability.
|
12
|
+
*
|
13
|
+
* @param entity
|
14
|
+
* @param entityAppData
|
15
|
+
*/
|
16
|
+
export async function registerEntity(pool : GatewayPool, entity, address) {
|
17
|
+
// Make a copy of the metadata template and customize it
|
18
|
+
|
19
|
+
const entityMetadata: EntityMetadata = Object.assign({}, EntityMetadataTemplate)
|
20
|
+
|
21
|
+
entityMetadata.name.default = "App"
|
22
|
+
entityMetadata.description.default = "App"
|
23
|
+
/*entityMetadata.media = {
|
24
|
+
avatar: 'https://my-organization.org/logo.png',
|
25
|
+
header: 'https://my-organization.org/header.jpeg'
|
26
|
+
}*/
|
27
|
+
entityMetadata.actions = []
|
28
|
+
|
29
|
+
const contentUri = await EntityApi.setMetadata(address, entityMetadata, entity, pool)
|
30
|
+
// Show stored values
|
31
|
+
console.log("The entity has been defined")
|
32
|
+
console.log(contentUri)
|
33
|
+
}
|