Clean up app strucutre deleting blockchain file and add methods on blockchain folder
Co-authored-by: brunoedcf <brest.dallacosta@outlook.com>
This commit is contained in:
parent
d78f7f1fdf
commit
8338064dcd
@ -6,7 +6,78 @@ import { getP2PixAddress } from "./addresses";
|
|||||||
import p2pix from "../utils/smart_contract_files/P2PIX.json";
|
import p2pix from "../utils/smart_contract_files/P2PIX.json";
|
||||||
|
|
||||||
import { BigNumber, ethers, type Event } from "ethers";
|
import { BigNumber, ethers, type Event } from "ethers";
|
||||||
import { formatEther } from "ethers/lib/utils";
|
import { formatEther, parseEther } from "ethers/lib/utils";
|
||||||
|
|
||||||
|
|
||||||
|
// Buyer Flow methods //
|
||||||
|
|
||||||
|
// Make lock
|
||||||
|
const addLock = async (
|
||||||
|
depositId: BigNumber,
|
||||||
|
amount: number
|
||||||
|
): Promise<Event> => {
|
||||||
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
|
const provider = getProvider();
|
||||||
|
const signer = provider.getSigner();
|
||||||
|
const p2pContract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
||||||
|
|
||||||
|
const lock = await p2pContract.lock(
|
||||||
|
depositId, // BigNumber
|
||||||
|
etherStore.walletAddress, // String "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" (Example)
|
||||||
|
ethers.constants.AddressZero, // String "0x0000000000000000000000000000000000000000"
|
||||||
|
0,
|
||||||
|
parseEther(String(amount)), // BigNumber
|
||||||
|
[],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
lock.wait();
|
||||||
|
|
||||||
|
return lock;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Release lock
|
||||||
|
const releaseLock = async (
|
||||||
|
pixKey: string,
|
||||||
|
amount: Number,
|
||||||
|
e2eId: string,
|
||||||
|
lockId: string
|
||||||
|
) => {
|
||||||
|
|
||||||
|
const mockBacenSigner = new ethers.Wallet(
|
||||||
|
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
||||||
|
);
|
||||||
|
|
||||||
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
|
["string", "uint256", "bytes32"],
|
||||||
|
[
|
||||||
|
pixKey,
|
||||||
|
formatEther(String(amount)),
|
||||||
|
ethers.utils.formatBytes32String(e2eId),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
const messageHashBytes = ethers.utils.arrayify(messageToSign);
|
||||||
|
const flatSig = await mockBacenSigner.signMessage(messageHashBytes);
|
||||||
|
const provider = getProvider();
|
||||||
|
|
||||||
|
const sig = ethers.utils.splitSignature(flatSig);
|
||||||
|
|
||||||
|
const signer = provider.getSigner();
|
||||||
|
const p2pContract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
||||||
|
|
||||||
|
const release = await p2pContract.release(
|
||||||
|
lockId,
|
||||||
|
ethers.constants.AddressZero,
|
||||||
|
ethers.utils.formatBytes32String(e2eId),
|
||||||
|
sig.r,
|
||||||
|
sig.s,
|
||||||
|
sig.v
|
||||||
|
);
|
||||||
|
release.wait();
|
||||||
|
|
||||||
|
return release;
|
||||||
|
};
|
||||||
|
|
||||||
const cancelDeposit = async (depositId: BigNumber): Promise<Boolean> => {
|
const cancelDeposit = async (depositId: BigNumber): Promise<Boolean> => {
|
||||||
const provider = getProvider();
|
const provider = getProvider();
|
||||||
@ -34,79 +105,9 @@ const withdrawDeposit = async (depositId: BigNumber): Promise<Boolean> => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addLock = async (
|
|
||||||
depositId: BigNumber,
|
|
||||||
amount: number
|
|
||||||
): Promise<Event> => {
|
|
||||||
const etherStore = useEtherStore();
|
|
||||||
const provider = getProvider();
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
|
||||||
|
|
||||||
// Make lock
|
|
||||||
// const oldEventsLen = etherStore.locksAddedList.length;
|
|
||||||
const lock = await p2pContract.lock(
|
|
||||||
depositId, // BigNumber
|
|
||||||
etherStore.walletAddress, // String "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" (Example)
|
|
||||||
ethers.constants.AddressZero, // String "0x0000000000000000000000000000000000000000"
|
|
||||||
0,
|
|
||||||
formatEther(String(amount)), // BigNumber
|
|
||||||
[],
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
lock.wait();
|
|
||||||
|
|
||||||
// while (etherStore.locksAddedList.length === oldEventsLen) {
|
|
||||||
// await updateLockAddedEvents();
|
|
||||||
// await updateValidDeposits();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Releases lock by specific ID and other additional data
|
// Releases lock by specific ID and other additional data
|
||||||
const releaseLock = async (
|
|
||||||
pixKey: string,
|
|
||||||
amount: Number,
|
|
||||||
e2eId: string,
|
|
||||||
lockId: string
|
|
||||||
) => {
|
|
||||||
const provider = getProvider();
|
|
||||||
|
|
||||||
const mockBacenSigner = new ethers.Wallet(
|
|
||||||
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
|
||||||
);
|
|
||||||
|
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
|
||||||
["string", "uint256", "bytes32"],
|
|
||||||
[
|
|
||||||
pixKey,
|
|
||||||
formatEther(String(amount)),
|
|
||||||
ethers.utils.formatBytes32String(e2eId),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
const messageHashBytes = ethers.utils.arrayify(messageToSign);
|
|
||||||
const flatSig = await mockBacenSigner.signMessage(messageHashBytes);
|
|
||||||
const sig = ethers.utils.splitSignature(flatSig);
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
|
||||||
|
|
||||||
const release = await p2pContract.release(
|
|
||||||
lockId,
|
|
||||||
ethers.constants.AddressZero,
|
|
||||||
ethers.utils.formatBytes32String(e2eId),
|
|
||||||
sig.r,
|
|
||||||
sig.s,
|
|
||||||
sig.v
|
|
||||||
);
|
|
||||||
release.wait();
|
|
||||||
// await updateLockReleasedEvents();
|
|
||||||
// await updateValidDeposits();
|
|
||||||
|
|
||||||
return release;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { cancelDeposit, withdrawDeposit, addLock, releaseLock };
|
export { cancelDeposit, withdrawDeposit, addLock, releaseLock };
|
||||||
|
@ -3,7 +3,7 @@ import { updateWalletStatus } from "./wallet";
|
|||||||
import { getTokenAddress, getP2PixAddress } from "./addresses";
|
import { getTokenAddress, getP2PixAddress } from "./addresses";
|
||||||
import { parseEther } from "ethers/lib/utils";
|
import { parseEther } from "ethers/lib/utils";
|
||||||
|
|
||||||
import { BigNumber, ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
|
|
||||||
import p2pix from "../utils/smart_contract_files/P2PIX.json";
|
import p2pix from "../utils/smart_contract_files/P2PIX.json";
|
||||||
import mockToken from "../utils/smart_contract_files/MockToken.json";
|
import mockToken from "../utils/smart_contract_files/MockToken.json";
|
||||||
@ -51,15 +51,4 @@ const addDeposit = async (tokenQty: string, pixKey: string) => {
|
|||||||
// await updateValidDeposits();
|
// await updateValidDeposits();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Map deposit
|
export { approveTokens, addDeposit };
|
||||||
const mapDeposits = async (depositId: BigNumber): Promise<any> => {
|
|
||||||
const provider = getProvider();
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const contract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
|
||||||
const deposit = await contract.mapDeposits(depositId);
|
|
||||||
|
|
||||||
return deposit;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { approveTokens, addDeposit, mapDeposits };
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { useEtherStore } from "@/store/ether";
|
import { useEtherStore } from "@/store/ether";
|
||||||
|
|
||||||
import { getProvider } from "./provider";
|
import { getProvider } from "./provider";
|
||||||
import { getTokenAddress, possibleChains } from "./addresses";
|
import { getP2PixAddress, getTokenAddress, possibleChains } from "./addresses";
|
||||||
|
|
||||||
|
import p2pix from "../utils/smart_contract_files/P2PIX.json";
|
||||||
import mockToken from "../utils/smart_contract_files/MockToken.json";
|
import mockToken from "../utils/smart_contract_files/MockToken.json";
|
||||||
|
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
import { formatEther } from "ethers/lib/utils";
|
import { formatEther } from "ethers/lib/utils";
|
||||||
|
import { getValidDeposits } from "./events";
|
||||||
|
|
||||||
const updateWalletStatus = async () => {
|
const updateWalletStatus = async () => {
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
@ -30,4 +32,72 @@ const updateWalletStatus = async () => {
|
|||||||
etherStore.setWalletAddress(ethers.utils.getAddress(walletAddress[0]));
|
etherStore.setWalletAddress(ethers.utils.getAddress(walletAddress[0]));
|
||||||
};
|
};
|
||||||
|
|
||||||
export { updateWalletStatus };
|
const listValidDepositTransactionsByWalletAddress = async (
|
||||||
|
walletAddress: string
|
||||||
|
): Promise<any[]> => {
|
||||||
|
const walletDeposits = await getValidDeposits();
|
||||||
|
if (walletDeposits) {
|
||||||
|
return walletDeposits
|
||||||
|
.filter((deposit) => deposit.seller == walletAddress)
|
||||||
|
.sort((a, b) => {
|
||||||
|
return b.blockNumber - a.blockNumber;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const listAllTransactionByWalletAddress = async (
|
||||||
|
walletAddress: string
|
||||||
|
): Promise<any[] | undefined> => {
|
||||||
|
const provider = getProvider();
|
||||||
|
if (!provider) return;
|
||||||
|
|
||||||
|
const signer = provider.getSigner();
|
||||||
|
const p2pContract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
||||||
|
|
||||||
|
const filterDeposits = p2pContract.filters.DepositAdded([walletAddress]);
|
||||||
|
const eventsDeposits = await p2pContract.queryFilter(filterDeposits);
|
||||||
|
|
||||||
|
const filterAddedLocks = p2pContract.filters.LockAdded([walletAddress]);
|
||||||
|
const eventsAddedLocks = await p2pContract.queryFilter(filterAddedLocks);
|
||||||
|
|
||||||
|
const filterReleasedLocks = p2pContract.filters.LockReleased([walletAddress]);
|
||||||
|
const eventsReleasedLocks = await p2pContract.queryFilter(
|
||||||
|
filterReleasedLocks
|
||||||
|
);
|
||||||
|
|
||||||
|
return [...eventsDeposits, ...eventsAddedLocks, ...eventsReleasedLocks].sort(
|
||||||
|
(a, b) => {
|
||||||
|
return b.blockNumber - a.blockNumber;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// get wallet's release transactions
|
||||||
|
const listReleaseTransactionByWalletAddress = async (
|
||||||
|
walletAddress: string
|
||||||
|
): Promise<any[] | undefined> => {
|
||||||
|
const provider = getProvider();
|
||||||
|
if (!provider) return;
|
||||||
|
|
||||||
|
const signer = provider.getSigner();
|
||||||
|
const p2pContract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
|
||||||
|
|
||||||
|
const filterReleasedLocks = p2pContract.filters.LockReleased([walletAddress]);
|
||||||
|
const eventsReleasedLocks = await p2pContract.queryFilter(
|
||||||
|
filterReleasedLocks
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventsReleasedLocks.sort((a, b) => {
|
||||||
|
return b.blockNumber - a.blockNumber;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
updateWalletStatus,
|
||||||
|
listValidDepositTransactionsByWalletAddress,
|
||||||
|
listAllTransactionByWalletAddress,
|
||||||
|
listReleaseTransactionByWalletAddress
|
||||||
|
};
|
||||||
|
@ -1,208 +0,0 @@
|
|||||||
import { useEtherStore } from "@/store/ether";
|
|
||||||
import { BigNumber, ethers } from "ethers";
|
|
||||||
|
|
||||||
// Smart contract imports
|
|
||||||
import p2pix from "./smart_contract_files/P2PIX.json";
|
|
||||||
import addresses from "./smart_contract_files/localhost.json";
|
|
||||||
// Mock wallets import
|
|
||||||
import { getProvider } from "../blockchain/provider";
|
|
||||||
|
|
||||||
// get all wallet transactions
|
|
||||||
const listAllTransactionByWalletAddress = async (
|
|
||||||
walletAddress: string
|
|
||||||
): Promise<any[] | undefined> => {
|
|
||||||
const provider = getProvider();
|
|
||||||
if (!provider) return;
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterDeposits = p2pContract.filters.DepositAdded([walletAddress]);
|
|
||||||
const eventsDeposits = await p2pContract.queryFilter(filterDeposits);
|
|
||||||
|
|
||||||
const filterAddedLocks = p2pContract.filters.LockAdded([walletAddress]);
|
|
||||||
const eventsAddedLocks = await p2pContract.queryFilter(filterAddedLocks);
|
|
||||||
|
|
||||||
const filterReleasedLocks = p2pContract.filters.LockReleased([walletAddress]);
|
|
||||||
const eventsReleasedLocks = await p2pContract.queryFilter(
|
|
||||||
filterReleasedLocks
|
|
||||||
);
|
|
||||||
|
|
||||||
return [...eventsDeposits, ...eventsAddedLocks, ...eventsReleasedLocks].sort(
|
|
||||||
(a, b) => {
|
|
||||||
return b.blockNumber - a.blockNumber;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// get wallet's deposit transactions
|
|
||||||
const listDepositTransactionByWalletAddress = async (
|
|
||||||
walletAddress: string
|
|
||||||
): Promise<any[]> => {
|
|
||||||
const provider = getProvider();
|
|
||||||
if (!provider) return [];
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterDeposits = p2pContract.filters.DepositAdded([walletAddress]);
|
|
||||||
const eventsDeposits = await p2pContract.queryFilter(filterDeposits);
|
|
||||||
|
|
||||||
return eventsDeposits.sort((a, b) => {
|
|
||||||
return b.blockNumber - a.blockNumber;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// get wallet's deposit transactions
|
|
||||||
const listValidDepositTransactionsByWalletAddress = async (
|
|
||||||
walletAddress: string
|
|
||||||
): Promise<any[]> => {
|
|
||||||
const walletDeposits = await getValidDeposits();
|
|
||||||
if (walletDeposits) {
|
|
||||||
return walletDeposits
|
|
||||||
.filter((deposit) => deposit.seller == walletAddress)
|
|
||||||
.sort((a, b) => {
|
|
||||||
return b.blockNumber - a.blockNumber;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
};
|
|
||||||
|
|
||||||
// get wallet's lock transactions
|
|
||||||
const listLockTransactionByWalletAddress = async (
|
|
||||||
walletAddress: string
|
|
||||||
): Promise<any[] | undefined> => {
|
|
||||||
const provider = getProvider();
|
|
||||||
if (!provider) return;
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterAddedLocks = p2pContract.filters.LockAdded([walletAddress]);
|
|
||||||
const eventsAddedLocks = await p2pContract.queryFilter(filterAddedLocks);
|
|
||||||
|
|
||||||
return eventsAddedLocks.sort((a, b) => {
|
|
||||||
return b.blockNumber - a.blockNumber;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// get wallet's release transactions
|
|
||||||
const listReleaseTransactionByWalletAddress = async (
|
|
||||||
walletAddress: string
|
|
||||||
): Promise<any[] | undefined> => {
|
|
||||||
const provider = getProvider();
|
|
||||||
if (!provider) return;
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterReleasedLocks = p2pContract.filters.LockReleased([walletAddress]);
|
|
||||||
const eventsReleasedLocks = await p2pContract.queryFilter(
|
|
||||||
filterReleasedLocks
|
|
||||||
);
|
|
||||||
|
|
||||||
return eventsReleasedLocks.sort((a, b) => {
|
|
||||||
return b.blockNumber - a.blockNumber;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update events at store methods
|
|
||||||
const updateValidDeposits = async () => {
|
|
||||||
const etherStore = useEtherStore();
|
|
||||||
const deposits = await getValidDeposits();
|
|
||||||
if (deposits) etherStore.setDepositsValidList(deposits);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateDepositAddedEvents = async () => {
|
|
||||||
const etherStore = useEtherStore();
|
|
||||||
const window_ = window as any;
|
|
||||||
const connection = window_.ethereum;
|
|
||||||
let provider: ethers.providers.Web3Provider | null = null;
|
|
||||||
|
|
||||||
if (!connection) return;
|
|
||||||
provider = new ethers.providers.Web3Provider(connection);
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterDeposits = p2pContract.filters.DepositAdded(null);
|
|
||||||
const eventsDeposits = await p2pContract.queryFilter(filterDeposits);
|
|
||||||
|
|
||||||
etherStore.setDepositsAddedList(eventsDeposits);
|
|
||||||
console.log("DEPOSITS", eventsDeposits);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateLockAddedEvents = async () => {
|
|
||||||
const etherStore = useEtherStore();
|
|
||||||
const window_ = window as any;
|
|
||||||
const connection = window_.ethereum;
|
|
||||||
let provider: ethers.providers.Web3Provider | null = null;
|
|
||||||
|
|
||||||
if (!connection) return;
|
|
||||||
provider = new ethers.providers.Web3Provider(connection);
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterLocks = p2pContract.filters.LockAdded(null);
|
|
||||||
const eventsLocks = await p2pContract.queryFilter(filterLocks);
|
|
||||||
etherStore.setLocksAddedList(eventsLocks);
|
|
||||||
console.log("LOCKS", eventsLocks);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateLockReleasedEvents = async () => {
|
|
||||||
const etherStore = useEtherStore();
|
|
||||||
const window_ = window as any;
|
|
||||||
const connection = window_.ethereum;
|
|
||||||
let provider: ethers.providers.Web3Provider | null = null;
|
|
||||||
|
|
||||||
if (!connection) return;
|
|
||||||
provider = new ethers.providers.Web3Provider(connection);
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const p2pContract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
|
|
||||||
const filterReleases = p2pContract.filters.LockReleased(null);
|
|
||||||
const eventsReleases = await p2pContract.queryFilter(filterReleases);
|
|
||||||
etherStore.setLocksReleasedList(eventsReleases);
|
|
||||||
console.log("RELEASES", eventsReleases);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get specific lock data by its ID
|
|
||||||
const mapLocks = async (lockId: string) => {
|
|
||||||
const provider = getProvider();
|
|
||||||
|
|
||||||
if (!provider) return;
|
|
||||||
|
|
||||||
const signer = provider.getSigner();
|
|
||||||
const contract = new ethers.Contract(addresses.p2pix, p2pix.abi, signer);
|
|
||||||
const lock = await contract.mapLocks(lockId);
|
|
||||||
|
|
||||||
return lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Formatting methods
|
|
||||||
const formatEther = (num: string) => {
|
|
||||||
const formattedNum = ethers.utils.parseEther(num);
|
|
||||||
return formattedNum;
|
|
||||||
};
|
|
||||||
|
|
||||||
const formatBigNumber = (num: BigNumber) => {
|
|
||||||
const formattedNum = ethers.utils.formatEther(num);
|
|
||||||
return formattedNum;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
formatEther,
|
|
||||||
listValidDepositTransactionsByWalletAddress,
|
|
||||||
listAllTransactionByWalletAddress,
|
|
||||||
listReleaseTransactionByWalletAddress,
|
|
||||||
listDepositTransactionByWalletAddress,
|
|
||||||
listLockTransactionByWalletAddress,
|
|
||||||
formatBigNumber,
|
|
||||||
mapLocks,
|
|
||||||
updateLockAddedEvents,
|
|
||||||
updateValidDeposits,
|
|
||||||
updateLockReleasedEvents,
|
|
||||||
updateDepositAddedEvents,
|
|
||||||
};
|
|
@ -2,7 +2,6 @@
|
|||||||
import SearchComponent from "../components/SearchComponent.vue";
|
import SearchComponent from "../components/SearchComponent.vue";
|
||||||
import ValidationComponent from "../components/LoadingComponent.vue";
|
import ValidationComponent from "../components/LoadingComponent.vue";
|
||||||
import BuyConfirmedComponent from "@/components/BuyConfirmedComponent.vue";
|
import BuyConfirmedComponent from "@/components/BuyConfirmedComponent.vue";
|
||||||
import blockchain from "../utils/blockchain";
|
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
import { useEtherStore } from "@/store/ether";
|
import { useEtherStore } from "@/store/ether";
|
||||||
@ -11,6 +10,8 @@ import { storeToRefs } from "pinia";
|
|||||||
import { addLock, releaseLock } from "@/blockchain/buyerMethods";
|
import { addLock, releaseLock } from "@/blockchain/buyerMethods";
|
||||||
import { updateWalletStatus } from "@/blockchain/wallet";
|
import { updateWalletStatus } from "@/blockchain/wallet";
|
||||||
import { getNetworksLiquidity } from "@/blockchain/events";
|
import { getNetworksLiquidity } from "@/blockchain/events";
|
||||||
|
import { listReleaseTransactionByWalletAddress } from "@/blockchain/wallet"
|
||||||
|
|
||||||
enum Step {
|
enum Step {
|
||||||
Search,
|
Search,
|
||||||
Buy,
|
Buy,
|
||||||
@ -74,8 +75,7 @@ const releaseTransaction = async ({ e2eId }: any) => {
|
|||||||
);
|
);
|
||||||
release.wait();
|
release.wait();
|
||||||
|
|
||||||
await blockchain
|
await listReleaseTransactionByWalletAddress(walletAddress.value.toLowerCase())
|
||||||
.listReleaseTransactionByWalletAddress(walletAddress.value.toLowerCase())
|
|
||||||
.then((releaseTransactions) => {
|
.then((releaseTransactions) => {
|
||||||
if (releaseTransactions)
|
if (releaseTransactions)
|
||||||
lastWalletReleaseTransactions.value = releaseTransactions;
|
lastWalletReleaseTransactions.value = releaseTransactions;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useEtherStore } from "@/store/ether";
|
import { useEtherStore } from "@/store/ether";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import blockchain from "../utils/blockchain";
|
|
||||||
import ListingComponent from "@/components/ListingComponent.vue";
|
import ListingComponent from "@/components/ListingComponent.vue";
|
||||||
import type { BigNumber } from "ethers";
|
import type { BigNumber } from "ethers";
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { cancelDeposit, withdrawDeposit } from "@/blockchain/buyerMethods";
|
import { cancelDeposit, withdrawDeposit } from "@/blockchain/buyerMethods";
|
||||||
|
import { listValidDepositTransactionsByWalletAddress } from "@/blockchain/wallet"
|
||||||
|
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ const depositList = ref<any[]>([]);
|
|||||||
|
|
||||||
if (walletAddress.value) {
|
if (walletAddress.value) {
|
||||||
const walletDeposits =
|
const walletDeposits =
|
||||||
await blockchain.listValidDepositTransactionsByWalletAddress(
|
await listValidDepositTransactionsByWalletAddress(
|
||||||
walletAddress.value
|
walletAddress.value
|
||||||
);
|
);
|
||||||
if (walletDeposits) {
|
if (walletDeposits) {
|
||||||
@ -40,7 +40,7 @@ const handleWithDrawDeposit = async (depositID: BigNumber, index: number) => {
|
|||||||
|
|
||||||
watch(walletAddress, async () => {
|
watch(walletAddress, async () => {
|
||||||
const walletDeposits =
|
const walletDeposits =
|
||||||
await blockchain.listValidDepositTransactionsByWalletAddress(
|
await listValidDepositTransactionsByWalletAddress(
|
||||||
walletAddress.value
|
walletAddress.value
|
||||||
);
|
);
|
||||||
if (walletDeposits) {
|
if (walletDeposits) {
|
||||||
|
@ -3,22 +3,21 @@ import { useEtherStore } from "@/store/ether";
|
|||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import ListingComponent from "@/components/ListingComponent.vue";
|
import ListingComponent from "@/components/ListingComponent.vue";
|
||||||
import blockchain from "../utils/blockchain";
|
import { listAllTransactionByWalletAddress } from "@/blockchain/wallet";
|
||||||
|
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
const { walletAddress } = storeToRefs(etherStore);
|
const { walletAddress } = storeToRefs(etherStore);
|
||||||
const allUserTransactions = ref<any[]>([]);
|
const allUserTransactions = ref<any[]>([]);
|
||||||
|
|
||||||
if (walletAddress.value) {
|
if (walletAddress.value) {
|
||||||
await blockchain
|
await listAllTransactionByWalletAddress(walletAddress.value)
|
||||||
.listAllTransactionByWalletAddress(walletAddress.value)
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res) allUserTransactions.value = res;
|
if (res) allUserTransactions.value = res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(walletAddress, async (newValue) => {
|
watch(walletAddress, async (newValue) => {
|
||||||
await blockchain.listAllTransactionByWalletAddress(newValue).then((res) => {
|
await listAllTransactionByWalletAddress(newValue).then((res) => {
|
||||||
if (res) allUserTransactions.value = res;
|
if (res) allUserTransactions.value = res;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user