From be4339a9fef0b2e2860ad4cf71f0e9f1b4b775a4 Mon Sep 17 00:00:00 2001 From: "Michele \"Ubik\" De Simoni" Date: Thu, 6 Aug 2020 22:30:38 +0200 Subject: [PATCH 1/4] Add basic sphinx configuration --- .gitignore | 4 +- docs/Makefile | 20 ++++++++++ docs/make.bat | 35 ++++++++++++++++++ docs/source/conf.py | 86 +++++++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 20 ++++++++++ requirements.in | 3 ++ requirements.txt | 37 +++++++++++++++++++ 7 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 requirements.in create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index d5b1a3e..7ff9640 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /**/spa/**/style.css /**/node_modules /**/package-lock.json -/**/npm/dist \ No newline at end of file +/**/npm/dist + +docs/build diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..fee0091 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,86 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# + +import os +import sys + +sys.path.insert(0, os.path.abspath(".")) + + +# -- Project information ----------------------------------------------------- + +project = "dfo-hub" +copyright = "2020, dfo-hub" +author = "dfo-hub" + +# The full version, including alpha/beta/rc tags +release = "0.3.0" + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinxcontrib.soliditydomain", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +# -- Options for HTML output ------------------------------------------------- + +# Logo +html_logo = "" + + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +html_theme_options = { + "display_version": True, + "sticky_navigation": True, + "collapse_navigation": False, + "navigation_depth": 4, + "logo_only": True, +} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +html_css_files = ["css/custom.css"] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..0f609d8 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. dfo-hub documentation master file, created by + sphinx-quickstart on Thu Aug 6 20:57:06 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to dfo-hub's documentation! +=================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..08cf9e8 --- /dev/null +++ b/requirements.in @@ -0,0 +1,3 @@ +sphinx +sphinxcontrib-soliditydomain +sphinx-rtd-theme diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..28347b9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,37 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile requirements.in +# +alabaster==0.7.12 # via sphinx +antlr4-python3-runtime==4.8 # via sphinxcontrib-soliditydomain +babel==2.8.0 # via sphinx +certifi==2020.6.20 # via requests +chardet==3.0.4 # via requests +docutils==0.16 # via sphinx +idna==2.10 # via requests +imagesize==1.2.0 # via sphinx +jinja2==2.11.2 # via sphinx +markupsafe==1.1.1 # via jinja2 +packaging==20.4 # via sphinx +peewee==3.13.3 # via sphinxcontrib-soliditydomain +pygments==2.6.1 # via sphinx +pyparsing==2.4.7 # via packaging +pytz==2020.1 # via babel +requests==2.24.0 # via sphinx +six==1.15.0 # via packaging +snowballstemmer==2.0.0 # via sphinx +sphinx-rtd-theme==0.5.0 # via -r requirements.in +sphinx==3.1.2 # via -r requirements.in, sphinx-rtd-theme +sphinxcontrib-applehelp==1.0.2 # via sphinx +sphinxcontrib-devhelp==1.0.2 # via sphinx +sphinxcontrib-htmlhelp==1.0.3 # via sphinx +sphinxcontrib-jsmath==1.0.1 # via sphinx +sphinxcontrib-qthelp==1.0.3 # via sphinx +sphinxcontrib-serializinghtml==1.1.4 # via sphinx +sphinxcontrib-soliditydomain==0.5.1 # via -r requirements.in +urllib3==1.25.10 # via requests + +# The following packages are considered to be unsafe in a requirements file: +# setuptools From 67782972a86cce9e4651e4bae1026abd42d35458 Mon Sep 17 00:00:00 2001 From: "Michele \"Ubik\" De Simoni" Date: Sat, 8 Aug 2020 21:15:09 +0200 Subject: [PATCH 2/4] Configure Sphinx for Solidity integration --- .github/ISSUE_TEMPLATE/documentation-issue.md | 34 +++ .gitignore | 268 +++++++++++++++++- CONTRIBUTING.md | 56 ++++ README.md | 4 + contracts/BUIDLHodl.sol | 198 ++++++++++--- requirements.in => docs/requirements.in | 0 requirements.txt => docs/requirements.txt | 2 +- docs/source/api.rst | 5 + docs/source/conf.py | 6 +- docs/source/index.rst | 3 +- 10 files changed, 523 insertions(+), 53 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/documentation-issue.md create mode 100644 CONTRIBUTING.md create mode 100644 README.md rename requirements.in => docs/requirements.in (100%) rename requirements.txt => docs/requirements.txt (95%) create mode 100644 docs/source/api.rst diff --git a/.github/ISSUE_TEMPLATE/documentation-issue.md b/.github/ISSUE_TEMPLATE/documentation-issue.md new file mode 100644 index 0000000..a5182c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation-issue.md @@ -0,0 +1,34 @@ +--- +name: Documentation Issue +about: Use this template for documentation related +title: "[DOC] - Short meaningful description of documentation issue" +labels: 'Documentation' +assignees: '' + +--- + +## URL(s) with the issue: +Please provide a link to the documentation entry. + +## Description of issue (what needs changing): + +### Clear description +For example, why should someone use this method? How is it useful? + +### Correct links +Is the link to the source code correct? + +### Parameters defined +Are all parameters defined and formatted correctly? + +### Returns defined +Are return values defined? + +### Raises listed and defined +Are the errors defined? + +### Usage example +Is there a usage example? + +### Request visuals, if applicable +Are there currently visuals? If not, will it clarify the content? diff --git a/.gitignore b/.gitignore index 7ff9640..0177b03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,268 @@ -/**/.DS_Store /**/.vscode /**/spa/**/style.css -/**/node_modules -/**/package-lock.json -/**/npm/dist docs/build + +# Created by https://www.toptal.com/developers/gitignore/api/python,solidity,visualstudiocode,react +# Edit at https://www.toptal.com/developers/gitignore?templates=python,solidity,visualstudiocode,react + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +### react ### +.DS_* +logs +**/*.backup.* +**/*.back.* + +node_modules +bower_components + +*.sublime* + +psd +thumb +sketch + +### Solidity ### +# Logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env.test + +# parcel-bundler cache (https://parceljs.org/) + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +# End of https://www.toptal.com/developers/gitignore/api/python,solidity,visualstudiocode,react diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ca6bb65 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,56 @@ +# Contributing guidelines + +## Table of Contents + +- [Table of Contents](#table-of-contents) +- [Coding Style](#coding-style) + - [Solidity](#solidity) + - [JavaScript](#javascript) + - [Python](#python) +- [Documentation](#documentation) + +## Coding Style + +### Solidity + +* Solidity portions of the codebase adhere follow the official [Solidity Styleguide] + +### JavaScript + +### Python + +* Python portions of the codebase follow standard PEP8 best practices. +* Python code must be formatted using the Black formatter using the provided settings. + +## Documentation + +New addition to the codebase must be fully documented. + +- JavaScript portions of the code should be annotated using JSDoc style docstrings. +- Solidity portions of the code should be fully annotated using [NatSpec] and [Solidity Domain for Sphinx]. + +Documentation is generated using Sphinx and reStructuredText, following the example set by Solidity. For a more comprehensive +description of the documentation process see [Write the Docs!] + +To locally generate the documentation either use: + +```console +tox -e docs +``` + +Or DIY: + +```console +virtualenv .venv +source .venv/bin/activate +pip install -r docs/requirements.txt +cd docs +make html +``` + +--- + +[Solidity Styleguide]: https://solidity.readthedocs.io/en/v0.7.0/style-guide.html +[NatSpec]: https://solidity.readthedocs.io/en/v0.7.0/style-guide.html#natspec +[Write the Docs!]: docs/source/write_the_docs.rst +[Solidity Domain for Sphinx]: https://solidity-domain-for-sphinx.readthedocs.io/en/latest/formatting.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..5939f56 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# dfo-hub + +## Table of Contents +- [Table of Contents](#table-of-contents) diff --git a/contracts/BUIDLHodl.sol b/contracts/BUIDLHodl.sol index 030016e..aa03d2d 100644 --- a/contracts/BUIDLHodl.sol +++ b/contracts/BUIDLHodl.sol @@ -1,7 +1,7 @@ pragma solidity ^0.6.0; +/// @title contract BUIDLHodl { - uint256 private constant MODES = 3; address private _proxy; @@ -28,7 +28,15 @@ contract BUIDLHodl { bool withrawed; } - event Staked(address indexed sender, uint256 indexed mode, bool eth, uint256 amountIn, uint256 tokenPool, uint256 reward, uint256 endBlock); + event Staked( + address indexed sender, + uint256 indexed mode, + bool eth, + uint256 amountIn, + uint256 tokenPool, + uint256 reward, + uint256 endBlock + ); constructor( address proxy, @@ -43,8 +51,8 @@ contract BUIDLHodl { ) public { assert( blocksRanges.length == MODES && - blocksRanges.length == tokenRewardsMultipliers.length && - tokenRewardsMultipliers.length == tokenRewardsDividers.length + blocksRanges.length == tokenRewardsMultipliers.length && + tokenRewardsMultipliers.length == tokenRewardsDividers.length ); _buidlTokenAddress = IMVDProxy(_proxy = proxy).getToken(); _usdcTokenAddress = usdcTokenAddress; @@ -53,75 +61,119 @@ contract BUIDLHodl { _buidlUSDCPoolTokenAddress = buidlUSDCPoolTokenAddress; _accumulatingEndBlock = accumulatingEndBlock; _blocksRanges = blocksRanges; - for(uint256 i = 0; i < tokenRewardsMultipliers.length; i++) { - _tokenRewards.push([tokenRewardsMultipliers[i], tokenRewardsDividers[i]]); + for (uint256 i = 0; i < tokenRewardsMultipliers.length; i++) { + _tokenRewards.push( + [tokenRewardsMultipliers[i], tokenRewardsDividers[i]] + ); } } - function proxy() public view returns(address) { + function proxy() public view returns (address) { return _proxy; } function setProxy(address newProxy) public { - require(IMVDFunctionalitiesManager(IMVDProxy(_proxy).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized Action!"); + require( + IMVDFunctionalitiesManager( + IMVDProxy(_proxy).getMVDFunctionalitiesManagerAddress() + ) + .isAuthorizedFunctionality(msg.sender), + "Unauthorized Action!" + ); _proxy = newProxy; } - function lock(uint256 buidlIn, uint256 usdcIn, uint256 mode) public payable { - require(block.number < _accumulatingEndBlock, "Accumulating Time has finished!"); + function lock( + uint256 buidlIn, + uint256 usdcIn, + uint256 mode + ) public payable { + require( + block.number < _accumulatingEndBlock, + "Accumulating Time has finished!" + ); require(mode < MODES, "Unknown mode!"); - uint256 reward =_calculateReward(buidlIn, mode); + uint256 reward = _calculateReward(buidlIn, mode); _installStorageIfNecessary(msg.sender); StakingInfo[] storage array = _totalLocked[msg.sender][mode]; - array.push(StakingInfo(msg.value > 0, buidlIn, reward, block.number + _blocksRanges[mode], false)); + array.push( + StakingInfo( + msg.value > 0, + buidlIn, + reward, + block.number + _blocksRanges[mode], + false + ) + ); _totalLocked[msg.sender][mode] = array; - if(msg.value == 0) { - IERC20(_usdcTokenAddress).transferFrom(msg.sender, address(this), usdcIn); + if (msg.value == 0) { + IERC20(_usdcTokenAddress).transferFrom( + msg.sender, + address(this), + usdcIn + ); } - emit Staked(msg.sender, mode, msg.value > 0, msg.value > 0 ? msg.value : buidlIn, 0, reward, block.number + _blocksRanges[mode]); + emit Staked( + msg.sender, + mode, + msg.value > 0, + msg.value > 0 ? msg.value : buidlIn, + 0, + reward, + block.number + _blocksRanges[mode] + ); } function _installStorageIfNecessary(address sender) private { - if(_totalLocked[sender].length > 0) { + if (_totalLocked[sender].length > 0) { return; } - for(uint256 i = 0; i < MODES; i++) { + for (uint256 i = 0; i < MODES; i++) { _totalLocked[sender].push(new StakingInfo[]); } } - function _calculateReward(uint256 amount, uint256 mode) private view returns (uint256) { + function _calculateReward(uint256 amount, uint256 mode) + private + view + returns (uint256) + { return _tokenRewards[mode][0]; } function withdraw(address sender) public { - require(block.number >= _accumulatingEndBlock, "Accumulating Time is still running!"); + require( + block.number >= _accumulatingEndBlock, + "Accumulating Time is still running!" + ); StakingInfo[][] storage stakingInfos = _totalLocked[sender]; uint256 ethPoolTokens = 0; uint256 usdcPoolTokens = 0; uint256 buidlTokens = 0; - for(uint256 i = 0; i < _blocksRanges.length; i++) { - for(uint256 z = 0; z < stakingInfos[i].length; z++) { + for (uint256 i = 0; i < _blocksRanges.length; i++) { + for (uint256 z = 0; z < stakingInfos[i].length; z++) { StakingInfo storage stakingInfo = stakingInfos[i][z]; - if(stakingInfo.withrawed) { + if (stakingInfo.withrawed) { continue; } - if(stakingInfo.unlockBlock > block.number) { + if (stakingInfo.unlockBlock > block.number) { break; } stakingInfo.withrawed = true; ethPoolTokens += stakingInfo.eth ? stakingInfo.amountLocked : 0; - usdcPoolTokens += stakingInfo.eth ? 0 : stakingInfo.amountLocked; + usdcPoolTokens += stakingInfo.eth + ? 0 + : stakingInfo.amountLocked; buidlTokens += stakingInfo.reward; } } - if(ethPoolTokens > 0) { + if (ethPoolTokens > 0) { IERC20(_buidlEthPoolTokenAddress).transfer(sender, ethPoolTokens); } - if(usdcPoolTokens > 0) { + if (usdcPoolTokens > 0) { IERC20(_buidlUSDCPoolTokenAddress).transfer(sender, usdcPoolTokens); } - if(buidlTokens > 0) { + if (buidlTokens > 0) { IERC20(_buidlTokenAddress).transfer(sender, buidlTokens); } } @@ -129,36 +181,90 @@ contract BUIDLHodl { interface IERC20 { function balanceOf(address account) external view returns (uint256); - function transfer(address recipient, uint256 amount) external returns (bool); - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + function transfer(address recipient, uint256 amount) + external + returns (bool); + + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + function burn(uint256 amount) external; } - interface IUniswapV2Router { function WETH() external pure returns (address); - function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); - function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); - function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); + + function getAmountsOut(uint256 amountIn, address[] calldata path) + external + view + returns (uint256[] memory amounts); + + function swapExactTokensForETH( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external returns (uint256[] memory amounts); + + function swapExactTokensForTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline + ) external returns (uint256[] memory amounts); } interface IMVDProxy { - function getToken() external view returns(address); - function getStateHolderAddress() external view returns(address); - function getMVDWalletAddress() external view returns(address); - function getMVDFunctionalitiesManagerAddress() external view returns(address); - function submit(string calldata codeName, bytes calldata data) external payable returns(bytes memory returnData); - function transfer(address receiver, uint256 value, address token) external; + function getToken() external view returns (address); + + function getStateHolderAddress() external view returns (address); + + function getMVDWalletAddress() external view returns (address); + + function getMVDFunctionalitiesManagerAddress() + external + view + returns (address); + + function submit(string calldata codeName, bytes calldata data) + external + payable + returns (bytes memory returnData); + + function transfer( + address receiver, + uint256 value, + address token + ) external; } interface IMVDFunctionalitiesManager { - function isAuthorizedFunctionality(address functionality) external view returns(bool); + function isAuthorizedFunctionality(address functionality) + external + view + returns (bool); } interface IStateHolder { - function setUint256(string calldata name, uint256 value) external returns(uint256); - function getUint256(string calldata name) external view returns(uint256); - function getAddress(string calldata name) external view returns(address); - function setAddress(string calldata varName, address val) external returns (address); - function clear(string calldata varName) external returns(string memory oldDataType, bytes memory oldVal); -} \ No newline at end of file + function setUint256(string calldata name, uint256 value) + external + returns (uint256); + + function getUint256(string calldata name) external view returns (uint256); + + function getAddress(string calldata name) external view returns (address); + + function setAddress(string calldata varName, address val) + external + returns (address); + + function clear(string calldata varName) + external + returns (string memory oldDataType, bytes memory oldVal); +} diff --git a/requirements.in b/docs/requirements.in similarity index 100% rename from requirements.in rename to docs/requirements.in diff --git a/requirements.txt b/docs/requirements.txt similarity index 95% rename from requirements.txt rename to docs/requirements.txt index 28347b9..d80e570 100644 --- a/requirements.txt +++ b/docs/requirements.txt @@ -5,7 +5,7 @@ # pip-compile requirements.in # alabaster==0.7.12 # via sphinx -antlr4-python3-runtime==4.8 # via sphinxcontrib-soliditydomain +antlr4-python3-runtime==4.7.1 # via sphinxcontrib-soliditydomain babel==2.8.0 # via sphinx certifi==2020.6.20 # via requests chardet==3.0.4 # via requests diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..ca7a377 --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,5 @@ +############# +API Reference +############# + +.. autosolcontract:: BUIDLHodl diff --git a/docs/source/conf.py b/docs/source/conf.py index fee0091..c3f163c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,8 +23,11 @@ copyright = "2020, dfo-hub" author = "dfo-hub" + +# The short X.Y version +version = "0.x.0" # The full version, including alpha/beta/rc tags -release = "0.3.0" +release = "0.x.0" # -- General configuration --------------------------------------------------- @@ -35,6 +38,7 @@ extensions = [ "sphinx.ext.autodoc", "sphinxcontrib.soliditydomain", + "sphinx.ext.intersphinx", ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/source/index.rst b/docs/source/index.rst index 0f609d8..fd3aba0 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,8 +8,9 @@ Welcome to dfo-hub's documentation! .. toctree:: :maxdepth: 2 - :caption: Contents: + :caption: Contents:' + api Indices and tables From 8e2314f69ca1c55402f433efdbef592a4ced12ae Mon Sep 17 00:00:00 2001 From: "Michele \"Ubik\" De Simoni" Date: Sun, 9 Aug 2020 23:14:10 +0200 Subject: [PATCH 3/4] Remove tox mention from contributing --- CONTRIBUTING.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca6bb65..0f84b45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,13 +32,7 @@ New addition to the codebase must be fully documented. Documentation is generated using Sphinx and reStructuredText, following the example set by Solidity. For a more comprehensive description of the documentation process see [Write the Docs!] -To locally generate the documentation either use: - -```console -tox -e docs -``` - -Or DIY: +To locally generate the documentation: ```console virtualenv .venv From bc86a09a24815dd7c093c08a91506e2701d28573 Mon Sep 17 00:00:00 2001 From: "Michele \"Ubik\" De Simoni" Date: Thu, 3 Sep 2020 21:05:23 +0200 Subject: [PATCH 4/4] Add part info on docs pipeline --- CONTRIBUTING.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f84b45..43b8b82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,22 +13,28 @@ ### Solidity -* Solidity portions of the codebase adhere follow the official [Solidity Styleguide] +- Solidity portions of the codebase adhere follow the official [Solidity Styleguide] +- `.sol` filename should be PascalCase ### JavaScript ### Python -* Python portions of the codebase follow standard PEP8 best practices. -* Python code must be formatted using the Black formatter using the provided settings. +- Python portions of the codebase follow standard PEP8 best practices. +- Python code must be formatted using the Black formatter using the provided settings. ## Documentation +**NOTE:** Currently the documentation pipeline is composed by a custom Python Parser that output `md` +files and renders them via `mkdocs`. We are however working on a more comprehensive solution built +around Sphinx and reStructuredText. + New addition to the codebase must be fully documented. - JavaScript portions of the code should be annotated using JSDoc style docstrings. -- Solidity portions of the code should be fully annotated using [NatSpec] and [Solidity Domain for Sphinx]. +- Solidity portions of the code should be fully annotated according to [NatSpec] standards. + ---