From 0d3a42e2154faaf9081e193bf81b79bcb5c9f781 Mon Sep 17 00:00:00 2001
From: JaiBo <65864145+iafhurtado@users.noreply.github.com>
Date: Thu, 29 Feb 2024 00:10:11 +0100
Subject: [PATCH] latest changes
---
packages/foundry/contracts/XocPin.sol | 42 ++++++++
packages/foundry/contracts/XocoLoco.sol | 20 ----
packages/foundry/contracts/YourContract.sol | 9 +-
packages/foundry/deployments/137.json | 3 +
packages/foundry/deployments/31337.json | 3 +
packages/foundry/foundry.toml | 2 +-
packages/foundry/script/Deploy.s.sol | 13 +--
packages/foundry/script/DeployHelpers.s.sol | 11 +--
packages/foundry/script/VerifyAll.s.sol | 99 +++++--------------
packages/foundry/test/YourContract.t.sol | 10 +-
packages/nextjs/components/Header.tsx | 5 +
packages/nextjs/components/index/hero.tsx | 2 +-
.../components/index/protocolNumbers.tsx | 2 +-
.../nextjs/components/streams/SuperTokens.tsx | 2 +-
14 files changed, 89 insertions(+), 134 deletions(-)
create mode 100644 packages/foundry/contracts/XocPin.sol
delete mode 100644 packages/foundry/contracts/XocoLoco.sol
create mode 100644 packages/foundry/deployments/137.json
create mode 100644 packages/foundry/deployments/31337.json
diff --git a/packages/foundry/contracts/XocPin.sol b/packages/foundry/contracts/XocPin.sol
new file mode 100644
index 0000000..99e77bf
--- /dev/null
+++ b/packages/foundry/contracts/XocPin.sol
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: MIT
+pragma solidity ^0.8.20;
+
+import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
+import "@openzeppelin/contracts/access/Ownable.sol";
+import "@openzeppelin/contracts/interfaces/IERC20.sol";
+import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
+
+contract XocPin is ERC721URIStorage, Ownable {
+ using SafeERC20 for IERC20;
+
+ address public constant XOCOLATL = 0xa411c9Aa00E020e4f88Bc19996d29c5B7ADB4ACf;
+ address public constant TREASURY = 0x707C5E55277A0C2f598f191b269c9e773516052A;
+ uint256 public constant MINT_PRICE = 100e18;
+
+ uint256 public nextTokenId = 1;
+
+ string public baseTokenURI;
+
+ constructor(string memory _tokenURI) ERC721("XocPin", "XOCP") Ownable(TREASURY) {
+ baseTokenURI = _tokenURI;
+ }
+
+ function mint(address to) external {
+ IERC20(XOCOLATL).safeTransferFrom(msg.sender, TREASURY, MINT_PRICE);
+ _mint(to, nextTokenId);
+ nextTokenId++;
+ }
+
+ function setTokenURI(uint256 tokenId, string memory _tokenURI) external onlyOwner {
+ _setTokenURI(tokenId, _tokenURI);
+ }
+
+ function setBaseTokenURI(string memory _baseTokenURI) external onlyOwner {
+ baseTokenURI = _baseTokenURI;
+ emit BatchMetadataUpdate(1, nextTokenId - 1);
+ }
+
+ function _baseURI() internal view override returns (string memory) {
+ return baseTokenURI;
+ }
+}
diff --git a/packages/foundry/contracts/XocoLoco.sol b/packages/foundry/contracts/XocoLoco.sol
deleted file mode 100644
index 84b94a9..0000000
--- a/packages/foundry/contracts/XocoLoco.sol
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity ^0.8.19;
-
-import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
-
-
-contract XocoLoco is ERC721 {
- using Counters for Counters.Counter;
- Counters.Counter private _tokenIds;
-
- constructor() ERC721("XocoLoco", "XOCO") {}
-
- function mint(address recipient, string memory tokenURI) public returns (uint256) {
- _tokenIds.increment();
- uint256 newItemId = _tokenIds.current();
- _mint(recipient, newItemId);
- _setTokenURI(newItemId, tokenURI);
- return newItemId;
- }
-}
diff --git a/packages/foundry/contracts/YourContract.sol b/packages/foundry/contracts/YourContract.sol
index 374c58a..c572b07 100644
--- a/packages/foundry/contracts/YourContract.sol
+++ b/packages/foundry/contracts/YourContract.sol
@@ -21,12 +21,7 @@ contract YourContract {
mapping(address => uint256) public userGreetingCounter;
// Events: a way to emit log statements from smart contract that can be listened to by external parties
- event GreetingChange(
- address indexed greetingSetter,
- string newGreeting,
- bool premium,
- uint256 value
- );
+ event GreetingChange(address indexed greetingSetter, string newGreeting, bool premium, uint256 value);
// Constructor: Called once on contract deployment
// Check packages/foundry/deploy/Deploy.s.sol
@@ -73,7 +68,7 @@ contract YourContract {
* The function can only be called by the owner of the contract as defined by the isOwner modifier
*/
function withdraw() public isOwner {
- (bool success, ) = owner.call{value: address(this).balance}("");
+ (bool success,) = owner.call{value: address(this).balance}("");
require(success, "Failed to send Ether");
}
diff --git a/packages/foundry/deployments/137.json b/packages/foundry/deployments/137.json
new file mode 100644
index 0000000..a7a79d4
--- /dev/null
+++ b/packages/foundry/deployments/137.json
@@ -0,0 +1,3 @@
+{
+ "networkName": "Polygon"
+}
\ No newline at end of file
diff --git a/packages/foundry/deployments/31337.json b/packages/foundry/deployments/31337.json
new file mode 100644
index 0000000..dc4be98
--- /dev/null
+++ b/packages/foundry/deployments/31337.json
@@ -0,0 +1,3 @@
+{
+ "networkName": "default_network"
+}
\ No newline at end of file
diff --git a/packages/foundry/foundry.toml b/packages/foundry/foundry.toml
index 3d894ea..0e4c8f1 100644
--- a/packages/foundry/foundry.toml
+++ b/packages/foundry/foundry.toml
@@ -1,5 +1,5 @@
[profile.default]
-solc = "0.8.19"
+solc = "0.8.20"
src = 'contracts'
out = 'out'
libs = ['lib']
diff --git a/packages/foundry/script/Deploy.s.sol b/packages/foundry/script/Deploy.s.sol
index 48a1565..8c32c93 100644
--- a/packages/foundry/script/Deploy.s.sol
+++ b/packages/foundry/script/Deploy.s.sol
@@ -1,7 +1,7 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
-import "../contracts/YourContract.sol";
+import "../contracts/XocPin.sol";
import "./DeployHelpers.s.sol";
contract DeployScript is ScaffoldETHDeploy {
@@ -15,15 +15,10 @@ contract DeployScript is ScaffoldETHDeploy {
);
}
vm.startBroadcast(deployerPrivateKey);
- YourContract yourContract = new YourContract(
- vm.addr(deployerPrivateKey)
- );
- console.logString(
- string.concat(
- "YourContract deployed at: ",
- vm.toString(address(yourContract))
- )
+ XocPin xocpin = new XocPin(
+ "https://ipfs.io/ipfs/QmRhakrLp8fzdMp4HDUm3ocFJ51bsBdZXjpZadPh7gYg4P?filename=Familia%20Tier%203.png"
);
+ console.logString(string.concat("XocPin deployed at: ", vm.toString(address(xocpin))));
vm.stopBroadcast();
/**
diff --git a/packages/foundry/script/DeployHelpers.s.sol b/packages/foundry/script/DeployHelpers.s.sol
index 824d007..e2e9017 100644
--- a/packages/foundry/script/DeployHelpers.s.sol
+++ b/packages/foundry/script/DeployHelpers.s.sol
@@ -16,10 +16,7 @@ contract ScaffoldETHDeploy is Script {
string path;
Deployment[] public deployments;
- function setupLocalhostEnv()
- internal
- returns (uint256 localhostPrivateKey)
- {
+ function setupLocalhostEnv() internal returns (uint256 localhostPrivateKey) {
if (block.chainid == 31337) {
root = vm.projectRoot();
path = string.concat(root, "/localhost.json");
@@ -44,11 +41,7 @@ contract ScaffoldETHDeploy is Script {
uint256 len = deployments.length;
for (uint256 i = 0; i < len; i++) {
- vm.serializeString(
- jsonWrite,
- vm.toString(deployments[i].addr),
- deployments[i].name
- );
+ vm.serializeString(jsonWrite, vm.toString(deployments[i].addr), deployments[i].name);
}
string memory chainName;
diff --git a/packages/foundry/script/VerifyAll.s.sol b/packages/foundry/script/VerifyAll.s.sol
index 7e86628..87b04a6 100644
--- a/packages/foundry/script/VerifyAll.s.sol
+++ b/packages/foundry/script/VerifyAll.s.sol
@@ -26,12 +26,8 @@ contract VerifyAll is Script {
function run() external {
string memory root = vm.projectRoot();
- string memory path = string.concat(
- root,
- "/broadcast/Deploy.s.sol/",
- vm.toString(block.chainid),
- "/run-latest.json"
- );
+ string memory path =
+ string.concat(root, "/broadcast/Deploy.s.sol/", vm.toString(block.chainid), "/run-latest.json");
string memory content = vm.readFile(path);
while (this.nextTransaction(content)) {
@@ -41,52 +37,24 @@ contract VerifyAll is Script {
}
function _verifyIfContractDeployment(string memory content) internal {
- string memory txType = abi.decode(
- vm.parseJson(
- content,
- searchStr(currTransactionIdx, "transactionType")
- ),
- (string)
- );
+ string memory txType =
+ abi.decode(vm.parseJson(content, searchStr(currTransactionIdx, "transactionType")), (string));
if (keccak256(bytes(txType)) == keccak256(bytes("CREATE"))) {
_verifyContract(content);
}
}
function _verifyContract(string memory content) internal {
- string memory contractName = abi.decode(
- vm.parseJson(
- content,
- searchStr(currTransactionIdx, "contractName")
- ),
- (string)
- );
- address contractAddr = abi.decode(
- vm.parseJson(
- content,
- searchStr(currTransactionIdx, "contractAddress")
- ),
- (address)
- );
- bytes memory deployedBytecode = abi.decode(
- vm.parseJson(
- content,
- searchStr(currTransactionIdx, "transaction.data")
- ),
- (bytes)
- );
- bytes memory compiledBytecode = abi.decode(
- vm.parseJson(
- _getCompiledBytecode(contractName),
- ".bytecode.object"
- ),
- (bytes)
- );
- bytes memory constructorArgs = BytesLib.slice(
- deployedBytecode,
- compiledBytecode.length,
- deployedBytecode.length - compiledBytecode.length
- );
+ string memory contractName =
+ abi.decode(vm.parseJson(content, searchStr(currTransactionIdx, "contractName")), (string));
+ address contractAddr =
+ abi.decode(vm.parseJson(content, searchStr(currTransactionIdx, "contractAddress")), (address));
+ bytes memory deployedBytecode =
+ abi.decode(vm.parseJson(content, searchStr(currTransactionIdx, "transaction.data")), (bytes));
+ bytes memory compiledBytecode =
+ abi.decode(vm.parseJson(_getCompiledBytecode(contractName), ".bytecode.object"), (bytes));
+ bytes memory constructorArgs =
+ BytesLib.slice(deployedBytecode, compiledBytecode.length, deployedBytecode.length - compiledBytecode.length);
string[] memory inputs = new string[](9);
inputs[0] = "forge";
@@ -102,12 +70,7 @@ contract VerifyAll is Script {
FfiResult memory f = tempVm(address(vm)).tryFfi(inputs);
if (f.stderr.length != 0) {
- console.logString(
- string.concat(
- "Submitting verification for contract: ",
- vm.toString(contractAddr)
- )
- );
+ console.logString(string.concat("Submitting verification for contract: ", vm.toString(contractAddr)));
console.logString(string(f.stderr));
} else {
console.logString(string(f.stdout));
@@ -115,9 +78,7 @@ contract VerifyAll is Script {
return;
}
- function nextTransaction(
- string memory content
- ) external view returns (bool) {
+ function nextTransaction(string memory content) external view returns (bool) {
try this.getTransactionFromRaw(content, currTransactionIdx) {
return true;
} catch {
@@ -125,33 +86,17 @@ contract VerifyAll is Script {
}
}
- function _getCompiledBytecode(
- string memory contractName
- ) internal view returns (string memory compiledBytecode) {
+ function _getCompiledBytecode(string memory contractName) internal view returns (string memory compiledBytecode) {
string memory root = vm.projectRoot();
- string memory path = string.concat(
- root,
- "/out/",
- contractName,
- ".sol/",
- contractName,
- ".json"
- );
+ string memory path = string.concat(root, "/out/", contractName, ".sol/", contractName, ".json");
compiledBytecode = vm.readFile(path);
}
- function getTransactionFromRaw(
- string memory content,
- uint96 idx
- ) external pure {
+ function getTransactionFromRaw(string memory content, uint96 idx) external pure {
abi.decode(vm.parseJson(content, searchStr(idx, "hash")), (bytes32));
}
- function searchStr(
- uint96 idx,
- string memory searchKey
- ) internal pure returns (string memory) {
- return
- string.concat(".transactions[", vm.toString(idx), "].", searchKey);
+ function searchStr(uint96 idx, string memory searchKey) internal pure returns (string memory) {
+ return string.concat(".transactions[", vm.toString(idx), "].", searchKey);
}
-}
\ No newline at end of file
+}
diff --git a/packages/foundry/test/YourContract.t.sol b/packages/foundry/test/YourContract.t.sol
index 00c8aec..5680a47 100644
--- a/packages/foundry/test/YourContract.t.sol
+++ b/packages/foundry/test/YourContract.t.sol
@@ -12,17 +12,11 @@ contract YourContractTest is Test {
}
function testMessageOnDeployment() public view {
- require(
- keccak256(bytes(yourContract.greeting())) ==
- keccak256("Building Unstoppable Apps!!!")
- );
+ require(keccak256(bytes(yourContract.greeting())) == keccak256("Building Unstoppable Apps!!!"));
}
function testSetNewMessage() public {
yourContract.setGreeting("Learn Scaffold-ETH 2! :)");
- require(
- keccak256(bytes(yourContract.greeting())) ==
- keccak256("Learn Scaffold-ETH 2! :)")
- );
+ require(keccak256(bytes(yourContract.greeting())) == keccak256("Learn Scaffold-ETH 2! :)"));
}
}
diff --git a/packages/nextjs/components/Header.tsx b/packages/nextjs/components/Header.tsx
index 12c9c65..150fb7c 100644
--- a/packages/nextjs/components/Header.tsx
+++ b/packages/nextjs/components/Header.tsx
@@ -23,6 +23,11 @@ export const menuLinks: HeaderMenuLink[] = [
href: "/defi",
icon: