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 basic PoolFactory #15

Merged
merged 1 commit into from
Sep 20, 2022
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
10 changes: 10 additions & 0 deletions contracts/Pool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.16;

/**
* @title Pool
*
* Empty Pool contract.
*/
contract Pool {
}
27 changes: 27 additions & 0 deletions contracts/PoolFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.16;

import "./Pool.sol";

/**
* @title PoolFactory
*/
contract PoolFactory {

/**
* @dev Emitted when a pool is created.
*/
event PoolCreated(address indexed addr);

/**
* @dev Creates a pool
* @dev Emits `PoolCreated` event.
*/
function createPool() external returns (address poolAddress) {
Pool pool = new Pool();
address addr = address(pool);
emit PoolCreated(addr);
return addr;
}

}
22 changes: 22 additions & 0 deletions test/PoolFactory.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import { expect } from "chai";
import { ethers } from "hardhat";

describe("PoolFactory", () => {
async function deployFixture() {
const PoolFactory = await ethers.getContractFactory("PoolFactory");
const poolFactory = await PoolFactory.deploy();
await poolFactory.deployed();

return {
poolFactory
};
}

it("emits PoolCreated", async () => {
const { poolFactory } = await loadFixture(deployFixture);
await expect(poolFactory.createPool())
.to.emit(poolFactory, "PoolCreated");
});

});