Skip to content

Commit

Permalink
Merge pull request #26 from nexusdev/0.2-dev
Browse files Browse the repository at this point in the history
0.2 dev
  • Loading branch information
nmushegian committed Apr 13, 2016
2 parents 3f5362a + 6bdc4f5 commit 143680d
Show file tree
Hide file tree
Showing 21 changed files with 153 additions and 49 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build

*.sw*
*.DS_Store
admin-gui/node_modules
admin-gui/bower_components
build/__*
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ audit](https://github.com/nexusdev/dappsys/blob/master/doc/nexus-review-final-20
Installation
---

npm install dapple
dapple install https://github.com/nexusdev/dappsys
npm install -g dapple
# `dapple install` is not reliable yet
# dapple install dappsys 0.2.0
git submodule add https://github.com/nexusdev/dappsys dapple_packages/dappsys

How to
---

0.1.* Contracts
0.2.0 Contracts
---

### `auth`:
Expand Down
22 changes: 20 additions & 2 deletions contracts/actor/base.sol
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
// Filename alias.
import 'actor/base_actor.sol';
// A base contract mostly used by governance contracts in `gov`.
// For now, this just means the multisig contract, but it could
// be used for stake-vote or futarchy.
contract DSBaseActor {
// return result of `call` keyword
function tryExec( address target, bytes calldata, uint value)
internal
returns (bool call_ret)
{
return target.call.value(value)(calldata);
}
function exec( address target, bytes calldata, uint value)
internal
{
if(!tryExec(target, calldata, value)) {
throw;
}
}
}

20 changes: 0 additions & 20 deletions contracts/actor/base_actor.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'actor/base_actor.sol';
import 'actor/base.sol';
import 'dapple/test.sol';
import 'dapple/debug.sol';

Expand Down
11 changes: 11 additions & 0 deletions contracts/auth/enum_test.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'dapple/test.sol';
import 'auth/enum.sol';

contract AuthEnumValuesTest is Test, DSAuthModesEnum {
function setUp() {}
// TODO how to test they are still the same ABI type?
function testValues() {
assertEq( 0, uint(DSAuthModes.Owner) );
assertEq( 1, uint(DSAuthModes.Authority) );
}
}
5 changes: 5 additions & 0 deletions contracts/data.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'data/approval_db.sol';
import 'data/balance_db.sol';

import 'data/map.sol';
import 'data/nullmap.sol';
2 changes: 2 additions & 0 deletions contracts/data/balance_db.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import 'auth.sol';
import 'util/safety.sol';

import 'dapple/debug.sol';

contract DSBalanceDBEvents {
event BalanceUpdate( address indexed who, uint new_amount );
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/dev.md

This file was deleted.

5 changes: 1 addition & 4 deletions contracts/factory/data_factory.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import 'auth.sol';
import 'data/balance_db.sol';
import 'data/approval_db.sol';
import 'data/nullmap.sol';
import 'data/map.sol';
import 'data.sol';

contract DSDataFactory is DSAuthUser {
function buildDSBalanceDB() returns (DSBalanceDB ret) {
Expand Down
5 changes: 2 additions & 3 deletions contracts/factory/factory.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'auth.sol';
import 'auth/basic_authority.sol';
import 'data/balance_db.sol';
import 'data/approval_db.sol';

import 'gov/easy_multisig.sol';
import 'token/base.sol';
import 'token/controller.sol';
import 'token/frontend.sol';

import 'factory/auth_factory.sol';
import 'factory/data_factory.sol';
import 'factory/auth_factory.sol';
import 'factory/token_factory.sol';
import 'factory/multisig_factory.sol';

Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/token_factory.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'auth.sol';
import 'auth/basic_authority.sol';
import 'data/balance_db.sol';
import 'data.sol';
import 'factory/data_factory.sol';
import 'factory/auth_factory.sol';
import 'token/controller.sol';
Expand Down
4 changes: 2 additions & 2 deletions contracts/gov/easy_multisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ contract DSEasyMultisig is DSBaseActor
// Public getter for the action mapping doesn't work in web3.js yet
function getActionStatus(uint action_id)
constant
returns (uint confirmations, uint expiration, bool triggered)
returns (uint confirmations, uint expiration, bool triggered, address target, uint eth_value)
{
var a = actions[action_id];
return (a.confirmations, a.expiration, a.triggered);
return (a.confirmations, a.expiration, a.triggered, a.target, a.value);
}

// `propose` an action using the calldata from this sender's last call.
Expand Down
7 changes: 5 additions & 2 deletions contracts/gov/easy_multisig_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ contract DSEasyMultisigTest is Test, DSEasyMultisigEvents
var (r, m, e, id) = ms.getInfo();
assertEq( id, 1, "wrong last action id");
uint c; bool t;
(c, e, t) = ms.getActionStatus(1);
address target; uint value;
(c, e, t, target, value) = ms.getActionStatus(1);
assertTrue( c == 0, "wrong number of confirmations" );
assertEq( target, address(h) );
assertEq( value, 0 );
ms.confirm(1);
DSEasyMultisig(t1).confirm(1);
(c, e, t) = ms.getActionStatus(1);
(c, e, t, target, value) = ms.getActionStatus(1);
assertTrue( c == 2, "wrong number of confirmations" );
DSEasyMultisig(t1).trigger(1);
assertEq( h._arg(), 1, "wrong last arg" );
Expand Down
73 changes: 73 additions & 0 deletions contracts/lang/fallback_tests.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Some tests to verify behavior of fallbacks and rsult of calling addresses with unexpected types
// TODO demonstrate that garbage is not always calldata (except when calling no-code addresses)
import 'dapple/test.sol';

contract ThrowingFallback {
function() {
throw;
}
}

contract UndefinedFunction {
function undefinedFunction() returns (bytes32);
function undefinedFunction2() returns (bytes32);
}

contract TypedFallback {
function() returns (bytes32) {
return 0x42;
// same as "return bytes32(0x0);"
}
}

contract UntypedFallback {
function() {
// same as "return bytes32(0x0);"
}
}


contract UndefinedFallback {
function iHaveCode() returns (bytes32) {
return "aaaaa";
}
}


contract FallbackTest is Test {
ThrowingFallback throwing;
TypedFallback typed;
UntypedFallback untyped;
UndefinedFallback undefined;
address noCode;
function setUp() {
throwing = new ThrowingFallback();
typed = new TypedFallback();
untyped = new UntypedFallback();
undefined = new UndefinedFallback();
noCode = address(0x42);
}
function testFailThrowingFallback() {
UndefinedFunction(throwing).undefinedFunction();
}
function testTypedFallbackReturnsFalse() {
var ret = UndefinedFunction(typed).undefinedFunction();
assertEq32(ret, 0x42);
}
function testUntypedFallbackReturnsGarbage() {
var ret = UndefinedFunction(undefined).undefinedFunction();
assertTrue( ret != bytes32(0), "ret is 0 by coincidence" );
log_named_bytes32("garbage", ret);
}
function testUndefinedFallbackReturnsGarbage() {
var ret = UndefinedFunction(undefined).undefinedFunction();
assertTrue( ret != bytes32(0), "ret is 0 by coincidence" );
log_named_bytes32("garbage", ret);
}
function testNoCodeReturnsGarbage() {
var ret = UndefinedFunction(noCode).undefinedFunction();
assertTrue( ret != bytes32(0), "ret is 0 by coincidence" );
log_named_bytes32("garbage", ret);
}

}
1 change: 0 additions & 1 deletion contracts/token/base_test.sol

This file was deleted.

1 change: 1 addition & 0 deletions contracts/token/provider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import 'token/token.sol';

contract DSTokenProvider {
function getToken(bytes32 symbol) returns (DSToken);
function tryGetToken(bytes32 symbol) returns (DSToken, bool ok);
}

5 changes: 5 additions & 0 deletions contracts/token/registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import 'token/provider.sol';

// Simple registry implementing DSTokenProvider
contract DSTokenRegistry is DSTokenProvider, DSNullMap {
// throws.
function getToken(bytes32 symbol) returns (DSToken) {
return DSToken(address(get(symbol)));
}
function tryGetToken(bytes32 symbol) returns (DSToken token, bool ok) {
var (_token, _ok) = tryGet(symbol);
return (DSToken(address(_token)), _ok);
}
}

10 changes: 9 additions & 1 deletion contracts/token/registry_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ contract TokenRegistryTest is Test {
registry.set(tokenName, bytes32(address(token)));
assertEq(registry.getToken(tokenName), token);
}

function testFailGetUnsetToken() {
bytes32 tokenName = "Kanye Coin";
assertEq(registry.getToken(tokenName), token);
}
function testTryGetToken() {
bytes32 tokenName = "Kanye Coin";
registry.set(tokenName, bytes32(address(token)));
var (_token, ok) = registry.tryGetToken(tokenName);
assertTrue(ok);
assertEq(token, _token);
(_token, ok) = registry.tryGetToken("NIL");
assertFalse(ok);
}
}
2 changes: 2 additions & 0 deletions contracts/token/token_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ contract DSTokenTester is Tester, Debug {
function doTransferFrom(address from, address to, uint amount)
returns (bool)
{
logs("in doTransferFrom");
return DSToken(_t).transferFrom(from, to, amount);
}

Expand Down Expand Up @@ -71,6 +72,7 @@ contract DSTokenTest is Test, DSAuthUser {

function testValidTransfers() logs_gas {
uint sentAmount = 250;
log_named_address("token11111", token);
token.transfer(user2, sentAmount);
assertEq(token.balanceOf(user2), sentAmount);
assertEq(token.balanceOf(me), initialBalance - sentAmount);
Expand Down
8 changes: 6 additions & 2 deletions dappfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: dappsys
version: 0.1.3-dev
version: 0.2.0
layout:
sol_sources: contracts
build_dir: build
ignore: []
ignore:
- actor/interpreter.sol
- auth/group_authority.sol
- data/vote_db.sol
- token/hooks/vote_sync.sol
environments:
morden:
objects:
Expand Down

0 comments on commit 143680d

Please sign in to comment.