fix: lint-stage solhint bug

This commit is contained in:
gitpusha 2020-11-03 14:25:36 +01:00 committed by Luis Schliesske
parent 1da9b630c8
commit b8e1aef64f
7 changed files with 35 additions and 120 deletions

View File

@ -7,9 +7,9 @@ import {
import {Address} from "../../vendor/Address.sol"; import {Address} from "../../vendor/Address.sol";
import {IERC20} from "../../interfaces/tokens/IERC20.sol"; import {IERC20} from "../../interfaces/tokens/IERC20.sol";
import {SafeERC20} from "../../vendor/SafeERC20.sol"; import {SafeERC20} from "../../vendor/SafeERC20.sol";
import {getUint, setUint} from "../../functions/InstaDapp/FInstaDapp.sol"; import {_getUint, _setUint} from "../../functions/InstaDapp/FInstaDapp.sol";
import {ETH} from "../../constants/CInstaDapp.sol"; import {ETH} from "../../constants/CInstaDapp.sol";
import {Ownable} from "../../lib/Ownable.sol"; import {Ownable} from "../../vendor/Ownable.sol";
/// @title ConnectGelatoProviderPayment /// @title ConnectGelatoProviderPayment
/// @notice InstaDapp Connector to compensate Gelato automation-gas Providers. /// @notice InstaDapp Connector to compensate Gelato automation-gas Providers.
@ -24,19 +24,20 @@ contract ConnectGelatoProviderPayment is
// solhint-disable-next-line const-name-snakecase // solhint-disable-next-line const-name-snakecase
string public constant override name = "ConnectGelatoProviderPayment-v1.0"; string public constant override name = "ConnectGelatoProviderPayment-v1.0";
uint256 internal immutable _id; address public override gelatoProvider;
address internal _providerAddress;
address internal immutable _paymentConnectorAddr;
constructor(uint256 id, address providerAddress) { uint256 internal immutable _id;
address internal immutable _this;
constructor(uint256 id, address _gelatoProvider) {
_id = id; _id = id;
_providerAddress = providerAddress; gelatoProvider = _gelatoProvider;
_paymentConnectorAddr = address(this); _this = address(this);
} }
/// @dev Connector Details /// @dev Connector Details
function connectorID() function connectorID()
public external
view view
override override
returns (uint256 _type, uint256 id) returns (uint256 _type, uint256 id)
@ -44,45 +45,39 @@ contract ConnectGelatoProviderPayment is
(_type, id) = (1, _id); // Should put specific value. (_type, id) = (1, _id); // Should put specific value.
} }
/// @notice Retrieve provider address that will be paid for executing the task /// @notice Set the gelatoProvider address that will be paid for executing a task
/// @return provider's address function setProvider(address _gelatoProvider) external override onlyOwner {
function getProvider() external view override returns (address) { gelatoProvider = _gelatoProvider;
return _providerAddress;
}
/// @notice Set the provider address that will be paid for executing a task
function setProvider(address providerAddress) external onlyOwner {
_providerAddress = providerAddress;
} }
/// @notice Transfers automation gas fees to Gelato Provider /// @notice Transfers automation gas fees to Gelato Provider
/// @dev Gelato Provider risks: /// @dev Gelato Provider risks:
/// - _getId does not match actual InstaMemory provider payment slot /// - _getId does not match actual InstaMemory gelatoProvider payment slot
/// - _token balance not in DSA /// - _token balance not in DSA
/// - worthless _token risk /// - worthless _token risk
/// @param _provider The Provider who pays the Gelato network for automation. /// @param _gelatoProvider The Provider who pays the Gelato network for automation.
// This param should be verified / replaced by the ProviderModule in Gelato on-chain. // This param should be verified / replaced by the ProviderModule in Gelato on-chain.
// In the latter case, it does not matter what address is passed off-chain. // In the latter case, it does not matter what address is passed off-chain.
/// @param _token The token used to pay the Provider. /// @param _token The token used to pay the Provider.
/// @param _amt The amount of _token to pay the Gelato Provider. /// @param _amt The amount of _token to pay the Gelato Provider.
/// @param _getId The InstaMemory slot at which the payment amount was stored. /// @param _getId The InstaMemory slot at which the payment amount was stored.
/// @param _setId The InstaMemory slot to save the provider payout amound in. /// @param _setId The InstaMemory slot to save the gelatoProvider payout amound in.
function payProvider( function payProvider(
address _token, address _token,
uint256 _amt, uint256 _amt,
uint256 _getId, uint256 _getId,
uint256 _setId uint256 _setId
) public payable override { ) external payable override {
address provider = IConnectGelatoProviderPayment(_paymentConnectorAddr) address _gelatoProvider = IConnectGelatoProviderPayment(_this)
.getProvider(); .gelatoProvider();
require( require(
provider != address(0x0), _gelatoProvider != address(0x0),
"ConnectGelatoProviderPayment.payProvider:!_provider" "ConnectGelatoProviderPayment.payProvider:!_gelatoProvider"
); );
uint256 amt = getUint(_getId, _amt); uint256 amt = _getUint(_getId, _amt);
setUint(_setId, amt); _setUint(_setId, amt);
_token == ETH _token == ETH
? payable(provider).sendValue(amt) ? payable(_gelatoProvider).sendValue(amt)
: IERC20(_token).safeTransfer(provider, amt); : IERC20(_token).safeTransfer(_gelatoProvider, amt);
} }
} }

