Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] improve the project in several aspects #3

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/src/built-contracts
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"cSpell.words": [
"Unstake",
"bignumber",
"borderless",
"browserslist",
"defi",
"identicon",
"noopener",
"noreferrer",
"stakers",
"unstaking"
]
}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# DeFi Demo

DApp developed using the following tech stacks:

- React.js (CRA)
- Smart Contracts (Solidity)
- Truffle
- Ganache
- Web3.js
- Automated Tests using Mocha and Chai


## Quick setup and running

- Install node in the local (Node version is v12.18.3 and if possible, use the same version for compatibility).
- Download Ganache from https://www.trufflesuite.com/ganache and install it in the local.
- Run Ganache in the local.

``` bash
$ npm install --g [email protected] # If possible, use the same version for compatibility

$ npm install # Or yarn install
$ npm run truffle-compile # Compile smart contracts
$ npm run truffle-migrate # (Or npm run truffle-migrate-reset) Deploy the compiled smart contracts
$ npm run truffle-test # Run the automated tests to make sure of the behaviors of the smart contracts
$ npm start # Run the UI website

$ npm run truffle-issue-dapp-tokens # Issue Dapp tokens to the stakers
```
3 changes: 2 additions & 1 deletion migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Migrations = artifacts.require("Migrations");

const Migrations = artifacts.require('Migrations');

module.exports = function(deployer) {
deployer.deploy(Migrations);
Expand Down
27 changes: 14 additions & 13 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
const DappToken = artifacts.require('DappToken')
const DaiToken = artifacts.require('DaiToken')
const TokenFarm = artifacts.require('TokenFarm')

const DappToken = artifacts.require('DappToken');
const DaiToken = artifacts.require('DaiToken');
const TokenFarm = artifacts.require('TokenFarm');

module.exports = async function(deployer, network, accounts) {
// Deploy Mock DAI Token
await deployer.deploy(DaiToken)
const daiToken = await DaiToken.deployed()
await deployer.deploy(DaiToken);
const daiToken = await DaiToken.deployed();

// Deploy Dapp Token
await deployer.deploy(DappToken)
const dappToken = await DappToken.deployed()
await deployer.deploy(DappToken);
const dappToken = await DappToken.deployed();

// Deploy TokenFarm
await deployer.deploy(TokenFarm, dappToken.address, daiToken.address)
const tokenFarm = await TokenFarm.deployed()
await deployer.deploy(TokenFarm, dappToken.address, daiToken.address);
const tokenFarm = await TokenFarm.deployed();

// Transfer all tokens to TokenFarm (1 million)
await dappToken.transfer(tokenFarm.address, '1000000000000000000000000')
await dappToken.transfer(tokenFarm.address, '1000000000000000000000000');

// Transfer 100 Mock DAI tokens to investor
await daiToken.transfer(accounts[1], '100000000000000000000')
}
// Transfer 100 Mock DAI tokens to investor (assume that accounts[0] => owner, accounts => investor)
await daiToken.transfer(accounts[1], '100000000000000000000');
};
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "0.1.0",
"description": "DeFi Token Staking App",
"author": "[email protected]",
"contributors": [
"[email protected]",
"Anton K. <[email protected]>"
],
"dependencies": {
"babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0",
Expand All @@ -26,7 +30,13 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"truffle-compile": "truffle compile",
"truffle-migrate": "truffle migrate",
"truffle-migrate-reset": "truffle migrate --reset",
"truffle-console": "truffle console",
"truffle-test": "truffle test",
"truffle-issue-dapp-tokens": "truffle exec scripts/issue-dapp-tokens.js"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
10 changes: 10 additions & 0 deletions scripts/issue-dapp-tokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

const TokenFarm = artifacts.require('TokenFarm');

module.exports = async function(callback) {
const tokenFarm = await TokenFarm.deployed();
await tokenFarm.issueDappTokens();
// Code goes here...
console.log('Tokens issued!');
callback();
};
9 changes: 0 additions & 9 deletions scripts/issue-token.js

This file was deleted.

4,978 changes: 0 additions & 4,978 deletions src/abis/DaiToken.json

This file was deleted.

4,978 changes: 0 additions & 4,978 deletions src/abis/DappToken.json

This file was deleted.

Loading