Skip to content

Commit

Permalink
remove autoScaling
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Jan 9, 2025
1 parent fb0464f commit 873020e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 112 deletions.
49 changes: 0 additions & 49 deletions contracts/InterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
bytes32 internal constant PREFIX_CANONICAL_TOKEN_SALT = keccak256('canonical-token-salt');
bytes32 internal constant PREFIX_INTERCHAIN_TOKEN_SALT = keccak256('interchain-token-salt');
bytes32 internal constant PREFIX_DEPLOY_APPROVAL = keccak256('deploy-approval');
bytes32 internal constant PREFIX_CUSTOM_TOKEN_SALT = keccak256('custom-token-salt');
address private constant TOKEN_FACTORY_DEPLOYER = address(0);

IInterchainTokenService public immutable interchainTokenService;
Expand Down Expand Up @@ -416,7 +415,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
currentChain,
tokenAddress.toBytes(),
TokenManagerType.LOCK_UNLOCK,
true,
'',
gasValue
);
Expand Down Expand Up @@ -492,53 +490,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
tokenId = deployRemoteCanonicalInterchainToken(originalTokenAddress, destinationChain, gasValue);
}

function linkedTokenDeploySalt(address deployer, bytes32 salt) public view returns (bytes32 deploySalt) {
deploySalt = keccak256(abi.encode(PREFIX_CUSTOM_TOKEN_SALT, chainNameHash, deployer, salt));
}

function linkedTokenId(address deployer, bytes32 salt) external view returns (bytes32 tokenId) {
bytes32 deploySalt = linkedTokenDeploySalt(deployer, salt);
tokenId = _interchainTokenId(deploySalt);
}

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 = '';
if (operator != address(0)) {
operatorBytes = operator.toBytes();
}

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

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

function linkToken(
bytes32 salt,
string calldata destinationChain,
bytes calldata destinationTokenAddress,
TokenManagerType tokenManagerType,
bytes calldata linkParams,
uint256 gasValue
) external payable returns (bytes32 tokenId) {
bytes32 deploySalt = linkedTokenDeploySalt(msg.sender, salt);
tokenId = interchainTokenService.linkToken(
deploySalt,
destinationChain,
destinationTokenAddress,
tokenManagerType,
linkParams,
gasValue
);
}

/********************\
|* Pure Key Getters *|
\********************/
Expand Down
11 changes: 3 additions & 8 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ contract InterchainTokenService is
string calldata destinationChain,
bytes memory destinationTokenAddress,
TokenManagerType tokenManagerType,
bool autoScaling,
bytes memory linkParams,
uint256 gasValue
) public payable whenNotPaused returns (bytes32 tokenId) {
Expand Down Expand Up @@ -346,7 +345,7 @@ contract InterchainTokenService is
} else {
if (chainNameHash == keccak256(bytes(destinationChain))) revert CannotDeployRemotelyToSelf();

_linkToken(tokenId, destinationChain, destinationTokenAddress, tokenManagerType, autoScaling, linkParams, gasValue);
_linkToken(tokenId, destinationChain, destinationTokenAddress, tokenManagerType, linkParams, gasValue);
}
}

Expand Down Expand Up @@ -753,8 +752,8 @@ contract InterchainTokenService is
* @notice Processes a deploy token manager payload.
*/
function _processLinkTokenPayload(bytes memory payload) internal {
(, bytes32 tokenId, TokenManagerType tokenManagerType, , bytes memory destinationTokenAddress, , bytes memory linkParams) = abi
.decode(payload, (uint256, bytes32, TokenManagerType, bytes, bytes, bool, bytes));
(, bytes32 tokenId, TokenManagerType tokenManagerType, , bytes memory destinationTokenAddress, bytes memory linkParams) = abi
.decode(payload, (uint256, bytes32, TokenManagerType, bytes, bytes, bytes));

if (tokenManagerType == TokenManagerType.NATIVE_INTERCHAIN_TOKEN) revert CannotDeploy(tokenManagerType);

Expand Down Expand Up @@ -908,7 +907,6 @@ contract InterchainTokenService is
* @param destinationChain The chain where the token manager will be deployed.
* @param destinationTokenAddress The address of the token on the destination chain.
* @param tokenManagerType The type of token manager to be deployed.
* @param autoScaling Whether to enable auto scaling of decimals for the interchain token.
* @param params Additional parameters for the token linking.
* @param gasValue The amount of gas to be paid for the transaction.
*/
Expand All @@ -917,7 +915,6 @@ contract InterchainTokenService is
string calldata destinationChain,
bytes memory destinationTokenAddress,
TokenManagerType tokenManagerType,
bool autoScaling,
bytes memory params,
uint256 gasValue
) internal {
Expand All @@ -930,7 +927,6 @@ contract InterchainTokenService is
sourceTokenAddress,
destinationTokenAddress,
tokenManagerType,
autoScaling,
params
);

Expand All @@ -940,7 +936,6 @@ contract InterchainTokenService is
tokenManagerType,
sourceTokenAddress,
destinationTokenAddress,
autoScaling,
params
);

Expand Down
3 changes: 0 additions & 3 deletions contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ interface IInterchainTokenService is
bytes sourceTokenAddress,
bytes destinationTokenAddress,
TokenManagerType indexed tokenManagerType,
bool autoScaling,
bytes params
);
event InterchainTokenDeploymentStarted(
Expand Down Expand Up @@ -185,7 +184,6 @@ interface IInterchainTokenService is
* @param destinationChain The name of the destination chain.
* @param destinationTokenAddress The address of the token on the destination chain.
* @param tokenManagerType The type of token manager. Cannot be NATIVE_INTERCHAIN_TOKEN.
* @param autoScaling Whether to enable auto scaling of decimals for the interchain token.
* @param linkParams The link parameters.
* @param gasValue The gas value for deployment.
* @return tokenId The tokenId associated with the token manager.
Expand All @@ -195,7 +193,6 @@ interface IInterchainTokenService is
string calldata destinationChain,
bytes memory destinationTokenAddress,
TokenManagerType tokenManagerType,
bool autoScaling,
bytes memory linkParams,
uint256 gasValue
) external payable returns (bytes32 tokenId);
Expand Down
Loading

0 comments on commit 873020e

Please sign in to comment.