Browse Source

#156 - Remove isEthereum flags and left over node-api related code

Elena Cristina Raffay Iglesias 1 year ago
parent
commit
3fc167441b
35 changed files with 3 additions and 5162 deletions
  1. 0 6
      apps/petitions/decode-app/config/server.yaml
  2. 0 1
      apps/petitions/decode-app/data/petitions.json
  3. 1 2
      apps/petitions/decode-app/src/decode_app/database.clj
  4. 0 5
      apps/petitions/ethereum/node-api/.gitignore
  5. 0 1
      apps/petitions/ethereum/node-api/.nvmrc
  6. 0 113
      apps/petitions/ethereum/node-api/README.md
  7. 0 23
      apps/petitions/ethereum/node-api/contracts/Migrations.sol
  8. 0 30
      apps/petitions/ethereum/node-api/contracts/Petition.sol
  9. 0 53
      apps/petitions/ethereum/node-api/contracts/SecurePetitions.sol
  10. 0 27
      apps/petitions/ethereum/node-api/contracts/deploy.js
  11. 0 31
      apps/petitions/ethereum/node-api/contracts/greeter.sol
  12. 0 97
      apps/petitions/ethereum/node-api/go.sh
  13. 0 11
      apps/petitions/ethereum/node-api/migrations/1_initial_migration.js
  14. 0 81
      apps/petitions/ethereum/node-api/node-api.gopipeline.json
  15. 0 93
      apps/petitions/ethereum/node-api/nodeApi.js
  16. 0 4110
      apps/petitions/ethereum/node-api/package-lock.json
  17. 0 24
      apps/petitions/ethereum/node-api/package.json
  18. 0 104
      apps/petitions/ethereum/node-api/test/nodeApi_spec.js
  19. 0 82
      apps/petitions/ethereum/node-api/test/testSecurePetitions.js
  20. 0 14
      apps/petitions/ethereum/node-api/truffle.js
  21. 0 5
      apps/petitions/ethereum/nodes/.gitignore
  22. 0 14
      apps/petitions/ethereum/nodes/README.md
  23. 0 32
      apps/petitions/ethereum/nodes/cloudformation.yaml
  24. 0 20
      apps/petitions/ethereum/nodes/genesis791.json
  25. 0 131
      apps/petitions/ethereum/nodes/go.sh
  26. 0 10
      apps/petitions/ethereum/nodes/nodes.iml
  27. BIN
      apps/petitions/ethereum/nodes/nodes_snapshot.tar.gz
  28. 0 1
      apps/petitions/ethereum/nodes/truffle-account.txt
  29. 0 29
      apps/petitions/petitions-app/go.sh
  30. 2 2
      apps/wallet-proxy/test/routes_test.py
  31. 0 1
      apps/wallet/application/redux/actions/petition.js
  32. 0 3
      apps/wallet/test/acceptance/sign.test.js
  33. 0 1
      apps/wallet/test/snapshot/PetitionSummary.test.js
  34. 0 2
      apps/wallet/test/snapshot/__snapshots__/PetitionSummary.test.js.snap
  35. 0 3
      apps/wallet/test/unit/application/redux/actions/petition.test.js

+ 0 - 6
apps/petitions/decode-app/config/server.yaml

@@ -2,8 +2,6 @@ development:
2 2
   mongo-port:      27017
3 3
   mongo-host:      "127.0.0.1"
4 4
   database:        "decode-dev"
5
-  node-api-port:   3000
6
-  node-api-host:   "http://127.0.0.1"
7 5
   chainspace-host: "http://127.0.0.1"
8 6
   chainspace-port: 5010
9 7
                
@@ -11,8 +9,6 @@ test:
11 9
   mongo-port:      27017
12 10
   mongo-host:      "127.0.0.1"
13 11
   database:        "decode-dev-test"
14
-  node-api-port:   3000
15
-  node-api-host:   "http://127.0.0.1"
16 12
   chainspace-host: "http://127.0.0.1"
17 13
   chainspace-port: 5010
18 14
                
@@ -20,7 +16,5 @@ production:
20 16
   mongo-port:      27017
21 17
   mongo-host:      "ip-10-0-0-59.eu-west-1.compute.internal"
22 18
   database:        "decode"
23
-  node-api-port:   3000
24
-  node-api-host:   "http://ec2-34-253-196-175.eu-west-1.compute.amazonaws.com"
25 19
   chainspace-host: "ec2-54-194-123-109.eu-west-1.compute.amazonaws.com"
26 20
   chainspace-port: 5010

+ 0 - 1
apps/petitions/decode-app/data/petitions.json

@@ -8,7 +8,6 @@
8 8
     "createdBy": "Andrei",
9 9
     "id": "59f888c8ce33c76884e8cf16",
10 10
     "cs_id": null,
11
-    "isEthereum": "false",
12 11
     "images": {
13 12
       "square": "images/petition1-square.jpg",
14 13
       "wide": "images/petition1-wide.jpg"

+ 1 - 2
apps/petitions/decode-app/src/decode_app/database.clj

@@ -55,8 +55,7 @@
55 55
                       {:_id object-id
56 56
                        :cs-id chainspace-object-id
57 57
                        :title title
58
-                       :description description
59
-                       :isEthereum "false"})
58
+                       :description description})
60 59
            (str  object-id)))
61 60
 
