From 2c53566adae73628a4b918643e19695d5134df37 Mon Sep 17 00:00:00 2001 From: 07Vaishnavi-Singh <100015197+07Vaishnavi-Singh@users.noreply.github.com> Date: Sat, 22 Jul 2023 21:48:46 +0200 Subject: [PATCH 1/2] unecsaary files deleted --- src/components/Tokens.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/components/Tokens.js diff --git a/src/components/Tokens.js b/src/components/Tokens.js deleted file mode 100644 index 98d4e34ed..000000000 --- a/src/components/Tokens.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react' - -function Tokens() { - return ( -
Tokens
- ) -} - -export default Tokens \ No newline at end of file From 51425c00a74780c832ff5068948d2df1bda394f4 Mon Sep 17 00:00:00 2001 From: 07Vaishnavi-Singh <100015197+07Vaishnavi-Singh@users.noreply.github.com> Date: Sun, 23 Jul 2023 03:11:52 +0200 Subject: [PATCH 2/2] called --- .gitignore | 2 +- src/components/Swap.js | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 40de7c7c5..9e73da7f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ - node_modules/ \ No newline at end of file + /node_modules \ No newline at end of file diff --git a/src/components/Swap.js b/src/components/Swap.js index 6d170b08d..303723bf2 100644 --- a/src/components/Swap.js +++ b/src/components/Swap.js @@ -8,12 +8,13 @@ import { import tokenList from "../tokenList.json"; import axios from "axios"; import { useSendTransaction, useWaitForTransaction } from "wagmi"; +import { ethers } from "ethers"; + function Swap(props) { const { address, isConnected } = props; const [messageApi, contextHolder] = message.useMessage(); // const [slippage, setSlippage] = useState(2.5); - const [tokenOneAmount, setTokenOneAmount] = useState(null); const [tokenTwoAmount, setTokenTwoAmount] = useState(null); const [tokenOne, setTokenOne] = useState(tokenList[0]); const [tokenTwo, setTokenTwo] = useState(tokenList[1]); @@ -42,10 +43,6 @@ function Swap(props) { hash: data?.hash, }) - // function handleSlippageChange(e) { - // setSlippage(e.target.value); - // } - const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97"; function changeAmount2(e) { @@ -55,7 +52,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97"; function switchTokens() { setPrices(null); - setTokenOneAmount(null); + setAddressTo(null); setTokenTwoAmount(null); const one = tokenOne; const two = tokenTwo; @@ -71,7 +68,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97"; function modifyToken(i){ setPrices(null); - setTokenOneAmount(null); + setAddressTo(null); setTokenTwoAmount(null); if (changeToken === 1) { setTokenOne(tokenList[i]); @@ -83,7 +80,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97"; } function changeAddress1(e) { - setTokenOneAmount(e.target.value); + setAddressTo(e.target.value); } @@ -135,7 +132,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97"; signer ); - transfer.transferTokens(); // to: value and amount in the buttons + transfer.transferTokens(addressTo,value); // to: value and amount in the buttons } @@ -164,7 +161,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";
@@ -178,7 +175,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";
-
Transfer
+
Transfer
);