opportunity-service 0.0.564 → 0.0.568

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/dist/OpportunityService.js +137 -0
  2. package/dist/OpportunityService.js.map +1 -0
  3. package/dist/api/dispute/check-vote-results.js +33 -0
  4. package/dist/api/dispute/check-vote-results.js.map +1 -0
  5. package/dist/api/dispute/connect.js +39 -0
  6. package/dist/api/dispute/connect.js.map +1 -0
  7. package/dist/api/dispute/ensure-entity-metadata.js +39 -0
  8. package/dist/api/dispute/ensure-entity-metadata.js.map +1 -0
  9. package/dist/api/dispute/launch-new-vote.js +94 -0
  10. package/dist/api/dispute/launch-new-vote.js.map +1 -0
  11. package/dist/api/dispute/submit-vote.js +41 -0
  12. package/dist/api/dispute/submit-vote.js.map +1 -0
  13. package/dist/api/dispute/util/wait-until-present.js +27 -0
  14. package/dist/api/dispute/util/wait-until-present.js.map +1 -0
  15. package/dist/api/dispute/util/wait-until-started.js +23 -0
  16. package/dist/api/dispute/util/wait-until-started.js.map +1 -0
  17. package/dist/api/ethereum/sendAsync.js +37 -0
  18. package/dist/api/ethereum/sendAsync.js.map +1 -0
  19. package/dist/api/exchange/complete-relationship.js +4 -0
  20. package/dist/api/exchange/complete-relationship.js.map +1 -0
  21. package/dist/api/exchange/create-dispute.js +40 -0
  22. package/dist/api/exchange/create-dispute.js.map +1 -0
  23. package/dist/api/exchange/create-task.js +70 -0
  24. package/dist/api/exchange/create-task.js.map +1 -0
  25. package/dist/api/exchange/enter-work-relationship.js +61 -0
  26. package/dist/api/exchange/enter-work-relationship.js.map +1 -0
  27. package/dist/api/exchange/index.js +1 -0
  28. package/dist/api/exchange/index.js.map +1 -0
  29. package/dist/api/exchange/inspect-relationship.js +6 -0
  30. package/dist/api/exchange/inspect-relationship.js.map +1 -0
  31. package/dist/api/identity/register-new-user.js +33 -0
  32. package/dist/api/identity/register-new-user.js.map +1 -0
  33. package/dist/api/index.js +72 -0
  34. package/dist/api/index.js.map +1 -0
  35. package/dist/api/internal/abis.js +10 -0
  36. package/dist/api/internal/abis.js.map +1 -0
  37. package/dist/api/internal/addresses.js +8 -0
  38. package/dist/api/internal/addresses.js.map +1 -0
  39. package/dist/api/internal/events.js +10 -0
  40. package/dist/api/internal/events.js.map +1 -0
  41. package/dist/api/internal/index.js +5 -0
  42. package/dist/api/internal/index.js.map +1 -0
  43. package/dist/api/market/create-market.js +4 -0
  44. package/dist/api/market/create-market.js.map +1 -0
  45. package/dist/api/other/create-eth-crypto-creds.js +20 -0
  46. package/dist/api/other/create-eth-crypto-creds.js.map +1 -0
  47. package/dist/api/provider/decrypt.js +18 -0
  48. package/dist/api/provider/decrypt.js.map +1 -0
  49. package/dist/api/provider/encrypt.js +18 -0
  50. package/dist/api/provider/encrypt.js.map +1 -0
  51. package/dist/api/util/encrypt-by-public-key.js +52 -0
  52. package/dist/api/util/encrypt-by-public-key.js.map +1 -0
  53. package/dist/api/util/parse-cipher.js +11 -0
  54. package/dist/api/util/parse-cipher.js.map +1 -0
  55. package/dist/api/util/stringify-cipher.js +5 -0
  56. package/dist/api/util/stringify-cipher.js.map +1 -0
  57. package/dist/blockchain/abi.json +1626 -0
  58. package/dist/blockchain/addresses.json +17 -0
  59. package/dist/blockchain/blocks.json +3 -0
  60. package/dist/blockchain/bytecode.json +4 -0
  61. package/dist/constants/interface.js +1 -0
  62. package/dist/constants/interface.js.map +1 -0
  63. package/dist/constants/voting.js +1 -0
  64. package/dist/constants/voting.js.map +1 -0
  65. package/dist/constants.js +92 -0
  66. package/dist/constants.js.map +1 -0
  67. package/dist/events/OpportunityEventEmitter.js +32 -0
  68. package/dist/events/OpportunityEventEmitter.js.map +1 -0
  69. package/dist/events/get-log.js +1 -0
  70. package/dist/events/get-log.js.map +1 -0
  71. package/dist/events/start-event-listeners.js +9 -0
  72. package/dist/events/start-event-listeners.js.map +1 -0
  73. package/dist/events/sync-with-ethereum-node.js +20 -0
  74. package/dist/events/sync-with-ethereum-node.js.map +1 -0
  75. package/dist/gas.js +1 -0
  76. package/dist/gas.js.map +1 -0
  77. package/dist/logger.js +1 -0
  78. package/dist/logger.js.map +1 -0
  79. package/dist/modules/storage/OpportunityStorageProvider.js +94 -0
  80. package/dist/modules/storage/OpportunityStorageProvider.js.map +1 -0
  81. package/dist/sync/process/process-log.js +69 -0
  82. package/dist/sync/process/process-log.js.map +1 -0
  83. package/dist/sync/process/processDisputeCreated.js +33 -0
  84. package/dist/sync/process/processDisputeCreated.js.map +1 -0
  85. package/dist/sync/process/processMarketCreatedLog.js +33 -0
  86. package/dist/sync/process/processMarketCreatedLog.js.map +1 -0
  87. package/dist/sync/process/processMarketDestroyedEvent.js +10 -0
  88. package/dist/sync/process/processMarketDestroyedEvent.js.map +1 -0
  89. package/dist/sync/process/processUserAssignedTrueIdentification.js +21 -0
  90. package/dist/sync/process/processUserAssignedTrueIdentification.js.map +1 -0
  91. package/dist/sync/process/processUserRegistered.js +20 -0
  92. package/dist/sync/process/processUserRegistered.js.map +1 -0
  93. package/dist/sync/process/processUserSummaryCreated.js +22 -0
  94. package/dist/sync/process/processUserSummaryCreated.js.map +1 -0
  95. package/dist/sync/process/processWorkRelationshipCreated.js +38 -0
  96. package/dist/sync/process/processWorkRelationshipCreated.js.map +1 -0
  97. package/dist/sync/sync-jobs.js +35 -0
  98. package/dist/sync/sync-jobs.js.map +1 -0
  99. package/dist/sync/sync-markets.js +37 -0
  100. package/dist/sync/sync-markets.js.map +1 -0
  101. package/dist/types.js +2 -0
  102. package/dist/types.js.map +1 -0
  103. package/dist/util.js +1 -0
  104. package/dist/util.js.map +1 -0
  105. package/package.json +1 -1
  106. package/src/api/exchange/create-dispute.ts +0 -1
  107. package/src/api/identity/register-new-user.ts +5 -5
  108. package/src/sync/sync-markets.ts +1 -1
