Skip to content

Commit

Permalink
Merge pull request #3 from ChronoBank/release/release-0.2.2
Browse files Browse the repository at this point in the history
Release/release 0.2.2
  • Loading branch information
Alex Rudyak committed Jul 16, 2018
2 parents 649af3d + 5b246e4 commit 13b7acb
Show file tree
Hide file tree
Showing 22 changed files with 11,380 additions and 504 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/*
contracts/*
node_modules/*
.*
*.json
truffle*
coverage/
64 changes: 64 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = {
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"es6": true,
"node": true,
"mocha": true,
},
"globals": {
"web3": false,
"artifacts": false,
"assert": false,
"contract": false,
},
"rules": {
"indent": ["error", "tab"],

"comma-dangle": ["error", "always"],
"no-cond-assign": ["error", "always"],
"no-await-in-loop": "off",
"block-scoped-var": "error",
"curly": "error",
"eqeqeq": ["error", "always"],
"no-alert": "error",
"no-else-return": ["error", { "allowElseIf": true }],
"no-magic-numbers": ["warn", { "ignoreArrayIndexes": true }],
"no-multi-spaces": ["error", { "exceptions": { "Property": true }}],
"no-restricted-syntax": ["error", "SequenceExpression"],
"no-useless-return": "warn",
"require-await": "warn",
"vars-on-top": "off",
"no-unused-vars": "warn",
"yoda": "error",

"global-require": "error",
"array-bracket-spacing": ["error", "always", { "singleValue": false, "objectsInArrays": false }],
"block-spacing": ["error", "always"],
"brace-style": ["error", "stroustrup", { "allowSingleLine": false }],
"camelcase": ["error", { "properties": "never" }],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
"keyword-spacing": ["error", { "before": true, "after": true }],
"no-lonely-if": "error",
"no-negated-condition": "error",
"no-trailing-spaces": "error",
"no-whitespace-before-property": "error",
"object-curly-newline": ["error", { "multiline": true, "minProperties": 4 }],
"object-curly-spacing": ["error", "always"],
"object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }],
"quote-props": ["warn", "as-needed", { "keywords": true, "numbers": true }],

"semi": ["error", "never"],

"arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",

"no-duplicate-imports": "error",
"prefer-const": "error",

"no-undef": "warn",
"no-empty": "warn",

"no-console": "off"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules/

*.log
*.bac

coverage/
coverage.json
21 changes: 19 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
*.log
*.bac
npm-debug.log

build/
migrations/
test/
ethpm.json
migrations/
ethpm.json
.travis.yml
.solcover*
.gitattributes
.es*
.solium*
truffle*
truffle.js

contracts/Migrations.sol
contracts/stub/

coverage/
coverage.json
9 changes: 9 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
copyNodeModules: true,
skipFiles: [
'Migrations.sol',
'ERC20Interface.sol',
'stub/StubToken.sol',
'stub/StubOwned.sol',
]
}
5 changes: 5 additions & 0 deletions .soliumignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
test
setup
build
coverage
24 changes: 24 additions & 0 deletions .soliumrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "solium:recommended",
"plugins": [
"security"
],
"rules": {
"quotes": [
"error",
"double"
],
"indentation": [
"error",
4
],
"security/no-low-level-calls": [
"error", [
"callcode"
]
],
"max-line-length": "off",
"security/no-assign-params": "off",
"security/no-inline-assembly": "warning"
}
}
43 changes: 13 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
sudo: false
sudo: required
dist: trusty
language: node_js
node_js: 8
node_js:
- '9'
before_install:
- export PATH=$PATH:$(pwd)/node_modules/.bin
- git config --global user.email "mike@chronobank.com"
- git config --global user.name "Travis-CI"
- export NODE_OPTIONS="--max_old_space_size=4096"
- export PATH=$PATH:$(pwd)/node_modules/.bin
install:
- npm install
script:
- ganache-cli -g 1 --network-id 424242 > /dev/null &
- truffle migrate --network test
- truffle test --network test --clear

# - if [ "$TRAVIS_BRANCH" == "release" ]; then
# git config credential.helper "store --file=.git/credentials";
# echo "https://${GH_TOKEN}:@github.com" > .git/credentials;
# npm run release;
# npm publish;
# fi
# notifications:
# slack: chrono-dev:a6jsr4kW5U4uxrGNOxygOWGF

# deploy:
# provider: npm
# email: mike.chronobank
# api_key:
# secure: fMwTum2BrHQUtI1nJiLxfkb7H5VyIb39heLQrmcnM9crttKQxsE8aCgI6/RHNOR0edDPfJnFd4ZDwRTfPUuRQnWoLgTHNv8dZGL0T3bXG1vi0pTaYTSyidJ9nx167gRZY1iq7jlLwLxDsqHQFIDL3QTJJ+13DrmgsiPRpa/BA5FDJAkW7uUD6EJSI/7TKqbVANAx0tpCAo5f52A/8ztC03IVGcGAYAX9drEm51JHI74uhhe6JsmIH6Q1G9ZyzkZaqibt2Oim4T63RXYtt1xP8qNcKmXo7V22I/NT2XDWB2jSJVGCWMmB5z4Q7Fftg/3PcO3fbpaTK4wc91nx05RXhzUFT1et789oVYNsTZd7DXrKsInWXVmzw+SOV9mKu1D7obdF02IdgspD1Sn39uBm32BsNDonsUlYNCyPGLerONSqm+rUE9RNblj1QxwqhNdCqk2ZXRdxriDDcUyjMFhQGJqMYLieHazWireQLckmz8Ndtqp9SV2oYU25Phett0/xNewDPFre/MZzjFUZwI5/BOwSqFZA1eoeUYqGxz0wj04Yz+wApYkWol5ifS9IGiki2PNAuNQSuP/7zHF+0bBywfG7yxB8AVjjscyMdBY98PHL/Y+sEpFlJz3LeSuuDgxdECuFnF8h/CR552H75QpKPYRQuTlJwTE+IBvEGlcOkrU=
# on:
# tags: true
# repo: ChronoBank/solidity-shared-lib
# branch: release
# env:
# global:
# secure: Xd5gNWvEmiefw835mdgq8Z2YdBmBTQTJ5gMMgw5eZ3/7dNS8PlErKWGQbg21X+YMfBR/v/qyYcST9PDWLLc452LAHIYGQsKJTLTlWOpIISVgvL0525bW/koFaRoGRgG2lLiD9vvv4/zNoM+tI8EUQo5VyUvpv5if5GWDAzYL0LHfFH0O5AoW7JNTDPbFkDKU+m2/E8VfYQdcRlhInjPb41Shme9D5gm9ut4OcQ+yP+FhHK/3roqNEyvmmYg1r15SHEk7s6mNTzlisZXk7wAeCVWW4C+FBB4jwJ+6Hw5H+WnNtzyV+Gr2jJmdFBL4kEyk7ReTmL6iDmSlunAL4NxJjB0Lj1333xN5TRv1X8nWZQopEmY3/6z4hJW3DtyeFYcf/ZpveLW3YWH3fQe6F4q6A1TJjl5EKYbnlp5h46ZLHhk1qquxY9eGkT6IGPSF3K95qyAPbU2KfpWN7888ChzbL/u+4BzirRLdtZ4qIec4RGgreOnAdQH246jyLTDiWJ/0CufWdQrevlf6z7OKBZvYoAfSKQr5f7r1S5I5TkoQkmm+IwSzr+YskZ1qQs2RLwiBAT1YHkHgSFOdOoh9ABkyUbeR9vXJ0bDwZH3FnSkaGQSCGMk0iLnkwySwCFtrD7cC6tSih5M0Uv22hAvgwYQbTjVW3Rh4NlpRc7P/In1wXHc=
- npm test
before_script:
- ganache-cli > /dev/null &
- sleep 5
after_script:
- travis_wait 50 npm run coverage && cat coverage/lcov.info | coveralls
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="0.2.2"></a>
## 0.2.2 (2018-07-16)
- add linters (eslint and solium);
- add more tests to cover smart contracts;
- update **Owned** contract implementation.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
# solidity-shared-lib
# Shared smart contracts [![Build Status](https://travis-ci.org/ChronoBank/solidity-shared-lib.svg?branch=master)](https://travis-ci.org/ChronoBank/solidity-shared-lib) [![Coverage Status](https://coveralls.io/repos/github/ChronoBank/solidity-shared-lib/badge.svg?branch=master)](https://coveralls.io/github/ChronoBank/solidity-shared-lib?branch=master)

Part of [LaborX project](https://github.com/ChronoBank). Contains a list of basic smart contracts and interfaces that should be at hands for every developer.

- **ERC20Interface** - describes an interface for ERC20 token standard;
- [**Owned**](#owned) - provides a smart contract that is owned by its creator and allows to transfer an ownership in different ways (immediately or with pending timeout).

## Installation

Organized as npm package this smart contracts could be easily added to a project by

```bash
npm install -s solidity-shared-lib
```

## Usage

Right before you decided to use them add this library to package dependencies and import any contract according to this pattern, for example:

```javascript
import "solidity-shared-lib/contracts/Owned.sol";
```

## Details

### Owned

This smart contract besides pinning a contract owner also allows to withdraw any tokens or ether that were mistakenly transferred to a contract (only for contract owner).
8 changes: 5 additions & 3 deletions contracts/ERC20Interface.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* Copyright 2017–2018, LaborX PTY
* Licensed under the AGPL Version 3 license.
*/
* Copyright 2017–2018, LaborX PTY
* Licensed under the AGPL Version 3 license.
*/

