Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getMetaData = async (contract: Contract): Promise<{ name: string; symbol: string }> => {
try {
return {
name: await contract.name(),
symbol: await contract.symbol()
};
} catch {
const alternativeContract = new Contract(
contract.address,
ALT_TOKEN_METADATA_ABI,
contract.provider
);
return {
name: parseBytes32String(await alternativeContract.name()),
symbol: parseBytes32String(await alternativeContract.symbol())
};
}
};
const getMetaData = async (contract: Contract): Promise<{ name: string; symbol: string }> => {
try {
return {
name: await contract.name(),
symbol: await contract.symbol()
};
} catch {
const alternativeContract = new Contract(
contract.address,
ALT_TOKEN_METADATA_ABI,
contract.provider
);
return {
name: parseBytes32String(await alternativeContract.name()),
symbol: parseBytes32String(await alternativeContract.symbol())
};
}
};