Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 27, 2024
1 parent c82fbd7 commit 1953142
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions contracts/nft/contracts/evm/UniversalNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract contract UniversalNFT is
GatewayEVM public immutable gateway;
uint256 private _nextTokenId;
address public universal;
uint256 public immutable gasLimit;
uint256 public immutable gasLimitAmount;

error InvalidAddress();
error Unauthorized();
Expand All @@ -41,7 +41,7 @@ abstract contract UniversalNFT is
constructor(address payable gatewayAddress, uint256 gas) {
if (gatewayAddress == address(0)) revert InvalidAddress();
if (gas == 0) revert InvalidGasLimit();
gasLimit = gas;
gasLimitAmount = gas;
gateway = GatewayEVM(gatewayAddress);
}

Expand Down Expand Up @@ -90,7 +90,7 @@ abstract contract UniversalNFT is
true,
address(0),
abi.encode(receiver, tokenId, uri, msg.sender),
gasLimit
gasLimitAmount
)
);
}
Expand Down
14 changes: 7 additions & 7 deletions contracts/nft/contracts/zetachain/UniversalNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract contract UniversalNFT is
address public immutable uniswapRouter;
uint256 private _nextTokenId;
bool public isUniversal = true;

Check warning

Code scanning / Slither

State variables that could be declared constant Warning

UniversalNFT.isUniversal should be constant
uint256 public immutable gasLimit;
uint256 public immutable gasLimitAmount;

error TransferFailed();
error Unauthorized();
Expand All @@ -50,7 +50,7 @@ abstract contract UniversalNFT is
if (gas == 0) revert InvalidGasLimit();
gateway = GatewayZEVM(gatewayAddress);
uniswapRouter = uniswapRouterAddress;
gasLimit = gas;
gasLimitAmount = gas;
}

function setConnected(
Expand All @@ -71,7 +71,7 @@ abstract contract UniversalNFT is
_burn(tokenId);

(, uint256 gasFee) = IZRC20(destination).withdrawGasFeeWithGasLimit(
gasLimit
gasLimitAmount
);
if (
!IZRC20(destination).transferFrom(msg.sender, address(this), gasFee)
Expand All @@ -85,14 +85,14 @@ abstract contract UniversalNFT is
msg.sender
);

CallOptions memory callOptions = CallOptions(gasLimit, false);
CallOptions memory callOptions = CallOptions(gasLimitAmount, false);

RevertOptions memory revertOptions = RevertOptions(
address(this),
true,
address(0),
abi.encode(tokenId, uri, msg.sender),
gasLimit
gasLimitAmount
);

gateway.call(
Expand Down Expand Up @@ -141,7 +141,7 @@ abstract contract UniversalNFT is
emit TokenTransferReceived(receiver, tokenId, uri);
} else {
(, uint256 gasFee) = IZRC20(destination).withdrawGasFeeWithGasLimit(
gasLimit
gasLimitAmount
);

uint256 out = SwapHelperLib.swapExactTokensForTokens(
Expand All @@ -158,7 +158,7 @@ abstract contract UniversalNFT is
out - gasFee,
destination,
abi.encode(receiver, tokenId, uri, out - gasFee, sender),
CallOptions(gasLimit, false),
CallOptions(gasLimitAmount, false),
RevertOptions(
address(this),
true,
Expand Down
6 changes: 3 additions & 3 deletions contracts/token/contracts/evm/UniversalToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "../shared/Events.sol";
abstract contract UniversalToken is ERC20, Ownable2Step, Events {
GatewayEVM public immutable gateway;
address public universal;
uint256 public immutable gasLimit;
uint256 public immutable gasLimitAmount;

error InvalidAddress();
error Unauthorized();
Expand All @@ -30,7 +30,7 @@ abstract contract UniversalToken is ERC20, Ownable2Step, Events {

constructor(address payable gatewayAddress, uint256 gas) {
if (gatewayAddress == address(0)) revert InvalidAddress();
gasLimit = gas;
gasLimitAmount = gas;
gateway = GatewayEVM(gatewayAddress);
}

Expand Down Expand Up @@ -67,7 +67,7 @@ abstract contract UniversalToken is ERC20, Ownable2Step, Events {
true,
address(0),
abi.encode(amount, msg.sender),
gasLimit
gasLimitAmount
)
);
}
Expand Down
14 changes: 7 additions & 7 deletions contracts/token/contracts/zetachain/UniversalToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract contract UniversalToken is
address public immutable uniswapRouter;
uint256 private _nextTokenId;
bool public isUniversal = true;

Check warning

Code scanning / Slither

State variables that could be declared constant Warning

UniversalToken.isUniversal should be constant
uint256 public immutable gasLimit;
uint256 public immutable gasLimitAmount;

error TransferFailed();
error Unauthorized();
Expand All @@ -45,7 +45,7 @@ abstract contract UniversalToken is
if (gas == 0) revert InvalidGasLimit();
gateway = GatewayZEVM(gatewayAddress);
uniswapRouter = uniswapRouterAddress;
gasLimit = gas;
gasLimitAmount = gas;
}

function setConnected(
Expand All @@ -65,22 +65,22 @@ abstract contract UniversalToken is
_burn(msg.sender, amount);

(, uint256 gasFee) = IZRC20(destination).withdrawGasFeeWithGasLimit(
gasLimit
gasLimitAmount
);
if (
!IZRC20(destination).transferFrom(msg.sender, address(this), gasFee)
) revert TransferFailed();
IZRC20(destination).approve(address(gateway), gasFee);
bytes memory message = abi.encode(receiver, amount, 0, msg.sender);

CallOptions memory callOptions = CallOptions(gasLimit, false);
CallOptions memory callOptions = CallOptions(gasLimitAmount, false);

RevertOptions memory revertOptions = RevertOptions(
address(this),
true,
address(0),
abi.encode(amount, msg.sender),
gasLimit
gasLimitAmount
);

gateway.call(
Expand Down Expand Up @@ -114,7 +114,7 @@ abstract contract UniversalToken is
_mint(receiver, tokenAmount);
} else {
(, uint256 gasFee) = IZRC20(destination).withdrawGasFeeWithGasLimit(
gasLimit
gasLimitAmount
);
uint256 out = SwapHelperLib.swapExactTokensForTokens(
uniswapRouter,
Expand All @@ -129,7 +129,7 @@ abstract contract UniversalToken is
out - gasFee,
destination,
abi.encode(receiver, tokenAmount, out - gasFee, sender),
CallOptions(gasLimit, false),
CallOptions(gasLimitAmount, false),
RevertOptions(
address(this),
true,
Expand Down

0 comments on commit 1953142

Please sign in to comment.