This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI pipeline, linting, tests (#20)
* Added Travis configuration * Added linting configuration (and fixed linting issues) * Added `docs/` folder * Added tests for most methods
- Loading branch information
Showing
22 changed files
with
17,689 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
"env": { | ||
"mocha": true, | ||
}, | ||
"extends": "airbnb-base", | ||
"rules": { | ||
"no-console": "off", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "8" | ||
- "10" | ||
|
||
script: | ||
- npm run lint | ||
- npm run test | ||
|
||
after_success: | ||
- npm run coverage | ||
|
||
notifications: | ||
email: | ||
roscokalis+travis@gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
pragma solidity ^0.4.23; | ||
|
||
contract Casino { | ||
address public owner; | ||
|
||
event Play(address indexed player, uint256 betSize, uint8 betNumber, uint8 winningNumber); | ||
event Payout(address winner, uint256 payout); | ||
|
||
constructor() public { | ||
owner = msg.sender; | ||
} | ||
|
||
function kill() external { | ||
require(msg.sender == owner, "Only the owner can kill this contract"); | ||
selfdestruct(owner); | ||
} | ||
|
||
function fund() external payable {} | ||
|
||
function bet(uint8 number) external payable { | ||
require(msg.value <= getMaxBet(), "Bet amount can not exceed max bet size"); | ||
require(msg.value > 0, "A bet should be placed"); | ||
|
||
uint8 winningNumber = generateWinningNumber(); | ||
emit Play(msg.sender, msg.value, number, winningNumber); | ||
|
||
if (number == winningNumber) { | ||
payout(msg.sender, msg.value * 10); | ||
} | ||
} | ||
|
||
function getMaxBet() public view returns (uint256) { | ||
return address(this).balance / 100; | ||
} | ||
|
||
function generateWinningNumber() internal view returns (uint8) { | ||
return uint8(block.number % 10 + 1); // Don't do this in production | ||
} | ||
|
||
function payout(address winner, uint256 amount) internal { | ||
assert(amount > 0); | ||
assert(amount <= address(this).balance); | ||
|
||
winner.transfer(amount); | ||
emit Payout(winner, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pragma solidity ^0.4.23; | ||
|
||
contract Migrations { | ||
address public owner; | ||
uint public last_completed_migration; | ||
|
||
modifier restricted() { | ||
if (msg.sender == owner) _; | ||
} | ||
|
||
constructor() public { | ||
owner = msg.sender; | ||
} | ||
|
||
function setCompleted(uint completed) public restricted { | ||
last_completed_migration = completed; | ||
} | ||
|
||
function upgrade(address new_address) public restricted { | ||
Migrations upgraded = Migrations(new_address); | ||
upgraded.setCompleted(last_completed_migration); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
docs/kalis-me-tutorial-code/migrations/1_initial_migration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var Migrations = artifacts.require("./Migrations.sol"); | ||
|
||
module.exports = function(deployer) { | ||
deployer.deploy(Migrations); | ||
}; |
Oops, something went wrong.