From 5cb9103ef5f5f82c8ce1c2b3ea6fe6e104cbe331 Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Fri, 24 Feb 2023 00:49:06 -0300 Subject: [PATCH 1/6] fix fill color from spinner component to always white instead of passing as parameter --- src/components/SearchComponent.vue | 6 +----- src/components/SpinnerComponent.vue | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/SearchComponent.vue b/src/components/SearchComponent.vue index 2a1736d..3983fd5 100644 --- a/src/components/SearchComponent.vue +++ b/src/components/SearchComponent.vue @@ -194,11 +194,7 @@ watch(walletAddress, (): void => { Carregando liquidez das redes. - +
{ return [ `w-${props.width}`, `h-${props.height}`, - `fill-${props.fillColor}`, + `fill-white`, "text-gray-200", "animate-spin", "dark:text-gray-600", From d686c0b9bc606c1177d59174f7c12018b2b07768 Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Fri, 24 Feb 2023 00:50:32 -0300 Subject: [PATCH 2/6] add method to get active lock amount from a seller wallet --- src/blockchain/wallet.ts | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/blockchain/wallet.ts b/src/blockchain/wallet.ts index 15271d8..e896b05 100644 --- a/src/blockchain/wallet.ts +++ b/src/blockchain/wallet.ts @@ -155,6 +155,22 @@ const listLockTransactionByWalletAddress = async ( }); }; +const listLockTransactionBySellerAddress = async ( + sellerAddress: string +): Promise => { + const p2pContract = getContract(true); + + const filterAddedLocks = p2pContract.filters.LockAdded(); + const eventsReleasedLocks = await p2pContract.queryFilter(filterAddedLocks); + + return eventsReleasedLocks.filter((lock) => + lock.args?.seller + .toHexString() + .substring(3) + .includes(sellerAddress.substring(2).toLowerCase()) + ); +}; + const checkUnreleasedLock = async ( walletAddress: string ): Promise => { @@ -187,10 +203,37 @@ const checkUnreleasedLock = async ( } }; +const getActiveLockAmount = async (walletAddress: string): Promise => { + const p2pContract = getContract(); + const lockSeller = await listLockTransactionBySellerAddress(walletAddress); + + const lockStatus = await p2pContract.getLocksStatus( + lockSeller.map((lock) => lock.args?.lockID) + ); + + const activeLockAmount = await lockStatus[1].reduce( + async (sumValue: Promise, currentStatus: number, index: number) => { + const currValue = await sumValue; + let valueToSum = 0; + + if (currentStatus == 1) { + const lock = await p2pContract.mapLocks(lockStatus[0][index]); + valueToSum = Number(formatEther(lock?.amount)); + } + + return currValue + valueToSum; + }, + Promise.resolve(0) + ); + + return activeLockAmount; +}; + export { updateWalletStatus, listValidDepositTransactionsByWalletAddress, listAllTransactionByWalletAddress, listReleaseTransactionByWalletAddress, checkUnreleasedLock, + getActiveLockAmount, }; From 8f45016532c2b0b0a8d873326ce28c5936d397a8 Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Fri, 24 Feb 2023 00:57:34 -0300 Subject: [PATCH 3/6] add text on listing component to show active lock amount --- src/assets/info.svg | 5 +++++ .../ListingComponent/ListingComponent.vue | 10 ++++++++-- .../__tests__/ListingComponent.spec.ts | 16 ++++++++++++++++ src/views/HomeView.vue | 5 +++++ src/views/ManageBidsView.vue | 5 +++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/assets/info.svg diff --git a/src/assets/info.svg b/src/assets/info.svg new file mode 100644 index 0000000..0f60765 --- /dev/null +++ b/src/assets/info.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/components/ListingComponent/ListingComponent.vue b/src/components/ListingComponent/ListingComponent.vue index e3433bf..2b8cc64 100644 --- a/src/components/ListingComponent/ListingComponent.vue +++ b/src/components/ListingComponent/ListingComponent.vue @@ -16,6 +16,7 @@ const etherStore = useEtherStore(); const props = defineProps<{ validDeposits: ValidDeposit[]; walletTransactions: WalletTransaction[]; + activeLockAmount: Number; }>(); const emit = defineEmits(["depositWithdrawn"]); @@ -139,7 +140,7 @@ showInitialItems();