From e993d44f766bd55ab1970d1c18b9fc16cffd2750 Mon Sep 17 00:00:00 2001 From: Ignacio Mazzara Date: Sun, 14 Feb 2021 20:02:06 -0300 Subject: [PATCH] feat: reduce gas cost by prevent reading again from storage --- contracts/root/RootChainManager/RootChainManager.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/root/RootChainManager/RootChainManager.sol b/contracts/root/RootChainManager/RootChainManager.sol index 009092f3..b232b27a 100644 --- a/contracts/root/RootChainManager/RootChainManager.sol +++ b/contracts/root/RootChainManager/RootChainManager.sol @@ -287,12 +287,13 @@ contract RootChainManager is address rootToken, bytes memory depositData ) private { + bytes32 tokenType = tokenToType[rootToken]; require( rootToChildToken[rootToken] != address(0x0) && - tokenToType[rootToken] != 0, + tokenType != 0, "RootChainManager: TOKEN_NOT_MAPPED" ); - address predicateAddress = typeToPredicate[tokenToType[rootToken]]; + address predicateAddress = typeToPredicate[tokenType]; require( predicateAddress != address(0), "RootChainManager: INVALID_TOKEN_TYPE" @@ -407,7 +408,7 @@ contract RootChainManager is ITokenPredicate(predicateAddress).exitTokens( _msgSender(), - childToRootToken[childToken], + rootToken, logRLP.toRlpBytes() ); }