View File

@ -4,10 +4,10 @@ pragma solidity 0.7.4;
import {MemoryInterface} from "../../interfaces/InstaDapp/IInstaDapp.sol"; import {MemoryInterface} from "../../interfaces/InstaDapp/IInstaDapp.sol";
import {INSTA_MEMORY} from "../../constants/CInstaDapp.sol"; import {INSTA_MEMORY} from "../../constants/CInstaDapp.sol";
function setUint(uint256 setId, uint256 val) { function _setUint(uint256 setId, uint256 val) {
if (setId != 0) MemoryInterface(INSTA_MEMORY).setUint(setId, val); if (setId != 0) MemoryInterface(INSTA_MEMORY).setUint(setId, val);
} }
function getUint(uint256 getId, uint256 val) returns (uint256 returnVal) { function _getUint(uint256 getId, uint256 val) returns (uint256 returnVal) {
returnVal = getId == 0 ? val : MemoryInterface(INSTA_MEMORY).getUint(getId); returnVal = getId == 0 ? val : MemoryInterface(INSTA_MEMORY).getUint(getId);
} }

View File

@ -5,7 +5,6 @@ import {
IConnectGelatoProviderPayment IConnectGelatoProviderPayment
} from "../../../interfaces/InstaDapp/connectors/IConnectGelatoProviderPayment.sol"; } from "../../../interfaces/InstaDapp/connectors/IConnectGelatoProviderPayment.sol";
// solhint-disable-next-line
function _encodePayGelatoProvider( function _encodePayGelatoProvider(
address _token, address _token,
uint256 _amt, uint256 _amt,

View File

@ -4,7 +4,7 @@ pragma solidity 0.7.4;
import {ConnectorInterface} from "../IInstaDapp.sol"; import {ConnectorInterface} from "../IInstaDapp.sol";
interface IConnectGelatoProviderPayment is ConnectorInterface { interface IConnectGelatoProviderPayment is ConnectorInterface {
function getProvider() external returns (address); function setProvider(address _provider) external;
function payProvider( function payProvider(
address _token, address _token,
@ -12,4 +12,6 @@ interface IConnectGelatoProviderPayment is ConnectorInterface {
uint256 _getId, uint256 _getId,
uint256 _setId uint256 _setId
) external payable; ) external payable;
function gelatoProvider() external view returns (address);
} }

View File

@ -1,82 +0,0 @@
// "SPDX-License-Identifier: UNLICENSED"
pragma solidity 0.7.4;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal virtual {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}

View File

@ -42,7 +42,6 @@
}, },
"lint-staged": { "lint-staged": {
"*.js": "eslint --cache --fix", "*.js": "eslint --cache --fix",
"*.sol": "solhint",
"*.{js,sol,css,md}": "prettier --write" "*.{js,sol,css,md}": "prettier --write"
} }
} }

View File

@ -168,17 +168,19 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
value: ethers.utils.parseEther("1"), value: ethers.utils.parseEther("1"),
} }
) )
).to.be.revertedWith("ConnectGelatoProviderPayment.payProvider:!_provider"); ).to.be.revertedWith(
"ConnectGelatoProviderPayment.payProvider:!_gelatoProvider"
);
}); });
it("#2: setProvider should change the provider address", async function () { it("#2: setProvider should change the provider address", async function () {
expect(await connectGelatoProviderPayment.getProvider()).to.be.equal( expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
ethers.constants.AddressZero ethers.constants.AddressZero
); );
await connectGelatoProviderPayment.setProvider(providerAddress); await connectGelatoProviderPayment.setProvider(providerAddress);
expect(await connectGelatoProviderPayment.getProvider()).to.be.equal( expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
providerAddress providerAddress
); );
}); });