62 61
 (defn close-petition [id outcome]

+ 0 - 5
apps/petitions/ethereum/node-api/.gitignore

@@ -1,5 +0,0 @@
1
-build
2
-node_modules
3
-output.log
4
-target
5
-npm-debug.log

+ 0 - 1
apps/petitions/ethereum/node-api/.nvmrc

@@ -1 +0,0 @@
1
-9.2.0

+ 0 - 113
apps/petitions/ethereum/node-api/README.md

@@ -1,113 +0,0 @@
1
-## Testing with truffle
2
-
3
-### Install requirements
4
-```
5
-npm install -g ethereumjs-testrpc truffle
6
-```
7
-
8
-### Run tests
9
-
10
-```
11
-./go.sh test-rpc
12
-```
13
-
14
-### Install Ethereum
15
-
16
-[https://www.ethereum.org/cli](https://www.ethereum.org/cli)
17
-
18
-```
19
-brew update
20
-brew upgrade
21
-brew install ethereum
22
-```
23
-
24
-You should now have a working ethereum service
25
-
26
-
27
-### Manually Deploy contracts to 2 node local node environment
28
-
29
-Start the 2 node local node environment.
30
-
31
-`cd` into the `nodes` folder. Run the following commands. These scripts will set up an account for your local instance which requires a password to be chosen.
32
-
33
-You can tell it what password to use via an environment variable, just replace `<value>` with whatever you want your password to be.
34
-
35
-```
36
-export PASS=<value>
37
-./go.sh start-nodes
38
-./go.sh start-mining
39
-```
40
-
41
-You can attach a console to your nodes to see and do things.
42
-
43
-The node 0 has been set up with an account as a miner, node 1 is a vaildating node they are called `0` and `1`.
44
-
45
-```
46
-./go.sh console 0
47
-```
48
-
49
-Try
50
-
51
-```
52
-eth.accounts
53
-```
54
-You should see a public key like
55
-
56
-```
57
-["0x2c175e93c2cb9cf183160cc1959ed4a8499a0f23"]
58
-```
59
-
60
-YOu can now deploy your contract using the geth console
61
-
62
-```
63
-personal.unlockAccount(eth.accounts[0])
64
-
65
-var abi=JSON.parse('<paste content of abi here>');
66
-var bin="<paste content of bin here>"
67
-var data="<any data you need to send in the constructor>"
68
-
69
-loadScript("../contracts/deploy.js")
70
-deployContract(abi, bin, data)
71
-```
72
-
73
-Eventually you should see something like:
74
-
75
-```
76
-Contract mined! address: 0x27090302484c9e996806904ec0602d621e4c0bfe transactionHash: 0xcf25029997cd1b059f6c03aadb2e55b39ac21b8ce282feb29da5ef027a06fc47
77
-```
78
-
79
-Which you can now use to interact with your contract.
80
-
81
-```
82
-truffle migrate --network local
83
-truffle console --network local
84
-
85
-> Petition.deployed().then(instance => instance.sign.sendTransaction("testest signature asdfasd adsf ")).then(result => result)
86
-
87
-> Petition.deployed().then(instance => instance.getSignatureCount.call()).then(result => result)
88
-```
89
-
90
-# Node API 
91
-
92
-```
93
-nvm install
94
-npm install
95
-```
96
-
97
-Deploy contracts into testrpc with
98
-
99
-```
100
-truffle compile
101
-truffle migrate --reset
102
-```
103
-
104
-Start the application with
105
-```
106
-npm start
107
-```
108
-
109
-Run tests with
110
-```
111
-./go.sh test
112
-```
113
-

+ 0 - 23
apps/petitions/ethereum/node-api/contracts/Migrations.sol

@@ -1,23 +0,0 @@
1
-pragma solidity ^0.4.4;
2
-
3
-contract Migrations {
4
-  address public owner;
5
-  uint public last_completed_migration;
6
-
7
-  modifier restricted() {
8
-    if (msg.sender == owner) _;
9
-  }
10
-
11
-  function Migrations() {
12
-    owner = msg.sender;
13
-  }
14
-
15
-  function setCompleted(uint completed) restricted {
16
-    last_completed_migration = completed;
17
-  }
18
-
19
-  function upgrade(address new_address) restricted {
20
-    Migrations upgraded = Migrations(new_address);
21
-    upgraded.setCompleted(last_completed_migration);
22
-  }
23
-}

+ 0 - 30
apps/petitions/ethereum/node-api/contracts/Petition.sol

@@ -1,30 +0,0 @@
1
-pragma solidity ^0.4.11;
2
-
3
-contract Petition {
4
-    bytes32 UUID;
5
-    string[] public signatureIDs;
6
-    uint signatureCount;
7
-
8
-    function Petition(bytes32 _UUID) {
9
-        UUID = _UUID;
10
-        signatureCount = 0;
11
-    }
12
-
13
-    function sign(string _signatureID) {
14
-        signatureIDs.push(_signatureID);
15
-        signatureCount++;
16
-    }
17
-
18
-    function getSignatureCount() returns (uint256) {
19
-        return signatureCount;
20
-    }
21
-
22
-    function getUUID() returns (bytes32) {
23
-        return UUID;
24
-    }
25
-
26
-    function getSignatureID(uint index) constant returns (string) {
27
-        return signatureIDs[index];
28
-    }
29
-}
30
-

+ 0 - 53
apps/petitions/ethereum/node-api/contracts/SecurePetitions.sol

@@ -1,53 +0,0 @@
1
-pragma solidity ^0.4.11;
2
-
3
-contract SecurePetitions {
4
-
5
-    struct Petition {
6
-        bytes32  UUID;
7
-        string[] signatureIDs;
8
-        uint signatureCount;
9
-        bool isEntity;
10
-    }
11
-
12
-    mapping(bytes32 => Petition) public petitions;
13
-
14
-    function isEntity(bytes32 UUID) public constant returns(bool isIndeed) {
15
-        return petitions[UUID].isEntity;
16
-  }
17
-
18
-    function SecurePetitions(bytes32[] petitionUUIDs) {
19
-        for (uint i = 0; i < petitionUUIDs.length; i++) {
20
-            petitions[petitionUUIDs[i]] = Petition({
21
-                UUID: petitionUUIDs[i],
22
-                signatureIDs: new string[](0),
23
-                signatureCount: 0,
24
-                isEntity: true
25
-        });
26
-        }
27
-    }
28
-
29
-    function addPetition(bytes32 UUID) {
30
-        petitions[UUID] = Petition({
31
-                UUID: UUID,
32
-                signatureIDs: new string[](0),
33
-                signatureCount: 0,
34
-                isEntity: true
35
-        });
36
-    }
37
-
38
-    function getSignatureCount(bytes32 UUID) returns (uint) {
39
-        if(!isEntity(UUID)) throw;
40
-        return petitions[UUID].signatureCount;
41
-    }
42
-
43
-    function getSignatoryOf(bytes32 UUID, uint signatoryIndex) returns (string) {
44
-        if(!isEntity(UUID)) throw;
45
-        return petitions[UUID].signatureIDs[signatoryIndex];
46
-    }
47
-
48
-    function sign(bytes32 UUID, string signature) {
49
-        if(!isEntity(UUID)) throw;
50
-        petitions[UUID].signatureIDs.push(signature);
51
-        petitions[UUID].signatureCount += 1;
52
-    }
53
-}

+ 0 - 27
apps/petitions/ethereum/node-api/contracts/deploy.js

@@ -1,27 +0,0 @@
1
-function deployContract(abi, bin, data) {
2
-
3
-  var contract = web3.eth.contract(abi);
4
-
5
-  return contract.new(
6
-    data,
7
-
8
-    {
9
-
10
-      from: web3.eth.accounts[0],
11
-
12
-      data: '0x' + bin,
13
-
14
-      gas: '4700000',
15
-
16
-    }, function(e, contract) {
17
-
18
-      console.log(e, contract);
19
-
20
-      if (typeof contract.address !== 'undefined') {
21
-
22
-        console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
23
-
24
-      }
25
-
26
-    });
27
-}

+ 0 - 31
apps/petitions/ethereum/node-api/contracts/greeter.sol

@@ -1,31 +0,0 @@
1
-/*Thanks to https://steemit.com/ethereum/@decentralised/hello-world-revisiting-the-ethereum-greeter-tutorial-for-the-summer-of-17*/
2
-
3
-pragma solidity ^0.4.11;
4
-
5
-contract Greeter {
6
-
7
-    address owner;
8
-    string greeting;
9
-
10
-    modifier onlyOwner() {
11
-        require (owner == msg.sender);
12
-        _;
13
-    }
14
-
15
-    function Greeter(string _greeting) {
16
-        owner = msg.sender;
17
-        greeting = _greeting;
18
-    }
19
-
20
-    function greet() constant returns (string) {
21
-        return greeting;
22
-    }
23
-
24
-    function setGreeting(string _greeting) {
25
-        greeting = _greeting;
26
-    }
27
-
28
-    function kill() onlyOwner {
29
-        selfdestruct(owner);
30
-    }
31
-}

+ 0 - 97
apps/petitions/ethereum/node-api/go.sh

@@ -1,97 +0,0 @@
1
-#!/bin/bash
2
-
3
-set -x
4
-
5
-NODE_MODULES_PATH=./node_modules/.bin
6
-EC2_INSTANCE="ec2-34-253-196-175.eu-west-1.compute.amazonaws.com"
7
-
8
-
9
-usage() {
10
-  echo "Usage:"
11
-  echo "./go.sh test      : runs tests"
12
-  echo "./go.sh deploy    : compiles and migrates contracts"
13
-  echo "./go.sh start     : starts Node API"
14
-  echo "./go.sh stop      : stops Node API"
15
-  echo "./go.sh restart   : restarts Node API"
16
-}
17
-
18
-test() {
19
-  testrpc_setup
20
-  npm test test/nodeApi_spec.js && $NODE_MODULES_PATH/truffle test test/testSecurePetitions.js
21
-  test_run_status=$?
22
-  pkill -f testrpc
23
-  exit $test_run_status
24
-}
25
-
26
-start() {
27
-  testrpc_setup
28
-  npm start 2>&1 > /dev/null &
29
-  echo "Started Node API"
30
-}
31
-
32
-testrpc_setup() {
33
-  npm install
34
-  $NODE_MODULES_PATH/testrpc > $PWD/output.log &
35
-  deploy_contracts
36
-}
37
-
38
-stop() {
39
-    pkill -f nodeApi.js
40
-    pkill -f testrpc
41
-}
42
-
43
-deploy_contracts() {
44
-    $NODE_MODULES_PATH/truffle compile
45
-    $NODE_MODULES_PATH/truffle migrate --reset
46
-}
47
-
48
-set_version() {
49
-  if [ "$GO_PIPELINE_LABEL" ]; then
50
-    VERSION="$GO_PIPELINE_LABEL"
51
-    echo "Using GO version number: $VERSION"
52
-  elif [ -z "$VERSION" ]; then
53
-    VERSION="SNAPSHOT"
54
-    echo "Using default version: $VERSION"
55
-  fi
56
-}
57
-
58
-deploy() {
59
-    package
60
-    ssh ec2-user@$EC2_INSTANCE "pushd node-api && ./go.sh stop && popd && rm -rf node-api && mkdir node-api"
61
-    scp target/public-$VERSION.tgz ec2-user@$EC2_INSTANCE:~/node-api
62
-    ssh ec2-user@$EC2_INSTANCE "cd node-api && tar -xvzf public-$VERSION.tgz && ./go.sh start > /dev/null 2>&1 &"
63
-}
64
-
65
-package() {
66
-    set_version
67
-    mkdir -p target
68
-    tar -cvzf target/public-$VERSION.tgz nodeApi.js package.json go.sh contracts migrations truffle.js
69
-}
70
-
71
-OPTION="$1"
72
-  case $OPTION in
73
-    start)
74
-      start
75
-      ;;
76
-    stop)
77
-      stop
78
-      ;;
79
-    restart)
80
-      stop
81
-      start
82
-      ;;
83
-    test)
84
-      test
85
-      ;;
86
-    deploy-contracts)
87
-      deploy_contracts
88
-      ;;
89
-    package)
90
-      package
91
-      ;;
92
-    deploy)
93
-      deploy
94
-      ;;
95
-    *)
96
-    usage
97
-  esac

