Skip to content

Commit

Permalink
chore(PTokenV2): remove ERC777 & others deps entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
gitmp01 committed Aug 15, 2024
1 parent c665d8b commit a3c0c9c
Show file tree
Hide file tree
Showing 31 changed files with 1,353 additions and 684 deletions.
2 changes: 1 addition & 1 deletion solidity/forge-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

ls lib/ | \
xargs -I % bash -c \
'cat ./lib/%/package.json | jq -r "@text \"\(.name)@\(.version)\""'
'cat ./lib/%/package.json' | jq -r '.version as $version | .repository.url|scan("([a-z-]+.git)") | @text "\(.[0])@\($version)"'
9 changes: 6 additions & 3 deletions solidity/forge-dependencies.txt
8 changes: 6 additions & 2 deletions solidity/hardhat.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('@openzeppelin/hardhat-upgrades')
require('@nomicfoundation/hardhat-toolbox')
require('@nomicfoundation/hardhat-foundry')
require('@nomicfoundation/hardhat-network-helpers')
require('hardhat-storage-layout')
require('hardhat-gas-reporter')
require('solidity-coverage')
require('hardhat-tracer')
Expand Down Expand Up @@ -32,7 +33,10 @@ module.exports = {
},
},
},
{ version: '0.8.25' },
{
version: '0.8.25',
settings: { evmVersion: 'cancun' },
},
],
},
paths: {
Expand All @@ -52,7 +56,7 @@ module.exports = {
},
},
ethFork: {
url: getEnvironmentVariable('ETH_RPC_URL'),
url: getEnvironmentVariable('MAINNET_RPC_URL'),
},
bscFork: {
url: getEnvironmentVariable('BSC_RPC_URL'),
Expand Down
2 changes: 1 addition & 1 deletion solidity/lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion solidity/lib/openzeppelin-contracts-upgradeable
2 changes: 1 addition & 1 deletion solidity/lib/solidity-bytes-utils
1 change: 1 addition & 0 deletions solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"ethers": "^6.13.1",
"hardhat": "^2.22.6",
"hardhat-gas-reporter": "^2.2.0",
"hardhat-storage-layout": "^0.1.7",
"hardhat-tracer": "^3.0.1",
"ramda": "^0.30.1",
"solhint": "^5.0.2",
Expand Down
1 change: 1 addition & 0 deletions solidity/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
forge-std/=lib/forge-std/src/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts
@openzeppelin/contracts-upgradeable-v3.4.2/=lib/openzeppelin-contracts-upgradeable-v3.4.2/contracts
solidity-bytes-utils/contracts=lib/solidity-bytes-utils/contracts
1 change: 1 addition & 0 deletions solidity/src/Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IPAM} from "./interfaces/IPAM.sol";
import {IPAM} from "./interfaces/IPAM.sol";
import {IXERC20} from "./interfaces/IXERC20.sol";
import {IPTokenV2} from "./interfaces/IPTokenV2.sol";
import {IAdapter} from "./interfaces/IAdapter.sol";
import {IPReceiver} from "./interfaces/IPReceiver.sol";
import {IFeesManager} from "./interfaces/IFeesManager.sol";
Expand Down
12 changes: 12 additions & 0 deletions solidity/src/interfaces/IOwnable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IOwnable {
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
function owner() external returns (address);
function renounceOwnership() external;
function transferOwnership(address newOwner) external;
}
41 changes: 41 additions & 0 deletions solidity/src/interfaces/IPTokenV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4 <0.9.0;

interface IPTokenV2 {
/**
* @notice Returns if this token is local or not
*/
function isLocal() external returns (bool);

/**
* @notice Returns the fees manager address
*/
function getLockbox() external returns (address);

/**
* @notice Returns the PAM address
*
* @param adapter the relative adapter
*/
function getPAM(address adapter) external returns (address);

/**
* @notice Returns the fees manager address
*/
function getFeesManager() external returns (address);

/**
* @notice Set the fees manager address
* @param newAddress new fees manager address
*/
function setFeesManager(address newAddress) external;

/**
* @notice Set the new PAM address
* @dev Be sure the API called by the adapter is respected
*
* @param adapterAddress the adapter address
* @param pamAddress the new PAM address
*/
function setPAM(address adapterAddress, address pamAddress) external;
}
36 changes: 4 additions & 32 deletions solidity/src/interfaces/IXERC20.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;

interface IXERC20 {
import {IPTokenV2} from "../interfaces/IPTokenV2.sol";

interface IXERC20 is IPTokenV2 {
/**
* @notice Emits when a lockbox is set
*
Expand Down Expand Up @@ -55,7 +57,6 @@ interface IXERC20 {
* @param maxLimit The max limit of the bridge
* @param currentLimit The current limit of the bridge
*/
// solhint-disable-next-line
struct BridgeParameters {
uint256 timestamp;
uint256 ratePerSecond;
Expand Down Expand Up @@ -144,33 +145,4 @@ interface IXERC20 {
*/

function burn(address _user, uint256 _amount) external;

// TODO: for clarity, move everything below to an interface IPTokenv2
/**
* @notice Returns the fees manager address
*/
function getLockbox() external returns (address);

/**
* @notice Returns the PAM address
*
* @param adapter the relative adapter
*/
function getPAM(address adapter) external returns (address);

/**
* @notice Returns if this token is local or not
*/
function isLocal() external returns (bool);

/**
* @notice Returns the fees manager address
*/
function getFeesManager() external returns (address);

/**
* @notice Set the fees manager address
* @param newAddress new fees manager address
*/
function setFeesManager(address newAddress) external;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.6.2;

import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/GSN/GSNRecipientUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/GSN/GSNRecipientUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/access/OwnableUpgradeable.sol";
import "./ERC777Upgradeable.sol";

contract ERC777GSNUpgradeable is
Expand Down
18 changes: 9 additions & 9 deletions solidity/src/ptoken-v1/ERC777Upgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

pragma solidity >=0.6.0 <0.8.0;

import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC777/IERC777Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC777/IERC777RecipientUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC777/IERC777SenderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/introspection/IERC1820RegistryUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/token/ERC777/IERC777Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/token/ERC777/IERC777RecipientUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/token/ERC777/IERC777SenderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/introspection/IERC1820RegistryUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/proxy/Initializable.sol";

/**
* @dev Implementation of the {IERC777} interface.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.6.2;

import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/proxy/Initializable.sol";
import "./ERC777Upgradeable.sol";

contract ERC777WithAdminOperatorUpgradeable is
Expand Down
6 changes: 3 additions & 3 deletions solidity/src/ptoken-v1/PToken.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;

import "./ERC777GSN.sol";
import "./ERC777GSNUpgradeable.sol";
import "./ERC777WithAdminOperatorUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/access/AccessControlUpgradeable.sol";

contract PToken is
Initializable,
Expand Down
4 changes: 2 additions & 2 deletions solidity/src/ptoken-v1/PTokenNoGSN.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity ^0.6.2;

import "./ERC777WithAdminOperatorUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable-v3.4.2/access/AccessControlUpgradeable.sol";

/**
* @dev Note: Unfortunately we can't just refactor the original pToken to inherit most of this
Expand Down
107 changes: 0 additions & 107 deletions solidity/src/ptoken-v2/IFeesManager-solc-0.6.sol

This file was deleted.

Loading

0 comments on commit a3c0c9c

Please sign in to comment.