Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules/
/node_modules
19 changes: 8 additions & 11 deletions src/components/Swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -42,10 +43,6 @@ function Swap(props) {
hash: data?.hash,
})

// function handleSlippageChange(e) {
// setSlippage(e.target.value);
// }

const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";

function changeAmount2(e) {
Expand All @@ -55,7 +52,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";

function switchTokens() {
setPrices(null);
setTokenOneAmount(null);
setAddressTo(null);
setTokenTwoAmount(null);
const one = tokenOne;
const two = tokenTwo;
Expand All @@ -71,7 +68,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";

function modifyToken(i){
setPrices(null);
setTokenOneAmount(null);
setAddressTo(null);
setTokenTwoAmount(null);
if (changeToken === 1) {
setTokenOne(tokenList[i]);
Expand All @@ -83,7 +80,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";
}

function changeAddress1(e) {
setTokenOneAmount(e.target.value);
setAddressTo(e.target.value);

}

Expand Down Expand Up @@ -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

}

Expand Down Expand Up @@ -164,7 +161,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";
<div className="inputs">
<Input
placeholder="Enter Address"
value={tokenOneAmount}
value={addressTo}
onChange= {changeAddress1}
/>
<Input placeholder="Enter Amount" value={value} onChange={changeAmount2} />
Expand All @@ -178,7 +175,7 @@ const contractAddress = "0x8D99163c2C04Df214b0546A7a40F8427b0F70C97";

</div>
</div>
<div className="swapButton" disabled={!tokenOneAmount && !isConnected} onClock={onTransfer} >Transfer</div>
<div className="swapButton" disabled={!addressTo && !isConnected} onClick={onTransfer} >Transfer</div>
</div>
</>
);
Expand Down
9 changes: 0 additions & 9 deletions src/components/Tokens.js

This file was deleted.