Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add storage to oe template (not working) (DO NOT MERGE) #1720

Draft
wants to merge 1 commit into
base: experimental-oe
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/storage/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
app/node_modules
build
.cache
dist
coverage
36 changes: 36 additions & 0 deletions apps/storage/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"standard",
"standard-react",
"prettier",
"prettier/react"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"plugins": ["prettier", "react"],
"rules": {
"valid-jsdoc": "error",
"react/prop-types": 0,
"prettier/prettier": [
"error",
{
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false
}
],
"linebreak-style": ["error", "unix"]
}
}
1 change: 1 addition & 0 deletions apps/storage/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
9 changes: 9 additions & 0 deletions apps/storage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
build
abi
.cache
dist
ipfs.cmd
package-lock.json
coverage.json
coverage
15 changes: 15 additions & 0 deletions apps/storage/.ipfsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Git files
.gitignore

# Build files
.cache
node_modules
build
coverage

# Lock files
package-lock.json
yarn.lock

# Others
test
7 changes: 7 additions & 0 deletions apps/storage/.solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
norpc: true,
copyPackages: [],
skipFiles: [
'test',
]
}
2 changes: 2 additions & 0 deletions apps/storage/.soliumignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
contracts/Migrations.sol
35 changes: 35 additions & 0 deletions apps/storage/.soliumrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": "solium:all",
"plugins": [
"security"
],
"rules": {
"imports-on-top": ["error"],
"variable-declarations": ["error"],
"array-declarations": ["error"],
"operator-whitespace": ["error"],
"lbrace": ["error"],
"mixedcase": ["warning"],
"camelcase": ["error"],
"uppercase": ["warning"],
"no-empty-blocks": ["error"],
"no-unused-vars": ["error"],
"quotes": ["error"],
"indentation": ["error"],
"whitespace": ["error"],
"deprecated-suicide": ["error"],
"arg-overflow": ["error", 8],
"pragma-on-top": ["error"],
"security/enforce-explicit-visibility": ["error"],
"consequent": 0,
"error-reason": ["warning"],
"function-order": [
"error",
{
"ignore": {
"functions": ["initialize"]
}
}
]
}
}
125 changes: 125 additions & 0 deletions apps/storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Aragon React Boilerplate

