Adjust linter errors.
This commit is contained in:
parent
9fa2b34a5d
commit
4908dff58b
@ -10,7 +10,7 @@
|
||||
"coverage": "vitest run --coverage",
|
||||
"build-only": "vite build",
|
||||
"type-check": "vue-tsc --skipLibCheck --noEmit",
|
||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore",
|
||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --fix",
|
||||
"lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -58,11 +58,10 @@ export const getProviderByNetwork = (network: NetworkEnum) => {
|
||||
const chain = network === NetworkEnum.sepolia ? sepolia : rootstock;
|
||||
return createPublicClient({
|
||||
chain,
|
||||
transport: http(getProviderUrl(network))
|
||||
transport: http(getProviderUrl(network)),
|
||||
});
|
||||
};
|
||||
|
||||
export const isPossibleNetwork = (networkChain: NetworkEnum): boolean => {
|
||||
return Number(networkChain) in NetworkEnum;
|
||||
};
|
||||
|
||||
|
@ -1,14 +1,16 @@
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import { formatEther, decodeEventLog, parseAbi, toHex, type PublicClient, type Address } from "viem";
|
||||
import {
|
||||
formatEther,
|
||||
decodeEventLog,
|
||||
parseAbi,
|
||||
toHex,
|
||||
type PublicClient,
|
||||
} from "viem";
|
||||
|
||||
import p2pix from "@/utils/smart_contract_files/P2PIX.json";
|
||||
import { getContract } from "./provider";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import {
|
||||
getP2PixAddress,
|
||||
getProviderByNetwork,
|
||||
getTokenAddress,
|
||||
} from "./addresses";
|
||||
import { getTokenAddress } from "./addresses";
|
||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||
import type { UnreleasedLock } from "@/model/UnreleasedLock";
|
||||
import type { Pix } from "@/model/Pix";
|
||||
@ -37,16 +39,17 @@ const getNetworksLiquidity = async (): Promise<void> => {
|
||||
|
||||
const getPixKey = async (seller: string, token: string): Promise<string> => {
|
||||
const { address, abi, client } = await getContract();
|
||||
|
||||
|
||||
const pixKeyHex = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'getPixTarget',
|
||||
args: [seller, token]
|
||||
functionName: "getPixTarget",
|
||||
args: [seller, token],
|
||||
});
|
||||
|
||||
|
||||
// Remove '0x' prefix and convert hex to UTF-8 string
|
||||
const hexString = typeof pixKeyHex === 'string' ? pixKeyHex : toHex(pixKeyHex);
|
||||
const hexString =
|
||||
typeof pixKeyHex === "string" ? pixKeyHex : toHex(pixKeyHex);
|
||||
if (!hexString) throw new Error("PixKey not found");
|
||||
const bytes = new Uint8Array(
|
||||
// @ts-ignore
|
||||
@ -62,10 +65,10 @@ const getPixKey = async (seller: string, token: string): Promise<string> => {
|
||||
const getValidDeposits = async (
|
||||
token: string,
|
||||
network: NetworkEnum,
|
||||
contractInfo?: { client: any, address: string }
|
||||
contractInfo?: { client: any; address: string }
|
||||
): Promise<ValidDeposit[]> => {
|
||||
let client:PublicClient, address, abi;
|
||||
|
||||
let client: PublicClient, address, abi;
|
||||
|
||||
if (contractInfo) {
|
||||
({ client, address } = contractInfo);
|
||||
abi = p2pix.abi;
|
||||
@ -76,17 +79,17 @@ const getValidDeposits = async (
|
||||
const depositLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi([
|
||||
"event DepositAdded(address indexed seller, address token, uint256 amount)"
|
||||
"event DepositAdded(address indexed seller, address token, uint256 amount)",
|
||||
])[0],
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
|
||||
if (!contractInfo) {
|
||||
// Get metamask provider contract
|
||||
({ address, abi, client } = await getContract());
|
||||
}
|
||||
|
||||
|
||||
const depositList: { [key: string]: ValidDeposit } = {};
|
||||
|
||||
for (const log of depositLogs) {
|
||||
@ -94,19 +97,19 @@ const getValidDeposits = async (
|
||||
const decoded = decodeEventLog({
|
||||
abi,
|
||||
data: log.data,
|
||||
topics: log.topics
|
||||
topics: log.topics,
|
||||
});
|
||||
|
||||
|
||||
// Get liquidity only for the selected token
|
||||
if (decoded?.args.token.toLowerCase() !== token.toLowerCase()) continue;
|
||||
|
||||
|
||||
const mappedBalance = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'getBalance',
|
||||
args: [decoded.args.seller, token]
|
||||
functionName: "getBalance",
|
||||
args: [decoded.args.seller, token],
|
||||
});
|
||||
|
||||
|
||||
let validDeposit: ValidDeposit | null = null;
|
||||
|
||||
if (mappedBalance) {
|
||||
@ -139,8 +142,8 @@ const getUnreleasedLockById = async (
|
||||
const lock = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'mapLocks',
|
||||
args: [BigInt(lockID)]
|
||||
functionName: "mapLocks",
|
||||
args: [BigInt(lockID)],
|
||||
});
|
||||
|
||||
const pixTarget = lock.pixTarget;
|
||||
|
@ -13,8 +13,9 @@ const getPublicClient = (onlyRpcProvider = false) => {
|
||||
const user = useUser();
|
||||
const rpcUrl = getProviderUrl();
|
||||
return createPublicClient({
|
||||
chain: Number(user.networkName.value) === sepolia.id ? sepolia : rootstock,
|
||||
transport: http(rpcUrl)
|
||||
chain:
|
||||
Number(user.networkName.value) === sepolia.id ? sepolia : rootstock,
|
||||
transport: http(rpcUrl),
|
||||
});
|
||||
}
|
||||
return publicClient;
|
||||
@ -35,16 +36,17 @@ const getContract = async (onlyRpcProvider = false) => {
|
||||
const connectProvider = async (p: any): Promise<void> => {
|
||||
console.log("Connecting to provider...");
|
||||
const user = useUser();
|
||||
const chain = Number(user.networkName.value) === sepolia.id ? sepolia : rootstock;
|
||||
const chain =
|
||||
Number(user.networkName.value) === sepolia.id ? sepolia : rootstock;
|
||||
|
||||
publicClient = createPublicClient({
|
||||
chain,
|
||||
transport: custom(p)
|
||||
transport: custom(p),
|
||||
});
|
||||
|
||||
walletClient = createWalletClient({
|
||||
chain,
|
||||
transport: custom(p)
|
||||
transport: custom(p),
|
||||
});
|
||||
|
||||
await updateWalletStatus();
|
||||
|
@ -26,8 +26,8 @@ const approveTokens = async (participant: Participant): Promise<any> => {
|
||||
const allowance = await publicClient.readContract({
|
||||
address: tokenAddress,
|
||||
abi: mockToken.abi,
|
||||
functionName: 'allowance',
|
||||
args: [account, getP2PixAddress()]
|
||||
functionName: "allowance",
|
||||
args: [account, getP2PixAddress()],
|
||||
});
|
||||
|
||||
if (allowance < parseEther(participant.offer.toString())) {
|
||||
@ -35,9 +35,9 @@ const approveTokens = async (participant: Participant): Promise<any> => {
|
||||
const hash = await walletClient.writeContract({
|
||||
address: tokenAddress,
|
||||
abi: mockToken.abi,
|
||||
functionName: 'approve',
|
||||
functionName: "approve",
|
||||
args: [getP2PixAddress(), parseEther(participant.offer.toString())],
|
||||
account
|
||||
account,
|
||||
});
|
||||
|
||||
await publicClient.waitForTransactionReceipt({ hash });
|
||||
@ -63,15 +63,15 @@ const addDeposit = async (): Promise<any> => {
|
||||
const hash = await walletClient.writeContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'deposit',
|
||||
functionName: "deposit",
|
||||
args: [
|
||||
sellerId.id,
|
||||
toHex("", { size: 32 }),
|
||||
getTokenAddress(user.selectedToken.value),
|
||||
parseEther(user.seller.value.offer),
|
||||
true
|
||||
true,
|
||||
],
|
||||
account
|
||||
account,
|
||||
});
|
||||
|
||||
const receipt = await client.waitForTransactionReceipt({ hash });
|
||||
|
@ -1,16 +1,9 @@
|
||||
import {
|
||||
decodeEventLog,
|
||||
formatEther,
|
||||
getAddress,
|
||||
type Log,
|
||||
parseAbi,
|
||||
} from "viem";
|
||||
import { decodeEventLog, formatEther, type Log, parseAbi } from "viem";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
|
||||
import { getPublicClient, getWalletClient, getContract } from "./provider";
|
||||
import { getTokenAddress, isPossibleNetwork } from "./addresses";
|
||||
import { getTokenAddress } from "./addresses";
|
||||
|
||||
import mockToken from "@/utils/smart_contract_files/MockToken.json";
|
||||
import p2pix from "@/utils/smart_contract_files/P2PIX.json";
|
||||
|
||||
import { getValidDeposits } from "./events";
|
||||
@ -63,8 +56,8 @@ const getLockStatus = async (id: bigint): Promise<number> => {
|
||||
const result = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'getLocksStatus',
|
||||
args: [[id]]
|
||||
functionName: "getLocksStatus",
|
||||
args: [[id]],
|
||||
});
|
||||
return result[1][0];
|
||||
};
|
||||
@ -90,9 +83,7 @@ const filterLockStatus = async (
|
||||
const tx: WalletTransaction = {
|
||||
token: args.token ? String(args.token) : "",
|
||||
blockNumber: Number(transaction.blockNumber),
|
||||
amount: args.amount
|
||||
? Number(formatEther(args.amount))
|
||||
: -1,
|
||||
amount: args.amount ? Number(formatEther(args.amount)) : -1,
|
||||
seller: args.seller ? String(args.seller) : "",
|
||||
buyer: args.buyer ? String(args.buyer) : "",
|
||||
event: decoded.eventName || "",
|
||||
@ -116,53 +107,61 @@ const filterLockStatus = async (
|
||||
export const listAllTransactionByWalletAddress = async (
|
||||
walletAddress: string
|
||||
): Promise<WalletTransaction[]> => {
|
||||
const { address, abi, client } = await getContract(true);
|
||||
const { address, client } = await getContract(true);
|
||||
|
||||
// Get deposits
|
||||
const depositLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event DepositAdded(address indexed seller, address token, uint256 amount)'])[0],
|
||||
event: parseAbi([
|
||||
"event DepositAdded(address indexed seller, address token, uint256 amount)",
|
||||
])[0],
|
||||
args: {
|
||||
seller: walletAddress
|
||||
seller: walletAddress,
|
||||
},
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
console.log("Fetched all wallet deposits");
|
||||
|
||||
// Get locks
|
||||
const lockLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event LockAdded(address indexed buyer, uint256 indexed lockID, address seller, address token, uint256 amount)'])[0],
|
||||
event: parseAbi([
|
||||
"event LockAdded(address indexed buyer, uint256 indexed lockID, address seller, address token, uint256 amount)",
|
||||
])[0],
|
||||
args: {
|
||||
buyer: walletAddress
|
||||
buyer: walletAddress,
|
||||
},
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
console.log("Fetched all wallet locks");
|
||||
|
||||
// Get released locks
|
||||
const releasedLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event LockReleased(address indexed buyer, uint256 indexed lockID, string e2eId)'])[0],
|
||||
event: parseAbi([
|
||||
"event LockReleased(address indexed buyer, uint256 indexed lockID, string e2eId)",
|
||||
])[0],
|
||||
args: {
|
||||
buyer: walletAddress
|
||||
buyer: walletAddress,
|
||||
},
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
console.log("Fetched all wallet released locks");
|
||||
|
||||
// Get withdrawn deposits
|
||||
const withdrawnLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event DepositWithdrawn(address indexed seller, address token, uint256 amount)'])[0],
|
||||
event: parseAbi([
|
||||
"event DepositWithdrawn(address indexed seller, address token, uint256 amount)",
|
||||
])[0],
|
||||
args: {
|
||||
seller: walletAddress
|
||||
seller: walletAddress,
|
||||
},
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
console.log("Fetched all wallet withdrawn deposits");
|
||||
|
||||
@ -170,7 +169,7 @@ export const listAllTransactionByWalletAddress = async (
|
||||
...depositLogs,
|
||||
...lockLogs,
|
||||
...releasedLogs,
|
||||
...withdrawnLogs
|
||||
...withdrawnLogs,
|
||||
].sort((a: Log, b: Log) => {
|
||||
return Number(b.blockNumber) - Number(a.blockNumber);
|
||||
});
|
||||
@ -182,16 +181,18 @@ export const listAllTransactionByWalletAddress = async (
|
||||
export const listReleaseTransactionByWalletAddress = async (
|
||||
walletAddress: string
|
||||
) => {
|
||||
const { address, abi, client } = await getContract(true);
|
||||
const { address, client } = await getContract(true);
|
||||
|
||||
const releasedLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event LockReleased(address indexed buyer, uint256 indexed lockID, string e2eId)'])[0],
|
||||
event: parseAbi([
|
||||
"event LockReleased(address indexed buyer, uint256 indexed lockID, string e2eId)",
|
||||
])[0],
|
||||
args: {
|
||||
buyer: walletAddress
|
||||
buyer: walletAddress,
|
||||
},
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
|
||||
return releasedLogs
|
||||
@ -203,7 +204,7 @@ export const listReleaseTransactionByWalletAddress = async (
|
||||
return decodeEventLog({
|
||||
abi: p2pix.abi,
|
||||
data: log.data,
|
||||
topics: log.topics
|
||||
topics: log.topics,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error decoding log", error);
|
||||
@ -213,19 +214,19 @@ export const listReleaseTransactionByWalletAddress = async (
|
||||
.filter((decoded: any) => decoded !== null);
|
||||
};
|
||||
|
||||
const listLockTransactionByWalletAddress = async (
|
||||
walletAddress: string
|
||||
) => {
|
||||
const { address, abi, client } = await getContract(true);
|
||||
const listLockTransactionByWalletAddress = async (walletAddress: string) => {
|
||||
const { address, client } = await getContract(true);
|
||||
|
||||
const lockLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event LockAdded(address indexed buyer, uint256 indexed lockID, address seller, address token, uint256 amount)'])[0],
|
||||
event: parseAbi([
|
||||
"event LockAdded(address indexed buyer, uint256 indexed lockID, address seller, address token, uint256 amount)",
|
||||
])[0],
|
||||
args: {
|
||||
buyer: walletAddress
|
||||
buyer: walletAddress,
|
||||
},
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
|
||||
return lockLogs
|
||||
@ -237,7 +238,7 @@ const listLockTransactionByWalletAddress = async (
|
||||
return decodeEventLog({
|
||||
abi: p2pix.abi,
|
||||
data: log.data,
|
||||
topics: log.topics
|
||||
topics: log.topics,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error decoding log", error);
|
||||
@ -247,17 +248,17 @@ const listLockTransactionByWalletAddress = async (
|
||||
.filter((decoded: any) => decoded !== null);
|
||||
};
|
||||
|
||||
const listLockTransactionBySellerAddress = async (
|
||||
sellerAddress: string
|
||||
) => {
|
||||
const { address, abi, client } = await getContract(true);
|
||||
const listLockTransactionBySellerAddress = async (sellerAddress: string) => {
|
||||
const { address, client } = await getContract(true);
|
||||
console.log("Will get locks as seller", sellerAddress);
|
||||
|
||||
const lockLogs = await client.getLogs({
|
||||
address,
|
||||
event: parseAbi(['event LockAdded(address indexed buyer, uint256 indexed lockID, address seller, address token, uint256 amount)'])[0],
|
||||
event: parseAbi([
|
||||
"event LockAdded(address indexed buyer, uint256 indexed lockID, address seller, address token, uint256 amount)",
|
||||
])[0],
|
||||
fromBlock: 0n,
|
||||
toBlock: 'latest'
|
||||
toBlock: "latest",
|
||||
});
|
||||
|
||||
return lockLogs
|
||||
@ -266,7 +267,7 @@ const listLockTransactionBySellerAddress = async (
|
||||
return decodeEventLog({
|
||||
abi: p2pix.abi,
|
||||
data: log.data,
|
||||
topics: log.topics
|
||||
topics: log.topics,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error decoding log", error);
|
||||
@ -275,7 +276,9 @@ const listLockTransactionBySellerAddress = async (
|
||||
})
|
||||
.filter((decoded: any) => decoded !== null)
|
||||
.filter(
|
||||
(decoded: any) => decoded.args && decoded.args.seller &&
|
||||
(decoded: any) =>
|
||||
decoded.args &&
|
||||
decoded.args.seller &&
|
||||
decoded.args.seller.toLowerCase() === sellerAddress.toLowerCase()
|
||||
);
|
||||
};
|
||||
@ -297,8 +300,8 @@ export const checkUnreleasedLock = async (
|
||||
const lockStatus = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'getLocksStatus',
|
||||
args: [lockIds]
|
||||
functionName: "getLocksStatus",
|
||||
args: [lockIds],
|
||||
});
|
||||
|
||||
const unreleasedLockId = lockStatus[1].findIndex(
|
||||
@ -311,8 +314,8 @@ export const checkUnreleasedLock = async (
|
||||
const lock = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'mapLocks',
|
||||
args: [lockID]
|
||||
functionName: "mapLocks",
|
||||
args: [lockID],
|
||||
});
|
||||
|
||||
const pixTarget = lock.pixTarget;
|
||||
@ -340,8 +343,8 @@ export const getActiveLockAmount = async (
|
||||
const lockStatus = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'getLocksStatus',
|
||||
args: [lockIds]
|
||||
functionName: "getLocksStatus",
|
||||
args: [lockIds],
|
||||
});
|
||||
|
||||
let activeLockAmount = 0;
|
||||
@ -351,8 +354,8 @@ export const getActiveLockAmount = async (
|
||||
const lock = await client.readContract({
|
||||
address,
|
||||
abi,
|
||||
functionName: 'mapLocks',
|
||||
args: [lockId]
|
||||
functionName: "mapLocks",
|
||||
args: [lockId],
|
||||
});
|
||||
activeLockAmount += Number(formatEther(lock.amount));
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import CustomButton from "@/components/CustomButton/CustomButton.vue";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import type { WalletTransaction } from "@/model/WalletTransaction";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import ListingComponent from "../ListingComponent/ListingComponent.vue";
|
||||
|
||||
@ -151,6 +150,8 @@ p {
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
appearance: textfield;
|
||||
-webkit-appearance: textfield;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { withdrawDeposit } from "@/blockchain/buyerMethods";
|
||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import type { WalletTransaction } from "@/model/WalletTransaction";
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { describe, expect, beforeEach } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import ListingComponent from "../ListingComponent.vue";
|
||||
import SpinnerComponent from "../../SpinnerComponent.vue";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import { MockValidDeposits } from "@/model/mock/ValidDepositMock";
|
||||
import { MockWalletTransactions } from "@/model/mock/WalletTransactionMock";
|
||||
|
@ -2,14 +2,6 @@
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
import CustomButton from "@/components/CustomButton/CustomButton.vue";
|
||||
import CustomModal from "@/components//CustomModal/CustomModal.vue";
|
||||
import QRCode from "qrcode";
|
||||
|
||||
// props and store references
|
||||
const props = defineProps({
|
||||
sellerId: String,
|
||||
amount: Number,
|
||||
qrcode: String,
|
||||
});
|
||||
|
||||
const windowSize = ref<number>(window.innerWidth);
|
||||
const qrCode = ref<string>("");
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from "vue";
|
||||
import { ref, watch } from "vue";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import SpinnerComponent from "@/components/SpinnerComponent.vue";
|
||||
import CustomButton from "@/components/CustomButton/CustomButton.vue";
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { ref, computed } from "vue";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import CustomButton from "@/components/CustomButton/CustomButton.vue";
|
||||
import { pixFormatValidation, postProcessKey } from "@/utils/pixKeyFormat";
|
||||
import { postProcessKey } from "@/utils/pixKeyFormat";
|
||||
import { TokenEnum } from "@/model/NetworkEnum";
|
||||
import { getTokenImage } from "@/utils/imagesPath";
|
||||
import { useOnboard } from "@web3-onboard/vue";
|
||||
|
@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import SpinnerComponent from "@/components/SpinnerComponent.vue";
|
||||
import CustomButton from "@/components/CustomButton/CustomButton.vue";
|
||||
import { debounce } from "@/utils/debounce";
|
||||
import { decimalCount } from "@/utils/decimalCount";
|
||||
@ -153,6 +152,8 @@ const handleInputEvent = (event: any): void => {
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
appearance: textfield;
|
||||
-webkit-appearance: textfield;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,8 @@ p {
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
appearance: textfield;
|
||||
-webkit-appearance: textfield;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, watchEffect } from "vue";
|
||||
import { ref, computed, watch, onMounted } from "vue";
|
||||
import { useOnboard } from "@web3-onboard/vue";
|
||||
import { Networks } from "../model/Networks";
|
||||
import { NetworkEnum } from "../model/NetworkEnum";
|
||||
|
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import { onClickOutside } from "@vueuse/core";
|
||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import TopBar from "../TopBar.vue";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
|
@ -1,74 +1,73 @@
|
||||
import { ref } from 'vue'
|
||||
import { NetworkEnum, TokenEnum } from "../model/NetworkEnum"
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit"
|
||||
import type { Participant } from "../utils/bbPay"
|
||||
import { ref } from "vue";
|
||||
import { NetworkEnum, TokenEnum } from "../model/NetworkEnum";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import type { Participant } from "../utils/bbPay";
|
||||
|
||||
const walletAddress = ref("")
|
||||
const balance = ref("")
|
||||
const networkName = ref(NetworkEnum.sepolia)
|
||||
const selectedToken = ref(TokenEnum.BRZ)
|
||||
const loadingLock = ref(false)
|
||||
const sellerView = ref(false)
|
||||
const depositsValidList = ref<ValidDeposit[]>([])
|
||||
const loadingWalletTransactions = ref(false)
|
||||
const loadingNetworkLiquidity = ref(false)
|
||||
const seller = ref<Participant>({} as Participant)
|
||||
const sellerId = ref("")
|
||||
const walletAddress = ref("");
|
||||
const balance = ref("");
|
||||
const networkName = ref(NetworkEnum.sepolia);
|
||||
const selectedToken = ref(TokenEnum.BRZ);
|
||||
const loadingLock = ref(false);
|
||||
const sellerView = ref(false);
|
||||
const depositsValidList = ref<ValidDeposit[]>([]);
|
||||
const loadingWalletTransactions = ref(false);
|
||||
const loadingNetworkLiquidity = ref(false);
|
||||
const seller = ref<Participant>({} as Participant);
|
||||
const sellerId = ref("");
|
||||
|
||||
export function useUser() {
|
||||
|
||||
// Actions become regular functions
|
||||
const setWalletAddress = (address: string) => {
|
||||
walletAddress.value = address
|
||||
}
|
||||
walletAddress.value = address;
|
||||
};
|
||||
|
||||
const setBalance = (newBalance: string) => {
|
||||
balance.value = newBalance
|
||||
}
|
||||
balance.value = newBalance;
|
||||
};
|
||||
|
||||
const setSelectedToken = (token: TokenEnum) => {
|
||||
selectedToken.value = token
|
||||
}
|
||||
selectedToken.value = token;
|
||||
};
|
||||
|
||||
const setNetworkId = (network: NetworkEnum) => {
|
||||
console.log("setNetworkId", network)
|
||||
networkName.value = Number(network)
|
||||
}
|
||||
console.log("setNetworkId", network);
|
||||
networkName.value = Number(network);
|
||||
};
|
||||
|
||||
const setLoadingLock = (isLoading: boolean) => {
|
||||
loadingLock.value = isLoading
|
||||
}
|
||||
loadingLock.value = isLoading;
|
||||
};
|
||||
|
||||
const setSellerView = (view: boolean) => {
|
||||
sellerView.value = view
|
||||
}
|
||||
sellerView.value = view;
|
||||
};
|
||||
|
||||
const setDepositsValidList = (deposits: ValidDeposit[]) => {
|
||||
depositsValidList.value = deposits
|
||||
}
|
||||
depositsValidList.value = deposits;
|
||||
};
|
||||
|
||||
const setLoadingWalletTransactions = (isLoading: boolean) => {
|
||||
loadingWalletTransactions.value = isLoading
|
||||
}
|
||||
loadingWalletTransactions.value = isLoading;
|
||||
};
|
||||
|
||||
const setLoadingNetworkLiquidity = (isLoading: boolean) => {
|
||||
loadingNetworkLiquidity.value = isLoading
|
||||
}
|
||||
loadingNetworkLiquidity.value = isLoading;
|
||||
};
|
||||
|
||||
const setSeller = (newSeller: Participant) => {
|
||||
seller.value = newSeller
|
||||
}
|
||||
seller.value = newSeller;
|
||||
};
|
||||
|
||||
const setSellerId = (id: string) => {
|
||||
sellerId.value = id
|
||||
}
|
||||
sellerId.value = id;
|
||||
};
|
||||
|
||||
// Getters become computed or regular functions
|
||||
const getValidDepositByWalletAddress = (address: string) => {
|
||||
return depositsValidList.value
|
||||
.filter((deposit) => deposit.seller == address)
|
||||
.sort((a, b) => b.blockNumber - a.blockNumber)
|
||||
}
|
||||
.sort((a, b) => b.blockNumber - a.blockNumber);
|
||||
};
|
||||
|
||||
return {
|
||||
// State
|
||||
@ -98,6 +97,6 @@ export function useUser() {
|
||||
setSellerId,
|
||||
|
||||
// Getters
|
||||
getValidDepositByWalletAddress
|
||||
}
|
||||
}
|
||||
getValidDepositByWalletAddress,
|
||||
};
|
||||
}
|
||||
|
@ -33,7 +33,10 @@ const showModal = ref<boolean>(false);
|
||||
const showBuyAlert = ref<boolean>(false);
|
||||
const paramLockID = window.history.state?.lockID;
|
||||
|
||||
const confirmBuyClick = async (selectedDeposit: ValidDeposit, tokenValue: number) => {
|
||||
const confirmBuyClick = async (
|
||||
selectedDeposit: ValidDeposit,
|
||||
tokenValue: number
|
||||
) => {
|
||||
pixTarget.value = selectedDeposit.pixKey;
|
||||
tokenAmount.value = tokenValue;
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { ref } from "vue";
|
||||
|
||||
import SellerComponent from "@/components/SellerSteps/SellerComponent.vue";
|
||||
import SearchComponent from "@/components/SearchComponent.vue";
|
||||
import SendNetwork from "@/components/SellerSteps/SendNetwork.vue";
|
||||
import SellerSearchComponent from "@/components/SellerSteps/SellerSearchComponent.vue";
|
||||
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
|
||||
import { useUser } from "@/composables/useUser";
|
||||
import { approveTokens, addDeposit } from "@/blockchain/sellerMethods";
|
||||
|
@ -27,7 +27,7 @@
|
||||
],
|
||||
"preserveValueImports": false,
|
||||
"importsNotUsedAsValues": "remove",
|
||||
"verbatimModuleSyntax": true
|
||||
"verbatimModuleSyntax": false
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
@ -38,4 +38,4 @@
|
||||
"node_modules",
|
||||
"./node_modules"
|
||||
]
|
||||
}
|
||||
}
|
@ -36,6 +36,9 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
"viem/errors": fileURLToPath(
|
||||
new URL("./node_modules/viem/errors", import.meta.url)
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user