From cd588622eae42b2f7d4d11d1a0fb70dc2b5a32cf Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Fri, 25 Nov 2022 17:05:21 -0300 Subject: [PATCH] add validations to search tokens form, also implemented core functions Co-authored-by: brunoedcf Co-authored-by: Esio Freitas --- src/store/ether.ts | 4 ++-- src/utils/blockchain.ts | 8 +++++-- src/utils/debounce.ts | 9 ++++++++ src/views/HomeView.vue | 50 +++++++++++++++++++++++++++++++++-------- 4 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 src/utils/debounce.ts diff --git a/src/store/ether.ts b/src/store/ether.ts index 0afd6ff..3a5b62b 100644 --- a/src/store/ether.ts +++ b/src/store/ether.ts @@ -4,7 +4,7 @@ export const useEtherStore = defineStore("ether", { state: () => ({ walletAddress: "", balance: "", - depositList: {}, + depositList: [{}], }), actions: { setWalletAddress(walletAddress: string) { @@ -13,7 +13,7 @@ export const useEtherStore = defineStore("ether", { setBalance(balance: string) { this.balance = balance; }, - setDepositList(depositList: {}) { + setDepositList(depositList: any[]) { this.depositList = depositList; }, }, diff --git a/src/utils/blockchain.ts b/src/utils/blockchain.ts index 1942a9d..7421133 100644 --- a/src/utils/blockchain.ts +++ b/src/utils/blockchain.ts @@ -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 }; diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts new file mode 100644 index 0000000..2079277 --- /dev/null +++ b/src/utils/debounce.ts @@ -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) + } + } \ No newline at end of file diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index bed7337..d747b6a 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,11 +1,43 @@