From 149310a9a3c4c4cae7d22890c4d0dc0d8b0ca26e Mon Sep 17 00:00:00 2001 From: Oleksandr Date: Tue, 10 Dec 2024 16:48:06 +0200 Subject: [PATCH] review fixes #1 --- smart-contracts/contracts/delegate/ProvidersDelegator.sol | 5 +++-- smart-contracts/contracts/diamond/facets/SessionRouter.sol | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/smart-contracts/contracts/delegate/ProvidersDelegator.sol b/smart-contracts/contracts/delegate/ProvidersDelegator.sol index b20204ce..6f09a9e7 100644 --- a/smart-contracts/contracts/delegate/ProvidersDelegator.sol +++ b/smart-contracts/contracts/delegate/ProvidersDelegator.sol @@ -120,13 +120,15 @@ contract ProvidersDelegator is IProvidersDelegator, OwnableUpgradeable { if (amount_ == 0) { revert InsufficientAmount(); } - + address user_ = _msgSender(); Staker storage staker = stakers[user_]; (uint256 currentRate_, uint256 contractBalance_) = getCurrentRate(); uint256 pendingRewards_ = _getCurrentStakerRewards(currentRate_, staker); + IERC20(token).safeTransferFrom(user_, address(this), amount_); + totalRate = currentRate_; totalStaked += amount_; @@ -136,7 +138,6 @@ contract ProvidersDelegator is IProvidersDelegator, OwnableUpgradeable { staker.staked += amount_; staker.pendingRewards = pendingRewards_; - IERC20(token).safeTransferFrom(user_, address(this), amount_); IProviderRegistry(lumerinDiamond).providerRegister(address(this), amount_, endpoint); emit Staked(user_, staker.staked, staker.pendingRewards, staker.rate); diff --git a/smart-contracts/contracts/diamond/facets/SessionRouter.sol b/smart-contracts/contracts/diamond/facets/SessionRouter.sol index 923ef18e..53e18b79 100644 --- a/smart-contracts/contracts/diamond/facets/SessionRouter.sol +++ b/smart-contracts/contracts/diamond/facets/SessionRouter.sol @@ -2,6 +2,8 @@ pragma solidity ^0.8.24; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; +import {Address} from "@openzeppelin/contracts/utils/Address.sol"; + import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; @@ -19,8 +21,6 @@ import {LibSD} from "../../libs/LibSD.sol"; import {ISessionRouter} from "../../interfaces/facets/ISessionRouter.sol"; -import "hardhat/console.sol"; - contract SessionRouter is ISessionRouter, OwnableDiamondStorage, @@ -34,6 +34,7 @@ contract SessionRouter is using LibSD for LibSD.SD; using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.Bytes32Set; + using Address for address; function __SessionRouter_init( address fundingAccount_, @@ -540,7 +541,7 @@ contract SessionRouter is return true; } - if (provider_.code.length > 0) { + if (provider_.isContract()) { (bool success, bytes memory result) = provider_.staticcall(abi.encodeWithSignature("owner()")); if (success && result.length == 32) { address owner_ = abi.decode(result, (address));