Skip to content

Commit

Permalink
Use npm and git submodules
Browse files Browse the repository at this point in the history
Code deduplication by getting dependencies from npm and git submodules.

* `UtilityToken` contracts are now imported as a git submodule.
* `Organization` contracst are now imported as a git submodule inside
  the `UtilityToken` submodule.
* `SafeMath` is now imported as open zeppelin npm package.

Note that inside the utility token repository, `token` has not been
renamed to `value token`, and therefore some tests needed to be updated.
Also, some tests required updating as `SafeMath` does not give an error
message anymore.

`Organiation` contracts cannot be imported as a separate git submodule
dependency, as then the solidity compiler will complain that there are
multiple definitions of the same symbol (e.g. `contract Organization`).

For now it is fine to import organization from inside utility tokens,
but that will lead to an error latest when there is a diamond
dependency:

```
      Organization
       /        \
UtilitToken   SomethingElse
       \        /
      NewRepository
```

In this case, it couldn't be avoided that `Organization` was defined
multiple times.

To fix this, I created follow-up ticket:
OpenST/developer-guidelines#27

Deduplicating EIP20Token is out-of-scope, as it requires changing
UtilityToken contracts (which has an EIP20Token) and all consumers of
UtilityToken, which currently may or may not rely on the EIP20Token from
there.
Simply adding the npm package does not work, as there will be an error
about multiple definitions of the same Symbol (`contract EIP20Token`).

To fix this, I created a follow-up ticket:
OpenST/developer-guidelines#28

Fixes OpenST#712
  • Loading branch information
schemar committed May 7, 2019
1 parent 76fffcf commit d99bd88
Show file tree
Hide file tree
Showing 40 changed files with 968 additions and 2,263 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ build/
.idea/
.vscode/
*.iml
*.swp
tags

# LaTeX auxiliary files
*.aux
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contracts/utilitytoken"]
path = contracts/utilitytoken
url = https://github.com/OpenST/utilitytoken-contracts.git
6 changes: 3 additions & 3 deletions contracts/anchor/Anchor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ pragma solidity ^0.5.0;

import "../lib/CircularBufferUint.sol";
import "../lib/MerklePatriciaProof.sol";
import "../lib/OrganizationInterface.sol";
import "../lib/Organized.sol";
import "../utilitytoken/contracts/organization/contracts/OrganizationInterface.sol";
import "../utilitytoken/contracts/organization/contracts/Organized.sol";
import "../lib/RLP.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../lib/StateRootInterface.sol";

/**
Expand Down
7 changes: 3 additions & 4 deletions contracts/core/AuxiliaryBlockStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pragma solidity ^0.5.0;

import "../lib/Block.sol";
import "../lib/MetaBlock.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./BlockStore.sol";
import "./PollingPlaceInterface.sol";
import "./KernelGatewayInterface.sol";
Expand Down Expand Up @@ -269,8 +269,8 @@ contract AuxiliaryBlockStore is

coreIdentifier_ = coreIdentifier;
kernelHash_ = kernelHashes[_blockHash];
auxiliaryDynasty_= checkpoints[_blockHash].dynasty;
auxiliaryBlockHash_=checkpoints[_blockHash].blockHash;
auxiliaryDynasty_ = checkpoints[_blockHash].dynasty;
auxiliaryBlockHash_ = checkpoints[_blockHash].blockHash;
accumulatedGas_ = accumulatedGases[_blockHash];
originDynasty_ = originDynasties[_blockHash];
originBlockHash_ = originBlockHashes[_blockHash];
Expand Down Expand Up @@ -497,5 +497,4 @@ contract AuxiliaryBlockStore is

isAncestor_ = currentCheckpoint.blockHash == _ancestor;
}

}
2 changes: 1 addition & 1 deletion contracts/core/BlockStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pragma solidity ^0.5.0;

import "../lib/Block.sol";
import "../lib/MetaBlock.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./BlockStoreInterface.sol";
import "./OriginTransitionObjectInterface.sol";
/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/KernelGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import "../lib/RLP.sol";
import "./BlockStoreInterface.sol";
import "../lib/MerklePatriciaProof.sol";
import "../lib/BytesLib.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../lib/MetaBlock.sol";
import "./AuxiliaryTransitionObjectInterface.sol";
import "./KernelGatewayInterface.sol";
Expand Down Expand Up @@ -666,7 +666,7 @@ contract KernelGateway is KernelGatewayInterface {
{
bytes32 transitionHash =
AuxiliaryTransitionObjectInterface(address(auxiliaryBlockStore))
.auxiliaryTransitionHashAtBlock(_blockHash);
.auxiliaryTransitionHashAtBlock(_blockHash);

metaBlockHash_ = MetaBlock.hashMetaBlock(
activeKernelHash,
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/MosaicCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import "./MosaicCoreInterface.sol";
import "./Stake.sol";
import "../lib/MetaBlock.sol";
import "../lib/OstInterface.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../lib/StateRootInterface.sol";

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/PollingPlace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pragma solidity ^0.5.0;
//
// ----------------------------------------------------------------------------

import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../lib/MetaBlock.sol";
import "./BlockStoreInterface.sol";
import "./PollingPlaceInterface.sol";
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/Stake.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pragma solidity ^0.5.0;

import "../lib/EIP20Interface.sol";
import "./StakeInterface.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
* @title The Stake contract tracks deposits, logouts, slashings etc. on origin.
Expand Down Expand Up @@ -60,7 +60,7 @@ contract Stake is StakeInterface {

/**
* The stake initially equals the deposit. It can decrease due to
* withdrawal or slashing. Initially, the weight on auxiliary will
* withdrawal or slashing. Initially, the weight on auxiliary will
* equal the stake.
*/
uint256 stake;
Expand Down
33 changes: 0 additions & 33 deletions contracts/gateway/CoGatewayUtilityTokenInterface.sol

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/gateway/EIP20CoGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ pragma solidity ^0.5.0;
-------------------------------------------------------------------------------
*/

