opportunity-service 0.0.536 → 0.0.542

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/dist/OpportunityService.js +16 -20
  2. package/dist/OpportunityService.js.map +1 -1
  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/{voting/connect.js → dispute/util/wait-until-started.js} +11 -21
  16. package/dist/api/dispute/util/wait-until-started.js.map +1 -0
  17. package/dist/api/exchange/create-dispute.js +1 -2
  18. package/dist/api/exchange/create-dispute.js.map +1 -1
  19. package/dist/api/exchange/create-task.js +1 -1
  20. package/dist/api/exchange/create-task.js.map +1 -1
  21. package/dist/api/identity/register-new-user.js +1 -1
  22. package/dist/api/identity/register-new-user.js.map +1 -1
  23. package/dist/api/index.js +31 -12
  24. package/dist/api/index.js.map +1 -1
  25. package/dist/api/internal/abis.js +2 -1
  26. package/dist/api/internal/abis.js.map +1 -1
  27. package/dist/api/internal/addresses.js +21 -4
  28. package/dist/api/internal/addresses.js.map +1 -1
  29. package/dist/api/other/create-eth-crypto-creds.js +20 -0
  30. package/dist/api/other/create-eth-crypto-creds.js.map +1 -0
  31. package/dist/api/provider/decrypt.js +18 -0
  32. package/dist/api/provider/decrypt.js.map +1 -0
  33. package/dist/api/provider/encrypt.js +18 -0
  34. package/dist/api/provider/encrypt.js.map +1 -0
  35. package/dist/api/util/encrypt-by-public-key.js +52 -0
  36. package/dist/api/util/encrypt-by-public-key.js.map +1 -0
  37. package/dist/api/util/parse-cipher.js +11 -0
  38. package/dist/api/util/parse-cipher.js.map +1 -0
  39. package/dist/api/util/stringify-cipher.js +5 -0
  40. package/dist/api/util/stringify-cipher.js.map +1 -0
  41. package/dist/blockchain/abi.json +779 -1
  42. package/dist/blockchain/addresses.json +15 -5
  43. package/dist/blockchain/bytecode.json +2 -2
  44. package/dist/constants.js +0 -1
  45. package/dist/constants.js.map +1 -1
  46. package/dist/modules/storage/OpportunityStorageProvider.js +71 -41
  47. package/dist/modules/storage/OpportunityStorageProvider.js.map +1 -1
  48. package/dist/sync/sync-jobs.js +17 -15
  49. package/dist/sync/sync-jobs.js.map +1 -1
  50. package/dist/sync/sync-markets.js +17 -15
  51. package/dist/sync/sync-markets.js.map +1 -1
  52. package/package.json +13 -2
  53. package/src/OpportunityService.ts +22 -24
  54. package/src/api/dispute/check-vote-results.ts +30 -0
  55. package/src/api/dispute/connect.ts +36 -0
  56. package/src/api/dispute/ensure-entity-metadata.ts +34 -0
  57. package/src/api/dispute/launch-new-vote.ts +116 -0
  58. package/src/api/dispute/submit-vote.ts +59 -0
  59. package/src/api/dispute/util/wait-until-present.ts +19 -0
  60. package/src/api/dispute/util/wait-until-started.ts +14 -0
  61. package/src/api/exchange/create-dispute.ts +1 -1
  62. package/src/api/exchange/create-task.ts +1 -1
  63. package/src/api/identity/register-new-user.ts +1 -1
  64. package/src/api/index.ts +31 -12
  65. package/src/api/internal/abis.ts +2 -1
  66. package/src/api/internal/addresses.ts +21 -4
  67. package/src/api/other/create-eth-crypto-creds.ts +14 -0
  68. package/src/api/provider/decrypt.ts +9 -0
  69. package/src/api/provider/encrypt.ts +9 -0
  70. package/src/api/util/encrypt-by-public-key.ts +47 -0
  71. package/src/api/util/parse-cipher.ts +11 -0
  72. package/src/api/util/stringify-cipher.ts +5 -0
  73. package/src/blockchain/abi.json +779 -1
  74. package/src/blockchain/addresses.json +17 -5
  75. package/src/blockchain/bytecode.json +2 -2
  76. package/src/constants.ts +0 -1
  77. package/src/modules/storage/OpportunityStorageProvider.ts +80 -23
  78. package/src/sync/sync-jobs.ts +2 -0
  79. package/src/sync/sync-markets.ts +3 -1
  80. package/src/types.ts +21 -1
  81. package/dist/api/voting/census.js +0 -38
  82. package/dist/api/voting/census.js.map +0 -1
  83. package/dist/api/voting/connect.js.map +0 -1
  84. package/dist/api/voting/entity.js +0 -39
  85. package/dist/api/voting/entity.js.map +0 -1
  86. package/dist/api/voting/process.js +0 -101
  87. package/dist/api/voting/process.js.map +0 -1
  88. package/src/api/voting/census.ts +0 -39
  89. package/src/api/voting/connect.ts +0 -34
  90. package/src/api/voting/entity.ts +0 -33
  91. package/src/api/voting/process.ts +0 -119
@@ -1,9 +1,21 @@
1
1
  {
2
- "MarketFactory": "0x8eb065482F681537e90eab826540E9DF8D8cBd89",
3
- "UserRegistration": "0xc4F1B570e57A5035a25035AFA5f7CbA204627024",
4
- "UserSummaryFactory": "",
5
- "Dai": "0x6b175474e89094c44da98b954eedeac495271d0f",
6
- "Scheduler": "0x"
2
+ "rinkeby": {
3
+ "MarketFactory": "0x72141925d0Cd8bC72Bea3A555976335341B1e7BF",
4
+ "UserRegistration": "0xb2359b2B2F4795b9AEd240d0e9606897BfEBB348",
5
+ "UserSummaryFactory": "0x95bFe6b12b89EBb87D6f2B854f2055Fc867Dbd50",
6
+ "Dai": "0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea",
7
+ "Participation": "0xE4c3a2698e5e4F8BE58481eB923ADA73982BD94d"
8
+ },
9
+ "mainnet": {
10
+ "MarketFactory": "0x8eb065482F681537e90eab826540E9DF8D8cBd89",
11
+ "UserRegistration": "0xc4F1B570e57A5035a25035AFA5f7CbA204627024",
12
+ "UserSummaryFactory": "",
13
+ "Dai": "0x6b175474e89094c44da98b954eedeac495271d0f",
14
+ "Tip": "0x"
15
+ },
16
+ "xdai": {
17
+
18
+ }
7
19
  }
