review modal, new smart contract pointer and network gas fees estimation

This commit is contained in:
2025-10-20 16:45:43 -04:00
parent f543b27620
commit cdbf2a57e6
4 changed files with 232 additions and 14 deletions

View File

@@ -2,7 +2,7 @@
import { useState, useEffect } from 'react';
import { usePublicClient } from 'wagmi';
import chainInfo from '@/app/liquidity-party.json';
import chainInfo from '../../../lmsr-amm/liqp-deployments.json';
import IPartyPlannerABI from '@/contracts/IPartyPlannerABI';
import IPartyPoolABI from '@/contracts/IPartyPoolABI';
import { ERC20ABI } from '@/contracts/ERC20ABI';
@@ -34,7 +34,7 @@ export function useGetAllTokens(offset: number = 0, limit: number = 100) {
// Get chain ID and contract address
const chainId = await publicClient.getChainId();
const address = (chainInfo as Record<string, { IPartyPlanner: string; IPartyPoolViewer: string }>)[chainId.toString()]?.IPartyPlanner;
const address = (chainInfo as Record<string, { v1: { PartyPlanner: string; PartyPoolViewer: string } }>)[chainId.toString()]?.v1?.PartyPlanner;
if (!address) {
setError('IPartyPlanner contract not found for current chain');
@@ -52,6 +52,7 @@ export function useGetAllTokens(offset: number = 0, limit: number = 100) {
setTokens(result);
} catch (err) {
console.error('Error calling getAllTokens:', err);
setError(err instanceof Error ? err.message : 'Failed to fetch tokens');
} finally {
setLoading(false);
@@ -120,7 +121,7 @@ export function useGetPoolsByToken(tokenAddress: `0x${string}` | undefined, offs
// Get chain ID and contract address
const chainId = await publicClient.getChainId();
const address = (chainInfo as Record<string, { IPartyPlanner: string; IPartyPoolViewer: string }>)[chainId.toString()]?.IPartyPlanner;
const address = (chainInfo as Record<string, { v1: { PartyPlanner: string; PartyPoolViewer: string } }>)[chainId.toString()]?.v1?.PartyPlanner;
if (!address) {
setError('IPartyPlanner contract not found for current chain');
@@ -136,8 +137,6 @@ export function useGetPoolsByToken(tokenAddress: `0x${string}` | undefined, offs
args: [tokenAddress, BigInt(offset), BigInt(limit)],
});
console.log('Pools for token', tokenAddress, ':', poolsResult);
// Get the symbol of the originally selected token
const selectedTokenSymbol = await publicClient.readContract({
address: tokenAddress,
@@ -216,7 +215,6 @@ export function useGetPoolsByToken(tokenAddress: `0x${string}` | undefined, offs
}
const availableTokensList = Array.from(tokenRoutesMap.values());
console.log('Available tokens with swap routes:', availableTokensList);
setAvailableTokens(availableTokensList);
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to fetch pools and tokens');