pragma solidity ^0.4.23;


/// @title Defines an interface for EIP20 token smart contract
contract ERC20Interface {

event Transfer(address indexed from, address indexed to, uint256 value);
Expand Down
8 changes: 5 additions & 3 deletions contracts/Owned.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ contract Owned {

emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
delete pendingContractOwner;
return true;
}

Expand All @@ -87,11 +88,12 @@ contract Owned {
public
onlyContractOwner
{
address _contractOwner = contractOwner;
for (uint i = 0; i < tokens.length; i++) {
ERC20Interface token = ERC20Interface(tokens[i]);
uint balance = token.balanceOf(this);
if (balance != 0) {
token.transfer(msg.sender, balance);
if (balance > 0) {
token.transfer(_contractOwner, balance);
}
}
}
Expand All @@ -104,7 +106,7 @@ contract Owned {
{
uint balance = address(this).balance;
if (balance > 0) {
msg.sender.transfer(balance);
contractOwner.transfer(balance);
}
}
}
17 changes: 17 additions & 0 deletions contracts/stub/StubOwned.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2017–2018, LaborX PTY
* Licensed under the AGPL Version 3 license.
*/

pragma solidity ^0.4.23;


import "../Owned.sol";


contract StubOwned is Owned {

function() external payable {

}
}

0 comments on commit 13b7acb

Please sign in to comment.