diff --git a/api/get-account-meme.ts b/api/get-account-meme.ts index d189968d..f136e45a 100644 --- a/api/get-account-meme.ts +++ b/api/get-account-meme.ts @@ -1,4 +1,4 @@ -import { getAssetsMEMEDetailed } from "../store"; +import { getAssetsMEMEDetail } from "../store"; import getBalance from "./get-balance"; import getPortfolioMEME from "./get-portfolio-meme"; @@ -9,7 +9,7 @@ const getAccountMEME = async () => { const account = await getAccountWallet(); const { accountId } = account; if (accountId) { - const assets = await getAssetsMEMEDetailed(); + const assets = await getAssetsMEMEDetail(); const tokenIds = assets.map((asset) => asset.token_id); const shadowRecords = await getShadowRecords(); const accountBalance = (await account.getAccountBalance()).available; diff --git a/api/get-account.ts b/api/get-account.ts index c3278822..0706f072 100644 --- a/api/get-account.ts +++ b/api/get-account.ts @@ -1,4 +1,4 @@ -import { getAssetsDetailed } from "../store"; +import { getAssetsDetail } from "../store"; import getBalance from "./get-balance"; import getPortfolio from "./get-portfolio"; @@ -10,7 +10,7 @@ const getAccount = async () => { const account = await getAccountWallet(); const { accountId } = account; if (accountId) { - const assets = await getAssetsDetailed(); + const assets = await getAssetsDetail(); const tokenIds = assets.map((asset) => asset.token_id); const shadowRecords = await getShadowRecords(); const accountBalance = (await account.getAccountBalance()).available; diff --git a/api/get-assets-meme.ts b/api/get-assets-meme.ts index 7e31ee20..37540374 100644 --- a/api/get-assets-meme.ts +++ b/api/get-assets-meme.ts @@ -1,5 +1,5 @@ import Decimal from "decimal.js"; -import { getAllMetadata, getAssetsMEMEDetailed, getPrices, getUnitLptAssets } from "../store"; +import { getAllMetadata, getAssetsMEMEDetail, getPrices, getUnitLptAssets } from "../store"; import { shrinkToken } from "../store/helper"; import { lpTokenPrefix } from "../utils/config"; import { IToken, IUnitLptAssetDetail, IMetadata } from "../interfaces/asset"; @@ -40,7 +40,7 @@ const getLptMetadata = (lp_token_details: IUnitLptAssetDetail, priceMap, metadat }; const getAssetsMEME = async () => { - const assets = await getAssetsMEMEDetailed(); + const assets = await getAssetsMEMEDetail(); const token_ids_from_regular = assets .filter((asset) => asset.token_id.indexOf(lpTokenPrefix) === -1) .map((asset) => asset.token_id); diff --git a/api/get-assets.ts b/api/get-assets.ts index 33b31709..48d33b3f 100644 --- a/api/get-assets.ts +++ b/api/get-assets.ts @@ -1,5 +1,5 @@ import Decimal from "decimal.js"; -import { getAllMetadata, getAssetsDetailed, getPrices, getUnitLptAssets } from "../store"; +import { getAllMetadata, getAssetsDetail, getPrices, getUnitLptAssets } from "../store"; import { shrinkToken } from "../store/helper"; import { lpTokenPrefix, blackAssets } from "../utils/config"; import { IToken, IUnitLptAssetDetail, IMetadata } from "../interfaces/asset"; @@ -40,7 +40,7 @@ const getLptMetadata = (lp_token_details: IUnitLptAssetDetail, priceMap, metadat }; const getAssets = async () => { - const assets_pending = await getAssetsDetailed(); + const assets_pending = await getAssetsDetail(); const assets = assets_pending.filter((asset) => !blackAssets.includes(asset.token_id)); const token_ids_from_regular = assets .filter((asset) => asset.token_id.indexOf(lpTokenPrefix) === -1) diff --git a/interfaces/burrow.ts b/interfaces/burrow.ts index 763e9005..d51ea1a0 100644 --- a/interfaces/burrow.ts +++ b/interfaces/burrow.ts @@ -52,7 +52,8 @@ export type IViewReturnType = | IMarginConfig | IMarginAccountDetailedView | IPoolDcl[] - | IQuoteResult; + | IQuoteResult + | IAssetDetailed[]; export interface IBurrow { selector: WalletSelector; diff --git a/interfaces/contract-methods.ts b/interfaces/contract-methods.ts index 9df4dcc6..6278f818 100644 --- a/interfaces/contract-methods.ts +++ b/interfaces/contract-methods.ts @@ -8,6 +8,7 @@ export enum ViewMethodsLogic { get_asset, get_assets, get_assets_paged, + get_assets_paged_detailed, // config get_config, get_margin_config, diff --git a/next.config.js b/next.config.js index 3adc3e67..e6e7ffd0 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ module.exports = { - reactStrictMode: true, - trailingSlash: true, + reactStrictMode: false, + trailingSlash: false, eslint: { ignoreDuringBuilds: true, }, diff --git a/store/accounts.ts b/store/accounts.ts index cf3ad936..c3db2e2c 100644 --- a/store/accounts.ts +++ b/store/accounts.ts @@ -1,43 +1,5 @@ -import { IAccount, IAccountDetailed, ViewMethodsLogic } from "../interfaces"; import { getBurrow } from "../utils"; -export const getAccounts = async (): Promise => { - const { view, logicContract } = await getBurrow(); - - const accounts: IAccount[] = (await view( - logicContract, - ViewMethodsLogic[ViewMethodsLogic.get_accounts_paged], - )) as IAccount[]; - - return accounts; -}; - -export const getAccountDetailed = async (account_id: string): Promise => { - if (!account_id) return null; - - const { view, logicContract } = await getBurrow(); - - const accountDetailed: IAccountDetailed = (await view( - logicContract, - ViewMethodsLogic[ViewMethodsLogic.get_account], - { - account_id, - }, - )) as IAccountDetailed; - - return accountDetailed; -}; - -export const getAccountsDetailed = async (): Promise => { - const accounts: IAccount[] = await getAccounts(); - - const result: IAccountDetailed[] = ( - await Promise.all(accounts.map((account) => getAccountDetailed(account.account_id))) - ).filter((account): account is IAccountDetailed => !!account); - - return result; -}; - export const getAccount = async () => { const { account } = await getBurrow(); return account; diff --git a/store/assets.ts b/store/assets.ts index a125e24b..60084880 100644 --- a/store/assets.ts +++ b/store/assets.ts @@ -22,6 +22,13 @@ export const getAssets = async (): Promise => { token_id, })); }; +export const getAssetsDetail = async (): Promise => { + const { view, logicContract } = await getBurrow(); + return (await view( + logicContract, + ViewMethodsLogic[ViewMethodsLogic.get_assets_paged_detailed], + )) as IAssetDetailed[]; +}; export const getAssetsMEME = async (): Promise => { const { view, logicMEMEContract, pythContract } = await getBurrow(); @@ -35,45 +42,12 @@ export const getAssetsMEME = async (): Promise => { token_id, })); }; - -export const getAssetDetailed = async (token_id: string): Promise => { - const { view, logicContract } = await getBurrow(); - const assetDetails: IAssetDetailed = (await view( - logicContract, - ViewMethodsLogic[ViewMethodsLogic.get_asset], - { - token_id, - }, - )) as IAssetDetailed; - - return assetDetails; -}; - -export const getAssetMEMEDetailed = async (token_id: string): Promise => { +export const getAssetsMEMEDetail = async (): Promise => { const { view, logicMEMEContract } = await getBurrow(); - const assetDetails: IAssetDetailed = (await view( + return (await view( logicMEMEContract, - ViewMethodsLogic[ViewMethodsLogic.get_asset], - { - token_id, - }, - )) as IAssetDetailed; - - return assetDetails; -}; - -export const getAssetsDetailed = async (): Promise => { - const assets: IAssetEntry[] = await getAssets(); - const detailedAssets = await Promise.all(assets.map((asset) => getAssetDetailed(asset.token_id))); - return detailedAssets; -}; - -export const getAssetsMEMEDetailed = async (): Promise => { - const assets: IAssetEntry[] = await getAssetsMEME(); - const detailedAssets = await Promise.all( - assets.map((asset) => getAssetMEMEDetailed(asset.token_id)), - ); - return detailedAssets; + ViewMethodsLogic[ViewMethodsLogic.get_assets_paged_detailed], + )) as IAssetDetailed[]; }; export const getUnitLptAssets = async (pool_ids: number[]): Promise => {