From 5357df3e81a0296db68b666d73d4b957efbfaca8 Mon Sep 17 00:00:00 2001 From: Harjyot Singh Date: Wed, 28 Apr 2021 21:21:18 +0530 Subject: [PATCH] Skale endpoint addition & Github workflows for docker & pypi deploys (#261) * Added SKALE Network Testnet Endpoint * Switch to new version and repo. * Switch version in package.json * Create docker-publish.yml * Remove stop from end of test script, solve naming inconsistency in library, make handlers add other handlers instead of factory. * Create python-publish.yml * Go 0.9.1 * Correct docker image * Fail CI check if tests fail Co-authored-by: Christine Perry Co-authored-by: Vlad Silviu Farcas --- .github/workflows/docker-publish.yml | 28 +++++++++++++++++++++++++ .github/workflows/python-publish.yml | 31 ++++++++++++++++++++++++++++ bin/ci | 5 +---- contracts/Escrow.sol | 2 +- docker-compose.yml | 2 +- hmt_escrow/eth_bridge.py | 2 +- hmt_escrow/job.py | 6 +++--- hmt_escrow/storage.py | 2 +- package-lock.json | 2 +- package.json | 2 +- setup.py | 4 ++-- truffle.js | 4 ++++ 12 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..ec78d572 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,28 @@ +name: Docker + +on: + push: + # Publish `master` as Docker `latest` image. + branches: + - master + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run tests for any PRs. + pull_request: + + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + ./bin/ci diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 00000000..1a03a7b6 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/bin/ci b/bin/ci index 60390523..04d6fc04 100755 --- a/bin/ci +++ b/bin/ci @@ -6,7 +6,4 @@ set -exu docker-compose build docker-compose run --no-deps -e CI=true job './bin/lint' docker-compose run job -docker-compose run job ./bin/generate-docs - -./bin/stop - +docker-compose run job ./bin/generate-docs \ No newline at end of file diff --git a/contracts/Escrow.sol b/contracts/Escrow.sol index 10a4f98c..74e17d66 100644 --- a/contracts/Escrow.sol +++ b/contracts/Escrow.sol @@ -56,7 +56,7 @@ contract Escrow { } function addTrustedHandlers(address[] memory _handlers) public { - require(msg.sender == launcher, "Address calling cannot add trusted handllers"); + require(areTrustedHandlers[msg.sender], "Address calling cannot add trusted handlers"); for (uint256 i = 0; i < _handlers.length; i++) { areTrustedHandlers[_handlers[i]] = true; } diff --git a/docker-compose.yml b/docker-compose.yml index 939b4f07..97e871e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: job: - image: hcaptcha/hmt-escrow:latest + image: humanprotocol/hmt-escrow:latest build: . environment: - HMT_ETH_SERVER=http://ganache:8545 diff --git a/hmt_escrow/eth_bridge.py b/hmt_escrow/eth_bridge.py index 7e18ba5b..df6a5578 100644 --- a/hmt_escrow/eth_bridge.py +++ b/hmt_escrow/eth_bridge.py @@ -396,4 +396,4 @@ def test_set_pub_key_at_address(self): if __name__ == "__main__": from test_manifest import manifest - unittest.main(exit=False) + unittest.main(exit=True) diff --git a/hmt_escrow/job.py b/hmt_escrow/job.py index decf441a..adf772ad 100644 --- a/hmt_escrow/job.py +++ b/hmt_escrow/job.py @@ -136,7 +136,7 @@ def manifest_hash( def is_trusted_handler( escrow_contract: Contract, handler_addr: str, gas_payer: str, gas: int = GAS_LIMIT ) -> bool: - return escrow_contract.functions.isTrustedHandler(handler_addr).call( + return escrow_contract.functions.areTrustedHandlers(handler_addr).call( {"from": gas_payer, "gas": Wei(gas)} ) @@ -1666,7 +1666,7 @@ def test_job_bulk_payout(self): def test_job_abort(self): - # The escrow contract is in Paid state after the a full bulk payout and it can't be aborted. + # The escrow contract is in Paid state after the full bulk payout and it can't be aborted. self.assertTrue(self.job.launch(self.rep_oracle_pub_key)) self.assertTrue(self.job.setup()) @@ -1726,4 +1726,4 @@ def test_job_balance(self): if __name__ == "__main__": from test_manifest import manifest - unittest.main(exit=False) + unittest.main(exit=True) diff --git a/hmt_escrow/storage.py b/hmt_escrow/storage.py index b3bf7ff8..45f3f1cd 100644 --- a/hmt_escrow/storage.py +++ b/hmt_escrow/storage.py @@ -257,4 +257,4 @@ def test_encrypt(self): from test_manifest import manifest from job import Job - unittest.main(exit=False) + unittest.main(exit=True) diff --git a/package-lock.json b/package-lock.json index 6b6bf3ac..cdb91813 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hmt-escrow", - "version": "0.8.11", + "version": "0.9.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 97a0a848..be8ccac6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hmt-escrow", - "version": "0.8.11", + "version": "0.9.1", "description": "Launch escrow contracts to the HUMAN network", "main": "truffle.js", "directories": { diff --git a/setup.py b/setup.py index 6b199be7..79bbc47c 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,10 @@ setuptools.setup( name="hmt-escrow", - version="0.8.11", + version="0.9.1", author="HUMAN Protocol", description="A python library to launch escrow contracts to the HUMAN network.", - url="https://github.com/hCaptcha/hmt-escrow", + url="https://github.com/humanprotocol/hmt-escrow", include_package_data=True, zip_safe=True, classifiers=[ diff --git a/truffle.js b/truffle.js index b2c6c292..fba3e1cc 100644 --- a/truffle.js +++ b/truffle.js @@ -37,6 +37,10 @@ module.exports = { provider: () => new PrivateKeyProvider(PRIV_KEY, 'https://rpc.testnet.moonbeam.network', 1287), network_id: '1287', }, + skale: { + provider: () => new HDWalletProvider(MNEMONIC, 'https://humanprotocol-integration.skale.network', 0, 10), + network_id: '344435', + }, }, compilers: { solc: {