From fb520c9bfa03a8589b1abd2b0a6711ce3e08bdce Mon Sep 17 00:00:00 2001 From: CJ42 Date: Tue, 24 Sep 2024 09:22:58 +0800 Subject: [PATCH] refactor: remove `lsp4TokenType` parameter from `initialize` function --- src/HypLSP7.sol | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/HypLSP7.sol b/src/HypLSP7.sol index cd4cd60..3d9e6af 100644 --- a/src/HypLSP7.sol +++ b/src/HypLSP7.sol @@ -9,6 +9,9 @@ import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/O // libraries import { TokenMessageForLSP7 } from "./TokenMessageForLSP7.sol"; +// constants +import { _LSP4_TOKEN_TYPE_TOKEN } from "@lukso/lsp4-contracts/contracts/LSP4Constants.sol"; + /** * @title LSP7 version of the Hyperlane ERC20 Token Router * @dev https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/solidity/contracts/token/HypERC20.sol @@ -25,6 +28,11 @@ contract HypLSP7 is LSP7DigitalAssetInitAbstract, TokenRouter { * @param _totalSupply The initial supply of the token. * @param _name The name of the token. * @param _symbol The symbol of the token. + * + * @dev The `LSP4TokenType` is hardcoded to type `Token` (= `0`) as all ERC20 tokens are of token type 0. + * This aims to keep the number of parameters consistent between hyperc20 and hypLSP7, so that the code of off-chain + * agents that call this function + * does not need to be modifed to add an extra parameter that would be irrelevant. */ function initialize( uint256 _totalSupply, @@ -32,8 +40,7 @@ contract HypLSP7 is LSP7DigitalAssetInitAbstract, TokenRouter { string memory _symbol, address _hook, address _interchainSecurityModule, - address _owner, - uint256 _lsp4TokenType + address _owner ) external initializer @@ -43,7 +50,7 @@ contract HypLSP7 is LSP7DigitalAssetInitAbstract, TokenRouter { name_: _name, symbol_: _symbol, newOwner_: _owner, - lsp4TokenType_: _lsp4TokenType, + lsp4TokenType_: _LSP4_TOKEN_TYPE_TOKEN, isNonDivisible_: false // isNonDivisible set to `false` as will not be used anyway since decimals() is // overriden });