From 1836224fcbda37d98371e35f3912a7cf03ed9839 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Fri, 1 Nov 2024 11:02:18 -0400 Subject: [PATCH] Require that DecentAutonomousAdmin (current and future versions) implement a `version` function --- contracts/autonomous-admin/DecentAutonomousAdminV1.sol | 4 ++++ .../interfaces/autonomous-admin/IDecentAutonomousAdmin.sol | 6 ++++++ .../autonomous-admin/IDecentAutonomousAdminV1.sol | 4 +++- test/autonomous-admin/DecentAutonomousAdminV1.test.ts | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 contracts/interfaces/autonomous-admin/IDecentAutonomousAdmin.sol diff --git a/contracts/autonomous-admin/DecentAutonomousAdminV1.sol b/contracts/autonomous-admin/DecentAutonomousAdminV1.sol index 3588fc2..1216ba6 100644 --- a/contracts/autonomous-admin/DecentAutonomousAdminV1.sol +++ b/contracts/autonomous-admin/DecentAutonomousAdminV1.sol @@ -20,6 +20,10 @@ contract DecentAutonomousAdminV1 is // ////////////////////////////////////////////////////////////// // Public Functions // ////////////////////////////////////////////////////////////// + function version() external pure override returns (uint32) { + return 1; + } + function triggerStartNextTerm(TriggerStartArgs calldata args) public { IHatsElectionsEligibility hatsElectionModule = IHatsElectionsEligibility( args.hatsProtocol.getHatEligibilityModule(args.hatId) diff --git a/contracts/interfaces/autonomous-admin/IDecentAutonomousAdmin.sol b/contracts/interfaces/autonomous-admin/IDecentAutonomousAdmin.sol new file mode 100644 index 0000000..b30b46e --- /dev/null +++ b/contracts/interfaces/autonomous-admin/IDecentAutonomousAdmin.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; + +interface IDecentAutonomousAdmin { + function version() external view returns (uint32); +} diff --git a/contracts/interfaces/autonomous-admin/IDecentAutonomousAdminV1.sol b/contracts/interfaces/autonomous-admin/IDecentAutonomousAdminV1.sol index bbac8b0..0f221fc 100644 --- a/contracts/interfaces/autonomous-admin/IDecentAutonomousAdminV1.sol +++ b/contracts/interfaces/autonomous-admin/IDecentAutonomousAdminV1.sol @@ -1,10 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.28; +import {IDecentAutonomousAdmin} from "./IDecentAutonomousAdmin.sol"; import {IHats} from "../hats/IHats.sol"; -interface IDecentAutonomousAdminV1 { +interface IDecentAutonomousAdminV1 is IDecentAutonomousAdmin { error NotCurrentWearer(); + struct TriggerStartArgs { address currentWearer; IHats hatsProtocol; diff --git a/test/autonomous-admin/DecentAutonomousAdminV1.test.ts b/test/autonomous-admin/DecentAutonomousAdminV1.test.ts index 7f67ec4..3004067 100644 --- a/test/autonomous-admin/DecentAutonomousAdminV1.test.ts +++ b/test/autonomous-admin/DecentAutonomousAdminV1.test.ts @@ -93,6 +93,12 @@ describe('DecentAutonomousAdminHatV1', function () { await hatsElectionModule.elect(nextTermEnd, [await secondWearer.getAddress()]); }); + describe('version', function () { + it('should return the correct version', async () => { + expect(await decentAutonomousAdminInstance.version()).to.equal(1); + }); + }); + describe('triggerStartNextTerm', function () { describe('before the first term is over', function () { it('should have correct wearers', async () => {