+ 0 - 11
apps/petitions/ethereum/node-api/migrations/1_initial_migration.js

@@ -1,11 +0,0 @@
1
-/* eslint-disable */
2
-
3
-const Migrations = artifacts.require('./Migrations.sol');
4
-const Petition = artifacts.require('./Petition.sol');
5
-const SecurePetitions = artifacts.require('./SecurePetitions.sol');
6
-
7
-module.exports = function (deployer) {
8
-  deployer.deploy(Migrations);
9
-  deployer.deploy(Petition);
10
-  deployer.deploy(SecurePetitions, ["UUID0", "59f888c8ce33c76884e8cf16", "59f888c8ce33c76884e8cf17", "59f888c8ce33c76884e8cf18"]);
11
-};

+ 0 - 81
apps/petitions/ethereum/node-api/node-api.gopipeline.json

@@ -1,81 +0,0 @@
1
-{
2
-  "name": "NodeAPI",
3
-  "environment_variables": [],
4
-  "group" : "ScaleModel",
5
-  "materials": [
6
-    {
7
-      "url": "https://gogs.dyne.org/DECODE/decode-prototype.git",
8
-      "type": "git",
9
-      "filter": {
10
-        "whitelist": [
11
-          "apps/petitions/ethereum/node-api/**/*"
12
-        ]
13
-      }
14
-    }
15
-  ],
16
-  "stages": [
17
-    {
18
-      "name": "test",
19
-      "fetch_materials": true,
20
-      "never_cleanup_artifacts": false,
21
-      "clean_working_directory": false,
22
-      "environment_variables": [],
23
-      "jobs": [
24
-        {
25
-          "name": "defaultJob",
26
-          "environment_variables": [],
27
-          "tabs": [],
28
-          "resources": ["node"],
29
-          "artifacts": [],
30
-          "properties": [],
31
-          "run_instance_count": null,
32
-          "timeout": 0,
33
-          "tasks": [
34
-            {
35
-              "type": "exec",
36
-              "run_if": "passed",
37
-              "on_cancel" : null,
38
-              "command": "./go.sh",
39
-              "arguments": [
40
-                "test"
41
-              ],
42
-              "working_directory": "apps/petitions/ethereum/node-api"
43
-            }
44
-
45
-          ]
46
-        }
47
-      ]
48
-    },
49
-    {
50
-      "name": "deploy",
51
-      "fetch_materials": true,
52
-      "never_cleanup_artifacts": false,
53
-      "clean_working_directory": false,
54
-      "environment_variables": [],
55
-      "jobs": [
56
-        {
57
-          "name": "deploy",
58
-          "environment_variables": [],
59
-          "tabs": [],
60
-          "resources": ["node"],
61
-          "artifacts": [],
62
-          "properties": [],
63
-          "run_instance_count": null,
64
-          "timeout": 0,
65
-          "tasks": [
66
-            {
67
-              "type": "exec",
68
-              "run_if": "passed",
69
-              "on_cancel" : null,
70
-              "command": "./go.sh",
71
-              "arguments": [
72
-                "deploy"
73
-              ],
74
-              "working_directory": "apps/petitions/ethereum/node-api"
75
-            }
76
-          ]
77
-        }
78
-      ]
79
-    }
80
-  ]
81
-}

