Skip to content

Commit

Permalink
feat(erc20): add name to balanceOf result
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Feb 14, 2024
1 parent 95847db commit dd428d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/thirdweb/src/extensions/erc20/read/balanceOf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { decimals } from "./decimals.js";
import { symbol } from "../../common/read/symbol.js";
import { name } from "../../common/read/name.js";
import {
readContract,
type BaseTransactionOptions,
Expand All @@ -15,6 +16,7 @@ type BalanceOfResult = {
decimals: number;
displayValue: string;
symbol: string;
name: string;
};

/**
Expand All @@ -32,19 +34,21 @@ type BalanceOfResult = {
export async function balanceOf(
options: BaseTransactionOptions<BalanceOfParams>,
): Promise<BalanceOfResult> {
const [balanceWei, decimals_, symbol_] = await Promise.all([
const [balanceWei, decimals_, symbol_, name_] = await Promise.all([
readContract({
...options,
method: METHOD,
params: [options.address],
}),
decimals(options),
symbol(options),
name(options),
]);
return {
value: balanceWei,
decimals: decimals_,
displayValue: formatUnits(balanceWei, decimals_),
symbol: symbol_,
name: name_,
};
}

0 comments on commit dd428d5

Please sign in to comment.