Skip to content

refactor(network-contracts): remove chainlink from contracts #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"solidity.defaultCompiler": "remote"
"solidity.defaultCompiler": "remote",
"makefile.configureOnOpen": false
}
2 changes: 0 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ module.exports = {
dependencyCompiler: {
paths: [
'@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol',
'@chainlink/contracts/src/v0.4/LinkToken.sol',
'@chainlink/contracts/src/v0.6/Oracle.sol'
],
},
solidity: {
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"clean": "npm run clean --workspaces --if-present",
"lint": "npm run lint --workspaces --if-present && eslint .",
"test": "npm run test --workspaces --if-present",
"integration-test": "npm run integration-test --workspaces --if-present",
"test:subgraph": "graph test -d",
"e2etest": "npm run e2etest --workspace=network-contracts"
},
Expand Down
1 change: 0 additions & 1 deletion packages/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@
}
],
"contracts": {
"ChainlinkOracle": "0x36BF71D0ba2e449fc14f9C4cF51468948E4ED27D",
"DATA": "0x3a9A81d576d83FF21f26f325066054540720fC34",
"DataUnionFactory": "0xd0B3a09A6bCee8446d10e6E7e12c78F8725C9B18",
"DataUnionTemplate": "0xaFe97F5a1cD3edE2c11d990e0EB0270054AA0589",
Expand Down
4 changes: 2 additions & 2 deletions packages/ens-sync-script/prepare.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdir -p network-contracts/artifacts/contracts/StreamRegistry/StreamRegistryV5.sol
mkdir -p network-contracts/artifacts/contracts/chainlinkClient/ENSCacheV2Streamr.sol
mkdir -p network-contracts/artifacts/contracts/ENS/ENSCacheV2Streamr.sol
cp ../network-contracts/artifacts/contracts/StreamRegistry/StreamRegistryV5.sol/StreamRegistryV5.json ./network-contracts/artifacts/contracts/StreamRegistry/StreamRegistryV5.sol
cp -r ../network-contracts/artifacts/contracts/chainlinkClient/ENSCacheV2Streamr.sol/ENSCacheV2Streamr.json ./network-contracts/artifacts/contracts/chainlinkClient/ENSCacheV2Streamr.sol
cp -r ../network-contracts/artifacts/contracts/ENS/ENSCacheV2Streamr.sol/ENSCacheV2Streamr.json ./network-contracts/artifacts/contracts/ENS/ENSCacheV2Streamr.sol

8 changes: 4 additions & 4 deletions packages/network-contracts/.openzeppelin/polygon.json
Original file line number Diff line number Diff line change
Expand Up @@ -868,31 +868,31 @@
"slot": "201",
"type": "t_mapping(t_string_memory_ptr,t_address)",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:17"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:17"
},
{
"label": "streamrScript",
"offset": 0,
"slot": "202",
"type": "t_address",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:18"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:18"
},
{
"label": "streamRegistry",
"offset": 0,
"slot": "203",
"type": "t_contract(IStreamRegistry)17218",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:19"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:19"
},
{
"label": "ensCacheV1",
"offset": 0,
"slot": "204",
"type": "t_contract(ENSCacheV1)17576",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:20"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:20"
}
],
"types": {
Expand Down
8 changes: 4 additions & 4 deletions packages/network-contracts/.openzeppelin/unknown-3338.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,31 +363,31 @@
"slot": "201",
"type": "t_mapping(t_string_memory_ptr,t_address)",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:17"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:17"
},
{
"label": "streamrScript",
"offset": 0,
"slot": "202",
"type": "t_address",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:18"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:18"
},
{
"label": "streamRegistry",
"offset": 0,
"slot": "203",
"type": "t_contract(IStreamRegistry)21862",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:19"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:19"
},
{
"label": "ensCacheV1",
"offset": 0,
"slot": "204",
"type": "t_contract(ENSCacheV1)22220",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:20"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:20"
}
],
"types": {
Expand Down
8 changes: 4 additions & 4 deletions packages/network-contracts/.openzeppelin/unknown-4689.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,31 +363,31 @@
"slot": "201",
"type": "t_mapping(t_string_memory_ptr,t_address)",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:17"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:17"
},
{
"label": "streamrScript",
"offset": 0,
"slot": "202",
"type": "t_address",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:18"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:18"
},
{
"label": "streamRegistry",
"offset": 0,
"slot": "203",
"type": "t_contract(IStreamRegistry)3531",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:19"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:19"
},
{
"label": "ensCacheV1",
"offset": 0,
"slot": "204",
"type": "t_contract(ENSCacheV1)3889",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:20"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:20"
}
],
"types": {
Expand Down
8 changes: 4 additions & 4 deletions packages/network-contracts/.openzeppelin/unknown-4690.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,31 +348,31 @@
"slot": "201",
"type": "t_mapping(t_string_memory_ptr,t_address)",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:17"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:17"
},
{
"label": "streamrScript",
"offset": 0,
"slot": "202",
"type": "t_address",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:18"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:18"
},
{
"label": "streamRegistry",
"offset": 0,
"slot": "203",
"type": "t_contract(IStreamRegistry)24359",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:19"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:19"
},
{
"label": "ensCacheV1",
"offset": 0,
"slot": "204",
"type": "t_contract(ENSCacheV1)24717",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:20"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:20"
}
],
"types": {
Expand Down
8 changes: 4 additions & 4 deletions packages/network-contracts/.openzeppelin/unknown-80002.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,31 +402,31 @@
"slot": "201",
"type": "t_mapping(t_string_memory_ptr,t_address)",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:17"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:17"
},
{
"label": "streamrScript",
"offset": 0,
"slot": "202",
"type": "t_address",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:18"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:18"
},
{
"label": "streamRegistry",
"offset": 0,
"slot": "203",
"type": "t_contract(IStreamRegistry)19523",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:19"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:19"
},
{
"label": "ensCacheV1",
"offset": 0,
"slot": "204",
"type": "t_contract(ENSCacheV1)19881",
"contract": "ENSCacheV2Streamr",
"src": "contracts/chainlinkClient/ENSCacheV2Streamr.sol:20"
"src": "contracts/ENS/ENSCacheV2Streamr.sol:20"
}
],
"types": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

