From 870d71eb58e5002fe80516b899c6fb0a5d2e8b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 21 May 2024 15:06:03 -0300 Subject: [PATCH] chore(payments): rename payments escrow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/data-service/GraphDirectory.sol | 14 +++++++------- .../{IGraphEscrow.sol => IPaymentsEscrow.sol} | 2 +- .../PaymentsEscrow.sol} | 6 +++--- .../PaymentsEscrowStorage.sol} | 8 ++++---- .../staking/StakingBackwardsCompatibility.sol | 1 - packages/horizon/test/GraphBase.t.sol | 6 +++--- 6 files changed, 18 insertions(+), 19 deletions(-) rename packages/horizon/contracts/interfaces/{IGraphEscrow.sol => IPaymentsEscrow.sol} (98%) rename packages/horizon/contracts/{escrow/GraphEscrow.sol => payments/PaymentsEscrow.sol} (97%) rename packages/horizon/contracts/{escrow/GraphEscrowStorage.sol => payments/PaymentsEscrowStorage.sol} (72%) diff --git a/packages/horizon/contracts/data-service/GraphDirectory.sol b/packages/horizon/contracts/data-service/GraphDirectory.sol index d76bda88f..24cfa14e0 100644 --- a/packages/horizon/contracts/data-service/GraphDirectory.sol +++ b/packages/horizon/contracts/data-service/GraphDirectory.sol @@ -6,7 +6,7 @@ import { IController } from "@graphprotocol/contracts/contracts/governance/ICont import { IGraphToken } from "../interfaces/IGraphToken.sol"; import { IHorizonStaking } from "../interfaces/IHorizonStaking.sol"; import { IGraphPayments } from "../interfaces/IGraphPayments.sol"; -import { IGraphEscrow } from "../interfaces/IGraphEscrow.sol"; +import { IPaymentsEscrow } from "../interfaces/IPaymentsEscrow.sol"; import { IEpochManager } from "@graphprotocol/contracts/contracts/epochs/IEpochManager.sol"; import { IRewardsManager } from "@graphprotocol/contracts/contracts/rewards/IRewardsManager.sol"; import { ICuration } from "@graphprotocol/contracts/contracts/curation/ICuration.sol"; @@ -26,7 +26,7 @@ abstract contract GraphDirectory { IGraphToken private immutable GRAPH_TOKEN; IHorizonStaking private immutable GRAPH_STAKING; IGraphPayments private immutable GRAPH_PAYMENTS; - IGraphEscrow private immutable GRAPH_ESCROW; + IPaymentsEscrow private immutable GRAPH_ESCROW; // Legacy Graph contracts // Required for StakingBackwardCompatibility @@ -41,7 +41,7 @@ abstract contract GraphDirectory { IGraphToken graphToken, IHorizonStaking graphStaking, IGraphPayments graphPayments, - IGraphEscrow graphEscrow, + IPaymentsEscrow graphEscrow, IEpochManager graphEpochManager, IRewardsManager graphRewardsManager, ICuration graphCuration, @@ -59,7 +59,7 @@ abstract contract GraphDirectory { GRAPH_TOKEN = IGraphToken(_getContractFromController("GraphToken")); GRAPH_STAKING = IHorizonStaking(_getContractFromController("Staking")); GRAPH_PAYMENTS = IGraphPayments(_getContractFromController("GraphPayments")); - GRAPH_ESCROW = IGraphEscrow(_getContractFromController("GraphEscrow")); + GRAPH_ESCROW = IPaymentsEscrow(_getContractFromController("PaymentsEscrow")); GRAPH_EPOCH_MANAGER = IEpochManager(_getContractFromController("EpochManager")); GRAPH_REWARDS_MANAGER = IRewardsManager(_getContractFromController("RewardsManager")); GRAPH_CURATION = ICuration(_getContractFromController("Curation")); @@ -94,7 +94,7 @@ abstract contract GraphDirectory { return GRAPH_PAYMENTS; } - function _graphEscrow() internal view returns (IGraphEscrow) { + function _graphEscrow() internal view returns (IPaymentsEscrow) { return GRAPH_ESCROW; } @@ -114,8 +114,8 @@ abstract contract GraphDirectory { return GRAPH_TOKEN_GATEWAY; } - function _getContractFromController(bytes memory __contractName) private view returns (address) { - address contractAddress = GRAPH_CONTROLLER.getContractProxy(keccak256(contractName)); + function _getContractFromController(bytes memory _contractName) private view returns (address) { + address contractAddress = GRAPH_CONTROLLER.getContractProxy(keccak256(_contractName)); if (contractAddress == address(0)) { revert GraphDirectoryInvalidZeroAddress(); } diff --git a/packages/horizon/contracts/interfaces/IGraphEscrow.sol b/packages/horizon/contracts/interfaces/IPaymentsEscrow.sol similarity index 98% rename from packages/horizon/contracts/interfaces/IGraphEscrow.sol rename to packages/horizon/contracts/interfaces/IPaymentsEscrow.sol index 9b638a87e..73acc6592 100644 --- a/packages/horizon/contracts/interfaces/IGraphEscrow.sol +++ b/packages/horizon/contracts/interfaces/IPaymentsEscrow.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.24; import { IGraphPayments } from "./IGraphPayments.sol"; -interface IGraphEscrow { +interface IPaymentsEscrow { struct EscrowAccount { uint256 balance; // Total escrow balance for a sender-receiver pair uint256 amountThawing; // Amount of escrow currently being thawed diff --git a/packages/horizon/contracts/escrow/GraphEscrow.sol b/packages/horizon/contracts/payments/PaymentsEscrow.sol similarity index 97% rename from packages/horizon/contracts/escrow/GraphEscrow.sol rename to packages/horizon/contracts/payments/PaymentsEscrow.sol index e6d021425..7b324606c 100644 --- a/packages/horizon/contracts/escrow/GraphEscrow.sol +++ b/packages/horizon/contracts/payments/PaymentsEscrow.sol @@ -2,15 +2,15 @@ pragma solidity ^0.8.24; import { IGraphToken } from "../interfaces/IGraphToken.sol"; -import { IGraphEscrow } from "../interfaces/IGraphEscrow.sol"; import { IGraphPayments } from "../interfaces/IGraphPayments.sol"; +import { IPaymentsEscrow } from "../interfaces/IPaymentsEscrow.sol"; import { TokenUtils } from "../libraries/TokenUtils.sol"; import { GraphDirectory } from "../data-service/GraphDirectory.sol"; -import { GraphEscrowStorageV1Storage } from "./GraphEscrowStorage.sol"; +import { PaymentsEscrowV1Storage } from "./PaymentsEscrowStorage.sol"; -contract GraphEscrow is IGraphEscrow, GraphEscrowStorageV1Storage, GraphDirectory { +contract PaymentsEscrow is IPaymentsEscrow, PaymentsEscrowV1Storage, GraphDirectory { using TokenUtils for IGraphToken; // -- Events -- diff --git a/packages/horizon/contracts/escrow/GraphEscrowStorage.sol b/packages/horizon/contracts/payments/PaymentsEscrowStorage.sol similarity index 72% rename from packages/horizon/contracts/escrow/GraphEscrowStorage.sol rename to packages/horizon/contracts/payments/PaymentsEscrowStorage.sol index 89a49e756..2607ab801 100644 --- a/packages/horizon/contracts/escrow/GraphEscrowStorage.sol +++ b/packages/horizon/contracts/payments/PaymentsEscrowStorage.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.24; -import { IGraphEscrow } from "../interfaces/IGraphEscrow.sol"; +import { IPaymentsEscrow } from "../interfaces/IPaymentsEscrow.sol"; -contract GraphEscrowStorageV1Storage { +contract PaymentsEscrowV1Storage { // Authorized collectors - mapping(address sender => mapping(address dataService => IGraphEscrow.Collector collector)) + mapping(address sender => mapping(address dataService => IPaymentsEscrow.Collector collector)) public authorizedCollectors; // Stores how much escrow each sender has deposited for each receiver, as well as thawing information - mapping(address sender => mapping(address receiver => IGraphEscrow.EscrowAccount escrowAccount)) + mapping(address sender => mapping(address receiver => IPaymentsEscrow.EscrowAccount escrowAccount)) public escrowAccounts; // The maximum thawing period (in seconds) for both escrow withdrawal and signer revocation diff --git a/packages/horizon/contracts/staking/StakingBackwardsCompatibility.sol b/packages/horizon/contracts/staking/StakingBackwardsCompatibility.sol index 30a667b77..a570242f4 100644 --- a/packages/horizon/contracts/staking/StakingBackwardsCompatibility.sol +++ b/packages/horizon/contracts/staking/StakingBackwardsCompatibility.sol @@ -97,7 +97,6 @@ abstract contract StakingBackwardsCompatibility is Managed, HorizonStakingV1Stor { // -- Pull tokens from the sender -- - IGraphToken graphToken = _graphToken(); _graphToken().pullTokens(msg.sender, queryFees); // -- Collect protocol tax -- diff --git a/packages/horizon/test/GraphBase.t.sol b/packages/horizon/test/GraphBase.t.sol index 28fa8f2c8..36721ed2c 100644 --- a/packages/horizon/test/GraphBase.t.sol +++ b/packages/horizon/test/GraphBase.t.sol @@ -5,7 +5,7 @@ import "forge-std/Test.sol"; import { Controller } from "@graphprotocol/contracts/contracts/governance/Controller.sol"; -import { GraphEscrow } from "contracts/escrow/GraphEscrow.sol"; +import { PaymentsEscrow } from "contracts/payments/PaymentsEscrow.sol"; import { GraphPayments } from "contracts/payments/GraphPayments.sol"; import { IHorizonStaking } from "contracts/interfaces/IHorizonStaking.sol"; import { HorizonStaking } from "contracts/staking/HorizonStaking.sol"; @@ -21,7 +21,7 @@ abstract contract GraphBaseTest is Test, Constants { Controller public controller; MockGRTToken public token; GraphPayments public payments; - GraphEscrow public escrow; + PaymentsEscrow public escrow; IHorizonStaking public staking; HorizonStaking private stakingBase; @@ -139,7 +139,7 @@ abstract contract GraphBaseTest is Test, Constants { address(controller), protocolPaymentCut ); - escrow = new GraphEscrow{salt: saltEscrow}( + escrow = new PaymentsEscrow{salt: saltEscrow}( address(controller), revokeCollectorThawingPeriod, withdrawEscrowThawingPeriod