* FIX: getBlocks optional params * v2.3.0 - new minor version for mempool-js - Add support for Bisq API - Add support for Liquid API - Change the main object to export network objects. - Change README.md instructions. Co-authored-by: softsimon <softsimon@users.noreply.github.com>
38 lines
1001 B
TypeScript
38 lines
1001 B
TypeScript
import { AxiosInstance } from 'axios';
|
|
import { Asset, AssetsInstance } from '../../interfaces/liquid/assets';
|
|
|
|
export const useAssets = (api: AxiosInstance): AssetsInstance => {
|
|
const getAsset = async (params: { asset_id: string }) => {
|
|
const { data } = await api.get<Asset>(`/asset/${params.asset_id}`);
|
|
return data;
|
|
};
|
|
|
|
const getAssetTxs = async (params: {
|
|
asset_id: string;
|
|
is_mempool: boolean;
|
|
}) => {
|
|
const paramsMempools = params.is_mempool === true ? '/mempool' : '/chain';
|
|
const { data } = await api.get<Asset>(
|
|
`/asset/${params.asset_id}/txs${paramsMempools}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
const getAssetSupply = async (params: {
|
|
asset_id: string;
|
|
decimal: boolean;
|
|
}) => {
|
|
const paramDecimal = params.decimal === true ? '/decimal' : '';
|
|
const { data } = await api.get<Asset>(
|
|
`/asset/${params.asset_id}/supply${paramDecimal}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
return {
|
|
getAsset,
|
|
getAssetTxs,
|
|
getAssetSupply,
|
|
};
|
|
};
|