Skip to content

Commit

Permalink
feat: upgrade existing tokens (experimental)
Browse files Browse the repository at this point in the history
  • Loading branch information
xtools-at committed Mar 4, 2024
1 parent 3c6e22b commit 69d0a7c
Show file tree
Hide file tree
Showing 5 changed files with 484 additions and 4 deletions.
8 changes: 7 additions & 1 deletion contracts/contracts-upgradable/examples/AvaxOFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

pragma solidity ^0.8.18;

import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import "../token/oft/v2/fee/OFTWithFeeUpgradeable.sol";
import "../token/oft/v2/fee/NativeOFTWithFeeUpgradeable.sol";

contract AvaxOFT is OFTWithFeeUpgradeable {}
contract AvaxOFTv1 is OFTWithFeeUpgradeable {}

contract AvaxNativeOFT is NativeOFTWithFeeUpgradeable {}

/// @custom:oz-upgrades-from AvaxOFTv1
contract AvaxOFT is AvaxOFTv1, ERC20PermitUpgradeable {

}
10 changes: 9 additions & 1 deletion contracts/contracts-upgradable/examples/UsdcOFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

pragma solidity ^0.8.18;

import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import "../token/oft/v2/fee/OFTWithFeeUpgradeable.sol";
import "../token/oft/v2/fee/ProxyOFTWithFeeUpgradeable.sol";

contract UsdcOFT is OFTWithFeeUpgradeable {
contract UsdcOFTv1 is OFTWithFeeUpgradeable {
function decimals() public view virtual override returns (uint8) {
return 6;
}
}

contract UsdcProxyOFT is ProxyOFTWithFeeUpgradeable {}

/// @custom:oz-upgrades-from UsdcOFTv1
contract UsdcOFT is UsdcOFTv1, ERC20PermitUpgradeable {
function decimals() public view virtual override(UsdcOFTv1, ERC20Upgradeable) returns (uint8) {
return 6;
}
}
7 changes: 7 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ module.exports = {
},
},
],
settings: {
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},

contractSizer: {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"test": "npx hardhat test --parallel",
"prettier": "prettier --write test/**/*.js && prettier --write test/*/*/*.js && prettier --write deploy/*.js && prettier --write tasks/*.js && prettier --write contracts/**/*.sol && prettier --write contracts/**/**/*.sol && prettier --write contracts/**/**/**/*.sol",
"lint": "yarn prettier && solhint 'contracts/*.sol' && solhint 'contracts/**/*.sol' && solhint 'contracts/**/**/*.sol' && solhint 'contracts/**/**/**/*.sol'",
"compile": "npx hardhat compile"
"compile": "npx hardhat compile",
"clean": "npx hardhat clean",
"validate": "npx @openzeppelin/upgrades-core validate"
},
"engines": {
"node": "==18"
Expand All @@ -38,6 +40,7 @@
"@nomiclabs/hardhat-ethers": "^2.0.3",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/upgrades-core": "^1.32.5",
"chai": "^4.3.4",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
Expand Down
Loading

0 comments on commit 69d0a7c

Please sign in to comment.