mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
type
This commit is contained in:
@@ -35,6 +35,13 @@ import {
|
||||
spendMeTokens,
|
||||
} from 'utils/meTokens';
|
||||
|
||||
type TokenData = {
|
||||
collateral: string;
|
||||
profilePicture: string;
|
||||
symbol: string;
|
||||
tokenAddress: string;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
player: Player;
|
||||
isOwnProfile?: boolean;
|
||||
@@ -73,9 +80,9 @@ const MeTokenSwap: React.FC<SwapProps> = ({
|
||||
const [previewAmount, setPreviewAmount] = useState<string>('0');
|
||||
|
||||
useEffect(() => {
|
||||
if (!metokenAddress || !collateral?.asset) return;
|
||||
if (!metokenAddress || !collateral) return;
|
||||
const getInAndOutTokenData = async () => {
|
||||
await getErc20TokenData(collateral.asset, owner).then((res) => {
|
||||
await getErc20TokenData(collateral, owner).then((res) => {
|
||||
setCollateralTokenData(res);
|
||||
});
|
||||
await getErc20TokenData(metokenAddress, owner).then((res) => {
|
||||
@@ -83,7 +90,7 @@ const MeTokenSwap: React.FC<SwapProps> = ({
|
||||
});
|
||||
};
|
||||
getInAndOutTokenData();
|
||||
}, [metokenAddress, collateral?.asset]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [metokenAddress, collateral]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
handlePreview();
|
||||
@@ -376,7 +383,7 @@ export const PlayerMeTokens: React.FC<Props> = ({
|
||||
editing,
|
||||
}) => {
|
||||
const [meTokenAddress, setMeTokenAddress] = useState<string>('');
|
||||
const [meTokenData, setMeTokenData] = useState<any>('');
|
||||
const [meTokenData, setMeTokenData] = useState<TokenData>();
|
||||
const { provider } = useWeb3();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import erc20Abi from 'contracts/erc20.abi';
|
||||
import FoundryFacetAbi from 'contracts/FoundryFacet.abi';
|
||||
import HubFacetAbi from 'contracts/HubFacet.abi';
|
||||
import MeTokensRegistryABI from 'contracts/meTokensRegistry.abi';
|
||||
import type { Signer } from 'ethers';
|
||||
import { BigNumber, Contract, ethers } from 'ethers';
|
||||
|
||||
export const metokenRegistry = '0x8b91FcF2230ab04A46e2D83aaF062EC1B5AAAa5c';
|
||||
@@ -19,7 +20,11 @@ const { mainnetRPC } = CONFIG;
|
||||
const mainnetProvider = new ethers.providers.JsonRpcProvider(mainnetRPC);
|
||||
|
||||
// Keeping it clean
|
||||
function getContractWithSigner(contractAddress: string, abi: any, signer: any) {
|
||||
function getContractWithSigner(
|
||||
contractAddress: string,
|
||||
abi: any,
|
||||
signer: Signer,
|
||||
) {
|
||||
const contract = new ethers.Contract(contractAddress, abi, signer);
|
||||
const contractWithSigner = contract.connect(signer);
|
||||
return contractWithSigner;
|
||||
@@ -72,7 +77,9 @@ export const getMeTokenInfo = async (tokenAddress: string, owner: string) => {
|
||||
profilePicture:
|
||||
data[0]?.details.profile.pfp || 'https://tinyurl.com/mr29vhmk',
|
||||
tokenAddress,
|
||||
collateral: await hub.getBasicHubInfo(tokenInfo?.hubId),
|
||||
collateral: await hub
|
||||
.getBasicHubInfo(tokenInfo?.hubId)
|
||||
.then((res: { asset: string }) => res.asset),
|
||||
};
|
||||
|
||||
return { ...tokenData };
|
||||
|
||||
Reference in New Issue
Block a user