diff --git a/src/queries/request.ts b/src/queries/request.ts index 7ad2bd2..17fb78b 100644 --- a/src/queries/request.ts +++ b/src/queries/request.ts @@ -157,6 +157,16 @@ export const metaletApiV3 = (path: string) => { } } +export const metaletApiV4 = (path: string) => { + const metaletHost = METALET_HOST + '/wallet-api/v4' + return { + get: (params?: OptionParams) => + metaletV3Request(`${metaletHost}${path}`, { method: 'GET', params, withCredential: true }), + post: (data?: OptionData) => + metaletV3Request(`${metaletHost}${path}`, { method: 'POST', data, withCredential: true }), + } +} + export const ordinalsApi = (path: string) => { const url = path.includes(ORDINALS_HOST) ? path : `${ORDINALS_HOST}${path}` return { diff --git a/src/queries/utxos.ts b/src/queries/utxos.ts index d64fc58..df82b29 100644 --- a/src/queries/utxos.ts +++ b/src/queries/utxos.ts @@ -2,11 +2,10 @@ import { Chain } from '@/lib/types' import { MRC20UTXO } from './mrc20' import { getNet } from '@/lib/network' import { Ref, ComputedRef } from 'vue' -import { getSafeUtxos } from '@/lib/utxo' import { useQuery } from '@tanstack/vue-query' import { UNISAT_ENABLED } from '@/data/config' import { fetchBtcTxHex } from '@/queries/transaction' -import { mvcApi, mempoolApi, metaletApiV3, unisatApi } from './request' +import { mvcApi, mempoolApi, metaletApiV3, unisatApi, metaletApiV4 } from './request' export interface UTXO { txId: string @@ -31,8 +30,17 @@ export type MvcUtxo = { height: number } -const fetchMVCUtxos = async (address: string): Promise => { - return (await mvcApi(`/address/${address}/utxo`)).get() +const fetchMVCUtxos = async (address: string, useUnconfirmed = true): Promise => { + const net = getNet() + let { list = [] } = await metaletApiV4<{ list: MvcUtxo[] }>('/mvc/address/utxo-list').get({ + address, + net, + }) + list = list.filter((utxo) => utxo.value >= 600) + if (!useUnconfirmed) { + list = list.filter((utxo) => utxo.height > 0) + } + return list } export type Utxo = {