Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from MyBitFoundation/develop
Develop
- Loading branch information
Showing
22 changed files
with
2,621 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
build | ||
dist | ||
dist | ||
accounts.json | ||
addresses.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Process for updating git repositories and npm packages | ||
|
||
When contracts are added/changed we have to make the following changes to these repositories: | ||
- MyBit-Network.tech | ||
- MyBit-Chain.tech | ||
- network.js | ||
- hello-network | ||
|
||
## 1) Update migrations/export chain: | ||
- Make sure any contracts that need to be deployed on the | ||
local chain are included in *migrations/2_deploy_protocol.js*. | ||
This includes importing the contract, setting a contract variable, | ||
deploying it inside the chain of promises, and exporting the address | ||
into addresses.json | ||
|
||
- In terminal, run: | ||
|
||
```bash | ||
./export_chain ../MyBit-Chain.tech | ||
``` | ||
*substitute ../MyBit-Chain.tech with whataver directory the chain is in* | ||
|
||
- This will also push the changes to the respository if a .git file is present | ||
|
||
## 2) Update lib/index.js and lib/js/: | ||
- If there are any new contracts we need to update the files that export the ABI's | ||
for use by network.js | ||
|
||
- In terminal, run: | ||
|
||
```bash | ||
scripts/prepare_lib.sh | ||
``` | ||
|
||
- This will generate the js files and index.js that will be used in the npm package. | ||
|
||
## 3) Update git: | ||
```bash | ||
git add -u | ||
git add contracts/. | ||
git commit -m "New update description" | ||
git push origin master | ||
``` | ||
|
||
## 4) Publish to NPM: | ||
- If the package is ready to be published, run the following: | ||
|
||
```bash | ||
npm version patch | ||
npm publish --access=public | ||
``` | ||
|
||
## 5) Move to MyBit-Chain.tech directory, and publish to NPM: | ||
```bash | ||
npm version patch | ||
npm publish --access=public | ||
``` | ||
*the chain should already have been pushed to the repository* | ||
|
||
## 6) Move to network.js, update API: | ||
- If you want the new contracts to be exposed by the API you'll need to update | ||
index.js. | ||
|
||
- First you must set up your contract artifacts. Under the section commented | ||
as *//Setup contracts*, create your contract object, e.g.: | ||
|
||
```javascript | ||
var exampleContract = contract(ContractArtifacts.Example); | ||
``` | ||
|
||
- Where 'exampleContract' is the name you'll be referencing when instatiating | ||
contracts in your functions and 'ContractArtifacts.Example' is the variable | ||
exported by @mybit/contracts. 'ContractArtifacts' is what we call @mybit/contracts | ||
when it is imported, and 'Example' is just the file name of the contract | ||
without the file type ('.sol'). | ||
|
||
- Next you'll want to build functions that expose the contract in the API. One | ||
option is to simply instatiate the contract and the return the object. This | ||
will expose all the contract's functions to the end user. For example: | ||
|
||
```javascript | ||
example: async () => { | ||
return await exampleContract.at(Chain.Example()); | ||
} | ||
``` | ||
|
||
- In this example we are just instatiating the contract that exists at Chain.Example(), | ||
which is the address that is generated in *migrations/2_deploy_protocol.js*, which | ||
we ran at the very beginning of this guide. Since we are returning the whole | ||
contract we can call any function inside Example.sol. So if we import network.js | ||
into a script as 'Network' we can call our function like so: | ||
|
||
```javascript | ||
example = await Network.example(); | ||
result = await example.function(parameter); | ||
``` | ||
|
||
- Alternatively, one can expose functions directly in our API. If we go back to | ||
*network.js/index.js* we can make the following function: | ||
|
||
```javascript | ||
someFunction: async (parameter) => { | ||
instance = await exampleContract.at(Chain.Example()); | ||
result = await instance.function(parameter); | ||
return result; | ||
} | ||
``` | ||
|
||
- Now we can access the function directly in our scripts: | ||
|
||
```javascript | ||
result = await Network.someFunction(parameter); | ||
``` | ||
|
||
## 7) Update package.json and publish to NPM: | ||
- Since we are using new npm packages, we need to update the version numbers in | ||
package.json. You can update @mybit/contracts and @mybit/chain to the most recent | ||
versions. | ||
|
||
- Update network.js to git: | ||
```bash | ||
git add -u | ||
git commit -m "Added example function" | ||
git push origin master | ||
``` | ||
|
||
- Now publish on npm: | ||
```bash | ||
npm version patch | ||
npm publish --access=public | ||
``` | ||
|
||
## 8) Update examples in hello-network: | ||
- If you want to show examples and use cases for the new functions you wrote | ||
in the API, you can add them here. | ||
|
||
- After creating examples, update package.json to reference the newest version | ||
of network.js. | ||
|
||
- Then update git: | ||
```bash | ||
git add . | ||
git commit -m "New stuff" | ||
git push origin master | ||
``` | ||
|
||
- Then publish to npm: | ||
```bash | ||
npm version patch | ||
npm publish --access=public | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[ | ||
"0x34b4c0cf65a762f3042070a03425ab4bffe0170c", | ||
"0x44067107f06443e6d125352bbf95de0c133456f8", | ||
"0x02c4039e7d59b00e20f0f1dade6265c5a27ea715", | ||
"0x9d01aafb060b3b76dc8e546b0550b68e8d7c529b", | ||
"0xb220118ca37c21717fd09d9fc01fbb98d9b1f930", | ||
"0x2fd989874137f24325474df1a3aacae508e3e2ce", | ||
"0x6925b5a5cc617e466437a39ffb9c82a56c89e0a9", | ||
"0xe42cd23ef408bf91042f3bb643db512c36d7a42e", | ||
"0xee3cc3822bfeb1567ded5c507eba3a9c680988e7", | ||
"0x20a698e36ae9bce21d5a00f87a98876a0e21af4e" | ||
"0xeed17b217b1e0c63b1b525d8d2e59cad0546432d", | ||
"0x0ec0e59bd4faf0a136c2ee638f3fcff19972a304", | ||
"0xe273d3d13d69f82b8071365e110e13c0fbde0c59", | ||
"0x4cbe9306228ff003fe5a47fe66f2e3d3162f0f37", | ||
"0x0dcea99d96046de44f1ab2a4bf9b3e21f3ac2924", | ||
"0x8bd581cca82af7cfff8ab46591803fe2f2061218", | ||
"0xd6a41e3da4bdc4a27d5707b08612925347f5934f", | ||
"0xd0702a4258c574ff15df4e65000dbb16843cbd24", | ||
"0xc3dda1fc00ba83300b9ad2d00faa30166fabc657", | ||
"0x45543e02e26442e6c95e3145f7d30a53b284f418" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{ | ||
"MyBit": "0x1251954ebb35a93414c4fdd6eb572f9292f79bcf", | ||
"ERC20Burner": "0xc263fabff96e5b4a11704478816c874fda9c4177", | ||
"Database": "0x3f4c458f7adc3ce2300cd9fa7ab2c218d04ea18d", | ||
"ContractManager": "0x346505e54761981543be0cd304d3c123887c6e99", | ||
"API": "0xa12d771ffb785ad139dbe082be83259b7a0da142", | ||
"SingleOwned": "0x5bb4c507e7a64c7db50f3a398dc80f399e9c968a", | ||
"Pausible": "0x23ecf8d2811058b790f97fe3c307c16b8e41649e", | ||
"AccessHierarchy": "0x24d2a3416e8b073dfc557fcf0b72cd73c4ae12c1", | ||
"PlatformFunds": "0x6bbb45d95ddbb7a015d10257f66d13936212e64d", | ||
"Operators": "0xbc135c1965c54aca5777aa750bf7863f23e074b3", | ||
"AssetManagerEscrow": "0x172a12d553dd2a57a4227005972340dafcfcf14d", | ||
"CrowdsaleETH": "0xdcf1b48d5bacfd16be0d03f68e0c748e08c79fb1", | ||
"CrowdsaleGeneratorETH": "0x0ff213559567c2787abd8fb42ff46777fe978307", | ||
"CrowdsaleERC20": "0xd5b03029ad72aa013cbcd5a8dd31f6a5cca04f45", | ||
"CrowdsaleGeneratorERC20": "0xa1a8c7e4c9b1cb580428f3326dec41fc1b53391f", | ||
"AssetExchange": "0x75fcdea05c36b0bdcbf1cd341b6cb7b846a885a3" | ||
"MyBit": "0x82e8ed40b49fa4682d58807e99eaed6daf20b1d4", | ||
"ERC20Burner": "0xfa3066aa522b18e0243f7c098e9c72fa85c89ae2", | ||
"Database": "0xf3a985536aa63fcc5e0732fef35a9d6e0881682c", | ||
"ContractManager": "0x8397e224cc3f2560d6c989bc29bb6800517d6f97", | ||
"API": "0x94e839af9b8ec45da92d8a76e0acd1ca45b710c5", | ||
"SingleOwned": "0x6df2e96b18b909e6127137a4a8ddf40eb259b610", | ||
"Pausible": "0xbea6ba1b1aa691fc07a5b722bc491df03f4c280a", | ||
"AccessHierarchy": "0xe4f4aeefd5087eababbd73bdd4c8188cbd008ebb", | ||
"PlatformFunds": "0x7bd53d17ebee6c87d9937c8cb4fb04297cdc83c2", | ||
"Operators": "0x54ae7cc1c7ec065a84b84ea7f9e33a14cf3d95e6", | ||
"AssetManagerEscrow": "0x860b672a9fcb0f12c156cc9c233cfc3ed18fc202", | ||
"CrowdsaleETH": "0x8af6ac104c639a9011b83f3baf789271e6df6198", | ||
"CrowdsaleGeneratorETH": "0xeed31156aa0eeb2ebf473cd16faf70d2bf463137", | ||
"CrowdsaleERC20": "0x03a685558ffd806ca2c44ab5f2ebe84688b82d57", | ||
"CrowdsaleGeneratorERC20": "0xede40300bea9631bddbf1ab91ca286b5cd591d14", | ||
"AssetExchange": "0x57bff4f318c5fb88e742d89627ad0b3ee62ab536" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.