Migrated project to Viem, removing Ethers completelly. Not finished tests.

This commit is contained in:
Filipe Soccol
2025-03-31 10:26:57 -03:00
parent 3227e3209c
commit e93cac6086
19 changed files with 672 additions and 469 deletions

View File

@@ -3,7 +3,7 @@ import SearchComponent from "@/components/SearchComponent.vue";
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
import BuyConfirmedComponent from "@/components/BuyConfirmedComponent/BuyConfirmedComponent.vue";
import { ref, onMounted, watch } from "vue";
import { useEtherStore } from "@/store/ether";
import { useViemStore } from "@/store/viem";
import QrCodeComponent from "@/components/QrCodeComponent.vue";
import { storeToRefs } from "pinia";
import { addLock, releaseLock } from "@/blockchain/buyerMethods";
@@ -20,11 +20,11 @@ enum Step {
List,
}
const etherStore = useEtherStore();
etherStore.setSellerView(false);
const viemStore = useViemStore();
viemStore.setSellerView(false);
// States
const { loadingLock, walletAddress, networkName } = storeToRefs(etherStore);
const { loadingLock, walletAddress, networkName } = storeToRefs(viemStore);
const flowStep = ref<Step>(Step.Search);
const pixTarget = ref<string>();
const tokenAmount = ref<number>();
@@ -45,7 +45,7 @@ const confirmBuyClick = async (
// Makes lock with deposit ID and the Amount
if (selectedDeposit) {
flowStep.value = Step.Buy;
etherStore.setLoadingLock(true);
viemStore.setLoadingLock(true);
await addLock(selectedDeposit.seller, selectedDeposit.token, tokenValue)
.then((_lockID) => {
@@ -56,7 +56,7 @@ const confirmBuyClick = async (
flowStep.value = Step.Search;
});
etherStore.setLoadingLock(false);
viemStore.setLoadingLock(false);
}
};

View File

@@ -1,10 +1,9 @@
<script setup lang="ts">
import { useEtherStore } from "@/store/ether";
import { storeToRefs } from "pinia";
import { ref, onMounted, watch } from "vue";
import { useViemStore } from "@/store/viem";
import ListingComponent from "@/components/ListingComponent/ListingComponent.vue";
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
import CustomAlert from "@/components/CustomAlert/CustomAlert.vue";
import { ref, watch, onMounted } from "vue";
import {
listValidDepositTransactionsByWalletAddress,
listAllTransactionByWalletAddress,
@@ -15,9 +14,10 @@ import type { ValidDeposit } from "@/model/ValidDeposit";
import type { WalletTransaction } from "@/model/WalletTransaction";
import router from "@/router/index";
import { storeToRefs } from "pinia";
const etherStore = useEtherStore();
const { walletAddress, networkName, selectedToken } = storeToRefs(etherStore);
const viemStore = useViemStore();
const { walletAddress, networkName, selectedToken } = storeToRefs(viemStore);
const loadingWithdraw = ref<boolean>(false);
const showAlert = ref<boolean>(false);
@@ -47,7 +47,7 @@ const callWithdraw = async (amount: string) => {
};
const getWalletTransactions = async () => {
etherStore.setLoadingWalletTransactions(true);
viemStore.setLoadingWalletTransactions(true);
if (walletAddress.value) {
console.log("Will fetch all required data...");
const walletDeposits = await listValidDepositTransactionsByWalletAddress(
@@ -70,7 +70,7 @@ const getWalletTransactions = async () => {
transactionsList.value = allUserTransactions;
}
}
etherStore.setLoadingWalletTransactions(false);
viemStore.setLoadingWalletTransactions(false);
};
onMounted(async () => {

View File

@@ -1,11 +1,15 @@
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { storeToRefs } from "pinia";
import SellerComponent from "@/components/SellerSteps/SellerComponent.vue";
import SearchComponent from "@/components/SearchComponent.vue";
import SendNetwork from "@/components/SellerSteps/SendNetwork.vue";
import SellerSearchComponent from "@/components/SellerSteps/SellerSearchComponent.vue";
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
import { useViemStore } from "@/store/viem";
import { approveTokens, addDeposit } from "@/blockchain/sellerMethods";
import { ref } from "vue";
import { useEtherStore } from "@/store/ether";
import CustomAlert from "@/components/CustomAlert/CustomAlert.vue";
import type { Participant } from "@/utils/bbPay";
@@ -15,8 +19,8 @@ enum Step {
Network,
}
const etherStore = useEtherStore();
etherStore.setSellerView(true);
const viemStore = useViemStore();
viemStore.setSellerView(true);
const flowStep = ref<Step>(Step.Sell);
const loading = ref<boolean>(false);
@@ -40,7 +44,7 @@ const approveOffer = async (args: Participant) => {
const sendNetwork = async () => {
loading.value = true;
try {
if (etherStore.seller) {
if (viemStore.seller) {
await addDeposit();
flowStep.value = Step.Sell;
loading.value = false;
@@ -70,9 +74,9 @@ const sendNetwork = async () => {
/>
<div v-if="flowStep == Step.Network">
<SendNetwork
:sellerId="etherStore.sellerId"
:offer="Number(etherStore.seller.offer)"
:selected-token="etherStore.selectedToken"
:sellerId="viemStore.sellerId"
:offer="Number(viemStore.seller.offer)"
:selected-token="viemStore.selectedToken"
v-if="!loading"
@send-network="sendNetwork"
/>