diff --git a/contracts/handlers/FeeHandlerRouter.sol b/contracts/handlers/FeeHandlerRouter.sol index bc9b6d65..580dc88d 100644 --- a/contracts/handlers/FeeHandlerRouter.sol +++ b/contracts/handlers/FeeHandlerRouter.sol @@ -43,6 +43,13 @@ contract FeeHandlerRouter is IFeeHandler, AccessControl { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "sender doesn't have admin role"); } + /** + @notice Getter function for fee handler type + */ + function feeHandlerType() public override pure returns (string memory) { + return "router"; + } + /** @param bridgeAddress Contract address of previously deployed Bridge. */ diff --git a/contracts/handlers/fee/BasicFeeHandler.sol b/contracts/handlers/fee/BasicFeeHandler.sol index f355b6bc..9b839b53 100644 --- a/contracts/handlers/fee/BasicFeeHandler.sol +++ b/contracts/handlers/fee/BasicFeeHandler.sol @@ -51,9 +51,9 @@ contract BasicFeeHandler is IFeeHandler, AccessControl { } /** - @notice Exposes getter function for fee handler type + @notice Getter function for fee handler type */ - function feeHandlerType() virtual public pure returns (string memory) { + function feeHandlerType() public virtual override pure returns (string memory) { return "basic"; } @@ -84,7 +84,7 @@ contract BasicFeeHandler is IFeeHandler, AccessControl { emit FeeCollected(sender, fromDomainID, destinationDomainID, resourceID, currentFee, address(0)); } - /** + /** @notice Calculates fee for deposit. @param sender Sender of the deposit. @param fromDomainID ID of the source chain. diff --git a/contracts/handlers/fee/DynamicFeeHandler.sol b/contracts/handlers/fee/DynamicFeeHandler.sol index 550a24df..af64784a 100644 --- a/contracts/handlers/fee/DynamicFeeHandler.sol +++ b/contracts/handlers/fee/DynamicFeeHandler.sol @@ -84,6 +84,10 @@ abstract contract DynamicFeeHandler is IFeeHandler, AccessControl, ERC20Safe { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } + function feeHandlerType() public override pure returns (string memory) { + return "dynamic"; + } + // Admin functions /** diff --git a/contracts/handlers/fee/PercentageERC20FeeHandlerEVM.sol b/contracts/handlers/fee/PercentageERC20FeeHandlerEVM.sol index 6790cfbf..bcc4b358 100644 --- a/contracts/handlers/fee/PercentageERC20FeeHandlerEVM.sol +++ b/contracts/handlers/fee/PercentageERC20FeeHandlerEVM.sol @@ -38,9 +38,9 @@ contract PercentageERC20FeeHandlerEVM is BasicFeeHandler, ERC20Safe { ) BasicFeeHandler(bridgeAddress, feeHandlerRouterAddress) {} /** - @notice Exposes getter function for fee handler type + @notice Getter function for fee handler type */ - function feeHandlerType() override public pure returns (string memory) { + function feeHandlerType() public override pure returns (string memory) { return "percentage"; } diff --git a/contracts/handlers/fee/V2/DynamicFeeHandlerV2.sol b/contracts/handlers/fee/V2/DynamicFeeHandlerV2.sol index 7b610131..0e655bab 100644 --- a/contracts/handlers/fee/V2/DynamicFeeHandlerV2.sol +++ b/contracts/handlers/fee/V2/DynamicFeeHandlerV2.sol @@ -75,9 +75,9 @@ abstract contract DynamicFeeHandlerV2 is IFeeHandler, AccessControl { } /** - @notice Exposes getter function for fee handler type + @notice Getter function for fee handler type */ - function feeHandlerType() virtual public pure returns (string memory) { + function feeHandlerType() public override pure returns (string memory) { return "twap"; } diff --git a/contracts/interfaces/IFeeHandler.sol b/contracts/interfaces/IFeeHandler.sol index 6780ad04..81d1e076 100644 --- a/contracts/interfaces/IFeeHandler.sol +++ b/contracts/interfaces/IFeeHandler.sol @@ -61,4 +61,9 @@ interface IFeeHandler { @return Returns the address of the token to be used for fee. */ function calculateFee(address sender, uint8 fromDomainID, uint8 destinationDomainID, bytes32 resourceID, bytes calldata depositData, bytes calldata feeData) external view returns(uint256, address); + + /** + @notice Exposes getter function for fee handler type + */ + function feeHandlerType() pure external returns (string memory); } diff --git a/test/handlers/fee/basic/admin.js b/test/handlers/fee/basic/admin.js index c560a34f..b6079c95 100644 --- a/test/handlers/fee/basic/admin.js +++ b/test/handlers/fee/basic/admin.js @@ -49,10 +49,15 @@ contract("BasicFeeHandler - [admin]", async (accounts) => { ) }); - it("should return fee handler type", async () => { + it("[sanity] should return fee handler type from fee handler", async () => { assert.equal(await BasicFeeHandlerInstance.feeHandlerType.call(), "basic"); }); + it("[sanity] should return fee handler from fee handler router", async () => { + const feeRouterInstance = await FeeHandlerRouterContract.at(BasicFeeHandlerInstance.address) + assert.equal(await feeRouterInstance.feeHandlerType.call(), "basic"); + }); + it("should set fee property", async () => { const fee = 3; assert.equal(await BasicFeeHandlerInstance._domainResourceIDToFee(destinationDomainID, resourceID), "0"); diff --git a/test/handlers/fee/dynamic/admin.js b/test/handlers/fee/dynamic/admin.js index 1355b8ce..13c6bfeb 100644 --- a/test/handlers/fee/dynamic/admin.js +++ b/test/handlers/fee/dynamic/admin.js @@ -37,6 +37,15 @@ contract("DynamicFeeHandler - [admin]", async (accounts) => { ADMIN_ROLE = await DynamicFeeHandlerInstance.DEFAULT_ADMIN_ROLE(); }); + it("[sanity] should return fee handler type from fee handler", async () => { + assert.equal(await DynamicFeeHandlerInstance.feeHandlerType.call(), "dynamic"); + }); + + it("[sanity] should return fee handler from fee handler router", async () => { + const feeRouterInstance = await FeeHandlerRouterContract.at(DynamicFeeHandlerInstance.address) + assert.equal(await feeRouterInstance.feeHandlerType.call(), "dynamic"); + }); + it("should set fee oracle and emit 'FeeOracleAddressSet' event", async () => { const oracleAddress = accounts[1]; assert.equal( diff --git a/test/handlers/fee/handlerRouter.js b/test/handlers/fee/handlerRouter.js index 0aa8607e..822b1587 100644 --- a/test/handlers/fee/handlerRouter.js +++ b/test/handlers/fee/handlerRouter.js @@ -54,6 +54,10 @@ contract("FeeHandlerRouter", async (accounts) => { ); }); + it("[sanity] should return fee handler router type", async () => { + assert.equal(await FeeHandlerRouterInstance.feeHandlerType.call(), "router"); + }); + it("should successfully set handler to resourceID", async () => { const feeHandlerAddress = accounts[1]; assert.equal( diff --git a/test/handlers/fee/percentage/admin.js b/test/handlers/fee/percentage/admin.js index 994962ab..01708187 100644 --- a/test/handlers/fee/percentage/admin.js +++ b/test/handlers/fee/percentage/admin.js @@ -53,10 +53,15 @@ contract("PercentageFeeHandler - [admin]", async (accounts) => { resourceID = Helpers.createResourceID(ERC20MintableInstance.address, originDomainID); }); - it("should return fee handler type", async () => { + it("[sanity] should return fee handler type from fee handler", async () => { assert.equal(await PercentageFeeHandlerInstance.feeHandlerType.call(), "percentage"); }); + it("[sanity] should return fee handler from fee handler router", async () => { + const feeRouterInstance = await FeeHandlerRouterContract.at(PercentageFeeHandlerInstance.address) + assert.equal(await feeRouterInstance.feeHandlerType.call(), "percentage"); + }); + it("should set fee property", async () => { const fee = 60000; assert.equal(await PercentageFeeHandlerInstance._domainResourceIDToFee(destinationDomainID, resourceID), "0");