+ 0 - 93
apps/petitions/ethereum/node-api/nodeApi.js

@@ -1,93 +0,0 @@
1
-const express = require('express');
2
-const Web3 = require('web3');
3
-const bodyParser = require('body-parser');
4
-
5
-const truffleContract = require('truffle-contract');
6
-const securePetitionsContractData = require('./build/contracts/SecurePetitions.json');
7
-
8
-const web3Provider = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
9
-const securePetitionsContractWithTruffle = truffleContract(securePetitionsContractData);
10
-securePetitionsContractWithTruffle.setProvider(web3Provider.currentProvider);
11
-
12
-const app = express();
13
-
14
-app.use(bodyParser.json());
15
-
16
-app.get('/dapp/petitions/:id/signature-count', (req, res, next) => {
17
-  securePetitionsContractWithTruffle.deployed()
18
-    .then((instance) => {
19
-      const petitionUUID = req.params.id;
20
-      return instance.getSignatureCount.call(petitionUUID);
21
-    })
22
-    .then((signatureCount) => {
23
-      const count = parseInt(signatureCount, 10);
24
-      res.send({ count });
25
-    })
26
-    .catch((error) => {
27
-      next(error);
28
-    });
29
-});
30
-
31
-app.post('/dapp/petitions/:id/sign', (req, res, next) => {
32
-  const petitionUUID = req.params.id;
33
-  const signatory = req.body.signatory;
34
-
35
-  securePetitionsContractWithTruffle.deployed()
36
-    .then(instance => instance.sign.sendTransaction(petitionUUID, signatory,
37
-      { from: web3Provider.eth.accounts[0] }))
38
-    .then(() => {
39
-      res.sendStatus(202);
40
-    })
41
-    .catch((error) => {
42
-      next(error);
43
-    });
44
-});
45
-
46
-app.get('/dapp/petitions/:id/signatories', (req, res, next) => {
47
-  const petitionUUID = req.params.id;
48
-
49
-  function getSignatories(intSigCount) {
50
-    const signatoryPromises = [];
51
-    for (let i = 0; i < parseInt(intSigCount, 10); i += 1) {
52
-      signatoryPromises.push(
53
-        securePetitionsContractWithTruffle.deployed()
54
-          .then(instance =>
55
-            instance.getSignatoryOf.call(petitionUUID, i)));
56
-    }
57
-    return signatoryPromises;
58
-  }
59
-
60
-  const getSignatureCount = () => {
61
-    securePetitionsContractWithTruffle.deployed()
62
-      .then(instance => instance.getSignatureCount.call(petitionUUID))
63
-      .then(signatureCount => Promise.all(getSignatories(signatureCount)))
64
-      .then((signatories) => {
65
-        res.send({ signatories });
66
-      })
67
-      .catch((error) => {
68
-        next(error);
69
-      });
70
-  };
71
-
72
-  getSignatureCount();
73
-});
74
-
75
-app.use((req, res, next) => {
76
-  const error = new Error('Whoops');
77
-  error.status = 404;
78
-  next(error);
79
-});
80
-
81
-// eslint-disable-next-line no-unused-vars
82
-app.use((err, req, res, next) => {
83
-  res.status(err.status || 500);
84
-  res.send({
85
-    errors: {
86
-      message: err.message,
87
-    },
88
-  });
89
-});
90
-
91
-app.listen(3000, () => console.log('Example app listening on port 3000'));
92
-
93
-module.exports = app;

