Skip to content

Commit

Permalink
submit registerTokenMetadata on registerCustomToken
Browse files Browse the repository at this point in the history
  • Loading branch information
hinalsheth committed Dec 16, 2024
1 parent 0c1dc92 commit e7c9e8a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
4 changes: 3 additions & 1 deletion contracts/InterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, Multicall, Upgradabl
tokenId = _interchainTokenId(deploySalt);
}

function registerCustomToken(bytes32 salt, address tokenAddress, TokenManagerType tokenManagerType, address operator) external payable returns (bytes32 tokenId) {
function registerCustomToken(bytes32 salt, address tokenAddress, TokenManagerType tokenManagerType, address operator, uint256 gasValue) external payable returns (bytes32 tokenId) {
bytes32 deploySalt = linkedTokenDeploySalt(msg.sender, salt);
bytes memory operatorBytes = '';
string memory currentChain = '';
Expand All @@ -465,6 +465,8 @@ contract InterchainTokenFactory is IInterchainTokenFactory, Multicall, Upgradabl
}

tokenId = interchainTokenService.linkToken(deploySalt, currentChain, tokenAddress.toBytes(), tokenManagerType, false, operatorBytes, 0);

interchainTokenService.registerTokenMetadata{ value: gasValue }(tokenAddress, gasValue);
}

function linkToken(bytes32 salt, string calldata destinationChain, bytes calldata destinationTokenAddress, TokenManagerType tokenManagerType, bool autoScaling, bytes calldata linkParams, uint256 gasValue) external payable returns (bytes32 tokenId) {
Expand Down
10 changes: 9 additions & 1 deletion contracts/interfaces/IInterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,15 @@ interface IInterchainTokenFactory is ITokenManagerType, IUpgradable, IMulticall
*/
function linkedTokenId(address deployer, bytes32 salt) external view returns (bytes32 tokenId);

function registerCustomToken(bytes32 salt, address tokenAddress, TokenManagerType tokenManagerType, address operator) external payable returns (bytes32 tokenId);
/**
* @notice Register an existing token under a `tokenId` computed from the provided `salt`. A token metadata registration message will also be sent to the ITS Hub.
* @param salt The salt used to derive the tokenId for the custom token registration. The same salt must be used when linking this token on other chains under the same tokenId.
* @param tokenAddress The token address of the token being registered.
* @param tokenManagerType The token manager type used for the token link.
* @param operator The operator of the token manager.
* @param gasValue The cross-chain gas value used to register the token metadata on the ITS Hub.
*/
function registerCustomToken(bytes32 salt, address tokenAddress, TokenManagerType tokenManagerType, address operator, uint256 gasValue) external payable returns (bytes32 tokenId);

function linkToken(bytes32 salt, string calldata destinationChain, bytes calldata destinationTokenAddress, TokenManagerType tokenManagerType, bool autoScaling, bytes calldata linkParams, uint256 gasValue) external payable returns (bytes32 tokenId);
}
2 changes: 1 addition & 1 deletion contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ interface IInterchainTokenService is
/**
* @notice Registers metadata for a token on the ITS Hub. This metadata is used for scaling linked tokens.
* @param tokenAddress The address of the token.
* @param gasValue The gas value for deployment.
* @param gasValue The cross-chain gas value for sending the registration message to ITS Hub.
*/
function registerTokenMetadata(address tokenAddress, uint256 gasValue) external payable;

Expand Down
1 change: 0 additions & 1 deletion contracts/proxies/TokenManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,3 @@ contract TokenManagerProxy is BaseProxy, ITokenManagerProxy {
implementation_ = ITokenManagerImplementation(interchainTokenService_).tokenManagerImplementation(implementationType_);
}
}

14 changes: 7 additions & 7 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const compilerSettings = {
optimizer: optimizerSettings,
},
};
if (!process.env.CHECK_CONTRACT_SIZE) {
//if (!process.env.CHECK_CONTRACT_SIZE) {
networks.hardhat.allowUnlimitedContractSize = true;
}
//}

/**
* @type import('hardhat/config').HardhatUserConfig
Expand Down Expand Up @@ -75,9 +75,9 @@ module.exports = {
enabled: process.env.REPORT_GAS !== undefined,
excludeContracts: ['contracts/test'],
},
contractSizer: {
runOnCompile: process.env.CHECK_CONTRACT_SIZE,
strict: process.env.CHECK_CONTRACT_SIZE,
except: ['contracts/test'],
},
//contractSizer: {
// runOnCompile: process.env.CHECK_CONTRACT_SIZE,
// strict: process.env.CHECK_CONTRACT_SIZE,
// except: ['contracts/test'],
//},
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e7c9e8a

Please sign in to comment.