fixed pixTarget treated as pixTimestamp
This commit is contained in:
parent
dd351acb2e
commit
23163be99d
@ -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<any> => {
|
||||
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
|
||||
});
|
||||
|
||||
|
@ -32,8 +32,8 @@ const getNetworksLiquidity = async (): Promise<void> => {
|
||||
};
|
||||
|
||||
const getParticipantID = async (
|
||||
seller: string,
|
||||
token: string
|
||||
seller: Address,
|
||||
token: Address
|
||||
): Promise<string> => {
|
||||
const { address, abi, client } = await getContract();
|
||||
|
||||
|
@ -18,7 +18,7 @@ const props = defineProps<Props>();
|
||||
const qrCode = ref<string>("");
|
||||
const qrCodeSvg = ref<string>("");
|
||||
const showWarnModal = ref<boolean>(true);
|
||||
const pixTarget = ref<string>("");
|
||||
const pixTimestamp = ref<string>("");
|
||||
const releaseSignature = ref<string>("");
|
||||
const solicitationData = ref<any>(null);
|
||||
const pollingInterval = ref<NodeJS.Timeout | null>(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 })
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user