> 🕵️ [Find more boilerplates using GitHub](https://github.com/search?q=topic:aragon-boilerplate) |
> ✨ [Official boilerplates](https://github.com/search?q=topic:aragon-boilerplate+org:aragon)

React boilerplate for Aragon applications.

This boilerplate includes a fully working example app, complete with a background worker and a front-end in React (with Aragon UI). Also comes with a DAO Template which will allow for using your app to interact with other Aragon apps like the Voting app. You can read more about DAO Template [here](https://hack.aragon.org/docs/templates-intro).

## Usage

To setup use the command `create-aragon-app`:

```sh
npx create-aragon-app <app-name> react
```

## Structure

This boilerplate has the following structure:

```md
root
├── app
├ ├── src
├ └── package.json
├── contracts
├ ├── CounterApp.sol
├ └── Template.sol
├── migration
├── test
├── arapp.json
├── manifest.json
├── truffle.js
└── package.json
```

- **app**: Frontend folder. Completely encapsulated, has its own package.json and dependencies.
- **src**: Source files.
- [**package.json**](https://docs.npmjs.com/creating-a-package-json-file): Frontend npm configuration file.
- **contracts**: Smart Constracts folder.
- `CounterApp.sol`: Aragon app contract example.
- `Template.sol`: [Aragon Template](https://hack.aragon.org/docs/templates-intro) to deploy a fully functional DAO.
- [**migrations**](https://truffleframework.com/docs/truffle/getting-started/running-migrations): Migrations folder.
- **test**: Tests folder.
- [**arapp.json**](https://hack.aragon.org/docs/cli-global-confg#the-arappjson-file): Aragon configuration file. Includes Aragon-specific metadata for your app.
- [**manifest.json**](https://hack.aragon.org/docs/cli-global-confg#the-manifestjson-file): Aragon configuration file. Includes web-specific configurations.
- [**truffle.js**](https://truffleframework.com/docs/truffle/reference/configuration): Truffle configuration file.
- [**package.json**](https://docs.npmjs.com/creating-a-package-json-file): Main npm configuration file.

## Make the template work with your app

- Edit the roles defined in the template to configure your DAO as you want!

## Run the template

```sh
npx aragon run --template Template --template-init @ARAGON_ENS
```

## Running your app

### Using HTTP

Running your app using HTTP will allow for a faster development process of your app's front-end, as it can be hot-reloaded without the need to execute `aragon run` every time a change is made.

- First start your app's development server running `npm run start:app`, and keep that process running. By default it will rebuild the app and reload the server when changes to the source are made.

- After that, you can run `npm run start:http` or `npm run start:http:template` which will compile your app's contracts, publish the app locally and create a DAO. You will need to stop it and run it again after making changes to your smart contracts.

Changes to the app's background script (`app/script.js`) cannot be hot-reloaded, after making changes to the script, you will need to either restart the development server (`npm run start:app`) or rebuild the script `npm run build:script`.

### Using IPFS

Running your app using IPFS will mimic the production environment that will be used for running your app. `npm run start:ipfs` will run your app using IPFS. Whenever a change is made to any file in your front-end, a new version of the app needs to be published, so the command needs to be restarted.

## What's in this boilerplate?

### npm Scripts

- **start** or **start:ipfs**: Runs your app inside a DAO served from IPFS
- **start:http**: Runs your app inside a DAO served with HTTP (hot reloading)
- **start:ipfs:template**: Creates a DAO with the [Template](https://github.com/aragon/aragon-react-boilerplate/blob/master/contracts/Template.sol) and serves the app from IPFS
- **start:http:template**: Creates a DAO with the [Template](https://github.com/aragon/aragon-react-boilerplate/blob/master/contracts/Template.sol) and serves the app with HTTP (hot reloading)
- **prepare**: Installs dependencies of the front-end
- **start:app**: Starts a development server for your app
- **compile**: Compiles the smart contracts
- **build**: Builds the front-end and background script
- **test**: Runs tests for the contracts
- **publish:patch**: Releases a patch version to aragonPM (only frontend/content changes allowed)
- **publish:minor**: Releases a minor version to aragonPM (only frontend/content changes allowed)
- **publish:major**: Releases a major version to aragonPM (frontend **and** contract changes)
- **versions**: Checks the currently installed versions of the app
- **lint**: Checks the app and the contracts for linting errors
- **lint:fix**: Fixes the lint errors that can be resolved automatically
- **coverage**: Runs the tests for the contracts and creates a report

### Libraries

- [**@aragon/os**](https://github.com/aragon/aragonos): Aragon interfaces
- [**@aragon/api**](https://github.com/aragon/aragon.js/tree/master/packages/aragon-api): Wrapper for Aragon application RPC
- [**@aragon/ui**](https://github.com/aragon/aragon-ui): Aragon UI components (in React)

## What you can do with this boilerplate?

### Publish

You can publish you app on [aragonPM](https://hack.aragon.org/docs/apm). See how in our [publish guide](https://hack.aragon.org/docs/guides-publish).

> **Note**<br>
> The [Template](https://github.com/aragon/aragon-react-boilerplate/blob/master/contracts/Template.sol) will not be published.

### Using a different Ethereum account

You can use a different account to interact with you app. [Check the documentation](https://hack.aragon.org/docs/guides-faq#set-a-private-key).

### Propagate content

You can propagate the content of your app on IPFS. Learn more in our [troubleshooting guide](https://hack.aragon.org/docs/guides-faq#propagating-your-content-hash-through-ipfs) or use the `aragon ipfs propagate` command:

```
npx aragon ipfs propagate <cid>
```

Where `cid` is your content id hash (this will be displayed after publishing).
35 changes: 35 additions & 0 deletions apps/storage/arapp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"roles": [
{
"name": "Register a key-value pair",
"id": "REGISTER_DATA_ROLE",
"params": []
},
{
"name": "Register a storage provider",
"id": "REGISTER_STORAGE_PROVIDER_ROLE",
"params": []
}
],
"environments": {
"default": {
"registry": "0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1",
"network": "rpc",
"appName": "storage.aragonpm.eth"
},
"rinkeby": {
"registry": "0x98df287b6c145399aaa709692c8d308357bc085d",
"appName": "storage.open.aragonpm.eth",
"wsRPC": "wss://rinkeby.eth.aragon.network/ws",
"network": "rinkeby"
},
"mainnet": {
"registry": "0x314159265dd8dbb310642f98f50c066173c1259b",
"appName": "storage.open.aragonpm.eth",
"wsRPC": "wss://mainnet.eth.aragon.network/ws",
"network": "mainnet"
}
},
"path": "contracts/Storage.sol",
"storage": true
}
38 changes: 38 additions & 0 deletions apps/storage/contracts/Storage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
pragma solidity ^0.4.24;

import "@aragon/os/contracts/apps/AragonApp.sol";


contract Storage is AragonApp {

/// Events
event Registered(bytes32 indexed key);
event PinHash(string cid);

/// State: data registry
mapping(bytes32 => string) internal registeredData;

/// ACL
bytes32 constant public REGISTER_DATA_ROLE = keccak256("REGISTER_DATA_ROLE");

/// Custom aragon constructor
function initialize() public onlyInit {
initialized();
}

/**
* @notice Set `_key` data to `_cid`
* @param _key Data item that will be stored in the registry
* @param _cid Data content to be stored
*/

function registerData(bytes32 _key, string _cid) external auth(REGISTER_DATA_ROLE) {
registeredData[_key] = _cid;
emit Registered(_key);
emit PinHash(_cid);
}

function getRegisteredData(bytes32 _key) external view returns(string) {
return registeredData[_key];
}
}
Loading