Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into issue-#10
Browse files Browse the repository at this point in the history
# Conflicts:
#	frontend/src/ui/BankAccountList.js
  • Loading branch information
garatortiz committed Jul 4, 2018
2 parents c79e104 + da256e3 commit 3423339
Show file tree
Hide file tree
Showing 20 changed files with 4,643 additions and 168 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"jest": false,
"describe": false,
"it": false,
"expect": false
"expect": false,
"contract": false,
"assert": false
}
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js

script:
- npm run lint
- npm run --prefix=blockchain coverage
- npm test

after_success:
Expand Down
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,53 @@
[![dependencies Status](https://david-dm.org/poanetwork/poa-poba/status.svg)](https://david-dm.org/poanetwork/poa-poba)
[![devDependencies Status](https://david-dm.org/poanetwork/poa-poba/dev-status.svg)](https://david-dm.org/poanetwork/poa-poba?type=dev)

## Development environment

After cloning the repo, run `npm run ganache` in one terminal. Leave it open
and, in another one, run:
## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites
What things you need to do previous to install
- Create a sandbox account on plaid.com, we need some information, for example:
```
PLAID_CLIENT_ID=1234565b16d38dd9e9b00013178296
PLAID_SECRET=12345672352d3da02e112fe290e1e8fd2085
PLAID_PUBLIC_KEY=123456e1e61319a1192b80bd5d09e7c5ac35
```

### Installing

A step by step series that tell you how to get a development env running

- Clone the repository and move to the directory where we cloned the repository
```
$ git clone git@github.com:poanetwork/poa-poba.gitt
$ cd poa-poba
```

- Install npm dependencies
```
$ npm install
```

- Move to the server folder, copy the file .env.example to .env, and add the plaid information related to the API
```
$ cd server
$ cp .env.example .env
```

- Move to the frontend folder, copy the file .env.example to .env, and add the plaid information related to the API
```
$ cd frontend
$ cp .env.example .env
```

- In another terminal, move to the directory where we cloned the repository and run the following command
```
$ npm run ganache
```

- In the previous terminal, run the following command
```
npm install
npm run dev
$ npm run dev
```
3 changes: 3 additions & 0 deletions blockchain/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/build/contracts/*
!/build/contracts/PoBA.json

coverage/
coverage.json
60 changes: 52 additions & 8 deletions blockchain/contracts/PoBA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,75 @@ contract PoBA {
address public owner;
address public signer;

mapping (address => string[]) public accounts;

constructor() {
constructor() public {
owner = msg.sender;
signer = owner;
}

struct BankAccount {
string accountNumber;
string bankName;
uint256 attestationDate;
bool attestationFact;

uint256 creationBlock;
}

struct User {
uint256 creationBlock;
BankAccount[] bankAccounts;
}

mapping (address => User) public users;

function signerIsValid(bytes32 data, uint8 v, bytes32 r, bytes32 s)
public constant returns (bool)
{
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixed = keccak256(prefix, data);
bytes32 prefixed = keccak256(abi.encodePacked(prefix, data));
return (ecrecover(prefixed, v, r, s) == signer);
}

function register(string account, uint8 v, bytes32 r, bytes32 s) {
function userExists(address wallet)
public view returns (bool)
{
return (users[wallet].creationBlock > 0);
}

function register(
string account,
string institution,
uint8 v, bytes32 r, bytes32 s) public {

require(bytes(account).length > 0);
require(bytes(institution).length > 0);
require(users[msg.sender].bankAccounts.length < 2**256-1);

if (!userExists(msg.sender)) {
// new user
users[msg.sender].creationBlock = block.number;
}

BankAccount memory ba;

ba.accountNumber = account;
ba.bankName = institution;
ba.attestationDate = now;
ba.attestationFact = true;
ba.creationBlock = block.number;

bytes32 hash = keccak256(msg.sender, account);
bytes32 hash = keccak256(
abi.encodePacked(
msg.sender,
ba.accountNumber,
ba.bankName
));
require(signerIsValid(hash, v, r, s));

accounts[msg.sender].push(account);
users[msg.sender].bankAccounts.push(ba);
}

function accountsLength(address _address) public constant returns (uint256) {
return accounts[_address].length;
return users[_address].bankAccounts.length;
}
}
Loading

0 comments on commit 3423339

Please sign in to comment.