Refactored variable names to be concise.
This commit is contained in:
parent
cf61f5ecfd
commit
81c8b04c7a
@ -29,10 +29,13 @@ const getNetworksLiquidity = async (): Promise<void> => {
|
|||||||
user.setLoadingNetworkLiquidity(false);
|
user.setLoadingNetworkLiquidity(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPixKey = async (seller: string, token: string): Promise<string> => {
|
const getParticipantID = async (
|
||||||
|
seller: string,
|
||||||
|
token: string
|
||||||
|
): Promise<string> => {
|
||||||
const { address, abi, client } = await getContract();
|
const { address, abi, client } = await getContract();
|
||||||
|
|
||||||
const pixKeyHex = await client.readContract({
|
const participantIDHex = await client.readContract({
|
||||||
address: address as `0x${string}`,
|
address: address as `0x${string}`,
|
||||||
abi,
|
abi,
|
||||||
functionName: "getPixTarget",
|
functionName: "getPixTarget",
|
||||||
@ -41,8 +44,10 @@ const getPixKey = async (seller: string, token: string): Promise<string> => {
|
|||||||
|
|
||||||
// Remove '0x' prefix and convert hex to UTF-8 string
|
// Remove '0x' prefix and convert hex to UTF-8 string
|
||||||
const hexString =
|
const hexString =
|
||||||
typeof pixKeyHex === "string" ? pixKeyHex : toHex(pixKeyHex as bigint);
|
typeof participantIDHex === "string"
|
||||||
if (!hexString) throw new Error("PixKey not found");
|
? participantIDHex
|
||||||
|
: toHex(participantIDHex as bigint);
|
||||||
|
if (!hexString) throw new Error("Participant ID not found");
|
||||||
const bytes = new Uint8Array(
|
const bytes = new Uint8Array(
|
||||||
hexString
|
hexString
|
||||||
.slice(2)
|
.slice(2)
|
||||||
@ -133,7 +138,7 @@ const getValidDeposits = async (
|
|||||||
remaining: Number(formatEther(mappedBalance.result as bigint)),
|
remaining: Number(formatEther(mappedBalance.result as bigint)),
|
||||||
seller: seller,
|
seller: seller,
|
||||||
network,
|
network,
|
||||||
pixKey: "",
|
participantID: "",
|
||||||
};
|
};
|
||||||
depositList[seller + token] = validDeposit;
|
depositList[seller + token] = validDeposit;
|
||||||
}
|
}
|
||||||
@ -177,5 +182,5 @@ export {
|
|||||||
getValidDeposits,
|
getValidDeposits,
|
||||||
getNetworksLiquidity,
|
getNetworksLiquidity,
|
||||||
getUnreleasedLockById,
|
getUnreleasedLockById,
|
||||||
getPixKey,
|
getParticipantID,
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ const selectedDeposits = ref<ValidDeposit[]>();
|
|||||||
|
|
||||||
import ChevronDown from "@/assets/chevronDown.svg";
|
import ChevronDown from "@/assets/chevronDown.svg";
|
||||||
import { useOnboard } from "@web3-onboard/vue";
|
import { useOnboard } from "@web3-onboard/vue";
|
||||||
import { getPixKey } from "@/blockchain/events";
|
import { getParticipantID } from "@/blockchain/events";
|
||||||
|
|
||||||
// Emits
|
// Emits
|
||||||
const emit = defineEmits(["tokenBuy"]);
|
const emit = defineEmits(["tokenBuy"]);
|
||||||
@ -54,7 +54,7 @@ const emitConfirmButton = async (): Promise<void> => {
|
|||||||
(d) => d.network === Number(networkName.value)
|
(d) => d.network === Number(networkName.value)
|
||||||
);
|
);
|
||||||
if (!deposit) return;
|
if (!deposit) return;
|
||||||
deposit.pixKey = await getPixKey(deposit.seller, deposit.token);
|
deposit.participantID = await getParticipantID(deposit.seller, deposit.token);
|
||||||
emit("tokenBuy", deposit, tokenValue.value);
|
emit("tokenBuy", deposit, tokenValue.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ export type ValidDeposit = {
|
|||||||
blockNumber: number;
|
blockNumber: number;
|
||||||
remaining: number;
|
remaining: number;
|
||||||
seller: string;
|
seller: string;
|
||||||
pixKey: string;
|
participantID: string;
|
||||||
network: NetworkEnum;
|
network: NetworkEnum;
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ export const MockValidDeposits: ValidDeposit[] = [
|
|||||||
token: "1",
|
token: "1",
|
||||||
remaining: 70,
|
remaining: 70,
|
||||||
seller: "mockedSellerAddress",
|
seller: "mockedSellerAddress",
|
||||||
pixKey: "123456789",
|
participantID: "123456789",
|
||||||
network: NetworkEnum.sepolia,
|
network: NetworkEnum.sepolia,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -15,7 +15,7 @@ export const MockValidDeposits: ValidDeposit[] = [
|
|||||||
token: "2",
|
token: "2",
|
||||||
remaining: 200,
|
remaining: 200,
|
||||||
seller: "mockedSellerAddress",
|
seller: "mockedSellerAddress",
|
||||||
pixKey: "123456789",
|
participantID: "123456789",
|
||||||
network: NetworkEnum.sepolia,
|
network: NetworkEnum.sepolia,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@ export const MockValidDeposits: ValidDeposit[] = [
|
|||||||
token: "3",
|
token: "3",
|
||||||
remaining: 1250,
|
remaining: 1250,
|
||||||
seller: "mockedSellerAddress",
|
seller: "mockedSellerAddress",
|
||||||
pixKey: "123456789",
|
participantID: "123456789",
|
||||||
network: NetworkEnum.sepolia,
|
network: NetworkEnum.sepolia,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ export const MockValidDeposits: ValidDeposit[] = [
|
|||||||
token: "4",
|
token: "4",
|
||||||
remaining: 4000,
|
remaining: 4000,
|
||||||
seller: "mockedSellerAddress",
|
seller: "mockedSellerAddress",
|
||||||
pixKey: "123456789",
|
participantID: "123456789",
|
||||||
network: NetworkEnum.sepolia,
|
network: NetworkEnum.sepolia,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ export const MockValidDeposits: ValidDeposit[] = [
|
|||||||
token: "5",
|
token: "5",
|
||||||
remaining: 2000,
|
remaining: 2000,
|
||||||
seller: "mockedSellerAddress",
|
seller: "mockedSellerAddress",
|
||||||
pixKey: "123456789",
|
participantID: "123456789",
|
||||||
network: NetworkEnum.sepolia,
|
network: NetworkEnum.sepolia,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { off } from "process";
|
|
||||||
|
|
||||||
export interface Participant {
|
export interface Participant {
|
||||||
offer: string;
|
offer: string;
|
||||||
chainID: number;
|
chainID: number;
|
||||||
|
@ -25,7 +25,8 @@ user.setSellerView(false);
|
|||||||
// States
|
// States
|
||||||
const { loadingLock, walletAddress, networkName } = user;
|
const { loadingLock, walletAddress, networkName } = user;
|
||||||
const flowStep = ref<Step>(Step.Search);
|
const flowStep = ref<Step>(Step.Search);
|
||||||
const pixTarget = ref<string>();
|
const participantID = ref<string>();
|
||||||
|
const sellerAddress = ref<`0x${string}` | undefined>();
|
||||||
const tokenAmount = ref<number>();
|
const tokenAmount = ref<number>();
|
||||||
const lockID = ref<string>("");
|
const lockID = ref<string>("");
|
||||||
const loadingRelease = ref<boolean>(false);
|
const loadingRelease = ref<boolean>(false);
|
||||||
@ -37,7 +38,7 @@ const confirmBuyClick = async (
|
|||||||
selectedDeposit: ValidDeposit,
|
selectedDeposit: ValidDeposit,
|
||||||
tokenValue: number
|
tokenValue: number
|
||||||
) => {
|
) => {
|
||||||
pixTarget.value = selectedDeposit.pixKey;
|
participantID.value = selectedDeposit.participantID;
|
||||||
tokenAmount.value = tokenValue;
|
tokenAmount.value = tokenValue;
|
||||||
|
|
||||||
if (selectedDeposit) {
|
if (selectedDeposit) {
|
||||||
@ -78,7 +79,7 @@ const checkForUnreleasedLocks = async (): Promise<void> => {
|
|||||||
if (lock) {
|
if (lock) {
|
||||||
lockID.value = lock.lockID;
|
lockID.value = lock.lockID;
|
||||||
tokenAmount.value = lock.amount;
|
tokenAmount.value = lock.amount;
|
||||||
pixTarget.value = lock.sellerAddress;
|
sellerAddress.value = lock.sellerAddress;
|
||||||
showModal.value = true;
|
showModal.value = true;
|
||||||
} else {
|
} else {
|
||||||
flowStep.value = Step.Search;
|
flowStep.value = Step.Search;
|
||||||
@ -91,7 +92,7 @@ if (paramLockID) {
|
|||||||
if (lockToRedirect) {
|
if (lockToRedirect) {
|
||||||
lockID.value = lockToRedirect.lockID;
|
lockID.value = lockToRedirect.lockID;
|
||||||
tokenAmount.value = lockToRedirect.amount;
|
tokenAmount.value = lockToRedirect.amount;
|
||||||
pixTarget.value = lockToRedirect.sellerAddress;
|
sellerAddress.value = lockToRedirect.sellerAddress;
|
||||||
flowStep.value = Step.Buy;
|
flowStep.value = Step.Buy;
|
||||||
} else {
|
} else {
|
||||||
flowStep.value = Step.Search;
|
flowStep.value = Step.Search;
|
||||||
@ -134,8 +135,6 @@ onMounted(async () => {
|
|||||||
/>
|
/>
|
||||||
<div v-if="flowStep == Step.Buy">
|
<div v-if="flowStep == Step.Buy">
|
||||||
<QrCodeComponent
|
<QrCodeComponent
|
||||||
:sellerId="String(pixTarget)"
|
|
||||||
:amount="tokenAmount || 0"
|
|
||||||
:lockID="lockID"
|
:lockID="lockID"
|
||||||
@pix-validated="releaseTransaction"
|
@pix-validated="releaseTransaction"
|
||||||
v-if="!loadingLock"
|
v-if="!loadingLock"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user