OpenST / developer-guidelines

Guidelines on code, project setup, etc.
MIT License
3 stars 8 forks source link

Deduplicate code #20

Open schemar opened 5 years ago

schemar commented 5 years ago

Organization and UtilityToken contracts are used in more than one repositories. All repositories have its own implementations, so

Following are the items that we are trying to achieve in this epic

**1. The code will be moved to a new repository.**

**2. These repositories should include the contract interacts**

These repositories should auto-generate the contract interact code from the ABI JSON files. Contract interacts creation in type-script has a lot of boilerplate code and its time consuming to maintain it manually. It will be helpful to consume APIs with proper typed parameters.

So for the creation of contract interacts the proposal will be as follows

Few example of generators are given below (You may add more)

**3. Publish NPM package** While publishing the NPM package

**4. Use git submodule to use the contracts in the dependent repository**

**5. Update dependent repositories to use published NPM module.**

jasonklein commented 5 years ago

@schemar: truffle documentation indicates it supports using contracts via NPM packages (I have not yet tried it, so this is a suggestion and not a recommendation 😅). Might that be a viable alternative to git-submodules?

cc: @deepesh-kn

schemar commented 5 years ago

@schemar: truffle documentation indicates it supports using contracts via NPM packages (I have not yet tried it, so this is a suggestion and not a recommendation 😅). Might that be a viable alternative to git-submodules?

cc: @deepesh-kn

Definitely. I think @pgev was in favor of git submodules over dependencies. @pgev can you please re-iterate?

schemar commented 5 years ago

I'll put step 1 on the backlog: use https://github.com/openst/organization-contracts/ and https://github.com/openst/utilitytoken-contracts

/cc @benjaminbollen @deepesh-kn

schemar commented 5 years ago

Will also add to use dependencies instead of copy/pasting code where possible for external things like EIP20Token.

jasonklein commented 5 years ago

@deepesh-kn / @schemar: where will SafeMath.sol come from for git-submodules tickets mosaic-contracts 712, openst-contracts 197, and brandedtoken-contracts 166?

cc: @benjaminbollen

schemar commented 5 years ago

I would guess https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v2.2.0/contracts/math/SafeMath.sol

deepesh-kn commented 5 years ago

@schemar: truffle documentation indicates it supports using contracts via NPM packages (I have not yet tried it, so this is a suggestion and not a recommendation 😅). Might that be a viable alternative to git-submodules?

cc: @deepesh-kn

Agree, we can discuss this. We can opt for NPM as well. @pgev has used git-submodules in one of the repo. Would like to hear from him on this.

jasonklein commented 5 years ago

Looking more into the topic of git-submodules to resolve an open question related to organization-contracts, in addition to internet comparisons commentary that mostly focuses on costs and not benefits, the Git also appears to vote in favor of an alternative solution for our purposes:

It’s quite likely that if you’re using submodules, you’re doing so because you really want to work on the code in the submodule at the same time as you’re working on the code in the main project (or across several submodules). Otherwise you would probably instead be using a simpler dependency management system (such as Maven or Rubygems).

My understanding is that we do not intend to make changes in the submodules. Git recommends using another tool in that case.

deepesh-kn commented 5 years ago

Following is the conclusion from today's discussion.