2024-03-30 14:34:09 +03:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.6.12;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
2024-03-30 23:35:10 +03:00
|
|
|
interface IENSRegistry {
|
2024-03-30 14:34:09 +03:00
|
|
|
// Logged when the owner of a node assigns a new owner to a subnode.
|
|
|
|
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
|
|
|
|
|
|
|
|
// Logged when the owner of a node transfers ownership to a new account.
|
|
|
|
event Transfer(bytes32 indexed node, address owner);
|
|
|
|
|
|
|
|
// Logged when the resolver for a node changes.
|
|
|
|
event NewResolver(bytes32 indexed node, address resolver);
|
|
|
|
|
|
|
|
// Logged when the TTL of a node changes
|
|
|
|
event NewTTL(bytes32 indexed node, uint64 ttl);
|
|
|
|
|
|
|
|
// Logged when an operator is added or removed.
|
|
|
|
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
|
|
|
|
|
|
|
|
function setRecord(
|
|
|
|
bytes32 node,
|
|
|
|
address owner,
|
|
|
|
address resolver,
|
|
|
|
uint64 ttl
|
|
|
|
) external;
|
|
|
|
|
|
|
|
function setSubnodeRecord(
|
|
|
|
bytes32 node,
|
|
|
|
bytes32 label,
|
|
|
|
address owner,
|
|
|
|
address resolver,
|
|
|
|
uint64 ttl
|
|
|
|
) external;
|
|
|
|
|
|
|
|
function setSubnodeOwner(
|
|
|
|
bytes32 node,
|
|
|
|
bytes32 label,
|
|
|
|
address owner
|
|
|
|
) external returns (bytes32);
|
|
|
|
|
|
|
|
function setResolver(bytes32 node, address resolver) external;
|
|
|
|
|
|
|
|
function setOwner(bytes32 node, address owner) external;
|
|
|
|
|
|
|
|
function setTTL(bytes32 node, uint64 ttl) external;
|
|
|
|
|
|
|
|
function setApprovalForAll(address operator, bool approved) external;
|
|
|
|
|
|
|
|
function owner(bytes32 node) external view returns (address);
|
|
|
|
|
|
|
|
function resolver(bytes32 node) external view returns (address);
|
|
|
|
|
|
|
|
function ttl(bytes32 node) external view returns (uint64);
|
|
|
|
|
|
|
|
function recordExists(bytes32 node) external view returns (bool);
|
|
|
|
|
|
|
|
function isApprovedForAll(address owner, address operator) external view returns (bool);
|
|
|
|
}
|
|
|
|
|
2024-03-30 23:35:10 +03:00
|
|
|
interface IENSResolver {
|
2024-03-30 14:34:09 +03:00
|
|
|
function addr(bytes32 node) external view returns (address);
|
|
|
|
|
|
|
|
function text(bytes32 node, string calldata key) external view returns (string memory);
|
|
|
|
}
|
|
|
|
|
2024-03-30 23:35:10 +03:00
|
|
|
interface IRelayerRegistry {
|
2024-03-30 14:34:09 +03:00
|
|
|
function getRelayerBalance(address relayer) external view returns (uint256);
|
|
|
|
|
|
|
|
function isRelayerRegistered(address relayer, address toResolve) external view returns (bool);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Relayer {
|
|
|
|
address owner;
|
|
|
|
uint256 balance;
|
|
|
|
bool isRegistered;
|
|
|
|
string[20] records;
|
|
|
|
}
|
|
|
|
|
|
|
|
contract RelayerAggregator {
|
2024-03-30 23:35:10 +03:00
|
|
|
IENSRegistry public immutable ENSRegistry;
|
|
|
|
IRelayerRegistry public immutable RelayerRegistry;
|
2024-03-30 14:34:09 +03:00
|
|
|
|
2024-03-30 23:35:10 +03:00
|
|
|
constructor(address _IENSRegistry, address _IRelayerRegistry) public {
|
|
|
|
ENSRegistry = IENSRegistry(_IENSRegistry);
|
|
|
|
RelayerRegistry = IRelayerRegistry(_IRelayerRegistry);
|
2024-03-30 14:34:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function relayersData(bytes32[] memory _relayers, string[] memory _subdomains) public view returns (Relayer[] memory) {
|
|
|
|
Relayer[] memory relayers = new Relayer[](_relayers.length);
|
|
|
|
|
|
|
|
for (uint256 i = 0; i < _relayers.length; i++) {
|
2024-03-30 23:35:10 +03:00
|
|
|
relayers[i].owner = ENSRegistry.owner(_relayers[i]);
|
|
|
|
IENSResolver resolver = IENSResolver(ENSRegistry.resolver(_relayers[i]));
|
2024-03-30 14:34:09 +03:00
|
|
|
|
|
|
|
for (uint256 j = 0; j < _subdomains.length; j++) {
|
|
|
|
bytes32 subdomainHash = keccak256(abi.encodePacked(_relayers[i], keccak256(abi.encodePacked(_subdomains[j]))));
|
|
|
|
relayers[i].records[j] = resolver.text(subdomainHash, "url");
|
|
|
|
}
|
|
|
|
|
2024-03-30 23:35:10 +03:00
|
|
|
relayers[i].isRegistered = RelayerRegistry.isRelayerRegistered(relayers[i].owner, relayers[i].owner);
|
|
|
|
relayers[i].balance = RelayerRegistry.getRelayerBalance(relayers[i].owner);
|
2024-03-30 14:34:09 +03:00
|
|
|
}
|
|
|
|
return relayers;
|
|
|
|
}
|
|
|
|
}
|