Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ test/unit/coverage
test/e2e/reports
selenium-debug.log


build/contracts/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


TODO
THOUGHTS

# Editor directories and files
.idea
*.suo
Expand Down
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

Initial scaffolding thanks to: https://github.com/wespr/truffle-vue

1. Install [Truffle](http://truffleframework.com) and an Ethereum client - like [EthereumJS TestRPC](https://github.com/ethereumjs/testrpc). Note I couldn't get this to work on our VMs so I installed them directly on the Mac.
1. Install [Truffle](http://truffleframework.com) and an Ethereum client - like [Ganache-cli](https://github.com/trufflesuite/ganache-cli).
```
[sudo] npm install -g truffle // Version 3.0.5+ required.
[sudo] npm install -g ethereumjs-testrpc
[sudo] npm install -g ganache-cli

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsaur what do you think about us defaulting to ganache? seems useful. @johnbayne You've found ganache really useful for getting up to speed, right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, it seems like there's not much of a difference but that ganache is what truffle is going with now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderintherye @jsaur Yes, absolutely. TestRPC redirects to ganache-cli these days - I think ganache has officially superseded it.

Last week we used ganache as opposed to ganache-cli, the above recommends the CLI. Same backend, less mouseclicks, more portability.

```

2. Pull down the repo and install dependancies
2. Pull down the repo and install dependencies
```
git clone https://github.com/jsaur/lending-dapp
npm install
```

3. Launch [`testrpc`](https://github.com/ethereumjs/testrpc) in it's own command prompt tab.
3. Launch [`ganache-cli`](https://github.com/trufflesuite/ganache-cli) in its own command prompt tab. Default settings should work out of the box, no <options> args required
```
testrpc <options>
ganache-cli <options>
```

4. Compile and migrate the contracts.
Expand All @@ -27,11 +27,29 @@ Initial scaffolding thanks to: https://github.com/wespr/truffle-vue
truffle migrate
```

4. Run the webpack server for front-end hot reloading. Smart contract changes do not support hot reloading for now.
5. Install [go-ipfs](https://dist.ipfs.io/#go-ipfs) and initialize by running
```
sudo ./install.sh
ipfs init
```
6. You will need to allow cross-origin resource sharing (CORS) for the ipfs API
to work. For local testing, add localhost:8080
```
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://localhost:8080\"]"
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]"
```

7. Start the ipfs daemon in its own command prompt tab with
```
ipfs daemon
```

8. Run the webpack server for front-end hot reloading. Smart contract changes do not support hot reloading for now.
```
npm run start
```

## Tests
This box comes with everything bundled for `unit`, `e2e` and `truffle` contracts testing. The tests are incomplete at the moment.

Expand Down Expand Up @@ -60,9 +78,9 @@ npm run build

1. Install Metamask in your browser: https://metamask.io/

2. Change network to: Localhost 8545
2. Change network to: 127.0.0.1:8545

3. When you started testrpc, it should have printed out a list of available accounts and private keys. Copy one of the private keys.
3. When you started ganache-cli, it should have printed out a list of available accounts and private keys. Copy one of the private keys.

4. In meta mask, click the circular arrows, then "Import Account", then paste the private key. Now you can spend your test accounts ether.

Expand Down
21,933 changes: 14,239 additions & 7,694 deletions build/contracts/LoanContract.json

Large diffs are not rendered by default.

3,642 changes: 2,360 additions & 1,282 deletions build/contracts/LoanFactory.json

Large diffs are not rendered by default.

1,943 changes: 1,253 additions & 690 deletions build/contracts/Migrations.json

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions contracts/LoanContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ contract LoanContract {
uint public repaymentDuration;
uint public fundRaisingDeadline;
uint public repaymentDeadline;
string public name;
string public use;
string public ipfsHash;

//Useful vars
uint public amountRaised;
Expand Down Expand Up @@ -49,16 +48,14 @@ contract LoanContract {
uint _loanAmountInEthers,
uint _fundRaisingDurationInDays,
uint _repaymentDurationInDays,
string _name,
string _use
string _ipfsHash
) public {
borrowerAddress = _borrowerAddress;
loanAmount = _loanAmountInEthers * 1 ether;
repaymentDuration = _repaymentDurationInDays;
fundRaisingDeadline = now + _fundRaisingDurationInDays * 1 days;
repaymentDeadline = fundRaisingDeadline + _repaymentDurationInDays * 1 days;
name = _name;
use = _use;
ipfsHash = _ipfsHash;
// For now just do a single scheduled payment at the end
schedule.push(PaymentEntry(repaymentDeadline, loanAmount));
}
Expand Down Expand Up @@ -197,4 +194,4 @@ contract LoanContract {
function isDelinquent() public view returns (bool) {
return (now >= repaymentDeadline && currentState != State.repaid);
}
}
}
8 changes: 3 additions & 5 deletions contracts/LoanFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ contract LoanFactory {
function create (
uint _loanAmountInEthers,
uint _repaymentDurationInDays,
string _name,
string _use
string _ipfsHash
) public returns(address _loanAddress) {
address borrowerAddress = msg.sender;
uint fundRaisingDurationInDays = 30; //default to 30 for now
Expand All @@ -32,13 +31,12 @@ contract LoanFactory {
_loanAmountInEthers,
fundRaisingDurationInDays,
_repaymentDurationInDays,
_name,
_use
_ipfsHash
);
loans.push(newLoanContract);
borrowers.push(borrowerAddress);
borrowerLoanIndex[borrowerAddress] = newLoanContract;
LoanCreated(newLoanContract, borrowerAddress);
return newLoanContract;
}
}
}
Loading