Skip to content

Commit 0cc761a

Browse files
committed
finish 02
1 parent 3a04c1e commit 0cc761a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+116
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
build
1+
build/
22
.idea
33
.DS_Store
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pragma solidity ^0.4.4;
2+
3+
contract HelloEthSalon {
4+
string message = "Hello Ethereum Salon!";
5+
6+
function HelloEthSalon() {
7+
// constructor
8+
}
9+
10+
function GetMessage() returns (string) {
11+
return message;
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity ^0.4.17;
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() public {
12+
owner = msg.sender;
13+
}
14+
15+
function setCompleted(uint completed) public restricted {
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) public restricted {
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var Migrations = artifacts.require("./Migrations.sol");
2+
var HelloEthSalon = artifacts.require('./HelloEthSalon.sol');
3+
4+
module.exports = function(deployer) {
5+
deployer.deploy(Migrations);
6+
deployer.deploy(HelloEthSalon);
7+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var HelloEthSalon = artifacts.require("./HelloEthSalon.sol");
2+
3+
contract("HelloEthSalon:GetMessage", function (accounts) {
4+
it("should return a correct string", async function () {
5+
const contract = await HelloEthSalon.deployed();
6+
const result = await contract.GetMessage.call();
7+
assert.isTrue(result === "Hello Ethereum Salon!");
8+
});
9+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
// See <http://truffleframework.com/docs/advanced/configuration>
3+
// to customize your Truffle configuration!
4+
};
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pragma solidity ^0.4.4;
2+
3+
contract HelloEthSalon {
4+
string message = "Hello Ethereum Salon!";
5+
6+
function HelloEthSalon() {
7+
// constructor
8+
}
9+
10+
function GetMessage() returns (string) {
11+
return message;
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity ^0.4.17;
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() public {
12+
owner = msg.sender;
13+
}
14+
15+
function setCompleted(uint completed) public restricted {
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) public restricted {
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}

0 commit comments

Comments
 (0)