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

Add CI #9

Merged
merged 6 commits into from
Feb 24, 2024
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "CI"

concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref}}

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"

jobs:
lint:
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-lint.yml@main"

build:
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-build.yml@main"


test-integration:
needs: ["lint", "build"]
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-test.yml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test-optimized"
match-path: "test/*.sol"
name: "Integration tests"
32 changes: 0 additions & 32 deletions .github/workflows/release.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/test.yml

This file was deleted.

38 changes: 8 additions & 30 deletions script/base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {stdJson} from "forge-std/StdJson.sol";
/// modified from sablier base test file
abstract contract BaseScript is Script {
/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
string internal constant TEST_MNEMONIC =
"test test test test test test test test test test test junk";
string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk";

/// @dev Needed for the deterministic deployments.
bytes32 internal constant ZERO_SALT = bytes32(0);
Expand All @@ -31,20 +30,11 @@ abstract contract BaseScript is Script {
if (from != address(0)) {
broadcaster = from;
} else {
mnemonic = vm.envOr({
name: "MNEMONIC",
defaultValue: TEST_MNEMONIC
});
uint256 walletIndex = vm.envOr({
name: "WALLET_INDEX",
defaultValue: uint256(0)
});
mnemonic = vm.envOr({name: "MNEMONIC", defaultValue: TEST_MNEMONIC});
uint256 walletIndex = vm.envOr({name: "WALLET_INDEX", defaultValue: uint256(0)});
require(walletIndex <= type(uint32).max, "Invalid wallet index");

(broadcaster, ) = deriveRememberKey({
mnemonic: mnemonic,
index: uint32(walletIndex)
});
(broadcaster,) = deriveRememberKey({mnemonic: mnemonic, index: uint32(walletIndex)});
}

console2.log(broadcaster);
Expand Down Expand Up @@ -74,25 +64,13 @@ abstract contract BaseScript is Script {
vm.stopBroadcast();
}

function getDeployConfigJson() internal view returns (string memory json) {
function getDeployConfigJson() internal view returns (string memory json) {
if (currentChain == Chains.BaseGoerli) {
json = vm.readFile(
string.concat(
vm.projectRoot(),
"/deployConfigs/goerli.base.json"
)
);
json = vm.readFile(string.concat(vm.projectRoot(), "/deployConfigs/goerli.base.json"));
} else if (currentChain == Chains.BaseSepolia) {
json = vm.readFile(
string.concat(
vm.projectRoot(),
"/deployConfigs/sepolia.base.json"
)
);
json = vm.readFile(string.concat(vm.projectRoot(), "/deployConfigs/sepolia.base.json"));
} else {
json = vm.readFile(
string.concat(vm.projectRoot(), "/deployConfigs/localnet.json")
);
json = vm.readFile(string.concat(vm.projectRoot(), "/deployConfigs/localnet.json"));
}
}
}
34 changes: 12 additions & 22 deletions script/deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,34 @@ import {stdJson} from "forge-std/StdJson.sol";

contract DeployScript is BaseScript {
using stdJson for string;

ERC20Token usdcAddress = getUsdc();
Currency xNGNVault = getxNGN();

function run()
external
broadcast
returns (
MultiStaticcall multiStaticcall,
VaultGetters vaultGetters,
VaultRouter vaultRouter
)
returns (MultiStaticcall multiStaticcall, VaultGetters vaultGetters, VaultRouter vaultRouter)
{
if (address(usdcAddress) == address(0))
if (address(usdcAddress) == address(0)) {
revert("USDC address not set, visit the deploy script and set it");
if (address(xNGNVault) == address(0))
revert(
"XNGN vault address not set, visit the deploy script and set it"
);
}
if (address(xNGNVault) == address(0)) {
revert("XNGN vault address not set, visit the deploy script and set it");
}

if (address(usdcAddress).code.length == 0)
revert(
"USDC address set is not a contract, it has no code deployed to it"
);
if (address(usdcAddress).code.length == 0) {
revert("USDC address set is not a contract, it has no code deployed to it");
}
if (address(xNGNVault).code.length == 0) {
revert(
"XNGN vault address set is not a contract, it has no code deployed to it"
);
revert("XNGN vault address set is not a contract, it has no code deployed to it");
}

multiStaticcall = new MultiStaticcall();
vaultGetters = new VaultGetters();
vaultRouter = new VaultRouter();

vaultRouter.approveTokenForVault(
address(usdcAddress),
address(xNGNVault),
true
);
vaultRouter.approveTokenForVault(address(usdcAddress), address(xNGNVault), true);
}

function getUsdc() private returns (ERC20Token usdc) {
Expand Down
3 changes: 1 addition & 2 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ FOUNDRY_PROFILE=optimized forge build

# Copy the production abis
cp out/multiStaticcall.sol/MultiStaticcall.json $abis
cp out/vaultGetters.sol/VaultGetters.json $abis
cp out/src/vaultRouter.sol/VaultRouter.json $abis
cp out/vaultGetters.sol/VaultGetters.json $abis
1 change: 1 addition & 0 deletions src/vaultRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract VaultRouter is Ownable {
}

enum Operations {
// Invalid operation
Invalid,
// Vault operations
DepositCollateral,
Expand Down
2 changes: 1 addition & 1 deletion test/vaultRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.13;

import {Test, console2} from "forge-std/Test.sol";
import {VaultGetters} from "../src/vaultGetters.sol";
import {VaultRouter, ERC20} from "../src/VaultRouter.sol";
import {VaultRouter, ERC20} from "../src/vaultRouter.sol";
import {MultiStaticcall} from "../src/multiStaticcall.sol";
import {BaseTest, IVault, Vault} from "lib/protocol-core/test/base.t.sol";
import {IPermit2, ISignatureTransfer, IAllowanceTransfer} from "permit2/interfaces/IPermit2.sol";
Expand Down
Loading