From 5af17b22e93190d9c66eb8b5430d19f61f05e1d0 Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Wed, 24 Jul 2024 17:40:42 +0000 Subject: [PATCH] make frozen state an enum --- foundry.toml | 3 +-- interfaces/IIsmpHost.sol | 50 +++++++++++++++++++++++++++------------- package.json | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/foundry.toml b/foundry.toml index 92b29f9..31b1b39 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,5 +1,4 @@ [profile.default] -src = 'src' +src = 'interfaces' out = 'out' libs = ['lib'] - diff --git a/interfaces/IIsmpHost.sol b/interfaces/IIsmpHost.sol index eb1e3f6..07e311b 100644 --- a/interfaces/IIsmpHost.sol +++ b/interfaces/IIsmpHost.sol @@ -20,6 +20,18 @@ struct ResponseReceipt { address relayer; } +// Various frozen states of the IIsmpHost +enum FrozenStatus { + // Host is operating normally + None, + // Host is currently disallowing incoming datagrams + Incoming, + // Host is currently disallowing outgoing messages + Outgoing, + // All actions have been frozen + All +} + /** * @title The Ismp Host Interface * @author Polytope Labs (hello@polytope.technology) @@ -64,22 +76,22 @@ interface IIsmpHost is IDispatcher { */ function timestamp() external view returns (uint256); - /** - * @dev Returns the nonce immediately available for requests - * @return the `nonce` - */ - function nonce() external view returns (uint256); + /** + * @dev Returns the nonce immediately available for requests + * @return the `nonce` + */ + function nonce() external view returns (uint256); - /** - * @dev Returns the fisherman responsible for vetoing the given state machine height. - * @return the `fisherman` address - */ - function vetoes(uint256 paraId, uint256 height) external view returns (address); + /** + * @dev Returns the fisherman responsible for vetoing the given state machine height. + * @return the `fisherman` address + */ + function vetoes(uint256 paraId, uint256 height) external view returns (address); /** * @return the `frozen` status */ - function frozen() external view returns (bool); + function frozen() external view returns (FrozenStatus); /** * @dev Returns the address for the Uniswap V2 Router implementation used for swaps @@ -132,11 +144,11 @@ interface IIsmpHost is IDispatcher { */ function consensusState() external view returns (bytes memory); - /** - * @dev Check the response status for a given request. - * @return `response` status - */ - function responded(bytes32 commitment) external view returns (bool); + /** + * @dev Check the response status for a given request. + * @return `response` status + */ + function responded(bytes32 commitment) external view returns (bool); /** * @param commitment - commitment to the request @@ -172,6 +184,12 @@ interface IIsmpHost is IDispatcher { */ function unStakingPeriod() external view returns (uint256); + /** + * @dev set the new frozen state of the host, only the admin or handler can call this. + * @param newState - the new frozen state + */ + function setFrozenState(FrozenStatus newState) external; + /** * @dev Store an encoded consensus state * @param state new consensus state diff --git a/package.json b/package.json index 6082d4f..29b1898 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polytope-labs/ismp-solidity", - "version": "0.2.7", + "version": "0.3.0", "description": "Hyperbridge Solidity SDK for the Interoperable state machine protocol", "author": "Polytope Labs ", "license": "Apache-2.0",