fixed pixTarget treated as pixTimestamp

This commit is contained in:
hueso 2025-07-04 21:09:32 -03:00
parent dd351acb2e
commit 23163be99d
5 changed files with 15 additions and 22 deletions

View File

@ -69,24 +69,20 @@ export const withdrawDeposit = async (
export const releaseLock = async ( export const releaseLock = async (
lockID: bigint, lockID: bigint,
pixtarget: string, pixTimestamp: `0x${string}`&{lenght:34},
signature: string signature: `0x${string}`
): Promise<any> => { ): Promise<any> => {
const { address, abi, wallet, client, account } = await getContract(); const { address, abi, wallet, client, account } = await getContract();
console.log("Releasing lock", { lockID, pixtarget, signature });
if (!wallet) { if (!wallet) {
throw new Error("Wallet not connected"); throw new Error("Wallet not connected");
} }
// Convert pixtarget to bytes32
const pixTimestamp = keccak256(stringToHex(pixtarget, { size: 32 }) );
const { request } = await client.simulateContract({ const { request } = await client.simulateContract({
address, address,
abi, abi,
functionName: "release", functionName: "release",
args: [BigInt(lockID), pixTimestamp, stringToHex(signature)], args: [BigInt(lockID), pixTimestamp, signature],
account account
}); });

View File

@ -32,8 +32,8 @@ const getNetworksLiquidity = async (): Promise<void> => {
}; };
const getParticipantID = async ( const getParticipantID = async (
seller: string, seller: Address,
token: string token: Address
): Promise<string> => { ): Promise<string> => {
const { address, abi, client } = await getContract(); const { address, abi, client } = await getContract();

View File

@ -18,7 +18,7 @@ const props = defineProps<Props>();
const qrCode = ref<string>(""); const qrCode = ref<string>("");
const qrCodeSvg = ref<string>(""); const qrCodeSvg = ref<string>("");
const showWarnModal = ref<boolean>(true); const showWarnModal = ref<boolean>(true);
const pixTarget = ref<string>(""); const pixTimestamp = ref<string>("");
const releaseSignature = ref<string>(""); const releaseSignature = ref<string>("");
const solicitationData = ref<any>(null); const solicitationData = ref<any>(null);
const pollingInterval = ref<NodeJS.Timeout | null>(null); const pollingInterval = ref<NodeJS.Timeout | null>(null);
@ -56,7 +56,7 @@ const checkSolicitationStatus = async () => {
); );
if (response.signature) { if (response.signature) {
pixTarget.value = response.pixTarget; pixTimestamp.value = response.pixTimestamp;
releaseSignature.value = response.signature; releaseSignature.value = response.signature;
// Stop polling when payment is confirmed // Stop polling when payment is confirmed
if (pollingInterval.value) { if (pollingInterval.value) {
@ -170,7 +170,7 @@ onUnmounted(() => {
releaseSignature ? 'Enviar para a rede' : 'Validando pagamento...' releaseSignature ? 'Enviar para a rede' : 'Validando pagamento...'
" "
@button-clicked=" @button-clicked="
emit('pixValidated', { pixTarget, signature: releaseSignature }) emit('pixValidated', { pixTimestamp, signature: releaseSignature })
" "
/> />
</div> </div>

View File

@ -61,15 +61,15 @@ export const createSolicitation = async (offer: Offer) => {
return response.json(); 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( const response = await fetch(
`${import.meta.env.VITE_APP_API_URL}/release/${id}` `${import.meta.env.VITE_APP_API_URL}/release/${id}`
); );
const obj: any = await response.json(); const obj = await response.json();
return { return {
pixTarget: obj.pixTarget, pixTimestamp: obj.pixTimestamp,
signature: obj.signature, signature: obj.signature,
}; };
}; };

View File

@ -59,18 +59,15 @@ const confirmBuyClick = async (
} }
}; };
const releaseTransaction = async ({ const releaseTransaction = async (params: {
pixTarget, pixTimestamp: `0x${string}`&{lenght:34},
signature, signature: `0x${string}`,
}: {
pixTarget: string;
signature: string;
}) => { }) => {
flowStep.value = Step.List; flowStep.value = Step.List;
showBuyAlert.value = true; showBuyAlert.value = true;
loadingRelease.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 release.wait();
await updateWalletStatus(); await updateWalletStatus();