opportunity-service 0.0.519 → 0.0.520
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/OpportunityService.js +141 -0
- package/dist/OpportunityService.js.map +1 -0
- package/dist/api/ethereum/sendAsync.js +37 -0
- package/dist/api/ethereum/sendAsync.js.map +1 -0
- package/dist/api/exchange/complete-relationship.js +4 -0
- package/dist/api/exchange/complete-relationship.js.map +1 -0
- 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 +70 -0
- package/dist/api/exchange/create-task.js.map +1 -0
- package/dist/api/exchange/enter-work-relationship.js +61 -0
- package/dist/api/exchange/enter-work-relationship.js.map +1 -0
- package/dist/api/exchange/index.js +1 -0
- package/dist/api/exchange/index.js.map +1 -0
- package/dist/api/exchange/inspect-relationship.js +6 -0
- package/dist/api/exchange/inspect-relationship.js.map +1 -0
- package/dist/api/identity/register-new-user.js +30 -0
- package/dist/api/identity/register-new-user.js.map +1 -0
- package/dist/api/index.js +43 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/internal/abis.js +9 -0
- package/dist/api/internal/abis.js.map +1 -0
- package/dist/api/internal/addresses.js +9 -0
- package/dist/api/internal/addresses.js.map +1 -0
- package/dist/api/internal/events.js +10 -0
- package/dist/api/internal/events.js.map +1 -0
- package/dist/api/internal/index.js +5 -0
- package/dist/api/internal/index.js.map +1 -0
- package/dist/api/market/create-market.js +4 -0
- package/dist/api/market/create-market.js.map +1 -0
- 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 +955 -0
- package/dist/blockchain/addresses.json +14 -0
- package/dist/blockchain/blocks.json +3 -0
- package/dist/blockchain/bytecode.json +4 -0
- 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 +93 -0
- package/dist/constants.js.map +1 -0
- package/dist/events/OpportunityEventEmitter.js +32 -0
- package/dist/events/OpportunityEventEmitter.js.map +1 -0
- package/dist/events/get-log.js +1 -0
- package/dist/events/get-log.js.map +1 -0
- package/dist/events/start-event-listeners.js +9 -0
- package/dist/events/start-event-listeners.js.map +1 -0
- package/dist/events/sync-with-ethereum-node.js +20 -0
- package/dist/events/sync-with-ethereum-node.js.map +1 -0
- package/dist/gas.js +1 -0
- package/dist/gas.js.map +1 -0
- package/dist/logger.js +1 -0
- package/dist/logger.js.map +1 -0
- package/dist/modules/storage/OpportunityStorageProvider.js +64 -0
- package/dist/modules/storage/OpportunityStorageProvider.js.map +1 -0
- package/dist/sync/process/process-log.js +69 -0
- package/dist/sync/process/process-log.js.map +1 -0
- package/dist/sync/process/processDisputeCreated.js +33 -0
- package/dist/sync/process/processDisputeCreated.js.map +1 -0
- package/dist/sync/process/processMarketCreatedLog.js +33 -0
- package/dist/sync/process/processMarketCreatedLog.js.map +1 -0
- package/dist/sync/process/processMarketDestroyedEvent.js +10 -0
- package/dist/sync/process/processMarketDestroyedEvent.js.map +1 -0
- package/dist/sync/process/processUserAssignedTrueIdentification.js +21 -0
- package/dist/sync/process/processUserAssignedTrueIdentification.js.map +1 -0
- package/dist/sync/process/processUserRegistered.js +20 -0
- package/dist/sync/process/processUserRegistered.js.map +1 -0
- package/dist/sync/process/processUserSummaryCreated.js +22 -0
- package/dist/sync/process/processUserSummaryCreated.js.map +1 -0
- package/dist/sync/process/processWorkRelationshipCreated.js +38 -0
- package/dist/sync/process/processWorkRelationshipCreated.js.map +1 -0
- package/dist/sync/sync-jobs.js +33 -0
- package/dist/sync/sync-jobs.js.map +1 -0
- package/dist/sync/sync-markets.js +35 -0
- package/dist/sync/sync-markets.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util.js +1 -0
- package/dist/util.js.map +1 -0
- package/package.json +1 -1
@@ -0,0 +1,141 @@
|
|
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
|
+
import { RPCEvents, ServiceEvents } from "./constants";
|
11
|
+
import opportunityEventEmitter from "./events/OpportunityEventEmitter";
|
12
|
+
import { syncWithEthereumNode } from "./events/sync-with-ethereum-node";
|
13
|
+
import abiMap from './blockchain/abi.json';
|
14
|
+
import addressesMap from './blockchain/addresses.json';
|
15
|
+
import blocksMap from './blockchain/blocks.json';
|
16
|
+
import { ethers } from "ethers";
|
17
|
+
import { startEventListeners } from "./events/start-event-listeners";
|
18
|
+
import opportunityAPI from './api/index';
|
19
|
+
import opportunityStorageProvider from "./modules/storage/OpportunityStorageProvider";
|
20
|
+
class OpportunityService {
|
21
|
+
/**
|
22
|
+
* The Singleton's constructor should always be private to prevent direct
|
23
|
+
* construction calls with the `new` operator.
|
24
|
+
*/
|
25
|
+
constructor() {
|
26
|
+
this.eventEmitter = opportunityEventEmitter;
|
27
|
+
this.running = false;
|
28
|
+
this.ethersProvider = ethers.getDefaultProvider('http://localhost:8545');
|
29
|
+
this.ethersSigner = null;
|
30
|
+
this.opportunityLogger = null;
|
31
|
+
this.storageProvider = opportunityStorageProvider;
|
32
|
+
this.currentAccount = null;
|
33
|
+
this.ethNetwork = 'rinkeby';
|
34
|
+
this.api = opportunityAPI;
|
35
|
+
this.ethNetwork = 'rinkeby';
|
36
|
+
}
|
37
|
+
/**
|
38
|
+
* The static method that controls the access to the singleton instance.
|
39
|
+
*
|
40
|
+
* This implementation let you subclass the Singleton class while keeping
|
41
|
+
* just one instance of each subclass around.
|
42
|
+
*/
|
43
|
+
static getInstance() {
|
44
|
+
if (!OpportunityService.instance) {
|
45
|
+
OpportunityService.instance = new OpportunityService();
|
46
|
+
}
|
47
|
+
return OpportunityService.instance;
|
48
|
+
}
|
49
|
+
assignDefaultProvider(provider) {
|
50
|
+
OpportunityService.defaultProvider = provider;
|
51
|
+
}
|
52
|
+
assignProvider(provider) {
|
53
|
+
this.ethersProvider = provider;
|
54
|
+
}
|
55
|
+
assignSigner(signer) {
|
56
|
+
this.ethersSigner = signer;
|
57
|
+
}
|
58
|
+
assignCurrentAccount(account) {
|
59
|
+
this.currentAccount = account;
|
60
|
+
}
|
61
|
+
subscribeToEvents(eventDictionary, onComplete) {
|
62
|
+
startEventListeners(eventDictionary, onComplete);
|
63
|
+
}
|
64
|
+
setEthNetwork(network) {
|
65
|
+
switch (network) {
|
66
|
+
case 1:
|
67
|
+
this.ethNetwork = 'mainnet';
|
68
|
+
break;
|
69
|
+
case 4:
|
70
|
+
this.ethNetwork = 'rinkeby';
|
71
|
+
break;
|
72
|
+
default:
|
73
|
+
this.ethNetwork = 'rinkeby';
|
74
|
+
}
|
75
|
+
}
|
76
|
+
getEthNetwork() {
|
77
|
+
return this.ethNetwork;
|
78
|
+
}
|
79
|
+
startService() {
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
81
|
+
if (this.running) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
console.log('Starting service...');
|
85
|
+
this.sync();
|
86
|
+
this.running = true;
|
87
|
+
console.log('Finished starting service...');
|
88
|
+
});
|
89
|
+
}
|
90
|
+
shutdownService() {
|
91
|
+
if (!this.running) {
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
;
|
95
|
+
this.running = false;
|
96
|
+
this.assignDefaultProvider(null);
|
97
|
+
this.assignProvider(null);
|
98
|
+
this.assignSigner(null);
|
99
|
+
this.eventEmitter.emit(ServiceEvents.ServiceStopped);
|
100
|
+
}
|
101
|
+
sync() {
|
102
|
+
//sync node
|
103
|
+
this.syncing = true;
|
104
|
+
this.eventEmitter.emit(RPCEvents.StartSyncing);
|
105
|
+
syncWithEthereumNode()
|
106
|
+
.then(() => {
|
107
|
+
this.syncing = false;
|
108
|
+
this.eventEmitter.emit(RPCEvents.StopSyncing);
|
109
|
+
console.log('Finished syncing ethereum node.');
|
110
|
+
this.syncing = false;
|
111
|
+
})
|
112
|
+
.catch(err => {
|
113
|
+
console.log('Error while syncing ethereum node: ' + err);
|
114
|
+
this.syncing = false;
|
115
|
+
});
|
116
|
+
}
|
117
|
+
isSyncing() {
|
118
|
+
return this.syncing;
|
119
|
+
}
|
120
|
+
accessContractUploadBlock(contract) {
|
121
|
+
return blocksMap[contract];
|
122
|
+
}
|
123
|
+
accessContractAddress(contract) {
|
124
|
+
return addressesMap[contract];
|
125
|
+
}
|
126
|
+
accessContractABI(contract) {
|
127
|
+
return abiMap[contract];
|
128
|
+
}
|
129
|
+
getDefaultProviderInterface() {
|
130
|
+
return OpportunityService.defaultProvider;
|
131
|
+
}
|
132
|
+
getProviderInterface() {
|
133
|
+
return this.ethersProvider;
|
134
|
+
}
|
135
|
+
getSignersInterface() {
|
136
|
+
return this.ethersSigner;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
const opportunityService = OpportunityService.getInstance();
|
140
|
+
export default opportunityService;
|
141
|
+
//# sourceMappingURL=OpportunityService.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"OpportunityService.js","sourceRoot":"","sources":["../src/OpportunityService.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAA6B,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,uBAAuB,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB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EAAE;aACjB,IAAI,CAAC,GAAG,EAAE;YACP,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;YAC9C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACT,OAAO,CAAC,GAAG,CAAC,qCAAqC,GAAG,GAAG,CAAC,CAAA;YACxD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC,CAAA;IACV,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,yBAAyB,CAAC,QAAmB;QACzC,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,qBAAqB,CAAC,QAAmB;QACrC,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,QAAmB;QACjC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,2BAA2B;QACvB,OAAO,kBAAkB,CAAC,eAAe,CAAC;IAC9C,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AAED,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;AAC5D,eAAe,kBAAkB,CAAC"}
|
@@ -0,0 +1,37 @@
|
|
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
|
+
import opportunityService from "../../OpportunityService";
|
11
|
+
export function sendAsync(method, params, from) {
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
13
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
14
|
+
yield opportunityService.getDefaultProviderInterface().currentProvider.sendAsync({
|
15
|
+
id: 1,
|
16
|
+
method,
|
17
|
+
params,
|
18
|
+
from,
|
19
|
+
}, function (error, result) {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
if (error) {
|
22
|
+
console.log(error);
|
23
|
+
throw error;
|
24
|
+
}
|
25
|
+
const realResult = result.result.toString().slice(2);
|
26
|
+
const r = '0x' + realResult.slice(0, 64);
|
27
|
+
const s = '0x' + realResult.slice(64, 128);
|
28
|
+
const v = parseInt(realResult.substring(128, 130), 16);
|
29
|
+
resolve({
|
30
|
+
v, r, s
|
31
|
+
});
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}));
|
35
|
+
});
|
36
|
+
}
|
37
|
+
//# sourceMappingURL=sendAsync.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sendAsync.js","sourceRoot":"","sources":["../../../src/api/ethereum/sendAsync.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D,MAAM,UAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI;;QAChD,OAAO,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;YAC7C,MAAM,kBAAkB,CAAC,2BAA2B,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC;gBAC7E,EAAE,EAAE,CAAC;gBACL,MAAM;gBACN,MAAM;gBACN,IAAI;aACL,EAAE,UAAe,KAAK,EAAE,MAAM;;oBAC7B,IAAI,KAAK,EAAE;wBACT,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;wBAClB,MAAM,KAAK,CAAC;qBACb;oBAEC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;oBACpD,MAAM,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBACzC,MAAM,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;oBAC3C,MAAM,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;oBAEvD,OAAO,CAAC;wBACJ,CAAC,EAAE,CAAC,EAAE,CAAC;qBACV,CAAC,CAAA;gBAEN,CAAC;aAAA,CAAC,CAAC;QACL,CAAC,CAAA,CAAC,CAAA;IACN,CAAC;CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"complete-relationship.js","sourceRoot":"","sources":["../../../src/api/exchange/complete-relationship.ts"],"names":[],"mappings":"AAAA,SAAS,oBAAoB,CAAC,mBAAmB;AAEjD,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
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
|
+
import { Contracts } from "../../constants";
|
11
|
+
import * as abiMap from '../../blockchain/abi.json';
|
12
|
+
import * as addressMap from '../../blockchain/addresses.json';
|
13
|
+
import * as bytecodeMap from '../../blockchain/bytecode.json';
|
14
|
+
import opportunityService from "../../OpportunityService";
|
15
|
+
import { ContractFactory } from 'ethers';
|
16
|
+
const Tx = require("ethereumjs-tx").Transaction;
|
17
|
+
function createDispute(data) {
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
19
|
+
//createData(data)
|
20
|
+
const parsedData = JSON.parse(data);
|
21
|
+
const abi = abiMap[Contracts.DISPUTE];
|
22
|
+
const complaintMetadataPointer = parsedData['complaintMetadataPointer'];
|
23
|
+
const complaintResponseMetadataPointer = parsedData['complaintResponseMetadataPointer'];
|
24
|
+
const relationshipAddress = parsedData['relationshipAddress'];
|
25
|
+
console.log(abi);
|
26
|
+
console.log(parsedData);
|
27
|
+
try {
|
28
|
+
// The factory we use for deploying contracts
|
29
|
+
const disputeContractfactory = new ContractFactory(abi, bytecodeMap[Contracts.DISPUTE], opportunityService.getSignersInterface());
|
30
|
+
// Deploy an instance of the contract
|
31
|
+
const disputeContract = yield disputeContractfactory.deploy(relationshipAddress, addressMap[opportunityService.getEthNetwork()][Contracts.SCHEDULER], complaintMetadataPointer, complaintResponseMetadataPointer);
|
32
|
+
const txReceipt = yield disputeContract.deployTransaction.wait();
|
33
|
+
console.log(txReceipt);
|
34
|
+
}
|
35
|
+
catch (error) {
|
36
|
+
console.log('Service: Caught error creating new job: ' + error);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
export { createDispute };
|
41
|
+
//# sourceMappingURL=create-dispute.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-dispute.js","sourceRoot":"","sources":["../../../src/api/exchange/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AM,eAAe,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAA;YAChE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;SACzB;QAAC,OAAM,KAAK,EAAE;YACX,OAAO,CAAC,GAAG,CAAC,0CAA0C,GAAG,KAAK,CAAC,CAAC;SACnE;IACL,CAAC;CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
@@ -0,0 +1,70 @@
|
|
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
|
+
import { Contracts, ContractType } from "../../constants";
|
11
|
+
import * as abiMap from '../../blockchain/abi.json';
|
12
|
+
import * as addressMap from '../../blockchain/addresses.json';
|
13
|
+
import opportunityService from "../../OpportunityService";
|
14
|
+
import { ethers } from 'ethers';
|
15
|
+
const Tx = require("ethereumjs-tx").Transaction;
|
16
|
+
function createTask(data) {
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
18
|
+
console.log('a');
|
19
|
+
const parsedData = JSON.parse(data);
|
20
|
+
const abi = abiMap[Contracts.MARKET];
|
21
|
+
console.log(abi);
|
22
|
+
console.log(parsedData);
|
23
|
+
const taskOwner = parsedData["taskOwner"];
|
24
|
+
const taskMarket = parsedData["taskMarket"];
|
25
|
+
const taskBounty = Number(parsedData["taskBounty"]);
|
26
|
+
const taskMetadataPointer = parsedData["taskMetadataPointer"];
|
27
|
+
console.log('b');
|
28
|
+
console.log(taskOwner);
|
29
|
+
console.log(taskMarket);
|
30
|
+
console.log('h');
|
31
|
+
console.log(taskBounty);
|
32
|
+
console.log(taskMetadataPointer);
|
33
|
+
if (taskOwner == null || taskMarket == 0 || taskBounty == 0 || taskMetadataPointer == '') {
|
34
|
+
throw new Error('Null value in data');
|
35
|
+
}
|
36
|
+
console.log('C');
|
37
|
+
try {
|
38
|
+
console.log('d');
|
39
|
+
const contract = yield new ethers.Contract(taskMarket, abi).connect(opportunityService.getSignersInterface());
|
40
|
+
console.log('e');
|
41
|
+
const txResponse = yield contract.functions.createJob(taskOwner, ContractType.NORMAL, taskMetadataPointer, addressMap[opportunityService.getEthNetwork()]['Dai']);
|
42
|
+
const txReceipt = yield txResponse.wait();
|
43
|
+
console.log(txReceipt);
|
44
|
+
}
|
45
|
+
catch (error) {
|
46
|
+
console.log('Service: Caught error creating new job: ' + error);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
export { createTask };
|
51
|
+
/*
|
52
|
+
|
53
|
+
blockHash: "0xa923c23eec29567d8c2a84c85efbf852d8843448e6452ace4296142a5bf172c4"
|
54
|
+
blockNumber: 546
|
55
|
+
byzantium: true
|
56
|
+
confirmations: 1
|
57
|
+
contractAddress: null
|
58
|
+
cumulativeGasUsed: BigNumber {_hex: '0x1905c4', _isBigNumber: true}
|
59
|
+
events: [{…}]
|
60
|
+
from: "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"
|
61
|
+
gasUsed: BigNumber {_hex: '0x1905c4', _isBigNumber: true}
|
62
|
+
logs: [{…}]
|
63
|
+
logsBloom: "0x00000000000000000000000000000000000008000000000000000000000000000000008004000000000000000000000000000000000000001080000020000000000000000000000000000000008000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000010000000040000000000000000000000000000000000000000000000000000080000008000800000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000"
|
64
|
+
status: 1
|
65
|
+
to: "0xF1fE363e6A32F91F52D55dCa56daFb1C88f9Dc2C"
|
66
|
+
transactionHash: "0x70f1f60a6a5056374cad6480dc1137be3a953d4ef724dac1190076305291096a"
|
67
|
+
transactionIndex: 0
|
68
|
+
|
69
|
+
*/
|
70
|
+
//# sourceMappingURL=create-task.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-task.js","sourceRoot":"","sources":["../../../src/api/exchange/create-task.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI1D,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAE7D,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,WAAW,CAAC;AAEhD,SAAe,UAAU,CAAC,IAAI;;QAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAEvB,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,CAAA;QAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAA;QACnD,MAAM,mBAAmB,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAA;QAC7D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,OAAO,CAAC,GAAG,CAAC,SAAS,C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
2
|
+
/*const abi = Contract.Market.WorkRelationship.abi;
|
3
|
+
const bytecode = '608060405234801561001057600080fd5b50606460008190555060ca806100276000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806380219655146037578063ed0109a5146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b6068608c565b6040518082815260200191505060405180910390f35b806000540160008190555050565b6000805490509056fea265627a7a7230582002f975dfd70c1b1f649671805826a83fc9b92457fe7dd245527f56b7776d043464736f6c634300050a0032';
|
4
|
+
|
5
|
+
const contract = opportunityConnectionProvider.getProviderInterface().web3.eth.Contract(JSON.parse(abi)); //web3.eth.Contract(JSON.parse(abi));
|
6
|
+
|
7
|
+
const txParameter : FakeTransaction = {
|
8
|
+
from: opportunityConnectionProvider.getProviderInterface().web3.eth.getAccounts()[0],
|
9
|
+
gasPrice: opportunityConnectionProvider.getProviderInterface().web3.utils.toHex(opportunityConnectionProvider.getProviderInterface().web3.utils.toWei('30', 'gwei'))
|
10
|
+
}
|
11
|
+
|
12
|
+
const isValidWorker = opportunityConnectionProvider.getProviderInterface().web3.eth.Contract(
|
13
|
+
contract,
|
14
|
+
relationshipAddress)
|
15
|
+
.methods
|
16
|
+
.checkWorkerEvaluation(opportunityConnectionProvider.getProviderInterface().web3.accounts.getAccounts()[0], evaluationState)
|
17
|
+
.send(txParameter, callback)
|
18
|
+
.on('transactionHash', hash => {
|
19
|
+
|
20
|
+
})
|
21
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
22
|
+
|
23
|
+
})
|
24
|
+
.on('receipt', receipt => {
|
25
|
+
// receipt example
|
26
|
+
console.log(receipt);
|
27
|
+
})
|
28
|
+
.on('error', (error, receipt) => { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
|
29
|
+
|
30
|
+
})
|
31
|
+
.then( receipt => {
|
32
|
+
// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()"
|
33
|
+
});
|
34
|
+
|
35
|
+
if (isValidWorker === true) {
|
36
|
+
opportunityConnectionProvider.getProviderInterface().web3.eth.Contract(
|
37
|
+
contract,
|
38
|
+
relationshipAddress)
|
39
|
+
.methods
|
40
|
+
.createWorkExchange(opportunityConnectionProvider.getProviderInterface().web3.accounts.getAccounts()[0], true)
|
41
|
+
.send(txParameter, callback)
|
42
|
+
.on('transactionHash', hash => {
|
43
|
+
|
44
|
+
})
|
45
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
46
|
+
|
47
|
+
})
|
48
|
+
.on('receipt', receipt => {
|
49
|
+
// receipt example
|
50
|
+
console.log(receipt);
|
51
|
+
})
|
52
|
+
.on('error', (error, receipt) => { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
|
53
|
+
|
54
|
+
})
|
55
|
+
.then( receipt => {
|
56
|
+
// receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()"
|
57
|
+
});
|
58
|
+
}*/
|
59
|
+
}
|
60
|
+
export { enterWorkRelationship };
|
61
|
+
//# sourceMappingURL=enter-work-relationship.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"enter-work-relationship.js","sourceRoot":"","sources":["../../../src/api/exchange/enter-work-relationship.ts"],"names":[],"mappings":"AAAA,SAAS,qBAAqB,CAAC,mBAAmB,EAAE,eAAe,EAAE,QAAQ;IACzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;AACP,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/exchange/index.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"inspect-relationship.js","sourceRoot":"","sources":["../../../src/api/exchange/inspect-relationship.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,SAAS,mBAAmB,CAAC,WAAoB;IAC7C,OAAO,EAAE,CAAC;AACd,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
@@ -0,0 +1,30 @@
|
|
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
|
+
import { Contract } from 'ethers';
|
11
|
+
import opportunityService from '../../OpportunityService';
|
12
|
+
import { Contracts } from '../../constants';
|
13
|
+
import * as addressMap from '../../blockchain/addresses.json';
|
14
|
+
import * as abiMap from '../../blockchain/abi.json';
|
15
|
+
function registerNewUser(universalAddress) {
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
17
|
+
const txResult = new Contract(addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION])
|
18
|
+
.connect(opportunityService.getSignersInterface())
|
19
|
+
.functions
|
20
|
+
.registerNewUser(universalAddress)
|
21
|
+
.then(value => {
|
22
|
+
return true;
|
23
|
+
})
|
24
|
+
.catch(error => {
|
25
|
+
return false;
|
26
|
+
});
|
27
|
+
});
|
28
|
+
}
|
29
|
+
export default registerNewUser;
|
30
|
+
//# sourceMappingURL=register-new-user.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"register-new-user.js","sourceRoot":"","sources":["../../../src/api/identity/register-new-user.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,QAAQ,CAAC;AAC/C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AAGpD,SAAe,eAAe,CAAC,gBAAgB;;QAC/C,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;aAC9I,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC;aACjD,SAAS;aACT,eAAe,CAAC,gBAAgB,CAAC;aACjC,IAAI,CAAC,KAAK,CAAC,EAAE;YACV,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;aACD,KAAK,CAAC,KAAK,CAAC,EAAE;YACX,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAA;IACF,CAAC;CAAA;AAED,eAAe,eAAe,CAAC"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { syncWithEthereumNode } from "../events/sync-with-ethereum-node";
|
2
|
+
import syncJobs from "../sync/sync-jobs";
|
3
|
+
import syncMarkets from "../sync/sync-markets";
|
4
|
+
import { completeRelationship } from "./exchange/complete-relationship";
|
5
|
+
import { createTask } from "./exchange/create-task";
|
6
|
+
import { enterWorkRelationship } from "./exchange/enter-work-relationship";
|
7
|
+
import registerNewUser from "./identity/register-new-user";
|
8
|
+
import { createMarket } from "./market/create-market";
|
9
|
+
import { abis, addresses } from './internal/index';
|
10
|
+
import { sendAsync } from './ethereum/sendAsync';
|
11
|
+
function generateAPI() {
|
12
|
+
return {
|
13
|
+
internal: {
|
14
|
+
abis: abis,
|
15
|
+
addresses,
|
16
|
+
},
|
17
|
+
exchange: {
|
18
|
+
completeRelationship,
|
19
|
+
createTask,
|
20
|
+
enterWorkRelationship
|
21
|
+
},
|
22
|
+
dispute: {},
|
23
|
+
identity: {
|
24
|
+
registerNewUser
|
25
|
+
},
|
26
|
+
markets: {
|
27
|
+
createMarket,
|
28
|
+
},
|
29
|
+
network: {
|
30
|
+
sync: {
|
31
|
+
syncWithEthereum: syncWithEthereumNode,
|
32
|
+
syncMarkets,
|
33
|
+
syncJobs
|
34
|
+
}
|
35
|
+
},
|
36
|
+
provider: {
|
37
|
+
sendAsync
|
38
|
+
}
|
39
|
+
};
|
40
|
+
}
|
41
|
+
const opportunityAPI = generateAPI();
|
42
|
+
export default opportunityAPI;
|
43
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,IAAI,EAAU,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,SAAS,WAAW;IAChB,OAAO;QACH,QAAQ,EAAE;YACN,IAAI,EAAE,IAAI;YACV,SAAS;SACZ;QACD,QAAQ,EAAE;YACN,oBAAoB;YACpB,UAAU;YACV,qBAAqB;SACxB;QACD,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE;YACN,eAAe;SAClB;QACD,OAAO,EAAE;YACL,YAAY;SACf;QACD,OAAO,EAAE;YACL,IAAI,EAAE;gBACF,gBAAgB,EAAE,oBAAoB;gBACtC,WAAW;gBACX,QAAQ;aACX;SACJ;QACD,QAAQ,EAAE;YACN,SAAS;SACZ;KACJ,CAAA;AACL,CAAC;AAED,MAAM,cAAc,GAAG,WAAW,EAAE,CAAC;AAErC,eAAe,cAAc,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as abiMap from '../../blockchain/abi.json';
|
2
|
+
export default {
|
3
|
+
'MarketFactory': abiMap['MarketFactory'],
|
4
|
+
'WorkRelationship': abiMap['WorkRelationship'],
|
5
|
+
'Market': abiMap['Market'],
|
6
|
+
'UserRegistration': abiMap['UserRegistration'],
|
7
|
+
'Dispute': abiMap['Dispute']
|
8
|
+
};
|
9
|
+
//# sourceMappingURL=abis.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"abis.js","sourceRoot":"","sources":["../../../src/api/internal/abis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AAEpD,eAAe;IACX,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC;IACxC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,CAAC;IAC9C,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;CAC/B,CAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as addressMap from '../../blockchain/addresses.json';
|
2
|
+
const ethNetwork = 'rinkeby'; //opportunityService.getEthNetwork()
|
3
|
+
export default {
|
4
|
+
'MarketFactory': addressMap['rinkeby']['MarketFactory'],
|
5
|
+
'UserRegistration': addressMap['rinkeby']['UserRegistration'],
|
6
|
+
'Dai': addressMap['rinkeby']['Dai'],
|
7
|
+
'Scheduler': addressMap['rinkeby']['Scheduler']
|
8
|
+
};
|
9
|
+
//# sourceMappingURL=addresses.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/api/internal/addresses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAE9D,MAAM,UAAU,GAAG,SAAS,CAAA,CAAC,oCAAoC;AAEjE,eAAe;IACX,eAAe,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC;IACvD,kBAAkB,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC;IAC7D,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC;IACnC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC;CAClD,CAAA"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ExchangeEvents, MarketEvents, UserEvents } from "../../constants";
|
2
|
+
export default {
|
3
|
+
'WorkRelationshipCreated': ExchangeEvents.WorkRelationshipCreated,
|
4
|
+
'MarketCreated': MarketEvents.MarkedCreated,
|
5
|
+
'MarketDestroyed': MarketEvents.MarketDestroyed,
|
6
|
+
'UserRegistered': UserEvents.UserRegistered,
|
7
|
+
'UserSummaryCreated': UserEvents.UserSummaryCreated,
|
8
|
+
'UserAssignedTrueIdentification': UserEvents.UserAssignedTrueIdentification,
|
9
|
+
};
|
10
|
+
//# sourceMappingURL=events.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/api/internal/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE3E,eAAe;IACX,yBAAyB,EAAE,cAAc,CAAC,uBAAuB;IACjE,eAAe,EAAE,YAAY,CAAC,aAAa;IAC3C,iBAAiB,EAAE,YAAY,CAAC,eAAe;IAC/C,gBAAgB,EAAE,UAAU,CAAC,cAAc;IAC3C,oBAAoB,EAAE,UAAU,CAAC,kBAAkB;IACnD,gCAAgC,EAAE,UAAU,CAAC,8BAA8B;CAC9E,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/internal/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-market.js","sourceRoot":"","sources":["../../../src/api/market/create-market.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,CAAC,aAAa;AAEnC,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
@@ -0,0 +1,38 @@
|
|
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
|
+
import { CensusOffChainApi, CensusOffChain } from 'dvote-js';
|
11
|
+
import gwPool from "./connect";
|
12
|
+
let merkleTreeOrigin;
|
13
|
+
let merkleRoot;
|
14
|
+
function publishVoteCensus(censusName, entityWallet, adminPubKey, accountsToPublicKeys) {
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
16
|
+
// Prepare the census parameters
|
17
|
+
const adminPublicKeys = [adminPubKey];
|
18
|
+
const publicKeyClaims = 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
|
+
// As the census does not exist yet, we create it (optional when it exists)
|
24
|
+
let { censusId } = yield CensusOffChainApi.addCensus(censusName, adminPublicKeys, gwPool, entityWallet);
|
25
|
+
console.log(`Census added: "${censusName}" with ID ${censusId}`);
|
26
|
+
// Add claims to the new census
|
27
|
+
let result = yield CensusOffChainApi.addClaimBulk(censusId, publicKeyClaims, true, gwPool, entityWallet);
|
28
|
+
console.log("Added", accountsToPublicKeys.length, "claims to", censusId);
|
29
|
+
if (result.invalidClaims.length > 0)
|
30
|
+
console.error("Invalid claims", result.invalidClaims);
|
31
|
+
merkleRoot = yield CensusOffChainApi.getRoot(censusId, gwPool);
|
32
|
+
console.log("Census Merkle Root", merkleRoot);
|
33
|
+
// Make it available publicly
|
34
|
+
merkleTreeOrigin = yield CensusOffChainApi.publishCensus(censusId, gwPool, entityWallet);
|
35
|
+
console.log("Census published on", merkleTreeOrigin);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
//# sourceMappingURL=census.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"census.js","sourceRoot":"","sources":["../../../src/api/voting/census.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE5D,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,IAAI,gBAAwB,CAAA;AAC5B,IAAI,UAAkB,CAAA;AAGtB,SAAe,iBAAiB,CAC5B,UAAkB,EAClB,YAAqC,EACrC,WAAmB,EACnB,oBAAgE;;QAEhE,gCAAgC;QAChC,MAAM,eAAe,GAAG,CAAC,WAAW,CAAC,CAAA;QACrC,MAAM,eAAe,GAAsC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YA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33 @@
|
|
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
|
+
import { GatewayPool } from "dvote-js";
|
11
|
+
let gwPool = null;
|
12
|
+
export function connectGateways(ethNetworkId, environment, bootnodesContentUri) {
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
14
|
+
console.log("Connecting to the gateways");
|
15
|
+
//gateway options
|
16
|
+
const options = {
|
17
|
+
networkId: ethNetworkId,
|
18
|
+
environment,
|
19
|
+
bootnodesContentUri,
|
20
|
+
numberOfGateways: 2,
|
21
|
+
// timeout: 10000,
|
22
|
+
};
|
23
|
+
const pool = yield GatewayPool.discover(options);
|
24
|
+
return pool;
|
25
|
+
});
|
26
|
+
}
|
27
|
+
function disconnectGateways() {
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
29
|
+
gwPool.disconnect();
|
30
|
+
});
|
31
|
+
}
|
32
|
+
export default gwPool;
|
33
|
+
//# sourceMappingURL=connect.js.map
|