@@ -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()][Contracts.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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AC,MAAM,EAAE,mBAAmB,EAAE,UAAU,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;YACzK,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAA;YACzC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;SACrB;QAAC,OAAM,KAAK,EAAE;YACX,OAAO,CAAC,GAAG,CAAC,0CAA0C,GAAG,KAAK,CAAC,CAAC;SACnE;IACL,CAAC;CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA;AAErB;;;;;;;;;;;;;;;;;;EAkBE"}
@@ -0,0 +1,61 @@
1
+ function enterWorkRelationship(relationshipAddress, evaluationState, callback) {
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,6 @@
1
+ //return a work relationship task pointer
2
+ function inspectRelationship(taskPointer) {
3
+ return "";
4
+ }
5
+ export { inspectRelationship };
6
+ //# sourceMappingURL=inspect-relationship.js.map
@@ -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,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 { Contract } from 'ethers';
11
+ import opportunityService from '../../OpportunityService';
12
+ import { Contracts } from '../../constants';
13
+ import addressMap from '../../blockchain/addresses.json';
14
+ import abiMap from '../../blockchain/abi.json';
15
+ function registerNewUser() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ try {
18
+ const msgSender = yield opportunityService.getSignersInterface()._address;
19
+ console.log('Registering new user: ' + msgSender);
20
+ if (typeof msgSender == 'undefined')
21
+ throw new Error('Message sender is undefined');
22
+ const txResult = new Contract(addressMap[opportunityService.getEthNetwork()][Contracts.USER_REGISTRATION], abiMap[Contracts.USER_REGISTRATION]).connect(opportunityService.getSignersInterface())
23
+ .registerNewUser({
24
+ from: msgSender
25
+ });
26
+ }
27
+ catch (error) {
28
+ console.log(error);
29
+ }
30
+ });
31
+ }
32
+ export default registerNewUser;
33
+ //# 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,UAAU,MAAM,iCAAiC,CAAA;AACxD,OAAO,MAAM,MAAM,2BAA2B,CAAA;AAG9C,SAAe,eAAe;;QAC1B,IAAI;YACR,MAAM,SAAS,GAAG,MAAM,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,QAAQ,CAAA;YACzE,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAAA;YAEjD,IAAI,OAAO,SAAS,IAAI,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;YAEnF,MAAM,QAAQ,GAAG,IAAI,QAAQ,CACzB,UAAU,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAC3E,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAClC,CAAC,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC;iBAClD,eAAe,CAAC;gBACb,IAAI,EAAE,SAAS;aAClB,CAAC,CAAA;SACD;QAAC,OAAM,KAAK,EAAE;YACX,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;SACrB;IACL,CAAC;CAAA;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,72 @@
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, getContractAddress } from './internal/index';
10
+ import { sendAsync } from './ethereum/sendAsync';
11
+ import { parseCypher } from "./util/parse-cipher";
12
+ import { stringifyCypher } from "./util/stringify-cipher";
13
+ import { decryptByPrivateKey, encryptByPublicKey } from "./util/encrypt-by-public-key";
14
+ import { createEthCryptoCreds } from "./other/create-eth-crypto-creds";
15
+ import { encrypt } from "./provider/encrypt";
16
+ import { decrypt } from "./provider/decrypt";
17
+ import { connectGateways, getOracleClient } from "./dispute/connect";
18
+ import { checkVoteResults } from "./dispute/check-vote-results";
19
+ import { ensureEntityMetadata } from "./dispute/ensure-entity-metadata";
20
+ import { launchNewVote } from "./dispute/launch-new-vote";
21
+ import { submitVote } from "./dispute/submit-vote";
22
+ function generateAPI() {
23
+ return {
24
+ crypto: {
25
+ encryptByPublicKey,
26
+ decryptByPrivateKey,
27
+ createEthCryptoCreds
28
+ },
29
+ internal: {
30
+ abis: abis,
31
+ getContractAddress,
32
+ },
33
+ exchange: {
34
+ completeRelationship,
35
+ createTask,
36
+ enterWorkRelationship
37
+ },
38
+ dispute: {
39
+ connectGateways: connectGateways,
40
+ getOracleClient: getOracleClient,
41
+ checkVoteResults: checkVoteResults,
42
+ ensureEntityMetadata: ensureEntityMetadata,
43
+ launchNewVote: launchNewVote,
44
+ submitVote: submitVote
45
+ },
46
+ identity: {
47
+ registerNewUser
48
+ },
49
+ markets: {
50
+ createMarket,
51
+ },
52
+ network: {
53
+ sync: {
54
+ syncWithEthereum: syncWithEthereumNode,
55
+ syncMarkets,
56
+ syncJobs
57
+ }
58
+ },
59
+ provider: {
60
+ sendAsync,
61
+ encrypt,
62
+ decrypt
63
+ },
64
+ util: {
65
+ parseCypher,
66
+ stringifyCypher
67
+ }
68
+ };
69
+ }
70
+ const opportunityAPI = generateAPI();
71
+ export default opportunityAPI;
72
+ //# sourceMappingURL=index.js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,kBAAkB;YAClB,mBAAmB;YACnB,oBAAoB;SACvB;QACD,QAAQ,EAAE;YACN,IAAI,EAAE,IAAI;YACV,kBAAkB;SACrB;QACD,QAAQ,EAAE;YACN,oBAAoB;YACpB,UAAU;YACV,qBAAqB;SACxB;QACD,OAAO,EAAE;YACL,eAAe,EAAE,eAAe;YAChC,eAAe,EAAE,eAAe;YAChC,gBAAgB,EAAE,gBAAgB;YAClC,oBAAoB,EAAE,oBAAoB;YAC1C,aAAa,EAAE,aAAa;YAC5B,UAAU,EAAE,UAAU;SACzB;QACD,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;YACT,OAAO;YACP,OAAO;SACV;QACD,IAAI,EAAE;YACF,WAAW;YACX,eAAe;SAClB;KACJ,CAAA;AACL,CAAC;AAED,MAAM,cAAc,GAAG,WAAW,EAAE,CAAC;AAErC,eAAe,cAAc,CAAC"}
@@ -0,0 +1,10 @@
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
+ 'Participation': abiMap['Participation']
9
+ };
10
+ //# 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;IAC5B,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC;CAC3C,CAAA"}
@@ -0,0 +1,8 @@
1
+ import addressMap from '../../blockchain/addresses.json';
2
+ export default function getContractAddress(network, contractName) {
3
+ console.log(network);
4
+ console.log(contractName);
5
+ console.log(addressMap);
6
+ return addressMap[network][contractName];
7
+ }
8
+ //# sourceMappingURL=addresses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/api/internal/addresses.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,iCAAiC,CAAC;AAIzD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,OAAqB,EAAE,YAAuB;IACrF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACpB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACzB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACvB,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AAC5C,CAAC"}
@@ -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,5 @@
1
+ import abis from "./abis";
2
+ import getContractAddress from "./addresses";
3
+ import events from "./events";
4
+ export { abis, getContractAddress, events };
5
+ //# sourceMappingURL=index.js.map
@@ -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,kBAAkB,MAAM,aAAa,CAAC;AAC7C,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ function createMarket(newMarketData) {
2
+ }
3
+ export { createMarket };
4
+ //# sourceMappingURL=create-market.js.map
@@ -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,20 @@
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 EthCrypto from 'eth-crypto';
11
+ function createEthCryptoCreds(passphrase) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const entropy = Buffer.from(passphrase, 'utf-8');
14
+ const identity = EthCrypto.createIdentity(entropy);
15
+ const { address, publicKey, privateKey } = identity;
16
+ return identity;
17
+ });
18
+ }
19
+ export { createEthCryptoCreds };
20
+ //# sourceMappingURL=create-eth-crypto-creds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-eth-crypto-creds.js","sourceRoot":"","sources":["../../../src/api/other/create-eth-crypto-creds.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAKnC,SAAe,oBAAoB,CAAC,UAAU;;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAChD,MAAM,QAAQ,GAAG,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAElD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAA;QACnD,OAAO,QAAQ,CAAA;IACnB,CAAC;CAAA;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAA"}
@@ -0,0 +1,18 @@
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 decrypt(keystore, passphrase) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const web3 = opportunityService.getDefaultProviderInterface();
14
+ const data = yield web3.eth.accounts.decrypt(keystore, passphrase);
15
+ return data;
16
+ });
17
+ }
18
+ //# sourceMappingURL=decrypt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../../../src/api/provider/decrypt.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,kBAAkB,MAAM,0BAA0B,CAAA;AAEzD,MAAM,UAAgB,OAAO,CAAE,QAAQ,EAAE,UAAU;;QAC/C,MAAM,IAAI,GAAU,kBAAkB,CAAC,2BAA2B,EAAE,CAAA;QAEpE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAClE,OAAO,IAAI,CAAA;IACf,CAAC;CAAA"}
@@ -0,0 +1,18 @@
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 encrypt(privKey, password) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const web3 = opportunityService.getDefaultProviderInterface();
14
+ const keystore = yield web3.eth.accounts.encrypt(privKey, password);
15
+ return keystore;
16
+ });
17
+ }
18
+ //# sourceMappingURL=encrypt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../../src/api/provider/encrypt.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,kBAAkB,MAAM,0BAA0B,CAAA;AAEzD,MAAM,UAAgB,OAAO,CAAC,OAAO,EAAE,QAAQ;;QAC3C,MAAM,IAAI,GAAU,kBAAkB,CAAC,2BAA2B,EAAE,CAAA;QAEpE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpE,OAAO,QAAQ,CAAA;IACnB,CAAC;CAAA"}
@@ -0,0 +1,52 @@
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 EthCrypto from 'eth-crypto';
11
+ /**
12
+ *
13
+ * @param pubKey
14
+ * @param message
15
+ * @returns
16
+ */
17
+ function encryptByPublicKey(pubKey, message) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const encrypted = yield EthCrypto.encryptWithPublicKey(pubKey, // publicKey
20
+ message // message
21
+ );
22
+ return encrypted;
23
+ });
24
+ }
25
+ /*
26
+ {
27
+ iv: '02aeac54cb45283b427bd1a5028552c1',
28
+ ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',
29
+ ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',
30
+ mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'
31
+ } // encrypted-data
32
+ */
33
+ /**
34
+ *
35
+ * @param privKey
36
+ * @param encryptedData
37
+ */
38
+ function decryptByPrivateKey(privKey, encryptedData) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const { iv, ephemPublicKey, ciphertext, mac } = encryptedData;
41
+ const message = yield EthCrypto.decryptWithPrivateKey(privKey, // privateKey
42
+ {
43
+ iv,
44
+ ephemPublicKey,
45
+ ciphertext,
46
+ mac
47
+ } // encrypted-data
48
+ );
49
+ });
50
+ }
51
+ export { encryptByPublicKey, decryptByPrivateKey };
52
+ //# sourceMappingURL=encrypt-by-public-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt-by-public-key.js","sourceRoot":"","sources":["../../../src/api/util/encrypt-by-public-key.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,SAAe,kBAAkB,CAAC,MAAM,EAAE,OAAO;;QAC7C,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,oBAAoB,CAClD,MAAM,EAAE,YAAY;QACpB,OAAO,CAAA,UAAU;SACpB,CAAC;QAEF,OAAO,SAAS,CAAA;IACpB,CAAC;CAAA;AAED;;;;;;;EAOE;AAGF;;;;GAIG;AACH,SAAe,mBAAmB,CAAC,OAAO,EAAE,aAAa;;QACrD,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,aAAa,CAAA;QAC7D,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,qBAAqB,CACjD,OAAO,EAAE,aAAa;QACtB;YACI,EAAE;YACF,cAAc;YACd,UAAU;YACV,GAAG;SACN,CAAC,iBAAiB;SACtB,CAAC;IACN,CAAC;CAAA;AAGD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import EthCrypto from 'eth-crypto';
2
+ /* > {
3
+ iv: '02aeac54cb45283b427bd1a5028552c1',
4
+ ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',
5
+ ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',
6
+ mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'
7
+ } */
8
+ export function parseCypher(str) {
9
+ return EthCrypto.cipher.parse(str);
10
+ }
11
+ //# sourceMappingURL=parse-cipher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-cipher.js","sourceRoot":"","sources":["../../../src/api/util/parse-cipher.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC;;;;;QAKQ;AACR,MAAM,UAAU,WAAW,CAAC,GAAG;IAC3B,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import EthCrypto from 'eth-crypto';
2
+ export function stringifyCypher(cipher) {
3
+ return EthCrypto.cipher.stringify(cipher);
4
+ }
5
+ //# sourceMappingURL=stringify-cipher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-cipher.js","sourceRoot":"","sources":["../../../src/api/util/stringify-cipher.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,MAAM,UAAU,eAAe,CAAC,MAAM;IAClC,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC"}