import "./ENSCacheV1.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/proxy/utils/UUPSUpgradeable.sol";

interface IStreamRegistry {
// solhint-disable-next-line func-name-mixedcase
function ENScreateStreamCallback(address requestorAddress, string memory ensName, string calldata streamIdPath, string calldata metadataJsonString) external;
}

contract ENSCacheV2Streamr is Initializable, UUPSUpgradeable, OwnableUpgradeable {

event RequestENSOwnerAndCreateStream(string ensName, string streamIdPath, string metadataJsonString, address requestorAddress);

mapping(string => address) public owners;
address private streamrScript; // TODO: make public
IStreamRegistry private streamRegistry; // TODO: make public
ENSCacheV1 private ensCacheV1; // TODO: make public
address public streamrScript;
IStreamRegistry public streamRegistry;

modifier onlyStreamr() {
require(msg.sender == address(streamrScript), "onlyStreamrScript");
Expand All @@ -32,11 +35,10 @@ contract ENSCacheV2Streamr is Initializable, UUPSUpgradeable, OwnableUpgradeable
constructor() {
}

function initialize(address _streamrScript, IStreamRegistry _streamRegistry, ENSCacheV1 _ensCacheV1) public initializer {
function initialize(address _streamrScript, IStreamRegistry _streamRegistry) public initializer {
__Ownable_init();
streamrScript = _streamrScript;
streamRegistry = _streamRegistry;
ensCacheV1 = _ensCacheV1;
}

function _authorizeUpgrade(address) internal override onlyOwner {}
Expand All @@ -45,10 +47,6 @@ contract ENSCacheV2Streamr is Initializable, UUPSUpgradeable, OwnableUpgradeable
streamRegistry = IStreamRegistry(streamRegistryAddress);
}

function setENSCacheV1(address ensCacheV1Address) public onlyOwner {
ensCacheV1 = ENSCacheV1(ensCacheV1Address);
}

function setStreamrScript(address _streamrScript) public onlyOwner {
streamrScript = _streamrScript;
}
Expand All @@ -60,17 +58,11 @@ contract ENSCacheV2Streamr is Initializable, UUPSUpgradeable, OwnableUpgradeable
string calldata metadataJsonString,
address requestorAddress
) public onlyStreamRegistry() {
address ownerAddress = address(ensCacheV1) != address(0) ? ensCacheV1.owners(ensName) : address(0);
if (ownerAddress == requestorAddress) {
owners[ensName] = ownerAddress;
streamRegistry.ENScreateStreamCallback(ownerAddress, ensName, streamIdPath, metadataJsonString);
} else {
emit RequestENSOwnerAndCreateStream(ensName, streamIdPath, metadataJsonString, requestorAddress);
}
emit RequestENSOwnerAndCreateStream(ensName, streamIdPath, metadataJsonString, requestorAddress);
}

function fulfillENSOwner(string calldata ensName, string calldata streamIdPath, string calldata metadataJsonString, address ownerAddress) public onlyStreamr() {
owners[ensName] = ownerAddress;
streamRegistry.ENScreateStreamCallback(ownerAddress, ensName, streamIdPath, metadataJsonString);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable-4.4.2/metatx/ERC2771ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/proxy/utils/UUPSUpgradeable.sol";
import "../chainlinkClient/ENSCache.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/proxy/utils/Initializable.sol";
import "../ENS/ENSCacheV2Streamr.sol";

contract StreamRegistry is Initializable, UUPSUpgradeable, ERC2771ContextUpgradeable, AccessControlUpgradeable {

Expand All @@ -38,7 +38,7 @@ contract StreamRegistry is Initializable, UUPSUpgradeable, ERC2771ContextUpgrade
// streamid -> keccak256(version, useraddress) -> permission struct above
mapping (string => mapping(bytes32 => Permission)) public streamIdToPermissions;
mapping (string => string) public streamIdToMetadata;
ENSCache private ensCache;
ENSCacheV2Streamr private ensCache;

// incremented when stream is (re-)created, so that users from old streams with same don't re-appear in the new stream (if they have permissions)
mapping (string => uint32) private streamIdToVersion;
Expand Down Expand Up @@ -72,7 +72,7 @@ contract StreamRegistry is Initializable, UUPSUpgradeable, ERC2771ContextUpgrade
// Constructor can't be used with upgradeable contracts, so use initialize instead
// this will not be called upon each upgrade, only once during first deployment
function initialize(address ensCacheAddr, address trustedForwarderAddress) public initializer {
ensCache = ENSCache(ensCacheAddr);
ensCache = ENSCacheV2Streamr(ensCacheAddr);
__AccessControl_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
ERC2771ContextUpgradeable.__ERC2771Context_init(trustedForwarderAddress);
Expand All @@ -89,7 +89,7 @@ contract StreamRegistry is Initializable, UUPSUpgradeable, ERC2771ContextUpgrade
}

function setEnsCache(address ensCacheAddr) public isTrusted() {
ensCache = ENSCache(ensCacheAddr);
ensCache = ENSCacheV2Streamr(ensCacheAddr);
}

function createStream(string calldata streamIdPath, string calldata metadataJsonString) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable-4.4.2/metatx/ERC2771ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/proxy/utils/UUPSUpgradeable.sol";
import "../chainlinkClient/ENSCache.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.2/proxy/utils/Initializable.sol";
import "../ENS/ENSCacheV2Streamr.sol";

contract StreamRegistryV2 is Initializable, UUPSUpgradeable, ERC2771ContextUpgradeable, AccessControlUpgradeable {

Expand All @@ -38,7 +38,7 @@ contract StreamRegistryV2 is Initializable, UUPSUpgradeable, ERC2771ContextUpgra
// streamid -> keccak256(version, useraddress) -> permission struct above
mapping (string => mapping(bytes32 => Permission)) public streamIdToPermissions;
mapping (string => string) public streamIdToMetadata;
ENSCache private ensCache;
ENSCacheV2Streamr private ensCache;

// incremented when stream is (re-)created, so that users from old streams with same don't re-appear in the new stream (if they have permissions)
mapping (string => uint32) private streamIdToVersion;
Expand Down Expand Up @@ -72,7 +72,7 @@ contract StreamRegistryV2 is Initializable, UUPSUpgradeable, ERC2771ContextUpgra
// Constructor can't be used with upgradeable contracts, so use initialize instead
// this will not be called upon each upgrade, only once during first deployment
function initialize(address ensCacheAddr, address trustedForwarderAddress) public initializer {
ensCache = ENSCache(ensCacheAddr);
ensCache = ENSCacheV2Streamr(ensCacheAddr);
__AccessControl_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
ERC2771ContextUpgradeable.__ERC2771Context_init(trustedForwarderAddress);
Expand All @@ -90,7 +90,7 @@ contract StreamRegistryV2 is Initializable, UUPSUpgradeable, ERC2771ContextUpgra
}

function setEnsCache(address ensCacheAddr) public isTrusted() {
ensCache = ENSCache(ensCacheAddr);
ensCache = ENSCacheV2Streamr(ensCacheAddr);
}

function createStream(string calldata streamIdPath, string calldata metadataJsonString) public {
Expand Down
Loading
Loading