mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
fix: lint-stage solhint bug
This commit is contained in:
parent
1da9b630c8
commit
b8e1aef64f
|
@ -7,9 +7,9 @@ import {
|
|||
import {Address} from "../../vendor/Address.sol";
|
||||
import {IERC20} from "../../interfaces/tokens/IERC20.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 {Ownable} from "../../lib/Ownable.sol";
|
||||
import {Ownable} from "../../vendor/Ownable.sol";
|
||||
|
||||
/// @title ConnectGelatoProviderPayment
|
||||
/// @notice InstaDapp Connector to compensate Gelato automation-gas Providers.
|
||||
|
@ -24,19 +24,20 @@ contract ConnectGelatoProviderPayment is
|
|||
// solhint-disable-next-line const-name-snakecase
|
||||
string public constant override name = "ConnectGelatoProviderPayment-v1.0";
|
||||
|
||||
uint256 internal immutable _id;
|
||||
address internal _providerAddress;
|
||||
address internal immutable _paymentConnectorAddr;
|
||||
address public override gelatoProvider;
|
||||
|
||||
constructor(uint256 id, address providerAddress) {
|
||||
uint256 internal immutable _id;
|
||||
address internal immutable _this;
|
||||
|
||||
constructor(uint256 id, address _gelatoProvider) {
|
||||
_id = id;
|
||||
_providerAddress = providerAddress;
|
||||
_paymentConnectorAddr = address(this);
|
||||
gelatoProvider = _gelatoProvider;
|
||||
_this = address(this);
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
function connectorID()
|
||||
public
|
||||
external
|
||||
view
|
||||
override
|
||||
returns (uint256 _type, uint256 id)
|
||||
|
@ -44,45 +45,39 @@ contract ConnectGelatoProviderPayment is
|
|||
(_type, id) = (1, _id); // Should put specific value.
|
||||
}
|
||||
|
||||
/// @notice Retrieve provider address that will be paid for executing the task
|
||||
/// @return provider's address
|
||||
function getProvider() external view override returns (address) {
|
||||
return _providerAddress;
|
||||
}
|
||||
|
||||
/// @notice Set the provider address that will be paid for executing a task
|
||||
function setProvider(address providerAddress) external onlyOwner {
|
||||
_providerAddress = providerAddress;
|
||||
/// @notice Set the gelatoProvider address that will be paid for executing a task
|
||||
function setProvider(address _gelatoProvider) external override onlyOwner {
|
||||
gelatoProvider = _gelatoProvider;
|
||||
}
|
||||
|
||||
/// @notice Transfers automation gas fees to Gelato Provider
|
||||
/// @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
|
||||
/// - 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.
|
||||
// In the latter case, it does not matter what address is passed off-chain.
|
||||
/// @param _token The token used to pay the 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 _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(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
uint256 _getId,
|
||||
uint256 _setId
|
||||
) public payable override {
|
||||
address provider = IConnectGelatoProviderPayment(_paymentConnectorAddr)
|
||||
.getProvider();
|
||||
) external payable override {
|
||||
address _gelatoProvider = IConnectGelatoProviderPayment(_this)
|
||||
.gelatoProvider();
|
||||
require(
|
||||
provider != address(0x0),
|
||||
"ConnectGelatoProviderPayment.payProvider:!_provider"
|
||||
_gelatoProvider != address(0x0),
|
||||
"ConnectGelatoProviderPayment.payProvider:!_gelatoProvider"
|
||||
);
|
||||
uint256 amt = getUint(_getId, _amt);
|
||||
setUint(_setId, amt);
|
||||
uint256 amt = _getUint(_getId, _amt);
|
||||
_setUint(_setId, amt);
|
||||
_token == ETH
|
||||
? payable(provider).sendValue(amt)
|
||||
: IERC20(_token).safeTransfer(provider, amt);
|
||||
? payable(_gelatoProvider).sendValue(amt)
|
||||
: IERC20(_token).safeTransfer(_gelatoProvider, amt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ pragma solidity 0.7.4;
|
|||
import {MemoryInterface} from "../../interfaces/InstaDapp/IInstaDapp.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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import {
|
|||
IConnectGelatoProviderPayment
|
||||
} from "../../../interfaces/InstaDapp/connectors/IConnectGelatoProviderPayment.sol";
|
||||
|
||||
// solhint-disable-next-line
|
||||
function _encodePayGelatoProvider(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
|
|
|
@ -4,7 +4,7 @@ pragma solidity 0.7.4;
|
|||
import {ConnectorInterface} from "../IInstaDapp.sol";
|
||||
|
||||
interface IConnectGelatoProviderPayment is ConnectorInterface {
|
||||
function getProvider() external returns (address);
|
||||
function setProvider(address _provider) external;
|
||||
|
||||
function payProvider(
|
||||
address _token,
|
||||
|
@ -12,4 +12,6 @@ interface IConnectGelatoProviderPayment is ConnectorInterface {
|
|||
uint256 _getId,
|
||||
uint256 _setId
|
||||
) external payable;
|
||||
|
||||
function gelatoProvider() external view returns (address);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -42,7 +42,6 @@
|
|||
},
|
||||
"lint-staged": {
|
||||
"*.js": "eslint --cache --fix",
|
||||
"*.sol": "solhint",
|
||||
"*.{js,sol,css,md}": "prettier --write"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,17 +168,19 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
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 () {
|
||||
expect(await connectGelatoProviderPayment.getProvider()).to.be.equal(
|
||||
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
|
||||
ethers.constants.AddressZero
|
||||
);
|
||||
|
||||
await connectGelatoProviderPayment.setProvider(providerAddress);
|
||||
|
||||
expect(await connectGelatoProviderPayment.getProvider()).to.be.equal(
|
||||
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
|
||||
providerAddress
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user