File diff suppressed because it is too large
+ 0 - 4110
apps/petitions/ethereum/node-api/package-lock.json


+ 0 - 24
apps/petitions/ethereum/node-api/package.json

@@ -1,24 +0,0 @@
1
-{
2
-  "name": "node-api",
3
-  "version": "5.2.0",
4
-  "description": "API for DECODE Nodes",
5
-  "main": "nodeApi.js",
6
-  "scripts": {
7
-    "start": "node nodeApi.js",
8
-    "test": "mocha --timeout 10000 --exit"
9
-  },
10
-  "author": "",
11
-  "license": "ISC",
12
-  "dependencies": {
13
-    "body-parser": "^1.18.2",
14
-    "chai": "^4.1.2",
15
-    "chai-http": "^3.0.0",
16
-    "ethereumjs-testrpc": "^6.0.1",
17
-    "express": "^4.16.2",
18
-    "mocha": "^4.0.1",
19
-    "solc": "^0.4.18",
20
-    "truffle": "~3.4.11",
21
-    "truffle-contract": "^3.0.1",
22
-    "web3": "^0.20.1"
23
-  }
24
-}

+ 0 - 104
apps/petitions/ethereum/node-api/test/nodeApi_spec.js

@@ -1,104 +0,0 @@
1
-const chai = require('chai');
2
-const chaiHttp = require('chai-http');
3
-
4
-const expect = chai.expect;
5
-
6
-const server = require('../nodeApi');
7
-
8
-chai.use(chaiHttp);
9
-
10
-describe('Testing errors', () => {
11
-  it('should return 404 if route does not exist', (done) => {
12
-    chai.request(server)
13
-      .get('/does-not-exist')
14
-      .end((err, response) => {
15
-        expect(response).to.have.status(404);
16
-        expect(response.body.errors.message).to.equal('Whoops');
17
-        done();
18
-      });
19
-  });
20
-
21
-  it('should return 500 when retrieving signatories of petition that does not exist', (done) => {
22
-    chai.request(server)
23
-      .get(`/dapp/petitions/${'INVALID'}/signatories`)
24
-      .end((err, response) => {
25
-        expect(response).to.have.status(500);
26
-        expect(response.body.errors.message).to.equal('VM Exception while processing transaction: revert');
27
-        done();
28
-      });
29
-  });
30
-
31
-  it('should return 500 when signing a petition that does not exist', (done) => {
32
-    chai.request(server)
33
-      .post(`/dapp/petitions/${'INVALID'}/sign`)
34
-      .send({ signatory: 'Douglas Fenella' })
35
-      .end((err, response) => {
36
-        expect(response).to.have.status(500);
37
-        expect(response.body.errors.message).to.equal('VM Exception while processing transaction: revert');
38
-        done();
39
-      });
40
-  });
41
-});
42
-
43
-describe('Testing all SecurePetitions routes', () => {
44
-  it('should return the signature count for a specific petition', (done) => {
45
-    const petitionId = 'UUID0';
46
-    chai.request(server)
47
-      .get(`/dapp/petitions/${petitionId}/signature-count`)
48
-      .end((err, response) => {
49
-        expect(response).to.have.status(200);
50
-        expect(response.body.count).to.equal(0);
51
-        done();
52
-      });
53
-  });
54
-
55
-  it('should respond with 202 when signing the petition', (done) => {
56
-    const petitionId = 'UUID0';
57
-    chai.request(server)
58
-      .post(`/dapp/petitions/${petitionId}/sign`)
59
-      .send({ signatory: 'Keira Smith' })
60
-      .end((err, response) => {
61
-        expect(response).to.have.status(202);
62
-        done();
63
-      });
64
-  });
65
-
66
-  it('should return increased signature count for petition that was just signed', (done) => {
67
-    const petitionId = 'UUID0';
68
-    chai.request(server)
69
-      .get(`/dapp/petitions/${petitionId}/signature-count`)
70
-      .end((err, response) => {
71
-        expect(response).to.have.status(200);
72
-        expect(response.body.count).to.equal(1);
73
-        done();
74
-      });
75
-  });
76
-
77
-  it('should return signatory', (done) => {
78
-    const petitionId = 'UUID0';
79
-    chai.request(server)
80
-      .get(`/dapp/petitions/${petitionId}/signatories`)
81
-      .end((err, response) => {
82
-        expect(response).to.have.status(200);
83
-        expect(response.body.signatories).to.eql(['Keira Smith']);
84
-        done();
85
-      });
86
-  });
87
-
88
-  it('should return signatories', (done) => {
89
-    const petitionId = 'UUID0';
90
-    chai.request(server)
91
-      .post(`/dapp/petitions/${petitionId}/sign`)
92
-      .send({ signatory: 'Alana Ocean' })
93
-      .end();
94
-
95
-    chai.request(server)
96
-      .get(`/dapp/petitions/${petitionId}/signatories`)
97
-      .end((err, response) => {
98
-        expect(response).to.have.status(200);
99
-        expect(response.body.signatories).to.eql(['Keira Smith', 'Alana Ocean']);
100
-        done();
101
-      });
102
-  });
103
-});
104
-

+ 0 - 82
apps/petitions/ethereum/node-api/test/testSecurePetitions.js