8
20
 
9
21
 
@@ -1,4 +1,4 @@
1
1
  {
2
- "WorkRelationship": "",
3
- "Scheduler": ""
2
+ "Dispute": "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80638e93d1d511610097578063d8025a8011610066578063d8025a801461027b578063eeabb1251461028e578063fc0e3d90146102a1578063ffe1ee9d146102a957600080fd5b80638e93d1d51461019e57806391b0d39a1461023a578063a3bef4d714610243578063a6430cc01461025057600080fd5b80633a4b66f1116100d35780633a4b66f11461015c5780634a60e34f1461016557806377e8fd9c1461016f5780637e291d851461017757600080fd5b80630b97bc86146100fa578063146ca531146101345780631712546614610153575b600080fd5b6101217f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6003546101419060ff1681565b60405160ff909116815260200161012b565b61012160065481565b61012160025481565b61016d6102d0565b005b61016d61037e565b6101217f000000000000000000000000000000000000000000000000000000000000000081565b6101f76101ac366004610bfc565b6000602081905290815260409020805460018201546002909201546001600160a01b03909116919067ffffffffffffffff81169060ff600160401b8204811691600160481b90041685565b604080516001600160a01b039096168652602086019490945267ffffffffffffffff9092169284019290925290151560608301521515608082015260a00161012b565b61012160045481565b6005546101419060ff1681565b61026361025e366004610d24565b6103b7565b6040516001600160a01b03909116815260200161012b565b610121610289366004610cee565b6103e1565b61016d61029c366004610c3d565b610890565b61016d610b1d565b6101217f000000000000000000000000000000000000000000000000000000000000000081565b6004546102e09062093a80610e06565b600454141561037c5761037c600880546102f990610e43565b80601f016020809104026020016040519081016040528092919081815260200182805461032590610e43565b80156103725780601f1061034757610100808354040283529160200191610372565b820191906000526020600020905b81548152906001019060200180831161035557829003601f168201915b5050505050610b36565b565b60095460009060ff16600381111561039857610398610e8e565b8160038111156103aa576103aa610e8e565b146103b457600080fd5b50565b600181815481106103c757600080fd5b6000918252602090912001546001600160a01b0316905081565b600954600090819060ff1660038111156103fd576103fd610e8e565b81600381111561040f5761040f610e8e565b1461041957600080fd5b60015460051161042857600080fd5b60075460408051632fe4c87f60e21b815290516001600160a01b0390921691600091839163bf9321fc9160048082019260209290919082900301818787803b15801561047357600080fd5b505af1158015610487573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ab9190610c20565b9050806001600160a01b0316638fcbaf0c836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156104f557600080fd5b505afa158015610509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052d9190610c20565b30893560208b0135600161054760608e0160408f01610d3d565b8d606001358e608001356040518963ffffffff1660e01b8152600401610574989796959493929190610d60565b600060405180830381600087803b15801561058e57600080fd5b505af11580156105a2573d6000803e3d6000fd5b50505050806001600160a01b031663f2d5d56b836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105ee57600080fd5b505afa158015610602573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106269190610c20565b6002546040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561066f57600080fd5b505af1158015610683573d6000803e3d6000fd5b50505050806001600160a01b0316638fcbaf0c836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156106cf57600080fd5b505afa1580156106e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107079190610c20565b306107148a356001610e06565b60208a0135600061072b60608d0160408e01610d3d565b8c606001358d608001356040518963ffffffff1660e01b8152600401610758989796959493929190610d60565b600060405180830381600087803b15801561077257600080fd5b505af1158015610786573d6000803e3d6000fd5b5050505061087e336040805160a0810182526000808252602080830182815283850183815260608501848152608086018581526001600160a01b03988916808752948690529685209551865498166001600160a01b03199889161786559151600186810191909155905160029095018054925196511515600160481b0269ff00000000000000000019971515600160401b0268ffffffffffffffffff1990941667ffffffffffffffff9790971696909617929092179590951693909317909255825480840184559290527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf69091018054909216179055565b610886610bc5565b5050505092915050565b60095460019060ff1660038111156108aa576108aa610e8e565b8160038111156108bc576108bc610e8e565b146108c657600080fd5b60035460ff166001141561096f57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146109625760405162461bcd60e51b815260206004820152602860248201527f54686520616767726573736f72206d757374207375626d6974207468652070726044820152671bd8d95cdcc81a5960c21b60648201526084015b60405180910390fd5b61096b82610b36565b5050565b60045461097f9062093a80610e06565b4210610989575050565b60075460408051638da5cb5b60e01b815290516001600160a01b03909216918291638da5cb5b916004808301926020929190829003018186803b1580156109cf57600080fd5b505afa1580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a079190610c20565b6001600160a01b0316336001600160a01b03161480610aa75750806001600160a01b0316634d547ada6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a5a57600080fd5b505afa158015610a6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a929190610c20565b6001600160a01b0316336001600160a01b0316145b610b0f5760405162461bcd60e51b815260206004820152603360248201527f5468652070726f63657373206964206d75737420636f6d652066726f6d206f6e604482015272329037b3103a3432903234b9b83aba32b9399760691b6064820152608401610959565b610b1883610b36565b505050565b60095460039060ff168181111561039857610398610e8e565b6009805460ff1916905560405130907f46fc1bd3ab8e7cd05a86c7dcc134023832df6d2dc518df189e63b27c386673ad90600090a2600354610b7c9060ff166001610e1e565b60ff16306001600160a01b03167f21f2e1db10f4df2a0f1fc876844286ccb4dde456aeaf56b34084fe757c10192f8342604051610bba929190610da9565b60405180910390a350565b60015460009060051415610be1576009805460ff191660021790555b90565b600060a08284031215610bf657600080fd5b50919050565b600060208284031215610c0e57600080fd5b8135610c1981610eba565b9392505050565b600060208284031215610c3257600080fd5b8151610c1981610eba565b600060208284031215610c4f57600080fd5b813567ffffffffffffffff80821115610c6757600080fd5b818401915084601f830112610c7b57600080fd5b813581811115610c8d57610c8d610ea4565b604051601f8201601f19908116603f01168101908382118183101715610cb557610cb5610ea4565b81604052828152876020848701011115610cce57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806101408385031215610d0257600080fd5b610d0c8484610be4565b9150610d1b8460a08501610be4565b90509250929050565b600060208284031215610d3657600080fd5b5035919050565b600060208284031215610d4f57600080fd5b813560ff81168114610c1957600080fd5b6001600160a01b039889168152969097166020870152604086019490945260608501929092521515608084015260ff1660a083015260c082015260e08101919091526101000190565b604081526000835180604084015260005b81811015610dd75760208187018101516060868401015201610dba565b81811115610de9576000606083860101525b50602083019390935250601f91909101601f191601606001919050565b60008219821115610e1957610e19610e78565b500190565b600060ff821660ff84168060ff03821115610e3b57610e3b610e78565b019392505050565b600181811c90821680610e5757607f821691505b60208210811415610bf657634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146103b457600080fdfea2646970667358221220e36760deb035eff2130e8ab72946509dd52d437feb2fb887714059c90eaa82e764736f6c63430008070033",
3
+ "WorkRelationship": "0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80637f755043116100de578063bfce14ea11610097578063ec3a479011610071578063ec3a4790146103c5578063ed8454fb146103d8578063f240f7c3146103eb578063f2a09497146103fe57600080fd5b8063bfce14ea14610363578063c6ee20d21461038a578063cb2ef6f7146103a457600080fd5b80637f755043146102e257806385209ee0146102f55780638da5cb5b146103075780639240a1001461031a57806396118e4414610334578063bf9321fc1461035b57600080fd5b80634d547ada1161014b57806353318a871161012557806353318a871461029b5780635db28c66146102ae57806363c852c9146102b65780637df38c5b146102d957600080fd5b80634d547ada146102365780634e12aa961461026157806350365be91461028857600080fd5b80630b73a87f14610193578063188bbbf3146101a85780631ed4b49e146101d157806331613fdb146101e657806339987e52146101ee5780633c86f6f314610201575b600080fd5b6101a66101a13660046117bf565b610406565b005b6007546101bb9062010000900460ff1681565b6040516101c89190611b80565b60405180910390f35b6101d96104ef565b6040516101c89190611bbb565b6101a661057d565b6101a66101fc366004611a99565b6106a4565b6102287ffa5e0016fb62b8dffda8fd95249d438edcffd3689b40ac3b4281d4cf710609ae81565b6040519081526020016101c8565b600054610249906001600160a01b031681565b6040516001600160a01b0390911681526020016101c8565b6102287fc35792dec8ea736e1a3478771b1f14a7472fd98ca01a9c9077ac63917f87f64981565b6101a6610296366004611961565b6107d5565b6101a66102a93660046119a7565b6108fe565b610228610a2c565b6102c96102c43660046118a9565b610a8a565b60405190151581526020016101c8565b61022860025481565b6101a66102f03660046117e3565b610b33565b6007546101bb90610100900460ff1681565b600154610249906001600160a01b031681565b610322600681565b60405160ff90911681526020016101c8565b6102287f62b607caa4d4e7fcbd31bf4c033cd30888b536567fadc83710fdf15f8d5cfc9e81565b610249610deb565b6102287f000000000000000000000000000000000000000000000000000000000000000081565b6007546103979060ff1681565b6040516101c89190611b93565b6007546103b8906301000000900460ff1681565b6040516101c89190611ba7565b6101a66103d33660046119cf565b610e56565b6101a66103e6366004611874565b610ed0565b600454610249906001600160a01b031681565b610322600481565b600754339060ff16600581111561041f5761041f611ec6565b600514801561043b57506004546001600160a01b038281169116145b6104605760405162461bcd60e51b815260040161045790611dd0565b60405180910390fd5b60035460025460405163a9059cbb60e01b81526001600160a01b038581166004830152602482019290925291169063a9059cbb906044015b602060405180830381600087803b1580156104b257600080fd5b505af11580156104c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ea9190611944565b505050565b600580546104fc90611e75565b80601f016020809104026020016040519081016040528092919081815260200182805461052890611e75565b80156105755780601f1061054a57610100808354040283529160200191610575565b820191906000526020600020905b81548152906001019060200180831161055857829003601f168201915b505050505081565b600754339060ff16600581111561059657610596611ec6565b60051480156105b257506004546001600160a01b038281169116145b6105ce5760405162461bcd60e51b815260040161045790611dd0565b6000600280546105de9190611e53565b60035460015460405163a9059cbb60e01b81526001600160a01b03918216600482015260248101849052929350169063a9059cbb90604401602060405180830381600087803b15801561063057600080fd5b505af1158015610644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106689190611944565b5060035460005460405163a9059cbb60e01b81526001600160a01b0391821660048201526024810184905291169063a9059cbb90604401610498565b6001546001600160a01b031633146106ce5760405162461bcd60e51b815260040161045790611c10565b60038060075460ff1660058111156106e8576106e8611ec6565b146107055760405162461bcd60e51b815260040161045790611c93565b604080517ffa5e0016fb62b8dffda8fd95249d438edcffd3689b40ac3b4281d4cf710609ae602080830191909152871580158385015283518084038501815260608401855280519083012061190160f01b60808501527f0000000000000000000000000000000000000000000000000000000000000000608285015260a2808501919091528451808503909101815260c29093019093528151910120906107b5576107b08789610f1a565b6107cb565b600780546002919060ff19166001835b02179055505b5050505050505050565b6000546001600160a01b031633146107ff5760405162461bcd60e51b815260040161045790611c63565b600180600754610100900460ff16600281111561081e5761081e611ec6565b1461083b5760405162461bcd60e51b815260040161045790611d67565b60018060075460ff16600581111561085557610855611ec6565b146108725760405162461bcd60e51b815260040161045790611c93565b60018060075462010000900460ff16600281111561089257610892611ec6565b146108af5760405162461bcd60e51b815260040161045790611cfd565b600187151514156108d0576007805462ff00ff1916620200021790556108f5565b600080546001600160a01b03191690556108e8610f76565b6007805462ff00ff191690555b50505050505050565b6000546001600160a01b031633146109285760405162461bcd60e51b815260040161045790611c63565b60028060075460ff16600581111561094257610942611ec6565b1461095f5760405162461bcd60e51b815260040161045790611c93565b604080517f62b607caa4d4e7fcbd31bf4c033cd30888b536567fadc83710fdf15f8d5cfc9e60208083019190915281830188905282518083038401815260608301845280519082012061190160f01b60808401527f0000000000000000000000000000000000000000000000000000000000000000608284015260a2808401919091528351808403909101815260c290920190925280519101206000546001600160a01b0316610a0e57600080fd5b610a1786600655565b50506007805460ff1916600317905550505050565b6001546000906001600160a01b03163314610a595760405162461bcd60e51b815260040161045790611c10565b6000546001600160a01b03163314610a835760405162461bcd60e51b815260040161045790611c63565b5060065490565b6040805160016232dea960e11b0319815283516001600160a01b03908116600483015260208501516024830152918401516044820152828216606482015260009182919086169063ff9a42ae9060840160206040518083038186803b158015610af257600080fd5b505afa158015610b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2a9190611944565b95945050505050565b6001546001600160a01b03163314610b5d5760405162461bcd60e51b815260040161045790611c10565b600080600754610100900460ff166002811115610b7c57610b7c611ec6565b14610b995760405162461bcd60e51b815260040161045790611d67565b60008060075460ff166005811115610bb357610bb3611ec6565b14610bd05760405162461bcd60e51b815260040161045790611c93565b6001600160a01b038c16610c4c5760405162461bcd60e51b815260206004820152603760248201527f576f726b65722061646472657373206d757374206e6f7420626520302077686560448201527f6e2061737369676e696e67206e657720776f726b65722e0000000000000000006064820152608401610457565b8a610c995760405162461bcd60e51b815260206004820181905260248201527f44616920616d6f756e742063616e6e6f7420626520657175616c20746f20302e6044820152606401610457565b6003546001546040516370a0823160e01b81526001600160a01b03918216600482015260009291909116906370a082319060240160206040518083038186803b158015610ce557600080fd5b505afa158015610cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1d9190611a80565b90508b811015610d2c57600080fd5b610d3c8b8b8b8b8b8b8b8b6110b8565b60028c9055600080546001600160a01b038f166001600160a01b031991821617909155600480549091169055600780546001919062ff0000191662010000830217905550600780546001919060ff1916828002179055506000546001600160a01b038e8116911614610db057610db0611eb0565b600160075462010000900460ff166002811115610dcf57610dcf611ec6565b14610ddc57610ddc611eb0565b50505050505050505050505050565b6003546000906001600160a01b0316610e465760405162461bcd60e51b815260206004820152601a60248201527f52657761726420616464726573732063616e6e6f7420626520300000000000006044820152606401610457565b506003546001600160a01b031690565b6001546001600160a01b03163314610e805760405162461bcd60e51b815260040161045790611c10565b60008060075462010000900460ff166002811115610ea057610ea0611ec6565b14610ebd5760405162461bcd60e51b815260040161045790611cfd565b81516104ea906005906020850190611726565b60028060075460ff166005811115610eea57610eea611ec6565b14610f075760405162461bcd60e51b815260040161045790611c93565b50506007805460ff191660051790555050565b6001546001600160a01b03163314610f445760405162461bcd60e51b815260040161045790611c10565b6000546001600160a01b0316610f5957600080fd5b610f638282611235565b50506007805461ffff1916610204179055565b6000546001600160a01b03163314610fa05760405162461bcd60e51b815260040161045790611c63565b60018060075462010000900460ff166002811115610fc057610fc0611ec6565b14610fdd5760405162461bcd60e51b815260040161045790611cfd565b60018060075460ff166005811115610ff757610ff7611ec6565b146110145760405162461bcd60e51b815260040161045790611c93565b6002546110795760405162461bcd60e51b815260206004820152602d60248201527f5468657265206973206e6f2044414920746f207472616e73666572206261636b60448201526c103a37903a34329037bbb732b960991b6064820152608401610457565b60035460015460025460405163a9059cbb60e01b81526001600160a01b039283166004820152602481019190915291169063a9059cbb90604401610498565b600354600180546040516323f2ebc360e21b81526001600160a01b0393841693638fcbaf0c936110fb939091169130918e918e91908e908e908e90600401611b1b565b600060405180830381600087803b15801561111557600080fd5b505af1158015611129573d6000803e3d6000fd5b505060035460015460025460405163f2d5d56b60e01b81526001600160a01b03928316600482015260248101919091529116925063f2d5d56b9150604401600060405180830381600087803b15801561118157600080fd5b505af1158015611195573d6000803e3d6000fd5b5050600354600180546001600160a01b039283169450638fcbaf0c93509091169030906111c3908d90611e2d565b8b60008989896040518963ffffffff1660e01b81526004016111ec989796959493929190611b1b565b600060405180830381600087803b15801561120657600080fd5b505af115801561121a573d6000803e3d6000fd5b5050600780546001935090915061ff001916610100836107c5565b60035460005460025460405163a9059cbb60e01b81526001600160a01b039283166004820152602481019190915291169063a9059cbb90604401602060405180830381600087803b15801561128957600080fd5b505af115801561129d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c19190611944565b50600154600080546001600160a01b03928316921690600660ff86161115611349576040516376267fd760e11b81526001600160a01b0383169063ec4cffae90611312903090600190600401611b64565b600060405180830381600087803b15801561132c57600080fd5b505af1158015611340573d6000803e3d6000fd5b505050506116c6565b600660ff86161115806113605750600460ff861610155b1561136a576116c6565b600460ff86161180159061138b5750611384846001611e2d565b8160ff1610155b15611649576000826001600160a01b031663c897d6956040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156113cd57600080fd5b505af11580156113e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114059190611afe565b905060018160ff161161147857604051630668e3b760e41b81526001600160a01b0384169063668e3b7090611441903090600190600401611b64565b600060405180830381600087803b15801561145b57600080fd5b505af115801561146f573d6000803e3d6000fd5b50505050611643565b8060ff16600214156114ed57604051630668e3b760e41b81526000906001600160a01b0385169063668e3b70906114b59030908590600401611b64565b600060405180830381600087803b1580156114cf57600080fd5b505af11580156114e3573d6000803e3d6000fd5b5050505050611643565b8060ff166003141561158757604051630668e3b760e41b81526001600160a01b0384169063668e3b7090611528903090600090600401611b64565b600060405180830381600087803b15801561154257600080fd5b505af1158015611556573d6000803e3d6000fd5b50506040516332053e6960e01b8152600060048201526001600160a01b03861692506332053e699150602401611441565b6040516332053e6960e01b8152600160048201526001600160a01b038416906332053e6990602401600060405180830381600087803b1580156115c957600080fd5b505af11580156115dd573d6000803e3d6000fd5b5050604051630668e3b760e41b81526001600160a01b038616925063668e3b709150611610903090600190600401611b64565b600060405180830381600087803b15801561162a57600080fd5b505af115801561163e573d6000803e3d6000fd5b505050505b506116c6565b600460ff86161180159061165f5750838160ff16105b156116c657604051630668e3b760e41b81526001600160a01b0383169063668e3b7090611693903090600190600401611b64565b600060405180830381600087803b1580156116ad57600080fd5b505af11580156116c1573d6000803e3d6000fd5b505050505b604051633336dad960e21b81523060048201526001600160a01b0384169063ccdb6b6490602401600060405180830381600087803b15801561170757600080fd5b505af115801561171b573d6000803e3d6000fd5b505050505050505050565b82805461173290611e75565b90600052602060002090601f016020900481019282611754576000855561179a565b82601f1061176d57805160ff191683800117855561179a565b8280016001018555821561179a579182015b8281111561179a57825182559160200191906001019061177f565b506117a69291506117aa565b5090565b5b808211156117a657600081556001016117ab565b6000602082840312156117d157600080fd5b81356117dc81611f05565b9392505050565b6000806000806000806000806000806101408b8d03121561180357600080fd5b8a3561180e81611f05565b995060208b0135985060408b0135975060608b0135965060808b013561183381611f28565b955060a08b0135945060c08b0135935060e08b013561185181611f28565b809350506101008b013591506101208b013590509295989b9194979a5092959850565b60008060006060848603121561188957600080fd5b833561189481611f05565b95602085013595506040909401359392505050565b600080600083850360a08112156118bf57600080fd5b84356118ca81611f05565b93506060601f19820112156118de57600080fd5b506040516060810181811067ffffffffffffffff8211171561190257611902611edc565b604052602085013561191381611f05565b815260408581013560208301526060860135908201529150608084013561193981611f05565b809150509250925092565b60006020828403121561195657600080fd5b81516117dc81611f1a565b6000806000806080858703121561197757600080fd5b843561198281611f1a565b9350602085013561199281611f28565b93969395505050506040820135916060013590565b600080600080608085870312156119bd57600080fd5b84359350602085013561199281611f28565b6000602082840312156119e157600080fd5b813567ffffffffffffffff808211156119f957600080fd5b818401915084601f830112611a0d57600080fd5b813581811115611a1f57611a1f611edc565b604051601f8201601f19908116603f01168101908382118183101715611a4757611a47611edc565b81604052828152876020848701011115611a6057600080fd5b826020860160208301376000928101602001929092525095945050505050565b600060208284031215611a9257600080fd5b5051919050565b60008060008060008060c08789031215611ab257600080fd5b863595506020870135611ac481611f28565b94506040870135611ad481611f1a565b93506060870135611ae481611f28565b9598949750929560808101359460a0909101359350915050565b600060208284031215611b1057600080fd5b81516117dc81611f28565b6001600160a01b039889168152969097166020870152604086019490945260608501929092521515608084015260ff1660a083015260c082015260e08101919091526101000190565b6001600160a01b0392909216825260ff16602082015260400190565b60208101611b8d83611ef2565b91905290565b6020810160068310611b8d57611b8d611ec6565b6020810160028310611b8d57611b8d611ec6565b600060208083528351808285015260005b81811015611be857858101830151858201604001528201611bcc565b81811115611bfa576000604083870101525b50601f01601f1916929092016040019392505050565b60208082526033908201527f576f726b52656c6174696f6e736869703a206f6e6c794f776e65722063616e2060408201527231b0b636103a3434b990333ab731ba34b7b71760691b606082015260800190565b602080825260169082015275576f726b52656c6174696f6e736869703a206f6e6c7960501b604082015260600190565b60208082526044908201527f5468697320616374696f6e2063616e6e6f742062652063617272696564206f7560408201527f7420756e646572207468652063757272656e7420636f6e7472616374207374616060820152633a3ab99760e11b608082015260a00190565b60208082526044908201527f43616e6e6f7420696e766f6b65207468697320657363726f772066756e63746960408201527f6f6e2077697468207468652063757272656e7420636f6e7472616374207374616060820152633a3ab99760e11b608082015260a00190565b60208082526043908201527f43616e6e6f7420696e766f6b65207468697320657363726f772066756e63746960408201527f6f6e2077697468207468652063757272656e7420636f6e7472616374207374616060820152623a329760e91b608082015260a00190565b60208082526037908201527f54686520636f6e74726163742063616e6e6f74206265207265736f6c7665642060408201527f756e64657220746865736520636f6e646974696f6e732e000000000000000000606082015260800190565b60008219821115611e4e57634e487b7160e01b600052601160045260246000fd5b500190565b600082611e7057634e487b7160e01b600052601260045260246000fd5b500490565b600181811c90821680611e8957607f821691505b60208210811415611eaa57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b60038110611f0257611f02611ec6565b50565b6001600160a01b0381168114611f0257600080fd5b8015158114611f0257600080fd5b60ff81168114611f0257600080fdfea264697066735822122027624e7f435ac760348d3a66c1ed21ccd7fdfb4824992c920caddc2c2483c8b764736f6c63430008070033"
4
4
  }
