From 6288040db20154c26cde7a354d0b3ec18366c3a7 Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Mon, 4 Nov 2024 10:00:42 +0000 Subject: [PATCH 1/2] chore: update hyperbridge adapter to v1.0.0 --- .../adapters/Hyperbridge/HyperbridgeAdapter.sol | 11 +++++++++++ .../adapters/Hyperbridge/HyperbridgeReporter.sol | 15 +++++++++++---- packages/evm/package.json | 2 +- packages/evm/tasks/deploy/adapters/hyperbridge.ts | 6 ++++-- yarn.lock | 8 ++++---- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol index ac34587e..183d3607 100644 --- a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol +++ b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol @@ -10,6 +10,17 @@ contract HyperbridgeAdapter is BlockHashAdapter, Ownable, BaseIsmpModule { mapping(bytes32 => bytes32) public enabledReporters; mapping(bytes32 => uint256) public chainIds; + // @dev The address of the IsmpHost on the current chain + address public _host; + + constructor(address ismpHost) { + _host = ismpHost; + } + + function host() public view override returns (address) { + return _host; + } + error UnauthorizedRequest(); event ReporterSet(uint256 indexed chainId, address indexed reporter); diff --git a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol index 8fc5a5ee..1f7e870d 100644 --- a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol +++ b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol @@ -11,11 +11,18 @@ import { Reporter } from "../Reporter.sol"; contract HyperbridgeReporter is Reporter, Ownable, BaseIsmpModule { string public constant PROVIDER = "hyperbridge"; - constructor(address headerStorage, address yaho) Reporter(headerStorage, yaho) { - address host = host(); - address feeToken = IDispatcher(host).feeToken(); + // @dev The address of the IsmpHost on the current chain + address public _host; + + constructor(address headerStorage, address yaho, address ismpHost) Reporter(headerStorage, yaho) { + _host = ismpHost; + address feeToken = IDispatcher(ismpHost).feeToken(); // approve the host to spend infinitely - IERC20(feeToken).approve(host, type(uint256).max); + IERC20(feeToken).approve(ismpHost, type(uint256).max); + } + + function host() public view override returns (address) { + return _host; } function _dispatch( diff --git a/packages/evm/package.json b/packages/evm/package.json index 90dfb08b..99d6a1fd 100644 --- a/packages/evm/package.json +++ b/packages/evm/package.json @@ -87,7 +87,7 @@ "@layerzerolabs/lz-evm-oapp-v2": "^2.3.29", "@layerzerolabs/lz-evm-protocol-v2": "^2.3.29", "@openzeppelin/contracts-upgradeable": "4.8.1", - "@polytope-labs/ismp-solidity": "^0.7.4", + "@polytope-labs/ismp-solidity": "^1.0.0", "@polytope-labs/solidity-merkle-trees": "0.3.2", "@routerprotocol/evm-gateway-contracts": "1.1.13", "solidity-bytes-utils": "^0.8.2", diff --git a/packages/evm/tasks/deploy/adapters/hyperbridge.ts b/packages/evm/tasks/deploy/adapters/hyperbridge.ts index 903caed2..93c17bbb 100644 --- a/packages/evm/tasks/deploy/adapters/hyperbridge.ts +++ b/packages/evm/tasks/deploy/adapters/hyperbridge.ts @@ -10,13 +10,14 @@ import { verify } from "../index" task("deploy:HyperbridgeAdapter") .addFlag("verify", "whether to verify the contract on Etherscan") + .addParam("ismpHost", "The address of the IsmpHost on the current chain") .setAction(async function (taskArguments: TaskArguments, hre) { console.log("Deploying HyperbridgeAdapter...") const signers: SignerWithAddress[] = await hre.ethers.getSigners() const HyperbridgeAdapterFactory: HyperbridgeAdapter__factory = ( await hre.ethers.getContractFactory("HyperbridgeAdapter") ) - const constructorArguments = [] as const + const constructorArguments = [taskArguments.ismpHost] as const const HyperbridgeAdapter: HyperbridgeAdapter = ( await HyperbridgeAdapterFactory.connect(signers[0]).deploy(...constructorArguments) ) @@ -28,6 +29,7 @@ task("deploy:HyperbridgeAdapter") task("deploy:HyperbridgeReporter") .addParam("headerStorage", "address of the header storage contract") .addParam("yaho", "address of the Yaho contract") + .addParam("ismpHost", "The address of the IsmpHost on the current chain") .addFlag("verify", "whether to verify the contract on Etherscan") .setAction(async function (taskArguments: TaskArguments, hre) { console.log("Deploying HyperbridgeReporter...") @@ -35,7 +37,7 @@ task("deploy:HyperbridgeReporter") const HyperbridgeReporterFactory: HyperbridgeReporter__factory = ( await hre.ethers.getContractFactory("HyperbridgeReporter") ) - const constructorArguments = [taskArguments.headerStorage, taskArguments.yaho] as const + const constructorArguments = [taskArguments.headerStorage, taskArguments.yaho, taskArguments.ismpHost] as const const HyperbridgeReporter: HyperbridgeReporter = ( await HyperbridgeReporterFactory.connect(signers[0]).deploy(...constructorArguments) ) diff --git a/yarn.lock b/yarn.lock index b81afe7c..545fa5a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1217,10 +1217,10 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.3.3.tgz#ff6ee919fc2a1abaf72b22814bfb72ed129ec137" integrity sha512-tDBopO1c98Yk7Cv/PZlHqrvtVjlgK5R4J6jxLwoO7qxK4xqOiZG+zSkIvGFpPZ0ikc3QOED3plgdqjgNTnBc7g== -"@polytope-labs/ismp-solidity@^0.7.4": - version "0.7.4" - resolved "https://registry.yarnpkg.com/@polytope-labs/ismp-solidity/-/ismp-solidity-0.7.4.tgz#00a9e02f2eb0cdbb444fb3f244dc8199c5bfb685" - integrity sha512-NLthu+D+ycLwMkSgdURpzfotKs9NtFuI/TKcNm+8XH8FF74B26o8BOJMtvE2TD2TPOxu9rcs54u2p5HNaHoU2w== +"@polytope-labs/ismp-solidity@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@polytope-labs/ismp-solidity/-/ismp-solidity-1.0.0.tgz#0af23618da591aefca6808881ce8b55815f3b90c" + integrity sha512-0jpCueJFv98R/8w6wk9ufMRXb5dYjN4RSfZDhRphnKpVgD7Zmwb92RdqIjTesbFwxjiVpWkTzvhppQsZj6jdpg== dependencies: "@polytope-labs/solidity-merkle-trees" "^0.3.3" openzeppelin-solidity "^4.8.1" From 9307fd38a40e7f7f0f4612f2594c57b53ca7eb0f Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Wed, 13 Nov 2024 09:31:48 +0000 Subject: [PATCH 2/2] chore: make _host private --- .../evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol | 2 +- .../evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol index 183d3607..64509261 100644 --- a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol +++ b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeAdapter.sol @@ -11,7 +11,7 @@ contract HyperbridgeAdapter is BlockHashAdapter, Ownable, BaseIsmpModule { mapping(bytes32 => uint256) public chainIds; // @dev The address of the IsmpHost on the current chain - address public _host; + address private _host; constructor(address ismpHost) { _host = ismpHost; diff --git a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol index 1f7e870d..5d1e03b4 100644 --- a/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol +++ b/packages/evm/contracts/adapters/Hyperbridge/HyperbridgeReporter.sol @@ -12,7 +12,7 @@ contract HyperbridgeReporter is Reporter, Ownable, BaseIsmpModule { string public constant PROVIDER = "hyperbridge"; // @dev The address of the IsmpHost on the current chain - address public _host; + address private _host; constructor(address headerStorage, address yaho, address ismpHost) Reporter(headerStorage, yaho) { _host = ismpHost;