diff --git a/contracts/IPRBProxyFactory.sol b/contracts/IPRBProxyFactory.sol index bbd752b..ca56fd3 100644 --- a/contracts/IPRBProxyFactory.sol +++ b/contracts/IPRBProxyFactory.sol @@ -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. diff --git a/contracts/PRBProxyFactory.sol b/contracts/PRBProxyFactory.sol index e9f1f3d..77d15c7 100644 --- a/contracts/PRBProxyFactory.sol +++ b/contracts/PRBProxyFactory.sol @@ -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. diff --git a/test/contracts/prbProxyFactory/PRBProxyFactory.behavior.ts b/test/contracts/prbProxyFactory/PRBProxyFactory.behavior.ts index 871df22..e06582d 100644 --- a/test/contracts/prbProxyFactory/PRBProxyFactory.behavior.ts +++ b/test/contracts/prbProxyFactory/PRBProxyFactory.behavior.ts @@ -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(); diff --git a/test/contracts/prbProxyFactory/view/version.ts b/test/contracts/prbProxyFactory/view/version.ts new file mode 100644 index 0000000..4170d69 --- /dev/null +++ b/test/contracts/prbProxyFactory/view/version.ts @@ -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); + }); +}