From 81c8b04c7a4fc89390400f1de0d4e2b4e3c5bfef Mon Sep 17 00:00:00 2001 From: Filipe Soccol Date: Fri, 27 Jun 2025 16:34:29 -0300 Subject: [PATCH] Refactored variable names to be concise. --- src/blockchain/events.ts | 17 +++++++++++------ src/components/SearchComponent.vue | 4 ++-- src/model/ValidDeposit.ts | 2 +- src/model/mock/ValidDepositMock.ts | 10 +++++----- src/utils/bbPay.ts | 2 -- src/views/HomeView.vue | 11 +++++------ 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/blockchain/events.ts b/src/blockchain/events.ts index a720acf..9ff2c20 100644 --- a/src/blockchain/events.ts +++ b/src/blockchain/events.ts @@ -29,10 +29,13 @@ const getNetworksLiquidity = async (): Promise => { user.setLoadingNetworkLiquidity(false); }; -const getPixKey = async (seller: string, token: string): Promise => { +const getParticipantID = async ( + seller: string, + token: string +): Promise => { const { address, abi, client } = await getContract(); - const pixKeyHex = await client.readContract({ + const participantIDHex = await client.readContract({ address: address as `0x${string}`, abi, functionName: "getPixTarget", @@ -41,8 +44,10 @@ const getPixKey = async (seller: string, token: string): Promise => { // Remove '0x' prefix and convert hex to UTF-8 string const hexString = - typeof pixKeyHex === "string" ? pixKeyHex : toHex(pixKeyHex as bigint); - if (!hexString) throw new Error("PixKey not found"); + typeof participantIDHex === "string" + ? participantIDHex + : toHex(participantIDHex as bigint); + if (!hexString) throw new Error("Participant ID not found"); const bytes = new Uint8Array( hexString .slice(2) @@ -133,7 +138,7 @@ const getValidDeposits = async ( remaining: Number(formatEther(mappedBalance.result as bigint)), seller: seller, network, - pixKey: "", + participantID: "", }; depositList[seller + token] = validDeposit; } @@ -177,5 +182,5 @@ export { getValidDeposits, getNetworksLiquidity, getUnreleasedLockById, - getPixKey, + getParticipantID, }; diff --git a/src/components/SearchComponent.vue b/src/components/SearchComponent.vue index 8efb9e6..43d1276 100644 --- a/src/components/SearchComponent.vue +++ b/src/components/SearchComponent.vue @@ -38,7 +38,7 @@ const selectedDeposits = ref(); import ChevronDown from "@/assets/chevronDown.svg"; import { useOnboard } from "@web3-onboard/vue"; -import { getPixKey } from "@/blockchain/events"; +import { getParticipantID } from "@/blockchain/events"; // Emits const emit = defineEmits(["tokenBuy"]); @@ -54,7 +54,7 @@ const emitConfirmButton = async (): Promise => { (d) => d.network === Number(networkName.value) ); if (!deposit) return; - deposit.pixKey = await getPixKey(deposit.seller, deposit.token); + deposit.participantID = await getParticipantID(deposit.seller, deposit.token); emit("tokenBuy", deposit, tokenValue.value); }; diff --git a/src/model/ValidDeposit.ts b/src/model/ValidDeposit.ts index c15eea0..46e9c6e 100644 --- a/src/model/ValidDeposit.ts +++ b/src/model/ValidDeposit.ts @@ -5,7 +5,7 @@ export type ValidDeposit = { blockNumber: number; remaining: number; seller: string; - pixKey: string; + participantID: string; network: NetworkEnum; open?: boolean; }; diff --git a/src/model/mock/ValidDepositMock.ts b/src/model/mock/ValidDepositMock.ts index 21a308a..3c14d26 100644 --- a/src/model/mock/ValidDepositMock.ts +++ b/src/model/mock/ValidDepositMock.ts @@ -7,7 +7,7 @@ export const MockValidDeposits: ValidDeposit[] = [ token: "1", remaining: 70, seller: "mockedSellerAddress", - pixKey: "123456789", + participantID: "123456789", network: NetworkEnum.sepolia, }, { @@ -15,7 +15,7 @@ export const MockValidDeposits: ValidDeposit[] = [ token: "2", remaining: 200, seller: "mockedSellerAddress", - pixKey: "123456789", + participantID: "123456789", network: NetworkEnum.sepolia, }, { @@ -23,7 +23,7 @@ export const MockValidDeposits: ValidDeposit[] = [ token: "3", remaining: 1250, seller: "mockedSellerAddress", - pixKey: "123456789", + participantID: "123456789", network: NetworkEnum.sepolia, }, { @@ -31,7 +31,7 @@ export const MockValidDeposits: ValidDeposit[] = [ token: "4", remaining: 4000, seller: "mockedSellerAddress", - pixKey: "123456789", + participantID: "123456789", network: NetworkEnum.sepolia, }, { @@ -39,7 +39,7 @@ export const MockValidDeposits: ValidDeposit[] = [ token: "5", remaining: 2000, seller: "mockedSellerAddress", - pixKey: "123456789", + participantID: "123456789", network: NetworkEnum.sepolia, }, ]; diff --git a/src/utils/bbPay.ts b/src/utils/bbPay.ts index 8b5bb68..e711aa5 100644 --- a/src/utils/bbPay.ts +++ b/src/utils/bbPay.ts @@ -1,5 +1,3 @@ -import { off } from "process"; - export interface Participant { offer: string; chainID: number; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 8c3153c..7370a22 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -25,7 +25,8 @@ user.setSellerView(false); // States const { loadingLock, walletAddress, networkName } = user; const flowStep = ref(Step.Search); -const pixTarget = ref(); +const participantID = ref(); +const sellerAddress = ref<`0x${string}` | undefined>(); const tokenAmount = ref(); const lockID = ref(""); const loadingRelease = ref(false); @@ -37,7 +38,7 @@ const confirmBuyClick = async ( selectedDeposit: ValidDeposit, tokenValue: number ) => { - pixTarget.value = selectedDeposit.pixKey; + participantID.value = selectedDeposit.participantID; tokenAmount.value = tokenValue; if (selectedDeposit) { @@ -78,7 +79,7 @@ const checkForUnreleasedLocks = async (): Promise => { if (lock) { lockID.value = lock.lockID; tokenAmount.value = lock.amount; - pixTarget.value = lock.sellerAddress; + sellerAddress.value = lock.sellerAddress; showModal.value = true; } else { flowStep.value = Step.Search; @@ -91,7 +92,7 @@ if (paramLockID) { if (lockToRedirect) { lockID.value = lockToRedirect.lockID; tokenAmount.value = lockToRedirect.amount; - pixTarget.value = lockToRedirect.sellerAddress; + sellerAddress.value = lockToRedirect.sellerAddress; flowStep.value = Step.Buy; } else { flowStep.value = Step.Search; @@ -134,8 +135,6 @@ onMounted(async () => { />