Skip to content

Commit 97b7baa

Browse files
committed
Upgrade support for contracts
1 parent 57aa913 commit 97b7baa

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

contracts/Autopay.sol

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.3;
33

4-
import {UsingFetch} from "usingfetch/contracts/UsingFetch.sol";
4+
//TODO fix import paths
5+
import {UsingFetchUpgradeReady} from "usingfetch/contracts/UsingFetchUpgradeReady.sol";
56
import {IERC20} from "./interfaces/IERC20.sol";
67
import "./interfaces/IQueryDataStorage.sol";
8+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
9+
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
10+
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
711

812
/**
913
@author Fetch Inc.
1014
@title Autopay
1115
@dev This is a contract for automatically paying for Fetch oracle data at
1216
* specific time intervals, as well as one time tips.
1317
*/
14-
contract Autopay is UsingFetch {
18+
contract Autopay is UsingFetchUpgradeReady, Initializable, OwnableUpgradeable, UUPSUpgradeable {
1519
// Storage
1620
IERC20 public token; // FETCH token address
1721
IQueryDataStorage public queryDataStorage; // Query data storage contract
@@ -91,20 +95,16 @@ contract Autopay is UsingFetch {
9195
address _reporter
9296
);
9397

94-
// Functions
95-
/**
96-
* @dev Initializes system parameters
97-
* @param _fetch address of Fetch contract
98-
* @param _queryDataStorage address of query data storage contract
99-
*/
100-
constructor(
101-
address payable _fetch,
102-
address _queryDataStorage
103-
) UsingFetch(_fetch) {
98+
function initialize(address payable _fetch, address _queryDataStorage) public initializer {
99+
__Ownable_init();
100+
setFetchAddress(_fetch);
104101
token = IERC20(fetch.token());
105102
queryDataStorage = IQueryDataStorage(_queryDataStorage);
106103
}
107104

105+
function _authorizeUpgrade(address _newImplementation) internal virtual override onlyOwner {
106+
}
107+
108108
/**
109109
* @dev Function to claim singular tip
110110
* @param _queryId id of reported data

contracts/testing/AutopayMock.sol

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ pragma solidity 0.8.3;
44
import "../Autopay.sol";
55

66
contract AutopayMock is Autopay {
7-
constructor(
8-
address payable _fetch,
9-
address _queryDataStorage
10-
) Autopay(_fetch, _queryDataStorage) {}
11-
127
function bytesToUint(bytes memory _b) public pure returns(uint256) {
138
return _bytesToUint(_b);
149
}

0 commit comments

Comments
 (0)