package/src/constants.ts CHANGED
@@ -18,7 +18,6 @@ export enum Contracts {
18
18
  MARKET='Market',
19
19
  MARKET_FACTORY='MarketFactory',
20
20
  USER_REGISTRATION='UserRegistration',
21
- SCHEDULER='Scheduler'
22
21
  }
23
22
 
24
23
  export const enum WorkRelationshipState {
@@ -1,40 +1,97 @@
1
- import ipfsClient from 'ipfs-http-client';
1
+ import OrbitDB from 'orbit-db'
2
+ import IPFS from 'ipfs'
3
+
4
+ import {
5
+ DisputeDoc,
6
+ WorkRelationshipDoc,
7
+ UserSummaryDoc
8
+ } from '../../types'
9
+
10
+ const operations = ['>', '<', '==', '>=', '<=']
2
11
 
3
12
 
4
13
  class OpportunityStorageProvider {
5
- private ipfsProvider = null;
14
+ private db: any
6
15
 
7
- constructor() {
8
- this.ipfsProvider = ipfsClient({ url: 'https://ipfs.infura.io', protocol: 'https', port: 5001, apiPath: '/ipfs/api/v0' })
16
+ constructor(address: string) {
17
+ this.initIPFSInstance()
18
+ this.listen(address)
9
19
  }
10
20
 
11
- async storeContent(content: any): Promise<string> {
12
- const { cid } = await this.ipfsProvider.add(content)
13
- console.log(`OpportunityStorageProvider: Upload content with CID (${cid})`);
14
- return cid;
15
- }
21
+ // Create IPFS instance
22
+ initIPFSInstance = async () => {
23
+ return await IPFS.create({ repo: "/opportunity/ipfs" });
24
+ };
16
25
 
17
- async storeRawContent(content : any) {
18
- const parsedContent = JSON.stringify(content);
19
- const cid = await this.ipfsProvider.add(parsedContent);
20
- console.log('Storage Provider: ' + 'Storing raw content with cid: ' + cid);
26
+ listen(address = '') {
27
+ this.initIPFSInstance().then(async ipfs => {
28
+ const orbitdb = await OrbitDB.createInstance(ipfs);
29
+
30
+ // Create / Open a database
31
+ if (address == '') {
32
+ this.db = await orbitdb.docs('opportunity.database.default');
33
+ console.log(this.db.address)
34
+ } else {
35
+ this.db = await orbitdb.docs(address);
36
+ this.db.load();
37
+ }
38
+
39
+ // Listen for updates from peers
40
+ this.db.events.on("replicated", address => {
41
+ console.log(this.db.iterator({ limit: -1 }).collect());
42
+ });
43
+
44
+ // Add an entry
45
+ const hash = await this.db.add("world");
46
+ console.log(hash);
47
+
48
+ // Query
49
+ const result = this.db.iterator({ limit: -1 }).collect();
50
+ console.log(JSON.stringify(result, null, 2));
51
+ });
21
52
  }
22
53
 
23
- async retrieveContent(cid: string): Promise<AsyncIterable<Object>> | Promise<number> {
24
- const file = this.ipfsProvider.get(cid);
25
- console.log(file.type, file.path)
26
54
 
27
- if (!file.content) return -1;
55
+ /**
56
+ * Returns a Promise that resolves to the multihash of the entry as a String.
57
+ * @param doc
58
+ * @returns
59
+ */
60
+ async store(doc: DisputeDoc | WorkRelationshipDoc | UserSummaryDoc): Promise<string> {
61
+ try {
62
+ const hash = await this.db.put(doc).then(hash => {
63
+ return hash;
64
+ })
28
65
 
29
- const content = []
66
+ return hash;
67
+ } catch(error) {
68
+ console.log(error)
69
+ return ''
70
+ }
71
+ }
30
72
 
31
- for await (const chunk of file.content) {
32
- content.push(chunk)
73
+ /**
74
+ * Returns an Array of all Objects that match the given key in their _id field or the field specified by indexBy. If no document with
75
+ * that key exists, this returns an empty array.
76
+ * @param key
77
+ */
78
+ async retrieveDoc(key: string = '', collection: string): Promise<DisputeDoc> | Promise<WorkRelationshipDoc> | Promise<UserSummaryDoc> {
79
+ try {
80
+ const docs = await this.db.get(key)
81
+ return docs
82
+ } catch(error) {
83
+ console.log(error)
84
+ return []
33
85
  }
86
+ }
87
+
88
+ async retrieveDocsByCollection(collection: string) {
89
+ return await this.db.query((doc) => doc[collection] == collection)
90
+ }
34
91
 
35
- console.log('Returning content from storage provider: ' + content);
92
+ async deleteDoc(key: string) {
93
+ const hash = await this.db.del(key)
36
94
  }
37
95
  }
38
96
 
39
- const opportunityStorageProvider: OpportunityStorageProvider = new OpportunityStorageProvider();
40
- export default opportunityStorageProvider;
97
+ export default OpportunityStorageProvider
@@ -4,6 +4,7 @@ import * as addressMap from '../blockchain/addresses.json';
4
4
  import { Contracts } from '../constants';
5
5
 
6
6
  async function syncJobs(marketAddress) {
7
+ if (opportunityService.getProviderInterface()) {
7
8
  //sync Jobs
8
9
  await opportunityService.getProviderInterface().getLogs({
9
10
  address: marketAddress,
@@ -21,5 +22,6 @@ async function syncJobs(marketAddress) {
21
22
  console.log('Err on fetching logs from blockchain: ' + err)
22
23
  })
23
24
  }
25
+ }
24
26
 
25
27
  export default syncJobs;
@@ -4,9 +4,10 @@ import { Contracts } from '../constants';
4
4
  import { processLog } from './process/process-log';
5
5
 
6
6
  async function syncMarkets() {
7
+ if (opportunityService.getProviderInterface()) {
7
8
  //sync Markets
8
9
  await opportunityService.getProviderInterface().getLogs({
9
- address: addressMap[Contracts.MARKET_FACTORY],
10
+ address: addressMap[opportunityService.getEthNetwork()][Contracts.MARKET_FACTORY],
10
11
  fromBlock: 1,
11
12
  toBlock: 'latest'
12
13
  }).then((logs) => {
@@ -20,6 +21,7 @@ async function syncMarkets() {
20
21
  .catch(err => {
21
22
  console.log('Err on fetching logs from blockchain: ' + err)
22
23
  })
24
+ }
23
25
  }
24
26
 
25
27
  export default syncMarkets;
package/src/types.ts CHANGED
@@ -50,4 +50,24 @@ export type WorkRelationshipMetadata = {
50
50
  description: string,
51
51
  }
52
52
 
53
- export interface EventCallbackDictionary { [eventName : string]: () => any }
53
+ export interface EventCallbackDictionary { [eventName : string]: () => any }
54
+
55
+
56
+ export type DisputeDoc = {
57
+ _id: string,
58
+ collection: string, //dispute
59
+ disputeAddress: string,
60
+ vocdoniProcessId: string
61
+ }
62
+
63
+ export type WorkRelationshipDoc = {
64
+ _id: string,
65
+ collection: string //relationship
66
+ }
67
+
68
+ export type UserSummaryDoc = {
69
+ _id: string,
70
+ collection: string, //summary
71
+ universalAddress: string,
72
+ userSummaryAddress: string
73
+ }
@@ -1,38 +0,0 @@
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
@@ -1 +0,0 @@
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;YAC1F,MAAM,aAAa,GAAG,cAAc,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;YAC9G,MAAM,KAAK,GAAG,EAAE,CAAA;YAChB,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAA;QACxC,CAAC,CAAC,CAAA,CAAC,gBAAgB;QAEnB,2EAA2E;QAC3E,IAAI,EAAE,Q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GAAgC;YACzC,SAAS,EAAE,YAAY;YACvB,WAAW;YACX,mBAAmB;YACnB,gBAAgB,EAAE,CAAC;YACnB,kBAAkB;SACrB,CAAA;QAEF,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,IAAI,CAAA;IAClB,CAAC;CAAA;AAED,SAAe,kBAAkB;;QAC7B,MAAM,CAAC,UAAU,EAAE,CAAA;IACvB,CAAC;CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -1,39 +0,0 @@
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 { EntityApi, EntityMetadataTemplate } from "dvote-js";
11
- /**
12
- * Vocdoni Docs:
13
- * We created JSON metadata containing the custom details of our entity
14
- * We pinned the JSON content on IPFS using a gateway from the pool
15
- * The hash of our metadata is QmdK5TnHDXPt4xozkuboyKP94RTrUxFr1z9Pkv5qhfahFG and should be available from any IPFS peer (opens new window)
16
- * An Ethereum transaction was sent to the entities contract, defining the pointer to our new metadata.
17
- * 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.
18
- *
19
- * @param entity
20
- * @param entityAppData
21
- */
22
- export function registerEntity(pool, entity, address) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- // Make a copy of the metadata template and customize it
25
- const entityMetadata = Object.assign({}, EntityMetadataTemplate);
26
- entityMetadata.name.default = "App";
27
- entityMetadata.description.default = "App";
28
- /*entityMetadata.media = {
29
- avatar: 'https://my-organization.org/logo.png',
30
- header: 'https://my-organization.org/header.jpeg'
31
- }*/
32
- entityMetadata.actions = [];
33
- const contentUri = yield EntityApi.setMetadata(address, entityMetadata, entity, pool);
34
- // Show stored values
35
- console.log("The entity has been defined");
36
- console.log(contentUri);
37
- });
38
- }
39
- //# sourceMappingURL=entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/api/voting/entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAkB,SAAS,EAAE,sBAAsB,EAAe,MAAM,UAAU,CAAA;AAIzF;;;;;;;;;;GAUG;AACH,MAAM,UAAgB,cAAc,CAAC,IAAkB,EAAE,MAAM,EAAE,OAAO;;QACxE,wDAAwD;QAExD,MAAM,cAAc,GAAmB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,CAAC,CAAA;QAEhF,cAAc,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACnC,cAAc,CAAC,WAAW,CAAC,OAAO,GAAG,KAAK,CAAA;QAC1C;;;WAGG;QACH,cAAc,CAAC,OAAO,GAAG,EAAE,CAAA;QAE3B,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QACrF,qBAAqB;QACrB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;QAC1C,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACvB,CAAC;CAAA"}
@@ -1,101 +0,0 @@
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 { VochainWaiter, CensusOffChainApi, ProcessMode, VotingApi, ProcessEnvelopeType, ProcessCensusOrigin, } from "dvote-js";
11
- import gwPool from "./connect";
12
- import { CensusOffChain } from "dvote-js/dist/api/census";
13
- import opportunityService from "../../OpportunityService";
14
- /**
15
- * As it happened before, the JSON metadata is pinned on IPFS and pointed to from the process smart contract. In addition, some metadata fields are also stored on the smart contract so they can be accessed on-chain.
16
- * The contract flags define how the process will behave, whereas the metadata is used to store the human readable content.
17
- * In about 2-3 minutes, the Ethereum transaction will be relayed to the voting blockchain as well. When the block number reaches startBlock, the process will become open to those who are part of the census. The startBlock value should be at least 25 blocks ahead of the current value.
18
- *
19
- * @param censusRoot
20
- * @param censusUri
21
- * @param details
22
- * @param entityWallet
23
- */
24
- export function createVotingProcess(censusRoot, censusUri, details, entityWallet) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- console.log("Preparing the new vote metadata");
27
- console.log("Getting the block height");
28
- const currentBlock = yield VotingApi.getBlockHeight(gwPool);
29
- const startBlock = currentBlock + 25;
30
- const blockCount = 60480;
31
- const processParamsPre = {
32
- mode: ProcessMode.make({ autoStart: true, interruptible: true }),
33
- envelopeType: ProcessEnvelopeType.ENCRYPTED_VOTES,
34
- censusOrigin: ProcessCensusOrigin.OFF_CHAIN_TREE,
35
- metadata: details,
36
- censusRoot: censusRoot,
37
- censusUri: censusUri,
38
- startBlock,
39
- blockCount,
40
- maxCount: 1,
41
- maxValue: 3,
42
- maxTotalCost: 0,
43
- costExponent: 10000,
44
- maxVoteOverwrites: 1,
45
- paramsSignature: "0x0000000000000000000000000000000000000000000000000000000000000000"
46
- };
47
- console.log("Creating the process");
48
- const processId = yield VotingApi.newProcess(processParamsPre, entityWallet, gwPool);
49
- //assert(processId)
50
- //processMetadata = processParamsPre.metadata
51
- // Reading back
52
- //processParams = await VotingApi.getProcessContractParameters(processId, gwPool)
53
- //assert.strictEqual(processParams.entityAddress.toLowerCase(), entityAddr.toLowerCase())
54
- //assert.strictEqual(processParams.startBlock, processParamsPre.startBlock, "SENT " + JSON.stringify(processParamsPre) + " GOT " + JSON.stringify(processParams))
55
- //assert.strictEqual(processParams.blockCount, processParamsPre.blockCount)
56
- //assert.strictEqual(processParams.censusRoot, processParamsPre.censusRoot)
57
- //assert.strictEqual(processParams.censusUri, processParamsPre.censusUri)
58
- });
59
- }
60
- function vote(processId, choices, publicKey) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- // Fetch the metadata
63
- const processMeta = yield VotingApi.getProcessMetadata(processId, gwPool);
64
- const processParams = yield VotingApi.getProcessContractParameters(processId, gwPool);
65
- console.log("- Starting:", yield VotingApi.estimateDateAtBlock(processMeta.startBlock, gwPool));
66
- console.log("- Ending:", yield VotingApi.estimateDateAtBlock(processMeta.startBlock + processMeta.numberOfBlocks, gwPool));
67
- console.log("- Census size:", yield CensusOffChainApi.getSize(processMeta.census.merkleRoot, gwPool));
68
- console.log("- Current block:", yield VotingApi.getBlockHeight(gwPool));
69
- console.log("- Current votes:", yield VotingApi.getEnvelopeHeight(processId, gwPool));
70
- yield VochainWaiter.waitUntil(processParams.startBlock, gwPool, { verbose: true });
71
- //await waitUntilVochainBlock(processMeta.startBlock, gwPool, { verbose: true })
72
- console.log("Submitting vote envelopes");
73
- // Hash the voter's public key
74
- const publicKeyHash = CensusOffChain.Public.encodePublicKey(publicKey); //supposed to be digestPublicKey(x, y)?
75
- // Generate the census proof
76
- const merkleProof = yield CensusOffChainApi.generateProof(processParams.censusRoot, { key: Buffer.from(String(publicKey), "hex").toString("base64"), value: 0 }, true, gwPool);
77
- // Sign the vote envelope with our choices
78
- const voteEnvelope = yield VotingApi.packageSignedEnvelope({ votes: choices, censusOrigin: 0, censusProof: merkleProof, processLeys: processId, walletOrSigner: opportunityService.getSignersInterface() });
79
- // If the process had encrypted votes:
80
- // const voteEnvelope = await packagePollEnvelope({ votes, merkleProof, processId, walletOrSigner: wallet, encryptionPubKeys: ["..."] })
81
- yield VotingApi.submitEnvelope(voteEnvelope, opportunityService.getSignersInterface(), gwPool);
82
- console.log("Envelope submitted");
83
- });
84
- }
85
- /*
86
- async function checkVoteStatus() {
87
- // Compute our deterministic nullifier to check the status of our vote
88
- const nullifier = await getPollNullifier(wallet.address, processId)
89
- const status = await VotingApi.getEnvelopeStatus(processId, nullifier, pool)
90
-
91
- console.log("- Registered: ", status.registered)
92
- console.log("- Block: ", status.block)
93
- console.log("- Date: ", status.date)
94
- }*/
95
- function fetchResults(processId) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const { results, status } = yield VotingApi.getResults(processId, gwPool);
98
- console.log("Process results", results);
99
- });
100
- }
101
- //# sourceMappingURL=process.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.js","sourceRoot":"","sources":["../../../src/api/voting/process.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAmB,aAAa,EAAE,iBAAiB,EAAyD,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,mBAAmB,GAAY,MAAM,UAAU,CAAA;AAE/M,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,OAAO,EAAG,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,kBAAkB,MAAM,0BAA0B,CAAA;AAEzD;;;;;;;;;GASG;AACH,MAAM,UAAgB,mBAAmB,CACrC,UAAU,EACV,SAAS,EACT,OAAyB,EACzB,YAAsC;;QAEtC,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;QAC9C,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;QACvC,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;QAC3D,MAAM,UAAU,GAAG,YAAY,GAAG,EAAE,CAAA;QACpC,MAAM,UAAU,GAAG,KAAK,CAAA;QAExB,MAAM,gBAAgB,GAAsB;YAExC,IAAI,EAAE,WA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CAAC,mBAAmB,EAAE,EAAE,MAAM,CAAC,CAAA;QAC9F,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACzC,CAAC;CAAA;AAED;;;;;;;;;GASG;AAGH,SAAe,YAAY,CAAC,SAAS;;QACjC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QACzE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;CAAA"}
@@ -1,39 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
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
@@ -1,33 +0,0 @@
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
- }