fixing search tokens iteration structure and wallet address formatting
This commit is contained in:
parent
ee35c17b6e
commit
e3cb9275c5
@ -50,20 +50,22 @@ const verifyLiquidity = () => {
|
||||
|
||||
if (!walletAddress.value || tokenValue.value == 0) return;
|
||||
|
||||
depositList.value.forEach((deposit) => {
|
||||
const found = depositList.value.find((element) => {
|
||||
const p2pixTokenValue = blockchain.verifyDepositAmmount(
|
||||
deposit.args.amount
|
||||
element.args.amount
|
||||
);
|
||||
|
||||
if (
|
||||
tokenValue.value!! <= Number(p2pixTokenValue) &&
|
||||
tokenValue.value!! != 0
|
||||
tokenValue.value!! != 0 &&
|
||||
element.args.seller !== walletAddress.value
|
||||
) {
|
||||
enableSelectButton.value = true;
|
||||
hasLiquidity.value = true;
|
||||
selectedDeposit.value = deposit;
|
||||
return;
|
||||
selectedDeposit.value = element;
|
||||
console.log("Selected is :", blockchain.verifyDepositAmmount(element.args.amount))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!enableSelectButton.value) {
|
||||
@ -72,6 +74,19 @@ const verifyLiquidity = () => {
|
||||
};
|
||||
|
||||
const emit = defineEmits(["tokenBuy"]);
|
||||
|
||||
const confirmPurchase = async () => {
|
||||
|
||||
const buyInfo = {
|
||||
"buyer":"",
|
||||
"seller":"",
|
||||
"amount":"",
|
||||
"depositID":"",
|
||||
"pixKey":""
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -15,8 +15,8 @@ const formatWalletAddress = (): string => {
|
||||
const walletAddressLength = walletAddress.value.length;
|
||||
const initialText = walletAddress.value.substring(0, 5);
|
||||
const finalText = walletAddress.value.substring(
|
||||
walletAddressLength - 5,
|
||||
walletAddressLength - 1
|
||||
walletAddressLength - 4,
|
||||
walletAddressLength
|
||||
);
|
||||
return `${initialText}...${finalText}`;
|
||||
};
|
||||
|
@ -5,6 +5,7 @@ import { BigNumber, ethers } from "ethers";
|
||||
import mockToken from "./smart_contract_files/MockToken.json";
|
||||
import p2pix from "./smart_contract_files/P2PIX.json";
|
||||
import addresses from "./smart_contract_files/localhost.json";
|
||||
import p2pEventsAndErrors from "./smart_contract_files/EventAndErrors.json"
|
||||
|
||||
import { wallets } from "./smart_contract_files/wallets.json";
|
||||
|
||||
@ -19,7 +20,7 @@ const updateWalletStatus = async (walletAddress: string) => {
|
||||
const balance = await contract.balanceOf(walletAddress);
|
||||
|
||||
etherStore.setBalance(String(balance));
|
||||
etherStore.setWalletAddress(walletAddress);
|
||||
etherStore.setWalletAddress(ethers.utils.getAddress(walletAddress));
|
||||
};
|
||||
|
||||
const connectProvider = async () => {
|
||||
@ -36,10 +37,10 @@ const connectProvider = async () => {
|
||||
const walletAddress = await provider.send("eth_requestAccounts", []);
|
||||
const balance = await contract.balanceOf(walletAddress[0]);
|
||||
|
||||
etherStore.setWalletAddress(walletAddress[0]);
|
||||
etherStore.setWalletAddress(ethers.utils.getAddress(walletAddress[0]));
|
||||
etherStore.setBalance(String(balance));
|
||||
|
||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pEventsAndErrors.abi, signer);
|
||||
|
||||
const filter = p2pContract.filters.DepositAdded(null);
|
||||
const events = await p2pContract.queryFilter(filter);
|
||||
@ -101,8 +102,10 @@ const mockDeposit = async (tokenQty = "1000.0", pixKey = "00011122233") => {
|
||||
|
||||
updateWalletStatus(etherStore.walletAddress);
|
||||
|
||||
const filter = p2pContract.filters.DepositAdded(null);
|
||||
const events = await p2pContract.queryFilter(filter);
|
||||
const p2pEvents = new ethers.Contract(addresses.p2pix, p2pEventsAndErrors.abi, signer);
|
||||
|
||||
const filter = p2pEvents.filters.DepositAdded(null);
|
||||
const events = await p2pEvents.queryFilter(filter);
|
||||
|
||||
console.log(events);
|
||||
|
||||
|
219
src/utils/smart_contract_files/EventAndErrors.json
Normal file
219
src/utils/smart_contract_files/EventAndErrors.json
Normal file
@ -0,0 +1,219 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "EventAndErrors",
|
||||
"sourceName": "contracts/EventAndErrors.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AlreadyReleased",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "DepositAlreadyExists",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "InvalidDeposit",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "InvalidSigner",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "LoopOverflow",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NotEnoughTokens",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NotExpired",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "OnlySeller",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "TxAlreadyUsed",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DepositAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DepositClosed",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DepositWithdrawn",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "FundsWithdrawn",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "lockID",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "LockAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes32",
|
||||
"name": "lockId",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "LockReleased",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes32",
|
||||
"name": "lockId",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "LockReturned",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user