Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
add truffle infrastructure files
Browse files Browse the repository at this point in the history
- includes docker, though we recommend running natively for now
- helper scripts, specifically scripts/testrpc.sh
  which is required for running tests
  • Loading branch information
oryband committed Sep 5, 2017
1 parent 77c52dc commit ad312eb
Show file tree
Hide file tree
Showing 16 changed files with 8,104 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
@@ -0,0 +1,16 @@
FROM node:8

RUN mkdir /code
WORKDIR /code
COPY package-lock.json .
COPY package.json .

RUN apt-get -qq update \
&& apt-get -qq install netcat \
&& apt-get clean && rm -rf /var/lib/apt/lists /tmp/* /var/tmp/* \
&& npm install -q

ENV PATH="/code/node_modules/.bin:${PATH}"
VOLUME ["/code"]
EXPOSE 8545
CMD ["truffle"]
57 changes: 57 additions & 0 deletions Makefile
@@ -0,0 +1,57 @@

default: ;
.DEFAULT_GOAL: default

run_truffle := docker-compose run --rm truffle

compile:
$(run_truffle) truffle compile
.PHONY: compile

test:
$(run_truffle) npm test
.PHONY: test

test-long:
docker-compose run --rm -e LONG_TESTS=1 truffle npm test
.PHONY: test-long

coverage:
$(run_truffle) npm run-script coverage
.PHONY: coverage

codecov:
$(run_truffle) npm run-script codecov
.PHONY: codecov

migrate:
$(run_truffle) truffle migrate
.PHONY: migrate

console:
$(run_truffle) npm run-script console
.PHONY: console

testrpc:
$(run_truffle) npm run-script testrpc
.PHONY: testrpc

build:
docker-compose build
.PHONY: build

log:
docker-compose logs
.PHONY: log

sh:
$(run_truffle) sh
.PHONY: sh

down:
docker-compose down -v
.PHONY: down

clean: down
docker-compose down --rmi all
.PHONY: clean
27 changes: 27 additions & 0 deletions contracts/Migrations.sol
@@ -0,0 +1,27 @@
pragma solidity ^0.4.15;

contract Migrations {
address public owner;
uint public lastCompletedMigration;

modifier restricted() {
if (msg.sender != owner) {
revert();
}

_;
}

function Migrations() {
owner = msg.sender;
}

function setCompleted(uint completed) restricted {
lastCompletedMigration = completed;
}

function upgrade(address new_address) restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(lastCompletedMigration);
}
}
19 changes: 19 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,19 @@
version: "3"

services:
truffle:
image: kikinteractive/truffle
build:
context: .
volumes:
- ./contracts:/code/contracts
- ./coverage:/code/coverage
- ./build:/code/build
- ./migrations:/code/migrations
- ./scripts:/code/scripts
- ./test:/code/test
- ./truffle.js:/code/truffle.js
- ./.babelrc:/code/.babelrc
- ./.solcover.js:/code/.solcover.js
- ./.git:/code/.git

5 changes: 5 additions & 0 deletions migrations/1_initial_migration.js
@@ -0,0 +1,5 @@
const Migrations = artifacts.require('./Migrations.sol');

module.exports = (deployer) => {
deployer.deploy(Migrations);
};
14 changes: 14 additions & 0 deletions migrations/2_deploy_contracts.js
@@ -0,0 +1,14 @@
const SafeMath = artifacts.require('./SafeMath.sol');
const Ownable = artifacts.require('./Ownable.sol');

const KinToken = artifacts.require('./KinToken.sol');

module.exports = (deployer) => {
deployer.deploy(SafeMath);
deployer.deploy(Ownable);

deployer.link(Ownable, KinToken);
deployer.link(SafeMath, KinToken);

deployer.deploy(KinToken);
};

0 comments on commit ad312eb

Please sign in to comment.