@@ -1,82 +0,0 @@
1
-/* eslint-disable no-undef */
2
-const SecurePetitions = artifacts.require('SecurePetitions');
3
-
4
-contract('Secure Petitions', () => {
5
-  it('should have petition id golden data once initialised', async () => {
6
-    const instance = await SecurePetitions.deployed();
7
-    return instance.petitions.call('UUID0')
8
-      .then(petition =>
9
-        assert.isOk(petition));
10
-  });
11
-
12
-  it('should add petition', async () => {
13
-    const petitionUUID = 'UUID0';
14
-    const petitionUUIDByte32 = '0x5555494430000000000000000000000000000000000000000000000000000000';
15
-    const instance = await SecurePetitions.deployed();
16
-    await instance.addPetition.sendTransaction(petitionUUID);
17
-    return instance.petitions.call(petitionUUID)
18
-      .then(petition =>
19
-        assert.equal(petition[0], petitionUUIDByte32));
20
-  });
21
-
22
-  it('should not have signatures if not signed', async () => {
23
-    const petitionUUID = 'UUID0';
24
-    const instance = await SecurePetitions.deployed();
25
-    return instance.getSignatureCount.call(petitionUUID)
26
-      .then(signatureCount =>
27
-        assert.equal(signatureCount, 0));
28
-  });
29
-
30
-  it('should increase signature count for signed petition', async () => {
31
-    const petitionUUID = 'UUID0';
32
-    const instance = await SecurePetitions.deployed();
33
-    await instance.sign.sendTransaction(petitionUUID, 'Colin Ramsey');
34
-    return instance.getSignatureCount.call(petitionUUID)
35
-      .then(signatureCount =>
36
-        assert.equal(signatureCount, 1));
37
-  });
38
-
39
-  it('should increase signature count if more than one signature', async () => {
40
-    const petitionUUID = 'UUID0';
41
-    const instance = await SecurePetitions.deployed();
42
-    await instance.sign.sendTransaction(petitionUUID, 'Tomi Praise');
43
-    return instance.getSignatureCount.call(petitionUUID)
44
-      .then(signatureCount =>
45
-        assert.equal(signatureCount, 2));
46
-  });
47
-
48
-  it('should get signatory for signed petition', async () => {
49
-    const petitionUUID = 'UUID0';
50
-    const instance = await SecurePetitions.deployed();
51
-    return instance.getSignatoryOf.call(petitionUUID, 0)
52
-      .then(signatory =>
53
-        assert.equal(signatory, 'Colin Ramsey'));
54
-  });
55
-
56
-  it('should throw exception if calling getSignatoryOf with petitionId', async () => {
57
-    const petitionUUID = 'INVALID';
58
-
59
-    const instance = await SecurePetitions.deployed();
60
-    try {
61
-      await instance.getSignatoryOf.call(petitionUUID, 0);
62
-    } catch (error) {
63
-      assert.isTrue(error.message.search('VM Exception while processing transaction: revert') >= 0);
64
-      return;
65
-    }
66
-    assert.fail('Expected throw was not received');
67
-  });
68
-
69
-  it('should throw exception if calling getSignatureCount', async () => {
70
-    const petitionUUID = 'INVALID';
71
-
72
-    const instance = await SecurePetitions.deployed();
73
-    try {
74
-      await instance.getSignatureCount.call(petitionUUID);
75
-    } catch (error) {
76
-      assert.isTrue(error.message.search('VM Exception while processing transaction: revert') >= 0);
77
-      return;
78
-    }
79
-    assert.fail('Expected throw was not received');
80
-  });
81
-});
82
-

+ 0 - 14
apps/petitions/ethereum/node-api/truffle.js

@@ -1,14 +0,0 @@
1
-module.exports = {
2
-  networks: {
3
-    development: {
4
-      host: 'localhost',
5
-      port: 8545,
6
-      network_id: '*', // Match any network id
7
-    },
8
-    localnodes: {
9
-      host: 'localhost',
10
-      port: 8100,
11
-      network_id: '*', // Match any network id
12
-    },
13
-  },
14
-};

+ 0 - 5
apps/petitions/ethereum/nodes/.gitignore

