diff --git a/.github/workflows/abi.yml b/.github/workflows/abi.yml new file mode 100644 index 0000000000..99e30c3068 --- /dev/null +++ b/.github/workflows/abi.yml @@ -0,0 +1,50 @@ +name: DeFi +on: + push: + tags: + - v* + +concurrency: + cancel-in-progress: true + group: ${{ github.ref_name }} + +jobs: + abi-gen: + name: "Generate and publish ABI" + runs-on: ubuntu-latest + environment: master + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "16.x" + cache: "yarn" + cache-dependency-path: contracts/yarn.lock + + - run: yarn install --frozen-lockfile + working-directory: ./contracts + + - name: "Generate ABI files" + run: (yarn run abi:generate) && (yarn run abi:dist) + env: + CONTRACT_SIZE: true + working-directory: ./contracts + + - name: Update version from tag + working-directory: ./contracts/dist + run: | + VERSION="0.1.0" + if [ "${{ env.GITHUB_REF_TYPE }}" = "tag" ]; then + VERSION="${GITHUB_REF_NAME#v}" + fi + + echo "Version set to $VERSION" + sed -i -e "s/RELEASE_VERSION/$VERSION/g" package.json + + - name: "Publish" + run: npm publish --access public + working-directory: ./contracts/dist + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ORIGIN_DEFI }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8140f2aeb4..13d748dadc 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ contracts/deployments/hardhat* contracts/coverage/ contracts/coverage.json contracts/build/ +contracts/dist/ dapp/network.json dapp/keys/ dapp/ganache-network.json diff --git a/contracts/.npmrc.abi b/contracts/.npmrc.abi new file mode 100644 index 0000000000..ababd7a28e --- /dev/null +++ b/contracts/.npmrc.abi @@ -0,0 +1,3 @@ +//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} +registry=https://registry.npmjs.org/ +always-auth=true diff --git a/contracts/abi.package.json b/contracts/abi.package.json new file mode 100644 index 0000000000..6712c2e167 --- /dev/null +++ b/contracts/abi.package.json @@ -0,0 +1,9 @@ +{ + "name": "@origin/defi", + "version": "RELEASE_VERSION", + "license": "MIT", + "homepage": "https://github.com/originprotocol/origin-dollar", + "engines": { + "node": "16" + } +} diff --git a/contracts/package.json b/contracts/package.json index 121912cf5b..96c861fae6 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -8,6 +8,8 @@ "deploy:mainnet": "(npx hardhat deploy --network mainnet --verbose --export '../dapp/network.mainnet.json') && yarn run copy-interface-artifacts", "deploy:oeth": "(rm -rf deployments/hardhat && npx hardhat deploy --export '../dapp-oeth/network.json') && yarn run copy-interface-artifacts:oeth", "deploy:oeth:mainnet": "(npx hardhat deploy --network mainnet --verbose --export '../dapp-oeth/network.mainnet.json') && yarn run copy-interface-artifacts", + "abi:generate": "(rm -rf deployments/hardhat && mkdir -p dist/abi && npx hardhat deploy --export '../dist/network.json')", + "abi:dist": "find ./artifacts/contracts -name \"*.json\" -type f -exec cp {} ./dist/abi \\; && rm -rf dist/abi/*.dbg.json dist/abi/Mock*.json && cp ./abi.package.json dist/package.json && cp ./.npmrc.abi dist/.npmrc", "node": "yarn run node:fork", "node:fork": "./node.sh fork", "lint": "yarn run lint:js && yarn run lint:sol", diff --git a/package.json b/package.json index 9baadec94d..9d0645e27d 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,6 @@ "build:oethdapp": "(cd dapp-oeth && NODE_ENV=development yarn install && yarn build)", "start": "bash devops/start-dapp.sh" }, - "dependencies": { - "react-use": "^17.4.0" - }, "engines": { "node": "16" }