add validations to search tokens form, also implemented core functions

Co-authored-by: brunoedcf <brest.dallacosta@outlook.com>
Co-authored-by: Esio Freitas <esio.gustavo@gmail.com>
This commit is contained in:
RcleydsonR
2022-11-25 17:05:21 -03:00
parent 203376a20f
commit cd588622ea
4 changed files with 58 additions and 13 deletions

View File

@@ -45,7 +45,6 @@ const connectProvider = async () => {
const events = await p2pContract.queryFilter(filter);
console.log(events)
etherStore.setDepositList(events);
connection.on("accountsChanged", (accounts: string[]) => {
@@ -129,6 +128,11 @@ const formatEther = (balance: string) => {
return formatted;
};
const verifyDepositAmmount = (ammountBigNumber: BigNumber) => {
return ethers.utils.formatEther(ammountBigNumber)
}
const getProvider = (): ethers.providers.Web3Provider | null => {
const window_ = window as any;
const connection = window_.ethereum;
@@ -138,4 +142,4 @@ const getProvider = (): ethers.providers.Web3Provider | null => {
return new ethers.providers.Web3Provider(connection);
};
export default { connectProvider, formatEther, splitTokens, mockDeposit, countDeposit, mapDeposits };
export default { connectProvider, formatEther, splitTokens, mockDeposit, countDeposit, mapDeposits, verifyDepositAmmount };

9
src/utils/debounce.ts Normal file
View File

@@ -0,0 +1,9 @@
export const debounce = (func: any, delay: number) => {
let timer: any = null
return function (this: unknown, ...args: any) {
clearTimeout(timer)
timer = setTimeout(() => {
func.apply(this, args)
}, delay)
}
}