Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: npm exporter action #43

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Canary Release

on: [push]

jobs:
export:
name: Generate Interfaces And Contracts

runs-on: ubuntu-latest
strategy:
matrix:
export_type: ['all']

env:
PROJECT_NAME: '@allo-protocol/allo-v2.1'
EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 1

- name: Setup bun env
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Smock
run: bun smock
id: smock

- name: Build project and generate out directory
run: forge build

- name: Export Solidity - Export Type ${{ matrix.export_type }}
uses: defi-wonderland/solidity-exporter-action@c39954b18f1105333bcd232ff527fe1b114f4d1d
with:
package_name: ${{ env.PROJECT_NAME }}
out: 'out'
contracts: 'contracts'
export_type: '${{ matrix.export_type }}'

- 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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// ===============================
Expand Down
6 changes: 3 additions & 3 deletions script/strategies/DeployDirectAllocation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
6 changes: 3 additions & 3 deletions test/integration/DirectAllocation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions test/invariant/fuzz/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -27,7 +27,7 @@ contract Setup is Actors {
Allo allo;
Registry registry;

DirectAllocationStrategy strategy_directAllocation;
DirectAllocation strategy_directAllocation;

ERC20 token;

Expand Down Expand Up @@ -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()));
Expand Down
3 changes: 3 additions & 0 deletions test/unit/core/RegistryUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -402,6 +403,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));
Expand Down
6 changes: 3 additions & 3 deletions test/unit/strategies/DirectAllocation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
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;

function setUp() external {
/// 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 {
Expand Down
Loading