dao-inegration #2

Merged
mico merged 22 commits from dao-inegration into main 2024-10-29 23:32:14 +00:00
6 changed files with 31 additions and 13 deletions
Showing only changes of commit 9873dfc76b - Show all commits

View File

@ -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 <you'r base mainnet 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 <you'r base mainnet rpc url>

View File

@ -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();
}
}

8
src/Constants.sol Normal file
View File

@ -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;
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {