diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml new file mode 100644 index 0000000..47013fe --- /dev/null +++ b/.github/workflows/canary.yml @@ -0,0 +1,56 @@ +name: Canary Release + +on: workflow_dispatch + +jobs: + export: + name: Generate Interfaces And Contracts + + runs-on: ubuntu-latest + strategy: + matrix: + export_type: ['interfaces', 'all'] + + env: + PROJECT_NAME: '@defi-wonderland/prophet-core' + EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install Node + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + node-version: 20.x + cache: 'yarn' + + - name: Install dependencies + run: yarn --frozen-lockfile + + - name: Build project and generate out directory + run: yarn build + + - name: Update version + run: yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version + + - name: Export Solidity - Export Type ${{ matrix.export_type }} + uses: defi-wonderland/solidity-exporter-action@v2.1.0 + with: + package_name: ${{ env.PROJECT_NAME }} + out: 'out' + interfaces: 'solidity/interfaces' + contracts: 'solidity/contracts' + libraries: "solidity/libraries" + export_type: '${{ matrix.export_type }}' + + - name: Publish to NPM - Export Type ${{ matrix.export_type }} + run: cd export/${{ env.PROJECT_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag canary + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/interfaces-canary.yml b/.github/workflows/interfaces-canary.yml deleted file mode 100644 index 1ea9515..0000000 --- a/.github/workflows/interfaces-canary.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Interface Exporter Action - Canary - -on: workflow_dispatch - -jobs: - generate-and-publish-interfaces: - name: Generate Interfaces (canary) - runs-on: ubuntu-latest - strategy: - matrix: - typing_type: ["abi", "contracts"] - - steps: - - uses: actions/checkout@v3 - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: "https://registry.npmjs.org" - - - name: Install dependencies - run: yarn --frozen-lockfile - - - name: Build project and generate out directory - run: yarn build - - - name: Update version - run: yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version - - - name: Export Interfaces - ${{ matrix.typing_type }} - uses: defi-wonderland/interface-exporter-action@v1.2.2 - with: - out_dir: "out" - interfaces_dir: "solidity/interfaces" - contracts_dir: "solidity/contracts" - typing_type: "${{ matrix.typing_type }}" - package_name: "@defi-wonderland/prophet-core-${{ matrix.typing_type }}" - destination_dir: "exported-interfaces/prophet-core-${{ matrix.typing_type }}" - - - name: Publish - run: cd exported-interfaces/prophet-core-${{ matrix.typing_type }} && npm publish --access public --tag canary - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/interfaces-production.yml b/.github/workflows/interfaces-production.yml deleted file mode 100644 index da3fd7d..0000000 --- a/.github/workflows/interfaces-production.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Interface Exporter Action - Production - -on: - push: - branches: - - main - -jobs: - generate-and-publish-interfaces: - if: github.repository == 'defi-wonderland/prophet-core' - name: Generate Interfaces - runs-on: ubuntu-latest - strategy: - matrix: - typing_type: ["abi", "contracts"] - - steps: - - uses: actions/checkout@v3 - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: "https://registry.npmjs.org" - - - name: Install dependencies - run: yarn --frozen-lockfile - - - name: Build project and generate out directory - run: yarn build - - - name: Export Interfaces - ${{ matrix.typing_type }} - uses: defi-wonderland/interface-exporter-action@v1.2.2 - with: - out_dir: "out" - interfaces_dir: "solidity/interfaces" - contracts_dir: "solidity/contracts" - typing_type: "${{ matrix.typing_type }}" - package_name: "@defi-wonderland/prophet-core-${{ matrix.typing_type }}" - destination_dir: "exported-interfaces/prophet-core-${{ matrix.typing_type }}" - - - name: Publish - run: cd exported-interfaces/prophet-core-${{ matrix.typing_type }} && npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..56cf9aa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Production Release + +on: + release: + types: [published] + +jobs: + release: + name: Release + + runs-on: ubuntu-latest + strategy: + matrix: + export_type: ['interfaces', 'all'] + + env: + PROJECT_NAME: '@defi-wonderland/prophet-core' + EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install Node + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + node-version: 20.x + cache: 'yarn' + + - name: Install dependencies + run: yarn --frozen-lockfile + + - name: Build project and generate out directory + run: yarn build + + - name: Export Solidity - Export Type ${{ matrix.export_type }} + uses: defi-wonderland/solidity-exporter-action@v2.1.0 + with: + package_name: ${{ env.PROJECT_NAME }} + out: 'out' + interfaces: 'solidity/interfaces' + contracts: 'solidity/contracts' + libraries: "solidity/libraries" + export_type: '${{ matrix.export_type }}' + + - name: Publish to NPM - Export Type ${{ matrix.export_type }} + run: cd export/${{ env.PROJECT_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/solidity/contracts/Oracle.sol b/solidity/contracts/Oracle.sol index 8e66005..521b2e7 100644 --- a/solidity/contracts/Oracle.sol +++ b/solidity/contracts/Oracle.sol @@ -9,9 +9,11 @@ import {IFinalityModule} from '../interfaces/modules/finality/IFinalityModule.so import {IRequestModule} from '../interfaces/modules/request/IRequestModule.sol'; import {IResolutionModule} from '../interfaces/modules/resolution/IResolutionModule.sol'; import {IResponseModule} from '../interfaces/modules/response/IResponseModule.sol'; -import {ValidatorLib} from '../lib/ValidatorLib.sol'; +import {ValidatorLib} from '../libraries/ValidatorLib.sol'; contract Oracle is IOracle { + using ValidatorLib for *; + /// @inheritdoc IOracle mapping(bytes32 _requestId => uint128 _finalizedAt) public finalizedAt; @@ -106,7 +108,7 @@ contract Oracle is IOracle { Response calldata _response ) external returns (bytes32 _responseId) { bytes32 _requestId = ValidatorLib._getId(_request); - (_responseId) = ValidatorLib._validateResponse(_request, _response); + _responseId = ValidatorLib._validateResponse(_request, _response); if (requestCreatedAt[_requestId] == 0) { revert Oracle_InvalidRequest(); diff --git a/solidity/contracts/Validator.sol b/solidity/contracts/Validator.sol index 00b0d55..515aa92 100644 --- a/solidity/contracts/Validator.sol +++ b/solidity/contracts/Validator.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.19; import {IOracle, IValidator} from '../interfaces/IValidator.sol'; -import {ValidatorLib} from '../lib/ValidatorLib.sol'; +import {ValidatorLib} from '../libraries/ValidatorLib.sol'; abstract contract Validator is IValidator { /// @inheritdoc IValidator diff --git a/solidity/lib/ValidatorLib.sol b/solidity/libraries/ValidatorLib.sol similarity index 100% rename from solidity/lib/ValidatorLib.sol rename to solidity/libraries/ValidatorLib.sol diff --git a/solidity/test/unit/modules/Module.t.sol b/solidity/test/unit/Module.t.sol similarity index 89% rename from solidity/test/unit/modules/Module.t.sol rename to solidity/test/unit/Module.t.sol index 0d9e40d..fbce818 100644 --- a/solidity/test/unit/modules/Module.t.sol +++ b/solidity/test/unit/Module.t.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.19; import 'forge-std/Test.sol'; -import {IModule, Module} from '../../../contracts/Module.sol'; -import {IOracle} from '../../../interfaces/IOracle.sol'; -import {Helpers} from '../../utils/Helpers.sol'; +import {IModule, Module} from '../../contracts/Module.sol'; +import {IOracle} from '../../interfaces/IOracle.sol'; +import {Helpers} from '../utils/Helpers.sol'; /** * @dev Harness to deploy the abstract contract diff --git a/solidity/test/unit/Oracle.t.sol b/solidity/test/unit/Oracle.t.sol index fe9503c..d5de1cd 100644 --- a/solidity/test/unit/Oracle.t.sol +++ b/solidity/test/unit/Oracle.t.sol @@ -16,7 +16,7 @@ import {IResponseModule} from '../../interfaces/modules/response/IResponseModule import {Oracle} from '../../contracts/Oracle.sol'; import {Helpers} from '../utils/Helpers.sol'; -import {ValidatorLib} from '../../lib/ValidatorLib.sol'; +import {ValidatorLib} from '../../libraries/ValidatorLib.sol'; /** * @notice Harness to deploy and test Oracle diff --git a/solidity/test/unit/Validator.t.sol b/solidity/test/unit/Validator.t.sol index d6d19d4..3a69d68 100644 --- a/solidity/test/unit/Validator.t.sol +++ b/solidity/test/unit/Validator.t.sol @@ -14,7 +14,7 @@ import {IResponseModule} from '../../interfaces/modules/response/IResponseModule import {IValidator, Validator} from '../../contracts/Validator.sol'; -import {ValidatorLib} from '../../lib/ValidatorLib.sol'; +import {ValidatorLib} from '../../libraries/ValidatorLib.sol'; import {Helpers} from '../utils/Helpers.sol'; diff --git a/solidity/test/lib/ValidatorLib.t.sol b/solidity/test/unit/ValidatorLib.t.sol similarity index 98% rename from solidity/test/lib/ValidatorLib.t.sol rename to solidity/test/unit/ValidatorLib.t.sol index b40f246..e45b7ca 100644 --- a/solidity/test/lib/ValidatorLib.t.sol +++ b/solidity/test/unit/ValidatorLib.t.sol @@ -12,7 +12,7 @@ import {IRequestModule} from '../../interfaces/modules/request/IRequestModule.so import {IResolutionModule} from '../../interfaces/modules/resolution/IResolutionModule.sol'; import {IResponseModule} from '../../interfaces/modules/response/IResponseModule.sol'; -import {ValidatorLib} from '../../lib/ValidatorLib.sol'; +import {ValidatorLib} from '../../libraries/ValidatorLib.sol'; import {Helpers} from '../utils/Helpers.sol'; /**