Skip to content

Commit

Permalink
Merge pull request #6 from La-DAO/fix/approve
Browse files Browse the repository at this point in the history
Fix/approve
  • Loading branch information
iafhurtado authored Feb 28, 2024
2 parents d3568cf + 0a65ead commit acd5f3d
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 89 deletions.
57 changes: 0 additions & 57 deletions packages/foundry/contracts/XocVendor.sol

This file was deleted.

20 changes: 20 additions & 0 deletions packages/foundry/contracts/XocoLoco.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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;
}
}
1 change: 1 addition & 0 deletions packages/foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"verify": "forge build --build-info --build-info-path out/build-info/ && forge script script/VerifyAll.s.sol --ffi --rpc-url ${1:-default_network}"
},
"dependencies": {
"@openzeppelin/contracts-upgradeable": "^5.0.1",
"dotenv": "~16.3.1",
"envfile": "~6.18.0",
"ethers": "~5.7.1",
Expand Down
12 changes: 5 additions & 7 deletions packages/nextjs/components/index/data.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import benefitOneImg from "../../public/benefit-one.png";
import benefitTwoImg from "../../public/benefit-two.png";
import {
FaceSmileIcon,
AdjustmentsHorizontalIcon,
ChartBarSquareIcon,
CursorArrowRaysIcon,
DevicePhoneMobileIcon,
AdjustmentsHorizontalIcon,
FaceSmileIcon,
SunIcon,
} from "@heroicons/react/24/solid";

import benefitOneImg from "../../public/benefit-one.png";
import benefitTwoImg from "../../public/benefit-two.png";

const benefitOne = {
title: "El primer peso MXN decentralizado",
desc: "Por medio de contratos inteligentes, $XOC se convierte en una peso MXN digital sin intermediarios de por medio, lo que significa que no está controlada por ningún gobierno o banco central. Esto permite a los usuarios enviar y recibir dinero de forma rápida y segura, sin importar dónde se encuentren.",
Expand Down Expand Up @@ -56,5 +55,4 @@ const benefitTwo = {
],
};


export {benefitOne, benefitTwo};
export { benefitOne, benefitTwo };
6 changes: 4 additions & 2 deletions packages/nextjs/components/index/faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ const Faq = () => {
const faqdata = [
{
question: "Como se respalda el valor de cada $XOC?",
answer: "Cada $XOC está respaldado por un token ERC20 en la red de Polygon, Gnosis Chain and Optimism, el cual se puede liquidar por el valor equivalente a la deuda en XOC y saldar la cuenta en el proceso, todo confiando en la red de validadores.",
answer:
"Cada $XOC está respaldado por un token ERC20 en la red de Polygon, Gnosis Chain and Optimism, el cual se puede liquidar por el valor equivalente a la deuda en XOC y saldar la cuenta en el proceso, todo confiando en la red de validadores.",
},
{
question: "Que puedo hacer con $XOC?",
answer: "Puedes usar $XOC para pagar tus deudas, comprar bienes y servicios, o simplemente mantenerlo como una reserva de valor como si fuera cualquier otro peso mexicano. Lo mas impactante que puedes hacer es apoyar a la comunidad de La DAO construyendo el siguiente sistema fincanciero abierto y decentralizado.",
answer:
"Puedes usar $XOC para pagar tus deudas, comprar bienes y servicios, o simplemente mantenerlo como una reserva de valor como si fuera cualquier otro peso mexicano. Lo mas impactante que puedes hacer es apoyar a la comunidad de La DAO construyendo el siguiente sistema fincanciero abierto y decentralizado.",
},
{
question: "Quien mantiene todo esto? ",
Expand Down
36 changes: 23 additions & 13 deletions packages/nextjs/components/index/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useEffect, useState } from "react";
import Image from "next/image";
import heroImg from "../../public/hero-1.png";
import { houseOfReserveABI, xocolatlABI } from "../xoc-dapp/abis/xocabis";
import Container from "./container";
import React, { useEffect, useState } from "react";
import { parseEther } from "viem";
import { useAccount } from "wagmi";
import { useContractRead,useContractWrite } from "wagmi";
import { houseOfReserveABI, xocolatlABI } from "../xoc-dapp/abis/xocabis";
import { useContractRead, useContractWrite } from "wagmi";
import { swapRouterABI } from "~~/components/index/abis/uniabis";
import { parseEther } from 'viem';

enum FEE_BIPS {
ONE = 100,
Expand Down Expand Up @@ -70,17 +70,17 @@ const Hero = () => {
}, [latestPriceData]);

const { write: approve } = useContractWrite({
address: "0xa411c9aa00e020e4f88bc19996d29c5b7adb4acf",
address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
abi: xocolatlABI,
functionName: "approve",
args: ["0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", expectedAmountIn],
args: ["0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", parseEther("0.002")],
});

const { write: executeTrade } = useContractWrite({
const { write: executeTrade, isError } = useContractWrite({
address: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
abi: swapRouterABI,
functionName: "exactOutput",
args: [{path: path, recipient: account.address, amountOut: amountOut, amountInMaximum: expectedAmountIn}],
args: [{ path: path, recipient: account.address, amountOut: amountOut, amountInMaximum: expectedAmountIn }],
});

return (
Expand Down Expand Up @@ -120,11 +120,21 @@ const Hero = () => {
<dialog id="my_modal_1" className="modal">
<div className="modal-box">
<h3 className="font-bold text-lg">BUY $XOC</h3>
<p className="py-4">This is a Modal where you can eventually see a route and execute a swap upon.</p>
<h3>Token In: Wrapped Ether</h3>
<h3>Token Out: XOC</h3>
<button onClick={() => approve()}>Approve Weth</button>
<button onClick={() => executeTrade()}>Execute Trade</button>
<p className="py-4">
Since this is the 1st version, you need to click approve to approve 0.02 wETH that will be used to
buy XOC on Uniswap.
</p>
<h3>Token In: ~0.02 Wrapped Ether</h3>
<h3>Token Out: 100 XOC</h3>
<div className=" mt-12">
<button className="btn mr-5" onClick={() => approve()}>
Approve Weth
</button>
<button className="btn btn-primary" onClick={() => executeTrade()}>
Execute Trade
</button>
</div>
{isError && <p className="text-red-500">Error executing trade</p>}
<div className="modal-action">
<form method="dialog">
{/* if there is a button in form, it will close the modal */}
Expand Down
15 changes: 6 additions & 9 deletions packages/nextjs/components/index/sectionTitle.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React from "react";
import Container from "./container";

const SectionTitle = (props) => {
const SectionTitle = props => {
return (
<Container
className={`flex w-full flex-col mt-4 ${
props.align === "left" ? "" : "items-center justify-center text-center"
}`}>
className={`flex w-full flex-col mt-4 ${props.align === "left" ? "" : "items-center justify-center text-center"}`}
>
{props.pretitle && (
<div className="text-sm font-bold tracking-wider text-inherit uppercase">
{props.pretitle}
</div>
<div className="text-sm font-bold tracking-wider text-inherit uppercase">{props.pretitle}</div>
)}

{props.title && (
Expand All @@ -26,6 +23,6 @@ const SectionTitle = (props) => {
)}
</Container>
);
}
};

export default SectionTitle;
export default SectionTitle;
2 changes: 1 addition & 1 deletion packages/nextjs/components/index/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ const Video = () => {
);
}

export default Video;
export default Video;
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3464,6 +3464,15 @@ __metadata:
languageName: node
linkType: hard

"@openzeppelin/contracts-upgradeable@npm:^5.0.1":
version: 5.0.1
resolution: "@openzeppelin/contracts-upgradeable@npm:5.0.1"
peerDependencies:
"@openzeppelin/contracts": 5.0.1
checksum: a3a09ce10bc4647ab440aa56098b94e8a8bb763a9a399b834a4b7804be03d36331097b8e8f323791c0a0802a84d900597af1e23ac25aaeebeab0a2ae32763fc8
languageName: node
linkType: hard

"@openzeppelin/contracts@npm:3.4.1-solc-0.7-2":
version: 3.4.1-solc-0.7-2
resolution: "@openzeppelin/contracts@npm:3.4.1-solc-0.7-2"
Expand Down Expand Up @@ -4163,6 +4172,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@se-2/foundry@workspace:packages/foundry"
dependencies:
"@openzeppelin/contracts-upgradeable": ^5.0.1
"@types/prettier": 2
"@types/qrcode": 1
dotenv: ~16.3.1
Expand Down

0 comments on commit acd5f3d

Please sign in to comment.