diff --git a/src/sol/factory/auth_factory.sol b/src/sol/factory/auth_factory.sol new file mode 100644 index 0000000..e7f0343 --- /dev/null +++ b/src/sol/factory/auth_factory.sol @@ -0,0 +1,8 @@ +contract DSAuthFactory { + function buildDSBasicAuthorityFactory() returns (DSBasicAuthority) { + var c = new DSBasicAuthority(); + c.updateAuthority(msg.sender, false); + return c; + + } +} diff --git a/src/sol/factory/data_factory.sol b/src/sol/factory/data_factory.sol new file mode 100644 index 0000000..d18b3b5 --- /dev/null +++ b/src/sol/factory/data_factory.sol @@ -0,0 +1,21 @@ +import 'data/balance_db.sol'; +import 'data/approval_db.sol'; +import 'data/map.sol'; + +contract DSDataFactory { + function buildDSBalanceDB() returns (DSBalanceDB) { + var c = new DSBalanceDB(); + c.updateAuthority(msg.sender, false); + return c; + } + function buildDSApprovalDB() returns (DSApprovalDB) { + var c = new DSApprovalDB(); + c.updateAuthority(msg.sender, false); + return c; + } + function buildDSMap() returns (DSMap) { + var c = new DSMap(); + c.updateAuthority(msg.sender, false); + return c; + } +} diff --git a/src/sol/factory/factory.sol b/src/sol/factory/factory.sol index 313eee0..49e081f 100644 --- a/src/sol/factory/factory.sol +++ b/src/sol/factory/factory.sol @@ -1,6 +1,16 @@ +import 'data/balance_db.sol'; +import 'data/approval_db.sol'; +import 'gov/easy_multisig.sol'; +import 'token/controller.sol'; +import 'token/frontend.sol'; + +import 'factory/data_factory.sol'; +import 'factory/token_factory.sol'; +import 'factory/multisig_factory.sol'; + + // One singleton factory per dappsys version. -// Tries to minimize runtime gas cost at the expense of deploy time gas cost. -// Limited by block gas limit. +// Motivated by and limited by block gas limit. contract DSFactory { function buildDSBalanceDB() returns (DSBalanceDB); @@ -9,3 +19,47 @@ contract DSFactory { returns (DSTokenController); function buildDSTokenFrontend( DSTokenController cont ) returns (DSTokenFrontend); } +contract DSFactory1 is DSFactory { + DSDataFactory _data; + DSTokenFactory _token; + DSMultisigFactory _ms; + function DSFactory1( DSDataFactory data + , DSTokenFactory token + , DSMultisigFactory ms ) + { + _data = data; + _token = token; + _ms = ms; + } + + function buildDSBalanceDB() returns (DSBalanceDB) { + return _data.buildDSBalanceDB(); + } + function buildDSApprovalDB() returns (DSApprovalDB) { + return _data.buildDSApprovalDB(); + } + function buildDSTokenController( DSBalanceDB bal_db, DSApprovalDB appr_db ) + returns (DSTokenController) + { + return _token.buildDSTokenController( bal_db, appr_db ); + } + function buildDSTokenFrontend( DSTokenController cont ) returns (DSTokenFrontend) + { + return _token.buildDSTokenFrontend( cont ); + } +} + + +// If you need the latest factory in assembled form for a private +// chain or VM tests. +contract DSFactoryTestFactory { + function buildFactory() returns (DSFactory) { + var data = new DSDataFactory(); + var token = new DSTokenFactory(); + var ms = new DSMultisigFactory(); + var f = new DSFactory1(data, token, ms); + return f; + } +} + + diff --git a/src/sol/factory/factory1.sol b/src/sol/factory/factory1.sol deleted file mode 100644 index 833f674..0000000 --- a/src/sol/factory/factory1.sol +++ /dev/null @@ -1,33 +0,0 @@ -import 'factory/factory.sol'; - -import 'data/balance_db.sol'; -import 'data/approval_db.sol'; -import 'data/map.sol'; - -import 'token/frontend.sol'; -import 'token/controller.sol'; - -contract DSFactory1 is DSFactory { - function buildDSBalanceDB() returns (DSBalanceDB) { - var c = new DSBalanceDB(); - c.updateAuthority(msg.sender, false); - return c; - } - function buildDSApprovalDB() returns (DSApprovalDB) { - var c = new DSApprovalDB(); - c.updateAuthority(msg.sender, false); - return c; - } - function buildDSTokenController( DSBalanceDB bal_db, DSApprovalDB appr_db ) - returns (DSTokenController) - { - var c = new DSTokenController( bal_db, appr_db ); - c.updateAuthority(msg.sender, false); - return c; - } - function buildDSTokenFrontend( DSTokenController cont ) returns (DSTokenFrontend) { - var c = new DSTokenFrontend( cont ); - c.updateAuthority(msg.sender, false); - return c; - } -} diff --git a/src/sol/factory/factory_test.sol b/src/sol/factory/factory_test.sol index f3e574b..3260e04 100644 --- a/src/sol/factory/factory_test.sol +++ b/src/sol/factory/factory_test.sol @@ -1,12 +1,11 @@ import 'factory/factory.sol'; import 'dapple/test.sol'; -contract Factory1Test is Test { +contract FactoryTest is Test { DSFactory f; function setUp() { - f = new DSFactory1(); } function testCreateCostMain() logs_gas() { - f = new DSFactory1(); + f = (new DSFactoryTestFactory()).buildFactory(); } } diff --git a/src/sol/factory/multisig_factory.sol b/src/sol/factory/multisig_factory.sol new file mode 100644 index 0000000..5fb2d39 --- /dev/null +++ b/src/sol/factory/multisig_factory.sol @@ -0,0 +1,10 @@ +import 'gov/easy_multisig.sol'; + +contract DSMultisigFactory { + function buildDSEasyMultisig( uint n, uint m, uint expiration ) returns (DSEasyMultisig) + { + var c = new DSEasyMultisig( n, m, expiration ); + c.updateAuthority(msg.sender, false); + return c; + } +} diff --git a/src/sol/factory/token_factory.sol b/src/sol/factory/token_factory.sol new file mode 100644 index 0000000..8be8a03 --- /dev/null +++ b/src/sol/factory/token_factory.sol @@ -0,0 +1,14 @@ +contract DSTokenFactory { + function buildDSTokenController( DSBalanceDB bal_db, DSApprovalDB appr_db ) + returns (DSTokenController) + { + var c = new DSTokenController( bal_db, appr_db ); + c.updateAuthority(msg.sender, false); + return c; + } + function buildDSTokenFrontend( DSTokenController cont ) returns (DSTokenFrontend) { + var c = new DSTokenFrontend( cont ); + c.updateAuthority(msg.sender, false); + return c; + } +} diff --git a/src/sol/token/deployer_test.sol b/src/sol/token/deployer_test.sol index e6f7312..97944dc 100644 --- a/src/sol/token/deployer_test.sol +++ b/src/sol/token/deployer_test.sol @@ -9,7 +9,7 @@ contract TokenSetupTest is Test { DSTokenDeployer deployer; DSToken t; function setUp() { - f = new DSFactory1(); + f = (new DSFactoryTestFactory()).buildFactory(); deployer = new DSTokenDeployer(f); tester = new TokenTester(); deployer.deploy(address(tester), 100);