Skip to content

Commit

Permalink
fixed some dependancy error in contract, still problems with helperco…
Browse files Browse the repository at this point in the history
…nfig functionality to deploy both locally and to a testnet, most likely need to start by making two independant repos with one having the hardcoded ability to deploy locally, and another one with the hardcoded ability to deploy to a testnet. Then after we see proof of life we can look for a more streamlined version.
  • Loading branch information
WillStansill committed Jan 23, 2025
1 parent abc8c06 commit eaa1e3e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/solidity-stringutils"]
path = lib/solidity-stringutils
url = https://github.com/Arachnid/solidity-stringutils
18 changes: 8 additions & 10 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
src = "src"
out = "out"
libs = ["lib"]

# Add remappings to resolve imports correctly
remappings = [
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"forge-std/=lib/forge-std/src/"
'@openzeppelin-contracts/=lib/openzeppelin-contracts/',
'@forge-std/=lib/forge-std/src/'
]

# Include settings to optimize Foundry workflows
[default]
evm_version = "paris" # Set to the desired EVM version (e.g., istanbul, london, paris)
optimizer = true
optimizer_runs = 200
ffi = true # Enable ffi if your tests/scripts require external calls
# [etherscan]
# mainnet = { key = "${ETHERSCAN_API_KEY}" }
# sepolia = {key = "${ETHERSCAN_API_KEY}"}

# [rpc_endpoints]
# sepolia = "${SEPOLIA_RPC_URL}"
1 change: 1 addition & 0 deletions lib/solidity-stringutils
Submodule solidity-stringutils added at 4b2fcc
55 changes: 53 additions & 2 deletions script/Tokens/FYRE/DeployFYREToken.s.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Script} from "forge-std/Script.sol";
import {Script} from "lib/forge-std/src/Script.sol";
import {FYREToken} from "src/Tokens/FYREToken.sol";
import {console} from "forge-std/console.sol";
import {console} from "lib/forge-std/src/console.sol";
import {HelperConfig} from "script/HelperConfig.s.sol";
import {strings} from "lib/solidity-stringutils/strings.sol";

using strings for string;
using strings for strings.slice;

contract DeployFyreToken is Script {
FYREToken public fyreToken;
Expand All @@ -26,5 +30,52 @@ contract DeployFyreToken is Script {

vm.stopBroadcast();
console.log("Deployed FYREToken at:", address(fyreToken));

// Write the deployed address to the .env file
string memory envFilePath = ".env";
string memory key = "ANVIL_FYRE_TOKEN_ADDRESS";
string memory value = vm.toString(address(fyreToken));
updateEnv(envFilePath, key, value);
}

function updateEnv(
string memory envFilePath,
string memory key,
string memory value
) internal {
// Read the existing .env file (if it exists)
string memory content = "";
try vm.readFile(envFilePath) returns (string memory fileContent) {
content = fileContent;
} catch {
// File doesn't exist yet, start with an empty string
}

// Check if the key exists in the file and update or append the value
string memory keyWithEqual = string.concat(key, "=");
strings.slice memory contentSlice = content.toSlice();
strings.slice memory keySlice = keyWithEqual.toSlice();
if (contentSlice.contains(keySlice)) {
// Replace the existing value
strings.slice memory prefix = contentSlice.split(keySlice);
strings.slice memory suffix = contentSlice.split("\n".toSlice());
string memory newContent = string.concat(
prefix.toString(),
keyWithEqual,
value,
"\n",
suffix.toString()
);
vm.writeFile(envFilePath, newContent);
} else {
// Append the new key-value pair
string memory newContent = string.concat(
content,
"\n",
keyWithEqual,
value
);
vm.writeFile(envFilePath, newContent);
}
}
}
11 changes: 7 additions & 4 deletions src/Treasury/Treasury.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ pragma solidity ^0.8.19;

import {FYREToken} from "src/Tokens/FYREToken.sol";
import {MANA} from "src/Tokens/MANA.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol";
import {ECDSA} from "lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
import {MessageHashUtils} from "lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol";


contract Treasury is Ownable {
using ECDSA for bytes32;
Expand Down Expand Up @@ -165,7 +167,8 @@ contract Treasury is Ownable {
abi.encodePacked(nearAccountId, " owns SHLD token ", tokenHash)
);

bytes32 ethSignedMessageHash = messageHash.toEthSignedMessageHash();
bytes32 ethSignedMessageHash = MessageHashUtils.toEthSignedMessageHash(messageHash);

address recoveredSigner = ethSignedMessageHash.recover(signature);
require(recoveredSigner == authorizedSigner, "Invalid signature");

Expand Down

0 comments on commit eaa1e3e

Please sign in to comment.