diff --git a/README.md b/README.md index 7f86c36..ead054e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ Idle game & shitcoin advanture dedicated to cohort VII of Raid Guild. ## Set up for local DEV -### 1. Run `anvil` to setup local RPC +### 1. Run `anvil` to setup local RPC as a fork of base mainnet +anvil --rpc-url ### 2. Deploy contract @@ -14,14 +15,14 @@ Either use `./deploy_contract.sh` script (!! change contract values and set priv Move to `app` dir, install deps via `npm install` and run `npm run dev` to start the dev server. -#### 3. 1. Run `cast rpc anvil_mine` +#### 3. 1. Point Metamask to Anvil network for local dev -This is so time gets set on the local chain, otherwise you will start at 0 time and first mint will give you bajillion GELD. - -#### 3. 2. Point Metamask to Anvil network for local dev - -#### 3. 3. Change `app/contract_address.ts` to match your program address if needed +#### 3. 2. Change `app/contract_address.ts` to match your program address if needed ### 4. Local development requires mining blocks by hand Call `cast rpc anvil_mine` to mine next block, otherwise it wont ever progress and time "stands still" as far as the game is concerned + + +### 5. Fork tests +forge test --rpc-url diff --git a/script/RaidGeld.s.sol b/script/RaidGeld.s.sol index ea5f87c..851b83d 100644 --- a/script/RaidGeld.s.sol +++ b/script/RaidGeld.s.sol @@ -4,14 +4,16 @@ pragma solidity ^0.8.13; import {Script, console} from "forge-std/Script.sol"; import {RaidGeld} from "../src/RaidGeld.sol"; -contract RaidGeldScript is Script { +import {Constants} from "../src/Constants.sol"; + +contract RaidGeldScript is Script, Constants { RaidGeld public raidgeld; function setUp() public {} function run() public { vm.startBroadcast(); - raidgeld = new RaidGeld(); + raidgeld = new RaidGeld(DAO_TOKEN, POOL); vm.stopBroadcast(); } } diff --git a/src/Constants.sol b/src/Constants.sol new file mode 100644 index 0000000..b31ade5 --- /dev/null +++ b/src/Constants.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +contract Constants { + //base addresses + address public constant DAO_TOKEN = 0x11dC980faf34A1D082Ae8A6a883db3A950a3c6E8; + address public constant POOL = 0x27004f6d0c1bB7979367D32Ba9d6DF6d61A18926; +} \ No newline at end of file diff --git a/src/RaidGeld.sol b/src/RaidGeld.sol index 52c96a4..30e6350 100644 --- a/src/RaidGeld.sol +++ b/src/RaidGeld.sol @@ -16,13 +16,19 @@ contract RaidGeld is ERC20, Ownable { mapping(address => Player) private players; mapping(address => Army) private armies; + ERC20 public daoToken; + address public pool; + // Modifier for functions that should only be available to registered players modifier onlyPlayer() { require(players[msg.sender].created_at != 0, "Not an initiated player"); _; } - constructor() ERC20("Raid Geld", "GELD") Ownable(msg.sender) {} + constructor(address _daoToken, address _pool) ERC20("Raid Geld", "GELD") Ownable(msg.sender) { + daoToken = ERC20(_daoToken); + pool = _pool; + } // This effectively registers the user function register() external payable { diff --git a/test/RaidGeld.t.sol b/test/RaidGeld.t.sol index 375fb31..8a00a7b 100644 --- a/test/RaidGeld.t.sol +++ b/test/RaidGeld.t.sol @@ -4,8 +4,9 @@ pragma solidity ^0.8.13; import {Test, console} from "forge-std/Test.sol"; import {RaidGeld, Army, Player} from "../src/RaidGeld.sol"; import "../src/RaidGeldUtils.sol"; +import {Constants} from "../src/Constants.sol"; -contract raid_geldTest is Test { +contract raid_geldTest is Test, Constants { RaidGeld public raid_geld; address public player1; address public player2; @@ -17,7 +18,7 @@ contract raid_geldTest is Test { vm.deal(owner, 10 ether); vm.deal(player1, 10 ether); vm.prank(owner); - raid_geld = new RaidGeld(); + raid_geld = new RaidGeld(DAO_TOKEN, POOL); } function registerPlayer() private { diff --git a/test/RaidGeldUtils.t.sol b/test/RaidGeldUtils.t.sol index 8de1385..c6b5b24 100644 --- a/test/RaidGeldUtils.t.sol +++ b/test/RaidGeldUtils.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.13; import {Test, console} from "forge-std/Test.sol"; -import {Army, Raider} from "../src/RaidGeld.sol"; +import {Army, Raider} from "../src/RaidGeldStructs.sol"; import "../src/RaidGeldUtils.sol"; contract raid_geldTest is Test {