From 3b6a835b9a55056aa32f27e7a774fe986c6cf39d Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Sat, 12 Oct 2024 16:57:12 +0000 Subject: [PATCH] Make per byte fee dependent on destination --- interfaces/IDispatcher.sol | 5 +++-- interfaces/IIsmpModule.sol | 9 ++------- package.json | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/interfaces/IDispatcher.sol b/interfaces/IDispatcher.sol index b037756..a8d47f2 100644 --- a/interfaces/IDispatcher.sol +++ b/interfaces/IDispatcher.sol @@ -91,13 +91,14 @@ interface IDispatcher { function feeToken() external view returns (address); /** - * @dev Returns the address of the per byte fee configured for this state machine. + * @dev Returns the address of the per byte fee configured for the destination state machine. * * @notice Hyperbridge collects it's dispatch fees per every byte of the outgoing message. * + * @param dest - The destination chain for the per byte fee. * @return perByteFee - The per byte fee for outgoing messages. */ - function perByteFee() external view returns (uint256); + function perByteFee(bytes memory dest) external view returns (uint256); /** * @dev Dispatch a POST request to Hyperbridge diff --git a/interfaces/IIsmpModule.sol b/interfaces/IIsmpModule.sol index 184d081..26f5f72 100644 --- a/interfaces/IIsmpModule.sol +++ b/interfaces/IIsmpModule.sol @@ -133,17 +133,12 @@ abstract contract BaseIsmpModule is IIsmpModule { // @dev returns the quoted fee for a dispatch function quote(DispatchPost memory post) public view returns (uint256) { - return post.fee + (post.body.length * IDispatcher(host()).perByteFee()); + return post.fee + (post.body.length * IDispatcher(host()).perByteFee(post.dest)); } // @dev returns the quoted fee for a dispatch function quote(DispatchPostResponse memory res) public view returns (uint256) { - return res.fee + (res.response.length * IDispatcher(host()).perByteFee()); - } - - // @dev returns the quoted fee for a dispatch - function quote(DispatchGet memory get) public view returns (uint256) { - return get.fee + (get.context.length * IDispatcher(host()).perByteFee()); + return res.fee + (res.response.length * IDispatcher(host()).perByteFee(res.request.source)); } function onAccept(IncomingPostRequest calldata) external virtual onlyHost { diff --git a/package.json b/package.json index 62096d5..5b8f6e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polytope-labs/ismp-solidity", - "version": "0.7.2", + "version": "0.7.3", "description": "Hyperbridge Solidity SDK for the Interoperable state machine protocol", "author": "Polytope Labs ", "license": "Apache-2.0",