import "./UtilityTokenInterface.sol";
import "../utilitytoken/contracts/UtilityTokenInterface.sol";
import "./GatewayBase.sol";
import "../lib/OrganizationInterface.sol";
import "../utilitytoken/contracts/organization/contracts/OrganizationInterface.sol";

/**
* @title EIP20CoGateway Contract
Expand Down
2 changes: 1 addition & 1 deletion contracts/gateway/EIP20Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pragma solidity ^0.5.0;

import "./SimpleStake.sol";
import "./GatewayBase.sol";
import "../lib/OrganizationInterface.sol";
import "../utilitytoken/contracts/organization/contracts/OrganizationInterface.sol";

/**
* @title EIP20Gateway Contract
Expand Down
4 changes: 2 additions & 2 deletions contracts/gateway/EIP20Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ pragma solidity ^0.5.0;
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// ----------------------------------------------------------------------------
//
// http://www.simpletoken.org/
//
// ----------------------------------------------------------------------------

import "../lib/EIP20Interface.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
* @title EIP20Token contract.
Expand Down
8 changes: 4 additions & 4 deletions contracts/gateway/GatewayBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pragma solidity ^0.5.0;
import "../lib/EIP20Interface.sol";
import "../lib/GatewayLib.sol";
import "../lib/MessageBus.sol";
import "../lib/OrganizationInterface.sol";
import "../lib/Organized.sol";
import "../lib/SafeMath.sol";
import "../utilitytoken/contracts/organization/contracts/OrganizationInterface.sol";
import "../utilitytoken/contracts/organization/contracts/Organized.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../lib/StateRootInterface.sol";

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ contract GatewayBase is Organized {

// The following variables are not known at construction:
messageBox = MessageBus.MessageBox();
encodedGatewayPath = '';
encodedGatewayPath = "";
remoteGateway = address(0);
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/gateway/OSTPrime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ pragma solidity ^0.5.0;
* the auxiliary chain.
*/
import "./OSTPrimeConfig.sol";
import "./UtilityToken.sol";
import "../utilitytoken/contracts/UtilityToken.sol";
import "../lib/Mutex.sol";
import "../lib/OrganizationInterface.sol";
import "../lib/SafeMath.sol";
import "../utilitytoken/contracts/organization/contracts/OrganizationInterface.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
* @title OSTPrime contract implements UtilityToken and
Expand Down Expand Up @@ -121,7 +121,7 @@ contract OSTPrime is UtilityToken, OSTPrimeConfig, Mutex {
* minted as base coin.
*
* @return success_ `true` if initialize was successful.
*/
*/
function initialize()
external
payable
Expand Down
2 changes: 1 addition & 1 deletion contracts/gateway/SimpleStake.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pragma solidity ^0.5.0;
// ----------------------------------------------------------------------------

import "../lib/EIP20Interface.sol";
import "../lib/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
* @title SimpleStake contract
Expand Down
Loading

0 comments on commit d99bd88

Please sign in to comment.