Skip to content

Commit

Permalink
feat: add version storage var in PRBProxyFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRBerg committed Oct 13, 2021
1 parent ad8dfc7 commit 06a028e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/IPRBProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ interface IPRBProxyFactory {
/// @param proxy The address of the proxy to make the check for.
function isProxy(address proxy) external view returns (bool result);

/// @notice The release version of PRBProxy.
/// @dev This is stored in the factory rather than the proxy to save gas for end users.
function version() external view returns (uint256);

/// PUBLIC NON-CONSTANT FUNCTIONS ///

/// @notice Deploys a new proxy via CREATE2.
Expand Down
3 changes: 3 additions & 0 deletions contracts/PRBProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import "./PRBProxy.sol";
contract PRBProxyFactory is IPRBProxyFactory {
/// PUBLIC STORAGE ///

/// @inheritdoc IPRBProxyFactory
uint256 public constant version = 1;

/// INTERNAL STORAGE ///

/// @dev Internal mapping to track all deployed proxies.
Expand Down
5 changes: 5 additions & 0 deletions test/contracts/prbProxyFactory/PRBProxyFactory.behavior.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { shouldBehaveLikeDeploy } from "./effects/deploy";
import { shouldBehaveLikeDeployFor } from "./effects/deployFor";
import { shouldBehaveLikeVersionGetter } from "./view/version";

export function shouldBehaveLikePrbProxyFactory(): void {
describe("View Functions", function () {
shouldBehaveLikeVersionGetter();
});

describe("Effects Functions", function () {
describe("deploy", function () {
shouldBehaveLikeDeploy();
Expand Down
10 changes: 10 additions & 0 deletions test/contracts/prbProxyFactory/view/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { BigNumber } from "@ethersproject/bignumber";
import { One } from "@ethersproject/constants";
import { expect } from "chai";

export function shouldBehaveLikeVersionGetter(): void {
it("returns the correct version", async function () {
const version: BigNumber = await this.contracts.prbProxyFactory.version();
expect(One).to.equal(version);
});
}

0 comments on commit 06a028e

Please sign in to comment.