1
0
forked from mico/idle_moloch

fix errors with upgradeable contracts

This commit is contained in:
san 2024-10-29 00:28:30 +05:30
parent 20b81db5e7
commit 5255856727
4 changed files with 15 additions and 8 deletions

3
.gitmodules vendored
View File

@ -4,9 +4,6 @@
[submodule "lib/openzeppelin-contracts"] [submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib\\openzeppelin-foundry-upgrades"] [submodule "lib\\openzeppelin-foundry-upgrades"]
path = lib\\openzeppelin-foundry-upgrades path = lib\\openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades

View File

@ -15,7 +15,7 @@ contract RaidGeldScript is Script {
address _proxyAddress = Upgrades.deployTransparentProxy( address _proxyAddress = Upgrades.deployTransparentProxy(
"RaidGeld.sol", "RaidGeld.sol",
msg.sender, msg.sender,
abi.encodeCall(RaidGeld.initialize, (msg.sender)) abi.encodeCall(RaidGeld.initialize, ())
); );
// Get the implementation address // Get the implementation address
@ -24,7 +24,5 @@ contract RaidGeldScript is Script {
); );
vm.stopBroadcast(); vm.stopBroadcast();
return (implementationAddress, _proxyAddress);
} }
} }

View File

@ -24,7 +24,7 @@ contract RaidGeld is Initializable, ERC20Upgradeable, OwnableUpgradeable {
function initialize() public initializer { function initialize() public initializer {
__ERC20_init("Raid Geld", "GELD"); __ERC20_init("Raid Geld", "GELD");
__Ownable_init(); __Ownable_init(msg.sender);
} }
// This effectively registers the user // This effectively registers the user

View File

@ -2,11 +2,14 @@
pragma solidity ^0.8.13; pragma solidity ^0.8.13;
import {Test, console} from "forge-std/Test.sol"; import {Test, console} from "forge-std/Test.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {RaidGeld, Army, Player} from "../src/RaidGeld.sol"; import {RaidGeld, Army, Player} from "../src/RaidGeld.sol";
import "../src/RaidGeldUtils.sol"; import "../src/RaidGeldUtils.sol";
contract raid_geldTest is Test { contract raid_geldTest is Test {
RaidGeld public raid_geld; RaidGeld public raid_geld;
address implementationAddress;
address payable proxyAddress;
address public player1; address public player1;
address public player2; address public player2;
address public owner; address public owner;
@ -17,7 +20,16 @@ contract raid_geldTest is Test {
vm.deal(owner, 10 ether); vm.deal(owner, 10 ether);
vm.deal(player1, 10 ether); vm.deal(player1, 10 ether);
vm.prank(owner); vm.prank(owner);
raid_geld = new RaidGeld();
// Deploy the upgradeable contract
address _proxyAddress = Upgrades.deployTransparentProxy(
"RaidGeld.sol",
msg.sender,
abi.encodeCall(RaidGeld.initialize, ())
);
proxyAddress = payable(_proxyAddress);
raid_geld = RaidGeld(proxyAddress);
} }
function registerPlayer() private { function registerPlayer() private {