From 23163be99d49099ec3ff5bdc07a0e328a86354eb Mon Sep 17 00:00:00 2001 From: hueso Date: Fri, 4 Jul 2025 21:09:32 -0300 Subject: [PATCH] fixed pixTarget treated as pixTimestamp --- src/blockchain/buyerMethods.ts | 10 +++------- src/blockchain/events.ts | 4 ++-- src/components/QrCodeComponent.vue | 6 +++--- src/utils/bbPay.ts | 6 +++--- src/views/HomeView.vue | 11 ++++------- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/blockchain/buyerMethods.ts b/src/blockchain/buyerMethods.ts index ec54e15..aa003ac 100644 --- a/src/blockchain/buyerMethods.ts +++ b/src/blockchain/buyerMethods.ts @@ -69,24 +69,20 @@ export const withdrawDeposit = async ( export const releaseLock = async ( lockID: bigint, - pixtarget: string, - signature: string + pixTimestamp: `0x${string}`&{lenght:34}, + signature: `0x${string}` ): Promise => { const { address, abi, wallet, client, account } = await getContract(); - console.log("Releasing lock", { lockID, pixtarget, signature }); if (!wallet) { throw new Error("Wallet not connected"); } - // Convert pixtarget to bytes32 - const pixTimestamp = keccak256(stringToHex(pixtarget, { size: 32 }) ); - const { request } = await client.simulateContract({ address, abi, functionName: "release", - args: [BigInt(lockID), pixTimestamp, stringToHex(signature)], + args: [BigInt(lockID), pixTimestamp, signature], account }); diff --git a/src/blockchain/events.ts b/src/blockchain/events.ts index 6c460a6..9251421 100644 --- a/src/blockchain/events.ts +++ b/src/blockchain/events.ts @@ -32,8 +32,8 @@ const getNetworksLiquidity = async (): Promise => { }; const getParticipantID = async ( - seller: string, - token: string + seller: Address, + token: Address ): Promise => { const { address, abi, client } = await getContract(); diff --git a/src/components/QrCodeComponent.vue b/src/components/QrCodeComponent.vue index 1fc446c..19f67ea 100644 --- a/src/components/QrCodeComponent.vue +++ b/src/components/QrCodeComponent.vue @@ -18,7 +18,7 @@ const props = defineProps(); const qrCode = ref(""); const qrCodeSvg = ref(""); const showWarnModal = ref(true); -const pixTarget = ref(""); +const pixTimestamp = ref(""); const releaseSignature = ref(""); const solicitationData = ref(null); const pollingInterval = ref(null); @@ -56,7 +56,7 @@ const checkSolicitationStatus = async () => { ); if (response.signature) { - pixTarget.value = response.pixTarget; + pixTimestamp.value = response.pixTimestamp; releaseSignature.value = response.signature; // Stop polling when payment is confirmed if (pollingInterval.value) { @@ -170,7 +170,7 @@ onUnmounted(() => { releaseSignature ? 'Enviar para a rede' : 'Validando pagamento...' " @button-clicked=" - emit('pixValidated', { pixTarget, signature: releaseSignature }) + emit('pixValidated', { pixTimestamp, signature: releaseSignature }) " /> diff --git a/src/utils/bbPay.ts b/src/utils/bbPay.ts index 6a0588f..2f049fe 100644 --- a/src/utils/bbPay.ts +++ b/src/utils/bbPay.ts @@ -61,15 +61,15 @@ export const createSolicitation = async (offer: Offer) => { return response.json(); }; -export const getSolicitation = async (id: string) => { +export const getSolicitation = async (id: bigint): Promise<{pixTimestamp: `0x${string}`, signature: `0x${string}`}> => { const response = await fetch( `${import.meta.env.VITE_APP_API_URL}/release/${id}` ); - const obj: any = await response.json(); + const obj = await response.json(); return { - pixTarget: obj.pixTarget, + pixTimestamp: obj.pixTimestamp, signature: obj.signature, }; }; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 3b4f00d..1799766 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -59,18 +59,15 @@ const confirmBuyClick = async ( } }; -const releaseTransaction = async ({ - pixTarget, - signature, -}: { - pixTarget: string; - signature: string; +const releaseTransaction = async (params: { + pixTimestamp: `0x${string}`&{lenght:34}, + signature: `0x${string}`, }) => { flowStep.value = Step.List; showBuyAlert.value = true; loadingRelease.value = true; - const release = await releaseLock(BigInt(lockID.value), pixTarget, signature); + const release = await releaseLock(BigInt(lockID.value), params.pixTimestamp, params.signature); await release.wait(); await updateWalletStatus();