From ad7e533dfc2f901ccb00f00aac06b0fb58fc4718 Mon Sep 17 00:00:00 2001 From: OneTony Date: Fri, 18 Oct 2024 12:02:24 +0300 Subject: [PATCH 1/9] feat: npm exporter action --- .github/workflows/release.yml | 55 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..8397788a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Release + +on: [push] + +jobs: + release: + name: Release + + runs-on: ubuntu-latest + strategy: + matrix: + export_type: ['interfaces', 'all'] + + env: + PROJECT_NAME: '@allo-protocol/allo-v2.1' + EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Setup bun env + uses: oven-sh/setup-bun@v1 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install dependencies + run: bun install + + - name: Build project and generate out directory + run: bun run 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: 'contracts/core/interfaces' + contracts: 'contracts/core' + libraries: "contracts/core/libraries" + export_type: '${{ matrix.export_type }}' + + - name: Publish to NPM + 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/package.json b/package.json index e6ba98ca4..896962122 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "private": true, "scripts": { "compile": "forge compile", - "build": "forge build", + "build": "bun run smock && forge build", "test": "forge test", "fmt": "forge fmt contracts/**/*.sol && forge fmt test/**/*.sol", "lint:sol": "solhint -c .solhint.json 'contracts/**/*.sol'", From 767742fa08d7492841202254ee3cc39fd96efd22 Mon Sep 17 00:00:00 2001 From: OneTony Date: Fri, 18 Oct 2024 12:06:35 +0300 Subject: [PATCH 2/9] fix: package json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 896962122..e6ba98ca4 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "private": true, "scripts": { "compile": "forge compile", - "build": "bun run smock && forge build", + "build": "forge build", "test": "forge test", "fmt": "forge fmt contracts/**/*.sol && forge fmt test/**/*.sol", "lint:sol": "solhint -c .solhint.json 'contracts/**/*.sol'", From ceb5a21df6708231b91d904b773e1c7ede0e1019 Mon Sep 17 00:00:00 2001 From: OneTony Date: Fri, 18 Oct 2024 12:11:03 +0300 Subject: [PATCH 3/9] fix: workflow --- .github/workflows/release.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8397788a9..2210b9b5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,28 +16,29 @@ jobs: EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }} steps: - - name: Checkout Repo - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "recursive" + fetch-depth: 1 - name: Setup bun env uses: oven-sh/setup-bun@v1 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: bun install - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: version: nightly - - name: Install dependencies - run: bun install + - name: Run Smock + run: bun smock + id: smock - name: Build project and generate out directory - run: bun run build + run: forge build - name: Export Solidity - Export Type ${{ matrix.export_type }} uses: defi-wonderland/solidity-exporter-action@v2.1.0 From c900dca446a0618c0abe65d2ae8b1a512b89541c Mon Sep 17 00:00:00 2001 From: OneTony Date: Mon, 21 Oct 2024 12:40:50 +0300 Subject: [PATCH 4/9] fix: workflow --- .github/workflows/{release.yml => canary.yml} | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) rename .github/workflows/{release.yml => canary.yml} (64%) diff --git a/.github/workflows/release.yml b/.github/workflows/canary.yml similarity index 64% rename from .github/workflows/release.yml rename to .github/workflows/canary.yml index 2210b9b5f..dc38e4553 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/canary.yml @@ -1,10 +1,10 @@ -name: Release +name: Canary Release -on: [push] +on: workflow_dispatch jobs: - release: - name: Release + export: + name: Generate Interfaces And Contracts runs-on: ubuntu-latest strategy: @@ -23,7 +23,7 @@ jobs: fetch-depth: 1 - name: Setup bun env - uses: oven-sh/setup-bun@v1 + uses: oven-sh/setup-bun@v2 - name: Install dependencies run: bun install @@ -50,7 +50,14 @@ jobs: libraries: "contracts/core/libraries" export_type: '${{ matrix.export_type }}' - - name: Publish to NPM - run: cd export/${{ env.PROJECT_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag latest + - name: Update version + run: cd export/${{ env.PROJECT_NAME }}${{ env.EXPORT_NAME }} && yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version + + - name: Configure npm for Publishing + run: | + echo "registry=https://registry.npmjs.org/" > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc + - 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 }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 29ff9b7689ce32467a24d5ba6361c14ec2a907ad Mon Sep 17 00:00:00 2001 From: OneTony Date: Wed, 6 Nov 2024 12:57:07 +0200 Subject: [PATCH 5/9] fix: naming of strategy and workflow --- .github/workflows/canary.yml | 6 ++---- .../examples/direct-allocation/DirectAllocation.sol | 4 ++-- script/strategies/DeployDirectAllocation.sol | 6 +++--- test/integration/DirectAllocation.t.sol | 6 +++--- test/invariant/fuzz/Setup.t.sol | 6 +++--- test/unit/strategies/DirectAllocation.t.sol | 6 +++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index dc38e4553..9c82dc329 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - export_type: ['interfaces', 'all'] + export_type: ['all'] env: PROJECT_NAME: '@allo-protocol/allo-v2.1' @@ -45,9 +45,7 @@ jobs: with: package_name: ${{ env.PROJECT_NAME }} out: 'out' - interfaces: 'contracts/core/interfaces' - contracts: 'contracts/core' - libraries: "contracts/core/libraries" + contracts: 'contracts' export_type: '${{ matrix.export_type }}' - name: Update version diff --git a/contracts/strategies/examples/direct-allocation/DirectAllocation.sol b/contracts/strategies/examples/direct-allocation/DirectAllocation.sol index 924bbb5a5..3ac016f65 100644 --- a/contracts/strategies/examples/direct-allocation/DirectAllocation.sol +++ b/contracts/strategies/examples/direct-allocation/DirectAllocation.sol @@ -8,10 +8,10 @@ import {BaseStrategy} from "strategies/BaseStrategy.sol"; import {Errors} from "contracts/core/libraries/Errors.sol"; import {Transfer} from "contracts/core/libraries/Transfer.sol"; -/// @title DirectAllocationStrategy +/// @title DirectAllocation /// @dev The strategy only implements the allocate logic /// @notice A strategy that directly allocates funds to a recipient -contract DirectAllocationStrategy is BaseStrategy, Errors { +contract DirectAllocation is BaseStrategy, Errors { using Transfer for address; /// =============================== diff --git a/script/strategies/DeployDirectAllocation.sol b/script/strategies/DeployDirectAllocation.sol index bce0c41a2..9a5ba1938 100644 --- a/script/strategies/DeployDirectAllocation.sol +++ b/script/strategies/DeployDirectAllocation.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.19; import {DeployBase} from "script/DeployBase.sol"; -import {DirectAllocationStrategy} from "contracts/strategies/examples/direct-allocation/DirectAllocation.sol"; +import {DirectAllocation} from "contracts/strategies/examples/direct-allocation/DirectAllocation.sol"; contract DeployDirectAllocation is DeployBase { function _deploy() internal override returns (address _contract, string memory _contractName) { address _allo = vm.envAddress("ALLO_ADDRESS"); - _contract = address(new DirectAllocationStrategy(_allo)); - _contractName = "DirectAllocationStrategy"; + _contract = address(new DirectAllocation(_allo)); + _contractName = "DirectAllocation"; } } diff --git a/test/integration/DirectAllocation.t.sol b/test/integration/DirectAllocation.t.sol index 7f0c676f1..e30d4ae6d 100644 --- a/test/integration/DirectAllocation.t.sol +++ b/test/integration/DirectAllocation.t.sol @@ -4,13 +4,13 @@ pragma solidity ^0.8.19; import {IAllo} from "contracts/core/interfaces/IAllo.sol"; import {Metadata} from "contracts/core/Registry.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {DirectAllocationStrategy} from "strategies/examples/direct-allocation/DirectAllocation.sol"; +import {DirectAllocation} from "strategies/examples/direct-allocation/DirectAllocation.sol"; import {IntegrationBase} from "./IntegrationBase.sol"; import {Errors} from "contracts/core/libraries/Errors.sol"; contract IntegrationDirectAllocationStrategy is IntegrationBase { IAllo public allo; - DirectAllocationStrategy public strategy; + DirectAllocation public strategy; uint256 public poolId; @@ -19,7 +19,7 @@ contract IntegrationDirectAllocationStrategy is IntegrationBase { allo = IAllo(ALLO_PROXY); - strategy = new DirectAllocationStrategy(address(allo)); + strategy = new DirectAllocation(address(allo)); // Deal deal(DAI, userAddr, 100000 ether); diff --git a/test/invariant/fuzz/Setup.t.sol b/test/invariant/fuzz/Setup.t.sol index 8f042b142..cb6c96217 100644 --- a/test/invariant/fuzz/Setup.t.sol +++ b/test/invariant/fuzz/Setup.t.sol @@ -7,7 +7,7 @@ import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transpa import {Allo, IAllo, Metadata} from "contracts/core/Allo.sol"; import {Registry, Anchor} from "contracts/core/Anchor.sol"; import {IRegistry} from "contracts/core/interfaces/IRegistry.sol"; -import {DirectAllocationStrategy} from "contracts/strategies/examples/direct-allocation/DirectAllocation.sol"; +import {DirectAllocation} from "contracts/strategies/examples/direct-allocation/DirectAllocation.sol"; import {Actors} from "./helpers/Actors.t.sol"; import {Utils} from "./helpers/Utils.t.sol"; @@ -27,7 +27,7 @@ contract Setup is Actors { Allo allo; Registry registry; - DirectAllocationStrategy strategy_directAllocation; + DirectAllocation strategy_directAllocation; ERC20 token; @@ -66,7 +66,7 @@ contract Setup is Actors { ); // Deploy base strategy - strategy_directAllocation = new DirectAllocationStrategy(address(allo)); + strategy_directAllocation = new DirectAllocation(address(allo)); // Deploy token token = ERC20(address(new FuzzERC20())); diff --git a/test/unit/strategies/DirectAllocation.t.sol b/test/unit/strategies/DirectAllocation.t.sol index 6a6d7fbdb..732df7155 100644 --- a/test/unit/strategies/DirectAllocation.t.sol +++ b/test/unit/strategies/DirectAllocation.t.sol @@ -2,14 +2,14 @@ pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; -import {DirectAllocationStrategy} from "strategies/examples/direct-allocation/DirectAllocation.sol"; +import {DirectAllocation} from "strategies/examples/direct-allocation/DirectAllocation.sol"; import {Errors} from "contracts/core/libraries/Errors.sol"; contract DirectAllocationTest is Test { event Initialized(uint256 poolId, bytes data); event DirectAllocated(address indexed recipient, uint256 amount, address token, address sender); - DirectAllocationStrategy directAllocationStrategy; + DirectAllocation directAllocationStrategy; address mockAlloAddress; @@ -17,7 +17,7 @@ contract DirectAllocationTest is Test { /// create a mock allo address mockAlloAddress = makeAddr("allo"); /// create the direct allocation strategy - directAllocationStrategy = new DirectAllocationStrategy(mockAlloAddress); + directAllocationStrategy = new DirectAllocation(mockAlloAddress); } function test_InitializeWhenCalled(uint256 _poolId) external { From ff4868ec531082dec4864980de1adf533d4a8ee8 Mon Sep 17 00:00:00 2001 From: OneTony Date: Wed, 6 Nov 2024 12:57:58 +0200 Subject: [PATCH 6/9] fix: exporter version --- .github/workflows/canary.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 9c82dc329..967eca203 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -41,7 +41,7 @@ jobs: run: forge build - name: Export Solidity - Export Type ${{ matrix.export_type }} - uses: defi-wonderland/solidity-exporter-action@v2.1.0 + uses: defi-wonderland/solidity-exporter-action@c39954b18f1105333bcd232ff527fe1b114f4d1d with: package_name: ${{ env.PROJECT_NAME }} out: 'out' From ecaa00e50e5b8f91835191a09f0ff7d531ad1219 Mon Sep 17 00:00:00 2001 From: OneTony Date: Wed, 6 Nov 2024 13:21:29 +0200 Subject: [PATCH 7/9] fix: unit test --- test/unit/core/RegistryUnit.t.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/core/RegistryUnit.t.sol b/test/unit/core/RegistryUnit.t.sol index 5756d8c10..2d614f5ce 100644 --- a/test/unit/core/RegistryUnit.t.sol +++ b/test/unit/core/RegistryUnit.t.sol @@ -402,6 +402,8 @@ contract RegistryUnit is Test { { vm.assume(_recipient != address(0)); vm.assume(_token != address(vm)); + vm.assume(_token != NATIVE); + assumeNotPrecompile(_token); vm.mockCall(_token, abi.encodeWithSignature("balanceOf(address)", address(registry)), abi.encode(_amount)); vm.mockCall(_token, abi.encodeWithSignature("transfer(address,uint256)", _recipient, _amount), abi.encode(true)); From 752fa62629cb489f4ea0885020378e24589766c0 Mon Sep 17 00:00:00 2001 From: OneTony Date: Wed, 6 Nov 2024 13:27:51 +0200 Subject: [PATCH 8/9] fix: error --- test/unit/core/RegistryUnit.t.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/core/RegistryUnit.t.sol b/test/unit/core/RegistryUnit.t.sol index 2d614f5ce..d7b7fcee9 100644 --- a/test/unit/core/RegistryUnit.t.sol +++ b/test/unit/core/RegistryUnit.t.sol @@ -14,6 +14,7 @@ contract RegistryUnit is Test { using stdStorage for StdStorage; MockMockRegistry public registry; + address public constant NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; event ProfileCreated( bytes32 indexed profileId, uint256 nonce, string name, Metadata metadata, address owner, address anchor From 0b46e9ab87e64981263830f80616a3d3eda1bb50 Mon Sep 17 00:00:00 2001 From: OneTony Date: Thu, 7 Nov 2024 19:11:18 +0200 Subject: [PATCH 9/9] chore: make flow run on push --- .github/workflows/canary.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 967eca203..083b1ee73 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -1,6 +1,6 @@ name: Canary Release -on: workflow_dispatch +on: [push] jobs: export: