From ecd97671e2cf33c0f6b995840b88351648b2b634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 18 Mar 2024 10:37:10 -0300 Subject: [PATCH] chore(subgraph-service): more boilerplate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/staking/IHorizonStaking.sol | 24 +++++--------- packages/subgraph-service/contracts/Lock.sol | 31 ------------------- .../contracts/SubgraphService.sol | 8 +++++ packages/subgraph-service/eslint.config.js | 2 +- packages/subgraph-service/hardhat.config.ts | 2 +- packages/subgraph-service/package.json | 1 + yarn.lock | 21 +------------ 7 files changed, 20 insertions(+), 69 deletions(-) delete mode 100644 packages/subgraph-service/contracts/Lock.sol create mode 100644 packages/subgraph-service/contracts/SubgraphService.sol diff --git a/packages/contracts/contracts/staking/IHorizonStaking.sol b/packages/contracts/contracts/staking/IHorizonStaking.sol index 51cb03c33..2de5c1f28 100644 --- a/packages/contracts/contracts/staking/IHorizonStaking.sol +++ b/packages/contracts/contracts/staking/IHorizonStaking.sol @@ -1,8 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.7.6; +pragma solidity >=0.7.6 <0.9.0; pragma abicoder v2; +interface Test { + function test() external; +} + interface IHorizonStaking { struct Provision { // Service provider that created the provision @@ -93,12 +97,7 @@ interface IHorizonStaking { function stake(uint256 tokens) external; // create a provision - function provision( - uint256 tokens, - address verifier, - uint256 maxVerifierCut, - uint256 thawingPeriod - ) external; + function provision(uint256 tokens, address verifier, uint256 maxVerifierCut, uint256 thawingPeriod) external; // initiate a thawing to remove tokens from a provision function thaw(bytes32 provisionId, uint256 tokens) external returns (bytes32 thawRequestId); @@ -123,11 +122,7 @@ interface IHorizonStaking { ) external returns (bytes32 thawRequestId); // slash a service provider - function slash( - bytes32 provisionId, - uint256 tokens, - uint256 verifierAmount - ) external; + function slash(bytes32 provisionId, uint256 tokens, uint256 verifierAmount) external; // set the Service Provider's preferred provisions to be force thawed function setForceThawProvisions(bytes32[] calldata provisions) external; @@ -148,10 +143,7 @@ interface IHorizonStaking { // `Provision.tokens - Provision.tokensThawing` function getTokensAvailable(bytes32 provision) external view returns (uint256 tokens); - function getServiceProvider(address serviceProvider) - external - view - returns (ServiceProvider memory); + function getServiceProvider(address serviceProvider) external view returns (ServiceProvider memory); function getProvision(bytes32 provision) external view returns (Provision memory); } diff --git a/packages/subgraph-service/contracts/Lock.sol b/packages/subgraph-service/contracts/Lock.sol deleted file mode 100644 index cd5b72627..000000000 --- a/packages/subgraph-service/contracts/Lock.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; - -// Uncomment this line to use console.log -// import "hardhat/console.sol"; - -contract Lock { - uint256 public unlockTime; - address payable public owner; - - event Withdrawal(uint256 amount, uint256 when); - - constructor(uint256 _unlockTime) payable { - require(block.timestamp < _unlockTime, "Unlock time should be in the future"); - - unlockTime = _unlockTime; - owner = payable(msg.sender); - } - - function withdraw() public { - // Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal - // console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); - - require(block.timestamp >= unlockTime, "You can't withdraw yet"); - require(msg.sender == owner, "You aren't the owner"); - - emit Withdrawal(address(this).balance, block.timestamp); - - owner.transfer(address(this).balance); - } -} diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol new file mode 100644 index 000000000..e4ed1d233 --- /dev/null +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.4.0 <0.9.0; + +import { Test } from "@graphprotocol/contracts/contracts/staking/IHorizonStaking.sol"; + +contract SimpleTest is Test { + function test() external {} +} \ No newline at end of file diff --git a/packages/subgraph-service/eslint.config.js b/packages/subgraph-service/eslint.config.js index db3d69955..3b94cc88d 100644 --- a/packages/subgraph-service/eslint.config.js +++ b/packages/subgraph-service/eslint.config.js @@ -5,7 +5,7 @@ const eslintGraphConfig = require('eslint-graph-config') module.exports = [ - ...eslintGraphConfig, + ...eslintGraphConfig.default, { ignores: ['typechain-types/*'], }, diff --git a/packages/subgraph-service/hardhat.config.ts b/packages/subgraph-service/hardhat.config.ts index ac596d0aa..b473a1a23 100644 --- a/packages/subgraph-service/hardhat.config.ts +++ b/packages/subgraph-service/hardhat.config.ts @@ -3,7 +3,7 @@ import '@nomicfoundation/hardhat-toolbox' import { HardhatUserConfig } from 'hardhat/config' const config: HardhatUserConfig = { - solidity: '0.8.24', + solidity: '0.8.25', paths: { artifacts: './build/contracts', }, diff --git a/packages/subgraph-service/package.json b/packages/subgraph-service/package.json index a1d19376e..cd96bd737 100644 --- a/packages/subgraph-service/package.json +++ b/packages/subgraph-service/package.json @@ -12,6 +12,7 @@ "build": "hardhat compile" }, "devDependencies": { + "@graphprotocol/contracts": "workspace:^7.0.0", "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", "@nomicfoundation/hardhat-ethers": "^3.0.0", "@nomicfoundation/hardhat-foundry": "^1.1.1", diff --git a/yarn.lock b/yarn.lock index 652e12465..0fac61a17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2749,6 +2749,7 @@ __metadata: version: 0.0.0-use.local resolution: "@graphprotocol/subgraph-service@workspace:packages/subgraph-service" dependencies: + "@graphprotocol/contracts": "workspace:^7.0.0" "@nomicfoundation/hardhat-chai-matchers": "npm:^2.0.0" "@nomicfoundation/hardhat-ethers": "npm:^3.0.0" "@nomicfoundation/hardhat-foundry": "npm:^1.1.1" @@ -22154,16 +22155,6 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^4.0.2": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 5f6cad2e728a8a063521328e612d7876e12f0d8a8390d3b3aaa452a6a65e24e9ac8ea22beb72a924fd96ea0a49ea63bb4e251fb922b12eedfb7f7a26475e5c56 - languageName: node - linkType: hard - "typescript@npm:^5.0.4, typescript@npm:^5.1.6, typescript@npm:^5.3.3": version: 5.3.3 resolution: "typescript@npm:5.3.3" @@ -22184,16 +22175,6 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^4.0.2#optional!builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#optional!builtin::version=4.9.5&hash=289587" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 583ff68cafb0c076695f72d61df6feee71689568179fb0d3a4834dac343df6b6ed7cf7b6f6c801fa52d43cd1d324e2f2d8ae4497b09f9e6cfe3d80a6d6c9ca52 - languageName: node - linkType: hard - "typescript@patch:typescript@npm%3A^5.0.4#optional!builtin, typescript@patch:typescript@npm%3A^5.1.6#optional!builtin, typescript@patch:typescript@npm%3A^5.3.3#optional!builtin": version: 5.3.3 resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7"