From 56ba85e9463e2c7716684bfa5c86a03ade9b08d8 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 12:56:36 +0100 Subject: [PATCH 1/8] Add publish to Gitlab CI --- .gitlab-ci.yml | 26 ++++++++++++++++++++++++++ package.json | 48 +++++++++++++++++++++--------------------------- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b012440d..4274147d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,10 @@ stages: - checks + - prepare + - publish + +variables: + IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} test: stage: checks @@ -40,3 +45,24 @@ certora-test: - certoraRun specs/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness --solc_args "['--optimize']" --verify StableDebtTokenHarness:specs/StableDebtToken.spec --settings -assumeUnwindCond,-b=4 --cache StableDebtToken --cloud - certoraRun specs/harness/UserConfigurationHarness.sol --verify UserConfigurationHarness:specs/UserConfiguration.spec --solc_args "['--optimize']" --settings -useBitVectorTheory --cache UserConfiguration --cloud - certoraRun contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken specs/harness/LendingPoolHarnessForVariableDebtToken.sol --solc_args "['--optimize']" --link VariableDebtToken:POOL=LendingPoolHarnessForVariableDebtToken --verify VariableDebtToken:specs/VariableDebtToken.spec --settings -assumeUnwindCond,-useNonLinearArithmetic,-b=4 --cache VariableDebtToken --cloud + +prepare: + stage: prepare + tags: + - docker-builder + script: + - docker build -t ${IMAGE} . + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + - docker push ${IMAGE} + only: + - master + +publish: + extends: .image_step + stage: publish + script: + - npm ci + - echo //registry.npmjs.org/:_authToken=${NPM_V2_PACKAGES_TOKEN} > .npmrc + - npm run compile + - ${VERSION} + - npm publish --access public diff --git a/package.json b/package.json index 4fefea1b..ea016bca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,11 @@ { - "name": "protocol-v2", + "name": "@aave/protocol-v2", "version": "1.0.0", "description": "Aave Protocol V2 smart contracts", + "files": [ + "contracts", + "artifacts" + ], "scripts": { "run-env": "npm i && tail -f /dev/null", "hardhat": "hardhat", @@ -62,7 +66,8 @@ "main:initialize-tokens": "npm run compile && hardhat --network main full:initialize-tokens --pool Aave", "kovan:initialize-tokens": "npm run compile && hardhat --network kovan full:initialize-tokens --pool Aave", "external:deploy-assets-kovan": "npm run compile && hardhat --network kovan external:deploy-new-asset --symbol ${SYMBOL} --verify", - "external:deploy-assets-main": "npm run compile && hardhat --network main external:deploy-new-asset --symbol ${SYMBOL} --verify" + "external:deploy-assets-main": "npm run compile && hardhat --network main external:deploy-new-asset --symbol ${SYMBOL} --verify", + "prepublishOnly": "npm run compile" }, "devDependencies": { "@nomiclabs/buidler": "^1.4.7", @@ -118,33 +123,22 @@ }, "author": "Aave", "contributors": [ - { - "name": "Emilio Frangella", - "email": "emilio@aave.com" - }, - { - "name": "Ernesto Boado", - "email": "ernesto@aave.com" - }, - { - "name": "Andrey Kozlov", - "email": "andrey@aave.com" - }, - { - "name": "David Racero", - "email": "david.k@aave.com" - }, - { - "name": "Pol Sendra", - "email": "pol@aave.com" - }, - { - "name": "David Truong", - "email": "david@aave.com" - } + "Ernesto Boado ", + "Emilio Frangella ", + "Andrey Kozlov ", + "David Racero ", + "Pol Sendra ", + "David Truong " ], "license": "AGPLv3", "dependencies": { "tmp-promise": "^3.0.2" - } + }, + "keywords": [ + "aave", + "protocol", + "protocol-v2", + "ethereum", + "solidity" + ] } From 9cd6175f111e2d38f34cd4ac35c659a041323551 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 12:58:39 +0100 Subject: [PATCH 2/8] Fix gitlab ci --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4274147d..25a2d513 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,7 +58,9 @@ prepare: - master publish: - extends: .image_step + image: ${IMAGE} + tags: + - docker stage: publish script: - npm ci From 422d843815332c954983fc735bb5fc5ed627b8d1 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 13:01:37 +0100 Subject: [PATCH 3/8] Run CI to test publish image prepare --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25a2d513..aef1554d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,6 +56,7 @@ prepare: - docker push ${IMAGE} only: - master + - merge_requests publish: image: ${IMAGE} @@ -68,3 +69,6 @@ publish: - npm run compile - ${VERSION} - npm publish --access public + only: + - master + - merge_requests From 5434b279d1bcccde91189598400d0469349c7ab3 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 13:03:06 +0100 Subject: [PATCH 4/8] Fix detached missing tests --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aef1554d..1e0afada 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,9 @@ test: after_script: - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down + only: + - master + - merge_requests deploy-mainnet-fork: tags: @@ -29,6 +32,9 @@ deploy-mainnet-fork: after_script: - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down + only: + - master + - merge_requests certora-test: stage: checks @@ -45,6 +51,9 @@ certora-test: - certoraRun specs/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness --solc_args "['--optimize']" --verify StableDebtTokenHarness:specs/StableDebtToken.spec --settings -assumeUnwindCond,-b=4 --cache StableDebtToken --cloud - certoraRun specs/harness/UserConfigurationHarness.sol --verify UserConfigurationHarness:specs/UserConfiguration.spec --solc_args "['--optimize']" --settings -useBitVectorTheory --cache UserConfiguration --cloud - certoraRun contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken specs/harness/LendingPoolHarnessForVariableDebtToken.sol --solc_args "['--optimize']" --link VariableDebtToken:POOL=LendingPoolHarnessForVariableDebtToken --verify VariableDebtToken:specs/VariableDebtToken.spec --settings -assumeUnwindCond,-useNonLinearArithmetic,-b=4 --cache VariableDebtToken --cloud + only: + - master + - merge_requests prepare: stage: prepare From 2f4219d6430c01d07528d00b0a585c2329fd5aad Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 13:20:32 +0100 Subject: [PATCH 5/8] Detach mode to test prepare and publish step --- .gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e0afada..b743cdbe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,9 +51,6 @@ certora-test: - certoraRun specs/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness --solc_args "['--optimize']" --verify StableDebtTokenHarness:specs/StableDebtToken.spec --settings -assumeUnwindCond,-b=4 --cache StableDebtToken --cloud - certoraRun specs/harness/UserConfigurationHarness.sol --verify UserConfigurationHarness:specs/UserConfiguration.spec --solc_args "['--optimize']" --settings -useBitVectorTheory --cache UserConfiguration --cloud - certoraRun contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken specs/harness/LendingPoolHarnessForVariableDebtToken.sol --solc_args "['--optimize']" --link VariableDebtToken:POOL=LendingPoolHarnessForVariableDebtToken --verify VariableDebtToken:specs/VariableDebtToken.spec --settings -assumeUnwindCond,-useNonLinearArithmetic,-b=4 --cache VariableDebtToken --cloud - only: - - master - - merge_requests prepare: stage: prepare From e84ab7cf0355eb2a146f10ab6750fab73040095f Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 13:34:39 +0100 Subject: [PATCH 6/8] Allow detached to skip tests for testing publish --- .gitlab-ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b743cdbe..aef1554d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,9 +17,6 @@ test: after_script: - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down - only: - - master - - merge_requests deploy-mainnet-fork: tags: @@ -32,9 +29,6 @@ deploy-mainnet-fork: after_script: - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down - only: - - master - - merge_requests certora-test: stage: checks From 9169e0db62dbfe8122de848ae0c295ac7f683af9 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 13:46:48 +0100 Subject: [PATCH 7/8] Add notes about how to use NPM package to import contract or artifacts --- README.md | 31 +++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aba2356e..739ef23c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,37 @@ A more detailed and technical description of the protocol can be found in this r You can join at the [Discord](http://aave.com/discord) channel or at the [Governance Forum](https://governance.aave.com/) for asking questions about the protocol or talk about Aave with other peers. +## Getting Started + +You can install `@aave/protocol-v2` as an NPM package in your Hardhat, Buidler or Truffle project to import the contracts and interfaces: + +`npm install @aave/protocol-v2` + +Import at Solidity files: + +``` +import {ILendingPool} from "@aave/protocol-v2/contracts/interfaces/ILendingPool.sol"; + +contract Misc { + + function deposit(address pool, address token, address user, uint256 amount) { + ILendingPool(pool).deposit(token, amount, user, '0'); + {...} + } +} +``` + +The JSON artifacts with the ABI and Bytecode are also included into the bundled NPM package at `artifacts/` directory. + +Import JSON file via Node JS `require`: + +``` +const LendingPoolV2Artifact = require('@aave/protocol-v2/artifacts/contracts/protocol/lendingpool/LendingPool.sol/LendingPool.json'); + +// Log the ABI into console +console.log(LendingPoolV2Artifact.abi) +``` + ## Setup The repository uses Docker Compose to manage sensitive keys and load the configuration. Prior any action like test or deploy, you must run `docker-compose up` to start the `contracts-env` container, and then connect to the container console via `docker-compose exec contracts-env bash`. diff --git a/package.json b/package.json index ea016bca..d5cd3e16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aave/protocol-v2", - "version": "1.0.0", + "version": "1.0.1", "description": "Aave Protocol V2 smart contracts", "files": [ "contracts", From b2d70ec133e81128d8b9e5142cececeb91f12c36 Mon Sep 17 00:00:00 2001 From: David Racero Date: Tue, 26 Jan 2021 14:02:47 +0100 Subject: [PATCH 8/8] Run tests before publish at master --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aef1554d..cea5dc05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,9 @@ test: after_script: - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down - + only: + - master + - merge_requests deploy-mainnet-fork: tags: - aave-build-runner @@ -29,6 +31,9 @@ deploy-mainnet-fork: after_script: - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down + only: + - master + - merge_requests certora-test: stage: checks @@ -45,6 +50,9 @@ certora-test: - certoraRun specs/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness --solc_args "['--optimize']" --verify StableDebtTokenHarness:specs/StableDebtToken.spec --settings -assumeUnwindCond,-b=4 --cache StableDebtToken --cloud - certoraRun specs/harness/UserConfigurationHarness.sol --verify UserConfigurationHarness:specs/UserConfiguration.spec --solc_args "['--optimize']" --settings -useBitVectorTheory --cache UserConfiguration --cloud - certoraRun contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken specs/harness/LendingPoolHarnessForVariableDebtToken.sol --solc_args "['--optimize']" --link VariableDebtToken:POOL=LendingPoolHarnessForVariableDebtToken --verify VariableDebtToken:specs/VariableDebtToken.spec --settings -assumeUnwindCond,-useNonLinearArithmetic,-b=4 --cache VariableDebtToken --cloud + only: + - master + - merge_requests prepare: stage: prepare @@ -56,7 +64,6 @@ prepare: - docker push ${IMAGE} only: - master - - merge_requests publish: image: ${IMAGE} @@ -71,4 +78,3 @@ publish: - npm publish --access public only: - master - - merge_requests