-
-
{{blockchain.formatBigNumber(deposit?.args.amount)}} BRZ
-
{{deposit?.event == 'DepositAdded' ? 'Depósito' : deposit?.event == 'LockAdded' ? 'Reserva' : 'Compra'}}
-
+
+
+ {{ blockchain.formatBigNumber(deposit?.args.amount) }} BRZ
+
+
+ {{
+ deposit?.event == "DepositAdded"
+ ? "Depósito"
+ : deposit?.event == "LockAdded"
+ ? "Reserva"
+ : "Compra"
+ }}
+
+
Etherscan
-

+
-
Não há nenhuma transação anterior
+
+ Não há nenhuma transação anterior
+
@@ -97,7 +114,7 @@ const props = defineProps({
}
p {
- @apply text-gray-900
+ @apply text-gray-900;
}
.text-container {
@@ -115,8 +132,8 @@ p {
@apply flex flex-col justify-center items-center px-8 py-6 gap-2 rounded-lg shadow-md shadow-gray-600 backdrop-blur-md mt-8 w-1/3;
}
-.last-deposit-info{
- @apply font-medium text-base
+.last-deposit-info {
+ @apply font-medium text-base;
}
input[type="number"] {
diff --git a/src/components/QrCodeComponent.vue b/src/components/QrCodeComponent.vue
index de3f84a..c9e3753 100644
--- a/src/components/QrCodeComponent.vue
+++ b/src/components/QrCodeComponent.vue
@@ -5,6 +5,7 @@ import { debounce } from "@/utils/debounce";
import CustomButton from "./CustomButton.vue";
import api from "../services/index";
+// props and store references
const props = defineProps({
pixTarget: String,
tokenValue: Number,
@@ -12,13 +13,17 @@ const props = defineProps({
const qrCode = ref
("");
const qrCodePayload = ref("");
+const isPixValid = ref(false);
+const isCodeInputEmpty = ref(true);
+const e2eId = ref("");
+
+// Emits
+const emit = defineEmits(["pixValidated"]);
+
const pixQrCode = pix({
pixKey: props.pixTarget ?? "",
value: props.tokenValue,
});
-const isPixValid = ref(false);
-const isCodeInputEmpty = ref(true);
-
pixQrCode.base64QrCode().then((code: string) => {
qrCode.value = code;
});
@@ -27,12 +32,12 @@ qrCodePayload.value = pixQrCode.payload();
const handleInputEvent = (event: any) => {
const { value } = event.target;
-
- validatePix(value);
+ e2eId.value = value;
+ validatePix();
};
-const validatePix = async (e2eid: any) => {
- if (e2eid == "") {
+const validatePix = async () => {
+ if (e2eId.value == "") {
isPixValid.value = false;
isCodeInputEmpty.value = true;
return;
@@ -42,7 +47,7 @@ const validatePix = async (e2eid: any) => {
if (sellerPixKey && transactionValue) {
var body_req = {
- e2e_id: e2eid,
+ e2e_id: e2eId.value,
pix_key: sellerPixKey,
pix_value: transactionValue,
};
@@ -64,6 +69,7 @@ const validatePix = async (e2eid: any) => {
diff --git a/src/utils/blockchain.ts b/src/utils/blockchain.ts
index 7e86049..fbc332e 100644
--- a/src/utils/blockchain.ts
+++ b/src/utils/blockchain.ts
@@ -222,6 +222,7 @@ const addLock = async (depositId: Number, amount: Number) => {
lock.wait();
updateLockAddedEvents();
+ return lock;
};
// Get specific lock data by its ID
@@ -270,6 +271,7 @@ const releaseLock = async (
release.wait();
updateLockReleasedEvents();
+ return release
};
// Formatting methods
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index 383a77a..d39443c 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -21,10 +21,11 @@ enum Step {
// States
const etherStore = useEtherStore();
-const { loadingLock, walletAddress } = storeToRefs(etherStore);
+const { loadingLock, walletAddress, locksAddedList } = storeToRefs(etherStore);
const flowStep = ref(Step.Search);
const pixTarget = ref("");
-const tokenAmmount = ref();
+const tokenAmount = ref();
+const lockTransactionHash = ref("");
const loadingRelease = ref(false);
const lastWalletTransactions = ref([]);
@@ -36,7 +37,7 @@ const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => {
await blockchain
.mapDeposits(depositId)
.then((deposit) => (depositDetail = deposit));
- tokenAmmount.value = tokenValue;
+ tokenAmount.value = tokenValue;
pixTarget.value = depositDetail?.pixTarget;
// Makes lock with deposit ID and the Amount
@@ -44,7 +45,12 @@ const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => {
flowStep.value = Step.Buy;
etherStore.setLoadingLock(true);
- await blockchain.addLock(depositId, tokenValue).catch(() => {
+ await blockchain.addLock(depositId, tokenValue)
+ .then((lock) => {
+ console.log(lock)
+ lockTransactionHash.value = lock.hash
+ })
+ .catch(() => {
flowStep.value = Step.Search;
});
@@ -67,17 +73,24 @@ const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => {
}
};
-const releaseTransaction = async ({ pixE2Eid }: any) => {
- console.log("release: ", pixE2Eid);
+const releaseTransaction = async ({ e2eId }: any) => {
+ console.log(e2eId);
flowStep.value = Step.List;
loadingRelease.value = true;
+ console.log(lockTransactionHash.value);
+ console.log(locksAddedList.value);
+
+ // make lock release
+ // need to find lockId
+ // const release = await blockchain.releaseLock(pixTarget.value, String(tokenAmount.value), Number(e2eId), lockTransactionHash.value)
+ // console.log(release);
lastWalletTransactions.value =
await blockchain.listTransactionByWalletAddress(
walletAddress.value.toLowerCase()
);
- setTimeout(() => (loadingRelease.value = false), 2000);
+ loadingRelease.value = false
};
@@ -89,7 +102,7 @@ const releaseTransaction = async ({ pixE2Eid }: any) => {
@@ -99,7 +112,7 @@ const releaseTransaction = async ({ pixE2Eid }: any) => {
/>
-
+