@@ -1,5 +0,0 @@
1
-geth/
2
-0/keystore/*
3
-1/keystore/*
4
-output.log
5
-build

+ 0 - 14
apps/petitions/ethereum/nodes/README.md

@@ -1,14 +0,0 @@
1
-# Deploying Nodes
2
-
3
-To begin, you'll need to add a password environment variable for a new geth account:
4
-
5
-```
6
-export PASS=[value]
7
-```
8
- To deploy, run:
9
- ```
10
- cd nodes
11
- ./go.sh deploy
12
- ```
13
-
14
- This creates two nodes, with one adding the other as a peer and one node beginning to mine.

+ 0 - 32
apps/petitions/ethereum/nodes/cloudformation.yaml

@@ -1,32 +0,0 @@
1
-  AWSTemplateFormatVersion: 2010-09-09
2
-  Description: CloudFormation template for creating an ec2 instance
3
-  Resources:
4
-    MyInstance:
5
-      Type: "AWS::EC2::Instance"
6
-      Metadata:
7
-        AWS::CloudFormation::Init:
8
-          config:
9
-            packages:
10
-              :
11
-            groups:
12
-              :
13
-            users:
14
-              :
15
-            sources:
16
-              :
17
-            files:
18
-              :
19
-            commands:
20
-              - "sudo apt-get install software-properties-common"
21
-              - "sudo add-apt-repository -y ppa:ethereum/ethereum"
22
-              - "sudo apt-get update"
23
-              - "sudo apt-get install ethereum"
24
-            services:
25
-              :
26
-      Properties:
27
-        ImageId: ami-785db401
28
-        InstanceType: t2.micro
29
-        KeyName: decode-app-ec2
30
-        Tags:
31
-          - Key: Name
32
-            Value: Nodes

+ 0 - 20
apps/petitions/ethereum/nodes/genesis791.json

@@ -1,20 +0,0 @@
1
-{
2
-    "config": {
3
-        "chainId": 791,
4
-        "homesteadBlock": 0,
5
-        "eip150Block": 0,
6
-        "eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
7
-        "eip155Block": 0,
8
-        "eip158Block": 0
9
-    },
10
-    "nonce": "0x0000000000000791",
11
-    "timestamp": "0x00",
12
-    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
13
-    "extraData": "0x00",
14
-    "gasLimit": "0x4c4b40",
15
-    "difficulty": "0x0400",
16
-    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
17
-    "coinbase": "0x0000000000000000000000000000000000000000",
18
-    "alloc": {
19
-    }
20
-}

+ 0 - 131
apps/petitions/ethereum/nodes/go.sh

@@ -1,131 +0,0 @@
1
-#!/bin/bash
2
-
3
-set -ex
4
-
5
-BASE_PORT="3030"
6
-BASE_RPC_PORT="810"
7
-NETWORK_ID="791"
8
-APP_CORS_DOMAIN="http://localhost:8000"
9
-NODE_A="0"
10
-NODE_B="1"
11
-
12
-init() {
13
-  echo "Initialising node $NODE in directory '$PWD'"
14
-  geth --datadir $PWD/$NODE init $PWD/genesis791.json
15
-}
16
-
17
-start() {
18
-  NODE=$1
19
-  init
20
-  PORT=$BASE_PORT$NODE
21
-  RPC_PORT=$BASE_RPC_PORT$NODE
22
-  echo "Starting node $NODE"
23
-  geth --datadir $PWD/$NODE --port $PORT --rpc --rpcport $RPC_PORT --networkid $NETWORK_ID --nodiscover --verbosity 5 --rpccorsdomain $APP_CORS_DOMAIN --ipcpath $PWD/$NODE/geth.ipc > $PWD/$NODE/output.log 2>&1 &
24
-  wait_for_node
25
-}
26
-
27
-deploy() {
28
-  tar -zcvf nodes_snapshot.tar.gz --exclude 'geth' --exclude '*.ipc' --exclude '*.log' .
29
-  scp nodes_snapshot.tar.gz ubuntu@ec2-54-154-185-204.eu-west-1.compute.amazonaws.com:~
30
-  ssh ubuntu@ec2-54-154-185-204.eu-west-1.compute.amazonaws.com "rm -rf nodes; mkdir nodes; tar -zxvf nodes_snapshot.tar.gz -C nodes"
31
-  ssh ubuntu@ec2-54-154-185-204.eu-west-1.compute.amazonaws.com "cd nodes; ./go.sh stop-nodes; ./go.sh start-nodes"
32
-}
33
-
34
-console() {
35
-  geth attach $PWD/$NODE/geth.ipc
36
-}
37
-
38
-start_nodes() {
39
-  start $NODE_A
40
-  start $NODE_B
41
-  add_peer $NODE_A $NODE_B
42
-}
43
-
44
-start_mining() {
45
-  if geth --datadir $PWD/$NODE_A account list | grep -q "Account #"; then
46
-    echo "Account exists"
47
-  else
48
-    echo "No accounts found. Creating a new account"
49
-    create_account
50
-  fi
51
-
52
-  echo "Beginning mining"
53
-  sleep 1
54
-  ADDRESS=$(geth attach $PWD/$NODE_A/geth.ipc --exec "eth.accounts[0]")
55
-  geth attach $PWD/$NODE_A/geth.ipc --exec "miner.setEtherbase($ADDRESS)"
56
-  geth attach $PWD/$NODE_A/geth.ipc --exec "miner.start(1)"
57
-}
58
-
59
-wait_for_node() {
60
-  ATTEMPTS=20
61
-  while :
62
-  do
63
-    status=$(curl -w "%{http_code}\n" http://localhost:${RPC_PORT} -s || true)
64
-    if [ ${status} == 200 ]; then
65
-      echo "Node ${NODE} is running fine"
66
-      break;
67
-    fi
68
-    ((ATTEMPTS++))
69
-    if [ ${ATTEMPTS} == 15 ]; then
70
-      echo "The node ${NODE} is still not available"
71
-      echo "Exiting"
72
-      exit 1
73
-    fi
74
-    sleep 1
75
-  done
76
-}
77
-
78
-add_peer() {
79
-  PARENT=$1
80
-  CHILD=$2
81
-  echo "Adding node $CHILD to node $PARENT"
82
-  CHILD_ENODE=$(geth attach $PWD/$CHILD/geth.ipc --exec "admin.nodeInfo.enode")
83
-  geth attach $PWD/$PARENT/geth.ipc --exec "admin.addPeer($CHILD_ENODE)"
84
-}
85
-
86
-stop_nodes() {
87
-  pkill -f geth
88
-}
89
-
90
-usage() {
91
-  echo "Usage:"
92
-  echo "start-nodes      : starts a 2 node private network with 1 node mining"
93
-  echo "stop-nodes       : stops the nodes"
94
-  echo "start-mining     : starts mining"
95
-  echo "console <0, 1>   : attaches a js console to the node"
96
-}
97
-
98
-create_account() {
99
-  { echo $PASS ; echo $PASS; } | geth --datadir $PWD/$NODE_A account new
100
-    echo "New account created. Your accounts: $(geth --datadir $PWD/$NODE_A account list)"
101
-}
102
-
103
-check_validity(){
104
-  if [ -z "$PASS" ]; then
105
-      echo "Need to set an Ethereum wallet password"
106
-      exit 1
107
-  fi
108
-}
109
-
110
-OPTION="$1"
111
-  case $OPTION in
112
-    start-nodes)
113
-      start_nodes
114
-      ;;
115
-    console)
116
-      NODE=$2
117
-      console
118
-      ;;
119
-    stop-nodes)
120
-      stop_nodes
121
-      ;;
122
-    deploy)
123
-      deploy
124
-      ;;
125
-    start-mining)
126
-      check_validity
127
-      start_mining
128
-      ;;
129
-    *)
130
-    usage
131
-  esac

+ 0 - 10
apps/petitions/ethereum/nodes/nodes.iml

@@ -1,10 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<module type="WEB_MODULE" version="4">
3
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
4
-    <exclude-output />
5
-    <option name="createStubs" value="true" />
6
-    <content url="file://$MODULE_DIR$" />
7
-    <orderEntry type="inheritedJdk" />
8
-    <orderEntry type="sourceFolder" forTests="false" />
9
-  </component>
10
-</module>

BIN
apps/petitions/ethereum/nodes/nodes_snapshot.tar.gz


+ 0 - 1
apps/petitions/ethereum/nodes/truffle-account.txt

@@ -1 +0,0 @@
1
-password

+ 0 - 29
apps/petitions/petitions-app/go.sh

@@ -18,36 +18,10 @@ start_petition_services() {
18 18
     echo "Failed to start Decode app"
19 19
     exit 1
20 20
   fi
21
-
22
-  pushd ../ethereum/node-api && ./go.sh start && popd
23
-  if [ $? -ne 0 ]; then
24
-    echo "Failed to start Node API"
25
-    exit 1
26
-  fi
27
-}
28
-
29
-start_prototype() {
30
-#  pushd ../../atlantis && npm start && npm run webpack && popd &
31
-#  if [ $? -ne 0 ]; then
32
-#    echo "Failed to start Atlantis app"
33
-#    exit 1
34
-#  fi
35
-#
36
-#  pushd ../../neptune-id && npm start && npm run webpack && popd
37
-#  if [ $? -ne 0 ]; then
38
-#    echo "Failed to start Neptune ID app"
39
-#    exit 1
40
-#  fi
41
-
42
-  start &
43
-  start_petition_services &
44
-#  pushd ../../atlantis && npm start && npm run webpack && popd &
45
-#  pushd ../../neptune-id && npm start && npm run webpack && popd &
46 21
 }
47 22
 
48 23
 kill_services() {
49 24
   pushd ../decode-app && ./go.sh stop && popd
50
-  pushd ../ethereum/node-api && ./go.sh stop && popd
51 25
 }
52 26
 
53 27
 e2e() {
@@ -87,9 +61,6 @@ OPTION="$1"
87 61
     start-services)
88 62
       start_petition_services
89 63
       ;;
90
-    start-prototype)
91
-      start_prototype
92
-      ;;
93 64
     stop)
94 65
       kill_services
95 66
       ;;

+ 2 - 2
apps/wallet-proxy/test/routes_test.py

@@ -41,7 +41,7 @@ class RoutesTestCase(unittest.TestCase):
41 41
         self.petition_mock.increment.return_value = {"success": True, "outcome": "accepted_t_commit"}
42 42
         petition_func_mock.return_value = self.petition_mock
43 43
 
44
-        request_body = json.dumps({'signatory': 'someone', 'isEthereum': 'false', 'vote': 'Yes', 'gender': 'female', 'age': '0-19'})
44
+        request_body = json.dumps({'signatory': 'someone', 'vote': 'Yes', 'gender': 'female', 'age': '0-19'})
45 45
 
46 46
         response = self.app.post('/sign/petitions/1', data=request_body)
47 47
 
@@ -52,7 +52,7 @@ class RoutesTestCase(unittest.TestCase):
52 52
         self.petition_mock.increment.side_effect = Exception("Boom")
53 53
         petition_func_mock.return_value = self.petition_mock
54 54
 
55
-        request_body = json.dumps({'signatory': 'someone', 'isEthereum': 'false', 'vote': 'Yes', 'gender': 'female', 'age': '0-19'})
55
+        request_body = json.dumps({'signatory': 'someone', 'vote': 'Yes', 'gender': 'female', 'age': '0-19'})
56 56
 
57 57
         response = self.app.post('/sign/petitions/1', data=request_body)
58 58
 

+ 0 - 1
apps/wallet/application/redux/actions/petition.js

@@ -55,7 +55,6 @@ export function signPetition(petition, walletId, walletProxyLink, vote, age, gen
55 55
     },
56 56
     body: JSON.stringify({
57 57
       signatory: walletId.substring(0, 5),
58
-      isEthereum: petition.isEthereum,
59 58
       vote,
60 59
       age,
61 60
       gender,

+ 0 - 3
apps/wallet/test/acceptance/sign.test.js

@@ -57,7 +57,6 @@ describe('signing a petition', () => {
57 57
           description: 'world',
58 58
           closingDate: 'today',
59 59
           id: '1234',
60
-          isEthereum: 'false',
61 60
         },
62 61
       },
63 62
       attributes: {
@@ -95,7 +94,6 @@ describe('signing a petition', () => {
95 94
           description: 'world',
96 95
           closingDate: 'today',
97 96
           id: '1234',
98
-          isEthereum: 'false',
99 97
         },
100 98
       },
101 99
       attributes: {
@@ -135,7 +133,6 @@ describe('signing a petition', () => {
135 133
       description: 'world',
136 134
       closingDate: 'today',
137 135
       id: '1234',
138
-      isEthereum: 'false',
139 136
     };
140 137
     const state = {
141 138
       ...initialState,

+ 0 - 1
apps/wallet/test/snapshot/PetitionSummary.test.js

@@ -19,7 +19,6 @@ const initialState = {
19 19
       description: 'world',
20 20
       closingDate: 'today',
21 21
       id: '1234',
22
-      isEthereum: 'false',
23 22
     },
24 23
   },
25 24
   wallet: {

+ 0 - 2
apps/wallet/test/snapshot/__snapshots__/PetitionSummary.test.js.snap

@@ -36,7 +36,6 @@ ShallowWrapper {
36 36
         "closingDate": "today",
37 37
         "description": "world",
38 38
         "id": "1234",
39
-        "isEthereum": "false",
40 39
         "title": "hello",
41 40
       }
42 41
     }
@@ -1297,7 +1296,6 @@ ShallowWrapper {
1297 1296
         "closingDate": "today",
1298 1297
         "description": "world",
1299 1298
         "id": "1234",
1300
-        "isEthereum": "false",
1301 1299
         "title": "hello",
1302 1300
       }
1303 1301
     }

+ 0 - 3
apps/wallet/test/unit/application/redux/actions/petition.test.js

@@ -23,7 +23,6 @@ describe('getPetition', () => {
23 23
     const newPetition = {
24 24
       petition: {
25 25
         id: '2',
26
-        isEthereum: 'true',
27 26
       },
28 27
     };
29 28
     const response = newPetition;
@@ -64,7 +63,6 @@ describe('signPetition', () => {
64 63
 
65 64
   const petition = {
66 65
     id: 1,
67
-    isEthereum: false,
68 66
   };
69 67
   const walletId = '1234567890';
70 68
   const walletProxyLink = 'wallet-proxy-link.com';
@@ -87,7 +85,6 @@ describe('signPetition', () => {
87 85
 
88 86
     const expectedRequestBody = JSON.stringify({
89 87
       signatory: walletId.substring(0, 5),
90
-      isEthereum: petition.isEthereum,
91 88
       vote,
92 89
       age: '0-19',
93 90
       gender: 'undisclosed',